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

93.1% Statements 27/29
100% Branches 12/12
87.5% Functions 14/16
92.3% Lines 24/26

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 95 96  2x   2x 2x     2x       8x                 4x                                   6x 6x   6x   15x   15x       2x                       2x   15x                               8x   8x 8x   8x 5x 5x     8x 8x 8x 4x      
<template>
    <section class="grid gap-4 border-t border-default pt-8 md:grid-cols-3">
        <header>
            <h2 class="font-semibold">{{ $t("settingsRemove.title") }}</h2>
            <p class="text-sm text-muted">{{ $t("settingsRemove.rarely") }}</p>
        </header>
        <div
            class="flex flex-wrap items-center justify-between gap-3 rounded-xl border border-default p-4 md:col-span-2"
        >
            <I18nT keypath="settingsRemove.lead" tag="p" scope="global" class="text-sm text-muted">
                <template #command>
                    <code>{{ drop }}</code>
                </template>
            </I18nT>
            <UButton
                :label="$t('settingsRemove.deleteOpen')"
                icon="i-lucide-trash-2"
                color="error"
                variant="soft"
                size="sm"
                @click="deleting = true"
            />
        </div>
    </section>
 
    <UModal
        v-model:open="deleting"
        :title="$t('settingsRemove.modal.title', { title })"
        :description="$t('settingsRemove.modal.description')"
    >
        <template #body>
            <I18nT
                v-if="dropping.close > 0"
                keypath="settingsRemove.drop"
                tag="p"
                scope="global"
                class="mb-4 text-sm text-muted"
            >
                <template #close>{{ dropping.close }}</template>
                <template #keep>{{ dropping.keep }}</template>
                <template #command>
                    <code>{{ dropYes }}</code>
                </template>
            </I18nT>
            <UFormField :label="$t('settingsRemove.confirm', { project })">
                <UInput v-model="confirmation" class="w-full" autofocus />
            </UFormField>
        </template>
        <template #footer>
            <div class="flex w-full justify-end gap-2">
                <UButton
                    :label="$t('settingsRemove.cancel')"
                    color="neutral"
                    variant="ghost"
                    @click="deleting = false"
                />
                <UButton
                    :label="$t('settingsRemove.delete')"
                    icon="i-lucide-trash-2"
                    color="error"
                    :disabled="confirmation !== project"
                    @click="emit('remove')"
                />
            </div>
        </template>
    </UModal>
</template>
 
<script setup lang="ts">
import { dropPlan, type SnapshotIssue } from "#layers/workflows/shared/workflows.ts";
 
interface Props {
    project: string;
    title: string;
    /** The tickets as of the last sync, which decide what `workflow:drop` would close. */
    issues: SnapshotIssue[];
}
 
const { project, title, issues } = defineProps<Props>();
const emit = defineEmits<{ remove: [] }>();
 
const drop = computed(() => `pnpm workflow:drop ${project}`);
const dropYes = computed(() => `${drop.value} --yes`);
 
const dropping = computed(() => {
    const { close, keep } = dropPlan(issues);
    return { close: close.length, keep: keep.length };
});
 
const deleting = ref(false);
const confirmation = ref("");
watch(deleting, () => {
    confirmation.value = "";
});
</script>