0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

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
This commit is contained in:
Kevin Ansfield 2021-04-27 18:03:13 +01:00
parent 49b83add43
commit 6a6f50cf15
2 changed files with 6 additions and 4 deletions

View file

@ -172,13 +172,14 @@ export default class GhLaunchWizardSetPricingComponent extends Component {
} }
updateAllowedPlan(plan, isChecked) { updateAllowedPlan(plan, isChecked) {
const allowedPlans = this.settings.get('portalPlans') || []; const portalPlans = this.settings.get('portalPlans') || [];
const allowedPlans = [...portalPlans];
if (!isChecked) { if (!isChecked) {
this.settings.set('portalPlans', allowedPlans.filter(p => p !== plan)); this.settings.set('portalPlans', allowedPlans.filter(p => p !== plan));
} else { } else {
allowedPlans.push(plan); allowedPlans.push(plan);
this.settings.set('portalPlans', [...allowedPlans]); this.settings.set('portalPlans', allowedPlans);
} }
this.updatePreviewUrl(); this.updatePreviewUrl();

View file

@ -251,13 +251,14 @@ export default ModalComponent.extend({
}, },
updateAllowedPlan(plan, isChecked) { updateAllowedPlan(plan, isChecked) {
const allowedPlans = this.settings.get('portalPlans') || []; const portalPlans = this.settings.get('portalPlans') || [];
const allowedPlans = [...portalPlans];
if (!isChecked) { if (!isChecked) {
this.settings.set('portalPlans', allowedPlans.filter(p => p !== plan)); this.settings.set('portalPlans', allowedPlans.filter(p => p !== plan));
} else { } else {
allowedPlans.push(plan); allowedPlans.push(plan);
this.settings.set('portalPlans', [...allowedPlans]); this.settings.set('portalPlans', allowedPlans);
} }
}, },