Skip to content

Commit 499fc0d

Browse files
committed
fix: update SimpleTable component with loading state and skeleton rows
- remove existing loading table state from activity logs
1 parent 03b932c commit 499fc0d

File tree

2 files changed

+44
-32
lines changed

2 files changed

+44
-32
lines changed

frontend/src/components/table/SimpleTable.vue

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,30 @@
1010
>
1111
{{ header }}
1212
</th>
13-
<th scope="col" class="relative px-6 py-3"></th>
13+
<th v-if="showDelete" scope="col" class="relative px-6 py-3"></th>
1414
</tr>
1515
</thead>
1616
<tbody class="bg-background divide-y divide-border">
17-
<template v-if="data.length === 0">
17+
<!-- Loading State -->
18+
<template v-if="loading">
19+
<tr v-for="i in skeletonRows" :key="`skeleton-${i}`" class="hover:bg-accent">
20+
<td
21+
v-for="(header, index) in headers"
22+
:key="`skeleton-cell-${index}`"
23+
class="px-6 py-3 text-sm font-medium text-foreground whitespace-normal break-words"
24+
>
25+
<Skeleton class="h-4 w-[85%]" />
26+
</td>
27+
<td v-if="showDelete" class="px-6 py-4 text-sm text-muted-foreground">
28+
<Skeleton class="h-8 w-8 rounded" />
29+
</td>
30+
</tr>
31+
</template>
32+
33+
<!-- No Results State -->
34+
<template v-else-if="data.length === 0">
1835
<tr>
19-
<td :colspan="headers.length + 1" class="px-6 py-12 text-center">
36+
<td :colspan="headers.length + (showDelete ? 1 : 0)" class="px-6 py-12 text-center">
2037
<div class="flex flex-col items-center space-y-4">
2138
<span class="text-md text-muted-foreground">
2239
{{
@@ -29,6 +46,8 @@
2946
</td>
3047
</tr>
3148
</template>
49+
50+
<!-- Data Rows -->
3251
<template v-else>
3352
<tr v-for="(item, index) in data" :key="index" class="hover:bg-accent">
3453
<td
@@ -53,6 +72,7 @@
5372
import { Trash2 } from 'lucide-vue-next'
5473
import { defineProps, defineEmits } from 'vue'
5574
import { Button } from '@/components/ui/button'
75+
import { Skeleton } from '@/components/ui/skeleton'
5676
5777
defineProps({
5878
headers: {
@@ -73,6 +93,14 @@ defineProps({
7393
showDelete: {
7494
type: Boolean,
7595
default: true
96+
},
97+
loading: {
98+
type: Boolean,
99+
default: false
100+
},
101+
skeletonRows: {
102+
type: Number,
103+
default: 5
76104
}
77105
})
78106

frontend/src/features/admin/activity-log/ActivityLog.vue

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -63,35 +63,20 @@
6363
</Popover>
6464
</div>
6565

66-
<div v-if="loading" class="w-full">
67-
<div class="flex border-b border-border p-4 font-medium bg-gray-50">
68-
<div class="flex-1 text-muted-foreground">{{ t('globals.terms.name') }}</div>
69-
<div class="w-[200px] text-muted-foreground">{{ t('globals.terms.date') }}</div>
70-
<div class="w-[150px] text-muted-foreground">{{ t('globals.terms.ipAddress') }}</div>
71-
</div>
72-
<div v-for="i in perPage" :key="i" class="flex border-b border-border py-3 px-4">
73-
<div class="flex-1">
74-
<Skeleton class="h-4 w-[90%]" />
75-
</div>
76-
<div class="w-[200px]">
77-
<Skeleton class="h-4 w-[120px]" />
78-
</div>
79-
<div class="w-[150px]">
80-
<Skeleton class="h-4 w-[100px]" />
81-
</div>
82-
</div>
66+
<div class="w-full overflow-x-auto">
67+
<SimpleTable
68+
:headers="[
69+
t('globals.terms.name'),
70+
t('globals.terms.timestamp'),
71+
t('globals.terms.ipAddress')
72+
]"
73+
:keys="['activity_description', 'created_at', 'ip']"
74+
:data="activityLogs"
75+
:showDelete="false"
76+
:loading="loading"
77+
:skeletonRows="15"
78+
/>
8379
</div>
84-
85-
<template v-else>
86-
<div class="w-full overflow-x-auto">
87-
<SimpleTable
88-
:headers="[t('globals.terms.name'), t('globals.terms.timestamp'), t('globals.terms.ipAddress')]"
89-
:keys="['activity_description', 'created_at', 'ip']"
90-
:data="activityLogs"
91-
:showDelete="false"
92-
/>
93-
</div>
94-
</template>
9580
</div>
9681

9782
<!-- TODO: deduplicate this code, copied from contacts list -->
@@ -163,7 +148,6 @@
163148

164149
<script setup>
165150
import { ref, computed, onMounted, watch } from 'vue'
166-
import { Skeleton } from '@/components/ui/skeleton'
167151
import SimpleTable from '@/components/table/SimpleTable.vue'
168152
import {
169153
Pagination,

0 commit comments

Comments
 (0)