Files
archie/ui/src/mappings/MappingsTable.vue
T

77 lines
1.9 KiB
Vue

<script setup lang="ts">
import { Section } from "@/components/ui/section";
import {
Empty,
EmptyDescription,
EmptyHeader,
EmptyTitle,
} from "@/components/ui/empty";
import { Skeleton } from "@/components/ui/skeleton";
import {
Table,
TableBody,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table";
import MappingRow from "./MappingRow.vue";
import {
listLoading,
loadError,
mappings,
requestDelete,
startEdit,
} from "./state";
/**
* The saved mappings, in all four states: still loading, unreadable, none yet,
* and the table. A list that cannot be read says so instead of rendering empty,
* because "no mappings yet" and "cannot reach archied" call for different
* actions from whoever is looking.
*/
</script>
<template>
<div v-if="listLoading" class="flex flex-col gap-2" aria-busy="true">
<Skeleton class="h-10 w-full" />
<Skeleton class="h-28 w-full" />
</div>
<Empty v-else-if="loadError">
<EmptyHeader>
<EmptyTitle>Archie is not responding</EmptyTitle>
<EmptyDescription>{{ loadError }}</EmptyDescription>
</EmptyHeader>
</Empty>
<Empty v-else-if="!mappings.length">
<EmptyHeader>
<EmptyTitle>No mappings yet</EmptyTitle>
</EmptyHeader>
</Empty>
<Section v-else>
<Table>
<TableHeader>
<TableRow>
<TableHead>Name</TableHead>
<TableHead>Event type</TableHead>
<TableHead>Fields</TableHead>
<TableHead>Matched</TableHead>
<TableHead>Last match</TableHead>
<TableHead><span class="sr-only">Actions</span></TableHead>
</TableRow>
</TableHeader>
<TableBody>
<MappingRow
v-for="mapping in mappings"
:key="mapping.id"
:mapping="mapping"
@edit="startEdit"
@delete="requestDelete"
/>
</TableBody>
</Table>
</Section>
</template>