All files / apps/wp-editor/app/components RunReport.vue

0% Statements 0/19
0% Branches 0/6
0% Functions 0/7
0% Lines 0/19

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94                                                                                                                                                                                           
<template>
    <div class="flex flex-col gap-4">
        <p class="text-sm text-muted">{{ heading }}</p>
 
        <div class="flex flex-wrap gap-2">
            <UBadge
                v-for="section in sections"
                :key="section.label"
                :color="section.color"
                variant="subtle"
                :label="`${section.label} ${section.entries.length}`"
            />
        </div>
 
        <UAlert
            v-if="Ireport.stopped"
            color="error"
            variant="subtle"
            icon="i-lucide-octagon-x"
            title="Stopped early"
            :description="`${report.stopped} Run it again once WordPress answers; only ${RUN_LABELS[report.kind].retried} articles are retried.`"
        />
 
        <UAlert
            v-if="Ireport.incomplete"
            color="warning"
            variant="subtle"
            icon="i-lucide-circle-pause"
            title="This run didn't finish"
            description="It stopped partway, or is still going, so it lists only the articles it reached."
        />
 
        <UAlert
            v-if="Ireport.blocker"
            color="neutral"
            variant="subtle"
            icon="i-lucide-lock"
            title="Bulk apply would still be blocked"
            :description="report.blocker"
        />
 
        <template v-for="section in sections" :key="section.label">
            <section v-if="Isection.entries.length > 0">
                <h3 class="mb-1 text-sm font-semibold">{{ section.label }}</h3>
                <ul class="divide-y divide-default rounded-md border border-default text-sm">
                    <li
                        v-for="entry in section.entries"
                        :key="entry.key"
                        class="flex gap-3 px-3 py-1.5"
                    >
                        <UButton
                            :label="entry.key"
                            variant="link"
                            size="xs"
                            class="shrink-0 p-0"
                            @click="emit('select', entry.key)"
                        />
                        <span class="text-muted">{{ entry.reason }}</span>
                    </li>
                </ul>
            </section>
        </template>
    </div>
</template>
 
<script setup lang="ts">
import type { BadgeProps } from "@nuxt/ui";
import type { ItemKey } from "#shared/types/ItemKey.ts";
import type { RunReport } from "#shared/types/RunReport.ts";
 
interface Props {
    report: RunReport;
}
 
const props = defineProps<Props>();
const emit = defineEmits<{ select: [key: ItemKey] }>();
 
const heading = computed(
    () => `${runLabel(props.report)} ยท ${new Date(props.report.at).toLocaleString()}`,
);
 
const sections = computed(() => {
    const { kind, ok, refused, failed, warnings } = props.report;
    const okLabel = RUN_LABELS[kind].ok;
 
    return [
        { label: "Failed", color: "error", entries: failed },
        { label: "Refused", color: "warning", entries: refused },
        { label: "Warnings", color: "info", entries: warnings },
        { label: okLabel, color: "success", entries: ok.map((key) => ({ key, reason: "" })) },
    ] satisfies { label: string; color: BadgeProps["color"]; entries: unknown[] }[];
});
</script>