Skip to content

Commit 3a5932c

Browse files
committed
wip
1 parent 3dd35e0 commit 3a5932c

File tree

3 files changed

+38
-5
lines changed

3 files changed

+38
-5
lines changed

site/src/api/api.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,9 +1565,10 @@ export const getInsightsTemplate = async (
15651565
return response.data;
15661566
};
15671567

1568-
export const getHealth = async () => {
1568+
export const getHealth = async (forced: boolean = false) => {
1569+
const params = new URLSearchParams({ forced: forced.toString() });
15691570
const response = await axios.get<TypesGen.HealthcheckReport>(
1570-
"/api/v2/debug/health",
1571+
`/api/v2/debug/health?${params}`,
15711572
);
15721573
return response.data;
15731574
};

site/src/api/queries/deployment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const deploymentStats = () => {
2424
export const health = () => {
2525
return {
2626
queryKey: ["deployment", "health"],
27-
queryFn: API.getHealth,
27+
queryFn: () => API.getHealth(false),
2828
};
2929
};
3030

site/src/pages/HealthPage/HealthPage.tsx

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { type Interpolation, type Theme } from "@emotion/react";
22
import Box from "@mui/material/Box";
3-
import { useQuery } from "react-query";
3+
import { useQuery, useMutation } from "react-query";
44
import { getHealth } from "api/api";
55
import { Loader } from "components/Loader/Loader";
66
import { useTab } from "hooks";
@@ -19,6 +19,9 @@ import {
1919
import { Stats, StatsItem } from "components/Stats/Stats";
2020
import { createDayString } from "utils/createDayString";
2121
import { DashboardFullPage } from "components/Dashboard/DashboardLayout";
22+
import { LoadingButton } from "@mui/lab";
23+
import ReplayIcon from "@mui/icons-material/Replay";
24+
import { FC } from "react";
2225

2326
const sections = {
2427
derp: "DERP",
@@ -32,8 +35,9 @@ export default function HealthPage() {
3235
const { data: healthStatus } = useQuery({
3336
queryKey: ["health"],
3437
queryFn: () => getHealth(),
35-
refetchInterval: 120_000,
38+
refetchInterval: 30_000,
3639
});
40+
const mutation = useMutation({})
3741

3842
return (
3943
<>
@@ -103,6 +107,12 @@ export function HealthPageView({
103107
value={healthStatus.coder_version}
104108
/>
105109
</Stats>
110+
<RefreshButton
111+
loading={false}
112+
handleAction={() => {
113+
console.log("refresh");
114+
}}
115+
/>
106116
</FullWidthPageHeader>
107117
<Box
108118
sx={{
@@ -237,3 +247,25 @@ const styles = {
237247
},
238248
},
239249
} satisfies Record<string, Interpolation<Theme>>;
250+
251+
interface HealthcheckAction {
252+
handleAction: () => void;
253+
loading: boolean;
254+
}
255+
256+
export const RefreshButton: FC<HealthcheckAction> = ({
257+
handleAction,
258+
loading,
259+
}) => {
260+
return (
261+
<LoadingButton
262+
loading={loading}
263+
loadingPosition="start"
264+
data-testid="healthcheck-refresh-button"
265+
startIcon={<ReplayIcon />}
266+
onClick={handleAction}
267+
>
268+
{loading ? <>Refreshing&hellip;</> : <>Refresh</>}
269+
</LoadingButton>
270+
);
271+
};

0 commit comments

Comments
 (0)