Skip to content

Commit 09a9f84

Browse files
committed
Add checkbox to show offline provisioners
1 parent 72e1e5b commit 09a9f84

File tree

4 files changed

+99
-63
lines changed

4 files changed

+99
-63
lines changed

site/src/api/api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,8 @@ export type GetProvisionerDaemonsParams = {
420420
// Stringified JSON Object
421421
tags?: string;
422422
limit?: number;
423+
// Include offline provisioner daemons?
424+
offline?: boolean;
423425
};
424426

425427
/**

site/src/pages/OrganizationSettingsPage/OrganizationProvisionersPage/OrganizationProvisionersPage.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const OrganizationProvisionersPage: FC = () => {
2020
const queryParams = {
2121
ids: searchParams.get("ids") ?? "",
2222
tags: searchParams.get("tags") ?? "",
23+
offline: searchParams.get("offline") === "true",
2324
};
2425
const { organization, organizationPermissions } = useOrganizationSettings();
2526
const { entitlements } = useDashboard();
@@ -66,7 +67,13 @@ const OrganizationProvisionersPage: FC = () => {
6667
buildVersion={buildInfoQuery.data?.version}
6768
onRetry={provisionersQuery.refetch}
6869
filter={queryParams}
69-
onFilterChange={setSearchParams}
70+
onFilterChange={(filter) => {
71+
const params: Record<string, string> = {
72+
ids: filter.ids ?? "",
73+
offline: filter.offline ? "true" : "false",
74+
};
75+
setSearchParams(params);
76+
}}
7077
/>
7178
</>
7279
);

site/src/pages/OrganizationSettingsPage/OrganizationProvisionersPage/OrganizationProvisionersPageView.stories.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,14 @@ const meta: Meta<typeof OrganizationProvisionersPageView> = {
2323
...MockProvisionerWithTags,
2424
version: "0.0.0",
2525
},
26+
{
27+
...MockUserProvisioner,
28+
status: "offline",
29+
}
2630
],
2731
filter: {
2832
ids: "",
33+
offline: true,
2934
},
3035
},
3136
};
@@ -69,6 +74,17 @@ export const FilterByID: Story = {
6974
provisioners: [MockProvisioner],
7075
filter: {
7176
ids: MockProvisioner.id,
77+
offline: true,
7278
},
7379
},
7480
};
81+
82+
export const FilterByOffline: Story = {
83+
args: {
84+
provisioners: [MockProvisioner],
85+
filter: {
86+
ids: "",
87+
offline: false,
88+
}
89+
}
90+
}

site/src/pages/OrganizationSettingsPage/OrganizationProvisionersPage/OrganizationProvisionersPageView.tsx

Lines changed: 73 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { ProvisionerDaemon } from "api/typesGenerated";
22
import { Badge } from "components/Badge/Badge";
33
import { Button } from "components/Button/Button";
4+
import { Checkbox } from "components/Checkbox/Checkbox";
45
import { EmptyState } from "components/EmptyState/EmptyState";
56
import { Link } from "components/Link/Link";
67
import { Loader } from "components/Loader/Loader";
@@ -32,6 +33,7 @@ import { ProvisionerRow } from "./ProvisionerRow";
3233

3334
type ProvisionersFilter = {
3435
ids: string;
36+
offline: boolean;
3537
};
3638

3739
interface OrganizationProvisionersPageViewProps {
@@ -102,70 +104,79 @@ export const OrganizationProvisionersPageView: FC<
102104
documentationLink={docs("/")}
103105
/>
104106
) : (
105-
<Table>
106-
<TableHeader>
107-
<TableRow>
108-
<TableHead>Name</TableHead>
109-
<TableHead>Key</TableHead>
110-
<TableHead>Version</TableHead>
111-
<TableHead>Status</TableHead>
112-
<TableHead>Tags</TableHead>
113-
<TableHead>
114-
<LastConnectionHead />
115-
</TableHead>
116-
</TableRow>
117-
</TableHeader>
118-
<TableBody>
119-
{provisioners ? (
120-
provisioners.length > 0 ? (
121-
provisioners.map((provisioner) => (
122-
<ProvisionerRow
123-
provisioner={provisioner}
124-
key={provisioner.id}
125-
buildVersion={buildVersion}
126-
defaultIsOpen={filter.ids.includes(provisioner.id)}
127-
/>
128-
))
129-
) : (
107+
<><div className="flex items-center gap-2 mb-6">
108+
<Checkbox
109+
id="offline-filter"
110+
checked={filter.offline}
111+
onCheckedChange={(checked) => {
112+
onFilterChange({
113+
...filter,
114+
offline: checked === true,
115+
});
116+
} } />
117+
<label
118+
htmlFor="offline-filter"
119+
className="text-sm font-medium leading-none"
120+
>
121+
Include offline provisioners
122+
</label>
123+
</div><Table>
124+
<TableHeader>
130125
<TableRow>
131-
<TableCell colSpan={999}>
132-
<EmptyState
133-
message="No provisioners found"
134-
description="A provisioner is required before you can create templates and workspaces. You can connect your first provisioner by following our documentation."
135-
cta={
136-
<Button size="sm" asChild>
137-
<a href={docs("/admin/provisioners")}>
138-
Create a provisioner
139-
<SquareArrowOutUpRightIcon />
140-
</a>
141-
</Button>
142-
}
143-
/>
144-
</TableCell>
126+
<TableHead>Name</TableHead>
127+
<TableHead>Key</TableHead>
128+
<TableHead>Version</TableHead>
129+
<TableHead>Status</TableHead>
130+
<TableHead>Tags</TableHead>
131+
<TableHead>
132+
<LastConnectionHead />
133+
</TableHead>
145134
</TableRow>
146-
)
147-
) : error ? (
148-
<TableRow>
149-
<TableCell colSpan={999}>
150-
<EmptyState
151-
message="Error loading the provisioner jobs"
152-
cta={
153-
<Button onClick={onRetry} size="sm">
154-
Retry
155-
</Button>
156-
}
157-
/>
158-
</TableCell>
159-
</TableRow>
160-
) : (
161-
<TableRow>
162-
<TableCell colSpan={999}>
163-
<Loader />
164-
</TableCell>
165-
</TableRow>
166-
)}
167-
</TableBody>
168-
</Table>
135+
</TableHeader>
136+
<TableBody>
137+
{provisioners ? (
138+
provisioners.length > 0 ? (
139+
provisioners.map((provisioner) => (
140+
<ProvisionerRow
141+
provisioner={provisioner}
142+
key={provisioner.id}
143+
buildVersion={buildVersion}
144+
defaultIsOpen={filter.ids.includes(provisioner.id)} />
145+
))
146+
) : (
147+
<TableRow>
148+
<TableCell colSpan={999}>
149+
<EmptyState
150+
message="No provisioners found"
151+
description="A provisioner is required before you can create templates and workspaces. You can connect your first provisioner by following our documentation."
152+
cta={<Button size="sm" asChild>
153+
<a href={docs("/admin/provisioners")}>
154+
Create a provisioner
155+
<SquareArrowOutUpRightIcon />
156+
</a>
157+
</Button>} />
158+
</TableCell>
159+
</TableRow>
160+
)
161+
) : error ? (
162+
<TableRow>
163+
<TableCell colSpan={999}>
164+
<EmptyState
165+
message="Error loading the provisioner jobs"
166+
cta={<Button onClick={onRetry} size="sm">
167+
Retry
168+
</Button>} />
169+
</TableCell>
170+
</TableRow>
171+
) : (
172+
<TableRow>
173+
<TableCell colSpan={999}>
174+
<Loader />
175+
</TableCell>
176+
</TableRow>
177+
)}
178+
</TableBody>
179+
</Table></>
169180
)}
170181
</section>
171182
);

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