API Reference

JopiUiApplication

Documentation for the JopiUiApplication class.

JopiUiApplication

The JopiUiApplication class is the central manager for the client-side UI application. It handles user session information, role checks, event management, and dynamic object registry.

It is designed to be initialized via your plugin's uiInit.tsx logic.

Accessing the Instance

You can retrieve the global singleton instance using:

import { getDefaultJopiUiApplication } from "jopijs/ui";
const app = getDefaultJopiUiApplication();

User & Roles

getUserInfos()

Returns the current user's information (if logged in), including roles and other metadata.

getUserRoles()

Returns an array of roles assigned to the current user. Returns an empty array if not logged in.

userHasAllRoles(roles)

Checks if the current user possesses all the specified roles.

userHasOneOfThisRoles(roles)

Checks if the current user possesses at least one of the specified roles.

ifUserHasAllRoles(roles, callback) / ifUserHasOneOfThisRoles(roles, callback)

Executes the callback function only if the role condition is met. The callback receives the UiUserInfos object.

ifUserLoggedIn(callback)

Executes the callback if a user is currently logged in.

ifNotUserLoggedIn(callback)

Executes the callback if no user is logged in.

UI Initialization

addUiInitializer(priority, initializer)

Registers a callback to be executed during the UI initialization phase. On the server side, this runs for each page. On the browser, it runs on refresh / initial load.

Icon Management

resolveIcon(iconName, icon)

Registers a React component as an icon for a specific name.

getIconFromName(iconName)

Retrieves the React component associated with an icon name.

addIconResolved(resolver)

Registers a custom resolver function that can dynamically return icon components based on a name.

Utilities

getCurrentURL()

Returns the current page URL.

mustRemoveTrailingSlashes

A flag indicating if trailing slashes should be removed from URLs.

events

Access the global EventGroup for the application, allowing you to subscribe to and emit app-wide events.