From 58f4ef21cbeb6c83957d66b7ee2be3e9e30148c8 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Tue, 9 Apr 2024 21:03:14 +0200 Subject: [PATCH] [PUI] Quick commands pallet Fixes #5888 --- .../components/buttons/SpotlightButton.tsx | 15 +++++++ .../src/components/items/MenuLinks.tsx | 4 ++ src/frontend/src/components/nav/Header.tsx | 2 + src/frontend/src/components/nav/Layout.tsx | 32 ++++++++++----- .../src/components/nav/NavHoverMenu.tsx | 4 +- .../src/components/nav/NavigationDrawer.tsx | 3 +- src/frontend/src/defaults/actions.tsx | 40 +++++++++++++++++++ src/frontend/src/defaults/menuItems.tsx | 32 +++++++-------- 8 files changed, 105 insertions(+), 27 deletions(-) create mode 100644 src/frontend/src/components/buttons/SpotlightButton.tsx create mode 100644 src/frontend/src/defaults/actions.tsx diff --git a/src/frontend/src/components/buttons/SpotlightButton.tsx b/src/frontend/src/components/buttons/SpotlightButton.tsx new file mode 100644 index 0000000000..c524e0b947 --- /dev/null +++ b/src/frontend/src/components/buttons/SpotlightButton.tsx @@ -0,0 +1,15 @@ +import { t } from '@lingui/macro'; +import { ActionIcon } from '@mantine/core'; +import { spotlight } from '@mantine/spotlight'; +import { IconCommand } from '@tabler/icons-react'; + +/** + * A button which opens the quick command modal + */ +export function SpotlightButton() { + return ( + spotlight.open()} title={t`Open spotlight`}> + + + ); +} diff --git a/src/frontend/src/components/items/MenuLinks.tsx b/src/frontend/src/components/items/MenuLinks.tsx index c75cc565d5..e9e9b10772 100644 --- a/src/frontend/src/components/items/MenuLinks.tsx +++ b/src/frontend/src/components/items/MenuLinks.tsx @@ -16,6 +16,10 @@ export interface MenuLinkItem { docchildren?: React.ReactNode; } +export type menuItemsCollection = { + [key: string]: MenuLinkItem; +}; + function ConditionalDocTooltip({ item, children diff --git a/src/frontend/src/components/nav/Header.tsx b/src/frontend/src/components/nav/Header.tsx index b4f139cfb8..a9505f209e 100644 --- a/src/frontend/src/components/nav/Header.tsx +++ b/src/frontend/src/components/nav/Header.tsx @@ -10,6 +10,7 @@ import { navTabs as mainNavTabs } from '../../defaults/links'; import { ApiEndpoints } from '../../enums/ApiEndpoints'; import { InvenTreeStyle } from '../../globalStyle'; import { apiUrl } from '../../states/ApiState'; +import { SpotlightButton } from '../buttons/SpotlightButton'; import { ScanButton } from '../items/ScanButton'; import { MainMenu } from './MainMenu'; import { NavHoverMenu } from './NavHoverMenu'; @@ -80,6 +81,7 @@ export function Header() { + { export default function LayoutComponent() { const { classes } = InvenTreeStyle(); + const navigate = useNavigate(); + const actions = getActions(navigate); return ( - -
- - - - -