2018-08-24 22:33:04 +00:00
|
|
|
import Watchable from './watchable';
|
|
|
|
|
2020-06-11 21:23:00 +00:00
|
|
|
export default class DeploymentAdapter extends Watchable {
|
2018-08-24 22:33:04 +00:00
|
|
|
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,
|
|
|
|
},
|
|
|
|
});
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
|
|
|
}
|
2018-08-24 22:33:04 +00:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|