8000 feat: add opt-out option to new parameters form by aslilac · Pull Request #17456 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

feat: add opt-out option to new parameters form #17456

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 11 commits into from
Apr 21, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
yay
  • Loading branch information
aslilac committed Apr 17, 2025
commit 7efa2b093892634520441079f650867001c69521
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useDashboard } from "modules/dashboard/useDashboard";
import { createContext, type FC } from "react";
import { createContext, type FC, useState } from "react";
import CreateWorkspacePage from "./CreateWorkspacePage";
import CreateWorkspacePageExperimental from "./CreateWorkspacePageExperimental";
import { useParams } from "react-router-dom";
Expand All @@ -24,16 +24,26 @@ const CreateWorkspaceExperimentRouter: FC = () => {
if (templateQuery.isLoading) {
return <Loader />;
}

if (!templateQuery.data) {
return <ErrorAlert error={templateQuery.error} />;
}

const hasOptedOut =
localStorage.Item(`parameters.${templateQuery.data.id}.optOut`) == "true";
const optOut = `parameters.${templateQuery.data.id}.optOut`;
const [optedOut, setOptedOut] = useState(
localStorage.getItem(optOut) == "true",
);

const toggleOptedOut = () => {
setOptedOut((prev) => {
const next = !prev;
localStorage.setItem(optOut, next.toString());
return next;
});
};

return (
<CreateWorkspaceContext.Provider value={{}}>
{hasOptedOut ? (
<CreateWorkspaceContext.Provider value={{ toggleOptedOut }}>
{optedOut ? (
<CreateWorkspacePage />
) : (
<CreateWorkspacePageExperimental />
Expand All @@ -47,4 +57,6 @@ const CreateWorkspaceExperimentRouter: FC = () => {

export default CreateWorkspaceExperimentRouter;

const CreateWorkspaceContext = createContext<{}>({});
const CreateWorkspaceContext = createContext<
{ toggleOptedOut: () => void } | undefined
>(undefined);
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export const CreateWorkspacePageViewExperimental: FC<

return (
<>
<div className="absolute sticky top-5 ml-10">
<div className="sticky top-5 ml-10">
<button
onClick={onCancel}
type="button"
Expand Down
Loading
0