open-nomad/ui/app/components/job-deployments-stream.js
Buck Doyle 9b2fb14e51
UI: Update Ember to 3.12 LTS (#6419)
This is mostly deprecation fixes and blueprint changes. There
are some dependency updates too; the changes to Ember
Basic Dropdown necessitated changing it to angle bracket
component invocation. The conversion of the rest of the
templates will happen separately.
2019-10-15 13:32:58 -05:00

44 lines
1.2 KiB
JavaScript

import Component from '@ember/component';
import { computed } from '@ember/object';
import { computed as overridable } from 'ember-overridable-computed';
import moment from 'moment';
export default Component.extend({
tagName: 'ol',
classNames: ['timeline'],
deployments: overridable(() => []),
sortedDeployments: computed('deployments.@each.versionSubmitTime', function() {
return this.deployments
.sortBy('versionSubmitTime')
.reverse();
}),
annotatedDeployments: computed('sortedDeployments.@each.version', function() {
const deployments = this.sortedDeployments;
return deployments.map((deployment, index) => {
const meta = {};
if (index === 0) {
meta.showDate = true;
} else {
const previousDeployment = deployments.objectAt(index - 1);
const previousSubmitTime = previousDeployment.get('version.submitTime');
const submitTime = deployment.get('submitTime');
if (
submitTime &&
previousSubmitTime &&
moment(previousSubmitTime)
.startOf('day')
.diff(moment(submitTime).startOf('day'), 'days') > 0
) {
meta.showDate = true;
}
}
return { deployment, meta };
});
}),
});