2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-16 12:05:53 +00:00

add navigation action and test

This commit is contained in:
Matthias Mair
2024-04-09 23:06:25 +02:00
parent 364dcd9bf8
commit 3dbd5ef9b9
2 changed files with 27 additions and 6 deletions

View File

@ -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: <IconHome size="1.2rem" />
},
{
@ -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: <IconFileText size="1.2rem" />
},
{
@ -33,6 +38,12 @@ export function getActions(navigate: NavigateFunction) {
description: t`About the InvenTree org`,
onTrigger: () => navigate(menuItems.about.link),
icon: <IconInfoCircle size="1.2rem" />
},
{
title: t`Open Navigation`,
description: t`Open the main navigation menu`,
onTrigger: () => setNavigationOpen(true),
icon: <IconNavigation size="1.2rem" />
}
];

View File

@ -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();
});