1
- import { useTheme } from "@emotion/react" ;
2
1
import Checkbox from "@mui/material/Checkbox" ;
3
2
import FormControlLabel from "@mui/material/FormControlLabel" ;
4
3
import MenuItem from "@mui/material/MenuItem" ;
@@ -14,6 +13,10 @@ import {
14
13
FormFields ,
15
14
} from "components/Form/Form" ;
16
15
import { Stack } from "components/Stack/Stack" ;
16
+ import {
17
+ StackLabel ,
18
+ StackLabelHelperText ,
19
+ } from "components/StackLabel/StackLabel" ;
17
20
import { getFormHelpers } from "utils/formUtils" ;
18
21
import {
19
22
calculateAutostopRequirementDaysValue ,
@@ -51,7 +54,8 @@ const DORMANT_AUTODELETION_DEFAULT = 30;
51
54
* The default form field space is 4 but since this form is quite heavy I think
52
55
* increase the space can make it feels lighter.
53
56
*/
54
- const FORM_FIELDS_SPACING = 6 ;
57
+ const FORM_FIELDS_SPACING = 8 ;
58
+ const DORMANT_FIELDSET_SPACING = 4 ;
55
59
56
60
export interface TemplateScheduleForm {
57
61
template : Template ;
@@ -151,7 +155,6 @@ export const TemplateScheduleForm: FC<TemplateScheduleForm> = ({
151
155
form ,
152
156
error ,
153
157
) ;
154
- const theme = useTheme ( ) ;
155
158
156
159
const now = new Date ( ) ;
157
160
const weekFromNow = new Date ( now ) ;
@@ -404,62 +407,61 @@ export const TemplateScheduleForm: FC<TemplateScheduleForm> = ({
404
407
/>
405
408
</ Stack >
406
409
407
- < Stack direction = "row" alignItems = "center" >
408
- < Checkbox
409
- id = "allow-user-autostop"
410
- size = "small"
411
- disabled = { isSubmitting || ! allowAdvancedScheduling }
412
- onChange = { async ( ) => {
413
- await form . setFieldValue (
414
- "allow_user_autostop" ,
415
- ! form . values . allow_user_autostop ,
416
- ) ;
417
- } }
418
- name = "allow_user_autostop"
419
- checked = { form . values . allow_user_autostop }
420
- />
421
- < Stack spacing = { 0.5 } >
422
- < strong > Enforce these settings across all workspaces</ strong >
423
- < span
424
- css = { {
425
- fontSize : 12 ,
426
- color : theme . palette . text . secondary ,
410
+ < FormControlLabel
411
+ control = {
412
+ < Checkbox
413
+ id = "allow-user-autostop"
414
+ size = "small"
415
+ disabled = { isSubmitting || ! allowAdvancedScheduling }
416
+ onChange = { async ( _ , checked ) => {
417
+ await form . setFieldValue ( "allow_user_autostop" , checked ) ;
427
418
} }
428
- >
429
- Workspaces by default allow users to set custom autostop timers.
430
- Use this to apply the template settings to all workspaces under
431
- this template.
432
- </ span >
433
- </ Stack >
434
- </ Stack >
419
+ name = "allow_user_autostop"
420
+ checked = { form . values . allow_user_autostop }
421
+ />
422
+ }
423
+ label = {
424
+ < StackLabel >
425
+ Allow users to customize autostop duration for workspaces.
426
+ < StackLabelHelperText >
427
+ By default, workspaces will inherit the Autostop timer from
428
+ this template. Enabling this option allows users to set custom
429
+ Autostop timers on their workspaces or turn off the timer.
430
+ </ StackLabelHelperText >
431
+ </ StackLabel >
432
+ }
433
+ />
435
434
</ FormFields >
436
435
</ FormSection >
437
436
438
437
< FormSection
439
438
title = "Autostart"
440
439
description = "Allow users to set custom autostart and autostop scheduling options for workspaces created from this template."
441
440
>
442
- < Stack direction = "column" >
443
- < Stack direction = "row" alignItems = "center" >
444
- < Checkbox
445
- id = "allow_user_autostart"
446
- size = "small"
447
- disabled = { isSubmitting || ! allowAdvancedScheduling }
448
- onChange = { async ( ) => {
449
- await form . setFieldValue (
450
- "allow_user_autostart" ,
451
- ! form . values . allow_user_autostart ,
452
- ) ;
453
- } }
454
- name = "allow_user_autostart"
455
- checked = { form . values . allow_user_autostart }
456
- />
457
- < Stack spacing = { 0.5 } >
458
- < strong >
441
+ < Stack >
442
+ < FormControlLabel
443
+ control = {
444
+ < Checkbox
445
+ id = "allow_user_autostart"
446
+ size = "small"
447
+ disabled = { isSubmitting || ! allowAdvancedScheduling }
448
+ onChange = { async ( ) => {
449
+ await form . setFieldValue (
450
+ "allow_user_autostart" ,
451
+ ! form . values . allow_user_autostart ,
452
+ ) ;
453
+ } }
454
+ name = "allow_user_autostart"
455
+ checked = { form . values . allow_user_autostart }
456
+ />
457
+ }
458
+ label = {
459
+ < StackLabel >
459
460
Allow users to automatically start workspaces on a schedule.
460
- </ strong >
461
- </ Stack >
462
- </ Stack >
461
+ </ StackLabel >
462
+ }
463
+ />
464
+
463
465
{ allowAdvancedScheduling && (
464
466
< TemplateScheduleAutostart
465
467
enabled = { Boolean ( form . values . allow_user_autostart ) }
@@ -482,19 +484,20 @@ export const TemplateScheduleForm: FC<TemplateScheduleForm> = ({
482
484
< >
483
485
< FormSection
484
486
title = "Dormancy"
485
- description = "Coder's Dormancy Threshold determines when workspaces become dormant due to inactivity, requiring manual activation for access ."
487
+ description = "When enabled, Coder will mark workspaces as dormant after a period of time with no connections. Dormant workspaces can be auto-deleted (see below) or manually reviewed by the workspace owner or admins ."
486
488
>
487
489
< FormFields spacing = { FORM_FIELDS_SPACING } >
488
- < Stack >
490
+ < Stack spacing = { DORMANT_FIELDSET_SPACING } >
489
491
< FormControlLabel
490
492
control = {
491
493
< Switch
494
+ size = "small"
492
495
name = "dormancyThreshold"
493
496
checked = { form . values . inactivity_cleanup_enabled }
494
497
onChange = { handleToggleInactivityCleanup }
495
498
/>
496
499
}
497
- label = " Enable Dormancy Threshold"
500
+ label = { < StackLabel > Enable Dormancy Threshold</ StackLabel > }
498
501
/>
499
502
< TextField
500
503
{ ...getFieldHelpers ( "time_til_dormant_ms" , {
@@ -514,16 +517,33 @@ export const TemplateScheduleForm: FC<TemplateScheduleForm> = ({
514
517
/>
515
518
</ Stack >
516
519
517
- < Stack >
520
+ < Stack spacing = { DORMANT_FIELDSET_SPACING } >
518
521
< FormControlLabel
519
522
control = {
520
523
< Switch
524
+ size = "small"
521
525
name = "dormancyAutoDeletion"
522
526
checked = { form . values . dormant_autodeletion_cleanup_enabled }
523
527
onChange = { handleToggleDormantAutoDeletion }
524
528
/>
525
529
}
526
- label = "Enable Dormancy Auto-Deletion"
530
+ label = {
531
+ < StackLabel >
532
+ Enable Dormancy Auto-Deletion
533
+ < StackLabelHelperText >
534
+ When enabled, Coder will permanently delete dormant
535
+ workspaces after a period of time.{ " " }
536
+ < span
537
+ css = { ( theme ) => ( {
538
+ fontWeight : 500 ,
539
+ color : theme . palette . text . primary ,
540
+ } ) }
541
+ >
542
+ Once a workspace is deleted it cannot be recovered.
543
+ </ span >
544
+ </ StackLabelHelperText >
545
+ </ StackLabel >
546
+ }
527
547
/>
528
548
< TextField
529
549
{ ...getFieldHelpers ( "time_til_dormant_autodelete_ms" , {
@@ -544,16 +564,25 @@ export const TemplateScheduleForm: FC<TemplateScheduleForm> = ({
544
564
/>
545
565
</ Stack >
546
566
547
- < Stack >
567
+ < Stack spacing = { DORMANT_FIELDSET_SPACING } >
548
568
< FormControlLabel
549
569
control = {
550
570
< Switch
571
+ size = "small"
551
572
name = "failureCleanupEnabled"
552
573
checked = { form . values . failure_cleanup_enabled }
553
574
onChange = { handleToggleFailureCleanup }
554
575
/>
555
576
}
556
- label = "Enable Failure Cleanup"
577
+ label = {
578
+ < StackLabel >
579
+ Enable Failure Cleanup
580
+ < StackLabelHelperText >
581
+ When enabled, Coder will attempt to stop workspaces that
582
+ are in a failed state after a specified number of days.
583
+ </ StackLabelHelperText >
584
+ </ StackLabel >
585
+ }
557
586
/>
558
587
< TextField
559
588
{ ...getFieldHelpers ( "failure_ttl_ms" , {
0 commit comments