Options
All
  • Public
  • Public/Protected
  • All
Menu

@openfin/workspace-platform

Index

Enumerations

Interfaces

Type Aliases

Functions

Type Aliases

AnalyticsEvent: { action: string; data?: any; entityId?: OpenFin.Identity; source: AnalyticsSource; type: string; value?: string }

Event for analytics

Type declaration

  • action: string
  • Optional data?: any
  • Optional entityId?: OpenFin.Identity
  • source: AnalyticsSource
  • type: string
  • Optional value?: string
ApplyWorkspacePayload: Workspace & { options?: ApplyWorkspaceOptions }

Payload received by applyWorkspace platform provider method

AttachedPage: Page & AttachedPageMetadata
BrowserOverrideCallback: WorkspacePlatformOverrideCallback
deprecated
BrowserSnapshotWindow: OpenFin.WindowCreationOptions & BrowserCreateWindowRequest

A window that is part of a browser snapshot.

The payload received by a Custom Action. The callerType property can be used to determine what data is available in the payload and cast accordingly. When callerType == CustomActionCallerType.API, the payload is defined by the code directly invoking the action.

ExtendedPanelConfig: PanelConfig & { viewOptions: PanelConfig["viewOptions"] & OpenFin.Identity }
LockUnlockPageConfig: { disabled?: boolean; type: LockUnlockPage }

Configuration Object for the page lock/unlock button within the browser toolbar

example
const lockUnlockPageConfig: LockUnlockPageConfig = {
type: BrowserButtonType.LockUnlockPage,
disabled: false
};

Type declaration

OpenGlobalContextMenuPayload: OpenGlobalContextMenuRequest & { identity: OpenFin.Identity; template: GlobalContextMenuItemTemplate[]; callback: any }

Payload received by the openGlobalContextMenu provider override.

OpenPageTabContextMenuPayload: OpenPageTabContextMenuRequest & { identity: OpenFin.Identity; template: PageTabContextMenuItemTemplate[]; callback: any }

Payload received by the openViewTabContextMenu provider override.

OpenSaveButtonContextMenuPayload: OpenSaveButtonContextMenuRequest & { identity: OpenFin.Identity; template: SaveButtonContextMenuItemTemplate[]; callback: any }

Payload received by the openSaveButtonContextMenu provider override.

OpenSaveMenuRequest: { id: string; menuType: SaveModalType.SAVE_PAGE | SaveModalType.SAVE_PAGE_AS | SaveModalType.RENAME_PAGE } | { id?: never; menuType: SaveModalType.SAVE_WORKSPACE | SaveModalType.SAVE_WORKSPACE_AS | SaveModalType.RENAME_WORKSPACE }

Request to create a save modal.

OpenViewTabContextMenuPayload: OpenViewTabContextMenuRequest & { identity: OpenFin.Identity; callback: any }

Payload received by the openViewTabContextMenu provider override.

PageLayout: OpenFin.LayoutOptions & { layoutDetails?: PageLayoutDetails }
PageWithUpdatableRuntimeAttribs: Page & Pick<AttachedPage, "hasUnsavedChanges">
PanelConfig: (PanelConfigHorizontal | PanelConfigVertical) & { viewOptions: Omit<OpenFin.PlatformViewCreationOptions, "bounds" | "target"> }

Configuration of an individual fixed view panel

Example:

{
position: PanelPosition.Left,
width: '140px',
viewOptions: { url: 'https://example.com'}
}
ShowHideTabsConfig: { disabled?: boolean; type: ShowHideTabs }

Configuration Object for the show/hide tabs button within the browser toolbar

example
const showHideTabsConfig: ShowHideTabsConfig = {
type: BrowserButtonType.ShowHideTabs,
disabled: false
};

Type declaration

Buttons on the left of WindowStateButtonOptions

Buttons to the top far right of Browser

WorkspacePlatformOverrideCallback: OpenFin.OverrideCallback<WorkspacePlatformProvider>

Extend or replace default functionality in order to customize behavior of a Workspace Platform Provider.

To implement your own handlers for Workspace Platform behavior, extend the provided class and override any methods you'd like to alter.

import * as WorkspacePlatform from '@openfin/workspace-platform';
import { UpdateSavedPageRequest } from '@client-platform/shapes';

const overrideCallback: WorkspacePlatform.WorkspacePlatformOverrideCallback = async (
WorkspacePlatformProvider
) => {
class Override extends WorkspacePlatformProvider {
// Override the default behavior of updateSavedPage
updateSavedPage = async (req: UpdateSavedPageRequest): Promise<void> => {
console.log(`saving page ${req.page.pageId}`);
// calling custom function to the save page here
};

// add a custom menu item in Global Context Menu
openGlobalContextMenu(req: WorkspacePlatform.OpenGlobalContextMenuPayload, callerIdentity: any) {
return super.openGlobalContextMenu(
{
...req,
template: [
...req.template,
{
label: 'Sample custom global option',
data: {
type: GlobalContextMenuOptionType.Custom,
action: {
// This action needs to be registered in customActions property in the call WorkspacePlatform.init
id: 'sample-custom-global-menu-action'
}
}
}
]
},
callerIdentity
);
}

// add a custom menu item in View Tab Context Menu
openViewTabContextMenu = async (payload: OpenViewTabContextMenuPayload, callerIdentity) => {
const viewsInfo = await Promise.all(payload.selectedViews.map(async (v) => fin.View.wrapSync(v).getInfo()));

const enableBack = viewsInfo.every((viewInfo) => viewInfo.canNavigateBack === true);
const enableForward = viewsInfo.every((viewInfo) => viewInfo.canNavigateForward === true);

return super.openViewTabContextMenu({
...payload,
template: [
{
label: 'Sample View Tab Context Menu',
data: {
type: ViewTabMenuOptionType.Custom,
action: {
// This action needs to be registered in customActions property in the call WorkspacePlatform.init
id: 'sample-viewtab-action',
customData: 'Custom View Tab Action'
}
}
},
{
type: 'normal',
label: 'Back',
data: {
type: ViewTabMenuOptionType.Back
},
enabled: enableBack
},
{
type: 'normal',
label: 'Forward',
data: {
type: ViewTabMenuOptionType.Forward
},
enabled: enableForward
},
...payload.template
]
}, callerIdentity);
};

// add a custom menu item in Save Context Menu
openSaveButtonContextMenu = (req: WorkspacePlatform.OpenSaveButtonContextMenuPayload, callerIdentity: OpenFin.Identity) => {
return super.openSaveButtonContextMenu(
{
...req,
template: [
...req.template,
{
label: 'Save custom option',
data: {
type: SaveButtonContextMenuOptionType.Custom,
action: {
id: 'sample-custom-action-name',
customData: {
someProp: 'Save Button task'
}
}
}
}
]
},
callerIdentity
);
}
}
return new Override();
};

await WorkspacePlatform.init({
browser: {
title: "My Workspace Platform"
}
overrideCallback,
customActions: {
'sample-custom-global-menu-action': (payload: CustomActionPayload) => {
alert('This custom action works ' + JSON.stringify(payload));
return 'someresponse';
},
'sample-viewtab-action': (payload: ViewTabCustomActionPayload) => {
alert('This custom action works ' + JSON.stringify(payload));
return 'someresponse';
}
}
});

Functions

  • Synchronously returns a Platform object that represents the current platform.

    import * as WorkspacePlatform from '@openfin/workspace-platform';
    // get current Workspace Platform
    const workspacePlatform = WorkspacePlatform.getCurrentSync();
    // do something with workspacePlatform. e.g. get snapshot of browser window with pages
    const snapshot = await workspacePlatform.getSnapshot();

    Returns WorkspacePlatformModule

  • Initilaize a Workspace Platform.

    import * as WorkspacePlatform from '@openfin/workspace-platform';

    const customThemes: WorkspacePlatform.CustomThemes = [{
    label: "OpenFin's Custom Theme",
    palette: {
    // Required color options
    brandPrimary: '#F51F63',
    brandSecondary: '#1FF58A',
    backgroundPrimary: '#F8E71C', // hex, rgb/rgba, hsl/hsla only - no string colors: 'red'
    }
    }];

    const overrideCallback: WorkspacePlatform.WorkspacePlatformOverrideCallback = async (
    WorkspacePlatformProvider
    ) => {
    class Override extends WorkspacePlatformProvider {
    async quit(payload, callerIdentity) {
    return super.quit(payload, callerIdentity);
    }
    }
    return new Override();
    };


    await WorkspacePlatform.init({
    browser: { overrideCallback },
    theme: customThemes
    });

    Parameters

    Returns Promise<void>

  • Synchronously returns a Platform object that represents an existing platform.

    import * as WorkspacePlatform from '@openfin/workspace-platform';

    // declare platform identity
    const myPlatformIdentity: OpenFin.ApplicationIdentity = {
    uuid: 'testPlatform',
    name: 'Test Platform'
    };

    // get the platform representing myPlatformIdentity
    const platform = WorkspacePlatform.wrapSync(myPlatformIdentity);

    // do something with platform. e.g. create a window
    platform.createWindow({
    layout: {
    content: [
    {
    type: 'component',
    componentName: 'Example View',
    componentState: {
    name: 'example_view_1'
    url: 'https://cdn.openfin.co/docs/javascript/canary/Platform.html'
    }
    }
    ]
    }
    });

    Parameters

    • identity: ApplicationIdentity

    Returns WorkspacePlatformModule

Generated using TypeDoc