2018-01-25 17:31:48 +00:00
|
|
|
import Component from '@ember/component';
|
2018-08-24 22:34:07 +00:00
|
|
|
import { task } from 'ember-concurrency';
|
2020-05-21 05:28:23 +00:00
|
|
|
import { ForbiddenError } from '@ember-data/adapter/error';
|
2018-08-24 22:34:07 +00:00
|
|
|
import messageFromAdapterError from 'nomad-ui/utils/message-from-adapter-error';
|
2020-06-10 13:49:16 +00:00
|
|
|
import { tagName } from '@ember-decorators/component';
|
|
|
|
import classic from 'ember-classic-decorator';
|
2018-01-25 17:31:48 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@classic
|
|
|
|
@tagName('')
|
|
|
|
export default class LatestDeployment extends Component {
|
|
|
|
job = null;
|
2018-07-30 21:32:17 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
handleError() {}
|
2018-08-24 22:34:07 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
isShowingDeploymentDetails = false;
|
2018-08-24 22:34:07 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@task(function*() {
|
2018-08-24 22:34:07 +00:00
|
|
|
try {
|
|
|
|
yield this.get('job.latestDeployment.content').promote();
|
|
|
|
} catch (err) {
|
|
|
|
let message = messageFromAdapterError(err);
|
2020-05-21 05:28:23 +00:00
|
|
|
|
|
|
|
if (err instanceof ForbiddenError) {
|
2018-08-24 22:34:07 +00:00
|
|
|
message = 'Your ACL token does not grant permission to promote deployments.';
|
|
|
|
}
|
2020-05-21 05:28:23 +00:00
|
|
|
|
2019-03-26 07:46:44 +00:00
|
|
|
this.handleError({
|
2018-08-24 22:34:07 +00:00
|
|
|
title: 'Could Not Promote Deployment',
|
|
|
|
description: message,
|
|
|
|
});
|
|
|
|
}
|
2020-06-10 13:49:16 +00:00
|
|
|
})
|
|
|
|
promote;
|
|
|
|
}
|