0.0.7 • Published 3 years ago
@clarabridge/react-studio-console v0.0.7
React Studio Console
This library consists of layout components from Unified Angular Components libruary that have been adapted for usage in ReactJS.
Installation
React Layout Components can be installed as an npm package:
$ npm i @clarabridge/react-studio-consoleBasic usage
import { Header, Sidebar } from @clarabridge/react-studio-console
Available Options
Sidebar
The available options are:
className(String) - Optional, class names applied to theSidebarcomponent, defaults to empty stringlinks(URLListItem[]) - Optional, list of links
interface URLLinkItem {
name: string;
url: string | null;
children?: URLListItem[];
callback?: never;
collapsed?: boolean;
}locale(String) - Optional, locale name, defaults toENsidebarUrl(String) - Optional, the URL will be used to get thelinksfrom the server, default to/api/sidebarshowSidebar(Boolean) - Required, status of theSidebarcomponentshouldHaveKeyboardFocus(Boolean) - Required, trigger of keyboard focustoggleSidebar(() => void) - Required, callback for toggling theSidebarcomponentonLoading((isLoading: boolean) => void) - Optional, callback for processing loading state of theSidebarcomponent. When theSidebarcomponent is mounted, a callback with atruevalue will be called, when the request for getting the list of links is comleted, the callback will be called with afalsevalue
Header
The available options are:
className(String) - Optional, class names applied to theHeadercomponent, defaults to empty stringshowSidebar(Boolean) - Required, status of theSidebarcomponenttoggleSidebarButtonLabel(String) - Optional, label for toggleSidebarbutton , defaults toXM Discover NavigationuseAppName(Boolean) - Optional, adds a section with theapplicationNameof the application to theHeadercomponentapplicationName(String) - Optional, the name of the application, defaults to empty stringuseAccountSwitcher(Boolean) - Optional, adds a section with the Master Account swither. If used, when theHeadercomponent is mounted to the applicaton, the next requests will be made to get themaster accountsand thecurrent master accountfrom the server, default APIs:GET /api/user/master-accountGET /api/user/master-accounts
masterAccountUrl(String) - Optional, the URL will be used to get thecurrent master accountfrom the server, default to/api/user/master-accountmasterAccountsUrl(String) - Optional, the URL will be used to get themaster accountsfrom the server, default to/api/user/master-accountsswitchMasterAccountUrl(String) - Optional, the URL will be used when the User switches master account on the server, default API:POST /api/user/master-accounts/switch-towith the next query parameters:masterAccountIdandmasterAccountName. When a successful response is received from the server, the page will automatically reload, which will allow you to change the access scopes of the application
useWorkspaceSwitcher(Boolean) - Optional, adds a section with the Workspace swither. If used, when theHeadercomponent is mounted to the applicaton, the next request will be made to get theworkspacesfrom the server, default API:GET /api/user/workspacesworkspacesUrl(String) - Optional, the URL will be used to get theworkspacesfrom the server, default to/api/user/workspacesuseUserMenu(Boolean) - Optional, adds a section with the User menu. If used, when theHeadercomponent is mounted to the applicaton, the next request will be made to get theUserfrom the server, default API:GET /api/useruserUrl(String) - Optional, the URL will be used to get theUserfrom the server, default to/api/useruserSettings(UserSettings[]) - Optional, the list of options that uses in theUserMenu
interface UserSettings {
section: string;
options: {
label: string;
url?: string;
action?: string;
}[]
}toggleSidebar(() => void) - Required, callback for toggling theSidebarcomponenttoggleSidebarFromKeyboard(() => void) - Required, callback for toggling theSidebarcomponent from keyboardonLoading((isLoading: boolean) => void) - Optional, callback for processing loading state of theHeadercomponent. When theHeadercomponent is mounted, a callback with atruevalue will be called, when all retrieve requests are completed (depending on the configuration), the callback will be called with afalsevalueonInternalDataLoading((isLoading: boolean) => void) - Optional, callback for processing loading state of the internal data depends on selection(applicable for loading projects depending on the selected workspace).onSwitchWorkspace((workspace: AccountOption, projects?: Project[], selectedProject?: Project) => void) - Optional, callback for getting a selected workspace, and loading the corresponding list of projects for the selected workspace, and potentially the recently selected projectonSwitchMasterAccount((masterAccount: AccountOption)) - Optional, callback for getting a selected master account, by default will be emitted current master account which stores in the server.
interface AccountOption {
id: number;
name: string;
}
interface Project {
id: number;
name: string;
}