Skip to content

Commit

Permalink
Dev/john/salesforce update (#635)
Browse files Browse the repository at this point in the history
* Update salesforce integration to support concept of apps with updatable options
  • Loading branch information
johnman authored Dec 2, 2023
1 parent db92141 commit 8b767a8
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -355,7 +355,7 @@ export class SalesforceIntegration {
await fin.System.openUrlWithBrowser(u);
}
} else {
await this.openSalesforceView(data);
await this.openSalesforceContent(data);
}
return true;
}
Expand Down Expand Up @@ -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<void> {
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<void> {
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);
}
}

/**
Expand Down
38 changes: 38 additions & 0 deletions how-to/integrate-with-salesforce/client/src/shapes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -378,6 +383,15 @@ export interface IntegrationHelpers {
* @returns The interop client.
*/
getInteropClient(): Promise<OpenFin.InteropClient | undefined>;

/**
* 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<void>;
}

/**
Expand Down Expand Up @@ -491,3 +505,27 @@ export interface ThemeClient {
*/
getPalette(): Promise<CustomPaletteSet>;
}

/**
* 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<Pick<OpenFin.ViewOptions, "url" | "interop" | "customData">>;
}
2 changes: 1 addition & 1 deletion how-to/integrate-with-salesforce/public/manifest.fin.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"shortcut": {
"company": "OpenFin",
"description": "A way of showing examples of what OpenFin can do.",
"description": "A way of showing examples of what OpenFin can do in relation to Salesforce.",
"icon": "http://localhost:8080/favicon.ico",
"name": "Integrate With Salesforce - v16.0.0",
"target": ["desktop", "start-menu"]
Expand Down

0 comments on commit 8b767a8

Please sign in to comment.