Class DevAppRootStore

A simple application root store used for development/testing purposes.

Hierarchy

  • DevAppRootStore

Implements

Constructors

Properties

currentAllLocales: string[] = []
currentApp?: { app: App<AppStore>; id: string; name: string; view: AppView }

Type declaration

currentApps: App<AppStore>[] = []
currentLocale: string = ''
currentSidebar?: { app: App<AppStore>; id: string; name: string; view: AppView }

Type declaration

currentUserDict: undefined | HDict = undefined
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"' })
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'
sidebarOpen: boolean = false

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

Accessors

  • get allLocales(): string[]
  • All the locales available to use.

    const store = useAppRootStore()

    console.log(`All the supported locales are ${store.allLocales}`)

    Returns string[]

  • get locale(): string
  • The current locale being used.

    const store = useAppRootStore()

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

    Returns string

Methods

  • 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' })

    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' })

    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' })

    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') }
    }
    })
    }, [])
    ...
    }

    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 /> }
    }
    })
    }, [])
    ...
    }

    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.

    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>
    }

    Returns void

Generated using TypeDoc