@openfin/workspace-platform 5.7.2 → 6.1.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.
@@ -58,6 +58,15 @@ export declare enum GlobalContextMenuOptionType {
58
58
  Quit = "Quit",
59
59
  Custom = "Custom"
60
60
  }
61
+ /**Types of page tab context menu options, including pre-defined ones.
62
+ * User-defined context menu items should use the value `Custom` */
63
+ export declare enum PageTabContextMenuOptionType {
64
+ Close = "Close",
65
+ Duplicate = "Duplicate",
66
+ Rename = "Rename",
67
+ Save = "Save",
68
+ Custom = "Custom"
69
+ }
61
70
  /**Shape of the data property of a global context menu template item */
62
71
  export interface GlobalContextMenuItemData extends ContextMenuItemData {
63
72
  type: GlobalContextMenuOptionType;
@@ -66,11 +75,31 @@ export interface GlobalContextMenuItemData extends ContextMenuItemData {
66
75
  export interface GlobalContextMenuItemTemplate extends OpenFin.MenuItemTemplate {
67
76
  data: GlobalContextMenuItemData;
68
77
  }
69
- /**Payload received by a Custom Action that is invoked by a custom context menu option */
78
+ /**Shape of the data property of a page tab context menu template item */
79
+ export interface PageTabContextMenuItemData extends ContextMenuItemData {
80
+ type: PageTabContextMenuOptionType;
81
+ }
82
+ /**Configuration of an option in the page tab context menu */
83
+ export interface PageTabContextMenuItemTemplate extends OpenFin.MenuItemTemplate {
84
+ data: PageTabContextMenuItemData;
85
+ }
86
+ /**Payload received by a Custom Action that is invoked by a custom global context menu option */
70
87
  export interface GlobalContextMenuOptionActionPayload {
71
88
  callerType: CustomActionCallerType.GlobalContextMenu;
89
+ /** Identity of the browser window where the context menu is invoked */
90
+ windowIdentity: OpenFin.Identity;
91
+ /** Any data necessary for the functioning of specified custom action*/
92
+ customData?: any;
93
+ }
94
+ /**Payload received by a Custom Action that is invoked by a custom page tab context menu option */
95
+ export interface PageTabContextMenuOptionActionPayload {
96
+ callerType: CustomActionCallerType.PageTabContextMenu;
97
+ /** Identity of the browser window where the context menu is invoked */
72
98
  windowIdentity: OpenFin.Identity;
73
- customData: any | undefined;
99
+ /** Any data necessary for the functioning of specified custom action*/
100
+ customData?: any;
101
+ /** Id of the page on which the context menu is invoked */
102
+ pageId: string;
74
103
  }
75
104
  /**
76
105
  * Payload received by the openGlobalContextMenu provider override.
@@ -81,7 +110,7 @@ export declare type OpenGlobalContextMenuPayload = OpenGlobalContextMenuRequest
81
110
  /** Identity of the Browser window where context menu should be shown. */
82
111
  identity: NamedIdentity;
83
112
  /** Default function that handles stock context menu options. */
84
- callback: (data: GlobalContextMenuItemData) => any;
113
+ callback: (data: GlobalContextMenuItemData, payload: OpenGlobalContextMenuPayload) => any;
85
114
  };
86
115
  export interface ViewTabContextMenuTemplate extends OpenFin.MenuItemTemplate {
87
116
  data: ViewTabMenuData;
@@ -100,6 +129,19 @@ export interface OpenViewTabContextMenuRequest {
100
129
  template: ViewTabContextMenuTemplate[];
101
130
  selectedViews: OpenFin.Identity[];
102
131
  }
132
+ /**
133
+ * Request for opening a page tab context menu in Browser.
134
+ */
135
+ export interface OpenPageTabContextMenuRequest {
136
+ /** Screen x-coordinate where context menu should be shown. */
137
+ x: number;
138
+ /** Screen y-coordinate where context menu should be shown. */
139
+ y: number;
140
+ /** Miscellaneous options necessary for implementing custom logic in the provider override. */
141
+ customData?: any;
142
+ /** Id of the page on which the context menu is invoked */
143
+ pageId: string;
144
+ }
103
145
  export declare enum ViewTabMenuOptionType {
104
146
  NewView = "NewView",
105
147
  DuplicateViews = "DuplicateView",
@@ -130,7 +172,18 @@ export declare type OpenViewTabContextMenuPayload = OpenViewTabContextMenuReques
130
172
  /** Identity of the Browser window where context menu should be shown. */
131
173
  identity: NamedIdentity;
132
174
  /** Default function that handles stock context menu options. */
133
- callback: (data: ViewTabMenuData, req: OpenViewTabContextMenuRequest) => any;
175
+ callback: (data: ViewTabMenuData, req: OpenViewTabContextMenuPayload) => any;
176
+ };
177
+ /**
178
+ * Payload received by the openViewTabContextMenu provider override.
179
+ */
180
+ export declare type OpenPageTabContextMenuPayload = OpenPageTabContextMenuRequest & {
181
+ /** Identity of the Browser window where context menu should be shown. */
182
+ identity: NamedIdentity;
183
+ /** Template defining the options to show in the context menu. */
184
+ template: PageTabContextMenuItemTemplate[];
185
+ /** Default function that handles stock context menu options. */
186
+ callback: (data: PageTabContextMenuItemData, req: OpenPageTabContextMenuPayload) => any;
134
187
  };
135
188
  /**
136
189
  * Request to update the attributes of a page in which is attached to a running browser window.
@@ -195,16 +248,18 @@ export interface PreDefinedButtonConfig {
195
248
  /** icon URL for icon image */
196
249
  iconUrl?: string;
197
250
  iconProps?: IconProps;
251
+ disabled?: boolean;
198
252
  }
199
253
  declare type ShowHideTabsConfig = {
200
254
  type: BrowserButtonType.ShowHideTabs;
255
+ disabled?: boolean;
201
256
  };
202
257
  /**
203
258
  * Buttons on the left of WindowStateButtonOptions
204
259
  */
205
- export declare type IconTrayButton = ShowHideTabsConfig | CustomBrowserButtonConfig | PreDefinedButtonConfig;
206
- export interface IconTrayOptions {
207
- buttons: IconTrayButton[];
260
+ export declare type ToolbarButton = ShowHideTabsConfig | CustomBrowserButtonConfig | PreDefinedButtonConfig;
261
+ export interface ToolbarOptions {
262
+ buttons: ToolbarButton[];
208
263
  }
209
264
  /**
210
265
  * Buttons to the top far right of Browser
@@ -235,7 +290,7 @@ export interface BrowserCreateWindowRequest extends Omit<OpenFin.PlatformWindowC
235
290
  * If you do not provide a newPageUrl, then the new Page plus button will not be shown and you cannot create a new empty Page or Window.
236
291
  */
237
292
  newPageUrl?: string;
238
- iconTrayOptions?: IconTrayOptions;
293
+ toolbarOptions?: ToolbarOptions;
239
294
  windowStateButtonOptions?: WindowStateButtonOptions;
240
295
  /**
241
296
  * Remove the Page UI and only allow a single page in the browser window.
@@ -414,7 +469,66 @@ export interface BrowserWindowModule {
414
469
  * @param req the reorder pages request.
415
470
  */
416
471
  reorderPages(req: ReorderPagesRequest): Promise<void>;
472
+ /**
473
+ * Replace toolbar options with custom toolbar options
474
+ *
475
+ * ```ts
476
+ * import * as WorkspacePlatform from '@openfin/workspace-platform';
477
+ *
478
+ * // to set the array to our default buttons, pass in null
479
+ *
480
+ * const workspacePlatform = WorkspacePlatform.getCurrentSync();
481
+ * workspacePlatform.Browser.wrapSync(identity).replaceToolbarOptions({buttons:[{
482
+ * type: 'Custom',
483
+ * tooltip: 'Custom Tooltip',
484
+ * disabled: false,
485
+ * iconUrl: 'https://www.openfin.co/favicon.ico',
486
+ * action: {
487
+ * id: 'sample-custom-action-name',
488
+ * customData: {
489
+ * message: 'Clicked on custom Toolbar button'
490
+ * }
491
+ * }
492
+ * }]})
493
+ *
494
+ * const openFinWindow = fin.Window.wrapSync(identity);
495
+ * // call getOptions() to view updated toolbarOptions under workspacePlatform
496
+ * await openFinWindow.getOptions()
497
+ * ```
498
+ * @param options new toolbar options.
499
+ */
500
+ replaceToolbarOptions(options: ToolbarOptions): Promise<void>;
501
+ /**
502
+ * Replace window state button options with custom window state button options
503
+ *
504
+ * ```ts
505
+ * import * as WorkspacePlatform from '@openfin/workspace-platform';
506
+ *
507
+ * // to set the array to our default buttons, pass in null
508
+ *
509
+ * const workspacePlatform = WorkspacePlatform.getCurrentSync();
510
+ * workspacePlatform.Browser.wrapSync(identity).replaceWindowStateButtonOptions({buttons:[{
511
+ * type: 'Custom',
512
+ * tooltip: 'Custom tooltip',
513
+ * disabled: false,
514
+ * iconUrl: 'https://www.openfin.co/favicon.ico',
515
+ * action: {
516
+ * id: 'sample-custom-action-name',
517
+ * customData: {
518
+ * message: 'Clicked on custom window state button'
519
+ * }
520
+ * }
521
+ * }]})
522
+ *
523
+ * const openFinWindow = fin.Window.wrapSync(identity);
524
+ * // call getOptions() to view updated windowStateButtonOptions under workspacePlatform
525
+ * await openFinWindow.getOptions()
526
+ * ```
527
+ * @param options new window state options.
528
+ */
529
+ replaceWindowStateButtonOptions(options: WindowStateButtonOptions): Promise<void>;
417
530
  _openViewTabContextMenu(req: OpenViewTabContextMenuRequest): Promise<void>;
531
+ _openPageTabContextMenu(req: OpenPageTabContextMenuRequest): Promise<void>;
418
532
  }
419
533
  /**
420
534
  * Factory for wrapping browser windows and global operations.
@@ -481,7 +595,66 @@ export interface BrowserWindowFactory {
481
595
  * workspacePlatform {
482
596
  * pages: [page],
483
597
  * title: 'My Window Title',
484
- * favicon: 'https://google.com/favicon.ico'
598
+ * favicon: 'https://google.com/favicon.ico',
599
+ * disableMultiplePages: true, // disable page functonality for the window
600
+ * toolbarOptions: { // configure the set of tray icons for the window
601
+ * buttons: [
602
+ * { // adding a custom tray icon for the window
603
+ * type: BrowserButtonType.Custom,
604
+ * tooltip: 'Sample Tray Icon',
605
+ * disabled: false,
606
+ * iconUrl: 'https://www.openfin.co/favicon.ico',
607
+ * action: {
608
+ * // This action needs to be registed in customActions property in the call WorkspacePlatform.init
609
+ * id: 'sample-trayicon-custom-action',
610
+ * customData: {
611
+ * message: 'Clicked on custom Toolbar button'
612
+ * }
613
+ * }
614
+ * },
615
+ * {
616
+ * type: BrowserButtonType.ShowHideTabs
617
+ * },
618
+ * {
619
+ * type: BrowserButtonType.ColorLinking
620
+ * },
621
+ * {
622
+ * type: BrowserButtonType.PresetLayouts
623
+ * },
624
+ * {
625
+ * type: BrowserButtonType.SavePage
626
+ * }
627
+ * ]
628
+ * }
629
+ * windowStateButtonOptions: { configure the set of icons for setting window states
630
+ * buttons: [
631
+ * { // adding a custom window state icon for the window
632
+ * id: 'windowState123',
633
+ * type: BrowserButtonType.Custom,
634
+ * tooltip: 'Sample Window State button',
635
+ * disabled: false,
636
+ * iconUrl: 'https://www.openfin.co/favicon.ico',
637
+ * action: {
638
+ * // This action needs to be registed in customActions property in the call WorkspacePlatform.init
639
+ * id: 'sample-window-state-custom-action',
640
+ * customData: {
641
+ * message: 'Clicked on custom Window State button'
642
+ * }
643
+ * }
644
+ * },
645
+ * { // override tooltip and icon URL for standard Maximise button
646
+ * type: BrowserButtonType.Maximise,
647
+ * tooltip: overrideWindowStateIcons ? 'Studio Maximise' : undefined,
648
+ * iconUrl: overrideWindowStateIcons ? 'https://www.openfin.co/favicon.ico' : undefined
649
+ * },
650
+ * {
651
+ * type: BrowserButtonType.Minimise
652
+ * },
653
+ * {
654
+ * type: BrowserButtonType.Close
655
+ * }
656
+ * ]
657
+ * }
485
658
  * }
486
659
  * };
487
660
  * const window = await workspacePlatform.Browser.createWindow(options);
@@ -759,18 +932,25 @@ export interface WorkspacePlatformProvider extends OpenFin.PlatformProvider {
759
932
  deleteSavedPage(id: string): Promise<void>;
760
933
  /**
761
934
  * Implementation for showing a global context menu given a menu template,
762
- * handler callback, and screen coordinates
935
+ * handler callback, and screen coordinates. For an example of overriding, see {@link BrowserOverrideCallback}.
763
936
  * @param req the payload received by the provider call
764
937
  * @param callerIdentity OF identity of the entity from which the request originated
765
938
  */
766
- openGlobalContextMenu(req: OpenGlobalContextMenuPayload, callerIdentity: any): any;
939
+ openGlobalContextMenu(req: OpenGlobalContextMenuPayload, callerIdentity: OpenFin.Identity): any;
767
940
  /**
768
941
  * Implementation for showing a view tab context menu given a menu template,
769
- * handler callback, and screen coordinates
942
+ * handler callback, and screen coordinates. For an example of overriding, see {@link BrowserOverrideCallback}.
770
943
  * @param req the payload received by the provider call
771
944
  * @param callerIdentity OF identity of the entity from which the request originated
772
945
  */
773
- openViewTabContextMenu(req: OpenViewTabContextMenuPayload, callerIdentity: any): any;
946
+ openViewTabContextMenu(req: OpenViewTabContextMenuPayload, callerIdentity: OpenFin.Identity): any;
947
+ /**
948
+ * Implementation for showing a page tab context menu given a menu template,
949
+ * handler callback, and screen coordinates. For an example of overriding, see {@link BrowserOverrideCallback}.
950
+ * @param req the payload received by the provider call
951
+ * @param callerIdentity OF identity of the entity from which the request originated
952
+ */
953
+ openPageTabContextMenu(req: OpenPageTabContextMenuPayload, callerIdentity: OpenFin.Identity): any;
774
954
  }
775
955
  /**
776
956
  * The origins from which a custom action can be invoked
@@ -779,6 +959,7 @@ export declare enum CustomActionCallerType {
779
959
  CustomButton = "CustomButton",
780
960
  GlobalContextMenu = "GlobalContextMenu",
781
961
  ViewTabContextMenu = "ViewTabContextMenu",
962
+ PageTabContextMenu = "PageTabContextMenu",
782
963
  API = "API"
783
964
  }
784
965
  /**The payload received by a Custom Action.
@@ -786,7 +967,7 @@ export declare enum CustomActionCallerType {
786
967
  * When `callerType == CustomActionCallerType.API`, the payload is defined by the code directly invoking the action.*/
787
968
  export declare type CustomActionPayload = {
788
969
  callerType: CustomActionCallerType.API;
789
- } | CustomButtonActionPayload | GlobalContextMenuOptionActionPayload | ViewTabCustomActionPayload;
970
+ } | CustomButtonActionPayload | GlobalContextMenuOptionActionPayload | ViewTabCustomActionPayload | PageTabContextMenuOptionActionPayload;
790
971
  /**
791
972
  * Configures a custom action when the control is invoked
792
973
  */
@@ -864,16 +1045,75 @@ export interface WorkspacePlatformInitConfig {
864
1045
  * WorkspacePlatformProvider
865
1046
  * ) => {
866
1047
  * class Override extends WorkspacePlatformProvider {
1048
+ * // ovrride default behavior of updateSavedPage
867
1049
  * updateSavedPage = async (req: UpdateSavedPageRequest): Promise<void> => {
868
1050
  * console.log(`saving page ${req.page.pageId}`);
869
1051
  * // calling custom function to the save page here
870
- * };
1052
+ * };
1053
+ *
1054
+ * // add a custom menu item in Global Context Menu
1055
+ * openGlobalContextMenu(req: WorkspacePlatform.OpenGlobalContextMenuPayload, callerIdentity: any) {
1056
+ * return super.openGlobalContextMenu(
1057
+ * {
1058
+ * ...req,
1059
+ * template: [
1060
+ * ...req.template,
1061
+ * {
1062
+ * label: 'Sample custom global option',
1063
+ * data: {
1064
+ * type: GlobalContextMenuOptionType.Custom,
1065
+ * action: {
1066
+ * // This action needs to be registed in customActions property in the call WorkspacePlatform.init
1067
+ * id: 'sample-custom-global-menu-action'
1068
+ * }
1069
+ * }
1070
+ * }
1071
+ * ]
1072
+ * },
1073
+ * callerIdentity
1074
+ * );
1075
+ * }
1076
+ *
1077
+ * // add a custom menu item in View Tab Context Menu
1078
+ * openViewTabContextMenu = async (payload: OpenViewTabContextMenuPayload, callerIdentity) => {
1079
+ * return super.openViewTabContextMenu({
1080
+ * ...payload,
1081
+ * template: [
1082
+ * {
1083
+ * label: 'Sample View Tab Context Menu',
1084
+ * data: {
1085
+ * type: ViewTabMenuOptionType.Custom,
1086
+ * action: {
1087
+ * // This action needs to be registed in customActions property in the call WorkspacePlatform.init
1088
+ * id: 'sample-viewtab-action',
1089
+ * customData: 'Custom View Tab Action'
1090
+ * }
1091
+ * }
1092
+ * },
1093
+ * ...payload.template
1094
+ * ]
1095
+ * }, callerIdentity);
1096
+ * };
1097
+ *
1098
+ *
871
1099
  * }
872
1100
  * return new Override();
873
1101
  * };
874
1102
  *
875
1103
  * await WorkspacePlatform.init({
876
1104
  * browser: { overrideCallback },
1105
+ * customActions: {
1106
+ * 'sample-custom-global-menu-action': (payload: CustomActionPayload) => {
1107
+ * alert('This custom action works ' + JSON.stringify(payload));
1108
+ * return 'someresponse';
1109
+ * },
1110
+ * 'sample-viewtab-action': (payload: ViewTabCustomActionPayload) => {
1111
+ * alert('This custom action works ' + JSON.stringify(payload));
1112
+ * return 'someresponse';
1113
+ * }
1114
+ * }
1115
+ *
1116
+ *
877
1117
  * });
878
1118
  */
879
1119
  export declare type BrowserOverrideCallback = OpenFin.OverrideCallback<WorkspacePlatformProvider>;
@@ -15,7 +15,9 @@ export interface AddToChannelRequest {
15
15
  export declare enum ChannelAction {
16
16
  CloseBrowserWindow = "close-browser-window",
17
17
  QuitPlatform = "quit-platform",
18
- CloseActivePage = "close-active-page",
18
+ ClosePage = "close-page",
19
19
  AddToChannel = "add-to-channel",
20
- RemoveFromChannel = "remove-from-channel"
20
+ RemoveFromChannel = "remove-from-channel",
21
+ SavePage = "save-page",
22
+ DuplicatePage = "duplicate-page"
21
23
  }
@@ -0,0 +1,46 @@
1
+ /// <reference types="openfin-adapter/fin" />
2
+ interface InternalWindowOptions extends OpenFin.PlatformWindowCreationOptions {
3
+ workspacePlatform: OpenFin.WindowOptions['workspacePlatform'] & {
4
+ _internalAutoShow: boolean;
5
+ _internalDeferShowEnabled: boolean;
6
+ };
7
+ }
8
+ /**
9
+ * This function prevents a created window from being auto shown by the Core.
10
+ * The Core will auto show the window before the window has a chance to register a listener to prevent it.
11
+ * With these options applied, the window must call `setCanShow(true)` when it is ready to be shown.
12
+ * If `autoShow` was originally true, the window will be show upon the first call to `setCanShow(true)`.
13
+ *
14
+ * By applying these options it is assumed that the window calls `registerDeferShow()` and `setCanShow(true)`.
15
+ *
16
+ * This function should be used in conjunction the `withDeferShow` platform middleware.
17
+ * `withDeferShow` will prevent the window from being shown before the window has launched and registered
18
+ * its show requested listener.
19
+ *
20
+ * @param opts the options to modify.
21
+ * @returns the modified options.
22
+ */
23
+ export declare const applyDeferShowOptions: (opts: OpenFin.PlatformWindowCreationOptions) => InternalWindowOptions;
24
+ /**
25
+ * This function is a middleware that can be applied to a platform's `createWindow` function.
26
+ * If the defer show API has been enabled in window options using the `applyDeferShowOptions` function
27
+ * the window will be prevented from showing.
28
+ * @param superCreateWindow the create window method to decorate.
29
+ * @returns the `createWindow` method wrapped with this middleware.
30
+ */
31
+ export declare const withDeferShow: (superCreateWindow: (opts: OpenFin.PlatformWindowCreationOptions, callerIdentity: OpenFin.Identity) => Promise<OpenFin.Window>) => (opts: OpenFin.PlatformWindowCreationOptions, callerIdentity?: OpenFin.Identity) => Promise<import("openfin-adapter").Window>;
32
+ /**
33
+ * Assert if the window is able to be shown or not.
34
+ * Upon calling `setCanShow(true)`, if the window was previously prevented
35
+ * from being shown, this function will show the window.
36
+ * @param bool true if the window should be able to be shown. (Default is false)
37
+ */
38
+ export declare const setCanShow: (bool: boolean) => Promise<void>;
39
+ /**
40
+ * Add a listener that defers showing the current window.
41
+ * To allow the window to be shown, `setCanShow(true)` must be called.
42
+ * Upon calling `setCanShow(true)`, if the window was previously prevented
43
+ * from being shown, it will show.
44
+ */
45
+ export declare const registerDeferShow: () => Promise<void>;
46
+ export {};
@@ -20,10 +20,6 @@ export declare const workspaceProviderFinsLink: string;
20
20
  export declare const workspaceProviderFallbackUrl: string;
21
21
  export declare const workspaceCdnUrl: string;
22
22
  export declare const workspaceCdnEnvUrl: string;
23
+ export declare const workspaceDocsPlatformUrl: string;
24
+ export declare const workspaceDocsClientUrl: string;
23
25
  export declare const workspaceRuntimeVersion: string;
24
- /**
25
- * A promise that resolves when:
26
- * - The window 'load' event is fired.
27
- * - The window first paint occurs.
28
- */
29
- export declare const firstPaint: Promise<void>;
@@ -0,0 +1,2 @@
1
+ import { PageTabContextMenuItemTemplate } from '../../../client-api-platform/src/shapes';
2
+ export declare const getPageTabMenuTemplate: (saved: boolean) => PageTabContextMenuItemTemplate[];
@@ -25,7 +25,8 @@ export declare enum WindowEvent {
25
25
  ViewAttached = "view-attached",
26
26
  ViewDetached = "view-detached",
27
27
  ViewPageTitleUpdated = "view-page-title-updated",
28
- ViewDestroyed = "view-destroyed"
28
+ ViewDestroyed = "view-destroyed",
29
+ OptionsChanged = "options-changed"
29
30
  }
30
31
  export interface WindowIdentity {
31
32
  uuid: ApplicationUUID | string;
@@ -148,4 +149,5 @@ export declare const isHomeWindowRunning: () => Promise<boolean>;
148
149
  export declare const showAndFocusStorefront: () => Promise<void>;
149
150
  export declare const centerWindowIfOffScreen: (windowIdentity?: WindowIdentity) => Promise<void>;
150
151
  export declare const getDisableMultiplePagesOption: (identity: WindowIdentity) => Promise<any>;
152
+ export declare const getPlatformWindowTitle: (identity: WindowIdentity) => Promise<any>;
151
153
  export {};