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