File tree 2 files changed +12
-8
lines changed
pages/WorkspaceSettingsPage
2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change
1
+ import TextField from "@mui/material/TextField" ;
1
2
import {
2
3
FormFields ,
3
4
FormFooter ,
4
5
FormSection ,
5
6
HorizontalForm ,
6
7
} from "components/Form/Form" ;
7
8
import { useFormik } from "formik" ;
8
- import { FC } from "react" ;
9
+ import { type FC } from "react" ;
9
10
import * as Yup from "yup" ;
10
11
import {
11
12
nameValidator ,
12
13
getFormHelpers ,
13
14
onChangeTrimmed ,
14
15
} from "utils/formUtils" ;
15
- import TextField from "@mui/material/TextField" ;
16
16
import { Workspace } from "api/typesGenerated" ;
17
+ import { Alert } from "components/Alert/Alert" ;
17
18
18
19
export type WorkspaceSettingsFormValues = {
19
20
name : string ;
@@ -42,10 +43,7 @@ export const WorkspaceSettingsForm: FC<{
42
43
43
44
return (
44
45
< HorizontalForm onSubmit = { form . handleSubmit } data-testid = "form" >
45
- < FormSection
46
- title = "General info"
47
- description = "The name of your new workspace."
48
- >
46
+ < FormSection title = "General" description = "The name of your workspace." >
49
47
< FormFields >
50
48
< TextField
51
49
{ ...getFieldHelpers ( "name" ) }
@@ -55,6 +53,12 @@ export const WorkspaceSettingsForm: FC<{
55
53
fullWidth
56
54
label = "Name"
57
55
/>
56
+ { form . values . name !== form . initialValues . name && (
57
+ < Alert severity = "warning" >
58
+ Depending on the template, renaming your workspace may be
59
+ destructive
60
+ </ Alert >
61
+ ) }
58
62
</ FormFields >
59
63
</ FormSection >
60
64
< FormFooter onCancel = { onCancel } isLoading = { isSubmitting } />
Original file line number Diff line number Diff line change @@ -64,11 +64,11 @@ export const getFormHelpers =
64
64
} ;
65
65
66
66
export const onChangeTrimmed =
67
- < T > ( form : FormikContextType < T > , callback ?: ( ) => void ) =>
67
+ < T > ( form : FormikContextType < T > , callback ?: ( value : string ) => void ) =>
68
68
( event : ChangeEvent < HTMLInputElement > ) : void => {
69
69
event . target . value = event . target . value . trim ( ) ;
70
70
form . handleChange ( event ) ;
71
- callback && callback ( ) ;
71
+ callback ?. ( event . target . value ) ;
72
72
} ;
73
73
74
74
// REMARK: Keep these consts in sync with coderd/httpapi/httpapi.go
You can’t perform that action at this time.
0 commit comments