File tree Expand file tree Collapse file tree 2 files changed +42
-9
lines changed Expand file tree Collapse file tree 2 files changed +42
-9
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * This Source Code Form is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, you can obtain one at https://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright Oxide Computer Company
7
+ */
8
+ import type { Placement } from '@floating-ui/react'
9
+ import { format } from 'date-fns'
10
+
11
+ import { Tooltip } from '@oxide/ui'
12
+
13
+ import { timeAgoAbbr } from 'app/util/date'
14
+
15
+ export const TimeAgo = ( {
16
+ datetime,
17
+ description,
18
+ placement = 'top' ,
19
+ } : {
20
+ datetime : Date
21
+ description ?: string
22
+ placement ?: Placement
23
+ } ) : JSX . Element => {
24
+ const content = (
25
+ < div className = "flex flex-col" >
26
+ < span className = "text-tertiary" > { description } </ span >
27
+ < span > { format ( datetime , 'MMM d, yyyy p' ) } </ span >
28
+ </ div >
29
+ )
30
+ return (
31
+ < span className = "mt-0.5" >
32
+ < Tooltip content = { content } placement = { placement } >
33
+ < span className = "text-sans-sm text-tertiary" > { timeAgoAbbr ( datetime ) } </ span >
34
+ </ Tooltip >
35
+ </ span >
36
+ )
37
+ }
Original file line number Diff line number Diff line change 8
8
import type { Instance } from '@oxide/api'
9
9
10
10
import { InstanceStatusBadge } from 'app/components/StatusBadge'
11
- import { timeAgoAbbr } from 'app/util/date '
11
+ import { TimeAgo } from 'app/components/TimeAgo '
12
12
13
13
import type { Cell } from './Cell'
14
- import { TwoLineCell } from './TwoLineCell'
15
14
16
15
export const InstanceStatusCell = ( {
17
16
value,
18
17
} : Cell < Pick < Instance , 'runState' | 'timeRunStateUpdated' > > ) => {
19
18
return (
20
- < TwoLineCell
21
- detailsClass = "text-sans-sm"
22
- value = { [
23
- < InstanceStatusBadge key = "run-state" status = { value . runState } /> ,
24
- timeAgoAbbr ( value . timeRunStateUpdated ) ,
25
- ] }
26
- > </ TwoLineCell >
19
+ < div className = "flex flex-col" >
20
+ < InstanceStatusBadge key = "run-state" status = { value . runState } />
21
+ < TimeAgo description = "Run state updated" datetime = { value . timeRunStateUpdated } />
22
+ </ div >
27
23
)
28
24
}
You can’t perform that action at this time.
0 commit comments