Hooks
#
useActivePivotClientReact hook returning the ActivePivotClient at serverKey
.
useActivePivotClient(serverKey)
Argument | Type | Description |
---|---|---|
serverKey | string | undefined |
ActivePivotClient | undefined
Throws:ClientsNotFoundError when no clients are provided via ClientsProvider.
ActivePivotClientNotFoundError when serverKey
is defined but no ActivePivotClient is provided for this key via ClientsProvider.
#
useActivePivotClientsReact hook returning the map of all registered ActivePivotClients.
useActivePivotClients()
{ [serverKey: string]: ActivePivotClient; }
#
useActivityReact hook returning:
the value for the given activity key
a function to update this value
whether the activity is loading
useActivity(key)
Argument | Type | Description |
---|---|---|
key | T |
[Activity[T] | null, (value: Activity[T]) => void, { isLoading: boolean; }]
#
useConnectionStatusesReact hook returning the overall status of the connection with the registered ActivePivot clients.
useConnectionStatuses()
{ [serverKey: string]: ConnectionStatus; }
#
useContentClientReact hook returning the ContentClient.
useContentClient()
ClientsNotFoundError when no clients are provided via ClientsProvider.
ContentClientNotFoundError when no ContentClient is provided via ClientsProvider.
#
useDataModelReact hook returning the DataModel of the ActivePivot server identified by serverKey
.
useDataModel(serverKey)
Argument | Type | Description |
---|---|---|
serverKey | string | undefined |
DataModel | undefined
Throws:DataModelNotFoundError when serverKey
is defined but the data model could not be found.
#
useDataModelsReact hook returning the data models of all ActivePivot servers to which the client is connected.
useDataModels()
{ [serverKey: string]: DataModel; }
#
useDrillthroughColumnsReact hook returning the drillthrough columns for a given cube. Lazily fetches the columns on the server the first time this hook is invoked.
Returns:
the columns if they are loaded
isLoading
: a boolean indicating if the loading is in progresserror
: the error thrown while attempting to fetch the drillthrough columns (only returned if the drillthrough columns are missing because an error was thrown) Returnsundefined
IfserverKey
is undefined.
useDrillthroughColumns(serverKey, cubeName)
Argument | Type | Description |
---|---|---|
serverKey | string | undefined | |
cubeName | string |
[DrillthroughColumn[] | undefined, { isLoading: boolean; error?: Error; }] | undefined
#
useIsModalMountedHook returning whether a modal should be mounted/unmounted depending on whether it is visible. It allows to reset the state of a Modal declaratively, without losing Ant Design's close animation.
See https://github.com/activeviam/activeui-5/pull/1465\#issuecomment-862306468.
useIsModalMounted(isModalVisible)
Argument | Type | Description |
---|---|---|
isModalVisible | boolean |
boolean
For example:const ModalParent = () => { const [isModalVisible, setIsModalVisible] = useState(false); const isModalMounted = useIsModalMounted(isModalVisible); const handleModalClosed = () => {setIsModalVisible(false);}; return isModalMounted && <Modal isVisible={isModalVisible} onSubmit={handleModalClosed} onCancel={handleModalClosed} > <ModalChildren /> </Modal>}
#
useIsPresentingReact hook returning the current state of isPresenting.
useIsPresenting()
boolean
#
useMultiSelectionReact hook that handles multiple selection of items. It takes the initially selected ranges as argument. It returns:
the ranges of selected elements,
a callback to handle the selection event,
a callback to clear the selection.
The selection callback handles combining the selections using the Ctrl and Shift keys.
useMultiSelection(initiallySelectedRanges)
Argument | Type | Description |
---|---|---|
initiallySelectedRanges | { from: number; to: number; }[] |
{ selectedRanges: { from: number; to: number; }[]; onItemSelected: (index: number, event: MouseEvent<unknown, unknown>) => void; clearSelection: () => void; }
#
usePermissionReact hook returning:
the permission value for the given key
a function to update this permission when authenticated as a user with admin privileges
an object containing a property for whether the permissions are loading
usePermission(key)
Argument | Type | Description |
---|---|---|
key | T |
[Permissions[T], (value: Permissions[T]) => void, { isLoading: boolean; }]
#
usePersistedReact hook returning the value for the key
in the browser local storage and the function to update it.
usePersisted(key, initialValue)
Argument | Type | Description |
---|---|---|
key | string | |
initialValue | T |
[T | undefined, (newValue: T) => void]
#
useQueryReact hook returning the up-to-date Query corresponding to queryId
.
useQuery({ serverKey, queryId, })
Argument | Type | Description |
---|---|---|
{ serverKey, queryId, } | { serverKey?: string; queryId?: string; } |
#
useQueryResultSubscribes to a query's result. If queryId
is not provided, returns an empty result. If queryId
is provided: returns an up-to-date result. If queryId
and query
are provided and a query already exists for this serverKey
and queryId
: updates that query. Otherwise, registers query
within serverKey
.
useQueryResult({ serverKey, queryId, query, })
Argument | Type | Description |
---|---|---|
{ serverKey, queryId, query, } | { serverKey?: string; queryId?: string; query?: Query<MdxString>; } |
QueryResult<ResultType>
#
useSettingReact hook returning:
the setting value for the given key
a function to update this setting
an object containing a property for whether the settings are loading
useSetting(key)
Argument | Type | Description |
---|---|---|
key | T |
[Settings[T], (value: Settings[T]) => void, { isLoading: boolean; }]
#
useSwitchedWidgetStateReact Hook returning the switched widget state if switched or the original state if not switched.
useSwitchedWidgetState(widgetState, queryId)
Argument | Type | Description |
---|---|---|
widgetState | WidgetState | |
queryId | string |
WidgetState
#
useThemeReact hook returning the Theme.
useTheme()
#
useTreeReact hook returning the dashboards or widgets tree.
useTree(type)
Argument | Type | Description |
---|---|---|
type | T |
ContentRecord<DashboardMetaData | WidgetMetaData | FilterMetaData> | null
#
useUserReact hook returning the user from context.
useUser()
UserNotFoundError when no User is provided via UserProvider.
#
useUserGroupNamesReact hook returning the user group names from context.
useUserGroupNames()
UserGroupName[] | null
#
useUserNamesReact hook returning the provided user names from context.
useUserNames()
UserName[] | null
#
useWidgetNameReact Hook returning either widgetState.name if defined otherwise returns a translated initial name from the widget plugin.
useWidgetName(widgetState)
Argument | Type | Description |
---|---|---|
widgetState | AWidgetState |
string
#
useWidgetPluginKeysReact hook returning the keys of all the registered widget plugins.
useWidgetPluginKeys()
string[]
#
useWidgetPluginsReact hook returning the widget plugins corresponding to widgetKeys
.
useWidgetPlugins(widgetKeys)
Argument | Type | Description |
---|---|---|
widgetKeys | string[] |
#
useWidgetQueryReturns the widget's Query, impacted by the page and dashboard filters and the query contexts found in dashboardState
and paused when the widget is in an inactive dashboard page.
useWidgetQuery({ widgetState, dashboardState, pageKey, cube, ranges, })
Argument | Type | Description |
---|---|---|
{ widgetState, dashboardState, pageKey, cube, ranges, } | { widgetState: WidgetWithQueryState<MdxSelect | MdxDrillthrough>; dashboardState: DashboardState | undefined; pageKey?: string; cube: Cube; ranges?: Partial<{ [axisId in AxisId]: QueryRange; }>; } |