Skip to content

Commit 2f969b1

Browse files
committed
cleanup
1 parent 0aa6e20 commit 2f969b1

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

site/src/api/queries/organizations.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,15 @@ export const organizations = () => {
108108
};
109109
};
110110

111+
export const getProvisionerDaemonsKey = (organization: string) => [
112+
"organization",
113+
organization,
114+
"provisionerDaemons",
115+
];
116+
111117
export const provisionerDaemons = (organization: string) => {
112118
return {
113-
queryKey: ["organization", organization, "provisionerDaemons"],
119+
queryKey: getProvisionerDaemonsKey(organization),
114120
queryFn: () => API.getProvisionerDaemonsByOrganization(organization),
115121
};
116122
};

site/src/pages/CreateTemplatePage/CreateTemplateForm.stories.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import { action } from "@storybook/addon-actions";
22
import type { Meta, StoryObj } from "@storybook/react";
3+
import { screen, userEvent } from "@storybook/test";
34
import {
5+
getProvisionerDaemonsKey,
6+
organizationsKey,
7+
} from "api/queries/organizations";
8+
import {
9+
MockDefaultOrganization,
10+
MockOrganization2,
411
MockTemplate,
512
MockTemplateExample,
613
MockTemplateVersionVariable1,
@@ -54,6 +61,31 @@ export const StarterTemplateWithOrgPicker: Story = {
5461
},
5562
};
5663

64+
export const StarterTemplateWithProvisionerWarning: Story = {
65+
parameters: {
66+
queries: [
67+
{
68+
key: organizationsKey,
69+
data: [MockDefaultOrganization, MockOrganization2],
70+
},
71+
{
72+
key: getProvisionerDaemonsKey(MockOrganization2.id),
73+
data: [],
74+
},
75+
],
76+
},
77+
args: {
78+
...StarterTemplate.args,
79+
showOrganizationPicker: true,
80+
},
81+
play: async () => {
82+
const organizationPicker = screen.getByPlaceholderText("Organization name");
83+
await userEvent.click(organizationPicker);
84+
const org2 = await screen.findByText(MockOrganization2.display_name);
85+
await userEvent.click(org2);
86+
},
87+
};
88+
5789
export const DuplicateTemplateWithVariables: Story = {
5890
args: {
5991
copiedTemplate: MockTemplate,

site/src/pages/CreateTemplatePage/CreateTemplateForm.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,12 @@ export const CreateTemplateForm: FC<CreateTemplateFormProps> = (props) => {
225225
: { enabled: false },
226226
);
227227

228+
// TODO: Ideally, we would have a backend endpoint that could notify the
229+
// frontend that a provisioner has been connected, so that we could hide
230+
// this warning. In the meantime, **do not use this variable to disable
231+
// form submission**!! A user could easily see this warning, connect a
232+
// provisioner, and then not refresh the page. Even if they submit without
233+
// a provisioner, it'll just sit in the job queue until they connect one.
228234
const showProvisionerWarning = provisionerDaemonsQuery.data;
229235

230236
return (
@@ -252,7 +258,7 @@ export const CreateTemplateForm: FC<CreateTemplateFormProps> = (props) => {
252258
<>
253259
{showProvisionerWarning && <ProvisionerWarning />}
254260
<OrganizationAutocomplete
255-
{...getFieldHelpers("organization_id")}
261+
{...getFieldHelpers("organization")}
256262
required
257263
label="Belongs to"
258264
value={selectedOrg}

0 commit comments

Comments
 (0)