@openfin/workspace-platform 7.0.0 → 7.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  /// <reference types="openfin-adapter/fin" />
2
2
  import type { AttachedPage, Page, PageWithUpdatableRuntimeAttribs } from '../../../../common/src/api/pages/shapes';
3
3
  import { OpenPageTabContextMenuRequest } from '../../../../client-api-platform/src/index';
4
- import { OpenGlobalContextMenuRequest, OpenSaveMenuRequest, OpenViewTabContextMenuRequest, ToolbarOptions, WindowStateButtonOptions } from '../../../../client-api-platform/src/shapes';
4
+ import { OpenGlobalContextMenuRequest, OpenSaveButtonContextMenuRequest, OpenSaveMenuRequest, OpenViewTabContextMenuRequest, ToolbarOptions, WindowStateButtonOptions } from '../../../../client-api-platform/src/shapes';
5
5
  export declare const getBrowserModule: (identity: OpenFin.Identity) => {
6
6
  identity: OpenFin.Identity;
7
7
  openfinWindow: import("openfin-adapter").Window;
@@ -18,4 +18,5 @@ export declare const getBrowserModule: (identity: OpenFin.Identity) => {
18
18
  _openViewTabContextMenu: (req: OpenViewTabContextMenuRequest) => Promise<any>;
19
19
  _openPageTabContextMenu: (req: OpenPageTabContextMenuRequest) => Promise<any>;
20
20
  _openSaveModal: (req: OpenSaveMenuRequest) => Promise<any>;
21
+ _openSaveButtonContextMenu: (req: OpenSaveButtonContextMenuRequest) => Promise<any>;
21
22
  };
@@ -18,6 +18,7 @@ export declare const getBrowserApi: (identity: OpenFin.ApplicationIdentity) => {
18
18
  _openViewTabContextMenu: (req: import("../../shapes").OpenViewTabContextMenuRequest) => Promise<any>;
19
19
  _openPageTabContextMenu: (req: import("../../shapes").OpenPageTabContextMenuRequest) => Promise<any>;
20
20
  _openSaveModal: (req: import("../../shapes").OpenSaveMenuRequest) => Promise<any>;
21
+ _openSaveButtonContextMenu: (req: import("../../shapes").OpenSaveButtonContextMenuRequest) => Promise<any>;
21
22
  };
22
23
  createWindow: (options: BrowserCreateWindowRequest) => Promise<BrowserWindowModule>;
23
24
  getAllAttachedPages: () => Promise<AttachedPage[]>;
@@ -0,0 +1,3 @@
1
+ import { OpenSaveButtonContextMenuPayload } from '../../../../client-api-platform/src/index';
2
+ import { SaveButtonContextMenuItemData } from '../../../../client-api-platform/src/shapes';
3
+ export declare const saveButtonContextMenuItemHandler: (data: SaveButtonContextMenuItemData, payload: OpenSaveButtonContextMenuPayload) => Promise<void>;
@@ -1,13 +1,16 @@
1
1
  import { NamedIdentity } from 'openfin-adapter/src/identity';
2
- import { OpenPageTabContextMenuPayload } from '../../../../client-api-platform/src/index';
3
- import { OpenGlobalContextMenuPayload, OpenGlobalContextMenuRequest, OpenPageTabContextMenuRequest, OpenViewTabContextMenuPayload, OpenViewTabContextMenuRequest } from '../../../../client-api-platform/src/shapes';
2
+ import { OpenPageTabContextMenuPayload, OpenSaveButtonContextMenuPayload } from '../../../../client-api-platform/src/index';
3
+ import { OpenGlobalContextMenuPayload, OpenGlobalContextMenuRequest, OpenPageTabContextMenuRequest, OpenSaveButtonContextMenuRequest, OpenViewTabContextMenuPayload, OpenViewTabContextMenuRequest } from '../../../../client-api-platform/src/shapes';
4
4
  export declare function openGlobalContextMenuInternal(payload: OpenGlobalContextMenuRequest & {
5
5
  identity: NamedIdentity;
6
6
  }, callerIdentity: any): Promise<void>;
7
- export declare const openCommonContextMenu: (payload: OpenGlobalContextMenuPayload | OpenViewTabContextMenuPayload | OpenPageTabContextMenuPayload, callerIdentity: any) => Promise<void>;
7
+ export declare const openCommonContextMenu: (payload: OpenGlobalContextMenuPayload | OpenViewTabContextMenuPayload | OpenPageTabContextMenuPayload | OpenSaveButtonContextMenuPayload, callerIdentity: any) => Promise<void>;
8
8
  export declare function openViewTabContextMenuInternal(payload: OpenViewTabContextMenuRequest & {
9
9
  identity: NamedIdentity;
10
10
  }, callerIdentity: any): Promise<void>;
11
11
  export declare function openPageTabContextMenuInternal(payload: OpenPageTabContextMenuRequest & {
12
12
  identity: NamedIdentity;
13
13
  }, callerIdentity: any): Promise<void>;
14
+ export declare function openSaveButtonContextMenuInternal(payload: OpenSaveButtonContextMenuRequest & {
15
+ identity: NamedIdentity;
16
+ }, callerIdentity: any): Promise<void>;
@@ -36,6 +36,7 @@ export declare enum ChannelAction {
36
36
  OpenGlobalContextMenuInternal = "openGlobalContextMenuInternal",
37
37
  OpenViewTabContextMenuInternal = "openViewTabContextMenuInternal",
38
38
  OpenPageTabContextMenuInternal = "openPageTabContextMenuInternal",
39
+ OpenSaveButtonContextMenuInternal = "openSaveButtonContextMenuInternal",
39
40
  InvokeCustomActionInternal = "invokeCustomActionInternal",
40
41
  GetSavedWorkspace = "getSavedWorkspace",
41
42
  CreateSavedWorkspace = "createSavedWorkspace",
@@ -44,8 +45,8 @@ export declare enum ChannelAction {
44
45
  GetSavedWorkspaces = "getSavedWorkspaces",
45
46
  SaveWorkspace = "saveWorkspace",
46
47
  GetCurrentWorkspace = "getCurrentWorkspace",
47
- SetCurrentWorkspace = "setCurrentWorkspace",
48
- GetActiveWorkspace = "getActiveWorkspace"
48
+ ApplyWorkspace = "applyWorkspace",
49
+ SetActiveWorkspace = "setActiveWorkspace"
49
50
  }
50
51
  /**
51
52
  * Get a channel client for a specific Workspace platform.
@@ -1,18 +1,22 @@
1
1
  import type { CreateSavedWorkspaceRequest, Workspace } from '../../../../client-api-platform/src/shapes';
2
+ /**
3
+ * Apply the given workspace and set it as active.
4
+ */
5
+ export declare function applyWorkspace(workspace: Workspace): Promise<void>;
2
6
  /**
3
7
  * Set the current active workspace.
4
8
  */
5
- export declare function setCurrentWorkspace(workspace: Workspace): Promise<void>;
9
+ export declare function setActiveWorkspace(workspace: Workspace): void;
6
10
  /**
7
- * Get a workspace data structure that represents the users current desktop.
11
+ * Get the initial workspace data structure that represents the an untitled empty workspace.
8
12
  * @returns the current active workspace.
9
13
  */
10
- export declare function getCurrentWorkspace(): Promise<any>;
14
+ export declare function getInitialWorkspace(): Promise<Workspace>;
11
15
  /**
12
- * Get the active workspace.
16
+ * Get a workspace data structure that represents the users current desktop.
13
17
  * @returns the current active workspace.
14
18
  */
15
- export declare function getActiveWorkspace(): Workspace | undefined;
19
+ export declare function getCurrentWorkspace(): Promise<Workspace>;
16
20
  export declare const createWorkspaceInStorage: (req: CreateSavedWorkspaceRequest) => Promise<any>;
17
21
  export declare const getWorkspacesInStorage: () => Promise<Workspace[]>;
18
22
  export declare const getWorkspaceInStorage: (id: string) => Promise<Workspace>;
@@ -53,9 +53,13 @@ export interface ContextMenuItemData {
53
53
  export declare enum GlobalContextMenuOptionType {
54
54
  NewWindow = "NewWindow",
55
55
  NewPage = "NewPage",
56
+ SaveWorkspace = "SaveWorkspace",
56
57
  SavePage = "SavePage",
57
58
  SavePageAs = "SavePageAs",
58
59
  CloseWindow = "CloseWindow",
60
+ SaveWorkspaceAs = "SaveWorkspaceAs",
61
+ RenameWorkspace = "RenameWorkspace",
62
+ SwitchWorkspace = "SwitchWorkspace",
59
63
  DeleteWorkspace = "DeleteWorkspace",
60
64
  OpenStorefront = "OpenStorefront",
61
65
  Quit = "Quit",
@@ -208,7 +212,7 @@ export declare enum BrowserButtonType {
208
212
  ShowHideTabs = "ShowHideTabs",
209
213
  ColorLinking = "ColorLinking",
210
214
  PresetLayouts = "PresetLayouts",
211
- SavePage = "SavePage",
215
+ SaveMenu = "SaveMenu",
212
216
  Minimise = "Minimise",
213
217
  Maximise = "Maximise",
214
218
  Close = "Close",
@@ -275,6 +279,59 @@ export declare type WindowStateButton = CustomBrowserButtonConfig | PreDefinedBu
275
279
  export interface WindowStateButtonOptions {
276
280
  buttons: WindowStateButton[];
277
281
  }
282
+ /**Types of context menu options for Save button, including pre-defined ones.
283
+ * User-defined context menu items should use the value `Custom` */
284
+ export declare enum SaveButtonContextMenuOptionType {
285
+ SavePage = "SavePage",
286
+ SaveWorkspace = "SaveWorkspace",
287
+ Custom = "Custom"
288
+ }
289
+ /**Shape of the data property of a save button context menu template item */
290
+ export interface SaveButtonContextMenuItemData extends ContextMenuItemData {
291
+ type: SaveButtonContextMenuOptionType;
292
+ }
293
+ /**Configuration of an option in the save button context menu */
294
+ export interface SaveButtonContextMenuItemTemplate extends OpenFin.MenuItemTemplate {
295
+ data: SaveButtonContextMenuItemData;
296
+ }
297
+ /**
298
+ * Request for opening a context menu from save button in Browser.
299
+ */
300
+ export interface OpenSaveButtonContextMenuRequest {
301
+ /** Screen x-coordinate where context menu should be shown. */
302
+ x: number;
303
+ /** Screen y-coordinate where context menu should be shown. */
304
+ y: number;
305
+ /** Screen x-coordinate of save button */
306
+ buttonLeft: number;
307
+ /** width of save button */
308
+ buttonWidth: number;
309
+ /** Miscellaneous options necessary for implementing custom logic in the provider override. */
310
+ customData?: any;
311
+ /** Id of the page on which the context menu is invoked */
312
+ pageId: string;
313
+ }
314
+ /**
315
+ * Payload received by the openSaveButtonContextMenu provider override.
316
+ */
317
+ export declare type OpenSaveButtonContextMenuPayload = OpenSaveButtonContextMenuRequest & {
318
+ /** Identity of the Browser window where context menu should be shown. */
319
+ identity: NamedIdentity;
320
+ /** Template defining the options to show in the context menu. */
321
+ template: SaveButtonContextMenuItemTemplate[];
322
+ /** Default function that handles stock context menu options. */
323
+ callback: (data: SaveButtonContextMenuItemData, req: OpenSaveButtonContextMenuPayload) => any;
324
+ };
325
+ /**Payload received by a Custom Action that is invoked by a custom save button context menu option */
326
+ export interface OpenSaveContextMenuOptionActionPayload {
327
+ callerType: CustomActionCallerType.SaveButtonContextMenu;
328
+ /** Identity of the browser window where the context menu is invoked */
329
+ windowIdentity: OpenFin.Identity;
330
+ /** Any data necessary for the functioning of specified custom action*/
331
+ customData?: any;
332
+ /** Id of the page on which the context menu is invoked */
333
+ pageId: string;
334
+ }
278
335
  /**
279
336
  * Request for creating a browser window.
280
337
  */
@@ -536,6 +593,7 @@ export interface BrowserWindowModule {
536
593
  replaceWindowStateButtonOptions(options: WindowStateButtonOptions): Promise<void>;
537
594
  _openViewTabContextMenu(req: OpenViewTabContextMenuRequest): Promise<void>;
538
595
  _openPageTabContextMenu(req: OpenPageTabContextMenuRequest): Promise<void>;
596
+ _openSaveButtonContextMenu(req: OpenSaveButtonContextMenuRequest): Promise<void>;
539
597
  }
540
598
  /**
541
599
  * Factory for wrapping browser windows and global operations.
@@ -599,7 +657,7 @@ export interface BrowserWindowFactory {
599
657
  * layout
600
658
  * };
601
659
  * const options: BrowserCreateWindowRequest = {
602
- * workspacePlatform {
660
+ * workspacePlatform: {
603
661
  * pages: [page],
604
662
  * title: 'My Window Title',
605
663
  * favicon: 'https://google.com/favicon.ico',
@@ -629,11 +687,12 @@ export interface BrowserWindowFactory {
629
687
  * type: BrowserButtonType.PresetLayouts
630
688
  * },
631
689
  * {
632
- * type: BrowserButtonType.SavePage
690
+ * type: BrowserButtonType.SaveMenu
633
691
  * }
634
692
  * ]
635
693
  * }
636
- * windowStateButtonOptions: { configure the set of icons for setting window states
694
+ * windowStateButtonOptions: {
695
+ * //configure the set of icons for setting window states
637
696
  * buttons: [
638
697
  * { // adding a custom window state icon for the window
639
698
  * id: 'windowState123',
@@ -959,15 +1018,16 @@ export interface WorkspacePlatformModule extends OpenFin.Platform {
959
1018
  */
960
1019
  getCurrentWorkspace(): Promise<Workspace>;
961
1020
  /**
962
- * Closes content from the current workspace and applies the given workspace to the user's desktop.
963
- * The given workspace becomes the active workspace, and the content of the workspace is launched.
1021
+ * Sets the workspace as the current active workspace. Does not apply the workspace to the user's desktop.
964
1022
  * @param workspace the workspace to set as current active workspace.
965
1023
  */
966
- setCurrentWorkspace(workspace: Workspace): Promise<void>;
1024
+ setActiveWorkspace(workspace: Workspace): Promise<void>;
967
1025
  /**
968
- * Gets a workspace data structure that represents the active state of the user's desktop.
1026
+ * Closes content from the current workspace and applies the given workspace to the user's desktop. Makes that
1027
+ * workspace the active workspace.
1028
+ * @param workspace the workspace to apply to the desktop and set as the current active workspace.
969
1029
  */
970
- getActiveWorkspace(): Promise<Workspace>;
1030
+ applyWorkspace(workspace: Workspace): Promise<void>;
971
1031
  /**
972
1032
  * The browser window factory for the Workspace Platform.
973
1033
  */
@@ -1053,6 +1113,13 @@ export interface WorkspacePlatformProvider extends OpenFin.PlatformProvider {
1053
1113
  * @param callerIdentity OF identity of the entity from which the request originated
1054
1114
  */
1055
1115
  openPageTabContextMenu(req: OpenPageTabContextMenuPayload, callerIdentity: OpenFin.Identity): any;
1116
+ /**
1117
+ * Implementation for showing a context menu for save button given a menu template,
1118
+ * handler callback, and screen coordinates. For an example of overriding, see {@link BrowserOverrideCallback}.
1119
+ * @param req the payload received by the provider call
1120
+ * @param callerIdentity OF identity of the entity from which the request originated
1121
+ */
1122
+ openSaveButtonContextMenu(req: OpenSaveButtonContextMenuPayload, callerIdentity: OpenFin.Identity): any;
1056
1123
  }
1057
1124
  /**
1058
1125
  * The origins from which a custom action can be invoked
@@ -1062,6 +1129,7 @@ export declare enum CustomActionCallerType {
1062
1129
  GlobalContextMenu = "GlobalContextMenu",
1063
1130
  ViewTabContextMenu = "ViewTabContextMenu",
1064
1131
  PageTabContextMenu = "PageTabContextMenu",
1132
+ SaveButtonContextMenu = "SaveButtonContextMenu",
1065
1133
  API = "API"
1066
1134
  }
1067
1135
  /**The payload received by a Custom Action.
@@ -1069,7 +1137,7 @@ export declare enum CustomActionCallerType {
1069
1137
  * When `callerType == CustomActionCallerType.API`, the payload is defined by the code directly invoking the action.*/
1070
1138
  export declare type CustomActionPayload = {
1071
1139
  callerType: CustomActionCallerType.API;
1072
- } | CustomButtonActionPayload | GlobalContextMenuOptionActionPayload | ViewTabCustomActionPayload | PageTabContextMenuOptionActionPayload;
1140
+ } | CustomButtonActionPayload | GlobalContextMenuOptionActionPayload | ViewTabCustomActionPayload | PageTabContextMenuOptionActionPayload | OpenSaveContextMenuOptionActionPayload;
1073
1141
  /**
1074
1142
  * Configures a custom action when the control is invoked
1075
1143
  */
@@ -1197,7 +1265,31 @@ export interface WorkspacePlatformInitConfig {
1197
1265
  * }, callerIdentity);
1198
1266
  * };
1199
1267
  *
1200
- *
1268
+ * // add a custom menu item in Save Context Menu
1269
+ * openSaveButtonContextMenu = (req: WorkspacePlatform.OpenSaveButtonContextMenuPayload, callerIdentity: OpenFin.Identity) => {
1270
+ * return super.openSaveButtonContextMenu(
1271
+ * {
1272
+ * ...req,
1273
+ * template: [
1274
+ * ...req.template,
1275
+ * {
1276
+ * label: 'Save custom option',
1277
+ * data: {
1278
+ * type: SaveButtonContextMenuOptionType.Custom,
1279
+ * action: {
1280
+ * id: 'sample-custom-action-name',
1281
+ * customData: {
1282
+ * someProp: 'Save Button task'
1283
+ * }
1284
+ * }
1285
+ * }
1286
+ * }
1287
+ * ]
1288
+ * },
1289
+ * callerIdentity
1290
+ * );
1291
+ * }
1292
+ * }
1201
1293
  * }
1202
1294
  * return new Override();
1203
1295
  * };
@@ -1245,13 +1337,11 @@ export interface BrowserInitConfig {
1245
1337
  }
1246
1338
  interface WorkspaceMetadata {
1247
1339
  APIVersion: string;
1248
- timestamp: string;
1249
1340
  }
1250
1341
  export interface Workspace {
1251
1342
  workspaceId: string;
1252
1343
  title: string;
1253
1344
  metadata: WorkspaceMetadata;
1254
- attributes: string[];
1255
1345
  snapshot: OpenFin.Snapshot;
1256
1346
  }
1257
1347
  /**
@@ -1274,9 +1364,13 @@ export interface UpdateSavedWorkspaceRequest {
1274
1364
  * Request to create a save modal.
1275
1365
  * @private
1276
1366
  */
1277
- export interface OpenSaveMenuRequest {
1278
- menuType: SaveModalType;
1279
- id: string;
1367
+ export declare type OpenSaveMenuRequest = {
1280
1368
  x?: number;
1281
1369
  y?: number;
1282
- }
1370
+ } & ({
1371
+ menuType: SaveModalType.SAVE_PAGE | SaveModalType.SAVE_PAGE_AS | SaveModalType.RENAME_PAGE;
1372
+ id: string;
1373
+ } | {
1374
+ menuType: SaveModalType.SAVE_WORKSPACE | SaveModalType.SAVE_WORKSPACE_AS | SaveModalType.RENAME_WORKSPACE;
1375
+ id?: never;
1376
+ });
@@ -10,3 +10,7 @@ export declare type ShowContextMenuResponse = OpenFin.MenuResult & {
10
10
  data: string;
11
11
  };
12
12
  export default function showContextMenu(opts: OpenFin.ShowPopupMenuOptions, win?: _Window): Promise<ShowContextMenuResponse>;
13
+ export declare const DefaultSaveMenuBounds: {
14
+ width: number;
15
+ height: number;
16
+ };
@@ -1,8 +1,8 @@
1
1
  import { NamedIdentity } from 'openfin-adapter/src/identity';
2
2
  import { MenuItemType } from '../../../common/src/utils/context-menu';
3
3
  import * as WP from '../../../client-api-platform/src/index';
4
- import { GlobalContextMenuItemTemplate } from '../../../client-api-platform/src/shapes';
5
- export declare const getAllSavedWorkspaces: () => Promise<{
4
+ import { GlobalContextMenuItemTemplate, GlobalContextMenuOptionType, Workspace } from '../../../client-api-platform/src/shapes';
5
+ export declare const getSavedWorkspaceContextMenuOptions: (activeWorkspace: Workspace, savedWorkspaces: Workspace[], contextMenuOptionType: GlobalContextMenuOptionType) => {
6
6
  label: string;
7
7
  type: MenuItemType;
8
8
  enabled: boolean;
@@ -11,5 +11,5 @@ export declare const getAllSavedWorkspaces: () => Promise<{
11
11
  type: WP.GlobalContextMenuOptionType;
12
12
  workspaceId: string;
13
13
  };
14
- }[]>;
14
+ }[];
15
15
  export declare const getGlobalContextMenuTemplate: (winIdentity: NamedIdentity) => Promise<GlobalContextMenuItemTemplate[]>;
@@ -0,0 +1,2 @@
1
+ import { SaveButtonContextMenuItemTemplate } from '../../../client-api-platform/src/shapes';
2
+ export declare const getSaveButtonMenuTemplate: () => SaveButtonContextMenuItemTemplate[];