github.com/manicqin/nomad@v0.9.5/ui/app/adapters/deployment.js (about)

     1  import Watchable from './watchable';
     2  
     3  export default Watchable.extend({
     4    promote(deployment) {
     5      const id = deployment.get('id');
     6      const url = urlForAction(this.urlForFindRecord(id, 'deployment'), '/promote');
     7      return this.ajax(url, 'POST', {
     8        data: {
     9          DeploymentId: id,
    10          All: true,
    11        },
    12      });
    13    },
    14  });
    15  
    16  // The deployment action API endpoints all end with the ID
    17  // /deployment/:action/:deployment_id instead of /deployment/:deployment_id/:action
    18  function urlForAction(url, extension = '') {
    19    const [path, params] = url.split('?');
    20    const pathParts = path.split('/');
    21    const idPart = pathParts.pop();
    22    let newUrl = `${pathParts.join('/')}${extension}/${idPart}`;
    23  
    24    if (params) {
    25      newUrl += `?${params}`;
    26    }
    27  
    28    return newUrl;
    29  }