10000 Template settings fixes/kira pilot by Kira-Pilot · Pull Request #3668 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

Template settings fixes/kira pilot #3668

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 13 commits into from
Aug 24, 2022
Prev Previous commit
PR feedback
  • Loading branch information
Kira-Pilot committed Aug 24, 2022
commit 15e1ad2c69d9616b0e810e6980de821df2e7b199
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ dayjs.extend(relativeTime)
dayjs.extend(timezone)

export const Language = {
errorNoDayOfWeek: "Must set at least one day of week if auto-start is enabled",
errorNoTime: "Start time is required when auto-start is enabled",
errorTime: "Time must be in HH:mm format (24 hours)",
errorTimezone: "Invalid timezone",
errorNoStop: "Time until shutdown must be greater than zero when auto-stop is enabled",
errorNoDayOfWeek: "Must set at least one day of week if auto-start is enabled.",
errorNoTime: "Start time is required when auto-start is enabled.",
errorTime: "Time must be in HH:mm format (24 hours).",
errorTimezone: "Invalid timezone.",
errorNoStop: "Time until shutdown must be greater than zero when auto-stop is enabled.",
errorTtlMax: "Please enter a limit that is less than or equal to 168 hours (7 days).",
daysOfWeekLabel: "Days of Week",
daySundayLabel: "Sunday",
Expand Down
10 changes: 7 additions & 3 deletions site/src/pages/TemplateSettingsPage/TemplateSettingsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const Language = {

const MAX_DESCRIPTION_CHAR_LIMIT = 128
const MAX_TTL_DAYS = 7
const MS_HOUR_CONVERSION = 3600000

export const validationSchema = Yup.object({
name: nameValidator(Language.nameLabel),
Expand Down Expand Up @@ -65,15 +66,15 @@ export const TemplateSettingsForm: FC<TemplateSettingsForm> = ({
name: template.name,
description: template.description,
// on display, convert from ms => hours
max_ttl_ms: template.max_ttl_ms / 3600000,
max_ttl_ms: template.max_ttl_ms / MS_HOUR_CONVERSION,
icon: template.icon,
},
validationSchema,
onSubmit: (formData) => {
// on submit, convert from hours => ms
onSubmit({
...formData,
max_ttl_ms: formData.max_ttl_ms ? formData.max_ttl_ms * 3600000 : undefined,
max_ttl_ms: formData.max_ttl_ms ? formData.max_ttl_ms * MS_HOUR_CONVERSION : undefined,
})
},
initialTouched,
Expand Down Expand Up @@ -171,7 +172,10 @@ export const TemplateSettingsForm: FC<TemplateSettingsForm> = ({
variant="outlined"
type="number"
/>
{!form.errors.max_ttl_ms && form.values.max_ttl_ms && (
{/* If a value for max_ttl_ms has been entered and
there are no validation errors for that field, display helper text.
We do not use the MUI helper-text prop because it overrides the validation error */}
{form.values.max_ttl_ms && !form.errors.max_ttl_ms && (
<Typography variant="subtitle2">
{Language.ttlHelperText(form.values.max_ttl_ms)}
</Typography>
Expand Down
0