@openmrs/esm-extensions
Version:
Coordinates extensions and extension points in the OpenMRS Frontend
28 lines (27 loc) • 987 B
JavaScript
import { createGlobalStore } from "@openmrs/esm-state";
/** @internal */ export const leftNavStore = createGlobalStore('left-nav', {
slotName: null,
basePath: window.spaBase,
mode: 'normal'
});
/**
* Sets the current left nav context. Must be paired with {@link unsetLeftNav}.
*
* @deprecated Please use {@link useLeftNav} instead. This function will be made internal in a future release.
*/ export function setLeftNav({ name, basePath, mode, componentContext }) {
leftNavStore.setState({
slotName: name,
basePath,
mode: mode ?? 'normal',
componentContext
});
}
/**
* Unsets the left nav context if the current context is for the supplied name.
*
* @deprecated Please use {@link useLeftNav} instead. This function will be made internal in a future release.
*/ export function unsetLeftNav(name) {
if (leftNavStore.getState().slotName === name) {
leftNavStore.setState(leftNavStore.getInitialState(), true);
}
}