Skip to content

feat: add inactivity cleanup and failure cleanup configuration fields to Template Schedule Form #7402

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 24 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
744e476
added workspace actions entitlement
Kira-Pilot May 1, 2023
e6e1ec6
added workspace actions experiment
Kira-Pilot May 1, 2023
c049e9e
added new route for template enterprise meta
Kira-Pilot May 3, 2023
537ced7
removing new route; repurposing old
Kira-Pilot May 3, 2023
cd6a485
add new fields to get endpoints
Kira-Pilot May 3, 2023
6c984fa
Merge remote-tracking branch 'origin/main' into workspace-actions-tem…
Kira-Pilot May 3, 2023
57a9de7
removed workspace actions experiment
Kira-Pilot May 3, 2023
07cb07c
added logic to enterprise template store
Kira-Pilot May 3, 2023
7091fc1
added new form fields
Kira-Pilot May 3, 2023
e565225
feature flagged new fields
Kira-Pilot May 3, 2023
3d9f6f5
fix validation
Kira-Pilot May 4, 2023
abab4c8
fixed submit btn
Kira-Pilot May 4, 2023
ad37203
Merge remote-tracking branch 'origin/main' into workspace-actions-tem…
Kira-Pilot May 4, 2023
240f297
fix tests
Kira-Pilot May 4, 2023
be512ee
changed ttl defaults
Kira-Pilot May 4, 2023
8536b75
added FE tests
Kira-Pilot May 4, 2023
a05eb6c
added BE tests
Kira-Pilot May 4, 2023
0478e07
fixed lint
Kira-Pilot May 4, 2023
bba4722
adjusted comment language
Kira-Pilot May 4, 2023
c76a0f4
fixing unstaged changes check
Kira-Pilot May 4, 2023
9db6b13
fix test
Kira-Pilot May 4, 2023
a2a38f0
Merge branch 'main' into workspace-actions-template-route/kira-pilot
Kira-Pilot May 4, 2023
9fa9c5b
Update coderd/database/migrations/000122_add_template_cleanup_ttls.do…
Kira-Pilot May 5, 2023
43a2267
Update coderd/database/migrations/000122_add_template_cleanup_ttls.up…
Kira-Pilot May 5, 2023
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
Prev Previous commit
Next Next commit
feature flagged new fields
  • Loading branch information
Kira-Pilot committed May 3, 2023
commit e56522584a60d81ce82ef9adc0c68bcd8a34ab53
6 changes: 4 additions & 2 deletions coderd/apidoc/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions coderd/apidoc/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions codersdk/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -1668,6 +1668,9 @@ const (
// feature is not yet complete in functionality.
ExperimentMoons Experiment = "moons"

// https://github.com/coder/coder/milestone/19
ExperimentWorkspaceActions Experiment = "workspace_actions"

// Add new experiments here!
// ExperimentExample Experiment = "example"
)
Expand Down
7 changes: 4 additions & 3 deletions docs/api/schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -2502,9 +2502,10 @@ CreateParameterRequest is a structure used to create a new parameter value for a

#### Enumerated Values

| Value |
| ------- |
| `moons` |
| Value |
| ------------------- |
| `moons` |
| `workspace_actions` |

## codersdk.Feature

Expand Down
4 changes: 2 additions & 2 deletions site/src/api/typesGenerated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1365,8 +1365,8 @@ export const Entitlements: Entitlement[] = [
]

// From codersdk/deployment.go
export type Experiment = "moons"
export const Experiments: Experiment[] = ["moons"]
export type Experiment = "moons" | "workspace_actions"
export const Experiments: Experiment[] = ["moons", "workspace_actions"]

// From codersdk/deployment.go
export type FeatureName =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export interface TemplateScheduleForm {
isSubmitting: boolean
error?: unknown
allowAdvancedScheduling: boolean
allowWorkspaceActions: boolean
// Helpful to show field errors on Storybook
initialTouched?: FormikTouched<UpdateTemplateMeta>
}
Expand All @@ -113,6 +114,7 @@ export const TemplateScheduleForm: FC<TemplateScheduleForm> = ({
onCancel,
error,
allowAdvancedScheduling,
allowWorkspaceActions,
isSubmitting,
initialTouched,
}) => {
Expand Down Expand Up @@ -317,72 +319,78 @@ export const TemplateScheduleForm: FC<TemplateScheduleForm> = ({
</Stack>
</Stack>
</FormSection>
<FormSection
title="Failure Cleanup"
description="When enabled, Coder will automatically stop workspaces that are in a failed state after a specified number of days."
>
<FormFields>
<FormControlLabel
control={
<Switch
name="failureCleanupEnabled"
checked={form.values.failure_cleanup_enabled}
onChange={handleToggleFailureCleanup}
color="primary"
{allowAdvancedScheduling && allowWorkspaceActions && (
<>
<FormSection
title="Failure Cleanup"
description="When enabled, Coder will automatically stop workspaces that are in a failed state after a specified number of days."
>
<FormFields>
<FormControlLabel
control={
<Switch
name="failureCleanupEnabled"
checked={form.values.failure_cleanup_enabled}
onChange={handleToggleFailureCleanup}
color="primary"
/>
}
label="Enable Failure Cleanup"
/>
}
label="Enable Failure Cleanup"
/>
<TextField
{...getFieldHelpers(
"failure_ttl_ms",
<TTLHelperText
translationName="failureTTLHelperText"
ttl={form.values.failure_ttl_ms}
/>,
)}
disabled={isSubmitting || !form.values.failure_cleanup_enabled}
fullWidth
inputProps={{ min: 0, step: 1 }}
label="Time until cleanup (days)"
variant="outlined"
type="number"
/>
</FormFields>
</FormSection>
<FormSection
title="Inactivity Cleanup"
description="When enabled, Coder will automatically delete workspaces that are in an inactive state after a specified number of days."
>
<FormFields>
<FormControlLabel
control={
<Switch
name="inactivityCleanupEnabled"
checked={form.values.inactivity_cleanup_enabled}
onChange={handleToggleInactivityCleanup}
color="primary"
<TextField
{...getFieldHelpers(
"failure_ttl_ms",
<TTLHelperText
translationName="failureTTLHelperText"
ttl={form.values.failure_ttl_ms}
/>,
)}
disabled={isSubmitting || !form.values.failure_cleanup_enabled}
fullWidth
inputProps={{ min: 0, step: 1 }}
label="Time until cleanup (days)"
variant="outlined"
type="number"
/>
}
label="Enable Inactivity Cleanup"
/>
<TextField
{...getFieldHelpers(
"inactivity_ttl_ms",
<TTLHelperText
translationName="inactivityTTLHelperText"
ttl={form.values.inactivity_ttl_ms}
/>,
)}
disabled={isSubmitting}
fullWidth
inputProps={{ min: 0, step: 1 }}
label="Time until cleanup (days)"
variant="outlined"
type="number"
/>
</FormFields>
</FormSection>
</FormFields>
</FormSection>
<FormSection
title="Inactivity Cleanup"
description="When enabled, Coder will automatically delete workspaces that are in an inactive state after a specified number of days."
>
<FormFields>
<FormControlLabel
control={
<Switch
name="inactivityCleanupEnabled"
checked={form.values.inactivity_cleanup_enabled}
onChange={handleToggleInactivityCleanup}
color="primary"
/>
}
label="Enable Inactivity Cleanup"
/>
<TextField
{...getFieldHelpers(
"inactivity_ttl_ms",
<TTLHelperText
translationName="inactivityTTLHelperText"
ttl={form.values.inactivity_ttl_ms}
/>,
)}
disabled={
isSubmitting || !form.values.inactivity_cleanup_enabled
}
fullWidth
inputProps={{ min: 0, step: 1 }}
label="Time until cleanup (days)"
variant="outlined"
type="number"
/>
</FormFields>
</FormSection>
</>
)}
<FormFooter onCancel={onCancel} isLoading={isSubmitting} />
</HorizontalForm>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ const TemplateSchedulePage: FC = () => {
const { template: templateName } = useParams() as { template: string }
const navigate = useNavigate()
const { template } = useTemplateSettingsContext()
const { entitlements } = useDashboard()
const { entitlements, experiments } = useDashboard()
const allowAdvancedScheduling =
entitlements.features["advanced_template_scheduling"].enabled
// This check can be removed when https://github.com/coder/coder/milestone/19
// is merged up
const allowWorkspaceActions = experiments.includes("workspace_actions")

const {
mutate: updateTemplate,
isLoading: isSubmitting,
Expand All @@ -37,6 +41,7 @@ const TemplateSchedulePage: FC = () => {
</Helmet>
<TemplateSchedulePageView
allowAdvancedScheduling={allowAdvancedScheduling}
allowWorkspaceActions={allowWorkspaceActions}
isSubmitting={isSubmitting}
template={template}
submitError={submitError}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface TemplateSchedulePageViewProps {
submitError?: unknown
initialTouched?: ComponentProps<typeof TemplateScheduleForm>["initialTouched"]
allowAdvancedScheduling: boolean
allowWorkspaceActions: boolean
}

export const TemplateSchedulePageView: FC<TemplateSchedulePageViewProps> = ({
Expand All @@ -20,6 +21,7 @@ export const TemplateSchedulePageView: FC<TemplateSchedulePageViewProps> = ({
onSubmit,
isSubmitting,
allowAdvancedScheduling,
allowWorkspaceActions,
submitError,
initialTouched,
}) => {
Expand All @@ -33,6 +35,7 @@ export const TemplateSchedulePageView: FC<TemplateSchedulePageViewProps> = ({

<TemplateScheduleForm
allowAdvancedScheduling={allowAdvancedScheduling}
allowWorkspaceActions={allowWorkspaceActions}
initialTouched={initialTouched}
isSubmitting={isSubmitting}
template={template}
Expand Down