Skip to content

Commit 8fbbfaf

Browse files
authored
feat: adds new menu for custom groups (#3573)
1 parent 3d077b9 commit 8fbbfaf

File tree

22 files changed

+83
-47
lines changed

22 files changed

+83
-47
lines changed

assets/components.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ declare module 'vue' {
4040
EventSource: typeof import('./components/LogViewer/EventSource.vue')['default']
4141
FuzzySearchModal: typeof import('./components/FuzzySearchModal.vue')['default']
4242
GroupedLog: typeof import('./components/GroupedViewer/GroupedLog.vue')['default']
43+
GroupMenu: typeof import('./components/GroupMenu.vue')['default']
4344
HostIcon: typeof import('./components/common/HostIcon.vue')['default']
4445
HostList: typeof import('./components/HostList.vue')['default']
4546
HostLog: typeof import('./components/HostViewer/HostLog.vue')['default']

assets/components/GroupMenu.vue

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<template>
2+
<ul class="menu w-full p-0 text-[0.95rem]">
3+
<li v-if="customGroups.length > 0">
4+
<details open>
5+
<summary class="text-base-content/80 font-light">
6+
<ph:bounding-box-fill />
7+
{{ $t("label.group-menu") }}
8+
</summary>
9+
<ul>
10+
<li v-for="group in customGroups" :key="group.name">
11+
<router-link :to="{ name: '/group/[name]', params: { name: group.name } }" active-class="menu-active">
12+
<ph:stack-simple />
13+
<div class="truncate">
14+
{{ group.name }}
15+
</div>
16+
</router-link>
17+
</li>
18+
</ul>
19+
</details>
20+
</li>
21+
</ul>
22+
</template>
23+
24+
<script lang="ts" setup>
25+
const store = useSwarmStore();
26+
27+
const { customGroups } = storeToRefs(store);
28+
</script>
29+
<style scoped></style>

assets/components/SideMenu.vue

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
<template>
22
<div v-if="ready" data-testid="side-menu" class="flex min-h-0 flex-col">
33
<Carousel v-model="selectedCard" class="flex-1">
4-
<CarouselItem title="Hosts and Containers" id="host">
4+
<CarouselItem :title="$t('label.host-menu')" id="host">
55
<HostMenu />
66
</CarouselItem>
7-
<CarouselItem title="Services and Stacks" v-if="services.length > 0" id="swarm">
7+
<CarouselItem :title="$t('label.group-menu')" v-if="customGroups.length > 0" id="group">
8+
<GroupMenu />
9+
</CarouselItem>
10+
<CarouselItem :title="$t('label.swarm-menu')" v-if="services.length > 0" id="swarm">
811
<SwarmMenu />
912
</CarouselItem>
1013
</Carousel>
@@ -20,16 +23,14 @@ const containerStore = useContainerStore();
2023
const { ready } = storeToRefs(containerStore);
2124
const route = useRoute();
2225
const swarmStore = useSwarmStore();
23-
const { services } = storeToRefs(swarmStore);
24-
const selectedCard = ref<"host" | "swarm">("host");
26+
const { services, customGroups } = storeToRefs(swarmStore);
27+
const selectedCard = ref<"host" | "swarm" | "group">("host");
2528
2629
watch(
2730
route,
2831
() => {
29-
if (route.meta.swarmMode) {
30-
selectedCard.value = "swarm";
31-
} else if (route.meta.containerMode) {
32-
selectedCard.value = "host";
32+
if (route.meta.menu && ["host", "swarm", "group"].includes(route.meta.menu as string)) {
33+
selectedCard.value = route.meta.menu as "host" | "swarm" | "group";
3334
}
3435
},
3536
{ immediate: true },

assets/components/SwarmMenu.vue

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -46,37 +46,13 @@
4646
</ul>
4747
</details>
4848
</li>
49-
50-
<li v-if="customGroups.length > 0">
51-
<details open>
52-
<summary class="text-base-content/80 font-light">
53-
<ph:bounding-box-fill />
54-
{{ $t("label.custom-groups") }}
55-
</summary>
56-
<ul>
57-
<li v-for="group in customGroups" :key="group.name">
58-
<router-link :to="{ name: '/group/[name]', params: { name: group.name } }" active-class="menu-active">
59-
<ph:stack-simple />
60-
<div class="truncate">
61-
{{ group.name }}
62-
</div>
63-
</router-link>
64-
</li>
65-
</ul>
66-
</details>
67-
</li>
6849
</ul>
6950
</template>
7051

7152
<script lang="ts" setup>
7253
const store = useSwarmStore();
7354
74-
const { stacks, services, customGroups } = storeToRefs(store);
55+
const { stacks, services } = storeToRefs(store);
7556
7657
const servicesWithoutStacks = computed(() => services.value.filter((service) => !service.stack));
7758
</script>
78-
<style scoped>
79-
.menu {
80-
@apply text-[0.95rem];
81-
}
82-
</style>

assets/pages/container/[id].vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,5 @@ watchEffect(() => {
7878
</script>
7979
<route lang="yaml">
8080
meta:
81-
containerMode: true
81+
menu: host
8282
</route>

assets/pages/group/[name].vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ watchEffect(() => {
2222
</script>
2323
<route lang="yaml">
2424
meta:
25-
swarmMode: true
25+
menu: group
2626
</route>

assets/pages/host/[id].vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ watchEffect(() => {
2626
</script>
2727
<route lang="yaml">
2828
meta:
29-
containerMode: true
29+
menu: host
3030
</route>

assets/pages/merged/[ids].vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ watchEffect(() => {
2222
</script>
2323
<route lang="yaml">
2424
meta:
25-
containerMode: true
25+
menu: host
2626
</route>

assets/pages/service/[name].vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ watchEffect(() => {
2828
</script>
2929
<route lang="yaml">
3030
meta:
31-
swarmMode: true
31+
menu: swarm
3232
</route>

assets/pages/stack/[name].vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ watchEffect(() => {
2828
</script>
2929
<route lang="yaml">
3030
meta:
31-
swarmMode: true
31+
menu: swarm
3232
</route>

0 commit comments

Comments
 (0)