OpenFin Workspace API
    Preparing search index...

    Interface HomeProvider

    A CLI provider responds to search requests from Home UI. Exposes search features that are specifically supported by Home.

    Sample HomeProvider definition.

    Import required dependencies.

    import { Home, type HomeProvider } from '@openfin/workspace';
    

    Create provider object to configure Home.

    const provider: HomeProvider = {
    id: 'provider-id',
    title: 'Sample Home',
    icon: 'https://www.openfin.co/favicon-32x32.png',
    description: 'A short description of the Search Provider.',
    onResultDispatch: () => { } // Handle Result Dispatch
    onUserInput: () => { } // Handle User Input
    };

    Register home provider object.

    await Home.register(provider);
    

    Show Home.

    await Home.show();
    
    interface HomeProvider {
        clientAPIVersion?: string;
        commandCode?: string;
        description?: string;
        dispatchFocusEvents?: boolean;
        hidden?: boolean;
        icon: string;
        id: string;
        identity?: Identity_4;
        inputLandingPlaceholder?: string;
        inputPlaceholder?: string;
        listTitle?: string;
        logoUrl?: string;
        scoreOrder?: ScoreOrder;
        subHeader?: {
            icon?: string;
            subtitle?: string;
            title1?: string;
            title2?: string;
        };
        title: string;
        onResultDispatch?(result: DispatchedSearchResult): Promise<void>;
        onUserInput(
            req: HomeSearchListenerRequest,
            res: HomeSearchListenerResponse,
        ): Promise<HomeSearchResponse>;
    }

    Hierarchy (View Summary)

    Index
    clientAPIVersion?: string

    version of client SDK, set by the API

    commandCode?: string

    A keycode that can be used to interact with this Search Provider.

    description?: string

    A short description of the Search Provider.

    dispatchFocusEvents?: boolean

    If set, focusing on a search result will trigger onResultDispatch callback.

    hidden?: boolean

    A flag to indicate this provider will not be displayed as a command.

    icon: string

    An icon that a UI can display for the Search Provider.

    id: string

    A unique ID used to identify the search provider.

    identity?: Identity_4

    The OpenFin identity that registered this search provider.

    inputLandingPlaceholder?: string

    A placeholder text that would be put into the empty search field for the selected provider for home in landing mode.

    inputPlaceholder?: string

    The placeholder string to be displayed in a UI when targeting this specific Search Provider.

    listTitle?: string

    A title to display above the result list in a UI when targeting this specific Search Provider.

    logoUrl?: string

    Logo to show render when targeting this specific Search Provider.

    scoreOrder?: ScoreOrder

    The order to sort the score in. The default is ascending.

    subHeader?: {
        icon?: string;
        subtitle?: string;
        title1?: string;
        title2?: string;
    }

    Optional subheader configuration for the home landing page.

    Type Declaration

    • Optionalicon?: string

      URL of the icon to display in the subheader.

    • Optionalsubtitle?: string

      Subtitle text to display in the subheader.

    • Optionaltitle1?: string

      First title text to display in the subheader.

    • Optionaltitle2?: string

      Second title text to display in the subheader (renders on a new line).

    title: string

    A UI friendly title for the search provider.

    • Callback that is invoked when ever a search result returned by this provider is interacted with from a Workspace component. (clicked, pressed enter, hotkey pressed, etc.)

      import { getAvailableCommands } from './my-commands';

      const onResultDispatch = async(result: CLIDispatchedSearchResult): Promise<void> => {
      try {
      //Grab the command corresponding to the result
      const availableCommands = await getAvailableCommands();
      const commandToExecute = availableCommands.find((command) => command.key === result.key);

      if (commandToExecute != undefined) {
      await commandToExecute.action();
      }
      } catch (err) {
      //Handle the error
      log.error('Error trying to action show command %s', err, result.key);
      }
      }

      Parameters

      Returns Promise<void>

    • Function that is called when a search request is triggered due to user input.


      import { getAllData, getResultsByQuery } from './get-all-data';

      const onUserInput = async({ query }): Promise<CLISearchResponse> => {
      if (!query) {
      return getAllData();
      }

      // Provide an implementation to fetch query-filtered search results
      return getResultsByQuery(query);
      }

      Parameters

      Returns Promise<HomeSearchResponse>

      an object that contains the search results to render in the requesting Workspace component.