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

0% Statements 0/14
0% Branches 0/26
0% Functions 0/4
0% Lines 0/13

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                                                                                                                               
<template>
    <UPageCard variant="subtle" class="shrink-0">
        <div class="flex flex-col gap-3">
            <div class="flex items-baseline justify-between gap-4">
                <p class="font-semibold">{{ RUN_LABELS[kind].name }}</p>
                <p class="text-sm text-muted tabular-nums">
                    {{ report?.total === undefined ? "Starting…" : `${done} / ${report.total}` }}
                </p>
            </div>
 
            <UProgress :model-value="report?.total ? done : null" :max="report?.total" />
 
            <p v-if="report?.current" class="truncate text-sm">
                <span class="text-muted">{{ RUN_LABELS[kind].doing }}</span>
                {{ report.current }}<template v-if="IcurrentTitle"> · {{ currentTitle }}</template>
            </p>
            <p v-else-if="Ireport" class="text-sm text-muted">Pausing before the next article</p>
 
            <div class="flex flex-wrap gap-2">
                <UBadge
                    v-for="count in counts"
                    :key="count.label"
                    :color="count.color"
                    variant="subtle"
                    :label="`${count.label} ${count.n}`"
                />
            </div>
        </div>
    </UPageCard>
</template>
 
<script setup lang="ts">
import type { RunReport } from "#shared/types/RunReport.ts";
 
interface Props {
    kind: RunReport["kind"];
    /** Null until the first progress save is read back. */
    report: RunReport | null;
    currentTitle?: string;
}
 
const props = defineProps<Props>();
 
const done = computed(() => {
    const { ok = [], refused = [], failed = [] } = props.report ?? {};
 
    return ok.length + refused.length + failed.length;
});
 
const counts = computed(() => {
    const { ok = [], refused = [], failed = [] } = props.report ?? {};
 
    return [
        {
            label: RUN_LABELS[props.kind].ok,
            color: "success",
            n: ok.length,
        },
        { label: "Refused", color: "warning", n: refused.length },
        { label: "Failed", color: "error", n: failed.length },
    ] as const;
});
</script>