-
Notifications
You must be signed in to change notification settings - Fork 894
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 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
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a66709a
feat: add frontend support for enabling automatic workspace updates
sreya 262050a
cleanup
Kira-Pilot 86b0cb7
add update policy to workspace stats
sreya ce25bba
revert restrictive behavior
sreya 3602dd9
move workspace setting behind experimental
sreya 2f0ef94
remove unused import
sreya c68a8b6
Merge branch 'main' into jon/wsautoupdatefe
sreya e751552
pr comments
sreya 2a67fe3
pr comments
sreya 2018b0b
remove unused prop
sreya 673b214
storybook: add auto updates story
aslilac File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,27 +13,36 @@ import { | |
getFormHelpers, | ||
onChangeTrimmed, | ||
} from "utils/formUtils"; | ||
import { Workspace } from "api/typesGenerated"; | ||
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<{ | ||
isSubmitting: boolean; | ||
workspace: Workspace; | ||
error: unknown; | ||
templatePoliciesEnabled: boolean; | ||
onCancel: () => void; | ||
onSubmit: (values: WorkspaceSettingsFormValues) => void; | ||
}> = ({ onCancel, onSubmit, workspace, error, isSubmitting }) => { | ||
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 resolved
Hide resolved
|
||
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="General" description="The name of your workspace."> | ||
<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> | ||
<FormFooter onCancel={onCancel} isLoading={isSubmitting} /> | ||
{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> | ||
); | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.