mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-17 12:35:46 +00:00
add navigation action and test
This commit is contained in:
@ -1,19 +1,24 @@
|
|||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import type { SpotlightAction } from '@mantine/spotlight';
|
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 { NavigateFunction } from 'react-router-dom';
|
||||||
|
|
||||||
|
import { useLocalState } from '../states/LocalState';
|
||||||
import { menuItems } from './menuItems';
|
import { menuItems } from './menuItems';
|
||||||
|
|
||||||
export function getActions(navigate: NavigateFunction) {
|
export function getActions(navigate: NavigateFunction) {
|
||||||
/**
|
const setNavigationOpen = useLocalState((state) => state.setNavigationOpen);
|
||||||
* Default actions for the spotlight
|
|
||||||
*/
|
|
||||||
const actions: SpotlightAction[] = [
|
const actions: SpotlightAction[] = [
|
||||||
{
|
{
|
||||||
title: t`Home`,
|
title: t`Home`,
|
||||||
description: `Go to the home page`,
|
description: `Go to the home page`,
|
||||||
onTrigger: (action) => navigate(menuItems.home.link),
|
onTrigger: () => navigate(menuItems.home.link),
|
||||||
icon: <IconHome size="1.2rem" />
|
icon: <IconHome size="1.2rem" />
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -25,7 +30,7 @@ export function getActions(navigate: NavigateFunction) {
|
|||||||
{
|
{
|
||||||
title: t`Documentation`,
|
title: t`Documentation`,
|
||||||
description: t`Visit documentation to learn more about InvenTree`,
|
description: t`Visit documentation to learn more about InvenTree`,
|
||||||
onTrigger: () => console.log('Documentation'),
|
onTrigger: () => log('Documentatioconsole.n'),
|
||||||
icon: <IconFileText size="1.2rem" />
|
icon: <IconFileText size="1.2rem" />
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -33,6 +38,12 @@ export function getActions(navigate: NavigateFunction) {
|
|||||||
description: t`About the InvenTree org`,
|
description: t`About the InvenTree org`,
|
||||||
onTrigger: () => navigate(menuItems.about.link),
|
onTrigger: () => navigate(menuItems.about.link),
|
||||||
icon: <IconInfoCircle size="1.2rem" />
|
icon: <IconInfoCircle size="1.2rem" />
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: t`Open Navigation`,
|
||||||
|
description: t`Open the main navigation menu`,
|
||||||
|
onTrigger: () => setNavigationOpen(true),
|
||||||
|
icon: <IconNavigation size="1.2rem" />
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -40,4 +40,14 @@ test('PUI - Quick Command', async ({ page }) => {
|
|||||||
await page.getByPlaceholder('Search...').press('Tab');
|
await page.getByPlaceholder('Search...').press('Tab');
|
||||||
await page.getByPlaceholder('Search...').press('Enter');
|
await page.getByPlaceholder('Search...').press('Enter');
|
||||||
await page.waitForURL('**/platform/dashboard');
|
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();
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user