Skip to content

Commit b513f85

Browse files
authored
Show archived status (#707)
* Show archived status * Allow icons with Archived
1 parent 7f0e9cf commit b513f85

File tree

10 files changed

+90
-35
lines changed

10 files changed

+90
-35
lines changed

src/views/shared/workflow-status-tag/__tests__/workflow-status-tag.test.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ describe('WorkflowStatusTag', () => {
2323
workflowStatus: WorkflowStatus;
2424
text: string;
2525
link?: string;
26+
isArchived?: boolean;
2627
}> = [
2728
{
2829
name: 'should render Running correctly',
@@ -65,17 +66,26 @@ describe('WorkflowStatusTag', () => {
6566
text: 'Continued As New',
6667
link: 'mock_continued_workflow_link',
6768
},
69+
{
70+
name: 'should render Archived correctly',
71+
workflowStatus: 'WORKFLOW_EXECUTION_CLOSE_STATUS_INVALID',
72+
isArchived: true,
73+
text: 'Archived',
74+
},
6875
];
6976

7077
tests.forEach((test) => {
7178
it(test.name, () => {
7279
render(
73-
<WorkflowStatusTag status={test.workflowStatus} link={test.link} />
80+
<WorkflowStatusTag
81+
status={test.workflowStatus}
82+
link={test.link}
83+
isArchived={test.isArchived}
84+
/>
7485
);
7586

7687
const tag = screen.getByText(test.text);
7788
expect(tag).toBeInTheDocument();
78-
7989
expect(screen.getByText('Mock icon start')).toBeInTheDocument();
8090
expect(screen.getByText('Mock icon end')).toBeInTheDocument();
8191

src/views/shared/workflow-status-tag/workflow-status-tag-icon/workflow-status-tag-icon.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { type Props } from './workflow-status-tag-icon.types';
88
export default function WorkflowStatusTagIcon(props: Props) {
99
switch (props.kind) {
1010
case 'start':
11+
if (props.isArchived) return null;
1112
if (props.status === WORKFLOW_STATUSES.running) {
1213
return <styled.Spinner aria-label="running-spinner" />;
1314
}

src/views/shared/workflow-status-tag/workflow-status-tag-icon/workflow-status-tag-icon.types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ export type Props = {
66
kind: WorkflowStatusTagIconKind;
77
status: WorkflowStatus;
88
link?: string;
9+
isArchived?: boolean;
910
};

src/views/shared/workflow-status-tag/workflow-status-tag.styles.ts

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,31 @@ export function overrides(args: OverridesArgs) {
1111
Root: {
1212
style: ({ $theme }: { $theme: Theme }): StyleObject => {
1313
let tagColor: string;
14-
switch (args.status) {
15-
case WORKFLOW_STATUSES.running:
16-
tagColor = $theme.colors.accent100;
17-
break;
18-
case WORKFLOW_STATUSES.completed:
19-
tagColor = $theme.colors.positive100;
20-
break;
21-
case WORKFLOW_STATUSES.failed:
22-
case WORKFLOW_STATUSES.timedOut:
23-
tagColor = $theme.colors.negative100;
24-
break;
25-
case WORKFLOW_STATUSES.canceled:
26-
case WORKFLOW_STATUSES.terminated:
27-
tagColor = $theme.colors.warning100;
28-
break;
29-
case WORKFLOW_STATUSES.continuedAsNew:
30-
tagColor = $theme.colors.primary100;
31-
break;
32-
default:
33-
tagColor = $theme.colors.negative100;
34-
break;
14+
if (args.isArchived) {
15+
tagColor = $theme.colors.warning100;
16+
} else {
17+
switch (args.status) {
18+
case WORKFLOW_STATUSES.running:
19+
tagColor = $theme.colors.accent100;
20+
break;
21+
case WORKFLOW_STATUSES.completed:
22+
tagColor = $theme.colors.positive100;
23+
break;
24+
case WORKFLOW_STATUSES.failed:
25+
case WORKFLOW_STATUSES.timedOut:
26+
tagColor = $theme.colors.negative100;
27+
break;
28+
case WORKFLOW_STATUSES.canceled:
29+
case WORKFLOW_STATUSES.terminated:
30+
tagColor = $theme.colors.warning100;
31+
break;
32+
case WORKFLOW_STATUSES.continuedAsNew:
33+
tagColor = $theme.colors.primary100;
34+
break;
35+
default:
36+
tagColor = $theme.colors.negative100;
37+
break;
38+
}
3539
}
3640

3741
return {

src/views/shared/workflow-status-tag/workflow-status-tag.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ export default function WorkflowStatusTag(props: Props) {
1313
<Tag
1414
variant={VARIANT.solid}
1515
closeable={false}
16-
overrides={overrides({ status: props.status, link: props.link }).tag}
16+
overrides={
17+
overrides({
18+
status: props.status,
19+
link: props.link,
20+
isArchived: props.isArchived,
21+
}).tag
22+
}
1723
// To render hover & focus effects for the tag, we need to pass an onClick hander
1824
// However, since we are already passing a link through overrides, we pass a no-op here
1925
{...(props.link && {
@@ -24,12 +30,14 @@ export default function WorkflowStatusTag(props: Props) {
2430
kind="start"
2531
status={props.status}
2632
link={props.link}
33+
isArchived={props.isArchived}
2734
/>
28-
{WORKFLOW_STATUS_NAMES[props.status]}
35+
{props.isArchived ? 'Archived' : WORKFLOW_STATUS_NAMES[props.status]}
2936
<WorkflowStatusTagIcon
3037
kind="end"
3138
status={props.status}
3239
link={props.link}
40+
isArchived={props.isArchived}
3341
/>
3442
</Tag>
3543
);

src/views/shared/workflow-status-tag/workflow-status-tag.types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ export type WorkflowStatus = WorkflowExecutionCloseStatus;
55
export type Props = {
66
status: WorkflowStatus;
77
link?: string;
8+
isArchived?: boolean;
89
};
910

1011
export type OverridesArgs = {
1112
status: WorkflowStatus;
1213
link?: string;
14+
isArchived?: boolean;
1315
};

src/views/workflow-page/helpers/__tests__/get-workflow-status-tag-props.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,11 @@ describe('getWorkflowStatusTagProps', () => {
133133
status: 'WORKFLOW_EXECUTION_CLOSE_STATUS_INVALID',
134134
});
135135
});
136+
137+
it('should return INVALID status and isArchived true for archived workflows', () => {
138+
expect(getWorkflowStatusTagProps(undefined, undefined, true)).toEqual({
139+
status: 'WORKFLOW_EXECUTION_CLOSE_STATUS_INVALID',
140+
isArchived: true,
141+
});
142+
});
136143
});

src/views/workflow-page/helpers/get-workflow-status-tag-props.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,15 @@ const getWorkflowStatusTagProps = (
3030
HistoryEvent,
3131
'attributes' | 'workflowExecutionContinuedAsNewEventAttributes'
3232
> | null,
33-
workflowInfo?: { cluster: string; workflowId: string; domain: string }
34-
): Pick<WorkflowStatusTagProps, 'status' | 'link'> => {
33+
workflowInfo?: { cluster: string; workflowId: string; domain: string },
34+
isArchived?: boolean
35+
): Pick<WorkflowStatusTagProps, 'status' | 'link' | 'isArchived'> => {
36+
if (isArchived)
37+
return {
38+
status: 'WORKFLOW_EXECUTION_CLOSE_STATUS_INVALID',
39+
isArchived: true,
40+
};
41+
3542
if (!lastEvent || !lastEvent.attributes)
3643
return { status: 'WORKFLOW_EXECUTION_CLOSE_STATUS_INVALID' };
3744

src/views/workflow-page/workflow-page-status-tag/workflow-page-status-tag.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@ export default function WorkflowPageStatusTag() {
2828
return null;
2929
}
3030

31-
const closeEvent = workflowDetails.workflowExecutionInfo?.closeEvent;
31+
const { closeEvent, isArchived } =
32+
workflowDetails.workflowExecutionInfo || {};
3233

3334
return (
34-
<WorkflowStatusTag {...getWorkflowStatusTagProps(closeEvent, params)} />
35+
<WorkflowStatusTag
36+
{...getWorkflowStatusTagProps(closeEvent, params, isArchived)}
37+
/>
3538
);
3639
}

src/views/workflow-summary-tab/config/workflow-summary-tab-details.config.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,18 @@ const workflowSummaryTabDetailsConfig: WorkflowSummaryTabDetailsConfig[] = [
1111
{
1212
key: 'status',
1313
getLabel: () => 'Status',
14-
valueComponent: ({ closeEvent, decodedPageUrlParams }) =>
14+
valueComponent: ({ closeEvent, decodedPageUrlParams, workflowDetails }) =>
1515
createElement(
1616
WorkflowStatusTag,
17-
getWorkflowStatusTagProps(closeEvent, {
18-
cluster: decodedPageUrlParams.cluster,
19-
workflowId: decodedPageUrlParams.workflowId,
20-
domain: decodedPageUrlParams.domain,
21-
})
17+
getWorkflowStatusTagProps(
18+
closeEvent,
19+
{
20+
cluster: decodedPageUrlParams.cluster,
21+
workflowId: decodedPageUrlParams.workflowId,
22+
domain: decodedPageUrlParams.domain,
23+
},
24+
workflowDetails.workflowExecutionInfo?.isArchived
25+
)
2226
),
2327
},
2428
{
@@ -80,6 +84,10 @@ const workflowSummaryTabDetailsConfig: WorkflowSummaryTabDetailsConfig[] = [
8084
: '-'
8185
);
8286
},
87+
hide: ({ workflowDetails }) => {
88+
//hide it on archived events as the value is not available
89+
return Boolean(workflowDetails.workflowExecutionInfo?.isArchived);
90+
},
8391
},
8492
{
8593
key: 'cronSchedule',
@@ -94,6 +102,10 @@ const workflowSummaryTabDetailsConfig: WorkflowSummaryTabDetailsConfig[] = [
94102
getLabel: () => 'History events',
95103
valueComponent: ({ workflowDetails }) =>
96104
workflowDetails.workflowExecutionInfo?.historyLength,
105+
hide: ({ workflowDetails }) => {
106+
//hide it on archived events as the value is not available
107+
return Boolean(workflowDetails.workflowExecutionInfo?.isArchived);
108+
},
97109
},
98110
{
99111
key: 'taskList',

0 commit comments

Comments
 (0)