github.com/hernad/nomad@v1.6.112/ui/app/components/gutter-menu.js (about)

     1  /**
     2   * Copyright (c) HashiCorp, Inc.
     3   * SPDX-License-Identifier: MPL-2.0
     4   */
     5  
     6  import { inject as service } from '@ember/service';
     7  import Component from '@ember/component';
     8  import { computed } from '@ember/object';
     9  import classic from 'ember-classic-decorator';
    10  
    11  @classic
    12  export default class GutterMenu extends Component {
    13    @service system;
    14    @service router;
    15    @service keyboard;
    16  
    17    @computed('system.namespaces.@each.name')
    18    get sortedNamespaces() {
    19      const namespaces = this.get('system.namespaces').toArray() || [];
    20  
    21      return namespaces.sort((a, b) => {
    22        const aName = a.get('name');
    23        const bName = b.get('name');
    24  
    25        // Make sure the default namespace is always first in the list
    26        if (aName === 'default') {
    27          return -1;
    28        }
    29        if (bName === 'default') {
    30          return 1;
    31        }
    32  
    33        if (aName < bName) {
    34          return -1;
    35        }
    36        if (aName > bName) {
    37          return 1;
    38        }
    39  
    40        return 0;
    41      });
    42    }
    43  
    44    onHamburgerClick() {}
    45  
    46    // Seemingly redundant, but serves to ensure the action is passed to the keyboard service correctly
    47    transitionTo(destination) {
    48      return this.router.transitionTo(destination);
    49    }
    50  }