2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-06-11 19:27:02 +00:00

UX: Disable standard allocation for trackable parts (#11811) (#11967)

* UX: Disable standard allocation for trackable parts and add tooltip (#11811)

* Test: Update Playwright tests for disabled trackable allocation

* Fix: Align trackable allocation logic and tests based on review

* Test: Fix incorrect assumption of trackable Red Widget in pui_build.spec.ts

---------

Co-authored-by: Matthias Mair <code@mjmair.com>
This commit is contained in:
Aditya Kumar Mishra
2026-06-08 03:19:32 +05:30
committed by GitHub
parent 20309146aa
commit c2c8e72f37
2 changed files with 37 additions and 16 deletions
@@ -1,3 +1,14 @@
import { ActionButton } from '@lib/components/ActionButton';
import { ProgressBar } from '@lib/components/ProgressBar';
import { RowEditAction, RowViewAction } from '@lib/components/RowActions';
import { ApiEndpoints } from '@lib/enums/ApiEndpoints';
import { ModelType } from '@lib/enums/ModelType';
import { UserRoles } from '@lib/enums/Roles';
import { apiUrl } from '@lib/functions/Api';
import { formatDecimal } from '@lib/functions/Formatting';
import useTable from '@lib/hooks/UseTable';
import type { TableFilter } from '@lib/types/Filters';
import type { RowAction, TableColumn } from '@lib/types/Tables';
import { t } from '@lingui/core/macro';
import { Alert, Group, Paper, Text } from '@mantine/core';
import {
@@ -13,18 +24,6 @@ import {
import type { DataTableRowExpansionProps } from 'mantine-datatable';
import { useCallback, useMemo, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { ActionButton } from '@lib/components/ActionButton';
import { ProgressBar } from '@lib/components/ProgressBar';
import { RowEditAction, RowViewAction } from '@lib/components/RowActions';
import { ApiEndpoints } from '@lib/enums/ApiEndpoints';
import { ModelType } from '@lib/enums/ModelType';
import { UserRoles } from '@lib/enums/Roles';
import { apiUrl } from '@lib/functions/Api';
import { formatDecimal } from '@lib/functions/Formatting';
import useTable from '@lib/hooks/UseTable';
import type { TableFilter } from '@lib/types/Filters';
import type { RowAction, TableColumn } from '@lib/types/Tables';
import OrderPartsWizard from '../../components/wizards/OrderPartsWizard';
import {
useAllocateStockToBuildForm,
@@ -769,7 +768,9 @@ export default function BuildLineTable({
!consumable &&
user.hasChangeRole(UserRoles.build) &&
required > 0 &&
record.trackable == hasOutput;
(hasOutput ? trackable : true);
const disableAllocation = !hasOutput && trackable;
// Can de-allocate
const canDeallocate =
@@ -792,6 +793,10 @@ export default function BuildLineTable({
icon: <IconArrowRight />,
title: t`Allocate Stock`,
hidden: !canAllocate,
disabled: disableAllocation,
tooltip: disableAllocation
? t`Trackable parts must be allocated via the Build Outputs tab`
: t`Allocate Stock`,
color: 'green',
onClick: () => {
setSelectedRows([record]);
+19 -3
View File
@@ -418,6 +418,18 @@ test('Build Order - Allocation', async ({ browser }) => {
await row.getByText(/150 \/ 150/).waitFor();
// Open the allocation menu for the red widget
const mainRedWidget = await page.getByRole('cell', { name: 'Red Widget' });
const mainRedRow = await getRowFromCell(mainRedWidget);
await mainRedRow.getByLabel(/row-action-menu-/i).click();
await page
.getByRole('menuitem', { name: 'Allocate Stock', exact: true })
.waitFor();
await page.keyboard.press('Escape');
// Expand this row
await cell.click();
await page.getByRole('cell', { name: '2022-4-27', exact: true }).waitFor();
@@ -494,9 +506,13 @@ test('Build Order - Allocation', async ({ browser }) => {
const redRow = await getRowFromCell(redWidget);
await redRow.getByLabel(/row-action-menu-/i).click();
await page
.getByRole('menuitem', { name: 'Allocate Stock', exact: true })
.waitFor();
const allocateStockBtn = page.getByRole('menuitem', {
name: 'Allocate Stock',
exact: true
});
await expect(allocateStockBtn).toBeEnabled();
await page
.getByRole('menuitem', { name: 'Deallocate Stock', exact: true })
.waitFor();