@openfin/workspace-platform 16.0.7 → 17.0.0

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,6 +1,6 @@
1
1
  import type OpenFin from '@openfin/core';
2
- import type { AttachedPage, DetachPagesFromWindowPayload, ExtendedAttachPagesToWindowPayload, ReorderPagesForWindowPayload, SetActivePageForWindowPayload, UpdatePageForWindowPayload } from '../../../../common/src/api/pages/shapes';
3
- import type { CreateSavedPageRequest, Page, UpdateSavedPageRequest } from '../../../../client-api-platform/src/shapes';
2
+ import type { AttachedPage, CopyPagePayload, DetachPagesFromWindowPayload, ExtendedAttachPagesToWindowPayload, HandleSaveModalOnPageClosePayload, ReorderPagesForWindowPayload, SaveModalOnPageCloseResult, SetActivePageForWindowPayload, UpdatePageForWindowPayload } from '../../../../common/src/api/pages/shapes';
3
+ import type { CreateSavedPageRequest, HandlePageChangesPayload, ModifiedPageState, Page, UpdateSavedPageRequest } from '../../../../client-api-platform/src/shapes';
4
4
  /**
5
5
  * Get all open pages in which are attached to a window.
6
6
  * @returns the list of attached pages.
@@ -30,3 +30,6 @@ export declare const getActivePageIdForWindow: (identity: OpenFin.Identity) => P
30
30
  * @returns string: a unique page name
31
31
  */
32
32
  export declare function getUniquePageTitle(initialName?: string): Promise<string>;
33
+ export declare function handleSaveModalOnPageClose({ page }: HandleSaveModalOnPageClosePayload): Promise<SaveModalOnPageCloseResult>;
34
+ export declare function copyPageOverride({ page }: CopyPagePayload): Promise<Page>;
35
+ export declare function handlePageChanges(payload: HandlePageChangesPayload): Promise<ModifiedPageState>;
@@ -2,7 +2,8 @@ import type OpenFin from '@openfin/core';
2
2
  import { IconProps } from '@openfin/ui-library';
3
3
  import type { AnalyticsEvent, AnalyticsEventInternal } from '../../common/src/utils/usage-register';
4
4
  import { CustomActionSpecifier, CustomButtonConfig } from '../../common/src/api/action';
5
- import type { AttachedPage, Page, PageWithUpdatableRuntimeAttribs } from '../../common/src/api/pages/shapes';
5
+ import type { AttachedPage, CopyPagePayload, HandleSaveModalOnPageClosePayload, Page, PageWithUpdatableRuntimeAttribs, SaveModalOnPageCloseResult } from '../../common/src/api/pages/shapes';
6
+ import { SetActivePageForWindowPayload } from '../../common/src/api/pages/shapes';
6
7
  import type { CustomThemes } from '../../common/src/api/theming';
7
8
  import type { App, DockProviderConfigWithIdentity, StoreButtonConfig } from '../../client-api/src/shapes';
8
9
  import type { WorkflowIntegration } from '../../client-api/src/shapes/integrations';
@@ -30,6 +31,15 @@ export interface UpdateSavedPageRequest {
30
31
  /** The updated page. */
31
32
  page: Page;
32
33
  }
34
+ export interface HandlePageChangesPayload {
35
+ /** The page with new changes. */
36
+ page: AttachedPage;
37
+ /** The OF window identity containing the page. */
38
+ identity: OpenFin.Identity;
39
+ }
40
+ export interface ModifiedPageState {
41
+ hasUnsavedChanges?: boolean;
42
+ }
33
43
  /**
34
44
  * Request for reordering the pages attached to a window.
35
45
  */
@@ -1287,6 +1297,11 @@ export interface WorkspacePlatformProvider extends OpenFin.PlatformProvider {
1287
1297
  * @param id of the id of the page to delete.
1288
1298
  */
1289
1299
  deleteSavedPage(id: string): Promise<void>;
1300
+ /**
1301
+ * Implementation for detecting if a page change qualifies as putting the page in an unsaved state.
1302
+ * @param payload the page with new changes and the identity of the OF window where the page change occured.
1303
+ */
1304
+ handlePageChanges(payload: HandlePageChangesPayload): Promise<ModifiedPageState>;
1290
1305
  /**
1291
1306
  * Implementation for getting a list of saved workspaces from persistent storage.
1292
1307
  * @param query an optional query.
@@ -1373,6 +1388,21 @@ export interface WorkspacePlatformProvider extends OpenFin.PlatformProvider {
1373
1388
  * @param req the payload received by the provider
1374
1389
  */
1375
1390
  handleAnalytics(req: AnalyticsEvent[]): Promise<void>;
1391
+ /**
1392
+ * Implementation for deciding whether a modal informing about loss of unsaved changes will be displayed when closing a page.
1393
+ * The default implementation returns `{ shouldShowModal: true }` if the page has unsaved changes (`hasUnsavedChanges` page property)
1394
+ * and `false` otherwise.
1395
+ */
1396
+ handleSaveModalOnPageClose(payload: HandleSaveModalOnPageClosePayload): Promise<SaveModalOnPageCloseResult>;
1397
+ /**
1398
+ * Implementation for setting the active page in a browser window.
1399
+ * Called when the active page is changed and on browser window creation.
1400
+ */
1401
+ setActivePage(payload: SetActivePageForWindowPayload): Promise<void>;
1402
+ /**
1403
+ * Implementation for creating a copy of a page. Called when a page is Saved-As or Duplicated.
1404
+ */
1405
+ copyPage(payload: CopyPagePayload): Promise<Page>;
1376
1406
  }
1377
1407
  /**
1378
1408
  * The origins from which a custom action can be invoked
@@ -187,4 +187,22 @@ export type PanelConfig = (PanelConfigHorizontal | PanelConfigVertical) & {
187
187
  export type ExtendedPanelConfig = PanelConfig & {
188
188
  viewOptions: PanelConfig['viewOptions'] & OpenFin.Identity;
189
189
  };
190
+ export interface HandleSaveModalOnPageClosePayload {
191
+ /** The page that is closing. */
192
+ page: AttachedPage;
193
+ /** The OF window identity containing the page. */
194
+ identity: OpenFin.Identity;
195
+ }
196
+ export interface SaveModalOnPageCloseResult {
197
+ /** If false, a modal informing that unsaved changes will be lost will not be displayed. */
198
+ shouldShowModal: boolean;
199
+ }
200
+ export interface CopyPagePayload {
201
+ /** The OF browser identity containing the page to copy. */
202
+ identity: OpenFin.Identity;
203
+ /** The page to copy. */
204
+ page: Page;
205
+ /** Specifies the trigger for creating a copy. */
206
+ reason: 'save-as' | 'duplicate';
207
+ }
190
208
  export {};
@@ -53,7 +53,10 @@ export declare enum WorkspacePlatformChannelAction {
53
53
  IsBrowserInitialized = "isBrowserInitialized",
54
54
  Analytics = "analyticsInternal",
55
55
  GetDockProviderConfig = "getDockProviderConfig",
56
- SaveDockProviderConfig = "saveDockProviderConfig"
56
+ SaveDockProviderConfig = "saveDockProviderConfig",
57
+ HandleSaveModalOnPageClose = "handleSaveModalOnPageClose",
58
+ CopyPage = "copyPage",
59
+ HandlePageChanges = "handlePageChanges"
57
60
  }
58
61
  export type PlatFormSupportedFeatures = boolean | {
59
62
  isWorkspacePlatform: boolean;
@@ -1,22 +1,39 @@
1
1
  import type OpenFin from '@openfin/core';
2
2
  import type { OptionalExceptFor } from '../../../common/src/utils/types';
3
- export interface ModalResponseContent {
4
- title: string;
5
- body: string;
6
- affirmativeButton: string;
7
- negativeButton?: string;
8
- canceledButton?: string;
9
- }
10
3
  export interface MenuConfig {
11
4
  windowOptions: OptionalExceptFor<OpenFin.WindowOptions, 'url' | 'name' | 'defaultHeight' | 'defaultWidth'>;
12
5
  title: string;
13
6
  }
14
- export interface ResponseModalConfig extends MenuConfig {
15
- content: ModalResponseContent;
16
- }
17
7
  export interface RightMenuConfig extends MenuConfig {
18
8
  windowOffset?: {
19
9
  x?: number;
20
10
  y?: number;
21
11
  };
22
12
  }
13
+ export interface ResponseModalConfig extends MenuConfig {
14
+ content: ResponseModalContent;
15
+ }
16
+ export interface ResponseModalContent {
17
+ title: string;
18
+ body: string;
19
+ closeType?: 'page' | 'workspace';
20
+ buttons: ResponseModalButtons;
21
+ textInputOptions?: {
22
+ placeholder?: string;
23
+ defaultValue?: string;
24
+ };
25
+ invocationId?: string;
26
+ }
27
+ export type ResponseModalButtons = LeftButtonConfig | RightButtonConfig;
28
+ export interface LeftButtonConfig {
29
+ left: ButtonConfig[];
30
+ right?: ButtonConfig[];
31
+ }
32
+ export interface RightButtonConfig {
33
+ left?: ButtonConfig[];
34
+ right: ButtonConfig[];
35
+ }
36
+ export type ButtonConfig = {
37
+ label: string;
38
+ type: 'primary' | 'secondary';
39
+ };
@@ -1,5 +1,5 @@
1
1
  import type OpenFin from '@openfin/core';
2
- import { ModalResponseContent } from '../../../common/src/utils/menu-config';
2
+ import { ResponseModalContent } from '../../../common/src/utils/menu-config';
3
3
  import type { OptionalExceptFor } from '../../../common/src/utils/types';
4
4
  type MenuEventTypes = {
5
5
  response: [ModalResponseEvent];
@@ -7,7 +7,12 @@ type MenuEventTypes = {
7
7
  update: [string, Partial<OpenFin.Bounds>, string];
8
8
  };
9
9
  export interface ModalResponseEvent {
10
- data: 'canceled' | 'negative' | 'affirmative';
10
+ data: {
11
+ actionName: string;
12
+ data?: {
13
+ textInputValue?: string;
14
+ };
15
+ };
11
16
  name: string;
12
17
  }
13
18
  export declare const menuEvents: {
@@ -28,7 +33,7 @@ export interface ShowChildOptions {
28
33
  }
29
34
  export interface ResponseModalOptions {
30
35
  options: WindowOptionsWithBounds;
31
- content: ModalResponseContent;
36
+ content: ResponseModalContent;
32
37
  }
33
38
  export declare function createMenuPosition(windowOptions: OptionalExceptFor<OpenFin.WindowOptions, 'x' | 'y' | 'defaultWidth'>): Promise<{
34
39
  top: number;
@@ -17,6 +17,7 @@ export declare enum PageRoute {
17
17
  BrowserPopupMenuColorLinking = "/browser/popup-menu/color-linking/color-linking/",
18
18
  BrowserIndicator = "/browser/indicator/",
19
19
  ResponseModal = "/browser/popup-menu/response-modal/",
20
+ CloseConfirmationModal = "/browser/popup-menu/close-confirmation-modal/",
20
21
  Docs = "/provider/docs/",
21
22
  Storefront = "/storefront/",
22
23
  DeprecatedAlert = "/provider/deprecated-alert/",