1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-21 13:23:07 +01:00

feat: only groups containers when there is more than one (#2902)

This commit is contained in:
Amir Raminfar
2024-04-16 12:55:59 -07:00
committed by GitHub
parent 81705c8a47
commit f4dd11d136
3 changed files with 19 additions and 12 deletions

View File

@@ -95,9 +95,10 @@ const updateCollapsedGroups = (event: Event, label: string) => {
const debouncedPinnedContainers = debouncedRef(pinnedContainers, 200);
const sortedContainers = computed(() =>
visibleContainers.value
.filter((c) => c.host === sessionHost.value)
.sort((a, b) => {
visibleContainers.value.filter((c) => c.host === sessionHost.value).sort(sorter),
);
const sorter = (a: Container, b: Container) => {
if (a.state === "running" && b.state !== "running") {
return -1;
} else if (a.state !== "running" && b.state === "running") {
@@ -105,8 +106,7 @@ const sortedContainers = computed(() =>
} else {
return a.name.localeCompare(b.name);
}
}),
);
};
const menuItems = computed(() => {
const namespaced: Record<string, Container[]> = {};
@@ -130,8 +130,15 @@ const menuItems = computed(() => {
items.push({ label: "label.pinned", containers: pinned, icon: Pin });
}
for (const [label, containers] of Object.entries(namespaced).sort(([a], [b]) => a.localeCompare(b))) {
if (containers.length > 1) {
items.push({ label, containers, icon: Stack });
} else {
singular.push(containers[0]);
}
}
singular.sort(sorter);
if (singular.length) {
items.push({
label: showAllContainers.value ? "label.all-containers" : "label.running-containers",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 14 KiB