1
- import { useCodeGateStatus } from "../hooks/use-codegate-status" ;
2
- import { HealthStatus } from "../types" ;
1
+ import { useQueriesCodegateStatus } from "../hooks/use-queries-codegate-status" ;
3
2
import {
4
3
Button ,
5
4
DialogTrigger ,
@@ -40,27 +39,27 @@ type CodeGateHealthCheckStatus =
40
39
| "error_checking_health" ;
41
40
42
41
function deriveOverallStatus (
43
- data : ReturnType < typeof useCodeGateStatus > [ "data" ] ,
42
+ data : ReturnType < typeof useQueriesCodegateStatus > [ "data" ] ,
44
43
isPending : boolean ,
45
44
isError : boolean ,
46
45
) : CodeGateStatus {
47
46
if ( isPending ) return "loading" ;
48
47
if ( isError ) return "error_checking_status" ;
49
48
50
49
if (
51
- data ?. health === HealthStatus . HEALTHY &&
50
+ data ?. health ?. status === "healthy" &&
52
51
data . version ?. error === null &&
53
52
data . version ?. is_latest === false
54
53
)
55
54
return "update_available" ;
56
55
57
- if ( data ?. health === HealthStatus . HEALTHY ) return "healthy" ;
56
+ if ( data ?. health ?. status === "healthy" ) return "healthy" ;
58
57
59
58
return "unhealthy" ;
60
59
}
61
60
62
61
function deriveVersionStatus (
63
- data : ReturnType < typeof useCodeGateStatus > [ "data" ] ,
62
+ data : ReturnType < typeof useQueriesCodegateStatus > [ "data" ] ,
64
63
isPending : boolean ,
65
64
isError : boolean ,
66
65
) : CodeGateVersionStatus {
@@ -72,14 +71,14 @@ function deriveVersionStatus(
72
71
}
73
72
74
73
function deriveHealthCheckStatus (
75
- data : ReturnType < typeof useCodeGateStatus > [ "data" ] ,
74
+ data : ReturnType < typeof useQueriesCodegateStatus > [ "data" ] ,
76
75
isPending : boolean ,
77
76
isError : boolean ,
78
77
) : CodeGateHealthCheckStatus {
79
78
if ( isPending ) return "loading" ;
80
79
if ( isError ) return "error_checking_health" ;
81
80
82
- if ( data ?. health == HealthStatus . HEALTHY ) return "healthy" ;
81
+ if ( data ?. health ?. status === "healthy" ) return "healthy" ;
83
82
return "unhealthy" ;
84
83
}
85
84
@@ -102,7 +101,7 @@ function getButtonText(status: CodeGateStatus): string {
102
101
103
102
function getVersionText (
104
103
status : CodeGateVersionStatus ,
105
- data : ReturnType < typeof useCodeGateStatus > [ "data" ] ,
104
+ data : ReturnType < typeof useQueriesCodegateStatus > [ "data" ] ,
106
105
) : ReactNode {
107
106
switch ( status ) {
108
107
case "error_checking_version" :
@@ -262,7 +261,7 @@ function StatusPopover({
262
261
} : {
263
262
versionStatus : CodeGateVersionStatus ;
264
263
healthCheckStatus : CodeGateHealthCheckStatus ;
265
- data : ReturnType < typeof useCodeGateStatus > [ "data" ] ;
264
+ data : ReturnType < typeof useQueriesCodegateStatus > [ "data" ] ;
266
265
} ) {
267
266
return (
268
267
< Popover className = "px-3 py-2 min-w-64" placement = "bottom end" >
@@ -290,7 +289,7 @@ function StatusPopover({
290
289
}
291
290
292
291
export function HeaderStatusMenu ( ) {
293
- const { data, isPending, isError } = useCodeGateStatus ( ) ;
292
+ const { data, isPending, isError } = useQueriesCodegateStatus ( ) ;
294
293
295
294
const status = deriveOverallStatus ( data , isPending , isError ) ;
296
295
const versionStatus = deriveVersionStatus ( data , isPending , isError ) ;
0 commit comments