- Notifications
You must be signed in to change notification settings - Fork928
feat: add frontend support for enabling automatic workspace updates#10375
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
a66709a
262050a
86b0cb7
ce25bba
3602dd9
2f0ef94
c68a8b6
e751552
2a67fe3
2018b0b
673b214
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -121,3 +121,11 @@ export const useIsWorkspaceActionsEnabled = (): boolean => { | ||
const allowWorkspaceActions = experiments.includes("workspace_actions"); | ||
return allowWorkspaceActions && allowAdvancedScheduling; | ||
}; | ||
export const useTemplatePoliciesEnabled = (): boolean => { | ||
const { entitlements, experiments } = useDashboard(); | ||
return ( | ||
entitlements.features.access_control.enabled && | ||
experiments.includes("template_update_policies") | ||
); | ||
}; | ||
sreya marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -13,27 +13,36 @@ import { | ||
getFormHelpers, | ||
onChangeTrimmed, | ||
} from "utils/formUtils"; | ||
import { | ||
AutomaticUpdates, | ||
AutomaticUpdateses, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. this name sounds like we hired gollum 😂 | ||
Workspace, | ||
} from "api/typesGenerated"; | ||
import { Alert } from "components/Alert/Alert"; | ||
import MenuItem from "@mui/material/MenuItem"; | ||
import upperFirst from "lodash/upperFirst"; | ||
export type WorkspaceSettingsFormValues = { | ||
name: string; | ||
automatic_updates: AutomaticUpdates; | ||
}; | ||
export const WorkspaceSettingsForm: FC<{ | ||
workspace: Workspace; | ||
error: unknown; | ||
templatePoliciesEnabled: boolean; | ||
onCancel: () => void; | ||
onSubmit: (values: WorkspaceSettingsFormValues) =>Promise<void>; | ||
}> = ({ onCancel, onSubmit, workspace, error,templatePoliciesEnabled }) => { | ||
const form = useFormik<WorkspaceSettingsFormValues>({ | ||
onSubmit, | ||
initialValues: { | ||
name: workspace.name, | ||
automatic_updates: workspace.automatic_updates, | ||
}, | ||
validationSchema: Yup.object({ | ||
name: nameValidator("Name"), | ||
sreya marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
automatic_updates: Yup.string().oneOf(AutomaticUpdateses), | ||
}), | ||
}); | ||
const getFieldHelpers = getFormHelpers<WorkspaceSettingsFormValues>( | ||
@@ -43,7 +52,10 @@ export const WorkspaceSettingsForm: FC<{ | ||
return ( | ||
<HorizontalForm onSubmit={form.handleSubmit} data-testid="form"> | ||
<FormSection | ||
title="Workspace Name" | ||
description="Update the name of your workspace." | ||
> | ||
<FormFields> | ||
<TextField | ||
{...getFieldHelpers("name")} | ||
@@ -61,7 +73,30 @@ export const WorkspaceSettingsForm: FC<{ | ||
)} | ||
</FormFields> | ||
</FormSection> | ||
{templatePoliciesEnabled && ( | ||
<FormSection | ||
title="Automatic Updates" | ||
description="Configure your workspace to automatically update when started." | ||
> | ||
<FormFields> | ||
<TextField | ||
{...getFieldHelpers("automatic_updates")} | ||
id="automatic_updates" | ||
label="Update Policy" | ||
value={form.values.automatic_updates} | ||
select | ||
disabled={form.isSubmitting} | ||
> | ||
{AutomaticUpdateses.map((value) => ( | ||
<MenuItem value={value} key={value}> | ||
{upperFirst(value)} | ||
</MenuItem> | ||
))} | ||
</TextField> | ||
</FormFields> | ||
</FormSection> | ||
)} | ||
<FormFooter onCancel={onCancel} isLoading={form.isSubmitting} /> | ||
</HorizontalForm> | ||
); | ||
}; |