github.com/manicqin/nomad@v0.9.5/ui/app/components/gutter-menu.js (about) 1 import { inject as service } from '@ember/service'; 2 import Component from '@ember/component'; 3 import { computed } from '@ember/object'; 4 5 export default Component.extend({ 6 system: service(), 7 router: service(), 8 9 sortedNamespaces: computed('system.namespaces.@each.name', function() { 10 const namespaces = this.get('system.namespaces').toArray() || []; 11 12 return namespaces.sort((a, b) => { 13 const aName = a.get('name'); 14 const bName = b.get('name'); 15 16 // Make sure the default namespace is always first in the list 17 if (aName === 'default') { 18 return -1; 19 } 20 if (bName === 'default') { 21 return 1; 22 } 23 24 if (aName < bName) { 25 return -1; 26 } 27 if (aName > bName) { 28 return 1; 29 } 30 31 return 0; 32 }); 33 }), 34 35 onHamburgerClick() {}, 36 37 gotoJobsForNamespace(namespace) { 38 if (!namespace || !namespace.get('id')) return; 39 40 this.router.transitionTo('jobs', { 41 queryParams: { namespace: namespace.get('id') }, 42 }); 43 }, 44 });