Skip to content

Commit

Permalink
fix(stats): add unknown author label
Browse files Browse the repository at this point in the history
  • Loading branch information
mtthp committed Oct 9, 2024
1 parent 797ae75 commit 53d5d46
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/components/audit/AuditEntryInline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,17 @@
<i18n-t :keypath="`audit.action.${event.action}.message`" scope="global" tag="p">
<template #author>
<RouterLink
v-if="$route.params.id !== event.author._id"
v-if="event.author && $route.params.id !== event.author._id"
class="font-medium text-indigo-600 hover:underline"
:to="{
name: ROUTE_NAMES.MEMBERS.DETAIL.INDEX,
params: { id: event.author._id || event.author.wpUserId },
}">
{{ event.author.name }}
</RouterLink>
<span v-else class="font-medium text-gray-900">{{ event.author.name }}</span>
<span v-else class="font-medium text-gray-900">
{{ event.author?.name || $t('audit.author.unknown') }}
</span>
</template>
</i18n-t>
</slot>
Expand Down
3 changes: 3 additions & 0 deletions src/i18n/locales/en-GB/audit.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"message": "{author} has unlocked the deck door"
}
},
"author": {
"unknown": "Someone"
},
"list": {
"description": "Everything that happens in detail.",
"empty": {
Expand Down
3 changes: 3 additions & 0 deletions src/i18n/locales/fr-FR/audit.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"message": "{author} a déverrouillé la porte de la terrasse"
}
},
"author": {
"unknown": "Quelqu'un"
},
"list": {
"description": "Tout ce qui se passe en détail.",
"empty": {
Expand Down
2 changes: 1 addition & 1 deletion src/services/api/audit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export enum AuditAction {

export interface AuditEvent {
_id: string;
author: {
author?: {
_id?: string;
wpUserId: number;
name: string;
Expand Down
7 changes: 5 additions & 2 deletions src/views/Private/History/HistoryEventsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ interface ListSorter {
const ALL_LIST_SORTERS = computed<ListSorter[]>(() => [
{
key: 'occurred',
sort: (a, b) => new Date(b.occurred).getTime() - new Date(a.occurred).getTime(),
sort: (a: AuditEvent, b: AuditEvent) =>
new Date(b.occurred).getTime() - new Date(a.occurred).getTime(),
},
{
key: 'action',
Expand All @@ -194,7 +195,9 @@ const ALL_LIST_SORTERS = computed<ListSorter[]>(() => [
{
key: 'author',
sort: (a, b) =>
a.author.name.toLocaleLowerCase().localeCompare(b.author.name.toLocaleLowerCase()),
(a.author?.name.toLocaleLowerCase() || '').localeCompare(
b.author?.name.toLocaleLowerCase() || '',
),
},
]);
Expand Down

0 comments on commit 53d5d46

Please sign in to comment.