Skip to content

Commit c64c3a5

Browse files
authored
fix(orchestrator): fix view variables screen (#595)
Signed-off-by: Lior Soffer <liorsoffer1@gmail.com>
1 parent 30b6443 commit c64c3a5

4 files changed

Lines changed: 97 additions & 49 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+
fix view variables screen

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

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,45 +30,66 @@ import CloseIcon from '@material-ui/icons/Close';
3030

3131
export type InfoDialogProps = {
3232
title: React.ReactNode;
33+
titleIcon?: React.ReactNode;
3334
open: boolean;
3435
onClose?: () => void;
3536
dialogActions?: React.ReactNode;
3637
children?: React.ReactNode;
38+
wideDialog?: boolean;
3739
};
3840

3941
export type ParentComponentRef = HTMLElement;
4042

41-
const useStyles = makeStyles(_theme => ({
43+
const useStyles = makeStyles(theme => ({
4244
closeBtn: {
4345
position: 'absolute',
44-
right: 8,
45-
top: 8,
46+
right: theme.spacing(1),
47+
top: theme.spacing(1),
4648
},
4749
dialogActions: {
4850
justifyContent: 'flex-start',
49-
paddingLeft: _theme.spacing(3),
50-
paddingBottom: _theme.spacing(2),
51+
paddingLeft: theme.spacing(3),
52+
paddingBottom: theme.spacing(2),
5153
},
52-
title: {
53-
position: 'absolute',
54-
left: 20,
55-
top: 20,
54+
titleContainer: {
55+
display: 'flex',
56+
alignItems: 'center',
57+
},
58+
titleIcon: {
59+
marginRight: theme.spacing(1),
5660
},
5761
}));
5862

5963
export const RefForwardingInfoDialog: ForwardRefRenderFunction<
6064
ParentComponentRef,
6165
InfoDialogProps
6266
> = (props, forwardedRef): JSX.Element | null => {
63-
const { title, open = false, onClose, children, dialogActions } = props;
67+
const {
68+
title,
69+
titleIcon,
70+
open = false,
71+
onClose,
72+
children,
73+
dialogActions,
74+
wideDialog,
75+
} = props;
6476
const classes = useStyles();
6577

6678
return (
67-
<Dialog onClose={_ => onClose} open={open} ref={forwardedRef}>
79+
<Dialog
80+
onClose={_ => onClose}
81+
open={open}
82+
ref={forwardedRef}
83+
maxWidth={wideDialog ? 'xl' : 'sm'}
84+
PaperProps={{
85+
style: { minWidth: wideDialog ? 500 : 400 },
86+
}}
87+
>
6888
<DialogTitle>
69-
<Box>
70-
<Typography className={classes.title} variant="h5">
71-
{title}
89+
<Box className={classes.titleContainer}>
90+
{titleIcon && <Box className={classes.titleIcon}>{titleIcon}</Box>}
91+
<Typography variant="h4">
92+
<b>{title}</b>
7293
</Typography>
7394
<IconButton
7495
className={classes.closeBtn}

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

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ import {
3535
Grid,
3636
IconButton,
3737
Tooltip,
38-
// FLPATH-2135
39-
// Menu,
40-
// MenuItem,
38+
Typography,
4139
} from '@material-ui/core';
4240
import Snackbar from '@material-ui/core/Snackbar';
4341
import { createStyles, makeStyles, Theme } from '@material-ui/core/styles';
@@ -81,7 +79,7 @@ const useStyles = makeStyles((theme: Theme) =>
8179
},
8280
},
8381
modalText: {
84-
fontSize: '1.1rem',
82+
marginBottom: theme.spacing(2),
8583
},
8684
errorColor: {
8785
color: theme.palette.error.dark,
@@ -104,11 +102,13 @@ const AbortConfirmationDialogContent = ({
104102
const classes = useStyles();
105103
return (
106104
<div>
107-
<p className={classes.modalText}>
108-
Are you sure you want to abort this workflow run? <br /> <br />
109-
Aborting will stop all in-progress and pending steps immediately. Any
110-
incomplete tasks will not be saved.
111-
</p>
105+
<Box className={classes.modalText}>
106+
<Typography variant="h6">
107+
Are you sure you want to abort this workflow run? <br /> <br />
108+
Aborting will stop all in-progress and pending steps immediately. Any
109+
incomplete tasks will not be saved.
110+
</Typography>
111+
</Box>
112112
{!canAbort && (
113113
<Box sx={{ width: '100%' }}>
114114
<Alert severity="info">
@@ -314,15 +314,8 @@ export const WorkflowInstancePage = ({
314314
<>
315315
<ContentHeader title="">
316316
<InfoDialog
317-
title={
318-
<Box display="flex" alignItems="center">
319-
<ErrorIcon
320-
className={classes.errorColor}
321-
style={{ marginRight: 8 }}
322-
/>
323-
<b>Abort workflow run?</b>
324-
</Box>
325-
}
317+
title="Abort workflow run?"
318+
titleIcon={<ErrorIcon className={classes.errorColor} />}
326319
onClose={toggleAbortConfirmationDialog}
327320
open={isAbortConfirmationDialogOpen}
328321
dialogActions={

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

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,23 @@
1616

1717
import React, { useState } from 'react';
1818
import { useAsync } from 'react-use';
19+
import useObservable from 'react-use/esm/useObservable';
1920

2021
import {
22+
CodeSnippet,
2123
Content,
2224
InfoCard,
2325
Link,
24-
StructuredMetadataTable,
2526
} from '@backstage/core-components';
26-
import { useApi } from '@backstage/core-plugin-api';
27+
import { appThemeApiRef, useApi } from '@backstage/core-plugin-api';
2728
import { usePermission } from '@backstage/plugin-permission-react';
2829

29-
import { Box, Grid, makeStyles, Typography } from '@material-ui/core';
30-
import InfoIcon from '@material-ui/icons/Info';
30+
import { Box, Button, Grid, makeStyles, Typography } from '@material-ui/core';
3131
import moment from 'moment';
3232

3333
import {
3434
AssessedProcessInstanceDTO,
35+
capitalize,
3536
InputSchemaResponseDTO,
3637
orchestratorAdminViewPermission,
3738
ProcessInstanceDTO,
@@ -92,13 +93,36 @@ const VariablesDialogContent = ({
9293
instanceVariables,
9394
}: {
9495
instanceVariables: WorkflowDataDTO;
95-
}) => (
96-
<Box sx={{ maxHeight: 300, marginTop: 20, width: 500, overflow: 'auto' }}>
97-
{instanceVariables && (
98-
<StructuredMetadataTable dense metadata={instanceVariables} />
99-
)}
100-
</Box>
101-
);
96+
}) => {
97+
const appThemeApi = useApi(appThemeApiRef);
98+
const activeThemeId = useObservable(
99+
appThemeApi.activeThemeId$(),
100+
appThemeApi.getActiveThemeId(),
101+
);
102+
103+
return (
104+
<Box>
105+
{Object.entries(instanceVariables).map(([key, value]) => (
106+
<div key={key} style={{ marginBottom: '16px' }}>
107+
<Typography variant="h6" style={{ marginBottom: '8px' }}>
108+
{capitalize(key)}
109+
</Typography>
110+
<CodeSnippet
111+
text={JSON.stringify(value, null, 2)}
112+
language="json"
113+
showLineNumbers
114+
showCopyCodeButton
115+
customStyle={{
116+
color: activeThemeId === 'dark' ? '#abb2bf' : 'd3d3d3',
117+
backgroundColor: activeThemeId === 'dark' ? '#151515' : '#F0F0F0',
118+
padding: '25px 0',
119+
}}
120+
/>
121+
</div>
122+
))}
123+
</Box>
124+
);
125+
};
102126

103127
export const WorkflowInstancePageContent: React.FC<{
104128
assessedInstance: AssessedProcessInstanceDTO;
@@ -167,17 +191,22 @@ export const WorkflowInstancePageContent: React.FC<{
167191
return (
168192
<Content noPadding>
169193
<InfoDialog
170-
title={
171-
<Box display="flex" alignItems="center">
172-
<InfoIcon color="primary" style={{ marginRight: 8 }} />
173-
<b>Run Variables</b>
174-
</Box>
175-
}
194+
title="Run Variables"
176195
onClose={toggleVariablesDialog}
177196
open={isVariablesDialogOpen}
197+
dialogActions={
198+
<Button
199+
color="primary"
200+
variant="contained"
201+
onClick={toggleVariablesDialog}
202+
>
203+
Close
204+
</Button>
205+
}
178206
children={
179207
<VariablesDialogContent instanceVariables={instanceVariables} />
180208
}
209+
wideDialog
181210
/>
182211
<Grid container spacing={2}>
183212
<Grid item xs={6}>

0 commit comments

Comments
 (0)