f462d7d1c2
This closes #8744 and #9826. It necessitated some customisation options for TwoStepButton. One is inlineText, which puts the confirmation text in the same line as the buttons. Also, there was a single-use configuration option named isInfoAction that I removed in favour of passing a set of class configuration options like this: @classes={{hash idleButton="is-warning" confirmationMessage="inherit-color" cancelButton="is-danger is-important" confirmButton="is-warning"}}
40 lines
1 KiB
JavaScript
40 lines
1 KiB
JavaScript
import Watchable from './watchable';
|
|
|
|
export default class DeploymentAdapter extends Watchable {
|
|
fail(deployment) {
|
|
const id = deployment.get('id');
|
|
const url = urlForAction(this.urlForFindRecord(id, 'deployment'), '/fail');
|
|
return this.ajax(url, 'POST', {
|
|
data: {
|
|
DeploymentId: id,
|
|
},
|
|
});
|
|
}
|
|
|
|
promote(deployment) {
|
|
const id = deployment.get('id');
|
|
const url = urlForAction(this.urlForFindRecord(id, 'deployment'), '/promote');
|
|
return this.ajax(url, 'POST', {
|
|
data: {
|
|
DeploymentId: id,
|
|
All: true,
|
|
},
|
|
});
|
|
}
|
|
}
|
|
|
|
// The deployment action API endpoints all end with the ID
|
|
// /deployment/:action/:deployment_id instead of /deployment/:deployment_id/:action
|
|
function urlForAction(url, extension = '') {
|
|
const [path, params] = url.split('?');
|
|
const pathParts = path.split('/');
|
|
const idPart = pathParts.pop();
|
|
let newUrl = `${pathParts.join('/')}${extension}/${idPart}`;
|
|
|
|
if (params) {
|
|
newUrl += `?${params}`;
|
|
}
|
|
|
|
return newUrl;
|
|
}
|