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

Fixed active prices not read from settings

no refs

Previously, we were fetching product and prices in the constructor of the controller which did not guarantee settings were updated when picking active prices from the price list. This updates the setup to use `did-insert` modifier to correctly fetch and populate product/price data.
This commit is contained in:
Rishabh 2021-05-18 19:12:37 +05:30
parent 6b287a41c0
commit d746265a52
2 changed files with 14 additions and 8 deletions

View file

@ -37,12 +37,12 @@ export default class MembersAccessController extends Controller {
queryParams = ['showPortalSettings'];
constructor(...args) {
super(...args);
this.siteUrl = this.config.get('blogUrl');
this.fetchDefaultProduct.perform();
get allCurrencies() {
return getCurrencyOptions();
}
this.allCurrencies = getCurrencyOptions();
get siteUrl() {
return this.config.get('blogUrl');
}
get selectedCurrency() {
@ -58,6 +58,7 @@ export default class MembersAccessController extends Controller {
}
_validateSignupRedirect(url, type) {
const siteUrl = this.config.get('blogUrl');
let errMessage = `Please enter a valid URL`;
this.settings.get('errors').remove(type);
this.settings.get('hasValidated').removeObject(type);
@ -73,8 +74,8 @@ export default class MembersAccessController extends Controller {
return;
}
if (url.href.startsWith(this.siteUrl)) {
const path = url.href.replace(this.siteUrl, '');
if (url.href.startsWith(siteUrl)) {
const path = url.href.replace(siteUrl, '');
this.settings.set(type, path);
} else {
this.settings.set(type, url.href);
@ -185,6 +186,11 @@ export default class MembersAccessController extends Controller {
});
}
setup() {
this.fetchDefaultProduct.perform();
this.updatePortalPreview();
}
async saveProduct() {
if (this.product) {
const stripePrices = this.product.stripePrices || [];

View file

@ -1,4 +1,4 @@
<section class="gh-canvas gh-setting-members-canvas" {{did-insert this.updatePortalPreview}}>
<section class="gh-canvas gh-setting-members-canvas" {{did-insert this.setup}}>
<GhCanvasHeader class="gh-canvas-header gh-setting-members-header">
<h2 class="gh-canvas-title" data-test-screen-title>
<LinkTo @route="settings">Settings</LinkTo>