import { HookEnableParam } from '../../../shared/hooks/types'; import { WidgetModel } from './widget-model'; /** * Parameters for {@link useGetWidgetModel} hook. */ export interface GetWidgetModelParams extends HookEnableParam { /** * Identifier of the dashboard that contains the widget */ dashboardOid: string; /** * Identifier of the widget to be retrieved */ widgetOid: string; } /** * States of a widget model load. */ export type WidgetModelState = WidgetModelLoadingState | WidgetModelErrorState | WidgetModelSuccessState; /** * State of a widget model that is loading. */ export type WidgetModelLoadingState = { /** Whether the widget model is loading */ isLoading: true; /** Whether the widget model load has failed */ isError: false; /** Whether the widget model load has succeeded */ isSuccess: false; /** Error, if one occurred */ error: undefined; /** Widget model, if the load succeeded */ widget: WidgetModel | undefined; /** Loading status */ status: 'loading'; }; /** * State of a widget model load that has failed. */ export type WidgetModelErrorState = { /** Whether the widget model is loading */ isLoading: false; /** Whether the widget model load has failed */ isError: true; /** Whether the widget model load has succeeded */ isSuccess: false; /** Error, if one occurred */ error: Error; /** Widget model, if the load succeeded */ widget: undefined; /** Loading status */ status: 'error'; }; /** * State of a widget model load that has succeeded. */ export type WidgetModelSuccessState = { /** Whether the widget model is loading */ isLoading: false; /** Whether the widget model load has failed */ isError: false; /** Whether the widget model load has succeeded */ isSuccess: true; /** Error, if one occurred */ error: undefined; /** Widget model, if the load succeeded */ widget: WidgetModel; /** Loading status */ status: 'success'; }; /** * React hook that retrieves an existing widget model from a Fusion instance. * * **Note:** Widget extensions based on JS scripts and add-ons in Fusion are not supported. * * ## Example * * Retrieve a widget model and use it to populate a `Chart` component * *