Skip to content

Commit 33cb286

Browse files
committed
fix(site): improve rendering of provisioner tags
1 parent 8a12ee7 commit 33cb286

File tree

2 files changed

+67
-9
lines changed

2 files changed

+67
-9
lines changed

site/src/pages/HealthPage/ProvisionerDaemonsPage.tsx

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
import { Header, HeaderTitle, HealthyDot, Main, Pill } from "./Content";
1+
import {
2+
BooleanPill,
3+
Header,
4+
HeaderTitle,
5+
HealthyDot,
6+
Main,
7+
Pill,
8+
} from "./Content";
29
import { Helmet } from "react-helmet-async";
310
import { pageTitle } from "utils/page";
411
import { useTheme } from "@mui/material/styles";
@@ -116,13 +123,9 @@ export const ProvisionerDaemonsPage = () => {
116123
</span>
117124
</Pill>
118125
</Tooltip>
119-
{Object.keys(extraTags).map((k) => (
120-
<Tooltip key={k} title={k}>
121-
<Pill key={k} icon={<Sell />}>
122-
{extraTags[k]}
123-
</Pill>
124-
</Tooltip>
125-
))}
126+
{Object.keys(extraTags).map((k) =>
127+
renderTag(k, extraTags[k]),
128+
)}
126129
</div>
127130
</header>
128131

@@ -163,4 +166,32 @@ export const ProvisionerDaemonsPage = () => {
163166
);
164167
};
165168

169+
const parseBool = (s: string): { valid: boolean; value: boolean } => {
170+
switch (s.toLowerCase()) {
171+
case "true":
172+
case "yes":
173+
case "1":
174+
return { valid: true, value: true };
175+
case "false":
176+
case "no":
177+
case "0":
178+
case "":
179+
return { valid: true, value: false };
180+
default:
181+
return { valid: false, value: false };
182+
}
183+
};
184+
185+
const renderTag = (k: string, v: string) => {
186+
const { valid, value: boolValue } = parseBool(v);
187+
if (valid) {
188+
return <BooleanPill value={boolValue}>{k}</BooleanPill>;
189+
}
190+
return (
191+
<Pill icon={<Sell />}>
192+
{k}: {v}
193+
</Pill>
194+
);
195+
};
196+
166197
export default ProvisionerDaemonsPage;

site/src/testHelpers/entities.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3129,7 +3129,30 @@ export const MockHealth: TypesGen.HealthcheckReport = {
31293129
tags: {
31303130
owner: "",
31313131
scope: "organization",
3132-
custom_tag_name: "custom_tag_value",
3132+
tag_value: "value",
3133+
tag_true: "true",
3134+
tag_1: "1",
3135+
tag_yes: "yes",
3136+
},
3137+
},
3138+
warnings: [],
3139+
},
3140+
{
3141+
provisioner_daemon: {
3142+
id: "00000000-0000-0000-000000000000",
3143+
created_at: "2024-01-04T15:53:03.21563Z",
3144+
last_seen_at: "2024-01-04T16:05:03.967551Z",
3145+
name: "user-scoped",
3146+
version: "v2.34-devel+abcd1234",
3147+
api_version: "1.0",
3148+
provisioners: ["echo", "terraform"],
3149+
tags: {
3150+
owner: "12345678-1234-1234-1234-12345678abcd",
3151+
scope: "user",
3152+
tag_value: "value",
3153+
tag_true: "true",
3154+
tag_1: "1",
3155+
tag_yes: "yes",
31333156
},
31343157
},
31353158
warnings: [],
@@ -3146,6 +3169,10 @@ export const MockHealth: TypesGen.HealthcheckReport = {
31463169
tags: {
31473170
owner: "",
31483171
scope: "organization",
3172+
tag_string: "value",
3173+
tag_false: "false",
3174+
tag_0: "0",
3175+
tag_no: "no",
31493176
},
31503177
},
31513178
warnings: [

0 commit comments

Comments
 (0)