From 208671ef23bd605ff5ec891855833631133a5e8f Mon Sep 17 00:00:00 2001 From: Amir Raminfar Date: Thu, 11 Jul 2024 10:56:08 -0700 Subject: [PATCH] feat: sorts services in swarm view (#3096) --- assets/stores/swarm.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/assets/stores/swarm.ts b/assets/stores/swarm.ts index 282412d4..53ef8ab1 100644 --- a/assets/stores/swarm.ts +++ b/assets/stores/swarm.ts @@ -39,9 +39,15 @@ export const useSwarmStore = defineStore("swarm", () => { if (newServices.length === 0) continue; - newStacks.push(new Stack(name, containers, newServices)); + newStacks.push( + new Stack( + name, + containers, + newServices.sort((a, b) => a.name.localeCompare(b.name)), + ), + ); } - return newStacks; + return newStacks.sort((a, b) => a.name.localeCompare(b.name)); }); const services = computed(() => { @@ -61,7 +67,7 @@ export const useSwarmStore = defineStore("swarm", () => { const servicesWithoutStack = Object.entries(services).map(([name, containers]) => new Service(name, containers)); - return [...serviceWithStack, ...servicesWithoutStack]; + return [...serviceWithStack, ...servicesWithoutStack].sort((a, b) => a.name.localeCompare(b.name)); }); const customGroups = computed(() => {