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

0% Statements 0/29
0% Branches 0/26
0% Functions 0/16
0% Lines 0/24

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 97 98 99 100 101 102 103 104                                                                                                                                                                                                               
<template>
    <div class="flex flex-wrap items-center gap-2">
        <template v-if="Idirty">
            <UButton
                icon="i-lucide-save"
                label="Save edit"
                :loading="!!busy"
                @click="emit('save')"
            />
            <UButton color="neutral" variant="ghost" label="Discard" @click="emit('discard')" />
            <USeparator orientation="vertical" class="h-6" />
        </template>
 
        <UButton
            v-if="Iitem.state.drift"
            icon="i-lucide-refresh-cw"
            color="warning"
            label="Re-pull"
            :loading="!!busy"
            @click="emit('act', 'repull')"
        />
 
        <UTooltip :text="confirmed ? 'Back to seen' : 'Confirm'" :kbds="['c']">
            <UButton
                v-if="Iconfirmed && pending"
                icon="i-lucide-check-check"
                color="success"
                variant="solid"
                label="Confirmed"
                :disabled="dirty"
                @click="emit('act', 'unconfirm')"
            />
            <UButton
                v-else
                icon="i-lucide-check"
                color="success"
                variant="soft"
                label="Confirm"
                :disabled="!pending || dirty"
                @click="emit('act', 'confirm')"
            />
        </UTooltip>
        <UButton
            v-if="Irejected"
            icon="i-lucide-rotate-ccw"
            color="error"
            variant="outline"
            label="Undo reject"
            @click="emit('act', 'unreject')"
        />
        <UButton
            v-else
            icon="i-lucide-x"
            color="error"
            variant="soft"
            label="Reject"
            :disabled="!pending || dirty"
            @click="emit('act', 'reject')"
        />
        <UButton
            :icon="dryRun ? 'i-lucide-flask-conical' : 'i-lucide-upload'"
            :label="dryRun ? 'Dry run' : 'Apply'"
            :disabled="!pending || dirty || !!item.state.drift"
            :loading="applying"
            @click="emit('act', dryRun ? 'dry-run' : 'apply')"
        />
        <UButton
            v-if="Ilive"
            icon="i-lucide-undo-2"
            color="neutral"
            variant="outline"
            label="Restore"
            :disabled="dryRun"
            :loading="restoring"
            @click="emit('act', 'restore')"
        />
    </div>
</template>
 
<script setup lang="ts">
import { isApplied, isPending } from "#shared/rules.ts";
import type { Item } from "#shared/types/Item.ts";
import type { ItemAction } from "~/composables/useChangeset";
 
interface Props {
    item: Item;
    busy: string | null;
    dirty: boolean;
    dryRun: boolean;
}
 
const props = defineProps<Props>();
const emit = defineEmits<{ act: [action: ItemAction]; save: []; discard: [] }>();
 
const pending = computed(() => isPending(props.item));
const applying = computed(
    () => !!props.busy?.startsWith("Apply") || !!props.busy?.startsWith("Dry-run"),
);
const restoring = computed(() => !!props.busy?.startsWith("Restore"));
const live = computed(() => isApplied(props.item));
const confirmed = computed(() => props.item.state.level === "confirmed");
const rejected = computed(() => !!props.item.state.rejected);
</script>