[Feat] make dashboard code cleaner

pull/104/head
V3L0C1T13S 2 years ago
parent a9a4e140e7
commit 131a099b2b
No known key found for this signature in database
GPG Key ID: CF6604FB86E0F7F8

@ -4,7 +4,7 @@
import { SettingsContextMenu } from '@vizality/components/vizality';
import { getModule, contextMenu } from '@vizality/webpack';
import { forceUpdateElement } from '@vizality/util/react';
import { forceUpdateElement, findInReactTree } from '@vizality/util/react';
import { patch, unpatch } from '@vizality/patcher';
import { Builtin } from '@vizality/entities';
import { Icon } from '@vizality/components';
@ -104,17 +104,17 @@ export default class Dashboard extends Builtin {
return;
}
res.props.children.props.children = [
...res.props.children.props.children.slice(0, 0),
const { children: list } = findInReactTree(res, (c) => c.channels);
list.unshift(
<LinkButton
icon={() => <Icon name='vizality' />}
route='/vizality'
text='Dashboard'
selected={vizality.api.routes.getLocation()?.pathname?.startsWith('/vizality')}
onContextMenu={evt => openContextMenu(evt, () => <SettingsContextMenu />)}
/>,
...res.props.children.props.children.slice(0)
];
/>
);
} catch (err) {
return this.error(this._labels.concat('_injectPrivateTab'), err);
}

Loading…
Cancel
Save