Inline error paragraphs become destructive Alerts, divided record lists become Item rows, the redirect URI box uses CodeView, and icon-button title hints use Tooltip. Native titles remain on truncated values and on disabled controls.
38 lines
1.6 KiB
Vue
38 lines
1.6 KiB
Vue
<script setup lang="ts">
|
|
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
|
import { Item, ItemGroup } from "@/components/ui/item";
|
|
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. A read-only diff
|
|
* passes `revertable: false`. */
|
|
withDefaults(
|
|
defineProps<{ changes: Change[]; label?: (path: string) => string; revertable?: boolean }>(),
|
|
{ revertable: true },
|
|
);
|
|
defineEmits<{ revert: [change: Change] }>();
|
|
</script>
|
|
|
|
<template>
|
|
<ItemGroup class="font-mono text-xs">
|
|
<Item v-for="change in changes" :key="change.path" as="li" variant="outline" size="xs" class="group items-start">
|
|
<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>
|
|
<Tooltip v-if="revertable">
|
|
<TooltipTrigger as-child>
|
|
<Button variant="ghost" size="icon-sm" :aria-label="`Revert ${label ? label(change.path) : change.path}`" @click="$emit('revert', change)">
|
|
<Undo2 />
|
|
</Button>
|
|
</TooltipTrigger>
|
|
<TooltipContent>Revert</TooltipContent>
|
|
</Tooltip>
|
|
</Item>
|
|
</ItemGroup>
|
|
</template>
|