491f4ff27d
Click events were greedily redirecting to the resource pages instead of first yielding to the anchor tag clicked if an anchor tag was in fact clicked.
36 lines
1.3 KiB
JavaScript
36 lines
1.3 KiB
JavaScript
import Ember from 'ember';
|
|
import { lazyClick } from '../helpers/lazy-click';
|
|
|
|
const { Component, inject, computed } = Ember;
|
|
|
|
export default Component.extend({
|
|
// TODO Switch back to the router service style when it is no longer feature-flagged
|
|
// router: inject.service('router'),
|
|
_router: inject.service('-routing'),
|
|
router: computed.alias('_router.router'),
|
|
|
|
tagName: 'tr',
|
|
classNames: ['server-agent-row', 'is-interactive'],
|
|
classNameBindings: ['isActive:is-active'],
|
|
|
|
agent: null,
|
|
isActive: computed('agent', 'router.currentURL', function() {
|
|
// TODO Switch back to the router service style when it is no longer feature-flagged
|
|
// const targetURL = this.get('router').urlFor('servers.server', this.get('agent'));
|
|
// const currentURL = `${this.get('router.rootURL').slice(0, -1)}${this.get('router.currentURL')}`;
|
|
|
|
const router = this.get('router');
|
|
const targetURL = router.generate('servers.server', this.get('agent'));
|
|
const currentURL = `${router.get('rootURL').slice(0, -1)}${router
|
|
.get('currentURL')
|
|
.split('?')[0]}`;
|
|
|
|
return currentURL === targetURL;
|
|
}),
|
|
|
|
click() {
|
|
const transition = () => this.get('router').transitionTo('servers.server', this.get('agent'));
|
|
lazyClick([transition, event]);
|
|
},
|
|
});
|