open-nomad/ui/app/components/job-page/parts/recent-allocations.js
2019-06-19 17:18:40 -07:00

27 lines
697 B
JavaScript

import Component from '@ember/component';
import { computed } from '@ember/object';
import PromiseArray from 'nomad-ui/utils/classes/promise-array';
export default Component.extend({
classNames: ['boxed-section'],
sortProperty: 'modifyIndex',
sortDescending: true,
sortedAllocations: computed('job.allocations.@each.modifyIndex', function() {
return new PromiseArray({
promise: this.get('job.allocations').then(allocations =>
allocations
.sortBy('modifyIndex')
.reverse()
.slice(0, 5)
),
});
}),
actions: {
gotoAllocation(allocation) {
this.transitionToRoute('allocations.allocation', allocation);
},
},
});