@@ -6,26 +6,16 @@ import {
6
6
HorizontalForm ,
7
7
} from "components/Form/Form" ;
8
8
import { useFormik } from "formik" ;
9
- import { useState , type FC } from "react" ;
9
+ import { type FC } from "react" ;
10
10
import * as Yup from "yup" ;
11
11
import {
12
12
nameValidator ,
13
13
getFormHelpers ,
14
14
onChangeTrimmed ,
15
15
} from "utils/formUtils" ;
16
- import {
17
- AutomaticUpdates ,
18
- AutomaticUpdateses ,
19
- Workspace ,
20
- } from "api/typesGenerated" ;
16
+ import { AutomaticUpdates , Workspace } from "api/typesGenerated" ;
21
17
import { Alert } from "components/Alert/Alert" ;
22
- import {
23
- FormControl ,
24
- InputLabel ,
25
- MenuItem ,
26
- Select ,
27
- SelectChangeEvent ,
28
- } from "@mui/material" ;
18
+ import MenuItem from "@mui/material/MenuItem" ;
29
19
30
20
export type WorkspaceSettingsFormValues = {
31
21
name : string ;
@@ -58,14 +48,7 @@ export const WorkspaceSettingsForm: FC<{
58
48
return inputString . charAt ( 0 ) . toUpperCase ( ) + inputString . slice ( 1 ) ;
59
49
} ;
60
50
61
- const [ automaticUpdates , setAutomaticUpdates ] = useState < AutomaticUpdates > (
62
- workspace . automatic_updates ,
63
- ) ;
64
-
65
- const handleChange = ( event : SelectChangeEvent ) => {
66
- setAutomaticUpdates ( event . target . value as AutomaticUpdates ) ;
67
- form . setFieldValue ( "automatic_updates" , automaticUpdates ) ;
68
- } ;
51
+ const autoUpdatesSet = [ "never" , "always" ] ;
69
52
70
53
return (
71
54
< HorizontalForm onSubmit = { form . handleSubmit } data-testid = "form" >
@@ -94,25 +77,22 @@ export const WorkspaceSettingsForm: FC<{
94
77
title = "Automatic Updates"
95
78
description = "Configure your workspace to automatically update to the active template version when started."
96
79
>
97
- < FormControl fullWidth >
98
- < FormFields >
99
- < InputLabel htmlFor = "automatic_updates" > Update Policy</ InputLabel >
100
- < Select
101
- labelId = "automatic_updates"
102
- id = "automatic_updates"
103
- label = "Update Policy"
104
- value = { automaticUpdates }
105
- onChange = { handleChange }
106
- disabled = { form . isSubmitting }
107
- >
108
- { AutomaticUpdateses . map ( ( value ) => (
109
- < MenuItem value = { value } >
110
- { capitalizeFirstLetter ( value ) }
111
- </ MenuItem >
112
- ) ) }
113
- </ Select >
114
- </ FormFields >
115
- </ FormControl >
80
+ < FormFields >
81
+ < TextField
82
+ { ...getFieldHelpers ( "automatic_updates" ) }
83
+ id = "automatic_updates"
84
+ label = "Update Policy"
85
+ value = { form . values . automatic_updates }
86
+ select
87
+ disabled = { form . isSubmitting }
88
+ >
89
+ { autoUpdatesSet . map ( ( value ) => (
90
+ < MenuItem value = { value } key = { value } >
91
+ { capitalizeFirstLetter ( value ) }
92
+ </ MenuItem >
93
+ ) ) }
94
+ </ TextField >
95
+ </ FormFields >
116
96
</ FormSection >
117
97
< FormFooter onCancel = { onCancel } isLoading = { isSubmitting } />
118
98
</ HorizontalForm >
0 commit comments