mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
feat: rename item sku to code.
feat: fix sidebar current tab issue.
This commit is contained in:
@@ -3,5 +3,5 @@ import React from 'react';
|
||||
export default function MenuItemLabel({
|
||||
text
|
||||
}) {
|
||||
return (<span class="bp3-menu-item-label">{ text }</span>);
|
||||
return (<span class="bp3-menu-item-labeler">{ text }</span>);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { Menu, MenuDivider } from '@blueprintjs/core';
|
||||
import React, { useMemo } from 'react';
|
||||
import { Menu, MenuDivider, Button } from '@blueprintjs/core';
|
||||
import { useHistory, useLocation } from 'react-router-dom';
|
||||
import sidebarMenuList from 'config/sidebarMenu';
|
||||
import Icon from 'components/Icon';
|
||||
@@ -16,16 +16,31 @@ export default function SidebarMenu() {
|
||||
const children = Array.isArray(item.children)
|
||||
? menuItemsMapper(item.children)
|
||||
: null;
|
||||
const isActive =
|
||||
(item.href && item.href === location.pathname) ||
|
||||
(item.children &&
|
||||
item.children.some((c) => c.href === location.pathname));
|
||||
|
||||
const matchPath = (pathname, path) => {
|
||||
return item.matchExact ? pathname === path : pathname.indexOf(path) !== -1;
|
||||
};
|
||||
const isActive = (item.children) ?
|
||||
item.children.some((c) => matchPath(location.pathname, c.href)) :
|
||||
(item.href && matchPath(location.pathname, item.href));
|
||||
|
||||
const handleItemClick = () => {
|
||||
if (item.href) {
|
||||
history.push(item.href);
|
||||
}
|
||||
};
|
||||
|
||||
const maybeRenderLabel = (item) => item.newTabHref ? (
|
||||
<Button
|
||||
className="menu-item__add-btn"
|
||||
icon={<Icon icon={'plus'} iconSize={16} />}
|
||||
onClick={(event) => {
|
||||
history.push(item.newTabHref);
|
||||
event.stopPropagation();
|
||||
}}
|
||||
/>
|
||||
) : null;
|
||||
|
||||
return item.spacer ? (
|
||||
<div class="bp3-menu-spacer"></div>
|
||||
) : item.divider ? (
|
||||
@@ -38,7 +53,7 @@ export default function SidebarMenu() {
|
||||
active={isActive}
|
||||
icon={<Icon icon={item.icon} iconSize={item.iconSize} />}
|
||||
text={item.text}
|
||||
label={item.label}
|
||||
label={maybeRenderLabel(item)}
|
||||
disabled={item.disabled}
|
||||
children={children}
|
||||
dropdownType={item.dropdownType || 'collapse'}
|
||||
|
||||
Reference in New Issue
Block a user