github.com/emate/nomad@v0.8.2-wo-binpacking/ui/app/components/server-agent-row.js (about)

     1  import { inject as service } from '@ember/service';
     2  import { alias } from '@ember/object/computed';
     3  import Component from '@ember/component';
     4  import { computed } from '@ember/object';
     5  import { lazyClick } from '../helpers/lazy-click';
     6  
     7  export default Component.extend({
     8    // TODO Switch back to the router service once the service behaves more like Route
     9    // https://github.com/emberjs/ember.js/issues/15801
    10    // router: inject.service('router'),
    11    _router: service('-routing'),
    12    router: alias('_router.router'),
    13  
    14    tagName: 'tr',
    15    classNames: ['server-agent-row', 'is-interactive'],
    16    classNameBindings: ['isActive:is-active'],
    17  
    18    agent: null,
    19    isActive: computed('agent', 'router.currentURL', function() {
    20      // TODO Switch back to the router service once the service behaves more like Route
    21      // https://github.com/emberjs/ember.js/issues/15801
    22      // const targetURL = this.get('router').urlFor('servers.server', this.get('agent'));
    23      // const currentURL = `${this.get('router.rootURL').slice(0, -1)}${this.get('router.currentURL')}`;
    24  
    25      const router = this.get('router');
    26      const targetURL = router.generate('servers.server', this.get('agent'));
    27      const currentURL = `${router.get('rootURL').slice(0, -1)}${router
    28        .get('currentURL')
    29        .split('?')[0]}`;
    30  
    31      return currentURL === targetURL;
    32    }),
    33  
    34    click() {
    35      const transition = () => this.get('router').transitionTo('servers.server', this.get('agent'));
    36      lazyClick([transition, event]);
    37    },
    38  });