Skip to content

Commit a9ab22e

Browse files
authored
fix(orchestrator): fix search and filter for 'running' and 'failed' (#978)
Signed-off-by: Lior Soffer <liorsoffer1@gmail.com>
1 parent 18bda47 commit a9ab22e

4 files changed

Lines changed: 31 additions & 23 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@red-hat-developer-hub/backstage-plugin-orchestrator': patch
3+
---
4+
5+
fix search and filter for "running" and "failed"

workspaces/orchestrator/plugins/orchestrator/src/components/OrchestratorPage/WorkflowRunsTabContent.tsx

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,13 @@ import { mapProcessInstanceToDetails } from '../WorkflowInstancePage/WorkflowIns
5151
import { WorkflowInstanceStatusIndicator } from '../WorkflowInstanceStatusIndicator';
5252
import { WorkflowRunDetail } from '../WorkflowRunDetail';
5353

54-
const makeSelectItemsFromProcessInstanceValues = () =>
55-
[
56-
ProcessInstanceStatusDTO.Active,
57-
ProcessInstanceStatusDTO.Error,
58-
ProcessInstanceStatusDTO.Completed,
59-
ProcessInstanceStatusDTO.Aborted,
60-
ProcessInstanceStatusDTO.Suspended,
61-
].map(
62-
(status): SelectItem => ({
63-
label: capitalize(status),
64-
value: status,
65-
}),
66-
);
54+
const makeSelectItemsFromProcessInstanceValues = (): SelectItem[] => [
55+
{ label: 'Running', value: ProcessInstanceStatusDTO.Active },
56+
{ label: 'Failed', value: ProcessInstanceStatusDTO.Error },
57+
{ label: 'Completed', value: ProcessInstanceStatusDTO.Completed },
58+
{ label: 'Aborted', value: ProcessInstanceStatusDTO.Aborted },
59+
{ label: 'Suspended', value: ProcessInstanceStatusDTO.Suspended },
60+
];
6761

6862
const statuses = makeSelectItemsFromProcessInstanceValues();
6963
const started = ['Today', 'Yesterday', 'Last 7 days', 'This month'].map(

workspaces/orchestrator/plugins/orchestrator/src/components/OrchestratorPage/WorkflowsTable.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import {
3737
WorkflowOverviewDTO,
3838
} from '@red-hat-developer-hub/backstage-plugin-orchestrator-common';
3939

40-
import { VALUE_UNAVAILABLE } from '../../constants';
4140
import WorkflowOverviewFormatter, {
4241
FormattedWorkflowOverview,
4342
} from '../../dataFormatters/WorkflowOverviewFormatter';
@@ -257,22 +256,25 @@ export const WorkflowsTable = ({ items }: WorkflowsTableProps) => {
257256
{
258257
title: 'Last run status',
259258
field: 'lastRunStatus',
260-
render: rowData =>
261-
rowData.lastRunStatus !== VALUE_UNAVAILABLE &&
262-
rowData.lastRunId !== VALUE_UNAVAILABLE ? (
259+
render: rowData => {
260+
const originalRawData = items.find(
261+
item => item.workflowId === rowData.id,
262+
);
263+
return (
263264
<WorkflowInstanceStatusIndicator
264-
status={rowData.lastRunStatus as ProcessInstanceStatusDTO}
265+
status={
266+
originalRawData?.lastRunStatus as ProcessInstanceStatusDTO
267+
}
265268
lastRunId={
266269
canViewInstance(rowData.id) ? rowData.lastRunId : undefined
267270
}
268271
/>
269-
) : (
270-
VALUE_UNAVAILABLE
271-
),
272+
);
273+
},
272274
},
273275
{ title: 'Description', field: 'description', minWidth: '25vw' },
274276
],
275-
[canViewInstance, canViewWorkflow, definitionLink],
277+
[canViewInstance, canViewWorkflow, definitionLink, items],
276278
);
277279

278280
const options = useMemo<TableProps['options']>(

workspaces/orchestrator/plugins/orchestrator/src/dataFormatters/WorkflowOverviewFormatter.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ const formatIsAvailable = (availablity: boolean | undefined) => {
4242
return VALUE_UNAVAILABLE;
4343
};
4444

45+
const formatLastRunStatus = (lastRunStatus: string | undefined) => {
46+
if (lastRunStatus === 'ERROR') return 'FAILED';
47+
else if (lastRunStatus === 'ACTIVE') return 'RUNNING';
48+
else if (lastRunStatus) return lastRunStatus?.toString();
49+
return VALUE_UNAVAILABLE;
50+
};
51+
4552
const WorkflowOverviewFormatter: DataFormatter<
4653
WorkflowOverviewDTO,
4754
FormattedWorkflowOverview
@@ -53,7 +60,7 @@ const WorkflowOverviewFormatter: DataFormatter<
5360
lastTriggered: data.lastTriggeredMs
5461
? moment(data.lastTriggeredMs).toDate().toLocaleString()
5562
: VALUE_UNAVAILABLE,
56-
lastRunStatus: data.lastRunStatus?.toString() ?? VALUE_UNAVAILABLE,
63+
lastRunStatus: formatLastRunStatus(data.lastRunStatus),
5764
lastRunId: data.lastRunId ?? VALUE_UNAVAILABLE,
5865
category: data.category ?? VALUE_UNAVAILABLE,
5966
description: data.description ?? VALUE_UNAVAILABLE,

0 commit comments

Comments
 (0)