fix dashboard again

pull/106/head
dperolio 2 years ago
parent f0c90b5100
commit 49e456dc6a
No known key found for this signature in database
GPG Key ID: 4191689562D51409

@ -22,8 +22,8 @@ export default class Router extends Builtin {
await this.patchViews();
await this.patchSidebar();
await this.forceRouterUpdate();
vizality.api.routes.on(Events.VIZALITY_ROUTE_ADD, this.forceRouterUpdate);
vizality.api.routes.on('routeRemove', this.forceRouterUpdate);
$vz.api.routes.on(Events.VIZALITY_ROUTE_ADD, this.forceRouterUpdate);
$vz.api.routes.on('routeRemove', this.forceRouterUpdate);
}
/**
@ -31,8 +31,8 @@ export default class Router extends Builtin {
* @returns {void}
*/
stop () {
vizality.api.routes.off(Events.VIZALITY_ROUTE_ADD, this.forceRouterUpdate);
vizality.api.routes.off('routeRemove', this.forceRouterUpdate);
$vz.api.routes.off(Events.VIZALITY_ROUTE_ADD, this.forceRouterUpdate);
$vz.api.routes.off('routeRemove', this.forceRouterUpdate);
unpatch('vz-router-routes');
unpatch('vz-router-views');
unpatch('vz-router-sidebar');
@ -50,7 +50,7 @@ export default class Router extends Builtin {
try {
const { children } = findInReactTree(res, m => isArray(m.children) && m.children.length > 5);
children.push(
...vizality.api.routes.getAllRoutes()?.map(route => ({
...$vz.api.routes.getAllRoutes()?.map(route => ({
...children[0],
props: {
/**
@ -84,10 +84,10 @@ export default class Router extends Builtin {
if (!isArray(routes)) {
return;
}
routes[routes.length - 1].props.path = [
routes[routes.length - 2].props.path = [
...new Set(
routes[routes.length - 1]?.props?.path?.concat(
vizality.api.routes.getAllRoutes()?.map(route => `/vizality${route.path}`)
routes[routes.length - 2]?.props?.path?.concat(
$vz.api.routes.getAllRoutes()?.map(route => `/vizality${route.path}`)
)
)
];
@ -126,14 +126,14 @@ export default class Router extends Builtin {
* Add listeners for route changes and addon settings toggle actions.
*/
useEffect(() => {
vizality.api.settings
$vz.api.settings
.on(Events.VIZALITY_SETTING_UPDATE, handleSidebarCollapse);
Routes.listeners.add(forceUpdate);
/**
* Remove the listeners on unmount.
*/
return () => {
vizality.api.settings
$vz.api.settings
.removeListener(Events.VIZALITY_SETTING_UPDATE, handleSidebarCollapse);
Routes.listeners.delete(forceUpdate);
};
@ -145,15 +145,15 @@ export default class Router extends Builtin {
child.type = props => {
try {
let ret = Reflect.apply(oType, null, [ props ]);
if (vizality.api.routes.getLocation()?.pathname?.startsWith('/vizality')) {
if ($vz.api.routes.getLocation()?.pathname?.startsWith('/vizality')) {
/**
* Add and remove collapsed and expanded attributes based on the setting.
*/
ret.props.className = joinClassNames('vz-dashboard-sidebar', ret.props.className);
ret.props['vz-collapsed'] = vizality.settings.get('dashboardSidebarCollapse', false) && '';
ret.props['vz-expanded'] = !vizality.settings.get('dashboardSidebarCollapse', false) && '';
const rawPath = vizality.api.routes.getLocation().pathname.substring('vizality/'.length);
const route = vizality.api.routes.getAllRoutes()?.find(rte => rawPath.startsWith(rte.path));
ret.props['vz-collapsed'] = $vz.settings.get('dashboardSidebarCollapse', false) && '';
ret.props['vz-expanded'] = !$vz.settings.get('dashboardSidebarCollapse', false) && '';
const rawPath = $vz.api.routes.getLocation().pathname.substring('vizality/'.length);
const route = $vz.api.routes.getAllRoutes()?.find(rte => rawPath.startsWith(rte.path));
if (route && route.sidebar) {
const Sidebar = route.sidebar;
ret.props.children[0] = <Sidebar />;

Loading…
Cancel
Save