From 85aaa53fd58f1c2ca4f821157dbf05535b5e9a06 Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Thu, 23 Aug 2018 15:40:42 -0700 Subject: [PATCH] Simplify the data control flow around job.plan() --- ui/app/adapters/job.js | 10 +++++++--- ui/app/components/job-editor.js | 3 +-- 2 files changed, 8 insertions(+), 5 deletions(-) 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';