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

Fixed portal preview not updating when connecting/disconnecting Stripe

no issue

- store current stripe connection status when opening the stripe connect modal and if it's different when the modal is closed force a save and refresh of the portal preview
This commit is contained in:
Kevin Ansfield 2021-05-20 14:31:51 +01:00
parent 430ba2329d
commit 03844d5b97
2 changed files with 16 additions and 9 deletions

View file

@ -36,6 +36,7 @@ export default class MembersAccessController extends Controller {
@tracked stripePlanError = ''; @tracked stripePlanError = '';
@tracked portalPreviewUrl = ''; @tracked portalPreviewUrl = '';
@tracked portalPreviewGuid = Date.now().valueOf();
queryParams = ['showPortalSettings']; queryParams = ['showPortalSettings'];
@ -147,11 +148,16 @@ export default class MembersAccessController extends Controller {
@action @action
openStripeConnect() { openStripeConnect() {
this.stripeEnabledOnOpen = this.membersUtils.isStripeEnabled;
this.showStripeConnect = true; this.showStripeConnect = true;
} }
@action @action
closeStripeConnect() { async closeStripeConnect() {
if (this.stripeEnabledOnOpen !== this.membersUtils.isStripeEnabled) {
await this.saveSettingsTask.perform();
this.portalPreviewGuid = Date.now().valueOf();
}
this.showStripeConnect = false; this.showStripeConnect = false;
} }

View file

@ -57,6 +57,7 @@
{{else}} {{else}}
<GhSiteIframe <GhSiteIframe
@src={{this.portalPreviewUrl}} @src={{this.portalPreviewUrl}}
@guid={{this.portalPreviewGuid}}
@invisibleUntilLoaded={{true}} @invisibleUntilLoaded={{true}}
@onLoad={{this.portalPreviewLoaded}} @onLoad={{this.portalPreviewLoaded}}
@onDestroyed={{this.portalPreviewDestroyed}} /> @onDestroyed={{this.portalPreviewDestroyed}} />
@ -92,8 +93,8 @@
@id="freeWelcomePage" @id="freeWelcomePage"
@value={{readonly this.settings.membersFreeSignupRedirect}} @value={{readonly this.settings.membersFreeSignupRedirect}}
@baseUrl={{readonly this.siteUrl}} @baseUrl={{readonly this.siteUrl}}
@setResult={{action "setFreeSignupRedirect"}} @setResult={{this.setFreeSignupRedirect}}
@validateUrl={{action "validateFreeSignupRedirect"}} @validateUrl={{this.validateFreeSignupRedirect}}
@placeholder={{readonly this.siteUrl}} @placeholder={{readonly this.siteUrl}}
/> />
<GhErrorMessage <GhErrorMessage
@ -116,9 +117,9 @@
</div> </div>
{{#if this.settings.stripeConnectAccountId}} {{#if this.settings.stripeConnectAccountId}}
<button type="button" class="gh-btn" {{action (toggle "paidOpen" this)}} data-test-toggle-pub-info><span>{{if this.paidOpen "Close" "Expand"}}</span></button> <button type="button" class="gh-btn" {{on "click" (toggle "paidOpen" this)}} data-test-toggle-pub-info><span>{{if this.paidOpen "Close" "Expand"}}</span></button>
{{else}} {{else}}
<button type="button" class="stripe-connect {{if this.isConnectDisallowed "disabled"}}" {{action (toggle "showStripeConnect" this)}}> <button type="button" class="stripe-connect {{if this.isConnectDisallowed "disabled"}}" {{on "click" this.openStripeConnect}}>
<span>Connect with Stripe</span> <span>Connect with Stripe</span>
</button> </button>
{{/if}} {{/if}}
@ -178,7 +179,7 @@
@value={{readonly this.stripeYearlyAmount}} @value={{readonly this.stripeYearlyAmount}}
@type="number" @type="number"
@input={{action (mut this.stripeYearlyAmount) value="target.value"}} @input={{action (mut this.stripeYearlyAmount) value="target.value"}}
@focus-out={{action "validateStripePlans"}} @focus-out={{this.validateStripePlans}}
@placeholder='' @placeholder=''
data-test-title-input={{true}} data-test-title-input={{true}}
/> />
@ -195,8 +196,8 @@
<GhUrlInput <GhUrlInput
@value={{readonly this.settings.membersPaidSignupRedirect}} @value={{readonly this.settings.membersPaidSignupRedirect}}
@baseUrl={{readonly this.siteUrl}} @baseUrl={{readonly this.siteUrl}}
@setResult={{action "setPaidSignupRedirect"}} @setResult={{this.setPaidSignupRedirect}}
@validateUrl={{action "validatePaidSignupRedirect"}} @validateUrl={{this.validatePaidSignupRedirect}}
@placeholder={{readonly this.siteUrl}} @placeholder={{readonly this.siteUrl}}
/> />
<GhErrorMessage <GhErrorMessage
@ -245,7 +246,7 @@
{{#if this.showStripeConnect}} {{#if this.showStripeConnect}}
<GhFullscreenModal <GhFullscreenModal
@modal="stripe-connect" @modal="stripe-connect"
@close={{action "closeStripeConnect"}} @close={{this.closeStripeConnect}}
@modifier="action wide stripe-connect {{if this.settings.stripeConnectAccountId "stripe-connected" ""}}" /> @modifier="action wide stripe-connect {{if this.settings.stripeConnectAccountId "stripe-connected" ""}}" />
{{/if}} {{/if}}
</section> </section>