Interface AppRootStore

The interface for the application's root store.

Use the useAppRootStore() hook to access the application's root store.

Hierarchy

  • AppRootStore

Implemented by

Properties

allLocales: string[]

All the locales available to use.

const store = useAppRootStore()

console.log(`All the supported locales are ${store.allLocales}`)
app: undefined | { app: App<AppStore>; id: string; name: string; view: AppView }

Returns

The current main application being rendered by the shell or undefined if there is no application view loaded.

apps: App<AppStore>[]

The currently installed applications.

currentUser?: HDict

The record for for the currently logged in user.

history: CustomHistory

The shell's history for the main view.

const store = useAppRootStore()

store.history.pushState({ query: 'site and geoCity == "Brighton and Hove"' })
historySidebar: CustomHistory

The shell's history for the sidebar view.

const store = useAppRootStore()

store.history.pushState({ query: 'site and geoCity == "Brighton and Hove"' })
locale: string

The current locale being used.

const store = useAppRootStore()

console.log(`The current user's locale is ${store.locale}`)
project: string

The current loaded project.

Setting this will change the project currently being used.

const store = useAppRootStore()
console.log(`The project name is ${store.project}`)

// Select a different project...
store.project = 'foo'
sidebar: undefined | { app: App<AppStore>; id: string; name: string; view: AppView }

Returns

The current sidebar application being rendered by the shell or undefined if there is no sidebar application view loaded.

sidebarOpen: boolean

A boolean flag used to toggle whether the sidebar is open or not.

Changing this will toggle whether the sidebar is showing or not.

const store = useAppRootStore()
if (store.sidebarOpen) {
...
}

// Close the sidebar...
store.sidebarOpen = false
target: string

The current context's target. An empty string means no target is currently selected.

Changing this will also change the target.

const store = useAppRootStore()

console.log(`The current target is ${store.target}`)

// Change the target...
const ref = HRef.make('p:foo:sometarget')
store.target = ref.value
targetSidebar: string

The current context's target for the sidebar. An empty string means the sidebar's target will fallback to the main target.

Changing this will also change the target for the sidebar.

  • ``` const store = useAppRootStore()

console.log(The current target is ${store.targetSidebar})

// Change the target for the sidebar... const ref = HRef.make('p:foo:sometarget') store.targetSidebar = ref.value

Methods

  • Return true if the current user has the specified access to an application.

    Parameters

    • app: string

      The application's id.

    • access: AppAccessLevel

      The application's access level.

    Returns boolean

  • Opens an application's view in the main view.

    const store = useAppRootStore()

    // Open an app's main view
    store.open('finUi.myApp.main', { param: 'some param' })

    Parameters

    • appViewId: string

      The id of the application view to open. This is the application's full id i.e. myApp.myView.

    • Optional state: Record<string, unknown>

      The state to load for the application.

    Returns void

  • Opens an application in the sidebar view.

    const store = useAppRootStore()

    // Open an app's main view
    store.open('finUi.myApp.main', { param: 'some param' })

    Parameters

    • appViewId: string

      The id of the application view to open. This is the application's full id i.e. myApp.mySidebarView.

    • Optional state: Record<string, unknown>

      The state to load for the application.

    Returns void

  • Post a message to the system. The message will be received via an application's onMessage callback. Please note, an application also needs to declare the messages its interested in via messages.

    const store = useAppRootStore()

    store.postAppMessage('newMessage', { data: 'some data' })

    Parameters

    • message: string

      The message to dispatch.

    • Optional params: Record<string, unknown>

      The parameters for the message.

    Returns void

  • Register quicklinks for the current application view.

    This is typically called in the main application's first render call...

    ...
    render(props: AppProps) {
    const store = useAppRootStore()
    useEffect(() => {
    store.registerQuicklinks({
    foo: {
    icon(): JSX.Element { return <MyIcon /> },
    invoke() { console.log('Invoked quicklink') }
    }
    })
    }, [])
    ...
    }

    Parameters

    • quicklinks: Record<string, Quicklink>

      The quicklinks to add.

    Returns void

  • Register dynamic sidebar application views. This is used to dynamically add temporary sidebar application views at runtime. These sidebar views are registered from a main application view. They are only available whilst the the current main application view is open.

    ...
    render(props: AppProps) {
    const store = useAppRootStore()
    useEffect(() => {
    store.registerSidebars({
    myDynamicSidebar: {
    icon(): JSX.Element { return <MyIcon /> },
    render(): JSXElement { return <Foo /> }
    }
    })
    }, [])
    ...
    }

    Parameters

    • sidebars: Record<string, AppView>

      The sidebar views to add.

    Returns void

  • Unregister quicklinks for the current application view.

    Please note, quicklinks are automatically unregistered when the current application view unloads.

    ``` ... const quicklinks = { foo: { icon(): JSX.Element { return }, invoke() { console.log('Invoked quicklink') } } }) ... render(props: AppProps) { const store = useAppRootStore() useEffect(() => { store.registerQuicklinks(quicklinks) }, []) ... <Button onClick={() => store.unregisterQuicklinks(quicklinks)}>Remove quicklinks }

    @param quicklinks The quicklinks to remove.

    Parameters

    • quicklinks: string[] | Record<string, Quicklink>

    Returns void

  • Unregister sidebars for an application. Only dynamic sidebars that were previously added via registerSidebars will be unregistered.

    Please note, all dynamic sidebars are automatically unregistered when the current application view unloads.

    ...
    const sidebars = {
    myDynamicSidebar: {
    icon(): JSX.Element { return <MyIcon /> },
    render(): JSXElement { return <Foo /> }
    }
    }
    ...
    render(props: AppProps) {
    const store = useAppRootStore()
    useEffect(() => {
    store.registerSidebars(sidebars)
    }, [])
    ...
    <Button onClick={() => store.unregisterSidebars(sidebars)}>Remove sidebars</Button>
    }

    Parameters

    • sidebars: string[] | Record<string, AppView>

      The sidebars to remove.

    Returns void

Generated using TypeDoc