Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipeline task node details link to execution #2858

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import React from 'react';

import { Stack, StackItem } from '@patternfly/react-core';
import { Grid, GridItem, Stack, StackItem } from '@patternfly/react-core';
import { Value as ProtoValue } from 'google-protobuf/google/protobuf/struct_pb';

import { Link } from 'react-router-dom';
import { Execution } from '~/third_party/mlmd';
import TaskDetailsInputOutput from '~/concepts/pipelines/content/pipelinesDetails/taskDetails/TaskDetailsInputOutput';
import { PipelineTask, PipelineTaskParam } from '~/concepts/pipelines/topology';
import { ExecutionDetailsPropertiesValueCode } from '~/pages/pipelines/global/experiments/executions/details/ExecutionDetailsPropertiesValue';
import { InputDefinitionParameterType } from '~/concepts/pipelines/kfTypes';
import { NoValue } from '~/components/NoValue';
import { executionDetailsRoute } from '~/routes';
import { usePipelinesAPI } from '~/concepts/pipelines/context';
import { SupportedArea, useIsAreaAvailable } from '~/concepts/areas';

type SelectedNodeInputOutputTabProps = {
task: PipelineTask;
Expand All @@ -19,6 +23,17 @@ const SelectedNodeInputOutputTab: React.FC<SelectedNodeInputOutputTabProps> = ({
task,
execution,
}) => {
const { namespace } = usePipelinesAPI();
const isExperimentsAvailable = useIsAreaAvailable(SupportedArea.PIPELINE_EXPERIMENTS).status;

const executionDisplayName = React.useMemo(
() =>
execution?.customPropertiesMap.find(
([customPropKey]) => customPropKey === 'display_name',
)?.[1].stringValue || '(No name)',
Gkrumbach07 marked this conversation as resolved.
Show resolved Hide resolved
[execution?.customPropertiesMap],
);

const getExecutionFieldsMap = React.useCallback(
(key: string) =>
execution?.customPropertiesMap.find(([customPropKey]) => customPropKey === key)?.[1]
Expand Down Expand Up @@ -94,6 +109,20 @@ const SelectedNodeInputOutputTab: React.FC<SelectedNodeInputOutputTabProps> = ({

return (
<Stack hasGutter>
{isExperimentsAvailable && execution?.id && (
<StackItem data-testid="execution-name">
<Grid hasGutter>
<GridItem span={6}>
<b>Execution name</b>
</GridItem>
<GridItem span={6}>
<Link to={executionDetailsRoute(namespace, execution.id.toString())}>
{executionDisplayName}
</Link>
</GridItem>
</Grid>
</StackItem>
)}
{task.inputs && (
<StackItem>
<TaskDetailsInputOutput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';

import { BrowserRouter } from 'react-router-dom';
import SelectedNodeInputOutputTab from '~/concepts/pipelines/content/pipelinesDetails/pipelineRun/SelectedNodeInputOutputTab';
import { InputDefinitionParameterType } from '~/concepts/pipelines/kfTypes';
import { Execution } from '~/third_party/mlmd';
Expand All @@ -11,7 +12,52 @@ jest.mock('~/components/MaxHeightCodeEditor', () => ({
MaxHeightCodeEditor: ({ code }: { code: string }) => JSON.stringify(JSON.parse(code)),
}));

jest.mock('~/concepts/areas/useIsAreaAvailable', () => () => ({
status: true,
featureFlags: {},
reliantAreas: {},
requiredComponents: {},
requiredCapabilities: {},
customCondition: jest.fn(),
}));

describe('SelectedNodeInputOutputTab', () => {
it('renders execution name', async () => {
render(
<BrowserRouter>
<SelectedNodeInputOutputTab
task={{
type: 'groupTask',
name: 'task-1',
inputs: {
params: [],
},
}}
execution={
{
id: 1,
customPropertiesMap: [
[
'display_name',
{
stringValue: 'task-1',
},
'inputs',
{
structValue: {
fieldsMap: [],
},
},
],
],
} as unknown as Execution.AsObject
}
/>
</BrowserRouter>,
);
expect(screen.getByText('task-1')).toBeVisible();
});

it('renders execution values for input parameters', async () => {
render(
<SelectedNodeInputOutputTab
Expand Down
Loading