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.
1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
1515 */
16+
1617import React , { useCallback , useEffect , useMemo , useState } from 'react' ;
1718import { useNavigate } from 'react-router-dom' ;
1819
1920import { Link , TableColumn , TableProps } from '@backstage/core-components' ;
2021import { useRouteRef } from '@backstage/core-plugin-api' ;
2122import { usePermission } from '@backstage/plugin-permission-react' ;
2223
24+ import { Box , makeStyles , Tooltip } from '@material-ui/core' ;
2325import FormatListBulleted from '@material-ui/icons/FormatListBulleted' ;
2426import PlayArrow from '@material-ui/icons/PlayArrow' ;
27+ import TaskAltOutlinedIcon from '@mui/icons-material/TaskAltOutlined' ;
28+ import WarningAmberOutlinedIcon from '@mui/icons-material/WarningAmberOutlined' ;
2529
2630import {
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' ;
3741import 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+
100119export 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' ] > (
0 commit comments