feat: allow disabled links

This commit is contained in:
2026-03-25 16:16:46 +01:00
parent 1d893719ef
commit bc9a95a7c8
3 changed files with 27 additions and 2 deletions

View File

@@ -17,10 +17,15 @@ const signOut = async () => {
const { data: links, status, refresh } = useLazyFetch("/api/links", { key: "links", server: false, });
const route = useRoute();
const category = computed(() => route.query.filter === "disabled" ? "disabled" : "all",);
const category = computed(() => {
if (route.query.filter === "active") return "active";
if (route.query.filter === "disabled") return "disabled";
return "all";
});
const filteredLinks = computed(() => {
if (!links.value) return [];
if (category.value === "active") return links.value.filter((l) => !l.disabled);
if (category.value === "disabled") return links.value.filter((l) => l.disabled);
return links.value;
});
@@ -61,6 +66,13 @@ const deleteLink = async (link: Link) => {
to: '/dashboard',
active: category === 'all',
},
{
label: 'Active',
icon: 'i-lucide-link-2',
badge: links?.filter((l) => !l.disabled).length ?? 0,
to: '/dashboard?filter=active',
active: category === 'active',
},
{
label: 'Disabled',
icon: 'i-lucide-link-2-off',
@@ -80,7 +92,7 @@ const deleteLink = async (link: Link) => {
<UDashboardPanel>
<template #header>
<UDashboardNavbar :title="category === 'all' ? 'All links' : 'Disabled links'">
<UDashboardNavbar :title="category === 'all' ? 'All links' : category === 'active' ? 'Active links' : 'Disabled links'">
<template #right>
<UButton icon="i-lucide-plus" @click="openModal(null)">
New link