Skip to content

Commit 04ca7f3

Browse files
authored
fix(orchestrator): Add Workflow Status to WorkflowsTable (#564)
Signed-off-by: Lior Soffer <liorsoffer1@gmail.com>
1 parent f406790 commit 04ca7f3

4 files changed

Lines changed: 78 additions & 7 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+
Add Workflow Status to WorkflowsTable

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

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 The Backstage Authors
2+
* Copyright Red Hat, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,15 +13,19 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
import React, { useCallback, useEffect, useMemo, useState } from 'react';
1718
import { useNavigate } from 'react-router-dom';
1819

1920
import { Link, TableColumn, TableProps } from '@backstage/core-components';
2021
import { useRouteRef } from '@backstage/core-plugin-api';
2122
import { usePermission } from '@backstage/plugin-permission-react';
2223

24+
import { Box, makeStyles, Tooltip } from '@material-ui/core';
2325
import FormatListBulleted from '@material-ui/icons/FormatListBulleted';
2426
import PlayArrow from '@material-ui/icons/PlayArrow';
27+
import TaskAltOutlinedIcon from '@mui/icons-material/TaskAltOutlined';
28+
import WarningAmberOutlinedIcon from '@mui/icons-material/WarningAmberOutlined';
2529

2630
import {
2731
capitalize,
@@ -33,7 +37,7 @@ import {
3337
WorkflowOverviewDTO,
3438
} from '@red-hat-developer-hub/backstage-plugin-orchestrator-common';
3539

36-
import { VALUE_UNAVAILABLE } from '../constants';
40+
import { AVAILABLE, UNAVAILABLE, VALUE_UNAVAILABLE } from '../constants';
3741
import WorkflowOverviewFormatter, {
3842
FormattedWorkflowOverview,
3943
} from '../dataFormatters/WorkflowOverviewFormatter';
@@ -97,7 +101,23 @@ const usePermittedToViewBatch = (
97101
};
98102
};
99103

104+
const useStyles = makeStyles(theme => ({
105+
warning: {
106+
color: theme.palette.warning.main,
107+
},
108+
error: {
109+
color: theme.palette.error.main,
110+
},
111+
success: {
112+
color: theme.palette.success.main,
113+
},
114+
info: {
115+
color: theme.palette.primary.main,
116+
},
117+
}));
118+
100119
export const WorkflowsTable = ({ items }: WorkflowsTableProps) => {
120+
const styles = useStyles();
101121
const navigate = useNavigate();
102122
const definitionLink = useRouteRef(workflowRouteRef);
103123
const definitionRunsLink = useRouteRef(workflowRunsRouteRef);
@@ -205,6 +225,35 @@ export const WorkflowsTable = ({ items }: WorkflowsTableProps) => {
205225
field: 'category',
206226
render: rowData => capitalize(rowData.category),
207227
},
228+
{
229+
title: 'Workflow status',
230+
field: 'avialability',
231+
render: rowData => {
232+
if (rowData.availablity === AVAILABLE)
233+
return (
234+
<Box display="flex" alignItems="center">
235+
<TaskAltOutlinedIcon
236+
sx={{ fontSize: 15, marginRight: 0.5 }}
237+
className={styles.success}
238+
/>
239+
{rowData.availablity}
240+
</Box>
241+
);
242+
else if (rowData.availablity === UNAVAILABLE)
243+
return (
244+
<Tooltip title="Workflow is currently down or in an error state">
245+
<Box display="flex" alignItems="center">
246+
<WarningAmberOutlinedIcon
247+
sx={{ fontSize: 15, marginRight: 0.5 }}
248+
className={styles.warning}
249+
/>
250+
{rowData.availablity}
251+
</Box>
252+
</Tooltip>
253+
);
254+
return rowData.availablity;
255+
},
256+
},
208257
{ title: 'Last run', field: 'lastTriggered' },
209258
{
210259
title: 'Last run status',
@@ -224,7 +273,13 @@ export const WorkflowsTable = ({ items }: WorkflowsTableProps) => {
224273
},
225274
{ title: 'Description', field: 'description', minWidth: '25vw' },
226275
],
227-
[canViewInstance, canViewWorkflow, definitionLink],
276+
[
277+
canViewInstance,
278+
canViewWorkflow,
279+
definitionLink,
280+
styles.success,
281+
styles.warning,
282+
],
228283
);
229284

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

workspaces/orchestrator/plugins/orchestrator/src/constants.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 The Backstage Authors
2+
* Copyright Red Hat, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,8 +13,10 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
export const VALUE_UNAVAILABLE = '---' as const;
1716

17+
export const VALUE_UNAVAILABLE = '---' as const;
18+
export const AVAILABLE = 'Available';
19+
export const UNAVAILABLE = 'Unavailable';
1820
export const SHORT_REFRESH_INTERVAL = 5000;
1921
export const LONG_REFRESH_INTERVAL = 15000;
2022
export const DEFAULT_TABLE_PAGE_SIZE = 20;

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 The Backstage Authors
2+
* Copyright Red Hat, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,14 +13,15 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
import moment from 'moment';
1718

1819
import {
1920
WorkflowFormatDTO,
2021
WorkflowOverviewDTO,
2122
} from '@red-hat-developer-hub/backstage-plugin-orchestrator-common';
2223

23-
import { VALUE_UNAVAILABLE } from '../constants';
24+
import { AVAILABLE, UNAVAILABLE, VALUE_UNAVAILABLE } from '../constants';
2425
import DataFormatter from './DataFormatter';
2526

2627
export interface FormattedWorkflowOverview {
@@ -32,8 +33,15 @@ export interface FormattedWorkflowOverview {
3233
readonly category: string;
3334
readonly description: string;
3435
readonly format: WorkflowFormatDTO;
36+
readonly availablity?: string;
3537
}
3638

39+
const formatIsAvailable = (availablity: boolean | undefined) => {
40+
if (availablity === true) return AVAILABLE;
41+
else if (availablity === false) return UNAVAILABLE;
42+
return VALUE_UNAVAILABLE;
43+
};
44+
3745
const WorkflowOverviewFormatter: DataFormatter<
3846
WorkflowOverviewDTO,
3947
FormattedWorkflowOverview
@@ -50,6 +58,7 @@ const WorkflowOverviewFormatter: DataFormatter<
5058
category: data.category ?? VALUE_UNAVAILABLE,
5159
description: data.description ?? VALUE_UNAVAILABLE,
5260
format: data.format,
61+
availablity: formatIsAvailable(data.isAvailable),
5362
};
5463
},
5564
};

0 commit comments

Comments
 (0)