mirror of
https://github.com/inventree/InvenTree.git
synced 2026-05-28 03:49:20 +00:00
Additional spotlight actions (#12012)
* Additional spotlight actions * Fix memo
This commit is contained in:
@@ -5,14 +5,16 @@ import {
|
||||
IconLink,
|
||||
IconPlug,
|
||||
IconPointer,
|
||||
IconReport,
|
||||
IconSettings,
|
||||
IconTags,
|
||||
IconUserBolt,
|
||||
IconUserCog
|
||||
} from '@tabler/icons-react';
|
||||
import type { NavigateFunction } from 'react-router-dom';
|
||||
|
||||
import { ModelInformationDict } from '@lib/enums/ModelInformation';
|
||||
import { UserRoles } from '@lib/index';
|
||||
import { ModelType, UserRoles } from '@lib/index';
|
||||
import { openContextModal } from '@mantine/modals';
|
||||
import { useMemo } from 'react';
|
||||
import { useShallow } from 'zustand/react/shallow';
|
||||
@@ -36,6 +38,8 @@ export function getActions(navigate: NavigateFunction) {
|
||||
const user = useUserState();
|
||||
|
||||
const actions: SpotlightActionData[] = useMemo(() => {
|
||||
const staff = user?.isStaff() ?? false;
|
||||
|
||||
const _actions: SpotlightActionData[] = [
|
||||
{
|
||||
id: 'dashboard',
|
||||
@@ -90,7 +94,7 @@ export function getActions(navigate: NavigateFunction) {
|
||||
}
|
||||
];
|
||||
|
||||
user?.isStaff() &&
|
||||
staff &&
|
||||
_actions.push({
|
||||
id: 'data-import',
|
||||
label: t`Import Data`,
|
||||
@@ -149,7 +153,7 @@ export function getActions(navigate: NavigateFunction) {
|
||||
leftSection: <IconLink size='1.2rem' />
|
||||
});
|
||||
|
||||
user?.isStaff() &&
|
||||
staff &&
|
||||
_actions.push({
|
||||
id: 'system-settings',
|
||||
label: t`System Settings`,
|
||||
@@ -158,7 +162,7 @@ export function getActions(navigate: NavigateFunction) {
|
||||
leftSection: <IconSettings size='1.2rem' />
|
||||
});
|
||||
|
||||
user?.isStaff() &&
|
||||
staff &&
|
||||
_actions.push({
|
||||
id: 'admin-center',
|
||||
label: t`Admin Center`,
|
||||
@@ -167,7 +171,7 @@ export function getActions(navigate: NavigateFunction) {
|
||||
leftSection: <IconUserBolt size='1.2rem' />
|
||||
});
|
||||
|
||||
user?.isStaff() &&
|
||||
staff &&
|
||||
_actions.push({
|
||||
id: 'plugin-settings',
|
||||
label: t`Plugins`,
|
||||
@@ -176,6 +180,26 @@ export function getActions(navigate: NavigateFunction) {
|
||||
leftSection: <IconPlug size='1.2rem' />
|
||||
});
|
||||
|
||||
staff &&
|
||||
user?.hasViewPermission(ModelType.reporttemplate) &&
|
||||
_actions.push({
|
||||
id: 'report-templates',
|
||||
label: t`Report Templates`,
|
||||
description: t`Manage report templates`,
|
||||
onClick: () => navigate('/settings/admin/reports'),
|
||||
leftSection: <IconReport size='1.2rem' />
|
||||
});
|
||||
|
||||
staff &&
|
||||
user?.hasViewPermission(ModelType.labeltemplate) &&
|
||||
_actions.push({
|
||||
id: 'label-templates',
|
||||
label: t`Label Templates`,
|
||||
description: t`Manage label templates`,
|
||||
onClick: () => navigate('/settings/admin/labels'),
|
||||
leftSection: <IconTags size='1.2rem' />
|
||||
});
|
||||
|
||||
return _actions;
|
||||
}, [navigate, setNavigationOpen, globalSettings, user]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user