All files / apps/developer-portal/layers/workflows/app/components WorkflowHomePanel.vue

100% Statements 14/14
100% Branches 4/4
100% Functions 7/7
100% Lines 12/12

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  12x             12x   2x         32x 32x 32x     32x             2x                       12x 12x   12x 12x                          
<template>
    <WidgetPanel
        :title="$t('workflowHomePanel.title')"
        :meta="$t('workflowHomePanel.meta')"
        :count="rows.length"
        to="/workflows"
        :all="{ label: $t('workflowHomePanel.new'), to: '/workflows/new' }"
    >
        <EmptyState v-if="rows.length === 0">{{ $t("workflowHomePanel.none") }}</EmptyState>
        <ul v-else class="divide-y divide-default">
            <li v-for="card in rows" :key="card.id">
                <NuxtLink
                    :to="`/workflows/${card.id}`"
                    class="flex flex-col gap-2 px-4 py-3 hover:bg-elevated"
                >
                    <div class="flex items-baseline justify-between gap-3">
                        <span class="min-w-0">
                            <span class="block truncate text-sm font-medium text-highlighted">
                                {{ card.title }}
                            </span>
                            <span class="block truncate text-xs text-muted">
                                {{ card.templateTitle }}
                            </span>
                        </span>
                        <span data-figure class="shrink-0 text-xl leading-none text-highlighted">
                            {{ card.percent }}<span class="text-sm text-muted">%</span>
                        </span>
                    </div>
                    <SplitBar :parts="card.parts" />
                </NuxtLink>
            </li>
        </ul>
    </WidgetPanel>
</template>
 
<script setup lang="ts">
import { activeProjects, projectCard } from "#layers/workflows/shared/workflows.ts";
import type { SplitPart } from "~/types/SplitPart";
 
const { t } = useI18n();
const { data: workflows } = await useWorkflows();
 
const rows = computed(() =>
    activeProjects(workflows.value.projects).map((view) => ({
        ...projectCard(view),
        parts: [
            { label: t("workflowHomePanel.parts.done"), value: view.progress.done, tone: "ink" },
            {
                label: t("workflowHomePanel.parts.left"),
                value: view.progress.total - view.progress.done,
                tone: "soft",
            },
        ] satisfies SplitPart[],
    })),
);
</script>