From 6a6f50cf1566f819ccb98244f6de4354f2c375e5 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Tue, 27 Apr 2021 18:03:13 +0100 Subject: [PATCH] Fixed rollback of selected plans when leaving portal settings no issue - the original `portalPlans` array was being modified by reference which was throwing off Ember Data's change tracking - switched to always creating a new plans array before any modifications take place --- ghost/admin/app/components/gh-launch-wizard/set-pricing.js | 5 +++-- ghost/admin/app/components/modal-portal-settings.js | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ghost/admin/app/components/gh-launch-wizard/set-pricing.js b/ghost/admin/app/components/gh-launch-wizard/set-pricing.js index b3e33e2843..338035ee41 100644 --- a/ghost/admin/app/components/gh-launch-wizard/set-pricing.js +++ b/ghost/admin/app/components/gh-launch-wizard/set-pricing.js @@ -172,13 +172,14 @@ export default class GhLaunchWizardSetPricingComponent extends Component { } updateAllowedPlan(plan, isChecked) { - const allowedPlans = this.settings.get('portalPlans') || []; + const portalPlans = this.settings.get('portalPlans') || []; + const allowedPlans = [...portalPlans]; if (!isChecked) { this.settings.set('portalPlans', allowedPlans.filter(p => p !== plan)); } else { allowedPlans.push(plan); - this.settings.set('portalPlans', [...allowedPlans]); + this.settings.set('portalPlans', allowedPlans); } this.updatePreviewUrl(); diff --git a/ghost/admin/app/components/modal-portal-settings.js b/ghost/admin/app/components/modal-portal-settings.js index fd511bb9ca..359c53591c 100644 --- a/ghost/admin/app/components/modal-portal-settings.js +++ b/ghost/admin/app/components/modal-portal-settings.js @@ -251,13 +251,14 @@ export default ModalComponent.extend({ }, updateAllowedPlan(plan, isChecked) { - const allowedPlans = this.settings.get('portalPlans') || []; + const portalPlans = this.settings.get('portalPlans') || []; + const allowedPlans = [...portalPlans]; if (!isChecked) { this.settings.set('portalPlans', allowedPlans.filter(p => p !== plan)); } else { allowedPlans.push(plan); - this.settings.set('portalPlans', [...allowedPlans]); + this.settings.set('portalPlans', allowedPlans); } },