Skip to content

Commit 1aaa866

Browse files
authored
fix(ui): show audit event facts in the shared key-value list (#1323)
The opened audit row laid out its event id, time, repository and path with a hand-made grid. It now uses MdKeyValueList like the other detail views, so labels line up the same way. Part of task 4.8 of migrate-content-to-components. Signed-off-by: TheMeinerLP <github@themeinerlp.dev>
1 parent 12b2d2c commit 1aaa866

3 files changed

Lines changed: 25 additions & 23 deletions

File tree

‎reposilite-frontend/src/components/audit/AuditEventRow.test.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import type { Component } from 'vue'
12
import { describe, it, expect } from 'vitest'
23
import { mount } from '@vue/test-utils'
34
import { createRouter, createMemoryHistory } from 'vue-router'
5+
import MdKeyValueList from '../md/MdKeyValueList.vue'
46
import AuditEventRow from './AuditEventRow.vue'
57
import type { AuditEvent } from './auditQuery'
68

@@ -133,6 +135,21 @@ describe('AuditEventRow details', () => {
133135
expect(row.find('button').attributes('aria-expanded')).toBe('true')
134136
})
135137

138+
it('lists the event facts in the shared key-value list when the row is open', async () => {
139+
const row = await mountRow({ event: event({ repository: 'releases', path: '/a/b' }), expanded: true })
140+
141+
const list = row.findComponent(MdKeyValueList as Component)
142+
expect(list.exists()).toBe(true)
143+
expect(list.findAll('dt').map(term => term.text())).toEqual(['Event id', 'Time (UTC)', 'Repository', 'Path'])
144+
expect(list.findAll('dd').map(detail => detail.text())).toContain('releases')
145+
})
146+
147+
it('shows a dash for a repository and a path the event does not carry', async () => {
148+
const row = await mountRow({ event: event({ repository: undefined, path: undefined }), expanded: true })
149+
150+
expect(row.findComponent(MdKeyValueList as Component).findAll('dd').slice(-2).map(detail => detail.text())).toEqual(['-', '-'])
151+
})
152+
136153
it('reports the toggle with the id of its event', async () => {
137154
const row = await mountRow({ event: event({ id: 42 }) })
138155

‎reposilite-frontend/src/components/audit/AuditEventRow.vue‎

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { RouterLink } from 'vue-router'
44
import { actionLabelOf, actorLabelOf, actorLocationOf, targetLabelOf, targetLocationOf } from './auditQuery'
55
import type { AuditEvent } from './auditQuery'
66
import MdCard from '../md/MdCard.vue'
7+
import MdKeyValueList from '../md/MdKeyValueList.vue'
78
89
/*
910
* One audited event. The row is dense: time, actor, action, target and result sit in one line on a
@@ -30,6 +31,12 @@ const actorLink = computed(() => actorLocationOf(props.event))
3031
const target = computed(() => targetLabelOf(props.event))
3132
const targetLink = computed(() => targetLocationOf(props.event))
3233
const detailsText = computed(() => (props.event.details ? JSON.stringify(props.event.details, null, 2) : null))
34+
const facts = computed(() => [
35+
{ label: 'Event id', value: String(props.event.id) },
36+
{ label: 'Time (UTC)', value: props.event.timestamp },
37+
{ label: 'Repository', value: props.event.repository || '-' },
38+
{ label: 'Path', value: props.event.path || '-' }
39+
])
3340
const attempts = computed(() => (props.event.occurrences > 1 ? `${props.event.occurrences} attempts` : null))
3441
</script>
3542

@@ -116,24 +123,7 @@ const attempts = computed(() => (props.event.occurrences > 1 ? `${props.event.oc
116123
tone="container"
117124
class="mt-3"
118125
>
119-
<dl class="grid grid-cols-[max-content_1fr] gap-x-4 gap-y-1 md-body-small text-on-surface-variant">
120-
<dt>Event id</dt>
121-
<dd class="text-on-surface">
122-
{{ event.id }}
123-
</dd>
124-
<dt>Time (UTC)</dt>
125-
<dd class="break-all text-on-surface">
126-
{{ event.timestamp }}
127-
</dd>
128-
<dt>Repository</dt>
129-
<dd class="break-all text-on-surface">
130-
{{ event.repository || '-' }}
131-
</dd>
132-
<dt>Path</dt>
133-
<dd class="break-all text-on-surface">
134-
{{ event.path || '-' }}
135-
</dd>
136-
</dl>
126+
<MdKeyValueList :items="facts" />
137127
<pre
138128
v-if="detailsText"
139129
class="mt-3 overflow-x-auto whitespace-pre-wrap break-all rounded-corner-small bg-surface-container-lowest p-3 md-body-small text-on-surface"

‎reposilite-frontend/src/style-gate/baseline/arbitrary-value.json‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@
1414
"match": "grid-cols-[auto_1fr]",
1515
"count": 1
1616
},
17-
{
18-
"file": "src/components/audit/AuditEventRow.vue",
19-
"match": "grid-cols-[max-content_1fr]",
20-
"count": 1
21-
},
2217
{
2318
"file": "src/components/audit/AuditEventRow.vue",
2419
"match": "grid-cols-[minmax(0,1fr)]",

0 commit comments

Comments
 (0)