Wired up stripeEnabled to Koenig config (#20750)

ref PLG-109

- Added a boolean config property `stripeEnabled` to the configuration.
- This property is now passed down to the Koenig Editor to manage
features based on Stripe connectivity.
This commit is contained in:
Ronald Langeveld 2024-08-14 14:32:18 +07:00 committed by GitHub
parent 5ba74b0243
commit e920888832
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -441,6 +441,16 @@ export default class KoenigLexicalEditor extends Component {
}
};
const checkStripeEnabled = () => {
const hasDirectKeys = !!(this.settings.stripeSecretKey && this.settings.stripePublishableKey);
const hasConnectKeys = !!(this.settings.stripeConnectSecretKey && this.settings.stripeConnectPublishableKey);
if (this.config.stripeDirect) {
return hasDirectKeys;
}
return hasDirectKeys || hasConnectKeys;
};
const defaultCardConfig = {
unsplash: this.settings.unsplash ? unsplashConfig.defaultHeaders : null,
tenor: this.config.tenor?.googleApiKey ? this.config.tenor : null,
@ -461,7 +471,8 @@ export default class KoenigLexicalEditor extends Component {
searchLinks,
siteTitle: this.settings.title,
siteDescription: this.settings.description,
siteUrl: this.config.getSiteUrl('/')
siteUrl: this.config.getSiteUrl('/'),
stripeEnabled: checkStripeEnabled() // returns a boolean
};
const cardConfig = Object.assign({}, defaultCardConfig, props.cardConfig, {pinturaConfig: this.pinturaConfig});