diff --git a/src/frontend/src/defaults/links.tsx b/src/frontend/src/defaults/links.tsx index 1646bab73e..51fa80f03e 100644 --- a/src/frontend/src/defaults/links.tsx +++ b/src/frontend/src/defaults/links.tsx @@ -37,10 +37,6 @@ export const navTabs = [ { text: Sales, name: 'sales', role: UserRoles.sales_order } ]; -if (IS_DEV_OR_DEMO) { - navTabs.push({ text: Playground, name: 'playground' }); -} - export const docLinks = { app: 'https://docs.inventree.org/app/', getting_started: 'https://docs.inventree.org/en/latest/getting_started/', diff --git a/src/frontend/src/defaults/menuItems.tsx b/src/frontend/src/defaults/menuItems.tsx index a20659a80d..5ceaf24585 100644 --- a/src/frontend/src/defaults/menuItems.tsx +++ b/src/frontend/src/defaults/menuItems.tsx @@ -64,12 +64,3 @@ export const menuItems: menuItemsCollection = { link: '/settings/admin' } }; - -if (IS_DEV_OR_DEMO) { - menuItems['playground'] = { - id: 'playground', - text: Playground, - link: '/playground', - highlight: true - }; -} diff --git a/src/frontend/src/pages/Index/Playground.tsx b/src/frontend/src/pages/Index/Playground.tsx deleted file mode 100644 index b596f4ecaf..0000000000 --- a/src/frontend/src/pages/Index/Playground.tsx +++ /dev/null @@ -1,240 +0,0 @@ -import { Trans } from '@lingui/macro'; -import { - Accordion, - Button, - Card, - Group, - Stack, - Text, - TextInput -} from '@mantine/core'; -import { SpotlightActionData } from '@mantine/spotlight'; -import { IconAlien } from '@tabler/icons-react'; -import { ReactNode, useMemo, useState } from 'react'; - -import { OptionsApiForm } from '../../components/forms/ApiForm'; -import { PlaceholderPill } from '../../components/items/Placeholder'; -import { StylishText } from '../../components/items/StylishText'; -import { firstSpotlight } from '../../components/nav/Layout'; -import { StatusRenderer } from '../../components/render/StatusRenderer'; -import { ApiEndpoints } from '../../enums/ApiEndpoints'; -import { ModelType } from '../../enums/ModelType'; -import { partCategoryFields, usePartFields } from '../../forms/PartForms'; -import { useCreateStockItem } from '../../forms/StockForms'; -import { - useCreateApiFormModal, - useEditApiFormModal -} from '../../hooks/UseForm'; - -// Generate some example forms using the modal API forms interface - -function ApiFormsPlayground() { - const fields = partCategoryFields({}); - - const editCategory = useEditApiFormModal({ - url: ApiEndpoints.category_list, - pk: 2, - title: 'Edit Category', - fields: fields - }); - - const createPartFields = usePartFields({ create: true }); - const editPartFields = usePartFields({ create: false }); - - const newPart = useCreateApiFormModal({ - url: ApiEndpoints.part_list, - title: 'Create Part', - fields: createPartFields, - initialData: { - description: 'A part created via the API' - } - }); - - const editPart = useEditApiFormModal({ - url: ApiEndpoints.part_list, - pk: 1, - title: 'Edit Part', - fields: editPartFields - }); - - const [active, setActive] = useState(true); - const [name, setName] = useState('Hello'); - - const partFieldsState: any = useMemo(() => { - const fields = editPartFields; - fields.name = { - ...fields.name, - value: name, - onValueChange: setName - }; - fields.active = { - ...fields.active, - value: active, - onValueChange: setActive - }; - fields.responsible = { - ...fields.responsible, - disabled: !active - }; - return fields; - }, [name, active]); - - const { modal: createPartModal, open: openCreatePart } = - useCreateApiFormModal({ - url: ApiEndpoints.part_list, - title: 'Create part', - fields: partFieldsState, - initialData: { - is_template: true, - virtual: true, - minimum_stock: 10, - description: 'An example part description', - keywords: 'apple, banana, carrottt', - 'initial_supplier.sku': 'SKU-123' - }, - preFormContent: ( - - ) - }); - - const { modal: createStockItemModal, open: openCreateStockItem } = - useCreateStockItem(); - - return ( - - - - {newPart.modal} - - - {editPart.modal} - - - {createStockItemModal} - - - {editCategory.modal} - - - {createPartModal} - - - - - - ); -} - -// Show some example status labels -function StatusLabelPlayground() { - const [status, setStatus] = useState('10'); - return ( - - Stock Status - setStatus(event.currentTarget.value)} - /> - - - ); -} - -// Sample for spotlight actions -function SpotlighPlayground() { - return ( - - ); -} - -/** Construct a simple accordion group with title and content */ -function PlaygroundArea({ - title, - content -}: Readonly<{ - title: string; - content: ReactNode; -}>) { - return ( - - - {title} - - {content} - - ); -} - -export default function Playground() { - return ( - <> - - - Playground - - - - - - This page is a showcase for the possibilities of Platform UI. - - - - } /> - } - /> - } - /> - - - ); -} diff --git a/src/frontend/src/router.tsx b/src/frontend/src/router.tsx index e3bfb19cf3..d606a6ade2 100644 --- a/src/frontend/src/router.tsx +++ b/src/frontend/src/router.tsx @@ -8,9 +8,6 @@ export const LayoutComponent = Loadable( lazy(() => import('./components/nav/Layout')) ); export const Home = Loadable(lazy(() => import('./pages/Index/Home'))); -export const Playground = Loadable( - lazy(() => import('./pages/Index/Playground')) -); export const CompanyDetail = Loadable( lazy(() => import('./pages/company/CompanyDetail')) @@ -125,7 +122,6 @@ export const routes = ( } />, } />, } />, - } />, } />, } /> diff --git a/src/frontend/tests/pages/pui_index.spec.ts b/src/frontend/tests/pages/pui_index.spec.ts index 92906fe824..9ccf1bc127 100644 --- a/src/frontend/tests/pages/pui_index.spec.ts +++ b/src/frontend/tests/pages/pui_index.spec.ts @@ -1,78 +1,6 @@ import { test } from '../baseFixtures.js'; import { doQuickLogin } from '../login.js'; -const newPartName = 'UITESTIN123'; - -test('Pages - Index - Playground', async ({ page }) => { - await doQuickLogin(page); - - await page.goto('./'); - // Playground - await page.getByRole('tab', { name: 'Playground' }).click(); - await page.getByRole('button', { name: 'API Forms' }).click(); - - // New Part - await page.getByRole('button', { name: 'Create New Part' }).click(); - await page.getByLabel('related-field-category').fill('category 0'); - - await page - .getByRole('option', { name: 'Category 0' }) - .locator('div') - .first() - .click(); - - // Set the "name" - await page.getByLabel('text-field-name').fill(newPartName); - await page.getByLabel('number-field-initial_stock').fill('1'); - - await page - .getByLabel('Create Part') - .getByRole('button', { name: 'Cancel' }) - .click(); - - // Edit Part - await page.getByRole('button', { name: 'Edit Part' }).click(); - await page.getByLabel('IPN').click(); - await page.getByLabel('IPN').fill(newPartName); - await page - .getByLabel('Edit Part') - .getByRole('button', { name: 'Cancel' }) - .click(); - - // Create Stock Item - await page.getByRole('button', { name: 'Create Stock Item' }).click(); - await page.getByLabel('related-field-part').fill('R_1K_0402_1'); - await page.getByText('R_1K_0402_1%').click(); - await page - .getByLabel('Add Stock Item') - .getByRole('button', { name: 'Cancel' }) - .click(); - - // EditCategory - await page.getByRole('button', { name: 'Edit Category' }).click(); - await page.getByLabel('related-field-parent').click(); - await page.getByText('Category 0').click(); - await page - .getByLabel('Edit Category') - .getByRole('button', { name: 'Cancel' }) - .click(); - - // Create Part new Modal - await page.getByRole('button', { name: 'Create Part new Modal' }).click(); - await page.getByLabel('related-field-category').click(); - await page.getByText('Category 0').click(); - await page - .getByLabel('Create part') - .getByRole('button', { name: 'Cancel' }) - .click(); - - // Status Label - await page.getByRole('button', { name: 'Status labels' }).click(); - await page.getByRole('textbox').dblclick(); - await page.getByRole('textbox').fill('50'); - await page.getByText('Attention needed').waitFor(); -}); - test('Pages - Index - Dashboard', async ({ page }) => { await doQuickLogin(page); diff --git a/src/frontend/tests/pui_command.spec.ts b/src/frontend/tests/pui_command.spec.ts index 4a2c30d3a9..d8c1108e00 100644 --- a/src/frontend/tests/pui_command.spec.ts +++ b/src/frontend/tests/pui_command.spec.ts @@ -97,24 +97,5 @@ test('Quick Command - No Keys', async ({ page }) => { .click(); await page.waitForURL('https://docs.inventree.org/**'); - // Test addition of new actions - await page.goto(`${baseUrl}/playground`); - await page.locator('p').filter({ hasText: 'Playground' }).waitFor(); - await page.getByRole('button', { name: 'Spotlight actions' }).click(); - await page.getByRole('button', { name: 'Register extra actions' }).click(); - /* - await page.getByPlaceholder('Search...').fill('secret'); - await page.getByRole('button', { name: 'Secret action It was' }).click(); - await page.getByLabel('open-spotlight').click(); - await page.getByPlaceholder('Search...').fill('Another secret action'); - await page - .getByRole('button', { - name: 'Another secret action You can register multiple actions with just one command' - }) - .click(); - await page.getByRole('tab', { name: 'Home' }).click(); - await page.getByLabel('open-spotlight').click(); - */ - await page.getByPlaceholder('Search...').fill('secret'); - await page.getByText('Nothing found...').click(); + // TODO: Test addition of new actions });