@@ -8,20 +8,23 @@ import { FC } from "react"
8
8
import { getFormHelpers } from "util/formUtils"
9
9
import {
10
10
FormFields ,
11
- FormFooter ,
11
+ FormSection ,
12
+ VerticalForm ,
12
13
} from "components/HorizontalForm/HorizontalForm"
13
14
import {
14
15
TemplateVersionParameter ,
15
16
WorkspaceBuildParameter ,
16
17
} from "api/typesGenerated"
17
18
import { RichParameterInput } from "components/RichParameterInput/RichParameterInput"
18
- import { Stack } from "components/Stack/Stack"
19
19
import { useFormik } from "formik"
20
20
import {
21
21
selectInitialRichParametersValues ,
22
22
ValidationSchemaForRichParameters ,
23
23
} from "util/richParameters"
24
24
import * as Yup from "yup"
25
+ import DialogActions from "@material-ui/core/DialogActions"
26
+ import Button from "@material-ui/core/Button"
27
+ import InfoOutlined from "@material-ui/icons/InfoOutlined"
25
28
26
29
export type UpdateBuildParametersDialogProps = DialogProps & {
27
30
onClose : ( ) => void
@@ -50,23 +53,75 @@ export const UpdateBuildParametersDialog: FC<
50
53
const getFieldHelpers = getFormHelpers ( form )
51
54
52
55
return (
53
- < Dialog { ...dialogProps } aria-labelledby = "update-build-parameters-title" >
56
+ < Dialog
57
+ { ...dialogProps }
58
+ scroll = "body"
59
+ aria-labelledby = "update-build-parameters-title"
60
+ maxWidth = "xs"
61
+ >
54
62
< DialogTitle
55
63
id = "update-build-parameters-title"
56
64
classes = { { root : styles . title } }
57
65
>
58
- Missing workspace parameters
66
+ Workspace parameters
59
67
</ DialogTitle >
60
68
< DialogContent className = { styles . content } >
61
- < DialogContentText className = { styles . contentText } >
69
+ < DialogContentText className = { styles . info } >
62
70
It looks like the new version has some mandatory parameters that need
63
71
to be filled in to update the workspace.
64
72
</ DialogContentText >
65
- < form className = { styles . form } onSubmit = { form . handleSubmit } >
66
- < Stack spacing = { 5 } >
73
+ < VerticalForm
74
+ className = { styles . form }
75
+ onSubmit = { form . handleSubmit }
76
+ id = "updateParameters"
77
+ >
78
+ { parameters && parameters . filter ( ( p ) => p . mutable ) . length > 0 && (
67
79
< FormFields >
68
- { parameters &&
69
- parameters . map ( ( parameter , index ) => {
80
+ { parameters . map ( ( parameter , index ) => {
81
+ if ( ! parameter . mutable ) {
82
+ return < > </ >
83
+ }
84
+
85
+ return (
86
+ < RichParameterInput
87
+ { ...getFieldHelpers (
88
+ "rich_parameter_values[" + index + "].value" ,
89
+ ) }
90
+ key = { parameter . name }
91
+ parameter = { parameter }
92
+ initialValue = ""
93
+ index = { index }
94
+ onChange = { async ( value ) => {
95
+ await form . setFieldValue (
96
+ "rich_parameter_values." + index ,
97
+ {
98
+ name : parameter . name ,
99
+ value : value ,
100
+ } ,
101
+ )
102
+ } }
103
+ />
104
+ )
105
+ } ) }
106
+ </ FormFields >
107
+ ) }
108
+ { parameters && parameters . filter ( ( p ) => ! p . mutable ) . length > 0 && (
109
+ < FormSection
110
+ title = {
111
+ < >
112
+ < InfoOutlined className = { styles . warningIcon } />
113
+ Immutable parameters
114
+ </ >
115
+ }
116
+ classes = { { infoTitle : styles . infoTitle } }
117
+ description = "These parameters values are immutable and cannot be changed after the update."
118
+ >
119
+ < FormFields >
120
+ { parameters . map ( ( parameter , index ) => {
121
+ if ( parameter . mutable ) {
122
+ return < > </ >
123
+ }
124
+
70
125
return (
71
126
< RichParameterInput
72
127
{ ...getFieldHelpers (
@@ -88,18 +143,31 @@ export const UpdateBuildParametersDialog: FC<
88
143
/>
89
144
)
90
145
} ) }
91
- </ FormFields >
92
- < FormFooter onCancel = { dialogProps . onClose } isLoading = { false } / >
93
- </ Stack >
94
- </ form >
146
+ </ FormFields >
147
+ </ FormSection >
148
+ ) }
149
+ </ VerticalForm >
95
150
</ DialogContent >
151
+ < DialogActions disableSpacing className = { styles . dialogActions } >
152
+ < Button
153
+ fullWidth
154
+ type = "button"
155
+ variant = "outlined"
156
+ onClick = { dialogProps . onClose }
157
+ >
158
+ Cancel
159
+ </ Button >
160
+ < Button color = "primary" fullWidth type = "submit" form = "updateParameters" >
161
+ Update
162
+ </ Button >
163
+ </ DialogActions >
96
164
</ Dialog >
97
165
)
98
166
}
99
167
100
168
const useStyles = makeStyles ( ( theme ) => ( {
101
169
title : {
102
- padding : theme . spacing ( 5 , 5 , 2 , 5 ) ,
170
+ padding : theme . spacing ( 3 , 5 ) ,
103
171
104
172
"& h2" : {
105
173
fontSize : theme . spacing ( 2.5 ) ,
@@ -108,15 +176,45 @@ const useStyles = makeStyles((theme) => ({
108
176
} ,
109
177
110
178
content : {
111
- padding : theme . spacing ( 0 , 5 , 5 , 5 ) ,
179
+ padding : theme . spacing ( 0 , 5 , 0 , 5 ) ,
112
180
} ,
113
181
114
- contentText : {
115
- fontSize : theme . spacing ( 2 ) ,
182
+ info : {
183
+ fontSize : theme . spacing ( 1.75 ) ,
116
184
lineHeight : "160%" ,
185
+ backgroundColor : theme . palette . info . dark ,
186
+ color : theme . palette . text . primary ,
187
+ border : `1px solid ${ theme . palette . info . light } ` ,
188
+ borderRight : 0 ,
189
+ borderLeft : 0 ,
190
+ padding : theme . spacing ( 3 , 5 ) ,
191
+ margin : theme . spacing ( 0 , - 5 ) ,
117
192
} ,
118
193
119
194
form : {
120
- marginTop : theme . spacing ( 4 ) ,
195
+ paddingTop : theme . spacing ( 5 ) ,
196
+ } ,
197
+
198
+ infoTitle : {
199
+ fontSize : theme . spacing ( 2 ) ,
200
+ fontWeight : 600 ,
201
+ display : "flex" ,
202
+ alignItems : "center" ,
203
+ gap : theme . spacing ( 1 ) ,
204
+ } ,
205
+
206
+ warningIcon : {
207
+ color : theme . palette . warning . light ,
208
+ fontSize : theme . spacing ( 1.5 ) ,
209
+ } ,
210
+
211
+ formFooter : {
212
+ flexDirection : "column" ,
213
+ } ,
214
+
215
+ dialogActions : {
216
+ padding : theme . spacing ( 5 ) ,
217
+ flexDirection : "column" ,
218
+ gap : theme . spacing ( 1 ) ,
121
219
} ,
122
220
} ) )
0 commit comments