Ghost/ghost/admin/app/components/modal-stripe-connect.js
Rishabh bc25dbdefa Fixed modal errors in stripe connect and member product
refs 909bd60db3

- The modal actions for glimmer modal components need to define `actions.confirm` separately and add confirmAction to handle both enter and manual confirmation
2021-06-18 16:24:18 +05:30

57 lines
1.6 KiB
JavaScript

import ModalBase from 'ghost-admin/components/modal-base';
import classic from 'ember-classic-decorator';
import {action} from '@ember/object';
import {inject as service} from '@ember/service';
// TODO: update modals to work fully with Glimmer components
@classic
export default class ModalStripeConnect extends ModalBase {
@service settings;
@action
setStripeConnectIntegrationTokenSetting(stripeConnectIntegrationToken) {
this.settings.set('stripeConnectIntegrationToken', stripeConnectIntegrationToken);
}
@action
reset() {
// stripeConnectIntegrationToken is not a persisted value so we don't want
// to keep it around across transitions
this.settings.set('stripeConnectIntegrationToken', undefined);
}
@action
close(event) {
event?.preventDefault?.();
this.closeModal();
}
@action
confirmAction() {
this.confirm();
this.close();
}
@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/, ''));
}
}
}
actions = {
confirm() {
if (this.settings.get('stripeConnectAccountId')) {
return this.confirmAction();
}
// noop - enter key shouldn't do anything
}
}
}