Skip to content

Commit

Permalink
Pipeline task node details link to execution
Browse files Browse the repository at this point in the history
  • Loading branch information
dpanshug committed May 30, 2024
1 parent 2dc72ad commit 98a73e2
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
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';

type SelectedNodeInputOutputTabProps = {
task: PipelineTask;
Expand All @@ -19,6 +22,16 @@ const SelectedNodeInputOutputTab: React.FC<SelectedNodeInputOutputTabProps> = ({
task,
execution,
}) => {
const { namespace } = usePipelinesAPI();

const getExecutionDisplayNameFromObject = React.useCallback(
() =>

Check warning on line 28 in frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/SelectedNodeInputOutputTab.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/SelectedNodeInputOutputTab.tsx#L28

Added line #L28 was not covered by tests
execution?.customPropertiesMap.find(
([customPropKey]) => customPropKey === 'display_name',
)?.[1].stringValue || '(No name)',

Check warning on line 31 in frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/SelectedNodeInputOutputTab.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/SelectedNodeInputOutputTab.tsx#L31

Added line #L31 was not covered by tests
[execution?.customPropertiesMap],
);

const getExecutionFieldsMap = React.useCallback(
(key: string) =>
execution?.customPropertiesMap.find(([customPropKey]) => customPropKey === key)?.[1]
Expand Down Expand Up @@ -88,12 +101,26 @@ const SelectedNodeInputOutputTab: React.FC<SelectedNodeInputOutputTabProps> = ({
[getExecutionValueFromInputType],
);

if (!task.inputs && !task.outputs) {
if (!task.inputs && !task.outputs && !execution) {
return <>No content</>;
}

return (
<Stack hasGutter>
{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())}>
{getExecutionDisplayNameFromObject()}
</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 @@ -12,6 +13,33 @@ jest.mock('~/components/MaxHeightCodeEditor', () => ({
}));

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

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

0 comments on commit 98a73e2

Please sign in to comment.