From 6345083c4d7041a96dd3a6889acad9b778e3632b Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Sat, 1 Jun 2019 12:25:09 +1000 Subject: [PATCH] initialize auth params and endpoints in the route & model --- .../discourse/controllers/admin-wizards-api.js.es6 | 6 ------ .../javascripts/discourse/models/custom-wizard-api.js.es6 | 4 ++-- .../javascripts/discourse/routes/admin-wizards-api.js.es6 | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/assets/javascripts/discourse/controllers/admin-wizards-api.js.es6 b/assets/javascripts/discourse/controllers/admin-wizards-api.js.es6 index 3787c60e..ec4b5170 100644 --- a/assets/javascripts/discourse/controllers/admin-wizards-api.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-wizards-api.js.es6 @@ -11,9 +11,6 @@ export default Ember.Controller.extend({ actions: { addParam() { - if (this.get('api.authParams') == undefined) { - this.set('api.authParams',[]); - }; this.get('api.authParams').pushObject({}); }, @@ -22,9 +19,6 @@ export default Ember.Controller.extend({ }, addEndpoint() { - if (this.get('api.endpoints') == undefined) { - this.set('api.endpoints',[]); - }; this.get('api.endpoints').pushObject({}); }, diff --git a/assets/javascripts/discourse/models/custom-wizard-api.js.es6 b/assets/javascripts/discourse/models/custom-wizard-api.js.es6 index 6cfbae06..6817ae70 100644 --- a/assets/javascripts/discourse/models/custom-wizard-api.js.es6 +++ b/assets/javascripts/discourse/models/custom-wizard-api.js.es6 @@ -10,9 +10,9 @@ const CustomWizardApi = Discourse.Model.extend({ }); CustomWizardApi.reopenClass({ - create(params) { + create(params = {}) { const api = this._super.apply(this); - const authorization = params.authorization; + const authorization = params.authorization || {}; const endpoints = params.endpoints; api.setProperties({ diff --git a/assets/javascripts/discourse/routes/admin-wizards-api.js.es6 b/assets/javascripts/discourse/routes/admin-wizards-api.js.es6 index 34320924..dda7d416 100644 --- a/assets/javascripts/discourse/routes/admin-wizards-api.js.es6 +++ b/assets/javascripts/discourse/routes/admin-wizards-api.js.es6 @@ -3,7 +3,7 @@ import CustomWizardApi from '../models/custom-wizard-api'; export default Discourse.Route.extend({ model(params) { if (params.service === 'new') { - return {}; + return CustomWizardApi.create(); } else { return CustomWizardApi.find(params.service); }