Configure dynamic Dock

In Workspace v13 and later, users can rearrange elements in the Dock UI or add apps to their favorites, and their arrangements persist by default.
If your platform makes any changes to the Dock configuration, Dock is dynamically updated with these changes.
Earlier Workspace versions require Dock to be re-registered if any changes are made to the configuration.

How it works

When you register a Dock provider, a DockProviderRegistration object is returned that includes a new updateDockProviderConfig method.
You call this method to update Dock with any new configuration you provide.
The DockProviderConfig and WorkspaceButtonsConfig interfaces support this functionality.
For details, see the Dock API reference.

You can disable or limit user arrangement of their Dock in either of the following ways:

  • To allow users to rearrange their Dock but disable state persistence of their configurations, set the skipSavedDockProviderConfig property of the DockProvider object to true (default false).

  • To disable user configuration of Dock entirely, set the disableUserRearrangement property of the DockProvider object to true (default false).

How to do it


const dockProvider: DockProvider = {
  title: "MY DOCK TITLE",
  id: "MY_UNIQUE_DOCK_ID",
  icon: "localhost:3000/icon.png"

  // set one or the other of the following two properties, but not both
  
  // default value false; set to true to keep user rearrangement state from persisting
  skipSavedDockProviderConfig: true

  // default value false; set to true to completely disable user configuration
  disableUserRearrangement: true
};

const dockRegistration = Dock.register(dockProvider);

Dock.show();

// update Dock configuration for the provider
const newConfig: DockProviderConfig = {
  buttons: [{
    tooltip: 'Updated button',
    iconUrl: 'https://www.openfin.co/favicon-32x32.png',
    action: {
      id: 'sampleButton1'
      }
  }]
};

await dockRegistration.updateDockProviderConfig(newConfig);

Dock configuration storage

By default, any Dock configuration is saved in local storage.
To save Dock configurations to your preferred storage location, you can write a WorkspacePlatformOverrideCallback to specify your preferred storage solution with overrides of the *DockProviderConfig methods of the WorkspacePlatformProvider interface.

Your override looks like:

import * as WorkspacePlatform from '@openfin/workspace-platform';
const overrideCallback: WorkspacePlatform.WorkspacePlatformOverrideCallback = async (
   WorkspacePlatformProvider
) => {
  class Override extends WorkspacePlatformProvider {
    getDockProviderConfig = async (id: string) => {
      // retrieve dock configuration by id from platfrom developer's custom storage.
    };
    saveDockProviderConfig = async (config: DockProviderConfigWithIdentity) => {
      // save dock configuration in platfrom developer's custom storage.
    };
  }
  return new Override();
};
await WorkspacePlatform.init({ overrideCallback });