Skip to content

Commit a1b34fb

Browse files
committed
cleanup
1 parent 8daffd7 commit a1b34fb

File tree

2 files changed

+22
-40
lines changed

2 files changed

+22
-40
lines changed

site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx

+20-40
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,16 @@ import {
66
HorizontalForm,
77
} from "components/Form/Form";
88
import { useFormik } from "formik";
9-
import { useState, type FC } from "react";
9+
import { type FC } from "react";
1010
import * as Yup from "yup";
1111
import {
1212
nameValidator,
1313
getFormHelpers,
1414
onChangeTrimmed,
1515
} from "utils/formUtils";
16-
import {
17-
AutomaticUpdates,
18-
AutomaticUpdateses,
19-
Workspace,
20-
} from "api/typesGenerated";
16+
import { AutomaticUpdates, Workspace } from "api/typesGenerated";
2117
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";
2919

3020
export type WorkspaceSettingsFormValues = {
3121
name: string;
@@ -58,14 +48,7 @@ export const WorkspaceSettingsForm: FC<{
5848
return inputString.charAt(0).toUpperCase() + inputString.slice(1);
5949
};
6050

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"];
6952

7053
return (
7154
<HorizontalForm onSubmit={form.handleSubmit} data-testid="form">
@@ -94,25 +77,22 @@ export const WorkspaceSettingsForm: FC<{
9477
title="Automatic Updates"
9578
description="Configure your workspace to automatically update to the active template version when started."
9679
>
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>
11696
</FormSection>
11797
<FormFooter onCancel={onCancel} isLoading={isSubmitting} />
11898
</HorizontalForm>

site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsPage.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ const WorkspaceSettingsPage = () => {
1717
const username = params.username.replace("@", "");
1818
const workspace = useWorkspaceSettings();
1919
const navigate = useNavigate();
20+
2021
const mutation = useMutation({
2122
mutationFn: async (formValues: WorkspaceSettingsFormValues) => {
23+
console.log("in here", formValues.automatic_updates);
2224
await patchWorkspace(workspace.id, { name: formValues.name });
2325
await updateWorkspaceAutomaticUpdates(
2426
workspace.id,

0 commit comments

Comments
 (0)