Skip to content

Commit 6fde537

Browse files
authored
web: use seconds in max TTL input (#3576)
Milliseconds are more difficult to deal with due to all of the zeros. Also, describe this feature as "auto-stop" to be consistent with our Workspace page UI and CLI. "ttl" is our backend lingo which should eventually be updated.
1 parent 5e36be8 commit 6fde537

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

site/src/pages/TemplateSettingsPage/TemplateSettingsForm.tsx

+9-5
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ import * as Yup from "yup"
1818
export const Language = {
1919
nameLabel: "Name",
2020
descriptionLabel: "Description",
21+
maxTtlLabel: "Auto-stop limit",
2122
iconLabel: "Icon",
22-
maxTtlLabel: "Max TTL",
2323
// This is the same from the CLI on https://github.com/coder/coder/blob/546157b63ef9204658acf58cb653aa9936b70c49/cli/templateedit.go#L59
24-
maxTtlHelperText: "Edit the template maximum time before shutdown in milliseconds",
24+
maxTtlHelperText: "Edit the template maximum time before shutdown in seconds",
2525
formAriaLabel: "Template settings form",
2626
selectEmoji: "Select emoji",
2727
}
@@ -59,9 +59,7 @@ export const TemplateSettingsForm: FC<TemplateSettingsForm> = ({
5959
icon: template.icon,
6060
},
6161
validationSchema,
62-
onSubmit: (data) => {
63-
onSubmit(data)
64-
},
62+
onSubmit,
6563
initialTouched,
6664
})
6765
const getFieldHelpers = getFormHelpersWithError<UpdateTemplateMeta>(form, error)
@@ -156,6 +154,12 @@ export const TemplateSettingsForm: FC<TemplateSettingsForm> = ({
156154
inputProps={{ min: 0, step: 1 }}
157155
label={Language.maxTtlLabel}
158156
variant="outlined"
157+
// Display seconds from ms
158+
value={form.values.max_ttl_ms ? form.values.max_ttl_ms / 1000 : ""}
159+
// Convert ms to seconds
160+
onChange={(event) =>
161+
form.setFieldValue("max_ttl_ms", Number(event.currentTarget.value) * 1000)
162+
}
159163
/>
160164
</Stack>
161165

0 commit comments

Comments
 (0)