components/ui and the pages now use only the style.css scale: text-[0.8rem]→text-label, text-[0.625rem]→text-micro, text-base/text-sm→ text-label (rows and controls), text-xs→text-caption (captions and secondary text), text-lg/text-xl/text-2xl→text-title (panel and page titles). Rendered markdown (ChatMarkdown/ChatInline/markdown.ts) keeps Tailwind steps as the issue allows. 196 files, class-token swaps only.
84 lines
2.6 KiB
Vue
84 lines
2.6 KiB
Vue
<script setup lang="ts">
|
|
import { Alert, AlertDescription } from "@/components/ui/alert";
|
|
import { Button } from "@/components/ui/button";
|
|
import { Section } from "@/components/ui/section";
|
|
import {
|
|
Dialog,
|
|
DialogContent,
|
|
DialogFooter,
|
|
DialogHeader,
|
|
DialogTitle,
|
|
} from "@/components/ui/dialog";
|
|
import { Spinner } from "@/components/ui/spinner";
|
|
import MappingActionError from "./MappingActionError.vue";
|
|
import MappingFieldsTable from "./MappingFieldsTable.vue";
|
|
import MappingForm from "./MappingForm.vue";
|
|
import PayloadTree from "./PayloadTree.vue";
|
|
import {
|
|
actionError,
|
|
addField,
|
|
closeEditor,
|
|
draft,
|
|
editorOpen,
|
|
runPreview,
|
|
saveMapping,
|
|
saving,
|
|
} from "./state";
|
|
|
|
/**
|
|
* One editing session, in an overlay: the mapping's own fields, the fields
|
|
* bound to payload paths, and the example event they were bound from.
|
|
*
|
|
* The payload panel is the editor's primary control rather than a preview of
|
|
* one: a field is bound by clicking a value that really is in a captured event,
|
|
* so no JSON path is ever typed by hand.
|
|
*/
|
|
function onOpenChange(open: boolean) {
|
|
if (!open) closeEditor();
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<Dialog :open="editorOpen" @update:open="onOpenChange">
|
|
<DialogContent class="max-h-[85vh] overflow-y-auto sm:max-w-3xl">
|
|
<DialogHeader>
|
|
<DialogTitle>{{
|
|
draft.id === null ? "New mapping" : "Edit mapping"
|
|
}}</DialogTitle>
|
|
</DialogHeader>
|
|
|
|
<Section class="mb-0">
|
|
<MappingForm />
|
|
</Section>
|
|
|
|
<Section title="Bound fields" class="mb-0">
|
|
<MappingFieldsTable />
|
|
<Button variant="outline" class="mt-4" @click="runPreview">Preview</Button>
|
|
</Section>
|
|
|
|
<Section title="Payload" class="mb-0">
|
|
<Alert v-if="draft.payloadError" variant="destructive">
|
|
<AlertDescription>{{ draft.payloadError }}</AlertDescription>
|
|
</Alert>
|
|
<PayloadTree
|
|
v-else-if="draft.payload !== null"
|
|
:value="draft.payload"
|
|
@pick="addField"
|
|
/>
|
|
<p v-else class="text-label text-fg-muted">No event selected.</p>
|
|
</Section>
|
|
|
|
<!-- Beside the buttons, not at the top: the dialog scrolls, and Save is
|
|
clicked at the bottom, where a refusal must be seen. -->
|
|
<MappingActionError v-if="actionError" :failure="actionError" />
|
|
|
|
<DialogFooter>
|
|
<Button variant="outline" @click="closeEditor">Cancel</Button>
|
|
<Button :disabled="saving" @click="saveMapping">
|
|
<Spinner v-if="saving" data-icon="inline-start" />{{ saving ? "Saving..." : "Save" }}
|
|
</Button>
|
|
</DialogFooter>
|
|
</DialogContent>
|
|
</Dialog>
|
|
</template>
|