Skip to content

Commit

Permalink
feat: only groups containers when there is more than one (#2902)
Browse files Browse the repository at this point in the history
  • Loading branch information
amir20 committed Apr 16, 2024
1 parent 81705c8 commit f4dd11d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions assets/components/SideMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,19 @@ 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) => {
if (a.state === "running" && b.state !== "running") {
return -1;
} else if (a.state !== "running" && b.state === "running") {
return 1;
} else {
return a.name.localeCompare(b.name);
}
}),
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") {
return 1;
} else {
return a.name.localeCompare(b.name);
}
};
const menuItems = computed(() => {
const namespaced: Record<string, Container[]> = {};
const pinned = [];
Expand All @@ -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))) {
items.push({ label, containers, icon: Stack });
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",
Expand Down
Binary file modified e2e/visual.spec.ts-snapshots/dark-homepage-1-chromium-linux.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f4dd11d

Please sign in to comment.