@@ -25,6 +25,11 @@ import {
25
25
getInitialRichParameterValues ,
26
26
useValidationSchemaForRichParameters ,
27
27
} from "utils/richParameters" ;
28
+ import {
29
+ ImmutableTemplateParametersSection ,
30
+ MutableTemplateParametersSection ,
31
+ } from "components/TemplateParameters/TemplateParameters" ;
32
+ import { ExternalAuthButton } from "./ExternalAuthButton" ;
28
33
import { ErrorAlert } from "components/Alert/ErrorAlert" ;
29
34
import { Stack } from "components/Stack/Stack" ;
30
35
import { Alert } from "components/Alert/Alert" ;
@@ -171,48 +176,74 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
171
176
</ Stack >
172
177
</ PageHeader >
173
178
174
- { requiresExternalAuth ? (
175
- < ExternalAuthBanner
176
- providers = { externalAuth }
177
- pollingState = { externalAuthPollingState }
178
- onStartPolling = { startPollingExternalAuth }
179
- />
180
- ) : (
181
- < HorizontalForm
182
- name = "create-workspace-form"
183
- onSubmit = { form . handleSubmit }
184
- css = { { padding : "16px 0" } }
179
+ < HorizontalForm onSubmit = { form . handleSubmit } css = { { padding : "16px 0" } } >
180
+ { Boolean ( error ) && < ErrorAlert error = { error } /> }
181
+
182
+ { mode === "duplicate" && (
183
+ < Alert severity = "info" dismissible >
184
+ { Language . duplicationWarning }
185
+ </ Alert >
186
+ ) }
187
+
188
+ { /* General info */ }
189
+ < FormSection
190
+ title = "General"
191
+ description = {
192
+ permissions . createWorkspaceForUser
193
+ ? "The name of the workspace and its owner. Only admins can create workspace for other users."
194
+ : "The name of your new workspace."
195
+ }
185
196
>
186
- { Boolean ( error ) && < ErrorAlert error = { error } /> }
197
+ < FormFields >
198
+ { versionId && versionId !== template . active_version_id && (
199
+ < Stack spacing = { 1 } css = { styles . hasDescription } >
200
+ < TextField
201
+ disabled
202
+ fullWidth
203
+ value = { versionId }
204
+ label = "Version ID"
205
+ />
206
+ < span css = { styles . description } >
207
+ This parameter has been preset, and cannot be modified.
208
+ </ span >
209
+ </ Stack >
210
+ ) }
187
211
188
- { mode === "duplicate" && (
189
- < Alert severity = "info" dismissible >
190
- { Language . duplicationWarning }
191
- </ Alert >
192
- ) }
212
+ < TextField
213
+ { ...getFieldHelpers ( "name" ) }
214
+ disabled = { creatingWorkspace }
215
+ // resetMutation facilitates the clearing of validation errors
216
+ onChange = { onChangeTrimmed ( form , resetMutation ) }
217
+ autoFocus
218
+ fullWidth
219
+ label = "Workspace Name"
220
+ />
193
221
194
- { /* General info */ }
222
+ { permissions . createWorkspaceForUser && (
223
+ < UserAutocomplete
224
+ value = { owner }
225
+ onChange = { ( user ) => {
226
+ setOwner ( user ?? defaultOwner ) ;
227
+ } }
228
+ label = "Owner"
229
+ size = "medium"
230
+ />
231
+ ) }
232
+ </ FormFields >
233
+ </ FormSection >
234
+
235
+ { externalAuth && externalAuth . length > 0 && (
195
236
< FormSection
196
- title = "General"
197
- description = {
198
- permissions . createWorkspaceForUser
199
- ? "The name of the workspace and its owner. Only admins can create workspace for other users."
200
- : "The name of your new workspace."
201
- }
237
+ title = "External Authentication"
238
+ description = "This template requires authentication to external services."
202
239
>
203
240
< FormFields >
204
- { versionId && versionId !== template . active_version_id && (
205
- < Stack spacing = { 1 } css = { styles . hasDescription } >
206
- < TextField
207
- disabled
208
- fullWidth
209
- value = { versionId }
210
- label = "Version ID"
211
- />
212
- < span css = { styles . description } >
213
- This parameter has been preset, and cannot be modified.
214
- </ span >
215
- </ Stack >
241
+ { requiresExternalAuth && (
242
+ < Alert severity = "error" >
243
+ To create a workspace using the selected template, please
244
+ ensure you are authenticated with all the external providers
245
+ listed below.
246
+ </ Alert >
216
247
) }
217
248
< div >
218
249
< TextField
@@ -248,54 +279,63 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
248
279
size = "medium"
249
280
/>
250
281
) }
282
+ { externalAuth . map ( ( auth ) => (
283
+ < ExternalAuthButton
284
+ key = { auth . id }
285
+ auth = { auth }
286
+ isLoading = { externalAuthPollingState === "polling" }
287
+ onStartPolling = { startPollingExternalAuth }
288
+ displayRetry = { externalAuthPollingState === "abandoned" }
289
+ />
290
+ ) ) }
251
291
</ FormFields >
252
292
</ FormSection >
293
+ ) }
253
294
254
- { parameters . length > 0 && (
255
- < FormSection
256
- title = "Parameters"
257
- description = "These are the settings used by your template. Please note that immutable parameters cannot be modified once the workspace is created."
258
- >
259
- { /*
295
+ { parameters . length > 0 && (
296
+ < FormSection
297
+ title = "Parameters"
298
+ description = "These are the settings used by your template. Please note that immutable parameters cannot be modified once the workspace is created."
299
+ >
300
+ { /*
260
301
Opted not to use FormFields in order to increase spacing.
261
302
This decision was made because rich parameter inputs are more visually dense than standard text fields.
262
303
*/ }
263
- < div css = { { display : "flex" , flexDirection : "column" , gap : 36 } } >
264
- { parameters . map ( ( parameter , index ) => {
265
- const parameterField = `rich_parameter_values.${ index } ` ;
266
- const parameterInputName = `${ parameterField } .value` ;
267
- const isDisabled =
268
- disabledParamsList ?. includes (
269
- parameter . name . toLowerCase ( ) . replace ( / / g, "_" ) ,
270
- ) || creatingWorkspace ;
304
+ < div css = { { display : "flex" , flexDirection : "column" , gap : 36 } } >
305
+ { parameters . map ( ( parameter , index ) => {
306
+ const parameterField = `rich_parameter_values.${ index } ` ;
307
+ const parameterInputName = `${ parameterField } .value` ;
308
+ const isDisabled =
309
+ disabledParamsList ?. includes (
310
+ parameter . name . toLowerCase ( ) . replace ( / / g, "_" ) ,
311
+ ) || creatingWorkspace ;
271
312
272
- return (
273
- < RichParameterInput
274
- { ...getFieldHelpers ( parameterInputName ) }
275
- onChange = { async ( value ) => {
276
- await form . setFieldValue ( parameterField , {
277
- name : parameter . name ,
278
- value,
279
- } ) ;
280
- } }
281
- autofillSource = { autofillSources [ parameter . name ] }
282
- key = { parameter . name }
283
- parameter = { parameter }
284
- disabled = { isDisabled }
285
- />
286
- ) ;
287
- } ) }
288
- </ div >
289
- </ FormSection >
290
- ) }
313
+ return (
314
+ < RichParameterInput
315
+ { ...getFieldHelpers ( parameterInputName ) }
316
+ onChange = { async ( value ) => {
317
+ await form . setFieldValue ( parameterField , {
318
+ name : parameter . name ,
319
+ value,
320
+ } ) ;
321
+ } }
322
+ autofillSource = { autofillSources [ parameter . name ] }
323
+ key = { parameter . name }
324
+ parameter = { parameter }
325
+ disabled = { isDisabled }
326
+ />
327
+ ) ;
328
+ } ) }
329
+ </ div >
330
+ </ FormSection >
331
+ ) }
291
332
292
- < FormFooter
293
- onCancel = { onCancel }
294
- isLoading = { creatingWorkspace }
295
- submitLabel = "Create Workspace"
296
- />
297
- </ HorizontalForm >
298
- ) }
333
+ < FormFooter
334
+ onCancel = { onCancel }
335
+ isLoading = { creatingWorkspace }
336
+ submitLabel = "Create Workspace"
337
+ />
338
+ </ HorizontalForm >
299
339
</ Margins >
300
340
) ;
301
341
} ;
0 commit comments