Skip to content

Commit 22db64f

Browse files
committed
remove max ttl from ui
1 parent 6ee1229 commit 22db64f

File tree

10 files changed

+15
-150
lines changed

10 files changed

+15
-150
lines changed

coderd/activitybump_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,6 @@ func TestWorkspaceActivityBump(t *testing.T) {
214214
require.NoError(t, err)
215215
_ = sshConn.Close()
216216

217-
assertBumped(true) // also asserts max ttl not exceeded
217+
assertBumped(true)
218218
})
219219
}

coderd/apidoc/docs.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codersdk/deployment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ when required by your organization's security policy.`,
543543
}
544544
deploymentGroupUserQuietHoursSchedule = serpent.Group{
545545
Name: "User Quiet Hours Schedule",
546-
Description: "Allow users to set quiet hours schedules each day for workspaces to avoid workspaces stopping during the day due to template max TTL.",
546+
Description: "Allow users to set quiet hours schedules each day for workspaces to avoid workspaces stopping during the day due to template scheduling.",
547547
YAML: "userQuietHoursSchedule",
548548
}
549549
deploymentGroupDangerous = serpent.Group{

codersdk/users.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ type UpdateUserQuietHoursScheduleRequest struct {
160160
// window is. Schedule must not be empty. For new users, the schedule is set
161161
// to 2am in their browser or computer's timezone. The schedule denotes the
162162
// beginning of a 4 hour window where the workspace is allowed to
163-
// automatically stop or restart due to maintenance or template max TTL.
163+
// automatically stop or restart due to maintenance or template schedule.
164164
//
165165
// The schedule must be daily with a single time, and should have a timezone
166166
// specified via a CRON_TZ prefix (otherwise UTC will be used).

docs/api/schemas.md

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/src/pages/TemplateSettingsPage/TemplateSchedulePage/TTLHelperText.tsx

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,26 +46,6 @@ export const ActivityBumpHelperText = (props: { bump?: number }) => {
4646
);
4747
};
4848

49-
export const MaxTTLHelperText = (props: { ttl?: number }) => {
50-
const { ttl = 0 } = props;
51-
52-
// Error will show once field is considered touched
53-
if (ttl < 0) {
54-
return null;
55-
}
56-
57-
if (ttl === 0) {
58-
return <span>Workspaces may run indefinitely.</span>;
59-
}
60-
61-
return (
62-
<span>
63-
Workspaces must stop within {ttl} {hours(ttl)} of starting, regardless of
64-
any active connections.
65-
</span>
66-
);
67-
};
68-
6949
export const FailureTTLHelperText = (props: { ttl?: number }) => {
7050
const { ttl = 0 } = props;
7151

site/src/pages/TemplateSettingsPage/TemplateSchedulePage/TemplateScheduleForm.tsx

Lines changed: 7 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { useTheme } from "@emotion/react";
22
import Checkbox from "@mui/material/Checkbox";
33
import FormControlLabel from "@mui/material/FormControlLabel";
4-
import Link from "@mui/material/Link";
54
import MenuItem from "@mui/material/MenuItem";
65
import Switch from "@mui/material/Switch";
76
import TextField from "@mui/material/TextField";
@@ -15,7 +14,6 @@ import {
1514
FormFields,
1615
} from "components/Form/Form";
1716
import { Stack } from "components/Stack/Stack";
18-
import { docs } from "utils/docs";
1917
import { getFormHelpers } from "utils/formUtils";
2018
import {
2119
calculateAutostopRequirementDaysValue,
@@ -38,7 +36,6 @@ import {
3836
DormancyAutoDeletionTTLHelperText,
3937
DormancyTTLHelperText,
4038
FailureTTLHelperText,
41-
MaxTTLHelperText,
4239
} from "./TTLHelperText";
4340
import {
4441
useWorkspacesToGoDormant,
@@ -77,15 +74,6 @@ export const TemplateScheduleForm: FC<TemplateScheduleForm> = ({
7774
// on display, convert from ms => hours
7875
default_ttl_ms: template.default_ttl_ms / MS_HOUR_CONVERSION,
7976
activity_bump_ms: template.activity_bump_ms / MS_HOUR_CONVERSION,
80-
// the API ignores these values, but to avoid tripping up validation set
81-
// it to zero if the user can't set the field.
82-
use_max_ttl:
83-
template.use_max_ttl === undefined
84-
? template.max_ttl_ms > 0
85-
: template.use_max_ttl,
86-
max_ttl_ms: allowAdvancedScheduling
87-
? template.max_ttl_ms / MS_HOUR_CONVERSION
88-
: 0,
8977
failure_ttl_ms: allowAdvancedScheduling
9078
? template.failure_ttl_ms / MS_DAY_CONVERSION
9179
: 0,
@@ -214,10 +202,6 @@ export const TemplateScheduleForm: FC<TemplateScheduleForm> = ({
214202
activity_bump_ms: form.values.activity_bump_ms
215203
? form.values.activity_bump_ms * MS_HOUR_CONVERSION
216204
: undefined,
217-
max_ttl_ms:
218-
form.values.max_ttl_ms && form.values.use_max_ttl
219-
? form.values.max_ttl_ms * MS_HOUR_CONVERSION
220-
: undefined,
221205
failure_ttl_ms: form.values.failure_ttl_ms
222206
? form.values.failure_ttl_ms * MS_DAY_CONVERSION
223207
: undefined,
@@ -228,14 +212,12 @@ export const TemplateScheduleForm: FC<TemplateScheduleForm> = ({
228212
? form.values.time_til_dormant_autodelete_ms * MS_DAY_CONVERSION
229213
: undefined,
230214

231-
autostop_requirement: form.values.use_max_ttl
232-
? undefined
233-
: {
234-
days_of_week: calculateAutostopRequirementDaysValue(
235-
form.values.autostop_requirement_days_of_week,
236-
),
237-
weeks: autostop_requirement_weeks,
238-
},
215+
autostop_requirement: {
216+
days_of_week: calculateAutostopRequirementDaysValue(
217+
form.values.autostop_requirement_days_of_week,
218+
),
219+
weeks: autostop_requirement_weeks,
220+
},
239221
autostart_requirement: {
240222
days_of_week: form.values.autostart_requirement_days_of_week,
241223
},
@@ -330,27 +312,6 @@ export const TemplateScheduleForm: FC<TemplateScheduleForm> = ({
330312
}
331313
};
332314

333-
const handleToggleUseMaxTTL = async () => {
334-
const val = !form.values.use_max_ttl;
335-
if (val) {
336-
// set max_ttl to 1, set autostop_requirement to empty
337-
await form.setValues({
338-
...form.values,
339-
use_max_ttl: val,
340-
max_ttl_ms: 1,
341-
autostop_requirement_days_of_week: "off",
342-
autostop_requirement_weeks: 1,
343-
});
344-
} else {
345-
// set max_ttl to 0
346-
await form.setValues({
347-
...form.values,
348-
use_max_ttl: val,
349-
max_ttl_ms: 0,
350-
});
351-
}
352-
};
353-
354315
return (
355316
<HorizontalForm
356317
onSubmit={form.handleSubmit}
@@ -402,7 +363,7 @@ export const TemplateScheduleForm: FC<TemplateScheduleForm> = ({
402363
/>
403364
),
404365
})}
405-
disabled={isSubmitting || form.values.use_max_ttl}
366+
disabled={isSubmitting}
406367
fullWidth
407368
select
408369
value={form.values.autostop_requirement_days_of_week}
@@ -433,7 +394,6 @@ export const TemplateScheduleForm: FC<TemplateScheduleForm> = ({
433394
})}
434395
disabled={
435396
isSubmitting ||
436-
form.values.use_max_ttl ||
437397
!["saturday", "sunday"].includes(
438398
form.values.autostop_requirement_days_of_week || "",
439399
)
@@ -446,68 +406,6 @@ export const TemplateScheduleForm: FC<TemplateScheduleForm> = ({
446406
</Stack>
447407
</FormSection>
448408

449-
<FormSection
450-
title="Max Lifetime"
451-
description="Define the maximum lifetime for workspaces created from this template."
452-
deprecated
453-
>
454-
<Stack direction="column" spacing={4}>
455-
<Stack direction="row" alignItems="center">
456-
<FormControlLabel
457-
control={
458-
<Checkbox
459-
id="use_max_ttl"
460-
size="small"
461-
disabled={isSubmitting || !allowAdvancedScheduling}
462-
onChange={handleToggleUseMaxTTL}
463-
name="use_max_ttl"
464-
checked={form.values.use_max_ttl}
465-
/>
466-
}
467-
label={
468-
<Stack spacing={0.5}>
469-
<strong>
470-
Use a max lifetime instead of a required autostop schedule.
471-
</strong>
472-
<span
473-
css={{
474-
fontSize: 12,
475-
color: theme.palette.text.secondary,
476-
}}
477-
>
478-
Use a maximum lifetime for workspaces created from this
479-
template instead of an autostop requirement as configured
480-
above.
481-
</span>
482-
</Stack>
483-
}
484-
/>
485-
</Stack>
486-
487-
<TextField
488-
{...getFieldHelpers("max_ttl_ms", {
489-
helperText: allowAdvancedScheduling ? (
490-
<MaxTTLHelperText ttl={form.values.max_ttl_ms} />
491-
) : (
492-
<>
493-
You need an enterprise license to use it{" "}
494-
<Link href={docs("/enterprise")}>Learn more</Link>.
495-
</>
496-
),
497-
})}
498-
disabled={
499-
isSubmitting ||
500-
!form.values.use_max_ttl ||
501-
!allowAdvancedScheduling
502-
}
503-
fullWidth
504-
inputProps={{ min: 0, step: 1 }}
505-
label="Max lifetime (hours)"
506-
type="number"
507-
/>
508-
</Stack>
509-
</FormSection>
510-
511409
<FormSection
512410
title="Allow users scheduling"
513411
description="Allow users to set custom autostart and autostop scheduling options for workspaces created from this template."

site/src/pages/TemplateSettingsPage/TemplateSchedulePage/TemplateSchedulePage.test.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ type FillAndSubmitConfig = {
6363

6464
const fillAndSubmitForm = async ({
6565
default_ttl_ms,
66-
max_ttl_ms,
6766
failure_ttl_ms,
6867
time_til_dormant_ms,
6968
time_til_dormant_autodelete_ms,
@@ -78,17 +77,6 @@ const fillAndSubmitForm = async ({
7877
await user.type(defaultTtlField, default_ttl_ms.toString());
7978
}
8079

81-
if (max_ttl_ms) {
82-
const useMaxTtlCheckbox = screen.getByRole("checkbox", {
83-
name: /Use a max lifetime/i,
84-
});
85-
const maxTtlField = await screen.findByLabelText("Max lifetime (hours)");
86-
87-
await user.click(useMaxTtlCheckbox);
88-
await user.clear(maxTtlField);
89-
await user.type(maxTtlField, max_ttl_ms.toString());
90-
}
91-
9280
if (failure_ttl_ms) {
9381
const failureTtlField = screen.getByRole("checkbox", {
9482
name: /Failure Cleanup/i,

site/src/pages/TemplateSettingsPage/TemplateSchedulePage/formHelpers.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export interface TemplateScheduleFormValues
1010
UpdateTemplateMeta,
1111
"autostop_requirement" | "autostart_requirement"
1212
> {
13-
use_max_ttl: boolean;
1413
autostart_requirement_days_of_week: TemplateAutostartRequirementDaysValue[];
1514
autostop_requirement_days_of_week: TemplateAutostopRequirementDaysValue;
1615
autostop_requirement_weeks: number;

0 commit comments

Comments
 (0)