Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PUI] Make breadcrumbs adjustable #8027

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/backend/InvenTree/common/models.py
Original file line number Diff line number Diff line change
@@ -2593,6 +2593,12 @@ class Meta:
'validator': [int, MinValueValidator(0)],
'default': 100,
},
'ENABLE_LAST_BREADCRUMB': {
'name': _('Show Last Breadcrumb'),
'description': _('Show the current page in breadcrumbs'),
'default': False,
'validator': bool,
},
'NOTIFICATION_ERROR_REPORT': {
'name': _('Receive error reports'),
'description': _('Receive notifications for system errors'),
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
{% include "InvenTree/settings/setting.html" with key="DISPLAY_SCHEDULE_TAB" icon="fa-calendar-alt" user_setting=True %}
{% include "InvenTree/settings/setting.html" with key="DISPLAY_STOCKTAKE_TAB" icon="fa-clipboard-check" user_setting=True %}
{% include "InvenTree/settings/setting.html" with key="TABLE_STRING_MAX_LENGTH" icon="fa-table" user_setting=True %}
{% include "InvenTree/settings/setting.html" with key="ENABLE_LAST_BREADCRUMB" icon="fa-table" user_setting=True %}
</tbody>
</table>
</div>
19 changes: 16 additions & 3 deletions src/frontend/src/components/nav/PageDetail.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Group, Paper, Space, Stack, Text } from '@mantine/core';
import { useHotkeys } from '@mantine/hooks';
import { Fragment, ReactNode } from 'react';
import { Fragment, ReactNode, useMemo } from 'react';

import { useUserSettingsState } from '../../states/SettingsState';
import { ApiImage } from '../images/ApiImage';
import { StylishText } from '../items/StylishText';
import { Breadcrumb, BreadcrumbList } from './BreadcrumbList';
@@ -14,6 +15,7 @@ interface PageDetailInterface {
detail?: ReactNode;
badges?: ReactNode[];
breadcrumbs?: Breadcrumb[];
last_crumb?: Breadcrumb[];
breadcrumbAction?: () => void;
actions?: ReactNode[];
editAction?: () => void;
@@ -34,11 +36,13 @@ export function PageDetail({
badges,
imageUrl,
breadcrumbs,
last_crumb,
breadcrumbAction,
actions,
editAction,
editEnabled
}: Readonly<PageDetailInterface>) {
const userSettings = useUserSettingsState();
useHotkeys([
[
'mod+E',
@@ -50,12 +54,21 @@ export function PageDetail({
]
]);

// breadcrumb caching
const computedBreadcrumbs = useMemo(() => {
SchrodingersGat marked this conversation as resolved.
Show resolved Hide resolved
if (userSettings.isSet('ENABLE_LAST_BREADCRUMB', false)) {
return [...(breadcrumbs ?? []), ...(last_crumb ?? [])];
} else {
return breadcrumbs;
}
}, [breadcrumbs, last_crumb, userSettings]);

return (
<Stack gap="xs">
{breadcrumbs && breadcrumbs.length > 0 && (
{computedBreadcrumbs && computedBreadcrumbs.length > 0 && (
<BreadcrumbList
navCallback={breadcrumbAction}
breadcrumbs={breadcrumbs}
breadcrumbs={computedBreadcrumbs}
/>
)}
<Paper p="xs" radius="xs" shadow="xs">
3 changes: 2 additions & 1 deletion src/frontend/src/pages/Index/Settings/UserSettings.tsx
Original file line number Diff line number Diff line change
@@ -87,7 +87,8 @@ export default function UserSettings() {
'PART_SHOW_QUANTITY_IN_FORMS',
'DISPLAY_SCHEDULE_TAB',
'DISPLAY_STOCKTAKE_TAB',
'TABLE_STRING_MAX_LENGTH'
'TABLE_STRING_MAX_LENGTH',
'ENABLE_LAST_BREADCRUMB'
]}
/>
)
4 changes: 2 additions & 2 deletions src/frontend/src/pages/build/BuildDetail.tsx
Original file line number Diff line number Diff line change
@@ -531,8 +531,8 @@ export default function BuildDetail() {
editAction={editBuild.open}
editEnabled={user.hasChangePermission(ModelType.part)}
imageUrl={build.part_detail?.image ?? build.part_detail?.thumbnail}
breadcrumbs={[
{ name: t`Manufacturing`, url: '/manufacturing' },
breadcrumbs={[{ name: t`Build Orders`, url: '/build' }]}
last_crumb={[
{
name: build.reference,
url: getDetailUrl(ModelType.build, build.pk)
7 changes: 7 additions & 0 deletions src/frontend/src/pages/company/CompanyDetail.tsx
Original file line number Diff line number Diff line change
@@ -55,6 +55,7 @@ import { StockItemTable } from '../../tables/stock/StockItemTable';
export type CompanyDetailProps = {
title: string;
breadcrumbs: Breadcrumb[];
last_crumb_url: string;
};

/**
@@ -323,6 +324,12 @@ export default function CompanyDetail(props: Readonly<CompanyDetailProps>) {
actions={companyActions}
imageUrl={company.image}
breadcrumbs={props.breadcrumbs}
last_crumb={[
{
name: company.name,
url: `${props.last_crumb_url}/${company.pk}/`
}
]}
badges={badges}
editAction={editCompany.open}
editEnabled={user.hasChangePermission(ModelType.company)}
1 change: 1 addition & 0 deletions src/frontend/src/pages/company/CustomerDetail.tsx
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ export default function CustomerDetail() {
<CompanyDetail
title={t`Customer`}
breadcrumbs={[{ name: t`Sales`, url: '/sales/' }]}
last_crumb_url="/sales/customer"
/>
);
}
1 change: 1 addition & 0 deletions src/frontend/src/pages/company/ManufacturerDetail.tsx
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ export default function ManufacturerDetail() {
<CompanyDetail
title={t`Manufacturer`}
breadcrumbs={[{ name: t`Purchasing`, url: '/purchasing/' }]}
last_crumb_url="/purchasing/manufacturer"
/>
);
}
9 changes: 9 additions & 0 deletions src/frontend/src/pages/company/ManufacturerPartDetail.tsx
Original file line number Diff line number Diff line change
@@ -276,6 +276,15 @@ export default function ManufacturerPartDetail() {
title={t`ManufacturerPart`}
subtitle={`${manufacturerPart.MPN} - ${manufacturerPart.part_detail?.name}`}
breadcrumbs={breadcrumbs}
last_crumb={[
{
name: manufacturerPart.MPN,
url: getDetailUrl(
ModelType.manufacturerpart,
manufacturerPart.pk
)
}
]}
actions={manufacturerPartActions}
imageUrl={manufacturerPart?.part_detail?.thumbnail}
editAction={editManufacturerPart.open}
1 change: 1 addition & 0 deletions src/frontend/src/pages/company/SupplierDetail.tsx
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ export default function SupplierDetail() {
<CompanyDetail
title={t`Supplier`}
breadcrumbs={[{ name: t`Purchasing`, url: '/purchasing/' }]}
last_crumb_url="/purchasing/supplier"
/>
);
}
6 changes: 6 additions & 0 deletions src/frontend/src/pages/company/SupplierPartDetail.tsx
Original file line number Diff line number Diff line change
@@ -364,6 +364,12 @@ export default function SupplierPartDetail() {
title={t`Supplier Part`}
subtitle={`${supplierPart.SKU} - ${supplierPart?.part_detail?.name}`}
breadcrumbs={breadcrumbs}
last_crumb={[
{
name: supplierPart.SKU,
url: `/purchasing/supplier-part/${supplierPart.pk}/`
}
]}
badges={badges}
actions={supplierPartActions}
imageUrl={supplierPart?.part_detail?.thumbnail}
6 changes: 6 additions & 0 deletions src/frontend/src/pages/part/PartDetail.tsx
Original file line number Diff line number Diff line change
@@ -1085,6 +1085,12 @@ export default function PartDetail() {
imageUrl={part.image}
badges={badges}
breadcrumbs={breadcrumbs}
last_crumb={[
{
name: part.name,
url: `/part/${part.pk}/`
}
]}
breadcrumbAction={() => {
setTreeOpen(true); // Open the category tree
}}
6 changes: 6 additions & 0 deletions src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx
Original file line number Diff line number Diff line change
@@ -478,6 +478,12 @@ export default function PurchaseOrderDetail() {
subtitle={order.description}
imageUrl={order.supplier_detail?.image}
breadcrumbs={[{ name: t`Purchasing`, url: '/purchasing/' }]}
last_crumb={[
{
name: order.reference,
url: `/purchasing/purchase-order/${order.pk}`
}
]}
actions={poActions}
badges={orderBadges}
editAction={editPurchaseOrder.open}
3 changes: 3 additions & 0 deletions src/frontend/src/pages/sales/ReturnOrderDetail.tsx
Original file line number Diff line number Diff line change
@@ -467,6 +467,9 @@ export default function ReturnOrderDetail() {
badges={orderBadges}
actions={orderActions}
breadcrumbs={[{ name: t`Sales`, url: '/sales/' }]}
last_crumb={[
{ name: order.reference, url: `/sales/return-order/${order.pk}` }
]}
editAction={editReturnOrder.open}
editEnabled={user.hasChangePermission(ModelType.returnorder)}
/>
3 changes: 3 additions & 0 deletions src/frontend/src/pages/sales/SalesOrderDetail.tsx
Original file line number Diff line number Diff line change
@@ -519,6 +519,9 @@ export default function SalesOrderDetail() {
badges={orderBadges}
actions={soActions}
breadcrumbs={[{ name: t`Sales`, url: '/sales/' }]}
last_crumb={[
{ name: order.reference, url: `/sales/sales-order/${order.pk}` }
]}
editAction={editSalesOrder.open}
editEnabled={user.hasChangePermission(ModelType.salesorder)}
/>
6 changes: 6 additions & 0 deletions src/frontend/src/pages/stock/LocationDetail.tsx
Original file line number Diff line number Diff line change
@@ -384,6 +384,12 @@ export default function Stock() {
editAction={editLocation.open}
editEnabled={user.hasChangePermission(ModelType.stocklocation)}
breadcrumbs={breadcrumbs}
last_crumb={[
{
name: location.name,
url: `/stock/location/${location.pk}/`
}
]}
breadcrumbAction={() => {
setTreeOpen(true);
}}
6 changes: 6 additions & 0 deletions src/frontend/src/pages/stock/StockDetail.tsx
Original file line number Diff line number Diff line change
@@ -844,6 +844,12 @@ export default function StockDetail() {
editEnabled={user.hasChangePermission(ModelType.stockitem)}
badges={stockBadges}
breadcrumbs={breadcrumbs}
last_crumb={[
{
name: stockitem.name,
url: `/stock/item/${stockitem.pk}/`
}
]}
breadcrumbAction={() => {
setTreeOpen(true);
}}
Loading