Skip to content

Commit 69b26cb

Browse files
committed
Review feedback
Signed-off-by: Danny Kopping <danny@coder.com>
1 parent 61d6595 commit 69b26cb

File tree

5 files changed

+37
-41
lines changed

5 files changed

+37
-41
lines changed

site/src/pages/DeploySettingsPage/GeneralSettingsPage/GeneralSettingsPage.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,22 @@ const GeneralSettingsPage: FC = () => {
1313
const deploymentDAUsQuery = useQuery(deploymentDAUs());
1414
const entitlementsQuery = useQuery(entitlements());
1515
const enabledExperimentsQuery = useQuery(experiments());
16-
const availableExperimentsQuery = useQuery(availableExperiments());
16+
const safeExperimentsQuery = useQuery(availableExperiments());
17+
18+
const safeExperiments: string[] = [];
19+
const invalidExperiments: string[] = [];
20+
21+
(enabledExperimentsQuery.data ?? []).forEach(function (exp) {
22+
const found = (safeExperimentsQuery.data?.safe ?? []).find((value) => {
23+
return exp === value;
24+
});
25+
26+
if (found) {
27+
safeExperiments.push(exp);
28+
} else {
29+
invalidExperiments.push(exp);
30+
}
31+
});
1732

1833
return (
1934
<>
@@ -25,8 +40,8 @@ const GeneralSettingsPage: FC = () => {
2540
deploymentDAUs={deploymentDAUsQuery.data}
2641
deploymentDAUsError={deploymentDAUsQuery.error}
2742
entitlements={entitlementsQuery.data}
28-
enabledExperiments={enabledExperimentsQuery.data ?? []}
29-
safeExperiments={availableExperimentsQuery.data?.safe ?? []}
43+
invalidExperiments={invalidExperiments}
44+
safeExperiments={safeExperiments}
3045
/>
3146
</>
3247
);

site/src/pages/DeploySettingsPage/GeneralSettingsPage/GeneralSettingsPageView.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const meta: Meta<typeof GeneralSettingsPageView> = {
4040
},
4141
],
4242
deploymentDAUs: MockDeploymentDAUResponse,
43-
enabledExperiments: [],
43+
invalidExperiments: [],
4444
safeExperiments: [],
4545
},
4646
};
@@ -104,7 +104,7 @@ export const allExperimentsEnabled: Story = {
104104
},
105105
],
106106
safeExperiments: ["shared-ports"],
107-
enabledExperiments: ["shared-ports"],
107+
invalidExperiments: ["invalid"],
108108
},
109109
};
110110

@@ -140,6 +140,6 @@ export const invalidExperimentsEnabled: Story = {
140140
},
141141
],
142142
safeExperiments: ["shared-ports"],
143-
enabledExperiments: ["invalid"],
143+
invalidExperiments: ["invalid"],
144144
},
145145
};

site/src/pages/DeploySettingsPage/GeneralSettingsPage/GeneralSettingsPageView.tsx

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,37 +24,18 @@ export type GeneralSettingsPageViewProps = {
2424
deploymentDAUs?: DAUsResponse;
2525
deploymentDAUsError: unknown;
2626
entitlements: Entitlements | undefined;
27-
enabledExperiments: Experiments | string[];
28-
safeExperiments: Experiments | string[];
27+
readonly invalidExperiments: Experiments | string[];
28+
readonly safeExperiments: Experiments | string[];
2929
};
3030

3131
export const GeneralSettingsPageView: FC<GeneralSettingsPageViewProps> = ({
3232
deploymentOptions,
3333
deploymentDAUs,
3434
deploymentDAUsError,
3535
entitlements,
36-
enabledExperiments,
3736
safeExperiments,
37+
invalidExperiments,
3838
}) => {
39-
const safe: string[] = [];
40-
const invalid: string[] = [];
41-
42-
enabledExperiments.forEach(function (exp) {
43-
let found = false;
44-
safeExperiments.forEach(function (name) {
45-
if (exp === name) {
46-
found = true;
47-
return;
48-
}
49-
});
50-
51-
if (found) {
52-
safe.push(exp);
53-
} else {
54-
invalid.push(exp);
55-
}
56-
});
57-
5839
return (
5940
<>
6041
<Header
@@ -81,11 +62,11 @@ export const GeneralSettingsPageView: FC<GeneralSettingsPageViewProps> = ({
8162
</ChartSection>
8263
</div>
8364
)}
84-
{invalid.length > 0 && (
65+
{invalidExperiments.length > 0 && (
8566
<Alert severity="warning">
8667
<AlertTitle>Invalid experiments in use:</AlertTitle>
8768
<ul>
88-
{invalid.map((it) => (
69+
{invalidExperiments.map((it) => (
8970
<li key={it}>
9071
<pre>{it}</pre>
9172
</li>
@@ -110,7 +91,7 @@ export const GeneralSettingsPageView: FC<GeneralSettingsPageViewProps> = ({
11091
"Wildcard Access URL",
11192
"Experiments",
11293
)}
113-
additionalValues={safe}
94+
additionalValues={safeExperiments}
11495
/>
11596
</Stack>
11697
</>

site/src/pages/DeploySettingsPage/Option.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { css, type Interpolation, type Theme, useTheme } from "@emotion/react";
2-
import LabelImportant from "@mui/icons-material/LabelImportant";
2+
import BuildCircleOutlinedIcon from "@mui/icons-material/BuildCircleOutlined";
33
import type { FC, HTMLAttributes, PropsWithChildren } from "react";
44
import { DisabledBadge, EnabledBadge } from "components/Badges/Badges";
55
import { MONOSPACE_FONT_FAMILY } from "theme/constants";
@@ -91,11 +91,11 @@ export const OptionValue: FC<OptionValueProps> = (props) => {
9191
}}
9292
>
9393
{isEnabled && (
94-
<LabelImportant
94+
<BuildCircleOutlinedIcon
9595
css={(theme) => ({
9696
width: 16,
9797
height: 16,
98-
color: theme.palette.info.light,
98+
color: theme.palette.mode,
9999
margin: "0 8px",
100100
})}
101101
/>

site/src/pages/DeploySettingsPage/optionValue.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ export function optionValue(
3838
([key, value]) => `"${key}"->"${value}"`,
3939
);
4040
case "Experiments": {
41-
const experimentMap: Record<string, boolean> | undefined =
42-
additionalValues?.reduce(
43-
(acc, v) => {
44-
return { ...acc, [v]: option.value.includes("*") };
45-
},
46-
{} as Record<string, boolean>,
47-
);
41+
const experimentMap = additionalValues?.reduce<Record<string, boolean>>(
42+
(acc, v) => {
43+
acc[v] = option.value.includes("*");
44+
return acc;
45+
},
46+
{},
47+
);
4848

4949
if (!experimentMap) {
5050
break;

0 commit comments

Comments
 (0)