From 8f48bc31ab871e018c7892d2959197346d05dbbf Mon Sep 17 00:00:00 2001 From: John Date: Fri, 1 Dec 2023 12:12:34 +0000 Subject: [PATCH] Update salesforce integration to support concept of apps with updatable options --- .../client/src/salesforce-integration.ts | 45 +++++++++++++------ .../client/src/shapes.ts | 38 ++++++++++++++++ 2 files changed, 69 insertions(+), 14 deletions(-) diff --git a/how-to/integrate-with-salesforce/client/src/salesforce-integration.ts b/how-to/integrate-with-salesforce/client/src/salesforce-integration.ts index 04972f81b5..e1735b6b70 100644 --- a/how-to/integrate-with-salesforce/client/src/salesforce-integration.ts +++ b/how-to/integrate-with-salesforce/client/src/salesforce-integration.ts @@ -308,7 +308,7 @@ export class SalesforceIntegration { const action = data.mapping?.actions?.[actionIdx]; if (!action?.url && !action?.intent && !action?.view) { - await this.openSalesforceView(data); + await this.openSalesforceContent(data); } else if (action.url) { await fin.System.openUrlWithBrowser( this.substituteProperties(data.mapping, data.obj, action.url, true) @@ -355,7 +355,7 @@ export class SalesforceIntegration { await fin.System.openUrlWithBrowser(u); } } else { - await this.openSalesforceView(data); + await this.openSalesforceContent(data); } return true; } @@ -750,21 +750,38 @@ export class SalesforceIntegration { } /** - * Open a Salesforce view. + * Open salesforce content in a view or as an app. * @param data The data to use for opening. */ - private async openSalesforceView(data: SalesforceResultData): Promise { - const preload = this._settings?.preload; - const viewOptions: OpenFin.PlatformViewCreationOptions = { - url: data.url, - fdc3InteropApi: "1.2", - interop: { - currentContextGroup: "green" - }, - customData: { buttonLabel: "Process Participant" }, - preloadScripts: [{ url: preload ?? "" }] + private async openSalesforceContent(data: SalesforceResultData): Promise { + const interop: OpenFin.InteropConfig = { + currentContextGroup: "green" }; - await this._integrationHelpers?.launchView(viewOptions); + const customData = { buttonLabel: "Process Participant" }; + const url = data.url; + + if (this._settings?.appId && this._integrationHelpers?.launchApp) { + await this._integrationHelpers?.launchApp(this._settings.appId, { + options: { + type: "view", + view: { + url, + interop, + customData + } + } + }); + } else { + const preload = this._settings?.preload; + const viewOptions: OpenFin.PlatformViewCreationOptions = { + url, + fdc3InteropApi: "1.2", + interop, + customData, + preloadScripts: [{ url: preload ?? "" }] + }; + await this._integrationHelpers?.launchView(viewOptions); + } } /** diff --git a/how-to/integrate-with-salesforce/client/src/shapes.ts b/how-to/integrate-with-salesforce/client/src/shapes.ts index c2f38fcbd2..4f0b199542 100644 --- a/how-to/integrate-with-salesforce/client/src/shapes.ts +++ b/how-to/integrate-with-salesforce/client/src/shapes.ts @@ -305,6 +305,11 @@ export interface SalesforceSettings { */ preload: string; + /** + * App Id. Should this integration launch an app instead of a view. + */ + appId?: string; + /** * Map the data from SF to templates, if you just include the type field the default display will be used. */ @@ -378,6 +383,15 @@ export interface IntegrationHelpers { * @returns The interop client. */ getInteropClient(): Promise; + + /** + * If available, this function lets you request the launch of an application that is available to this platform and + * the current user. + * @param appId The id of the application that is registered against the currently running platform + * @param launchPreference If the app supports launch preferences then these can be passed. + * @returns Nothing. + */ + launchApp?(appId: string, launchPreference?: UpdatableLaunchPreference): Promise; } /** @@ -491,3 +505,27 @@ export interface ThemeClient { */ getPalette(): Promise; } + +/** + * Are there any preferences you would like to apply when launching this application? + */ +export interface UpdatableLaunchPreference { + /** + * Are there any app type specific options you would like to apply? + */ + options?: ViewLaunchOptions; +} + +/** + * Additional options that apply to a view + */ +export interface ViewLaunchOptions { + /** + * View options type + */ + type: "view"; + /** + * The option to override a few settings that are specific to views. + */ + view?: Partial>; +}