fix(site): fix error when typing long number on ttl (#12249)

This commit is contained in:
Bruno Quaresma 2024-02-21 14:29:29 -03:00 committed by GitHub
parent 1d254f4680
commit 78c9f82719
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 2 deletions

View File

@ -428,7 +428,7 @@ export const WorkspaceScheduleForm: FC<WorkspaceScheduleFormProps> = ({
!template.allow_user_autostop ||
!form.values.autostopEnabled
}
inputProps={{ min: 0, step: "any" }}
inputProps={{ min: 0, step: "any", maxLength: 5 }}
label={Language.ttlLabel}
type="number"
fullWidth
@ -452,10 +452,17 @@ export const ttlShutdownAt = (formTTL: number): string => {
if (formTTL === 0) {
// Passing an empty value for TTL in the form results in a number that is not zero but less than 1.
return "Your workspace will not automatically shut down.";
} else {
}
try {
return `Your workspace will shut down ${formatDuration(
intervalToDuration({ start: 0, end: formTTL * 60 * 60 * 1000 }),
{ delimiter: " and " },
)} after its next start. We delay shutdown by 1 hour whenever we detect activity.`;
} catch (e) {
if (e instanceof RangeError) {
return Language.errorTtlMax;
}
throw e;
}
};