Skip to content

Commit 78c9f82

Browse files
fix(site): fix error when typing long number on ttl (coder#12249)
1 parent 1d254f4 commit 78c9f82

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

site/src/pages/WorkspaceSettingsPage/WorkspaceSchedulePage/WorkspaceScheduleForm.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ export const WorkspaceScheduleForm: FC<WorkspaceScheduleFormProps> = ({
428428
!template.allow_user_autostop ||
429429
!form.values.autostopEnabled
430430
}
431-
inputProps={{ min: 0, step: "any" }}
431+
inputProps={{ min: 0, step: "any", maxLength: 5 }}
432432
label={Language.ttlLabel}
433433
type="number"
434434
fullWidth
@@ -452,10 +452,17 @@ export const ttlShutdownAt = (formTTL: number): string => {
452452
if (formTTL === 0) {
453453
// Passing an empty value for TTL in the form results in a number that is not zero but less than 1.
454454
return "Your workspace will not automatically shut down.";
455-
} else {
455+
}
456+
457+
try {
456458
return `Your workspace will shut down ${formatDuration(
457459
intervalToDuration({ start: 0, end: formTTL * 60 * 60 * 1000 }),
458460
{ delimiter: " and " },
459461
)} after its next start. We delay shutdown by 1 hour whenever we detect activity.`;
462+
} catch (e) {
463+
if (e instanceof RangeError) {
464+
return Language.errorTtlMax;
465+
}
466+
throw e;
460467
}
461468
};

0 commit comments

Comments
 (0)