Skip to content

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

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 1 commit into from
Feb 21, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
};