forked from janus-idp/backstage-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(orchestrator): add Workflow Run List (janus-idp#30)
* feat(orchestrator): add Workflow Run List FLPATH-693 A component listing running workflows is added. * chore: move loading logic out of the OrchestratorPage
- Loading branch information
1 parent
d1d3cf5
commit 8748d8b
Showing
13 changed files
with
616 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 6 additions & 56 deletions
62
plugins/orchestrator/src/components/next/OrchestratorPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
plugins/orchestrator/src/components/next/ProcessInstanceStatus.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from 'react'; | ||
|
||
import { makeStyles } from '@material-ui/core'; | ||
import DotIcon from '@material-ui/icons/FiberManualRecord'; | ||
|
||
import { ProcessInstanceState } from '@janus-idp/backstage-plugin-orchestrator-common'; | ||
|
||
import { humanizeProcessInstanceState } from './utils'; | ||
|
||
const useStyles = makeStyles(theme => ({ | ||
root: {}, | ||
icon: { fontSize: '0.75rem' }, | ||
[ProcessInstanceState.Active.toLowerCase()]: { | ||
color: theme.palette.primary.main, | ||
}, | ||
[ProcessInstanceState.Aborted.toLowerCase()]: { | ||
color: theme.palette.grey[400], | ||
}, | ||
[ProcessInstanceState.Completed.toLowerCase()]: { | ||
color: theme.palette.success.main, | ||
}, | ||
[ProcessInstanceState.Error.toLowerCase()]: { | ||
color: theme.palette.error.main, | ||
}, | ||
[ProcessInstanceState.Suspended.toLowerCase()]: { | ||
color: theme.palette.warning.main, | ||
}, | ||
})); | ||
|
||
export const ProcessInstanceStatus = ({ status }: { status: string }) => { | ||
const styles = useStyles(); | ||
const colorStyle = styles[status.toLowerCase()]; | ||
|
||
const icon = colorStyle && ( | ||
<DotIcon className={`${styles.icon} ${colorStyle}`} /> | ||
); | ||
|
||
// TODO(mlibra): Show progress, i.e.: (2/5) | ||
return ( | ||
<div className={styles.root}> | ||
{icon} {humanizeProcessInstanceState(status)} | ||
</div> | ||
); | ||
}; |
82 changes: 82 additions & 0 deletions
82
plugins/orchestrator/src/components/next/StatusSelector.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import React from 'react'; | ||
|
||
import { Select, SelectedItems, SelectItem } from '@backstage/core-components'; | ||
|
||
import { makeStyles, Typography } from '@material-ui/core'; | ||
|
||
import { ProcessInstanceState } from '@janus-idp/backstage-plugin-orchestrator-common'; | ||
|
||
import { humanizeProcessInstanceState } from './utils'; | ||
|
||
const useStyles = makeStyles(theme => ({ | ||
root: { | ||
display: 'flex', | ||
alignItems: 'baseline', | ||
'& label + div': { | ||
marginTop: '0px', | ||
}, | ||
'& select': { | ||
width: '7rem', | ||
}, | ||
}, | ||
label: { | ||
color: theme.palette.text.primary, | ||
fontSize: theme.typography.fontSize, | ||
paddingRight: '0.5rem', | ||
fontWeight: 'bold', | ||
}, | ||
})); | ||
|
||
const ALL = '___all___'; | ||
|
||
export type StatusSelectorProps = { | ||
onChange: (item?: string) => void; | ||
value?: string; | ||
includeAll?: boolean; | ||
}; | ||
|
||
export const StatusSelector = ({ | ||
onChange, | ||
value, | ||
includeAll = true, | ||
}: StatusSelectorProps) => { | ||
const styles = useStyles(); | ||
|
||
let statuses: SelectItem[] = []; | ||
if (includeAll) { | ||
statuses = [{ label: 'All', value: ALL }]; | ||
} | ||
statuses = [ | ||
...statuses, | ||
...[ | ||
ProcessInstanceState.Active, | ||
ProcessInstanceState.Completed, | ||
ProcessInstanceState.Error, | ||
ProcessInstanceState.Aborted, | ||
ProcessInstanceState.Suspended, | ||
].map(status => ({ | ||
label: humanizeProcessInstanceState(status), | ||
value: status, | ||
})), | ||
]; | ||
|
||
const selected = statuses?.find(item => item.value === value)?.value; | ||
|
||
const handleOnChange = (item: SelectedItems) => { | ||
onChange(item === ALL ? undefined : (item as string)); | ||
}; | ||
|
||
return ( | ||
<div className={styles.root}> | ||
<Typography className={styles.label}>Status</Typography> | ||
<Select | ||
onChange={handleOnChange} | ||
items={statuses} | ||
selected={selected} | ||
margin="dense" | ||
native | ||
label="" | ||
/> | ||
</div> | ||
); | ||
}; |
38 changes: 38 additions & 0 deletions
38
plugins/orchestrator/src/components/next/TableExpandCollapse.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from 'react'; | ||
|
||
import { IconButton, Tooltip } from '@material-ui/core'; | ||
import Collapse from '@material-ui/icons/UnfoldLess'; | ||
import Expand from '@material-ui/icons/UnfoldMore'; | ||
|
||
type TableExpandCollapseProps = { | ||
isExpanded: boolean; | ||
setIsExpanded: (value: boolean) => void; | ||
}; | ||
|
||
export const TableExpandCollapse = ({ | ||
isExpanded, | ||
setIsExpanded, | ||
}: TableExpandCollapseProps) => { | ||
const handleExpandCollaspse = () => { | ||
setIsExpanded(!isExpanded); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Tooltip title="Collapse all" placement="top"> | ||
<span> | ||
<IconButton onClick={handleExpandCollaspse} disabled={!isExpanded}> | ||
<Collapse /> | ||
</IconButton> | ||
</span> | ||
</Tooltip> | ||
<Tooltip title="Expand all" placement="top"> | ||
<span> | ||
<IconButton onClick={handleExpandCollaspse} disabled={isExpanded}> | ||
<Expand /> | ||
</IconButton> | ||
</span> | ||
</Tooltip> | ||
</> | ||
); | ||
}; |
Oops, something went wrong.