Skip to content

Commit 11db26b

Browse files
committed
chore: show org autocomplete if experiment is enabled
1 parent c207cae commit 11db26b

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

site/src/pages/CreateTemplatePage/CreateTemplateForm.tsx

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
} from "components/Form/Form";
2323
import { IconField } from "components/IconField/IconField";
2424
import { OrganizationAutocomplete } from "components/OrganizationAutocomplete/OrganizationAutocomplete";
25+
import { useDashboard } from "modules/dashboard/useDashboard";
2526
import { SelectedTemplate } from "pages/CreateWorkspacePage/SelectedTemplate";
2627
import {
2728
nameValidator,
@@ -88,7 +89,7 @@ const defaultInitialValues: CreateTemplateData = {
8889
allow_user_autostop: false,
8990
allow_everyone_group_access: true,
9091
provisioner_type: "terraform",
91-
organization_id: "",
92+
organization_id: "00000000-0000-0000-0000-000000000000",
9293
};
9394

9495
type GetInitialValuesParams = {
@@ -179,6 +180,7 @@ export type CreateTemplateFormProps = (
179180
};
180181

181182
export const CreateTemplateForm: FC<CreateTemplateFormProps> = (props) => {
183+
const { experiments } = useDashboard();
182184
const [searchParams] = useSearchParams();
183185
const [selectedOrg, setSelectedOrg] = useState<Organization | null>(null);
184186
const {
@@ -193,6 +195,7 @@ export const CreateTemplateForm: FC<CreateTemplateFormProps> = (props) => {
193195
allowAdvancedScheduling,
194196
variablesSectionRef,
195197
} = props;
198+
const multiOrgExperimentEnabled = experiments.includes("multi-organization");
196199
// TODO: if there is only 1 organization, set the dropdown to the default organizationId or hide it
197200

198201
const form = useFormik<CreateTemplateData>({
@@ -232,16 +235,20 @@ export const CreateTemplateForm: FC<CreateTemplateFormProps> = (props) => {
232235
}}
233236
/>
234237
)}
235-
236-
<OrganizationAutocomplete
237-
{...getFieldHelpers("organization_id")}
238-
value={selectedOrg}
239-
onChange={(newValue) => {
240-
setSelectedOrg(newValue);
241-
return form.setFieldValue("organization_id", newValue?.id || "");
242-
}}
243-
size="medium"
244-
/>
238+
{multiOrgExperimentEnabled && (
239+
<OrganizationAutocomplete
240+
{...getFieldHelpers("organization_id")}
241+
value={selectedOrg}
242+
onChange={(newValue) => {
243+
setSelectedOrg(newValue);
244+
return form.setFieldValue(
245+
"organization_id",
246+
newValue?.id || "",
247+
);
248+
}}
249+
size="medium"
250+
/>
251+
)}
245252

246253
<TextField
247254
{...getFieldHelpers("name")}

site/src/pages/TemplatePage/TemplateLayout.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { ErrorAlert } from "components/Alert/ErrorAlert";
1919
import { Loader } from "components/Loader/Loader";
2020
import { Margins } from "components/Margins/Margins";
2121
import { TAB_PADDING_Y, TabLink, Tabs, TabsList } from "components/Tabs/Tabs";
22-
import { useDashboard } from "modules/dashboard/useDashboard";
2322
import { TemplatePageHeader } from "./TemplatePageHeader";
2423

2524
const templatePermissions = (

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