import { type CustomButtonConfig, type CustomDropdownConfig } from '../../../common/src/api/action'; import { type RegistrationMetaInfo } from '../../../client-api/src/shapes/common'; import { TaskbarIcon } from '../../../client-api-platform/src/shapes'; import { type ProviderInfo } from './provider'; /** * Allows you to hide buttons for different Workspace components in the Dock UI. * By default, all components are shown. * * @deprecated Use {@link WorkspaceButtonsConfig} instead. To migrate to the new configuration, any buttons that you wish to hide should be omitted from the `buttons` array. * * @example Hide all Workspace component buttons in the Dock UI. * ```ts * const workspaceComponentButtonOptions: WorkspaceComponentButtonOptions = { * hideHomeButton: true, * hideWorkspacesButton: true, * hideNotificationsButton: true, * hideStorefrontButton: true * } * ``` */ export interface WorkspaceComponentButtonOptions { /** * Set to true to hide the Workspaces button from the Dock UI. * @default false. */ hideWorkspacesButton?: boolean; /** * Set to true to hide the Home button from the Dock UI. * @default false. */ hideHomeButton?: boolean; /** * Set to true to hide the Notifications button from the Dock UI. * @default false. */ hideNotificationsButton?: boolean; /** * Set to true to hide the Storefront button from the Dock UI. * @default false. */ hideStorefrontButton?: boolean; } /** * The names of the Dock button types you can add and customize. * A dropdown button presents a list of options the user can choose from. * An action button initiates a single task or action only. */ export declare enum DockButtonNames { ActionButton = "ActionButton", DropdownButton = "DropdownButton" } /** * Configuration of a dock action button * When you add a custom button to the Dock, you must also provide details about the custom action. * * ```ts * const sampleDockButton: DockButtonConfig = { * tooltip: 'Sample Button 1', * iconUrl: 'https://www.openfin.co/favicon-32x32.png', * action: { * id: 'sampleButton1' * } * } * ``` */ export interface DockButtonConfig extends CustomButtonConfig { type?: DockButtonNames.ActionButton; } /** * Configuration of a dock dropdown button * When you add a dropdown button to the Dock, you must also specify the buttons to display in the dropdown. * * ```ts * const sampleDropdownButton1: DockDropdownConfig = { * type: DockButtonNames.DropdownButton, * tooltip: 'Sample Dropdown Button', * iconUrl: 'https://www.openfin.co/favicon-32x32.png', * options: [ * { * tooltip: 'Dropdown Button 1', * iconUrl: 'https://www.openfin.co/favicon-32x32.png', * action: { * id: 'dropdownButton1', * customData: 'dropdownButton1 clicked', * }, * }, * { * tooltip: 'Dropdown Button 2', * iconUrl: 'https://www.openfin.co/favicon-32x32.png', * action: { * id: 'dropdownButton2', * customData: 'dropdownButton2 clicked', * }, * }, * { * tooltip: 'Button with sub-options', * options: [ * { * tooltip: 'Nested button 1', * iconUrl: 'https://www.openfin.co/favicon-32x32.png', * action: { * id: 'nestedButton1', * customData: 'nestedButton1 clicked', * }, * }, * ], * }, * ], * }; * ``` */ export interface DockDropdownConfig extends CustomDropdownConfig { type: DockButtonNames.DropdownButton; } /** * Dock button types */ export type DockButton = { /** * Optional button identifier, if not provided will be automatically generated by the provider */ id?: string; /** * Specifies button context menu, if present and has one of the options enabled, the button will have a context menu on right click. */ contextMenu?: { removeOption?: boolean; }; } & (DockButtonConfig | DockDropdownConfig); /** * The names of the buttons for the workspace components on the Dock. * * Used in {@link WorkspaceButtonsConfig}. */ export type WorkspaceButton = 'switchWorkspace' | 'home' | 'notifications' | 'store'; /** * Controls the visibility as well as the order of buttons for workspace components on the Dock. * * To omit a button from the Dock UI, simply omit it from the array. * * The array must not contain duplicate values. Any duplicate values will be removed. * * @example Hide the Home button and move the Notifications button to the first position. * ```ts * const workspaceButtonsConfig: WorkspaceButtonsConfig = [ * 'notifications', * 'switchWorkspace', * 'store' * ]; * ``` * * @example Hide all of the workspace buttons. * * ```ts * const workspaceButtonsConfig: WorkspaceButtonsConfig = []; * ``` */ export type WorkspaceButtonsConfig = WorkspaceButton[]; /** * Configuration for the Dock provider. */ export interface DockProviderConfig { /** * Controls the visibility of buttons for workspace components on the Dock. * All components are visible by default, but you can hide any of them. * * @default - All components are visible. `['switchWorkspace', 'home', 'notifications', 'store']` */ workspaceComponents?: WorkspaceComponentButtonOptions | WorkspaceButtonsConfig; /** * Buttons for platform-specific custom actions to display on the Dock. */ buttons?: DockButton[]; /** * If true, the user will not be able to rearrange the buttons on the Dock. * * @default false */ disableUserRearrangement?: boolean; /** * A UI friendly title for the provider platform. */ title: string; /** * Icon for the provider. */ icon: string | TaskbarIcon; } export interface DockProviderConfigWithIdentity extends ProviderInfo, DockProviderConfig { } /** *

Sample DockProvider definition.

* * The icon for `DockProvider` must be in a raster image format. An SVG is not processed. * * Import required dependencies. * ```ts * import { CustomDropdownItemActionPayload, init } from "@openfin/workspace-platform"; * import { Dock, type DockProvider, DockButtonNames } from '@openfin/workspace'; * ``` * * Create provider object to pass to the static `register` function of the `Dock` type. * * ```ts * const provider: DockProvider = { * id: 'provider-id', * title: 'Sample Dock', * icon: 'https://www.openfin.co/favicon-32x32.png', * buttons: [ * { * tooltip: 'Sample Button 1', * iconUrl: 'https://www.openfin.co/favicon-32x32.png', * action: { * id: 'sampleButton1', * }, * }, * { * type: DockButtonNames.DropdownButton, * tooltip: 'Sample Dropdown Button', * iconUrl: 'https://www.openfin.co/favicon-32x32.png', * options: [ * { * tooltip: 'Dropdown Button 1', * iconUrl: 'https://www.openfin.co/favicon-32x32.png', * action: { * id: 'dropdownButton1', * customData: 'dropdownButton1 clicked', * }, * }, * { * tooltip: 'Dropdown Button 2', * iconUrl: 'https://www.openfin.co/favicon-32x32.png', * action: { * id: 'dropdownButton2', * customData: 'dropdownButton2 clicked', * }, * }, * { * tooltip: 'Button with sub-options', * options: [ * { * tooltip: 'Nested button 1', * iconUrl: 'https://www.openfin.co/favicon-32x32.png', * action: { * id: 'nestedButton1', * customData: 'nestedButton1 clicked', * }, * }, * ], * }, * ], * }, * ], * }; * ``` * * When a Dock button is clicked, the `action` object is passed to the `customActions` function defined as defined in the Workspace Platform `init` function. * * Initialize your Workspace Platform with ``customActions`` to be invoked by dock dropdown. * *```ts * await init({ * browser: {}, * customActions: { * "dropdownButton1": async (payload: CustomDropdownItemActionPayload) => { * alert(payload.customData) * }, * "dropdownButton2": async (payload: CustomDropdownItemActionPayload) => { * alert(payload.customData) * } * } * }); *``` * * Register Dock ``provider`` object. * * ```ts * await Dock.register(provider); * ``` * Show Dock. * * ```ts * await Dock.show(); * ``` */ export interface DockProvider extends DockProviderConfigWithIdentity { /** * By default, the Dock will save the user's configuration and restore it on the next launch. * * If true, the currently stored configuration will be ignored and the Dock will use the configuration provided by the provider. * * @default false */ skipSavedDockProviderConfig?: boolean; } /** * Return type from the Dock registration call. */ export interface DockProviderRegistration extends RegistrationMetaInfo { /** * Updates the Dock configuration. * * @param request The new Dock configuration. * @returns Promise that resolves when the update completes. * * @example Update the Dock configuration. This example requires that you have already registered a Dock provider. * * ```ts * import { Dock, type DockProviderConfig } from '@openfin/workspace'; * * const newConfig: DockProviderConfig = { * buttons: [ * { * tooltip: "Sample Button 1", * iconUrl: "https://www.openfin.co/favicon-32x32.png", * action: { * id: "sampleButton1", * }, * }, * ], * }; * * await dockProviderRegistration.updateDockProviderConfig(newConfig); * ``` * */ updateDockProviderConfig: (request: DockProviderConfig) => Promise; }