1
1
import { type Interpolation , type Theme } from "@emotion/react" ;
2
2
import Box from "@mui/material/Box" ;
3
- import { useQuery } from "react-query" ;
3
+ import { useQuery , useMutation } from "react-query" ;
4
4
import { getHealth } from "api/api" ;
5
5
import { Loader } from "components/Loader/Loader" ;
6
6
import { useTab } from "hooks" ;
@@ -19,6 +19,9 @@ import {
19
19
import { Stats , StatsItem } from "components/Stats/Stats" ;
20
20
import { createDayString } from "utils/createDayString" ;
21
21
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" ;
22
25
23
26
const sections = {
24
27
derp : "DERP" ,
@@ -32,8 +35,9 @@ export default function HealthPage() {
32
35
const { data : healthStatus } = useQuery ( {
33
36
queryKey : [ "health" ] ,
34
37
queryFn : ( ) => getHealth ( ) ,
35
- refetchInterval : 120_000 ,
38
+ refetchInterval : 30_000 ,
36
39
} ) ;
40
+ const mutation = useMutation ( { } )
37
41
38
42
return (
39
43
< >
@@ -103,6 +107,12 @@ export function HealthPageView({
103
107
value = { healthStatus . coder_version }
104
108
/>
105
109
</ Stats >
110
+ < RefreshButton
111
+ loading = { false }
112
+ handleAction = { ( ) => {
113
+ console . log ( "refresh" ) ;
114
+ } }
115
+ />
106
116
</ FullWidthPageHeader >
107
117
< Box
108
118
sx = { {
@@ -237,3 +247,25 @@ const styles = {
237
247
} ,
238
248
} ,
239
249
} 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…</ > : < > Refresh</ > }
269
+ </ LoadingButton >
270
+ ) ;
271
+ } ;
0 commit comments