@@ -11,17 +11,20 @@ import { useVirtualizer } from '@tanstack/react-virtual'
11
11
import cn from 'classnames'
12
12
import { differenceInMilliseconds } from 'date-fns'
13
13
import { useMemo , useRef } from 'react'
14
+ import { match } from 'ts-pattern'
14
15
15
16
import { api } from '@oxide/api'
16
17
import { Logs16Icon , Logs24Icon } from '@oxide/design-system/icons/react'
17
18
18
19
import { DocsPopover } from '~/components/DocsPopover'
19
20
import { useDateTimeRangePicker } from '~/components/form/fields/DateTimeRangePicker'
20
21
import { useIntervalPicker } from '~/components/RefetchIntervalPicker'
22
+ import { EmptyCell } from '~/table/cells/EmptyCell'
21
23
import { Badge } from '~/ui/lib/Badge'
22
24
import { Button } from '~/ui/lib/Button'
23
25
import { PageHeader , PageTitle } from '~/ui/lib/PageHeader'
24
26
import { Spinner } from '~/ui/lib/Spinner'
27
+ import { Truncate } from '~/ui/lib/Truncate'
25
28
import { classed } from '~/util/classed'
26
29
import { toSyslogDateString , toSyslogTimeString } from '~/util/date'
27
30
import { docLinks } from '~/util/links'
@@ -39,6 +42,10 @@ const LoadingState = () => {
39
42
return < div > Loading State</ div >
40
43
}
41
44
45
+ const colWidths = {
46
+ gridTemplateColumns : '7rem 4.25rem 180px 140px 120px 140px 300px 300px' ,
47
+ }
48
+
42
49
const HeaderCell = classed . div `text-mono-sm text-tertiary`
43
50
44
51
// for virtualizer
@@ -112,6 +119,12 @@ export default function SiloAuditLogsPage() {
112
119
{ rowVirtualizer . getVirtualItems ( ) . map ( ( virtualRow ) => {
113
120
const log = allItems [ virtualRow . index ]
114
121
122
+ const [ userId , siloId ] = match ( log . actor )
123
+ . with ( { kind : 'silo_user' } , ( actor ) => [ actor . siloUserId , actor . siloId ] )
124
+ . with ( { kind : 'user_builtin' } , ( actor ) => [ actor . userBuiltinId , undefined ] )
125
+ . with ( { kind : 'unauthenticated' } , ( ) => [ undefined , undefined ] )
126
+ . exhaustive ( )
127
+
115
128
return (
116
129
< div
117
130
key = { virtualRow . index }
@@ -126,10 +139,9 @@ export default function SiloAuditLogsPage() {
126
139
'grid h-9 w-full items-center gap-8 px-[var(--content-gutter)] text-left text-sans-md border-secondary' ,
127
140
virtualRow . index !== 0 && 'border-t'
128
141
) }
129
- style = { {
130
- gridTemplateColumns : '7rem 4.25rem 180px 120px 120px 120px 300px 300px' ,
131
- } }
142
+ style = { colWidths }
132
143
>
144
+ { /* TODO: might be especially useful here to get the original UTC timestamp in a tooltip */ }
133
145
< div className = "overflow-hidden whitespace-nowrap text-mono-sm" >
134
146
< span className = "text-tertiary" >
135
147
{ toSyslogDateString ( log . timeCompleted ) }
@@ -141,19 +153,37 @@ export default function SiloAuditLogsPage() {
141
153
< Badge > 200</ Badge >
142
154
</ div >
143
155
< div >
144
- < Badge color = "neutral" className = "text-tertiary" >
145
- { log . operationId . split ( '_' ) . join ( ' ' ) }
146
- </ Badge >
156
+ < Badge color = "neutral" > { log . operationId . split ( '_' ) . join ( ' ' ) } </ Badge >
157
+ </ div >
158
+ < div className = "text-secondary" >
159
+ { userId ? (
160
+ < Truncate
161
+ maxLength = { 12 }
162
+ text = { userId }
163
+ position = "middle"
164
+ hasCopyButton
165
+ />
166
+ ) : (
167
+ < EmptyCell />
168
+ ) }
147
169
</ div >
148
- < div className = "text-secondary" > hannah.arendt</ div >
149
170
< div >
150
- { ! ! log . accessMethod && (
151
- < Badge color = "neutral" className = "text-tertiary" >
152
- { log . accessMethod . split ( '_' ) . join ( ' ' ) }
153
- </ Badge >
171
+ < Badge color = "neutral" >
172
+ { log . accessMethod ?. split ( '_' ) . join ( ' ' ) || 'Unknown' }
173
+ </ Badge >
174
+ </ div >
175
+ < div className = "text-secondary" >
176
+ { siloId ? (
177
+ < Truncate
178
+ maxLength = { 12 }
179
+ text = { siloId }
180
+ position = "middle"
181
+ hasCopyButton
182
+ />
183
+ ) : (
184
+ < EmptyCell />
154
185
) }
155
186
</ div >
156
- < div className = "text-secondary" > maze-war</ div >
157
187
< div className = "text-secondary" >
158
188
{ differenceInMilliseconds ( new Date ( log . timeCompleted ) , log . timeStarted ) }
159
189
ms
@@ -204,16 +234,15 @@ export default function SiloAuditLogsPage() {
204
234
205
235
< div
206
236
className = "sticky top-0 z-10 !mx-0 grid !w-full items-center gap-8 border-b px-[var(--content-gutter)] pb-2 pt-4 bg-default border-secondary"
207
- style = { {
208
- gridTemplateColumns : '7rem 4.25rem 180px 120px 120px 120px 300px 300px' ,
209
- } }
237
+ style = { colWidths }
210
238
>
239
+ { /* TODO: explain that this is time completed, not time started as you might expect */ }
211
240
< HeaderCell > Time</ HeaderCell >
212
241
< HeaderCell > Status</ HeaderCell >
213
242
< HeaderCell > Operation</ HeaderCell >
214
- < HeaderCell > Actor</ HeaderCell >
243
+ < HeaderCell > Actor ID </ HeaderCell >
215
244
< HeaderCell > Access Method</ HeaderCell >
216
- < HeaderCell > Silo</ HeaderCell >
245
+ < HeaderCell > Silo ID </ HeaderCell >
217
246
< HeaderCell > Duration</ HeaderCell >
218
247
</ div >
219
248
0 commit comments