Skip to content

Commit fc2f94e

Browse files
authored
feat(orchestrator): make workflow last run status as link to the workflow last run details page (#1488)
* make workflow last run status as link to the workflow last run details page * Fix lint issue for WorkflowsTable component * Make the WorkflowInstanceStatusIndicator component as a link when the lastRunId is passed from parent component
1 parent 0ccdeef commit fc2f94e

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

plugins/orchestrator/src/components/WorkflowDefinitionViewerPage/WorkflowDefinitionDetailsCard.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ const WorkflowDefinitionDetailsCard = ({
6262
status={
6363
formattedWorkflowOverview?.lastRunStatus as ProcessInstanceStateValues
6464
}
65+
lastRunId={formattedWorkflowOverview?.lastRunId}
6566
/>
6667
) : (
6768
VALUE_UNAVAILABLE

plugins/orchestrator/src/components/WorkflowInstanceStatusIndicator.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import React from 'react';
22

3+
import { Link } from '@backstage/core-components';
4+
import { useRouteRef } from '@backstage/core-plugin-api';
5+
36
import DotIcon from '@material-ui/icons/FiberManualRecord';
47

58
import {
@@ -9,13 +12,17 @@ import {
912

1013
import { VALUE_UNAVAILABLE } from '../constants';
1114
import { useWorkflowInstanceStateColors } from '../hooks/useWorkflowInstanceStatusColors';
15+
import { workflowInstanceRouteRef } from '../routes';
1216

1317
export const WorkflowInstanceStatusIndicator = ({
1418
status,
19+
lastRunId,
1520
}: {
1621
status?: ProcessInstanceStateValues;
22+
lastRunId?: string;
1723
}) => {
1824
const iconColor = useWorkflowInstanceStateColors(status);
25+
const workflowInstanceLink = useRouteRef(workflowInstanceRouteRef);
1926

2027
if (!status) {
2128
return VALUE_UNAVAILABLE;
@@ -24,7 +31,13 @@ export const WorkflowInstanceStatusIndicator = ({
2431
return (
2532
<>
2633
<DotIcon style={{ fontSize: '0.75rem' }} className={iconColor} />{' '}
27-
{capitalize(status)}
34+
{lastRunId ? (
35+
<Link to={workflowInstanceLink({ instanceId: lastRunId })}>
36+
{capitalize(status)}
37+
</Link>
38+
) : (
39+
<>{capitalize(status)}</>
40+
)}
2841
</>
2942
);
3043
};

plugins/orchestrator/src/components/WorkflowsTable.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,11 @@ export const WorkflowsTable = ({ items }: WorkflowsTableProps) => {
104104
title: 'Last run status',
105105
field: 'lastRunStatus',
106106
render: rowData =>
107-
rowData.lastRunStatus !== VALUE_UNAVAILABLE ? (
107+
rowData.lastRunStatus !== VALUE_UNAVAILABLE &&
108+
rowData.lastRunId !== VALUE_UNAVAILABLE ? (
108109
<WorkflowInstanceStatusIndicator
109110
status={rowData.lastRunStatus as ProcessInstanceStateValues}
111+
lastRunId={rowData.lastRunId}
110112
/>
111113
) : (
112114
VALUE_UNAVAILABLE

plugins/orchestrator/src/dataFormatters/WorkflowOverviewFormatter.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface FormattedWorkflowOverview {
1313
readonly name: string;
1414
readonly lastTriggered: string;
1515
readonly lastRunStatus: string;
16+
readonly lastRunId: string;
1617
readonly category: string;
1718
readonly avgDuration: string;
1819
readonly description: string;
@@ -34,6 +35,7 @@ const WorkflowOverviewFormatter: DataFormatter<
3435
? moment(data.lastTriggeredMs).toDate().toLocaleString()
3536
: VALUE_UNAVAILABLE,
3637
lastRunStatus: data.lastRunStatus ?? VALUE_UNAVAILABLE,
38+
lastRunId: data.lastRunId ?? VALUE_UNAVAILABLE,
3739
category: data.category ?? VALUE_UNAVAILABLE,
3840
avgDuration: data.avgDurationMs
3941
? formatDuration(data.avgDurationMs)

0 commit comments

Comments
 (0)