@@ -42,6 +42,7 @@ import Snackbar from '@material-ui/core/Snackbar';
42
42
import { createStyles , makeStyles , Theme } from '@material-ui/core/styles' ;
43
43
import CloseIcon from '@material-ui/icons/Close' ;
44
44
import ErrorIcon from '@material-ui/icons/Error' ;
45
+ import { AlertTitle } from '@material-ui/lab' ;
45
46
import Alert from '@material-ui/lab/Alert' ;
46
47
import ArrowDropDown from '@mui/icons-material/ArrowDropDown' ;
47
48
import StartIcon from '@mui/icons-material/Start' ;
@@ -70,36 +71,89 @@ import { WorkflowInstancePageContent } from './WorkflowInstancePageContent';
70
71
const useStyles = makeStyles ( ( theme : Theme ) =>
71
72
createStyles ( {
72
73
abortButton : {
73
- backgroundColor : theme . palette . error . main ,
74
- color : theme . palette . getContrastText ( theme . palette . error . main ) ,
74
+ backgroundColor : theme . palette . error . dark ,
75
+ color : theme . palette . getContrastText ( theme . palette . error . dark ) ,
75
76
'&:hover' : {
76
77
backgroundColor : theme . palette . error . dark ,
78
+ filter : 'brightness(90%)' ,
77
79
} ,
78
80
} ,
81
+ modalText : {
82
+ fontSize : '1.1rem' ,
83
+ } ,
84
+ errorColor : {
85
+ color : theme . palette . error . dark ,
86
+ } ,
79
87
} ) ,
80
88
) ;
81
89
82
90
export type AbortConfirmationDialogActionsProps = {
83
91
handleSubmit : ( ) => void ;
84
92
handleCancel : ( ) => void ;
93
+ isAborting : boolean ;
94
+ canAbort : boolean ;
85
95
} ;
86
96
87
- const AbortConfirmationDialogContent = ( ) => (
88
- < div >
89
- < b >
90
- Are you sure you want to abort this workflow run? < br /> < br />
91
- Aborting will stop all in-progress and pending steps immediately. Any
92
- incomplete tasks will not be saved.
93
- </ b >
94
- </ div >
95
- ) ;
97
+ const AbortConfirmationDialogContent = ( {
98
+ canAbort,
99
+ } : {
100
+ canAbort : boolean ;
101
+ } ) => {
102
+ const classes = useStyles ( ) ;
103
+ return (
104
+ < div >
105
+ < p className = { classes . modalText } >
106
+ Are you sure you want to abort this workflow run? < br /> < br />
107
+ Aborting will stop all in-progress and pending steps immediately. Any
108
+ incomplete tasks will not be saved.
109
+ </ p >
110
+ { ! canAbort && (
111
+ < Box sx = { { width : '100%' } } >
112
+ < Alert severity = "info" >
113
+ < AlertTitle > Run completed</ AlertTitle >
114
+ It is not possible to abort the run as it has already been
115
+ completed.
116
+ </ Alert >
117
+ </ Box >
118
+ ) }
119
+ </ div >
120
+ ) ;
121
+ } ;
122
+
123
+ const AbortConfirmationDialogActions = (
124
+ props : AbortConfirmationDialogActionsProps ,
125
+ ) => {
126
+ const classes = useStyles ( ) ;
127
+ return (
128
+ < >
129
+ < Button
130
+ onClick = { props . handleSubmit }
131
+ variant = "contained"
132
+ className = { classes . abortButton }
133
+ startIcon = { props . isAborting ? < CircularProgress size = "1rem" /> : null }
134
+ disabled = { props . isAborting || ! props . canAbort }
135
+ >
136
+ { ' ' }
137
+ Abort
138
+ </ Button >
139
+ < Button
140
+ onClick = { props . handleCancel }
141
+ variant = "outlined"
142
+ color = "primary"
143
+ disabled = { props . isAborting }
144
+ >
145
+ { ' ' }
146
+ Cancel
147
+ </ Button >
148
+ </ >
149
+ ) ;
150
+ } ;
96
151
97
152
export const WorkflowInstancePage = ( {
98
153
instanceId,
99
154
} : {
100
155
instanceId ?: string ;
101
156
} ) => {
102
- const classes = useStyles ( ) ;
103
157
const navigate = useNavigate ( ) ;
104
158
const orchestratorApi = useApi ( orchestratorApiRef ) ;
105
159
const executeWorkflowLink = useRouteRef ( executeWorkflowRouteRef ) ;
@@ -125,32 +179,6 @@ export const WorkflowInstancePage = ({
125
179
setIsRerunSnackbarOpen ( false ) ;
126
180
} ;
127
181
128
- const AbortConfirmationDialogActions = (
129
- props : AbortConfirmationDialogActionsProps ,
130
- ) => (
131
- < >
132
- < Button
133
- onClick = { props . handleSubmit }
134
- variant = "contained"
135
- className = { classes . abortButton }
136
- startIcon = { isAborting ? < CircularProgress size = "1rem" /> : null }
137
- disabled = { isAborting }
138
- >
139
- { ' ' }
140
- Abort
141
- </ Button >
142
- < Button
143
- onClick = { props . handleCancel }
144
- variant = "outlined"
145
- color = "primary"
146
- disabled = { isAborting }
147
- >
148
- { ' ' }
149
- Cancel
150
- </ Button >
151
- </ >
152
- ) ;
153
-
154
182
const fetchInstance = React . useCallback ( async ( ) => {
155
183
if ( ! instanceId && ! queryInstanceId ) {
156
184
return undefined ;
@@ -266,6 +294,8 @@ export const WorkflowInstancePage = ({
266
294
else if ( option === 'retrigger' ) handleRetrigger ( ) ;
267
295
} ;
268
296
297
+ const classes = useStyles ( ) ;
298
+
269
299
return (
270
300
< BaseOrchestratorPage
271
301
title = { value ?. instance . id }
@@ -280,8 +310,11 @@ export const WorkflowInstancePage = ({
280
310
< InfoDialog
281
311
title = {
282
312
< Box display = "flex" alignItems = "center" >
283
- < ErrorIcon color = "error" style = { { marginRight : 8 } } />
284
- < b > Abort workflow</ b >
313
+ < ErrorIcon
314
+ className = { classes . errorColor }
315
+ style = { { marginRight : 8 } }
316
+ />
317
+ < b > Abort workflow run?</ b >
285
318
</ Box >
286
319
}
287
320
onClose = { toggleAbortConfirmationDialog }
@@ -290,9 +323,11 @@ export const WorkflowInstancePage = ({
290
323
< AbortConfirmationDialogActions
291
324
handleCancel = { toggleAbortConfirmationDialog }
292
325
handleSubmit = { handleAbort }
326
+ isAborting = { isAborting }
327
+ canAbort = { canAbort }
293
328
/>
294
329
}
295
- children = { < AbortConfirmationDialogContent /> }
330
+ children = { < AbortConfirmationDialogContent canAbort = { canAbort } /> }
296
331
/>
297
332
< Grid container item justifyContent = "flex-end" spacing = { 1 } >
298
333
< Grid item >
0 commit comments