Skip to content

Commit

Permalink
Use tabs to filter the package list by status
Browse files Browse the repository at this point in the history
Refs #989
  • Loading branch information
djjuhasz committed Oct 29, 2024
1 parent e5dc404 commit f170662
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 2 deletions.
60 changes: 60 additions & 0 deletions dashboard/src/components/PackageListTabFilters.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<script setup lang="ts">
import { usePackageStore } from "@/stores/package";
import { PackageListStatusEnum } from "@/openapi-generator";
import IconCheckCircleLine from "~icons/clarity/check-circle-line";
import IconTimesCircleLine from "~icons/clarity/times-circle-line";
import IconPlayLine from "~icons/clarity/play-line";
import IconBarsLine from "~icons/clarity/bars-line";
import type { FunctionalComponent } from "vue";
const packageStore = usePackageStore();
class tab {
value: string;
label: string;
icon?: FunctionalComponent;
constructor(v: string, l: string, i?: FunctionalComponent) {
this.value = v;
this.label = l;
this.icon = i;
}
}
const tabs = [
new tab("", "All"),
new tab("done", "Done", IconCheckCircleLine),
new tab("error", "Error", IconTimesCircleLine),
new tab("in progress", "In progress", IconPlayLine),
new tab("queued", "Queued", IconBarsLine),
];
const iconName = "IconCheckCircleLine";
function changeStatusFilter(s: string) {
if (s == packageStore.filters.status) {
return;
}
packageStore.filters.status = s as PackageListStatusEnum;
packageStore.fetchPackages(1);
}
</script>

<template>
<ul class="nav nav-tabs">
<li v-for="tab in tabs">
<a
:class="[
'nav-link',
packageStore.filters.status == tab.value ? 'active' : '',
]"
:aria-current="packageStore.filters.status == tab.value"
href="#"
@click="changeStatusFilter(tab.value)"
>
<component :is="tab.icon" />&nbsp;{{ tab.label }}
</a>
</li>
</ul>
</template>
4 changes: 2 additions & 2 deletions dashboard/src/pages/packages/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import PackageListFilters from "@/components/PackageListFilters.vue";
import PackageListTabFilters from "@/components/PackageListTabFilters.vue";
import PackageListLegend from "@/components/PackageListLegend.vue";
import PageLoadingAlert from "@/components/PageLoadingAlert.vue";
import StatusBadge from "@/components/StatusBadge.vue";
Expand Down Expand Up @@ -53,7 +53,7 @@ const toggleLegend = () => {
{{ packageStore.page.total }}
</div>

<PackageListFilters />
<PackageListTabFilters />
<PageLoadingAlert :execute="execute" :error="error" />
<PackageListLegend v-model="showLegend" />

Expand Down

0 comments on commit f170662

Please sign in to comment.