2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-05-30 21:25:36 +00:00

[UI] Fix navigation tabs (#12037)

* [UI] Fix navigation tabs

- Better fidelity of user permissions

* Consider global settings also

* update playwright

Ref: https://github.com/microsoft/playwright/issues/40998
This commit is contained in:
Oliver
2026-05-30 21:22:35 +10:00
committed by GitHub
parent f607e1bebe
commit e500b61029
2 changed files with 20 additions and 9 deletions
+1 -1
View File
@@ -271,7 +271,7 @@ function NavTabs() {
// static content
mainNavTabs.forEach((tab) => {
if (tab.role && !user.hasViewRole(tab.role)) {
if (tab.visible === false) {
return;
}
+19 -8
View File
@@ -16,15 +16,18 @@ import {
} from '@tabler/icons-react';
import type { ReactNode } from 'react';
import type { MenuLinkItem } from '../components/items/MenuLinks';
import { useGlobalSettingsState } from '../states/SettingsStates';
type NavTab = {
name: string;
title: string;
icon: ReactNode;
role?: UserRoles;
visible?: boolean;
};
export function getNavTabs(user: UserStateProps): NavTab[] {
const globalSettings = useGlobalSettingsState.getState();
const navTabs: NavTab[] = [
{
name: 'home',
@@ -35,37 +38,45 @@ export function getNavTabs(user: UserStateProps): NavTab[] {
name: 'part',
title: t`Parts`,
icon: <IconBox />,
role: UserRoles.part
visible:
user.hasViewRole(UserRoles.part) ||
user.hasViewRole(UserRoles.part_category)
},
{
name: 'stock',
title: t`Stock`,
icon: <IconPackages />,
role: UserRoles.stock
visible:
user.hasViewRole(UserRoles.stock) ||
user.hasViewRole(UserRoles.stock_location) ||
(globalSettings.isSet('TRANSFERORDER_ENABLED') &&
user.hasViewRole(UserRoles.transfer_order))
},
{
name: 'manufacturing',
title: t`Manufacturing`,
icon: <IconBuildingFactory2 />,
role: UserRoles.build
visible: user.hasViewRole(UserRoles.build)
},
{
name: 'purchasing',
title: t`Purchasing`,
icon: <IconShoppingCart />,
role: UserRoles.purchase_order
visible: user.hasViewRole(UserRoles.purchase_order)
},
{
name: 'sales',
title: t`Sales`,
icon: <IconTruckDelivery />,
role: UserRoles.sales_order
visible:
user.hasViewRole(UserRoles.sales_order) ||
(globalSettings.isSet('RETURNORDER_ENABLED') &&
user.hasViewRole(UserRoles.return_order))
}
];
return navTabs.filter((tab) => {
if (!tab.role) return true;
return user.hasViewRole(tab.role);
return tab.visible !== false;
});
}