Skip to content

Commit

Permalink
feat(orchestrator): make workflow last run status as link to the work…
Browse files Browse the repository at this point in the history
…flow 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
  • Loading branch information
yzhao583 authored Apr 10, 2024
1 parent 0ccdeef commit fc2f94e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const WorkflowDefinitionDetailsCard = ({
status={
formattedWorkflowOverview?.lastRunStatus as ProcessInstanceStateValues
}
lastRunId={formattedWorkflowOverview?.lastRunId}
/>
) : (
VALUE_UNAVAILABLE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import React from 'react';

import { Link } from '@backstage/core-components';
import { useRouteRef } from '@backstage/core-plugin-api';

import DotIcon from '@material-ui/icons/FiberManualRecord';

import {
Expand All @@ -9,13 +12,17 @@ import {

import { VALUE_UNAVAILABLE } from '../constants';
import { useWorkflowInstanceStateColors } from '../hooks/useWorkflowInstanceStatusColors';
import { workflowInstanceRouteRef } from '../routes';

export const WorkflowInstanceStatusIndicator = ({
status,
lastRunId,
}: {
status?: ProcessInstanceStateValues;
lastRunId?: string;
}) => {
const iconColor = useWorkflowInstanceStateColors(status);
const workflowInstanceLink = useRouteRef(workflowInstanceRouteRef);

if (!status) {
return VALUE_UNAVAILABLE;
Expand All @@ -24,7 +31,13 @@ export const WorkflowInstanceStatusIndicator = ({
return (
<>
<DotIcon style={{ fontSize: '0.75rem' }} className={iconColor} />{' '}
{capitalize(status)}
{lastRunId ? (
<Link to={workflowInstanceLink({ instanceId: lastRunId })}>
{capitalize(status)}
</Link>
) : (
<>{capitalize(status)}</>
)}
</>
);
};
4 changes: 3 additions & 1 deletion plugins/orchestrator/src/components/WorkflowsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,11 @@ export const WorkflowsTable = ({ items }: WorkflowsTableProps) => {
title: 'Last run status',
field: 'lastRunStatus',
render: rowData =>
rowData.lastRunStatus !== VALUE_UNAVAILABLE ? (
rowData.lastRunStatus !== VALUE_UNAVAILABLE &&
rowData.lastRunId !== VALUE_UNAVAILABLE ? (
<WorkflowInstanceStatusIndicator
status={rowData.lastRunStatus as ProcessInstanceStateValues}
lastRunId={rowData.lastRunId}
/>
) : (
VALUE_UNAVAILABLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface FormattedWorkflowOverview {
readonly name: string;
readonly lastTriggered: string;
readonly lastRunStatus: string;
readonly lastRunId: string;
readonly category: string;
readonly avgDuration: string;
readonly description: string;
Expand All @@ -34,6 +35,7 @@ const WorkflowOverviewFormatter: DataFormatter<
? moment(data.lastTriggeredMs).toDate().toLocaleString()
: VALUE_UNAVAILABLE,
lastRunStatus: data.lastRunStatus ?? VALUE_UNAVAILABLE,
lastRunId: data.lastRunId ?? VALUE_UNAVAILABLE,
category: data.category ?? VALUE_UNAVAILABLE,
avgDuration: data.avgDurationMs
? formatDuration(data.avgDurationMs)
Expand Down

0 comments on commit fc2f94e

Please sign in to comment.