All files / apps/developer-portal/layers/audits/app/components AuditsToolbar.vue

85% Statements 17/20
100% Branches 8/8
72.72% Functions 8/11
87.5% Lines 14/16

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  2x     1x         3x         3x                               2x 2x 2x 2x   2x   2x 6x     2x 6x     2x    
<template>
    <UDashboardToolbar>
        <template #left>
            <UInput
                v-model="search"
                icon="i-lucide-search"
                :placeholder="$t('auditsToolbar.search')"
                size="sm"
                class="w-56"
            />
            <USelect v-model="state" :items="stateItems" value-key="value" size="sm" class="w-40" />
            <USelect v-model="scope" :items="scopeItems" value-key="value" size="sm" class="w-56" />
        </template>
        <template #right>
            <USelect v-model="sort" :items="sortItems" value-key="value" size="sm" class="w-44" />
        </template>
    </UDashboardToolbar>
</template>
 
<script setup lang="ts">
import { AUDIT_SORTS, type AuditSort } from "#layers/audits/shared/auditReports.ts";
import { AUDIT_STATES, type AuditState } from "#layers/snapshot/shared/audits.ts";
 
interface Props {
    /** Every scope an audit covers, to filter by. */
    scopes: string[];
}
 
const { scopes } = defineProps<Props>();
 
const search = defineModel<string>("search", { required: true });
const state = defineModel<AuditState | "all">("state", { required: true });
const scope = defineModel<string>("scope", { required: true });
const sort = defineModel<AuditSort>("sort", { required: true });
 
const { t } = useI18n();
 
const stateItems = computed(() =>
    filterItems(t("auditsToolbar.everyState"), AUDIT_STATES, (value) => t(`audits.state.${value}`)),
);
 
const sortItems = computed(() =>
    AUDIT_SORTS.map((value) => ({ label: t(`auditsToolbar.sorts.${value}`), value })),
);
 
const scopeItems = computed(() => filterItems(t("auditsToolbar.everyScope"), scopes));
</script>