diff --git a/src/frontend/src/defaults/actions.tsx b/src/frontend/src/defaults/actions.tsx index 6c773b013c..21ae36e393 100644 --- a/src/frontend/src/defaults/actions.tsx +++ b/src/frontend/src/defaults/actions.tsx @@ -1,19 +1,24 @@ import { t } from '@lingui/macro'; import type { SpotlightAction } from '@mantine/spotlight'; -import { IconFileText, IconHome, IconInfoCircle } from '@tabler/icons-react'; +import { + IconFileText, + IconHome, + IconInfoCircle, + IconNavigation +} from '@tabler/icons-react'; import { NavigateFunction } from 'react-router-dom'; +import { useLocalState } from '../states/LocalState'; import { menuItems } from './menuItems'; export function getActions(navigate: NavigateFunction) { - /** - * Default actions for the spotlight - */ + const setNavigationOpen = useLocalState((state) => state.setNavigationOpen); + const actions: SpotlightAction[] = [ { title: t`Home`, description: `Go to the home page`, - onTrigger: (action) => navigate(menuItems.home.link), + onTrigger: () => navigate(menuItems.home.link), icon: }, { @@ -25,7 +30,7 @@ export function getActions(navigate: NavigateFunction) { { title: t`Documentation`, description: t`Visit documentation to learn more about InvenTree`, - onTrigger: () => console.log('Documentation'), + onTrigger: () => log('Documentatioconsole.n'), icon: }, { @@ -33,6 +38,12 @@ export function getActions(navigate: NavigateFunction) { description: t`About the InvenTree org`, onTrigger: () => navigate(menuItems.about.link), icon: + }, + { + title: t`Open Navigation`, + description: t`Open the main navigation menu`, + onTrigger: () => setNavigationOpen(true), + icon: } ]; diff --git a/src/frontend/tests/pui_command.spec.ts b/src/frontend/tests/pui_command.spec.ts index 1421fd4601..c90d622d30 100644 --- a/src/frontend/tests/pui_command.spec.ts +++ b/src/frontend/tests/pui_command.spec.ts @@ -40,4 +40,14 @@ test('PUI - Quick Command', async ({ page }) => { await page.getByPlaceholder('Search...').press('Tab'); await page.getByPlaceholder('Search...').press('Enter'); await page.waitForURL('**/platform/dashboard'); + + // Use navigation menu + await page.getByRole('button', { name: 'Open spotlight' }).click(); + await page + .getByRole('button', { name: 'Open Navigation Open the main' }) + .click(); + // assert the nav headers are visible + await page.getByRole('heading', { name: 'Pages' }).click(); + await page.getByRole('heading', { name: 'Documentation' }).click(); + await page.getByRole('heading', { name: 'About' }).click(); });