mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
@@ -110,4 +110,22 @@ describe("validationSchema", () => {
|
||||
const validate = () => validationSchema.validateSync(values)
|
||||
expect(validate).toThrowError(Language.errorTimezone)
|
||||
})
|
||||
|
||||
it("allows a ttl of 7 days", () => {
|
||||
const values: WorkspaceScheduleFormValues = {
|
||||
...valid,
|
||||
ttl: 24 * 7,
|
||||
}
|
||||
const validate = () => validationSchema.validateSync(values)
|
||||
expect(validate).not.toThrowError()
|
||||
})
|
||||
|
||||
it("disallows a ttl of 7 days + 1 hour", () => {
|
||||
const values: WorkspaceScheduleFormValues = {
|
||||
...valid,
|
||||
ttl: 24 * 7 + 1,
|
||||
}
|
||||
const validate = () => validationSchema.validateSync(values)
|
||||
expect(validate).toThrowError("ttl must be less than or equal to 168")
|
||||
})
|
||||
})
|
||||
|
||||
@@ -124,7 +124,10 @@ export const validationSchema = Yup.object({
|
||||
}
|
||||
}
|
||||
}),
|
||||
ttl: Yup.number().min(0).integer(),
|
||||
ttl: Yup.number()
|
||||
.integer()
|
||||
.min(0)
|
||||
.max(24 * 7 /* 7 days */),
|
||||
})
|
||||
|
||||
export const WorkspaceScheduleForm: FC<WorkspaceScheduleFormProps> = ({
|
||||
@@ -171,7 +174,7 @@ export const WorkspaceScheduleForm: FC<WorkspaceScheduleFormProps> = ({
|
||||
<Stack>
|
||||
<TextField
|
||||
{...formHelpers("startTime", Language.startTimeHelperText)}
|
||||
disabled={form.isSubmitting || isLoading}
|
||||
disabled={isLoading}
|
||||
InputLabelProps={{
|
||||
shrink: true,
|
||||
}}
|
||||
@@ -189,7 +192,7 @@ export const WorkspaceScheduleForm: FC<WorkspaceScheduleFormProps> = ({
|
||||
</Link>
|
||||
</>,
|
||||
)}
|
||||
disabled={form.isSubmitting || isLoading || !form.values.startTime}
|
||||
disabled={isLoading || !form.values.startTime}
|
||||
InputLabelProps={{
|
||||
shrink: true,
|
||||
}}
|
||||
@@ -207,7 +210,7 @@ export const WorkspaceScheduleForm: FC<WorkspaceScheduleFormProps> = ({
|
||||
control={
|
||||
<Checkbox
|
||||
checked={checkbox.value}
|
||||
disabled={!form.values.startTime || form.isSubmitting || isLoading}
|
||||
disabled={!form.values.startTime || isLoading}
|
||||
onChange={form.handleChange}
|
||||
name={checkbox.name}
|
||||
color="primary"
|
||||
@@ -226,13 +229,13 @@ export const WorkspaceScheduleForm: FC<WorkspaceScheduleFormProps> = ({
|
||||
|
||||
<TextField
|
||||
{...formHelpers("ttl", Language.ttlHelperText)}
|
||||
disabled={form.isSubmitting || isLoading}
|
||||
disabled={isLoading}
|
||||
inputProps={{ min: 0, step: 1 }}
|
||||
label={Language.ttlLabel}
|
||||
type="number"
|
||||
/>
|
||||
|
||||
<FormFooter onCancel={onCancel} isLoading={form.isSubmitting || isLoading} />
|
||||
<FormFooter onCancel={onCancel} isLoading={isLoading} />
|
||||
</Stack>
|
||||
</form>
|
||||
</FullPageForm>
|
||||
|
||||
Reference in New Issue
Block a user