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

Fixed stripe connect modal not adjusting correctly to connected state

no issue

- updated `<GhFullscreenModal>` to pass `@modifier` and `@updateModifier` through to child modal components so they can adjust their own classes
- added an `updateSuccessModifier()` action to `<ModalStripeConnect>` to set the modal size when first opening and on `@onConnected/Disconnected` actions passed to the `<GhMembersPaymentsSetting>` component
- updated `<GhMembersPaymentsSetting>` to call passed in `onConnected/Disconnected` actions when connection or disconnection is finalised
This commit is contained in:
Kevin Ansfield 2021-05-20 17:20:49 +01:00
parent bfd022e760
commit 3ab0a52f62
5 changed files with 26 additions and 2 deletions

View file

@ -9,6 +9,8 @@
@model={{this.model}} @model={{this.model}}
@confirm={{action "confirm"}} @confirm={{action "confirm"}}
@closeModal={{action "close"}} @closeModal={{action "close"}}
@modifier={{this.modifier}}
@updateModifier={{action (mut this.modifier)}}
/> />
{{/let}} {{/let}}
{{/if}} {{/if}}

View file

@ -226,6 +226,8 @@ export default Component.extend({
yield this.ajax.delete(url); yield this.ajax.delete(url);
yield this.settings.reload(); yield this.settings.reload();
this.onDisconnected?.();
}), }),
calculateDiscount(monthly, yearly) { calculateDiscount(monthly, yearly) {
@ -262,8 +264,10 @@ export default Component.extend({
if (this.get('settings.stripeConnectIntegrationToken')) { if (this.get('settings.stripeConnectIntegrationToken')) {
try { try {
let response = yield this.settings.save(); let response = yield this.settings.save();
const products = yield this.store.query('product', {include: 'stripe_prices'}); const products = yield this.store.query('product', {include: 'stripe_prices'});
this.product = products.firstObject; this.product = products.firstObject;
if (this.product) { if (this.product) {
const stripePrices = this.product.stripePrices || []; const stripePrices = this.product.stripePrices || [];
const yearlyDiscount = this.calculateDiscount(5, 50); const yearlyDiscount = this.calculateDiscount(5, 50);
@ -297,8 +301,11 @@ export default Component.extend({
this.settings.set('membersYearlyPriceId', yearlyPrice.id); this.settings.set('membersYearlyPriceId', yearlyPrice.id);
response = yield this.settings.save(); response = yield this.settings.save();
} }
this.set('membersStripeOpen', false); this.set('membersStripeOpen', false);
this.set('stripeConnectSuccess', true); this.set('stripeConnectSuccess', true);
this.onConnected?.();
return response; return response;
} catch (error) { } catch (error) {
if (error.payload && error.payload.errors) { if (error.payload && error.payload.errors) {

View file

@ -8,9 +8,11 @@
</button> </button>
<form> <form>
<div class="modal-body"> <div class="modal-body" {{did-insert this.updateSuccessModifier}}>
<GhMembersPaymentsSetting <GhMembersPaymentsSetting
@setStripeConnectIntegrationTokenSetting={{this.setStripeConnectIntegrationTokenSetting}} @setStripeConnectIntegrationTokenSetting={{this.setStripeConnectIntegrationTokenSetting}}
@onConnected={{this.updateSuccessModifier}}
@onDisconnected={{this.updateSuccessModifier}}
/> />
</div> </div>
</form> </form>

View file

@ -12,4 +12,17 @@ export default class ModalStripeConnect extends ModalBase {
setStripeConnectIntegrationTokenSetting(stripeConnectIntegrationToken) { setStripeConnectIntegrationTokenSetting(stripeConnectIntegrationToken) {
this.settings.set('stripeConnectIntegrationToken', stripeConnectIntegrationToken); this.settings.set('stripeConnectIntegrationToken', stripeConnectIntegrationToken);
} }
@action
updateSuccessModifier() {
if (this.settings.get('stripeConnectAccountId')) {
if (this.modifier?.indexOf('stripe-connected') === -1) {
this.updateModifier(`${this.modifier} stripe-connected`);
}
} else {
if (this.modifier?.indexOf('stripe-connected') !== -1) {
this.updateModifier(this.modifier.replace(/\s?stripe-connected/, ''));
}
}
}
} }

View file

@ -247,6 +247,6 @@
<GhFullscreenModal <GhFullscreenModal
@modal="stripe-connect" @modal="stripe-connect"
@close={{this.closeStripeConnect}} @close={{this.closeStripeConnect}}
@modifier="action wide stripe-connect {{if this.settings.stripeConnectAccountId "stripe-connected" ""}}" /> @modifier="action wide stripe-connect" />
{{/if}} {{/if}}
</section> </section>