diff --git a/ui/app/components/gutter-menu.js b/ui/app/components/gutter-menu.js index 63fb96085..9ab098cbb 100644 --- a/ui/app/components/gutter-menu.js +++ b/ui/app/components/gutter-menu.js @@ -1,9 +1,35 @@ import Ember from 'ember'; -const { Component, inject } = Ember; +const { Component, inject, computed } = Ember; export default Component.extend({ system: inject.service(), + sortedNamespaces: computed('system.namespaces.@each.name', function() { + const namespaces = this.get('system.namespaces').toArray() || []; + + return namespaces.sort((a, b) => { + const aName = a.get('name'); + const bName = b.get('name'); + + // Make sure the default namespace is always first in the list + if (aName === 'default') { + return -1; + } + if (bName === 'default') { + return 1; + } + + if (aName < bName) { + return -1; + } + if (aName > bName) { + return 1; + } + + return 0; + }); + }), + onNamespaceChange() {}, }); diff --git a/ui/app/templates/components/gutter-menu.hbs b/ui/app/templates/components/gutter-menu.hbs index 31f068742..b8ec0f397 100644 --- a/ui/app/templates/components/gutter-menu.hbs +++ b/ui/app/templates/components/gutter-menu.hbs @@ -9,14 +9,16 @@