Skip to content

web: use seconds in max TTL input #3576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions site/src/pages/TemplateSettingsPage/TemplateSettingsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import * as Yup from "yup"
export const Language = {
nameLabel: "Name",
descriptionLabel: "Description",
maxTtlLabel: "Auto-stop limit",
iconLabel: "Icon",
maxTtlLabel: "Max TTL",
// This is the same from the CLI on https://github.com/coder/coder/blob/546157b63ef9204658acf58cb653aa9936b70c49/cli/templateedit.go#L59
maxTtlHelperText: "Edit the template maximum time before shutdown in milliseconds",
maxTtlHelperText: "Edit the template maximum time before shutdown in seconds",
formAriaLabel: "Template settings form",
}

Expand Down Expand Up @@ -51,9 +51,7 @@ export const TemplateSettingsForm: FC<TemplateSettingsForm> = ({
icon: template.icon,
},
validationSchema,
onSubmit: (data) => {
onSubmit(data)
},
onSubmit,
initialTouched,
})
const getFieldHelpers = getFormHelpersWithError<UpdateTemplateMeta>(form, error)
Expand Down Expand Up @@ -114,6 +112,12 @@ export const TemplateSettingsForm: FC<TemplateSettingsForm> = ({
inputProps={{ min: 0, step: 1 }}
label={Language.maxTtlLabel}
variant="outlined"
// Display seconds from ms
value={form.values.max_ttl_ms ? form.values.max_ttl_ms / 1000 : ""}
// Convert ms to seconds
onChange={(event) =>
form.setFieldValue("max_ttl_ms", Number(event.currentTarget.value) * 1000)
}
/>
</Stack>

Expand Down