1
- import type { Interpolation , Theme } from "@emotion/react" ;
2
1
import Checkbox from "@mui/material/Checkbox" ;
2
+ import FormControlLabel from "@mui/material/FormControlLabel" ;
3
+ import FormHelperText from "@mui/material/FormHelperText" ;
3
4
import MenuItem from "@mui/material/MenuItem" ;
4
5
import TextField from "@mui/material/TextField" ;
5
6
import { type FormikContextType , type FormikTouched , useFormik } from "formik" ;
@@ -17,14 +18,12 @@ import {
17
18
HorizontalForm ,
18
19
FormFooter ,
19
20
} from "components/Form/Form" ;
20
- import {
21
- HelpTooltip ,
22
- HelpTooltipContent ,
23
- HelpTooltipText ,
24
- HelpTooltipTrigger ,
25
- } from "components/HelpTooltip/HelpTooltip" ;
26
21
import { IconField } from "components/IconField/IconField" ;
27
22
import { Stack } from "components/Stack/Stack" ;
23
+ import {
24
+ StackLabel ,
25
+ StackLabelHelperText ,
26
+ } from "components/StackLabel/StackLabel" ;
28
27
import {
29
28
getFormHelpers ,
30
29
nameValidator ,
@@ -160,92 +159,74 @@ export const TemplateSettingsForm: FC<TemplateSettingsForm> = ({
160
159
title = "Operations"
161
160
description = "Regulate actions allowed on workspaces created from this template."
162
161
>
163
- < Stack direction = "column" spacing = { 5 } >
164
- < label htmlFor = "allow_user_cancel_workspace_jobs" >
165
- < Stack direction = "row" spacing = { 1 } >
162
+ < FormFields spacing = { 6 } >
163
+ < FormControlLabel
164
+ control = {
166
165
< Checkbox
166
+ size = "small"
167
167
id = "allow_user_cancel_workspace_jobs"
168
168
name = "allow_user_cancel_workspace_jobs"
169
169
disabled = { isSubmitting }
170
170
checked = { form . values . allow_user_cancel_workspace_jobs }
171
171
onChange = { form . handleChange }
172
172
/>
173
-
174
- < Stack direction = "column" spacing = { 0.5 } >
175
- < Stack
176
- direction = "row"
177
- alignItems = "center"
178
- spacing = { 0.5 }
179
- css = { styles . optionText }
180
- >
181
- Allow users to cancel in-progress workspace jobs.
182
- < HelpTooltip >
183
- < HelpTooltipTrigger />
184
- < HelpTooltipContent >
185
- < HelpTooltipText >
186
- If checked, users may be able to corrupt their
187
- workspace.
188
- </ HelpTooltipText >
189
- </ HelpTooltipContent >
190
- </ HelpTooltip >
191
- </ Stack >
192
- < span css = { styles . optionHelperText } >
173
+ }
174
+ label = {
175
+ < StackLabel >
176
+ Allow users to cancel in-progress workspace jobs.
177
+ < StackLabelHelperText >
193
178
Depending on your template, canceling builds may leave
194
179
workspaces in an unhealthy state. This option isn't
195
- recommended for most use cases.
196
- </ span >
197
- </ Stack >
198
- </ Stack >
199
- </ label >
200
- < Stack spacing = { 2 } >
201
- < label htmlFor = "require_active_version" >
202
- < Stack direction = "row" spacing = { 1 } >
203
- < Checkbox
204
- id = "require_active_version"
205
- name = "require_active_version"
206
- checked = { form . values . require_active_version }
207
- onChange = { form . handleChange }
208
- disabled = {
209
- ! template . require_active_version &&
210
- ! advancedSchedulingEnabled
211
- }
212
- />
180
+ recommended for most use cases.{ " " }
181
+ < strong >
182
+ If checked, users may be able to corrupt their workspace.
183
+ </ strong >
184
+ </ StackLabelHelperText >
185
+ </ StackLabel >
186
+ }
187
+ />
213
188
214
- < Stack direction = "column" spacing = { 0.5 } >
215
- < Stack
216
- direction = "row"
217
- alignItems = "center "
218
- spacing = { 0.5 }
219
- css = { styles . optionText }
220
- >
221
- Require workspaces automatically update when started.
222
- < HelpTooltip >
223
- < HelpTooltipTrigger />
224
- < HelpTooltipContent >
225
- < HelpTooltipText >
226
- This setting is not enforced for template admins.
227
- </ HelpTooltipText >
228
- </ HelpTooltipContent >
229
- </ HelpTooltip >
230
- </ Stack >
231
- < span css = { styles . optionHelperText } >
189
+ < FormControlLabel
190
+ control = {
191
+ < Checkbox
192
+ size = "small "
193
+ id = "require_active_version"
194
+ name = "require_active_version"
195
+ checked = { form . values . require_active_version }
196
+ onChange = { form . handleChange }
197
+ disabled = {
198
+ ! template . require_active_version && ! advancedSchedulingEnabled
199
+ }
200
+ / >
201
+ }
202
+ label = {
203
+ < StackLabel >
204
+ Require workspaces automatically update when started.
205
+ < StackLabelHelperText >
206
+ < span >
232
207
Workspaces that are manually started or auto-started will
233
- use the active template version.
208
+ use the active template version.{ " " }
209
+ < strong >
210
+ This setting is not enforced for template admins.
211
+ </ strong >
234
212
</ span >
235
- </ Stack >
236
- </ Stack >
237
- </ label >
238
213
239
- { ! advancedSchedulingEnabled && (
240
- < Stack direction = "row" >
241
- < EnterpriseBadge />
242
- < span css = { styles . optionHelperText } >
243
- Enterprise license required to enabled.
244
- </ span >
245
- </ Stack >
246
- ) }
247
- </ Stack >
248
- </ Stack >
214
+ { ! advancedSchedulingEnabled && (
215
+ < Stack
216
+ direction = "row"
217
+ spacing = { 2 }
218
+ alignItems = "center"
219
+ css = { { marginTop : 16 } }
220
+ >
221
+ < EnterpriseBadge />
222
+ < span > Enterprise license required to enabled.</ span >
223
+ </ Stack >
224
+ ) }
225
+ </ StackLabelHelperText >
226
+ </ StackLabel >
227
+ }
228
+ />
229
+ </ FormFields >
249
230
</ FormSection >
250
231
251
232
< FormSection
@@ -265,13 +246,13 @@ export const TemplateSettingsForm: FC<TemplateSettingsForm> = ({
265
246
label = "Deprecation Message"
266
247
/>
267
248
{ ! accessControlEnabled && (
268
- < Stack direction = "row" >
249
+ < Stack direction = "row" spacing = { 2 } alignItems = "center" >
269
250
< EnterpriseBadge />
270
- < span css = { styles . optionHelperText } >
251
+ < FormHelperText >
271
252
Enterprise license required to deprecate templates.
272
253
{ template . deprecated &&
273
254
" You cannot change the message, but you may remove it to mark this template as no longer deprecated." }
274
- </ span >
255
+ </ FormHelperText >
275
256
</ Stack >
276
257
) }
277
258
</ FormFields >
@@ -306,11 +287,11 @@ export const TemplateSettingsForm: FC<TemplateSettingsForm> = ({
306
287
< MenuItem value = "public" > Public</ MenuItem >
307
288
</ TextField >
308
289
{ ! portSharingControlsEnabled && (
309
- < Stack direction = "row" >
290
+ < Stack direction = "row" spacing = { 2 } alignItems = "center" >
310
291
< EnterpriseBadge />
311
- < span css = { styles . optionHelperText } >
292
+ < FormHelperText >
312
293
Enterprise license required to control max port sharing level.
313
- </ span >
294
+ </ FormHelperText >
314
295
</ Stack >
315
296
) }
316
297
</ FormFields >
@@ -321,15 +302,3 @@ export const TemplateSettingsForm: FC<TemplateSettingsForm> = ({
321
302
</ HorizontalForm >
322
303
) ;
323
304
} ;
324
-
325
- const styles = {
326
- optionText : ( theme ) => ( {
327
- fontSize : 16 ,
328
- color : theme . palette . text . primary ,
329
- } ) ,
330
-
331
- optionHelperText : ( theme ) => ( {
332
- fontSize : 12 ,
333
- color : theme . palette . text . secondary ,
334
- } ) ,
335
- } satisfies Record < string , Interpolation < Theme > > ;
0 commit comments