2017-12-15 21:39:18 +00:00
|
|
|
import Component from '@ember/component';
|
|
|
|
import { computed } from '@ember/object';
|
2019-10-15 18:32:58 +00:00
|
|
|
import { computed as overridable } from 'ember-overridable-computed';
|
2017-09-19 14:47:10 +00:00
|
|
|
import moment from 'moment';
|
2020-06-10 13:49:16 +00:00
|
|
|
import { classNames, tagName } from '@ember-decorators/component';
|
|
|
|
import classic from 'ember-classic-decorator';
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@classic
|
|
|
|
@tagName('ol')
|
|
|
|
@classNames('timeline')
|
|
|
|
export default class JobDeploymentsStream extends Component {
|
|
|
|
@overridable(() => []) deployments;
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@computed('deployments.@each.versionSubmitTime')
|
|
|
|
get sortedDeployments() {
|
|
|
|
return this.deployments.sortBy('versionSubmitTime').reverse();
|
|
|
|
}
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@computed('sortedDeployments.@each.version')
|
|
|
|
get annotatedDeployments() {
|
2019-03-26 07:46:44 +00:00
|
|
|
const deployments = this.sortedDeployments;
|
2017-09-19 14:47:10 +00:00
|
|
|
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 };
|
|
|
|
});
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
|
|
|
}
|