diff --git a/src/frontend/src/tables/Column.tsx b/src/frontend/src/tables/Column.tsx index 6c9b6f9ea4..48a872876b 100644 --- a/src/frontend/src/tables/Column.tsx +++ b/src/frontend/src/tables/Column.tsx @@ -18,6 +18,7 @@ export type TableColumnProps = { textAlign?: 'left' | 'center' | 'right'; // The text alignment of the column cellsStyle?: any; // The style of the cells in the column extra?: any; // Extra data to pass to the render function + noContext?: boolean; // Disable context menu for this column }; /** diff --git a/src/frontend/src/tables/InvenTreeTable.tsx b/src/frontend/src/tables/InvenTreeTable.tsx index 72983c132e..bceb9a9d2f 100644 --- a/src/frontend/src/tables/InvenTreeTable.tsx +++ b/src/frontend/src/tables/InvenTreeTable.tsx @@ -88,7 +88,7 @@ export type InvenTreeTableProps = { modelType?: ModelType; rowStyle?: (record: T, index: number) => any; modelField?: string; - onRowContextMenu?: (record: T, event: any) => void; + onCellContextMenu?: (record: T, event: any) => void; minHeight?: number; noHeader?: boolean; }; @@ -568,16 +568,21 @@ export function InvenTreeTable>({ [props.onRowClick, props.onCellClick] ); - // Callback when a row is right-clicked - const handleRowContextMenu = ({ + // Callback when a cell is right-clicked + const handleCellContextMenu = ({ record, + column, event }: { record: any; + column: any; event: any; }) => { - if (props.onRowContextMenu) { - return props.onRowContextMenu(record, event); + if (column?.noContext === true) { + return; + } + if (props.onCellContextMenu) { + return props.onCellContextMenu(record, event); } else if (props.rowActions) { const empty = () => {}; const items = props.rowActions(record).map((action) => ({ @@ -693,7 +698,7 @@ export function InvenTreeTable>({ overflow: 'hidden' }) }} - onRowContextMenu={handleRowContextMenu} + onCellContextMenu={handleCellContextMenu} {...optionalParams} /> diff --git a/src/frontend/src/tables/general/AttachmentTable.tsx b/src/frontend/src/tables/general/AttachmentTable.tsx index dbd4f7784d..3e19e45adc 100644 --- a/src/frontend/src/tables/general/AttachmentTable.tsx +++ b/src/frontend/src/tables/general/AttachmentTable.tsx @@ -48,7 +48,8 @@ function attachmentTableColumns(): TableColumn[] { } else { return '-'; } - } + }, + noContext: true }, { accessor: 'comment', diff --git a/src/frontend/src/tables/settings/ImportSessionTable.tsx b/src/frontend/src/tables/settings/ImportSessionTable.tsx index 87deee0a96..8a99ca1d12 100644 --- a/src/frontend/src/tables/settings/ImportSessionTable.tsx +++ b/src/frontend/src/tables/settings/ImportSessionTable.tsx @@ -61,7 +61,8 @@ export default function ImportSesssionTable() { render: (record: any) => ( ), - sortable: false + sortable: false, + noContext: true }, DateColumn({ accessor: 'timestamp', diff --git a/src/frontend/src/tables/settings/StocktakeReportTable.tsx b/src/frontend/src/tables/settings/StocktakeReportTable.tsx index ae0678b059..e31e54bc14 100644 --- a/src/frontend/src/tables/settings/StocktakeReportTable.tsx +++ b/src/frontend/src/tables/settings/StocktakeReportTable.tsx @@ -28,7 +28,8 @@ export default function StocktakeReportTable() { title: t`Report`, sortable: false, switchable: false, - render: (record: any) => + render: (record: any) => , + noContext: true }, { accessor: 'part_count', diff --git a/src/frontend/src/tables/settings/TemplateTable.tsx b/src/frontend/src/tables/settings/TemplateTable.tsx index 70b86cd6bb..162a091646 100644 --- a/src/frontend/src/tables/settings/TemplateTable.tsx +++ b/src/frontend/src/tables/settings/TemplateTable.tsx @@ -219,7 +219,8 @@ export function TemplateTable({ } return ; - } + }, + noContext: true }, { accessor: 'model_type', diff --git a/src/frontend/src/tables/stock/StockItemTestResultTable.tsx b/src/frontend/src/tables/stock/StockItemTestResultTable.tsx index 46863385f9..c6bef2aea8 100644 --- a/src/frontend/src/tables/stock/StockItemTestResultTable.tsx +++ b/src/frontend/src/tables/stock/StockItemTestResultTable.tsx @@ -195,7 +195,10 @@ export default function StockItemTestResultTable({ accessor: 'attachment', title: t`Attachment`, render: (record: any) => - record.attachment && + record.attachment && ( + + ), + noContext: true }, NoteColumn({}), DateColumn({}),