plugin updates
This commit is contained in:
@@ -5,6 +5,7 @@ export const CoreMessages = {
|
||||
RedirectParentFrame: 'INTEGRATED_APP_EMBEDDER_REDIRECT_PARENT_FRAME',
|
||||
SendLocale: 'INTEGRATED_APP_EMBEDDER_SEND_LOCALE',
|
||||
SendDeviceId: 'INTEGRATED_APP_EMBEDDER_SEND_DEVICE_ID',
|
||||
SendIntegratedAppConfig: 'INTEGRATED_APP_EMBEDDER_CONFIG',
|
||||
} as const;
|
||||
|
||||
export type CoreMessageType = typeof CoreMessages[keyof typeof CoreMessages];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { MessageType, PluginMessages } from '../iframe/integratedMessages';
|
||||
import { MessageType, PluginMessages } from './integratedMessages';
|
||||
import {
|
||||
fetchDisableInternalTracking,
|
||||
trackConsent,
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
wpVersion,
|
||||
contentEmbed,
|
||||
requiresContentEmbedScope,
|
||||
refreshTokenError,
|
||||
decryptError,
|
||||
LeadinConfig,
|
||||
} from '../constants/leadinConfig';
|
||||
import { App, AppIframe } from './constants';
|
||||
@@ -55,9 +55,17 @@ type PartialLeadinConfig = Pick<
|
||||
| 'wpVersion'
|
||||
| 'contentEmbed'
|
||||
| 'requiresContentEmbedScope'
|
||||
| 'refreshTokenError'
|
||||
| 'decryptError'
|
||||
>;
|
||||
|
||||
type AppIntegrationConfig = Pick<LeadinConfig, 'adminUrl'>;
|
||||
|
||||
const getIntegrationConfig = (): AppIntegrationConfig => {
|
||||
return {
|
||||
adminUrl: leadinQueryParams.adminUrl,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* A modified version of the original leadinConfig that is passed to some integrated apps.
|
||||
*
|
||||
@@ -120,7 +128,7 @@ const getLeadinConfig = (): AppLeadinConfig => {
|
||||
wpVersion,
|
||||
contentEmbed,
|
||||
requiresContentEmbedScope,
|
||||
refreshTokenError,
|
||||
decryptError,
|
||||
...utm_query_params,
|
||||
};
|
||||
};
|
||||
@@ -135,15 +143,15 @@ const getAppOptions = (app: App, createRoute = false) => {
|
||||
let options;
|
||||
switch (app) {
|
||||
case App.Plugin:
|
||||
options = new PluginAppOptions().setLeadinConfig(getLeadinConfig());
|
||||
options = new PluginAppOptions();
|
||||
break;
|
||||
case App.PluginSettings:
|
||||
options = new PluginAppOptions()
|
||||
.setLeadinConfig(getLeadinConfig())
|
||||
.setPluginSettingsInit();
|
||||
options = new PluginAppOptions().setPluginSettingsInit();
|
||||
break;
|
||||
case App.Forms:
|
||||
options = new FormsAppOptions();
|
||||
options = new FormsAppOptions().setIntegratedAppConfig(
|
||||
getIntegrationConfig()
|
||||
);
|
||||
if (createRoute) {
|
||||
options = options.setCreateFormAppInit();
|
||||
}
|
||||
@@ -180,7 +188,8 @@ export default function useAppEmbedder(
|
||||
const options = getAppOptions(app, createRoute)
|
||||
.setLocale(locale)
|
||||
.setDeviceId(deviceId)
|
||||
.setRefreshToken(refreshToken);
|
||||
.setRefreshToken(refreshToken)
|
||||
.setLeadinConfig(getLeadinConfig());
|
||||
|
||||
const embedder = new IntegratedAppEmbedder(
|
||||
AppIframe[app],
|
||||
|
||||
Reference in New Issue
Block a user