From 494f791c087ecc6215dcafce77026fbd2fcf3265 Mon Sep 17 00:00:00 2001 From: Sam Wray Date: Thu, 1 Jul 2021 10:38:09 +0100 Subject: [PATCH] feat(gallery): updates ordering of modules to be alphabetical add a sort to modulesByRenderer fixes #605 --- src/components/Gallery.vue | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/components/Gallery.vue b/src/components/Gallery.vue index 736d7d04c..b40320f3b 100644 --- a/src/components/Gallery.vue +++ b/src/components/Gallery.vue @@ -97,18 +97,24 @@ export default { }, modulesByRenderer() { - return Object.keys(this.registeredModules).reduce((obj, key) => { - const module = this.registeredModules[key]; - const { type, name } = module.meta; - - if (!(type in obj)) { - obj[type] = {}; - } + return Object.keys(this.registeredModules) + .sort((a, b) => + this.registeredModules[a].meta.name.localeCompare( + this.registeredModules[b].meta.name + ) + ) + .reduce((obj, key) => { + const module = this.registeredModules[key]; + const { type, name } = module.meta; + + if (!(type in obj)) { + obj[type] = {}; + } - obj[type][name] = module; + obj[type][name] = module; - return obj; - }, {}); + return obj; + }, {}); } },