Customize save and copy workflows

In Workspace v16.1 or later, you can customize the save and copy workflows for Pages in Browser:

  • Whether a modal dialog about saving a Page is displayed when users close pages. You can remove the modal dialog if a Page is locked, for example.

  • What happens when your users make changes to a Page. You can include logic to save the Page automatically, for example.

How it works

Two methods of the WorkspacePlatformProvider interface let you customize when pages are saved:

  • handleSaveModalOnPageClose lets you specify when the save page modal is displayed. It checks for whether there are changes to the page, and does not display the modal if there are no changes. You can override it to support other behaviors as needed. See the API reference.

  • handlePageChanges lets you include your own code to provide custom logic for what happens when users make changes to a page. API reference.

How to do it

The following examples represent common use cases for these methods. You can write implementations for other use cases.

To hide the modal when a page is locked and the user closes it:

async handleSaveModalOnPageClose(payload: HandleSaveModalOnPageClosePayload): Promise<SaveModalOnPageCloseResult>  
{
  // close confirmation modal will not be shown if the page is locked
  if (payload.page.isLocked) 
  {
      return { shouldShowModal: false };
  }
  return super.handleSaveModalOnPageClose(payload);
}

To automatically save a page when the user makes changes, add your code to the following example:

async handlePageChanges(
    payload: HandlePageChangesPayload
): Promise<ModifiedPageState> {
  if (payload.page.customData?.autoSave) 
  {
    /* insert logic to automatically save the page here */

    // page will be displayed in the UI to have no unsaved changes
    return { hasUnsavedChanges: false };
  }
  return super.handlePageChanges(payload);
}