1
1
import { useTheme } from "@emotion/react" ;
2
2
import { Stack } from "components/Stack/Stack" ;
3
+ import { StatusIndicator } from "components/StatusIndicator/StatusIndicator" ;
3
4
import dayjs from "dayjs" ;
4
5
import relativeTime from "dayjs/plugin/relativeTime" ;
5
6
import { useTime } from "hooks/useTime" ;
6
7
import type { FC } from "react" ;
7
8
8
9
dayjs . extend ( relativeTime ) ;
9
-
10
- type CircleProps = {
11
- color : string ;
12
- variant ?: "solid" | "outlined" ;
13
- } ;
14
-
15
- const Circle : FC < CircleProps > = ( { color, variant = "solid" } ) => {
16
- return (
17
- < div
18
- aria-hidden
19
- css = { {
20
- width : 8 ,
21
- height : 8 ,
22
- backgroundColor : variant === "solid" ? color : undefined ,
23
- border : variant === "outlined" ? `1px solid ${ color } ` : undefined ,
24
- borderRadius : 9999 ,
25
- } }
26
- />
27
- ) ;
28
- } ;
29
-
30
10
interface LastUsedProps {
31
11
lastUsedAt : string ;
32
12
}
@@ -38,21 +18,19 @@ export const LastUsed: FC<LastUsedProps> = ({ lastUsedAt }) => {
38
18
const t = dayjs ( lastUsedAt ) ;
39
19
const now = dayjs ( ) ;
40
20
let message = t . fromNow ( ) ;
41
- let circle = (
42
- < Circle color = { theme . palette . text . secondary } variant = "outlined" />
43
- ) ;
21
+ let circle = < StatusIndicator color = "info" variant = "outlined" /> ;
44
22
45
23
if ( t . isAfter ( now . subtract ( 1 , "hour" ) ) ) {
46
- circle = < Circle color = { theme . roles . success . fill . solid } /> ;
24
+ circle = < StatusIndicator color = " success" /> ;
47
25
// Since the agent reports on a 10m interval,
48
26
// the last_used_at can be inaccurate when recent.
49
27
message = "Now" ;
50
28
} else if ( t . isAfter ( now . subtract ( 3 , "day" ) ) ) {
51
- circle = < Circle color = { theme . palette . text . secondary } /> ;
29
+ circle = < StatusIndicator color = "info" /> ;
52
30
} else if ( t . isAfter ( now . subtract ( 1 , "month" ) ) ) {
53
- circle = < Circle color = { theme . roles . warning . fill . solid } /> ;
31
+ circle = < StatusIndicator color = " warning" /> ;
54
32
} else if ( t . isAfter ( now . subtract ( 100 , "year" ) ) ) {
55
- circle = < Circle color = { theme . roles . error . fill . solid } /> ;
33
+ circle = < StatusIndicator color = " error" /> ;
56
34
} else {
57
35
message = "Never" ;
58
36
}
0 commit comments