6
6
Template ,
7
7
TemplateExample ,
8
8
TemplateVersionVariable ,
9
+ VariableValue ,
9
10
} from "api/typesGenerated" ;
10
11
import { Stack } from "components/Stack/Stack" ;
11
12
import { TemplateUpload , TemplateUploadProps } from "./TemplateUpload" ;
@@ -18,7 +19,6 @@ import {
18
19
onChangeTrimmed ,
19
20
templateDisplayNameValidator ,
20
21
} from "utils/formUtils" ;
21
- import { CreateTemplateData } from "xServices/createTemplate/createTemplateXService" ;
22
22
import * as Yup from "yup" ;
23
23
import { WorkspaceBuildLogs } from "components/WorkspaceBuildLogs/WorkspaceBuildLogs" ;
24
24
import {
@@ -42,51 +42,27 @@ import {
42
42
AutostopRequirementWeeksHelperText ,
43
43
} from "pages/TemplateSettingsPage/TemplateSchedulePage/AutostopRequirementHelperText" ;
44
44
import MenuItem from "@mui/material/MenuItem" ;
45
+ import { TemplateAutostopRequirementDaysValue } from "utils/schedule" ;
45
46
46
47
const MAX_DESCRIPTION_CHAR_LIMIT = 128 ;
47
48
const MAX_TTL_DAYS = 30 ;
48
49
49
- const hours = ( h : number ) => ( h === 1 ? "hour" : "hours" ) ;
50
-
51
- const DefaultTTLHelperText = ( props : { ttl ?: number } ) => {
52
- const { ttl = 0 } = props ;
53
-
54
- // Error will show once field is considered touched
55
- if ( ttl < 0 ) {
56
- return null ;
57
- }
58
-
59
- if ( ttl === 0 ) {
60
- return < span > Workspaces will run until stopped manually.</ span > ;
61
- }
62
-
63
- return (
64
- < span >
65
- Workspaces will default to stopping after { ttl } { hours ( ttl ) } without
66
- activity.
67
- </ span >
68
- ) ;
69
- } ;
70
-
71
- const MaxTTLHelperText = ( props : { ttl ?: number } ) => {
72
- const { ttl = 0 } = props ;
73
-
74
- // Error will show once field is considered touched
75
- if ( ttl < 0 ) {
76
- return null ;
77
- }
78
-
79
- if ( ttl === 0 ) {
80
- return < span > Workspaces may run indefinitely.</ span > ;
81
- }
82
-
83
- return (
84
- < span >
85
- Workspaces must stop within { ttl } { hours ( ttl ) } of starting, regardless of
86
- any active connections.
87
- </ span >
88
- ) ;
89
- } ;
50
+ export interface CreateTemplateData {
51
+ name : string ;
52
+ display_name : string ;
53
+ description : string ;
54
+ icon : string ;
55
+ default_ttl_hours : number ;
56
+ max_ttl_hours : number ;
57
+ autostop_requirement_days_of_week : TemplateAutostopRequirementDaysValue ;
58
+ autostop_requirement_weeks : number ;
59
+ allow_user_autostart : boolean ;
60
+ allow_user_autostop : boolean ;
61
+ allow_user_cancel_workspace_jobs : boolean ;
62
+ parameter_values_by_name ?: Record < string , string > ;
63
+ user_variable_values ?: VariableValue [ ] ;
64
+ allow_everyone_group_access : boolean ;
65
+ }
90
66
91
67
const validationSchema = Yup . object ( {
92
68
name : nameValidator ( "Name" ) ,
@@ -643,6 +619,48 @@ const fillNameAndDisplayWithFilename = async (
643
619
] ) ;
644
620
} ;
645
621
622
+ const hours = ( h : number ) => ( h === 1 ? "hour" : "hours" ) ;
623
+
624
+ const DefaultTTLHelperText = ( props : { ttl ?: number } ) => {
625
+ const { ttl = 0 } = props ;
626
+
627
+ // Error will show once field is considered touched
628
+ if ( ttl < 0 ) {
629
+ return null ;
630
+ }
631
+
632
+ if ( ttl === 0 ) {
633
+ return < span > Workspaces will run until stopped manually.</ span > ;
634
+ }
635
+
636
+ return (
637
+ < span >
638
+ Workspaces will default to stopping after { ttl } { hours ( ttl ) } without
639
+ activity.
640
+ </ span >
641
+ ) ;
642
+ } ;
643
+
644
+ const MaxTTLHelperText = ( props : { ttl ?: number } ) => {
645
+ const { ttl = 0 } = props ;
646
+
647
+ // Error will show once field is considered touched
648
+ if ( ttl < 0 ) {
649
+ return null ;
650
+ }
651
+
652
+ if ( ttl === 0 ) {
653
+ return < span > Workspaces may run indefinitely.</ span > ;
654
+ }
655
+
656
+ return (
657
+ < span >
658
+ Workspaces must stop within { ttl } { hours ( ttl ) } of starting, regardless of
659
+ any active connections.
660
+ </ span >
661
+ ) ;
662
+ } ;
663
+
646
664
const useStyles = makeStyles ( ( theme ) => ( {
647
665
ttlFields : {
648
666
width : "100%" ,
0 commit comments