Skip to content

Commit f8f4dc6

Browse files
authored
feat: check for classic flow on the create workspace page (#17852)
the local storage key is only set when a user presses the opt-in or opt-out buttons Overall, this feels less annoying for users to have to opt-in/opt-out on every visit to the create workspace page. Maybe less of a concern for end users but more of a concern while dogfooding. Pros: - User gets the admin setting value for the template as long as they didn't opt-in or opt-out - User can choose to opt-in/out-out at will and their preference is saved
1 parent 8914f7a commit f8f4dc6

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

site/src/pages/CreateWorkspacePage/CreateWorkspaceExperimentRouter.tsx

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,26 @@ const CreateWorkspaceExperimentRouter: FC = () => {
3030
templateQuery.data.id,
3131
"optOut",
3232
],
33-
queryFn: () => ({
34-
templateId: templateQuery.data.id,
35-
optedOut:
36-
localStorage.getItem(optOutKey(templateQuery.data.id)) === "true",
37-
}),
33+
queryFn: () => {
34+
const templateId = templateQuery.data.id;
35+
const localStorageKey = optOutKey(templateId);
36+
const storedOptOutString = localStorage.getItem(localStorageKey);
37+
38+
let optOutResult: boolean;
39+
40+
if (storedOptOutString !== null) {
41+
optOutResult = storedOptOutString === "true";
42+
} else {
43+
optOutResult = Boolean(
44+
templateQuery.data.use_classic_parameter_flow,
45+
);
46+
}
47+
48+
return {
49+
templateId: templateId,
50+
optedOut: optOutResult,
51+
};
52+
},
3853
}
3954
: { enabled: false },
4055
);
@@ -49,11 +64,15 @@ const CreateWorkspaceExperimentRouter: FC = () => {
4964

5065
const toggleOptedOut = () => {
5166
const key = optOutKey(optOutQuery.data.templateId);
52-
const current = localStorage.getItem(key) === "true";
67+
const storedValue = localStorage.getItem(key);
68+
69+
const current = storedValue
70+
? storedValue === "true"
71+
: Boolean(templateQuery.data?.use_classic_parameter_flow);
72+
5373
localStorage.setItem(key, (!current).toString());
5474
optOutQuery.refetch();
5575
};
56-
5776
return (
5877
<ExperimentalFormContext.Provider value={{ toggleOptedOut }}>
5978
{optOutQuery.data.optedOut ? (

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ export const TemplateSettingsForm: FC<TemplateSettingsForm> = ({
242242
<span>
243243
Show the original workspace creation form without dynamic
244244
parameters or live updates. Recommended if your provisioners
245-
aren't updated or the new form causes issues.
245+
aren't updated or the new form causes issues.{" "}
246246
<strong>
247247
Users can always manually switch experiences in the
248248
workspace creation form.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy