Files
archie/ui/src/components/ChangeList.vue
T

27 lines
1.2 KiB
Vue

<script setup lang="ts">
import { Undo2 } from "@lucide/vue";
import { Button } from "@/components/ui/button";
import { formatValue, type Change } from "@/lib/changes";
/** One row per changed leaf, each revertable on its own, so a reviewer keeps
* the changes they want and drops the rest before saving. */
defineProps<{ changes: Change[]; label?: (path: string) => string }>();
defineEmits<{ revert: [change: Change] }>();
</script>
<template>
<ul class="divide-y divide-border font-mono text-xs">
<li v-for="change in changes" :key="change.path" class="group flex items-start gap-2 px-3 py-2">
<div class="min-w-0 flex-1">
<p class="mb-1 font-sans font-medium">{{ label ? label(change.path) : change.path }}</p>
<p class="whitespace-pre-wrap break-words text-danger"><span class="font-sans">Before: </span>{{ formatValue(change.before) }}</p>
<p class="whitespace-pre-wrap break-words text-ok"><span class="font-sans">After: </span>{{ formatValue(change.after) }}</p>
</div>
<Button variant="ghost" size="icon-sm" :aria-label="`Revert ${label ? label(change.path) : change.path}`" title="Revert" @click="$emit('revert', change)">
<Undo2 />
</Button>
</li>
</ul>
</template>