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 88import type { Instance } from '@oxide/api'
99
1010import { InstanceStatusBadge } from 'app/components/StatusBadge'
11- import { timeAgoAbbr } from 'app/util/date '
11+ import { TimeAgo } from 'app/components/TimeAgo '
1212
1313import type { Cell } from './Cell'
14- import { TwoLineCell } from './TwoLineCell'
1514
1615export const InstanceStatusCell = ( {
1716 value,
1817} : Cell < Pick < Instance , 'runState' | 'timeRunStateUpdated' > > ) => {
1918 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 >
2723 )
2824}
You can’t perform that action at this time.
0 commit comments