diff --git a/ui/app/adapters/job.js b/ui/app/adapters/job.js index b9dc7aa09..efc18efea 100644 --- a/ui/app/adapters/job.js +++ b/ui/app/adapters/job.js @@ -77,15 +77,19 @@ export default Watchable.extend({ }, plan(job) { - const url = addToPath(this.urlForFindRecord(job.get('id'), 'job'), '/plan'); + const jobId = job.get('id'); + const store = this.get('store'); + const url = addToPath(this.urlForFindRecord(jobId, 'job'), '/plan'); + return this.ajax(url, 'POST', { data: { Job: job.get('_newDefinitionJSON'), Diff: true, }, }).then(json => { - json.ID = job.get('id'); - this.get('store').pushPayload('job-plan', { jobPlans: [json] }); + json.ID = jobId; + store.pushPayload('job-plan', { jobPlans: [json] }); + return store.peekRecord('job-plan', jobId); }); }, diff --git a/ui/app/components/job-editor.js b/ui/app/components/job-editor.js index d72c97a8a..2620954dc 100644 --- a/ui/app/components/job-editor.js +++ b/ui/app/components/job-editor.js @@ -55,8 +55,7 @@ export default Component.extend({ } try { - yield this.get('job').plan(); - const plan = this.get('store').peekRecord('job-plan', this.get('job.id')); + const plan = yield this.get('job').plan(); this.set('planOutput', plan); } catch (err) { const error = messageFromAdapterError(err) || 'Could not plan job';