open-nomad/ui/app/components/job-page/parts/task-groups.js
Jai Bhagat 2ec864c67e refact: move gotoTaskGroup action to component
Previously, the router service was not available to components. Now that it is,
we no longer need to prop-drill this linking action.
2022-01-24 11:04:48 -05:00

33 lines
890 B
JavaScript

import Component from '@ember/component';
import { action, computed } from '@ember/object';
import { inject as service } from '@ember/service';
import { alias } from '@ember/object/computed';
import Sortable from 'nomad-ui/mixins/sortable';
import { classNames } from '@ember-decorators/component';
import classic from 'ember-classic-decorator';
@classic
@classNames('boxed-section')
export default class TaskGroups extends Component.extend(Sortable) {
@service router;
job = null;
// Provide a value that is bound to a query param
sortProperty = null;
sortDescending = null;
@action
gotoTaskGroup(taskGroup) {
this.router.transitionTo('jobs.job.task-group', this.job, taskGroup);
}
@computed('job.taskGroups.[]')
get taskGroups() {
return this.get('job.taskGroups') || [];
}
@alias('taskGroups') listToSort;
@alias('listSorted') sortedTaskGroups;
}