mirror of
https://github.com/amir20/dozzle.git
synced 2025-12-24 06:28:42 +01:00
feat: only groups containers when there is more than one (#2902)
This commit is contained in:
@@ -95,9 +95,10 @@ const updateCollapsedGroups = (event: Event, label: string) => {
|
|||||||
|
|
||||||
const debouncedPinnedContainers = debouncedRef(pinnedContainers, 200);
|
const debouncedPinnedContainers = debouncedRef(pinnedContainers, 200);
|
||||||
const sortedContainers = computed(() =>
|
const sortedContainers = computed(() =>
|
||||||
visibleContainers.value
|
visibleContainers.value.filter((c) => c.host === sessionHost.value).sort(sorter),
|
||||||
.filter((c) => c.host === sessionHost.value)
|
);
|
||||||
.sort((a, b) => {
|
|
||||||
|
const sorter = (a: Container, b: Container) => {
|
||||||
if (a.state === "running" && b.state !== "running") {
|
if (a.state === "running" && b.state !== "running") {
|
||||||
return -1;
|
return -1;
|
||||||
} else if (a.state !== "running" && b.state === "running") {
|
} else if (a.state !== "running" && b.state === "running") {
|
||||||
@@ -105,8 +106,7 @@ const sortedContainers = computed(() =>
|
|||||||
} else {
|
} else {
|
||||||
return a.name.localeCompare(b.name);
|
return a.name.localeCompare(b.name);
|
||||||
}
|
}
|
||||||
}),
|
};
|
||||||
);
|
|
||||||
|
|
||||||
const menuItems = computed(() => {
|
const menuItems = computed(() => {
|
||||||
const namespaced: Record<string, Container[]> = {};
|
const namespaced: Record<string, Container[]> = {};
|
||||||
@@ -130,8 +130,15 @@ const menuItems = computed(() => {
|
|||||||
items.push({ label: "label.pinned", containers: pinned, icon: Pin });
|
items.push({ label: "label.pinned", containers: pinned, icon: Pin });
|
||||||
}
|
}
|
||||||
for (const [label, containers] of Object.entries(namespaced).sort(([a], [b]) => a.localeCompare(b))) {
|
for (const [label, containers] of Object.entries(namespaced).sort(([a], [b]) => a.localeCompare(b))) {
|
||||||
|
if (containers.length > 1) {
|
||||||
items.push({ label, containers, icon: Stack });
|
items.push({ label, containers, icon: Stack });
|
||||||
|
} else {
|
||||||
|
singular.push(containers[0]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
singular.sort(sorter);
|
||||||
|
|
||||||
if (singular.length) {
|
if (singular.length) {
|
||||||
items.push({
|
items.push({
|
||||||
label: showAllContainers.value ? "label.all-containers" : "label.running-containers",
|
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 |
Reference in New Issue
Block a user