Skip to content

Commit

Permalink
[PUI] Add "index" page for build orders (#8287)
Browse files Browse the repository at this point in the history
* Add "index" page for build orders

- Make consistent with other pages
- Allow plugin panels here
- Prepare for future development

* Rearrange URLs for "manufacturing"

- Provide same format as other order types
- Allow for other sub-pages under "manufacturing" in the future

* Fix breadcrumbs

* Adjust playwright tests
  • Loading branch information
SchrodingersGat authored Oct 15, 2024
1 parent fb9c117 commit e808fad
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/frontend/src/components/render/ModelType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ export const ModelInformationDict: ModelDict = {
build: {
label: () => t`Build`,
label_multiple: () => t`Builds`,
url_overview: '/build',
url_detail: '/build/:pk/',
url_overview: '/manufacturing/build-order/',
url_detail: '/manufacturing/build-order/:pk/',
cui_detail: '/build/:pk/',
api_endpoint: ApiEndpoints.build_order_list,
admin_url: '/build/build/'
Expand Down
6 changes: 5 additions & 1 deletion src/frontend/src/defaults/links.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ export const navTabs = [
{ text: <Trans>Dashboard</Trans>, name: 'dashboard' },
{ text: <Trans>Parts</Trans>, name: 'part', role: UserRoles.part },
{ text: <Trans>Stock</Trans>, name: 'stock', role: UserRoles.stock },
{ text: <Trans>Build</Trans>, name: 'build', role: UserRoles.build },
{
text: <Trans>Manufacturing</Trans>,
name: 'manufacturing',
role: UserRoles.build
},
{
text: <Trans>Purchasing</Trans>,
name: 'purchasing',
Expand Down
6 changes: 3 additions & 3 deletions src/frontend/src/defaults/menuItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ export const menuItems: menuItemsCollection = {
link: '/stock'
},
build: {
id: 'build',
text: <Trans>Build</Trans>,
link: '/build/'
id: 'manufacturing',
text: <Trans>Manufacturing</Trans>,
link: '/manufacturing/'
},
purchasing: {
id: 'purchasing',
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/pages/build/BuildDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ export default function BuildDetail() {
editEnabled={user.hasChangePermission(ModelType.part)}
imageUrl={build.part_detail?.image ?? build.part_detail?.thumbnail}
breadcrumbs={[
{ name: t`Build Orders`, url: '/build' },
{ name: t`Manufacturing`, url: '/manufacturing' },
{ name: build.reference, url: `/build/${build.pk}` }
]}
actions={buildActions}
Expand Down
23 changes: 21 additions & 2 deletions src/frontend/src/pages/build/BuildIndex.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { t } from '@lingui/macro';
import { Stack } from '@mantine/core';
import { IconTools } from '@tabler/icons-react';
import { useMemo } from 'react';

import PermissionDenied from '../../components/errors/PermissionDenied';
import { PageDetail } from '../../components/nav/PageDetail';
import { PanelGroup } from '../../components/panels/PanelGroup';
import { UserRoles } from '../../enums/Roles';
import { useUserState } from '../../states/UserState';
import { BuildOrderTable } from '../../tables/build/BuildOrderTable';
Expand All @@ -17,10 +20,26 @@ export default function BuildIndex() {
return <PermissionDenied />;
}

const panels = useMemo(() => {
return [
{
name: 'buildorders',
label: t`Build Orders`,
content: <BuildOrderTable />,
icon: <IconTools />
}
];
}, []);

return (
<Stack>
<PageDetail title={t`Build Orders`} actions={[]} />
<BuildOrderTable />
<PageDetail title={t`Manufacturing`} actions={[]} />
<PanelGroup
pageKey="build-index"
panels={panels}
model="manufacturing"
id={null}
/>
</Stack>
);
}
8 changes: 5 additions & 3 deletions src/frontend/src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const StockDetail = Loadable(
export const BuildIndex = Loadable(
lazy(() => import('./pages/build/BuildIndex'))
);

export const BuildDetail = Loadable(
lazy(() => import('./pages/build/BuildDetail'))
);
Expand Down Expand Up @@ -139,9 +140,10 @@ export const routes = (
<Route path="location/:id?/*" element={<LocationDetail />} />
<Route path="item/:id/*" element={<StockDetail />} />
</Route>
<Route path="build/">
<Route index element={<BuildIndex />} />
<Route path=":id/*" element={<BuildDetail />} />
<Route path="manufacturing/">
<Route index element={<Navigate to="index/" />} />
<Route path="index/*" element={<BuildIndex />} />
<Route path="build-order/:id/*" element={<BuildDetail />} />
</Route>
<Route path="purchasing/">
<Route index element={<Navigate to="index/" />} />
Expand Down
6 changes: 3 additions & 3 deletions src/frontend/tests/pages/pui_build.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test('Pages - Build Order', async ({ page }) => {
await page.goto(`${baseUrl}/part/`);

// Navigate to the correct build order
await page.getByRole('tab', { name: 'Build', exact: true }).click();
await page.getByRole('tab', { name: 'Manufacturing', exact: true }).click();

// We have now loaded the "Build Order" table. Check for some expected texts
await page.getByText('On Hold').first().waitFor();
Expand All @@ -30,7 +30,7 @@ test('Pages - Build Order', async ({ page }) => {
await page.getByRole('button', { name: 'Cancel' }).click();

// Back to the build list
await page.getByLabel('breadcrumb-0-build-orders').click();
await page.getByLabel('breadcrumb-0-manufacturing').click();

// Load a different build order
await page.getByRole('cell', { name: 'BO0011' }).click();
Expand Down Expand Up @@ -88,7 +88,7 @@ test('Pages - Build Order - Build Outputs', async ({ page }) => {
await page.goto(`${baseUrl}/part/`);

// Navigate to the correct build order
await page.getByRole('tab', { name: 'Build', exact: true }).click();
await page.getByRole('tab', { name: 'Manufacturing', exact: true }).click();

// We have now loaded the "Build Order" table. Check for some expected texts
await page.getByText('On Hold').first().waitFor();
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/tests/pui_tables.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test('Tables - Filters', async ({ page }) => {
await doQuickLogin(page);

// Head to the "build order list" page
await page.goto(`${baseUrl}/build/`);
await page.goto(`${baseUrl}/manufacturing/index/`);

await setFilter(page, 'Status', 'Complete');
await setFilter(page, 'Responsible', 'allaccess');
Expand Down

0 comments on commit e808fad

Please sign in to comment.