Skip to content

Commit 6a49f68

Browse files
committed
chore: add ui settings for changing to classic flow
1 parent e1e2af8 commit 6a49f68

File tree

6 files changed

+38
-1
lines changed

6 files changed

+38
-1
lines changed

coderd/database/migrations/000325_version_dynamic_parameter_flow.up.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
-- We want the new experience to be tried first.
33
ALTER TABLE templates ADD COLUMN classic_parameter_flow BOOL NOT NULL DEFAULT false;
44

5+
-- Existing templates will default to `true` for the classic parameter flow.
6+
-- They will be incompatible with the new parameter flow until they are re-imported.
7+
UPDATE templates SET classic_parameter_flow = true;
8+
59
COMMENT ON COLUMN templates.classic_parameter_flow IS
610
'Determines whether to default to the dynamic parameter creation flow for this template '
711
'or continue using the legacy classic parameter creation flow.'

codersdk/templates.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ type UpdateTemplateMeta struct {
257257
// "dynamic-parameters" enabled. This setting will live for a period after the experiment is
258258
// made the default.
259259
// An "opt-out" is present in case the new feature breaks some existing templates.
260-
ClassicParameterFlow *bool `json:"dynamic_parameter_flow,omitempty"`
260+
ClassicParameterFlow *bool `json:"classic_parameter_flow,omitempty"`
261261
}
262262

263263
type TemplateExample struct {

site/src/api/typesGenerated.ts

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

site/src/pages/TemplateSettingsPage/TemplateGeneralSettingsPage/TemplateSettingsForm.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export const validationSchema = Yup.object({
4747
allow_user_cancel_workspace_jobs: Yup.boolean(),
4848
icon: iconValidator,
4949
require_active_version: Yup.boolean(),
50+
classic_parameter_flow: Yup.boolean(),
5051
deprecation_message: Yup.string(),
5152
max_port_sharing_level: Yup.string().oneOf(WorkspaceAppSharingLevels),
5253
});
@@ -89,6 +90,7 @@ export const TemplateSettingsForm: FC<TemplateSettingsForm> = ({
8990
deprecation_message: template.deprecation_message,
9091
disable_everyone_group_access: false,
9192
max_port_share_level: template.max_port_share_level,
93+
classic_parameter_flow: template.classic_parameter_flow,
9294
},
9395
validationSchema,
9496
onSubmit,
@@ -222,6 +224,33 @@ export const TemplateSettingsForm: FC<TemplateSettingsForm> = ({
222224
</StackLabel>
223225
}
224226
/>
227+
<FormControlLabel
228+
control={
229+
<Checkbox
230+
size="small"
231+
id="classic_parameter_flow"
232+
name="classic_parameter_flow"
233+
checked={form.values.classic_parameter_flow}
234+
onChange={form.handleChange}
235+
disabled={false}
236+
/>
237+
}
238+
label={
239+
<StackLabel>
240+
Use classic workspace creation form
241+
<StackLabelHelperText>
242+
<span>
243+
If enabled, users will see the original workspace creation experience without dynamic parameters or live form updates.
244+
This is recommended if your provisioners haven&apos;t been updated for dynamic parameters, or if you&apos;re experiencing
245+
issues or incorrect behavior with the new form.{" "}
246+
<strong>
247+
Users can always manually switch experiences in the workspace creation form.
248+
</strong>
249+
</span>
250+
</StackLabelHelperText>
251+
</StackLabel>
252+
}
253+
/>
225254
</FormFields>
226255
</FormSection>
227256

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const validFormValues: FormValues = {
5454
require_active_version: false,
5555
disable_everyone_group_access: false,
5656
max_port_share_level: "owner",
57+
classic_parameter_flow: false,
5758
};
5859

5960
const renderTemplateSettingsPage = async () => {

site/src/testHelpers/entities.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,7 @@ export const MockTemplate: TypesGen.Template = {
824824
deprecated: false,
825825
deprecation_message: "",
826826
max_port_share_level: "public",
827+
classic_parameter_flow: false
827828
};
828829

829830
const MockTemplateVersionFiles: TemplateVersionFiles = {

0 commit comments

Comments
 (0)