github.com/blixtra/nomad@v0.7.2-0.20171221000451-da9a1d7bb050/ui/app/components/gutter-menu.js (about)

     1  import Ember from 'ember';
     2  
     3  const { Component, inject, computed } = Ember;
     4  
     5  export default Component.extend({
     6    system: inject.service(),
     7  
     8    sortedNamespaces: computed('system.namespaces.@each.name', function() {
     9      const namespaces = this.get('system.namespaces').toArray() || [];
    10  
    11      return namespaces.sort((a, b) => {
    12        const aName = a.get('name');
    13        const bName = b.get('name');
    14  
    15        // Make sure the default namespace is always first in the list
    16        if (aName === 'default') {
    17          return -1;
    18        }
    19        if (bName === 'default') {
    20          return 1;
    21        }
    22  
    23        if (aName < bName) {
    24          return -1;
    25        }
    26        if (aName > bName) {
    27          return 1;
    28        }
    29  
    30        return 0;
    31      });
    32    }),
    33  
    34    onNamespaceChange() {},
    35  });