Hooks
useActivePivotClient
React hook returning the ActivePivotClient at serverKey
.
useActivePivotClient(serverKey)
Argument | Type | Description |
---|---|---|
serverKey | string | undefined |
Returns:
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.
useActivePivotClients
React hook returning the map of all registered ActivePivotClients.
useActivePivotClients()
Returns:
{ [serverKey: string]: ActivePivotClient; }
useActivity
React 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 |
Returns:
[Activity[T] | null, (value: Activity[T]) => void, { isLoading: boolean; }]
useConnectionStatuses
React hook returning the overall status of the connection with the registered ActivePivot clients.
useConnectionStatuses()
Returns:
{ [serverKey: string]: ConnectionStatus; }
useContentClient
React hook returning the ContentClient.
useContentClient(options)
Argument | Type | Description |
---|---|---|
options | { throwIfMissing: boolean; } |
Returns:
ContentClient | undefined
Throws:
ClientsNotFoundError when no clients are provided via ClientsProvider, unless throwIfMissing
is set to false.
ContentClientNotFoundError when no ContentClient is provided via ClientsProvider, unless throwIfMissing
is set to false.
useCube
React hook returning a cube. Defaults serverKey
to the key of the first provided server, when props.widgetState.serverKey
is not defined. Defaults cube
to the first cube of the target server, when props.widgetState.query.mdx
does not include a cube name and no widgetState.initialCubeName
is defined.
useCube({
initialCubeName,
serverKey,
...widgetState
})
Argument | Type | Description |
---|---|---|
{ initialCubeName, serverKey, ...widgetState } | T |
Returns:
{ cube: Cube; dataModel: DataModel; serverKey: string; }
Throws:
- DataModelNotFoundError if the data model is not loaded yet. - CubeNotFoundError if the data model does not contain any cube with the specified name. - EmptyDataModelError if the data model was loaded but does not contain any cube.
useDataModel
React hook returning the DataModel of the ActivePivot server identified by serverKey
.
useDataModel(serverKey)
Argument | Type | Description |
---|---|---|
serverKey | string | undefined |
Returns:
DataModel | undefined
Throws:
DataModelNotFoundError when serverKey
is defined but the data model could not be found.
useDataModels
React hook returning the data models of all ActivePivot servers to which the client is connected.
useDataModels(options)
If "options.includeLoadingAndErroredDataModels" is set to false, only the successfully loaded data models will be returned.
Argument | Type | Description |
---|---|---|
options | { includeLoadingAndErroredDataModels: true; } |
Returns:
DataModels<true>
useIsModalMounted
Hook 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/atoti-ui/pull/1465\#issuecomment-862306468.
useIsModalMounted(isModalVisible)
Argument | Type | Description |
---|---|---|
isModalVisible | boolean |
Returns:
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>
}
useIsPresenting
React hook returning the current state of isPresenting.
useIsPresenting()
Returns:
boolean
useJwt
React hook returning the JWT allowing to authenticate the communication with the servers.
useJwt()
Returns:
string
useLogout
React hook returning a callback to logout the user.
useLogout()
Returns:
(() => Promise<void>) | null
useMenuItemCreateFolder
React hook returning a menu item to create a folder.
useMenuItemCreateFolder(props)
Argument | Type | Description |
---|---|---|
props | FileListMenuItemProps |
Returns:
MenuItemType | null
useMenuItemDeleteFilesAndFolders
React hook returning a menu item to delete several files and folders.
useMenuItemDeleteFilesAndFolders(props)
Argument | Type | Description |
---|---|---|
props | FileListMenuItemProps |
Returns:
MenuItemType | null
useMenuItemExportFolder
React hook returning a menu item to export the content of a file, a folder or a combination of files and folders.
useMenuItemExportFolder(props)
Argument | Type | Description |
---|---|---|
props | FileListMenuItemProps |
Returns:
MenuItemType | null
useMenuItemImportFolder
React hook returning a menu item to import a folder into another folder.
useMenuItemImportFolder(props)
Argument | Type | Description |
---|---|---|
props | FileListMenuItemProps |
Returns:
MenuItemType | null
useMenuItemMakeCopyOfFile
React hook returning a menu item to make a copy of a file.
useMenuItemMakeCopyOfFile(props)
Argument | Type | Description |
---|---|---|
props | FileListMenuItemProps |
Returns:
MenuItemType | null
useMenuItemMoveFilesAndFolders
React hook returning a menu item to move files and folders into a folder.
useMenuItemMoveFilesAndFolders({
onAfterSubmit,
selectedFilesAndFolders: selectedFilesAndFoldersOrServer,
pathToParentFolder,
contentTree,
contentType,
})
Argument | Type | Description |
---|---|---|
{ onAfterSubmit, selectedFilesAndFolders: selectedFilesAndFoldersOrServer, pathToParentFolder, contentTree, contentType, } | FileListMenuItemProps |
Returns:
MenuItemType | null
useMenuItemRenameFileOrFolder
React hook returning a menu item to rename a folder or a file.
useMenuItemRenameFileOrFolder(props)
Argument | Type | Description |
---|---|---|
props | FileListMenuItemProps |
Returns:
MenuItemType | null
useMenuItemShareFileOrFolder
React hook returning a menu item to edit permissions for the underlying file or folder.
useMenuItemShareFileOrFolder({
selectedFilesAndFolders,
pathToParentFolder,
contentType,
})
Argument | Type | Description |
---|---|---|
{ selectedFilesAndFolders, pathToParentFolder, contentType, } | FileListMenuItemProps |
Returns:
MenuItemType | null
useOnDataModelClicked
React hook accepting a listener on data model tree clicks. Calls this listener each time a node is clicked in the data model tree.
useOnDataModelClicked(listener)
Argument | Type | Description |
---|---|---|
listener | DataModelClickListener |
Returns:
void
useOnNewCalculatedMeasureButtonClicked
React hook accepting a listener on clicks on the "new calculated measure" button in the data model tree. Calls this listener each time the button is clicked.
useOnNewCalculatedMeasureButtonClicked(listener)
Argument | Type | Description |
---|---|---|
listener | () => void |
Returns:
void
useOnNewKpiButtonClicked
React hook accepting a listener on clicks on the "new KPI" button in the data model tree. Calls this listener each time the button is clicked.
useOnNewKpiButtonClicked(listener)
Argument | Type | Description |
---|---|---|
listener | () => void |
Returns:
void
usePermission
React 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 indicating whether the permissions are loading and whether the permission has explicitly been set
usePermission(key)
Argument | Type | Description |
---|---|---|
key | T |
Returns:
[ Permissions[T], (value: Permissions[T]) => Promise<void>, { isLoading: boolean; isSet: boolean; } ]
usePersisted
React 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 |
Returns:
[T | undefined, (newValue: T) => void]
usePositionInDashboard
Returns the PositionInDashboard of the widget in the dashboard.
usePositionInDashboard()
Returns:
PositionInDashboard | null
useQuery
React hook returning the up-to-date Query corresponding to queryId
.
useQuery({
serverKey,
queryId,
})
Argument | Type | Description |
---|---|---|
{ serverKey, queryId, } | { serverKey?: string; queryId?: string; } |
Returns:
useQueryResult
React hook allowing to subscribe to a query's result. If query
is provided, also runs the query.
useQueryResult({
serverKey,
queryId,
query,
})
Argument | Type | Description |
---|---|---|
{ serverKey, queryId, query, } | { serverKey?: string; queryId?: string; query?: Query<MdxString>; } |
Returns:
QueryResult<ResultType>
Remarks:
If queryId
is not provided, the subscription is canceled and an empty result is returned.
useSetting
React 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 |
Returns:
[ Settings[T], (value: Settings[T]) => Promise<void>, { isLoading: boolean; } ]
useSwitchedWidgetState
React 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 |
Returns:
WidgetState
useTheme
React hook returning the Theme.
useTheme()
Returns:
useTree
React hook returning the dashboards or widgets tree.
useTree(type)
Argument | Type | Description |
---|---|---|
type | T |
Returns:
ContentRecord<DashboardMetaData | WidgetMetaData | FilterMetaData> | null
useUser
React hook returning the User.
useUser(options)
Argument | Type | Description |
---|---|---|
options | { throwIfMissing: boolean; } |
Returns:
User | undefined
Throws:
UserNotFoundError when no User is provided via UserProvider, unless throwIfMissing
is set to false.
useUserNames
React hook returning the provided usernames from context.
useUserNames()
Returns:
UserName[] | null
useUserRoles
React hook returning the user roles from context.
useUserRoles()
Returns:
UserRole[] | null
useWidgetName
React Hook returning either widgetState.name if defined otherwise returns a translated initial name from the widget plugin.
useWidgetName(widgetState)
Argument | Type | Description |
---|---|---|
widgetState | AWidgetState |
Returns:
string
useWidgetPluginKeys
React hook returning the keys of all the registered widget plugins.
useWidgetPluginKeys()
Returns:
string[]
useWidgetPlugins
React hook returning the widget plugins corresponding to widgetKeys
.
useWidgetPlugins(widgetKeys)
Argument | Type | Description |
---|---|---|
widgetKeys | string[] |
Returns:
useWidgetQueryResult
React hook running the widget's Query, impacted by the user/dashboard/page filters and query contexts, and returning its result. When the widget is in an inactive dashboard page or deferred updates are enabled: - The query is paused if it was in real-time mode. - Updates to the query on the client side are not forwarded to the server.
useWidgetQueryResult({
serverKey,
queryId,
widgetState,
dashboardState,
pageKey,
cube,
queryRanges,
isDeferred,
})
Argument | Type | Description |
---|---|---|
{ serverKey, queryId, widgetState, dashboardState, pageKey, cube, queryRanges, isDeferred, } | { serverKey?: string; queryId?: string; widgetState: WidgetWithQueryState<MdxType>; dashboardState?: DashboardState; pageKey?: string; cube: Cube; queryRanges?: Partial<{ [axisId in AxisId]: QueryRange; }>; isDeferred?: boolean; } |
Returns:
QueryResult<MdxType extends MdxSelect ? CellSet : DrillthroughResult>