Skip to content

fix(site): hide ws proxy on menu when disabled #11101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 8, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(site): do not show ws proxy on menu if it is not enabled
  • Loading branch information
BrunoQuaresma committed Dec 8, 2023
commit 342a57b387cefd672803ad6a631092ad5a3a054a
43 changes: 25 additions & 18 deletions site/src/pages/HealthPage/HealthLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,11 @@ import { Suspense } from "react";
import { HealthIcon } from "./Content";
import { HealthSeverity } from "api/typesGenerated";
import NotificationsOffOutlined from "@mui/icons-material/NotificationsOffOutlined";

const sections = {
derp: "DERP",
access_url: "Access URL",
websocket: "Websocket",
database: "Database",
workspace_proxy: "Workspace Proxy",
} as const;
import { useDashboard } from "components/Dashboard/DashboardProvider";

export function HealthLayout() {
const theme = useTheme();
const dashboard = useDashboard();
const queryClient = useQueryClient();
const { data: healthStatus } = useQuery({
...health(),
Expand All @@ -36,6 +30,18 @@ export function HealthLayout() {
const { mutate: forceRefresh, isLoading: isRefreshing } = useMutation(
refreshHealth(queryClient),
);
const sections = {
derp: "DERP",
access_url: "Access URL",
websocket: "Websocket",
database: "Database",
workspace_proxy: dashboard.experiments.includes("moons")
? "Workspace Proxy"
: undefined,
} as const;
const visibleSections = Object.keys(sections).filter(
(key) => sections[key as keyof typeof sections],
) as Partial<typeof sections>;

return (
<>
Expand Down Expand Up @@ -106,13 +112,13 @@ export function HealthLayout() {
}}
>
{healthStatus.healthy
? Object.keys(sections).some(
(key) =>
healthStatus[key as keyof typeof sections]
.warnings !== null &&
healthStatus[key as keyof typeof sections].warnings
.length > 0,
)
? Object.keys(visibleSections).some((key) => {
const section =
healthStatus[key as keyof typeof visibleSections];
return (
section.warnings && section.warnings.length > 0
);
})
? "All systems operational, but performance might be degraded"
: "All systems operational"
: "Some issues have been detected"}
Expand Down Expand Up @@ -145,12 +151,13 @@ export function HealthLayout() {
</div>

<nav css={{ display: "flex", flexDirection: "column", gap: 1 }}>
{Object.keys(sections)
{Object.keys(visibleSections)
.sort()
.map((key) => {
const label = sections[key as keyof typeof sections];
const label =
visibleSections[key as keyof typeof visibleSections];
const healthSection =
healthStatus[key as keyof typeof sections];
healthStatus[key as keyof typeof visibleSections];

return (
<NavLink
Expand Down