From a7d9600c3d8a1b35555fed3fdb218fc5e579ce5d Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 19 Aug 2024 21:01:05 +1000 Subject: [PATCH] [PUI] Refactor "notYetImplemented" (#7913) * Remove default "not yet implemented" action - Will force us to manually add "not yet implemented" - Intended to highlight where we still need to work * Refactor more components * Fix for onClick --- .../src/components/buttons/ActionButton.tsx | 7 +- .../buttons/PrimaryActionButton.tsx | 5 +- .../importer/ImportDataSelector.tsx | 8 +- .../src/components/items/ActionDropdown.tsx | 129 +++++------------- src/frontend/src/pages/build/BuildDetail.tsx | 7 +- .../src/pages/company/CompanyDetail.tsx | 16 ++- .../src/pages/company/SupplierPartDetail.tsx | 7 +- src/frontend/src/pages/part/PartDetail.tsx | 7 +- .../pages/part/pricing/PriceBreakPanel.tsx | 8 +- .../pages/purchasing/PurchaseOrderDetail.tsx | 7 +- .../src/pages/sales/ReturnOrderDetail.tsx | 7 +- .../src/pages/sales/SalesOrderDetail.tsx | 15 +- .../src/pages/stock/LocationDetail.tsx | 16 ++- src/frontend/src/pages/stock/StockDetail.tsx | 7 +- src/frontend/src/tables/InvenTreeTable.tsx | 5 - src/frontend/src/tables/RowActions.tsx | 63 ++------- src/frontend/src/tables/UploadAction.tsx | 8 -- src/frontend/src/tables/bom/BomTable.tsx | 8 +- .../tables/build/BuildAllocatedStockTable.tsx | 4 +- .../src/tables/build/BuildLineTable.tsx | 10 +- .../src/tables/build/BuildOrderTestTable.tsx | 3 +- .../src/tables/build/BuildOutputTable.tsx | 13 +- .../src/tables/company/AddressTable.tsx | 4 +- .../src/tables/company/CompanyTable.tsx | 4 +- .../src/tables/company/ContactTable.tsx | 4 +- .../src/tables/general/AttachmentTable.tsx | 4 +- .../src/tables/general/ExtraLineItemTable.tsx | 3 +- .../src/tables/part/PartCategoryTable.tsx | 4 +- .../tables/part/PartCategoryTemplateTable.tsx | 4 +- .../src/tables/part/PartParameterTable.tsx | 4 +- .../part/PartParameterTemplateTable.tsx | 4 +- .../src/tables/part/PartTestTemplateTable.tsx | 4 +- .../src/tables/part/RelatedPartTable.tsx | 4 +- .../src/tables/plugin/PluginListTable.tsx | 2 +- .../ManufacturerPartParameterTable.tsx | 4 +- .../purchasing/ManufacturerPartTable.tsx | 4 +- .../purchasing/PurchaseOrderLineItemTable.tsx | 3 +- .../tables/purchasing/SupplierPartTable.tsx | 4 +- .../purchasing/SupplierPriceBreakTable.tsx | 4 +- .../tables/sales/ReturnOrderLineItemTable.tsx | 8 +- .../sales/SalesOrderAllocationTable.tsx | 3 +- .../tables/sales/SalesOrderLineItemTable.tsx | 10 +- .../tables/sales/SalesOrderShipmentTable.tsx | 8 +- .../src/tables/settings/TemplateTable.tsx | 4 +- .../src/tables/stock/LocationTypesTable.tsx | 4 +- .../src/tables/stock/StockItemTable.tsx | 4 +- .../tables/stock/StockItemTestResultTable.tsx | 9 +- .../src/tables/stock/StockLocationTable.tsx | 4 +- 48 files changed, 223 insertions(+), 255 deletions(-) delete mode 100644 src/frontend/src/tables/UploadAction.tsx diff --git a/src/frontend/src/components/buttons/ActionButton.tsx b/src/frontend/src/components/buttons/ActionButton.tsx index dce1209dc1..9acc6c66ad 100644 --- a/src/frontend/src/components/buttons/ActionButton.tsx +++ b/src/frontend/src/components/buttons/ActionButton.tsx @@ -2,7 +2,6 @@ import { ActionIcon, FloatingPosition, Group, Tooltip } from '@mantine/core'; import { ReactNode } from 'react'; import { identifierString } from '../../functions/conversion'; -import { notYetImplemented } from '../../functions/notifications'; export type ActionButtonProps = { icon?: ReactNode; @@ -13,7 +12,7 @@ export type ActionButtonProps = { size?: number | string; radius?: number | string; disabled?: boolean; - onClick?: any; + onClick: (event?: any) => void; hidden?: boolean; tooltipAlignment?: FloatingPosition; }; @@ -42,7 +41,9 @@ export function ActionButton(props: ActionButtonProps) { aria-label={`action-button-${identifierString( props.tooltip ?? props.text ?? '' )}`} - onClick={props.onClick ?? notYetImplemented} + onClick={() => { + props.onClick(); + }} variant={props.variant ?? 'transparent'} > diff --git a/src/frontend/src/components/buttons/PrimaryActionButton.tsx b/src/frontend/src/components/buttons/PrimaryActionButton.tsx index 8d30b3fd36..c4c61d2e89 100644 --- a/src/frontend/src/components/buttons/PrimaryActionButton.tsx +++ b/src/frontend/src/components/buttons/PrimaryActionButton.tsx @@ -1,7 +1,6 @@ import { Button, Tooltip } from '@mantine/core'; import { InvenTreeIcon, InvenTreeIconType } from '../../functions/icons'; -import { notYetImplemented } from '../../functions/notifications'; /** * A "primary action" button for display on a page detail, (for example) @@ -19,7 +18,7 @@ export default function PrimaryActionButton({ icon?: InvenTreeIconType; color?: string; hidden?: boolean; - onClick?: () => void; + onClick: () => void; }) { if (hidden) { return null; @@ -32,7 +31,7 @@ export default function PrimaryActionButton({ color={color} radius="sm" p="xs" - onClick={onClick ?? notYetImplemented} + onClick={onClick} > {title} diff --git a/src/frontend/src/components/importer/ImportDataSelector.tsx b/src/frontend/src/components/importer/ImportDataSelector.tsx index 9c6d7c531f..83c210e3f3 100644 --- a/src/frontend/src/components/importer/ImportDataSelector.tsx +++ b/src/frontend/src/components/importer/ImportDataSelector.tsx @@ -22,7 +22,11 @@ import { apiUrl } from '../../states/ApiState'; import { TableColumn } from '../../tables/Column'; import { TableFilter } from '../../tables/Filter'; import { InvenTreeTable } from '../../tables/InvenTreeTable'; -import { RowDeleteAction, RowEditAction } from '../../tables/RowActions'; +import { + RowAction, + RowDeleteAction, + RowEditAction +} from '../../tables/RowActions'; import { ActionButton } from '../buttons/ActionButton'; import { YesNoButton } from '../buttons/YesNoButton'; import { ApiFormFieldSet } from '../forms/fields/ApiFormField'; @@ -316,7 +320,7 @@ export default function ImporterDataSelector({ }, [session]); const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { return [ { title: t`Accept`, diff --git a/src/frontend/src/components/items/ActionDropdown.tsx b/src/frontend/src/components/items/ActionDropdown.tsx index f291bd520e..2e8a2df425 100644 --- a/src/frontend/src/components/items/ActionDropdown.tsx +++ b/src/frontend/src/components/items/ActionDropdown.tsx @@ -20,16 +20,15 @@ import { ReactNode, useMemo } from 'react'; import { ModelType } from '../../enums/ModelType'; import { identifierString } from '../../functions/conversion'; import { InvenTreeIcon } from '../../functions/icons'; -import { notYetImplemented } from '../../functions/notifications'; import { InvenTreeQRCode } from './QRCode'; export type ActionDropdownItem = { - icon: ReactNode; - name: string; + icon?: ReactNode; + name?: string; tooltip?: string; disabled?: boolean; hidden?: boolean; - onClick?: () => void; + onClick: (event?: any) => void; indicator?: Omit; }; @@ -97,13 +96,7 @@ export function ActionDropdown({ { - if (action.onClick != undefined) { - action.onClick(); - } else { - notYetImplemented(); - } - }} + onClick={action.onClick} disabled={action.disabled} > {action.name} @@ -159,131 +152,79 @@ export function ViewBarcodeAction({ } // Common action button for linking a custom barcode -export function LinkBarcodeAction({ - hidden = false, - onClick -}: { - hidden?: boolean; - onClick?: () => void; -}): ActionDropdownItem { +export function LinkBarcodeAction( + props: ActionDropdownItem +): ActionDropdownItem { return { + ...props, icon: , name: t`Link Barcode`, - tooltip: t`Link custom barcode`, - onClick: onClick, - hidden: hidden + tooltip: t`Link custom barcode` }; } // Common action button for un-linking a custom barcode -export function UnlinkBarcodeAction({ - hidden = false, - onClick -}: { - hidden?: boolean; - onClick?: () => void; -}): ActionDropdownItem { +export function UnlinkBarcodeAction( + props: ActionDropdownItem +): ActionDropdownItem { return { + ...props, icon: , name: t`Unlink Barcode`, - tooltip: t`Unlink custom barcode`, - onClick: onClick, - hidden: hidden + tooltip: t`Unlink custom barcode` }; } // Common action button for editing an item -export function EditItemAction({ - hidden = false, - tooltip, - onClick -}: { - hidden?: boolean; - tooltip?: string; - onClick?: () => void; -}): ActionDropdownItem { +export function EditItemAction(props: ActionDropdownItem): ActionDropdownItem { return { + ...props, icon: , name: t`Edit`, - tooltip: tooltip ?? `Edit item`, - onClick: onClick, - hidden: hidden + tooltip: props.tooltip ?? t`Edit item` }; } // Common action button for deleting an item -export function DeleteItemAction({ - hidden = false, - disabled = false, - tooltip, - onClick -}: { - hidden?: boolean; - disabled?: boolean; - tooltip?: string; - onClick?: () => void; -}): ActionDropdownItem { +export function DeleteItemAction( + props: ActionDropdownItem +): ActionDropdownItem { return { + ...props, icon: , name: t`Delete`, - tooltip: tooltip ?? t`Delete item`, - onClick: onClick, - hidden: hidden, - disabled: disabled + tooltip: props.tooltip ?? t`Delete item` }; } -export function HoldItemAction({ - hidden = false, - tooltip, - onClick -}: { - hidden?: boolean; - tooltip?: string; - onClick?: () => void; -}): ActionDropdownItem { +export function HoldItemAction(props: ActionDropdownItem): ActionDropdownItem { return { + ...props, icon: , name: t`Hold`, - tooltip: tooltip ?? t`Hold`, - onClick: onClick, - hidden: hidden + tooltip: props.tooltip ?? t`Hold` }; } -export function CancelItemAction({ - hidden = false, - tooltip, - onClick -}: { - hidden?: boolean; - tooltip?: string; - onClick?: () => void; -}): ActionDropdownItem { +export function CancelItemAction( + props: ActionDropdownItem +): ActionDropdownItem { return { + ...props, icon: , name: t`Cancel`, - tooltip: tooltip ?? t`Cancel`, - onClick: onClick, - hidden: hidden + tooltip: props.tooltip ?? t`Cancel` }; } // Common action button for duplicating an item -export function DuplicateItemAction({ - hidden = false, - tooltip, - onClick -}: { - hidden?: boolean; - tooltip?: string; - onClick?: () => void; -}): ActionDropdownItem { +export function DuplicateItemAction( + props: ActionDropdownItem +): ActionDropdownItem { return { + ...props, icon: , name: t`Duplicate`, - tooltip: tooltip ?? t`Duplicate item`, - onClick: onClick, - hidden: hidden + tooltip: props.tooltip ?? t`Duplicate item` }; } diff --git a/src/frontend/src/pages/build/BuildDetail.tsx b/src/frontend/src/pages/build/BuildDetail.tsx index 5796319a14..ff0f30a8c2 100644 --- a/src/frontend/src/pages/build/BuildDetail.tsx +++ b/src/frontend/src/pages/build/BuildDetail.tsx @@ -43,6 +43,7 @@ import { ApiEndpoints } from '../../enums/ApiEndpoints'; import { ModelType } from '../../enums/ModelType'; import { UserRoles } from '../../enums/Roles'; import { useBuildOrderFields } from '../../forms/BuildForms'; +import { notYetImplemented } from '../../functions/notifications'; import { useCreateApiFormModal, useEditApiFormModal @@ -477,10 +478,12 @@ export default function BuildDetail() { pk: build.pk }), LinkBarcodeAction({ - hidden: build?.barcode_hash + hidden: build?.barcode_hash, + onClick: notYetImplemented }), UnlinkBarcodeAction({ - hidden: !build?.barcode_hash + hidden: !build?.barcode_hash, + onClick: notYetImplemented }) ]} />, diff --git a/src/frontend/src/pages/company/CompanyDetail.tsx b/src/frontend/src/pages/company/CompanyDetail.tsx index dab24dd724..77e1f75f49 100644 --- a/src/frontend/src/pages/company/CompanyDetail.tsx +++ b/src/frontend/src/pages/company/CompanyDetail.tsx @@ -37,7 +37,10 @@ import { ApiEndpoints } from '../../enums/ApiEndpoints'; import { ModelType } from '../../enums/ModelType'; import { UserRoles } from '../../enums/Roles'; import { companyFields } from '../../forms/CompanyForms'; -import { useEditApiFormModal } from '../../hooks/UseForm'; +import { + useDeleteApiFormModal, + useEditApiFormModal +} from '../../hooks/UseForm'; import { useInstance } from '../../hooks/UseInstance'; import { useUserState } from '../../states/UserState'; import { AddressTable } from '../../tables/company/AddressTable'; @@ -289,6 +292,13 @@ export default function CompanyDetail(props: Readonly) { onFormSuccess: refreshInstance }); + const deleteCompany = useDeleteApiFormModal({ + url: ApiEndpoints.company_list, + pk: company?.pk, + title: t`Delete Company`, + onFormSuccess: refreshInstance + }); + const companyActions = useMemo(() => { return [ , @@ -301,7 +311,8 @@ export default function CompanyDetail(props: Readonly) { onClick: () => editCompany.open() }), DeleteItemAction({ - hidden: !user.hasDeleteRole(UserRoles.purchase_order) + hidden: !user.hasDeleteRole(UserRoles.purchase_order), + onClick: () => deleteCompany.open() }) ]} /> @@ -321,6 +332,7 @@ export default function CompanyDetail(props: Readonly) { return ( <> {editCompany.modal} + {deleteCompany.modal} , diff --git a/src/frontend/src/pages/part/PartDetail.tsx b/src/frontend/src/pages/part/PartDetail.tsx index e604a14ed7..74343e14fb 100644 --- a/src/frontend/src/pages/part/PartDetail.tsx +++ b/src/frontend/src/pages/part/PartDetail.tsx @@ -74,6 +74,7 @@ import { useTransferStockItem } from '../../forms/StockForms'; import { InvenTreeIcon } from '../../functions/icons'; +import { notYetImplemented } from '../../functions/notifications'; import { getDetailUrl } from '../../functions/urls'; import { useCreateApiFormModal, @@ -978,10 +979,12 @@ export default function PartDetail() { pk: part.pk }), LinkBarcodeAction({ - hidden: part?.barcode_hash || !user.hasChangeRole(UserRoles.part) + hidden: part?.barcode_hash || !user.hasChangeRole(UserRoles.part), + onClick: notYetImplemented }), UnlinkBarcodeAction({ - hidden: !part?.barcode_hash || !user.hasChangeRole(UserRoles.part) + hidden: !part?.barcode_hash || !user.hasChangeRole(UserRoles.part), + onClick: notYetImplemented }) ]} key="action_dropdown" diff --git a/src/frontend/src/pages/part/pricing/PriceBreakPanel.tsx b/src/frontend/src/pages/part/pricing/PriceBreakPanel.tsx index fa1da3fe07..e9cd680165 100644 --- a/src/frontend/src/pages/part/pricing/PriceBreakPanel.tsx +++ b/src/frontend/src/pages/part/pricing/PriceBreakPanel.tsx @@ -19,7 +19,11 @@ import { apiUrl } from '../../../states/ApiState'; import { useUserState } from '../../../states/UserState'; import { TableColumn } from '../../../tables/Column'; import { InvenTreeTable } from '../../../tables/InvenTreeTable'; -import { RowDeleteAction, RowEditAction } from '../../../tables/RowActions'; +import { + RowAction, + RowDeleteAction, + RowEditAction +} from '../../../tables/RowActions'; import { NoPricingData } from './PricingPanel'; export default function PriceBreakPanel({ @@ -113,7 +117,7 @@ export default function PriceBreakPanel({ }, [user]); const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { return [ RowEditAction({ hidden: !user.hasChangeRole(UserRoles.part), diff --git a/src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx b/src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx index 7f9ab3cd53..a2eacb9d7b 100644 --- a/src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx +++ b/src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx @@ -39,6 +39,7 @@ import { ApiEndpoints } from '../../enums/ApiEndpoints'; import { ModelType } from '../../enums/ModelType'; import { UserRoles } from '../../enums/Roles'; import { usePurchaseOrderFields } from '../../forms/PurchaseOrderForms'; +import { notYetImplemented } from '../../functions/notifications'; import { useCreateApiFormModal, useEditApiFormModal @@ -408,10 +409,12 @@ export default function PurchaseOrderDetail() { pk: order.pk }), LinkBarcodeAction({ - hidden: order?.barcode_hash + hidden: order?.barcode_hash, + onClick: notYetImplemented }), UnlinkBarcodeAction({ - hidden: !order?.barcode_hash + hidden: !order?.barcode_hash, + onClick: notYetImplemented }) ]} />, diff --git a/src/frontend/src/pages/sales/ReturnOrderDetail.tsx b/src/frontend/src/pages/sales/ReturnOrderDetail.tsx index b695521750..f623f35857 100644 --- a/src/frontend/src/pages/sales/ReturnOrderDetail.tsx +++ b/src/frontend/src/pages/sales/ReturnOrderDetail.tsx @@ -38,6 +38,7 @@ import { ApiEndpoints } from '../../enums/ApiEndpoints'; import { ModelType } from '../../enums/ModelType'; import { UserRoles } from '../../enums/Roles'; import { useReturnOrderFields } from '../../forms/SalesOrderForms'; +import { notYetImplemented } from '../../functions/notifications'; import { useCreateApiFormModal, useEditApiFormModal @@ -409,10 +410,12 @@ export default function ReturnOrderDetail() { pk: order.pk }), LinkBarcodeAction({ - hidden: order?.barcode_hash + hidden: order?.barcode_hash, + onClick: notYetImplemented }), UnlinkBarcodeAction({ - hidden: !order?.barcode_hash + hidden: !order?.barcode_hash, + onClick: notYetImplemented }) ]} />, diff --git a/src/frontend/src/pages/sales/SalesOrderDetail.tsx b/src/frontend/src/pages/sales/SalesOrderDetail.tsx index db6dd1ab63..73c9173545 100644 --- a/src/frontend/src/pages/sales/SalesOrderDetail.tsx +++ b/src/frontend/src/pages/sales/SalesOrderDetail.tsx @@ -41,6 +41,7 @@ import { ApiEndpoints } from '../../enums/ApiEndpoints'; import { ModelType } from '../../enums/ModelType'; import { UserRoles } from '../../enums/Roles'; import { useSalesOrderFields } from '../../forms/SalesOrderForms'; +import { notYetImplemented } from '../../functions/notifications'; import { useCreateApiFormModal, useEditApiFormModal @@ -449,10 +450,12 @@ export default function SalesOrderDetail() { pk: order.pk }), LinkBarcodeAction({ - hidden: order?.barcode_hash + hidden: order?.barcode_hash, + onClick: notYetImplemented }), UnlinkBarcodeAction({ - hidden: !order?.barcode_hash + hidden: !order?.barcode_hash, + onClick: notYetImplemented }) ]} />, @@ -467,23 +470,23 @@ export default function SalesOrderDetail() { actions={[ EditItemAction({ hidden: !canEdit, - onClick: () => editSalesOrder.open(), + onClick: editSalesOrder.open, tooltip: t`Edit order` }), DuplicateItemAction({ hidden: !user.hasAddRole(UserRoles.sales_order), - onClick: () => duplicateSalesOrder.open(), + onClick: duplicateSalesOrder.open, tooltip: t`Duplicate order` }), HoldItemAction({ tooltip: t`Hold order`, hidden: !canHold, - onClick: () => holdOrder.open() + onClick: holdOrder.open }), CancelItemAction({ tooltip: t`Cancel order`, hidden: !canCancel, - onClick: () => cancelOrder.open() + onClick: cancelOrder.open }) ]} /> diff --git a/src/frontend/src/pages/stock/LocationDetail.tsx b/src/frontend/src/pages/stock/LocationDetail.tsx index 1bb074b9d5..b55f49872c 100644 --- a/src/frontend/src/pages/stock/LocationDetail.tsx +++ b/src/frontend/src/pages/stock/LocationDetail.tsx @@ -38,6 +38,7 @@ import { useTransferStockItem } from '../../forms/StockForms'; import { InvenTreeIcon } from '../../functions/icons'; +import { notYetImplemented } from '../../functions/notifications'; import { getDetailUrl } from '../../functions/urls'; import { useDeleteApiFormModal, @@ -280,6 +281,7 @@ export default function Stock() { , } + onClick={notYetImplemented} variant="outline" size="lg" />, @@ -290,17 +292,23 @@ export default function Stock() { model: ModelType.stocklocation, pk: location.pk }), - LinkBarcodeAction({}), - UnlinkBarcodeAction({}), + LinkBarcodeAction({ + onClick: notYetImplemented + }), + UnlinkBarcodeAction({ + onClick: notYetImplemented + }), { name: 'Scan in stock items', icon: , - tooltip: 'Scan items' + tooltip: 'Scan items', + onClick: notYetImplemented }, { name: 'Scan in container', icon: , - tooltip: 'Scan container' + tooltip: 'Scan container', + onClick: notYetImplemented } ]} /> diff --git a/src/frontend/src/pages/stock/StockDetail.tsx b/src/frontend/src/pages/stock/StockDetail.tsx index 678b4e4500..3316b3dd7b 100644 --- a/src/frontend/src/pages/stock/StockDetail.tsx +++ b/src/frontend/src/pages/stock/StockDetail.tsx @@ -50,6 +50,7 @@ import { useTransferStockItem } from '../../forms/StockForms'; import { InvenTreeIcon } from '../../functions/icons'; +import { notYetImplemented } from '../../functions/notifications'; import { getDetailUrl } from '../../functions/urls'; import { useCreateApiFormModal, @@ -483,11 +484,13 @@ export default function StockDetail() { }), LinkBarcodeAction({ hidden: - stockitem?.barcode_hash || !user.hasChangeRole(UserRoles.stock) + stockitem?.barcode_hash || !user.hasChangeRole(UserRoles.stock), + onClick: notYetImplemented }), UnlinkBarcodeAction({ hidden: - !stockitem?.barcode_hash || !user.hasChangeRole(UserRoles.stock) + !stockitem?.barcode_hash || !user.hasChangeRole(UserRoles.stock), + onClick: notYetImplemented }) ]} />, diff --git a/src/frontend/src/tables/InvenTreeTable.tsx b/src/frontend/src/tables/InvenTreeTable.tsx index 9419c12777..233378af0c 100644 --- a/src/frontend/src/tables/InvenTreeTable.tsx +++ b/src/frontend/src/tables/InvenTreeTable.tsx @@ -53,7 +53,6 @@ import { TableFilter } from './Filter'; import { FilterSelectDrawer } from './FilterSelectDrawer'; import { RowAction, RowActions } from './RowActions'; import { TableSearchInput } from './Search'; -import { UploadAction } from './UploadAction'; const defaultPageSize: number = 25; @@ -66,7 +65,6 @@ const defaultPageSize: number = 25; * @param noRecordsText : string - Text to display when no records are found * @param enableBulkDelete : boolean - Enable bulk deletion of records * @param enableDownload : boolean - Enable download actions - * @param enableUpload : boolean - Enable upload actions * @param enableFilters : boolean - Enable filter actions * @param enableSelection : boolean - Enable row selection * @param enableSearch : boolean - Enable search actions @@ -92,7 +90,6 @@ export type InvenTreeTableProps = { noRecordsText?: string; enableBulkDelete?: boolean; enableDownload?: boolean; - enableUpload?: boolean; enableFilters?: boolean; enableSelection?: boolean; enableSearch?: boolean; @@ -125,7 +122,6 @@ const defaultInvenTreeTableProps: InvenTreeTableProps = { params: {}, noRecordsText: t`No records found`, enableDownload: false, - enableUpload: false, enableLabels: false, enableReports: false, enableFilters: true, @@ -607,7 +603,6 @@ export function InvenTreeTable({ - {tableProps.enableUpload && } void; + icon?: ReactNode; + onClick: () => void; hidden?: boolean; disabled?: boolean; }; // Component for duplicating a row in a table -export function RowDuplicateAction({ - onClick, - tooltip, - hidden -}: { - onClick?: () => void; - tooltip?: string; - hidden?: boolean; -}): RowAction { +export function RowDuplicateAction(props: RowAction): RowAction { return { + ...props, title: t`Duplicate`, color: 'green', - tooltip: tooltip, - onClick: onClick, - icon: , - hidden: hidden + icon: }; } // Component for editing a row in a table -export function RowEditAction({ - onClick, - tooltip, - hidden -}: { - onClick?: () => void; - tooltip?: string; - hidden?: boolean; -}): RowAction { +export function RowEditAction(props: RowAction): RowAction { return { + ...props, title: t`Edit`, color: 'blue', - tooltip: tooltip, - onClick: onClick, - icon: , - hidden: hidden + icon: }; } // Component for deleting a row in a table -export function RowDeleteAction({ - onClick, - tooltip, - hidden -}: { - onClick?: () => void; - tooltip?: string; - hidden?: boolean; -}): RowAction { +export function RowDeleteAction(props: RowAction): RowAction { return { + ...props, title: t`Delete`, color: 'red', - tooltip: tooltip, - onClick: onClick, - icon: , - hidden: hidden + icon: }; } @@ -120,13 +89,7 @@ export function RowActions({ onClick={(event) => { // Prevent clicking on the action from selecting the row itself cancelEvent(event); - - if (action.onClick) { - action.onClick(); - } else { - notYetImplemented(); - } - + action.onClick(); setOpened(false); }} disabled={action.disabled || false} diff --git a/src/frontend/src/tables/UploadAction.tsx b/src/frontend/src/tables/UploadAction.tsx deleted file mode 100644 index 0230b975c7..0000000000 --- a/src/frontend/src/tables/UploadAction.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { t } from '@lingui/macro'; -import { IconUpload } from '@tabler/icons-react'; - -import { ActionButton } from '../components/buttons/ActionButton'; - -export function UploadAction({}) { - return } tooltip={t`Upload Data`} />; -} diff --git a/src/frontend/src/tables/bom/BomTable.tsx b/src/frontend/src/tables/bom/BomTable.tsx index c51764057d..73cec15aec 100644 --- a/src/frontend/src/tables/bom/BomTable.tsx +++ b/src/frontend/src/tables/bom/BomTable.tsx @@ -23,6 +23,7 @@ import { ModelType } from '../../enums/ModelType'; import { UserRoles } from '../../enums/Roles'; import { bomItemFields } from '../../forms/BomForms'; import { dataImporterSessionFields } from '../../forms/ImporterForms'; +import { notYetImplemented } from '../../functions/notifications'; import { useApiFormModal, useCreateApiFormModal, @@ -41,7 +42,7 @@ import { } from '../ColumnRenderers'; import { TableFilter } from '../Filter'; import { InvenTreeTable } from '../InvenTreeTable'; -import { RowDeleteAction, RowEditAction } from '../RowActions'; +import { RowAction, RowDeleteAction, RowEditAction } from '../RowActions'; import { TableHoverCard } from '../TableHoverCard'; // Calculate the total stock quantity available for a given BomItem @@ -454,7 +455,7 @@ export function BomTable({ }, []); const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { // If this BOM item is defined for a *different* parent, then it cannot be edited if (record.part && record.part != partId) { return [ @@ -488,7 +489,8 @@ export function BomTable({ title: t`Edit Substitutes`, color: 'blue', hidden: partLocked || !user.hasChangeRole(UserRoles.part), - icon: + icon: , + onClick: notYetImplemented }, RowDeleteAction({ hidden: partLocked || !user.hasDeleteRole(UserRoles.part), diff --git a/src/frontend/src/tables/build/BuildAllocatedStockTable.tsx b/src/frontend/src/tables/build/BuildAllocatedStockTable.tsx index b2b9df3ee1..f39bdbbdf0 100644 --- a/src/frontend/src/tables/build/BuildAllocatedStockTable.tsx +++ b/src/frontend/src/tables/build/BuildAllocatedStockTable.tsx @@ -20,7 +20,7 @@ import { } from '../ColumnRenderers'; import { TableFilter } from '../Filter'; import { InvenTreeTable } from '../InvenTreeTable'; -import { RowDeleteAction, RowEditAction } from '../RowActions'; +import { RowAction, RowDeleteAction, RowEditAction } from '../RowActions'; /** * Render a table of allocated stock for a build. @@ -155,7 +155,7 @@ export default function BuildAllocatedStockTable({ }); const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { return [ RowEditAction({ hidden: !user.hasChangeRole(UserRoles.build), diff --git a/src/frontend/src/tables/build/BuildLineTable.tsx b/src/frontend/src/tables/build/BuildLineTable.tsx index 9a66fb1533..471f372046 100644 --- a/src/frontend/src/tables/build/BuildLineTable.tsx +++ b/src/frontend/src/tables/build/BuildLineTable.tsx @@ -12,6 +12,7 @@ import { ApiEndpoints } from '../../enums/ApiEndpoints'; import { ModelType } from '../../enums/ModelType'; import { UserRoles } from '../../enums/Roles'; import { useBuildOrderFields } from '../../forms/BuildForms'; +import { notYetImplemented } from '../../functions/notifications'; import { useCreateApiFormModal } from '../../hooks/UseForm'; import { useTable } from '../../hooks/UseTable'; import { apiUrl } from '../../states/ApiState'; @@ -20,6 +21,7 @@ import { TableColumn } from '../Column'; import { BooleanColumn, PartColumn } from '../ColumnRenderers'; import { TableFilter } from '../Filter'; import { InvenTreeTable } from '../InvenTreeTable'; +import { RowAction } from '../RowActions'; import { TableHoverCard } from '../TableHoverCard'; export default function BuildLineTable({ @@ -270,7 +272,7 @@ export default function BuildLineTable({ }); const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { let part = record.part_detail ?? {}; // Consumable items have no appropriate actions @@ -295,13 +297,15 @@ export default function BuildLineTable({ icon: , title: t`Allocate Stock`, hidden: !canAllocate, - color: 'green' + color: 'green', + onClick: notYetImplemented }, { icon: , title: t`Order Stock`, hidden: !canOrder, - color: 'blue' + color: 'blue', + onClick: notYetImplemented }, { icon: , diff --git a/src/frontend/src/tables/build/BuildOrderTestTable.tsx b/src/frontend/src/tables/build/BuildOrderTestTable.tsx index 371e7530a6..dc4145ae5c 100644 --- a/src/frontend/src/tables/build/BuildOrderTestTable.tsx +++ b/src/frontend/src/tables/build/BuildOrderTestTable.tsx @@ -19,6 +19,7 @@ import { TableColumn } from '../Column'; import { LocationColumn } from '../ColumnRenderers'; import { TableFilter } from '../Filter'; import { InvenTreeTable } from '../InvenTreeTable'; +import { RowAction } from '../RowActions'; import { TableHoverCard } from '../TableHoverCard'; /** @@ -226,7 +227,7 @@ export default function BuildOrderTestTable({ }, []); const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { return []; }, [user] diff --git a/src/frontend/src/tables/build/BuildOutputTable.tsx b/src/frontend/src/tables/build/BuildOutputTable.tsx index 3274109a4c..61dd1a8dc4 100644 --- a/src/frontend/src/tables/build/BuildOutputTable.tsx +++ b/src/frontend/src/tables/build/BuildOutputTable.tsx @@ -18,6 +18,7 @@ import { useScrapBuildOutputsForm } from '../../forms/BuildForms'; import { InvenTreeIcon } from '../../functions/icons'; +import { notYetImplemented } from '../../functions/notifications'; import { useCreateApiFormModal } from '../../hooks/UseForm'; import { useTable } from '../../hooks/UseTable'; import { apiUrl } from '../../states/ApiState'; @@ -245,19 +246,21 @@ export default function BuildOutputTable({ build }: { build: any }) { }, [user, table.selectedRecords, table.hasSelectedRecords]); const rowActions = useCallback( - (record: any) => { - let actions: RowAction[] = [ + (record: any): RowAction[] => { + return [ { title: t`Allocate`, tooltip: t`Allocate stock to build output`, color: 'blue', - icon: + icon: , + onClick: notYetImplemented }, { title: t`Deallocate`, tooltip: t`Deallocate stock from build output`, color: 'red', - icon: + icon: , + onClick: notYetImplemented }, { title: t`Complete`, @@ -290,8 +293,6 @@ export default function BuildOutputTable({ build }: { build: any }) { } } ]; - - return actions; }, [user, partId] ); diff --git a/src/frontend/src/tables/company/AddressTable.tsx b/src/frontend/src/tables/company/AddressTable.tsx index e6bc03a353..e65b42bc01 100644 --- a/src/frontend/src/tables/company/AddressTable.tsx +++ b/src/frontend/src/tables/company/AddressTable.tsx @@ -16,7 +16,7 @@ import { apiUrl } from '../../states/ApiState'; import { useUserState } from '../../states/UserState'; import { TableColumn } from '../Column'; import { InvenTreeTable } from '../InvenTreeTable'; -import { RowDeleteAction, RowEditAction } from '../RowActions'; +import { RowAction, RowDeleteAction, RowEditAction } from '../RowActions'; export function AddressTable({ companyId, @@ -146,7 +146,7 @@ export function AddressTable({ }); const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { let can_edit = user.hasChangeRole(UserRoles.purchase_order) || user.hasChangeRole(UserRoles.sales_order); diff --git a/src/frontend/src/tables/company/CompanyTable.tsx b/src/frontend/src/tables/company/CompanyTable.tsx index 6bd47b8bda..0b1970bf8c 100644 --- a/src/frontend/src/tables/company/CompanyTable.tsx +++ b/src/frontend/src/tables/company/CompanyTable.tsx @@ -19,7 +19,7 @@ import { useUserState } from '../../states/UserState'; import { BooleanColumn, DescriptionColumn } from '../ColumnRenderers'; import { TableFilter } from '../Filter'; import { InvenTreeTable } from '../InvenTreeTable'; -import { RowEditAction } from '../RowActions'; +import { RowAction, RowEditAction } from '../RowActions'; /** * A table which displays a list of company records, @@ -128,7 +128,7 @@ export function CompanyTable({ }, [user]); const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { return [ RowEditAction({ hidden: diff --git a/src/frontend/src/tables/company/ContactTable.tsx b/src/frontend/src/tables/company/ContactTable.tsx index 8219c6029d..c65bdcc5cf 100644 --- a/src/frontend/src/tables/company/ContactTable.tsx +++ b/src/frontend/src/tables/company/ContactTable.tsx @@ -15,7 +15,7 @@ import { apiUrl } from '../../states/ApiState'; import { useUserState } from '../../states/UserState'; import { TableColumn } from '../Column'; import { InvenTreeTable } from '../InvenTreeTable'; -import { RowDeleteAction, RowEditAction } from '../RowActions'; +import { RowAction, RowDeleteAction, RowEditAction } from '../RowActions'; export function ContactTable({ companyId, @@ -91,7 +91,7 @@ export function ContactTable({ }); const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { let can_edit = user.hasChangeRole(UserRoles.purchase_order) || user.hasChangeRole(UserRoles.sales_order); diff --git a/src/frontend/src/tables/general/AttachmentTable.tsx b/src/frontend/src/tables/general/AttachmentTable.tsx index 9b20017e10..3a22fa1f83 100644 --- a/src/frontend/src/tables/general/AttachmentTable.tsx +++ b/src/frontend/src/tables/general/AttachmentTable.tsx @@ -28,7 +28,7 @@ import { useUserState } from '../../states/UserState'; import { TableColumn } from '../Column'; import { TableFilter } from '../Filter'; import { InvenTreeTable } from '../InvenTreeTable'; -import { RowDeleteAction, RowEditAction } from '../RowActions'; +import { RowAction, RowDeleteAction, RowEditAction } from '../RowActions'; /** * Define set of columns to display for the attachment table @@ -262,7 +262,7 @@ export function AttachmentTable({ // Construct row actions for the attachment table const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { return [ RowEditAction({ hidden: !user.hasChangePermission(model_type), diff --git a/src/frontend/src/tables/general/ExtraLineItemTable.tsx b/src/frontend/src/tables/general/ExtraLineItemTable.tsx index a1befeb168..9d5c2d3ad4 100644 --- a/src/frontend/src/tables/general/ExtraLineItemTable.tsx +++ b/src/frontend/src/tables/general/ExtraLineItemTable.tsx @@ -18,6 +18,7 @@ import { TableColumn } from '../Column'; import { LinkColumn, NoteColumn } from '../ColumnRenderers'; import { InvenTreeTable } from '../InvenTreeTable'; import { + RowAction, RowDeleteAction, RowDuplicateAction, RowEditAction @@ -107,7 +108,7 @@ export default function ExtraLineItemTable({ }); const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { return [ RowEditAction({ hidden: !user.hasChangeRole(role), diff --git a/src/frontend/src/tables/part/PartCategoryTable.tsx b/src/frontend/src/tables/part/PartCategoryTable.tsx index b829ff892a..80e2ed934f 100644 --- a/src/frontend/src/tables/part/PartCategoryTable.tsx +++ b/src/frontend/src/tables/part/PartCategoryTable.tsx @@ -20,7 +20,7 @@ import { TableColumn } from '../Column'; import { DescriptionColumn } from '../ColumnRenderers'; import { TableFilter } from '../Filter'; import { InvenTreeTable } from '../InvenTreeTable'; -import { RowEditAction } from '../RowActions'; +import { RowAction, RowEditAction } from '../RowActions'; /** * PartCategoryTable - Displays a table of part categories @@ -117,7 +117,7 @@ export function PartCategoryTable({ parentId }: { parentId?: any }) { }, [user]); const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { let can_edit = user.hasChangeRole(UserRoles.part_category); return [ diff --git a/src/frontend/src/tables/part/PartCategoryTemplateTable.tsx b/src/frontend/src/tables/part/PartCategoryTemplateTable.tsx index d718aca421..44fc184565 100644 --- a/src/frontend/src/tables/part/PartCategoryTemplateTable.tsx +++ b/src/frontend/src/tables/part/PartCategoryTemplateTable.tsx @@ -17,7 +17,7 @@ import { useUserState } from '../../states/UserState'; import { TableColumn } from '../Column'; import { TableFilter } from '../Filter'; import { InvenTreeTable } from '../InvenTreeTable'; -import { RowDeleteAction, RowEditAction } from '../RowActions'; +import { RowAction, RowDeleteAction, RowEditAction } from '../RowActions'; export default function PartCategoryTemplateTable() { const table = useTable('part-category-parameter-templates'); @@ -104,7 +104,7 @@ export default function PartCategoryTemplateTable() { }, []); const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { return [ RowEditAction({ hidden: !user.hasChangeRole(UserRoles.part), diff --git a/src/frontend/src/tables/part/PartParameterTable.tsx b/src/frontend/src/tables/part/PartParameterTable.tsx index 1f612bdcd5..e08c2bc9f5 100644 --- a/src/frontend/src/tables/part/PartParameterTable.tsx +++ b/src/frontend/src/tables/part/PartParameterTable.tsx @@ -20,7 +20,7 @@ import { useUserState } from '../../states/UserState'; import { TableColumn } from '../Column'; import { DescriptionColumn, PartColumn } from '../ColumnRenderers'; import { InvenTreeTable } from '../InvenTreeTable'; -import { RowDeleteAction, RowEditAction } from '../RowActions'; +import { RowAction, RowDeleteAction, RowEditAction } from '../RowActions'; import { TableHoverCard } from '../TableHoverCard'; /** @@ -140,7 +140,7 @@ export function PartParameterTable({ // Callback for row actions const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { // Actions not allowed for "variant" rows if (String(partId) != String(record.part)) { return []; diff --git a/src/frontend/src/tables/part/PartParameterTemplateTable.tsx b/src/frontend/src/tables/part/PartParameterTemplateTable.tsx index e351eedc12..f19c14dcc1 100644 --- a/src/frontend/src/tables/part/PartParameterTemplateTable.tsx +++ b/src/frontend/src/tables/part/PartParameterTemplateTable.tsx @@ -17,7 +17,7 @@ import { TableColumn } from '../Column'; import { BooleanColumn, DescriptionColumn } from '../ColumnRenderers'; import { TableFilter } from '../Filter'; import { InvenTreeTable } from '../InvenTreeTable'; -import { RowDeleteAction, RowEditAction } from '../RowActions'; +import { RowAction, RowDeleteAction, RowEditAction } from '../RowActions'; export default function PartParameterTemplateTable() { const table = useTable('part-parameter-templates'); @@ -114,7 +114,7 @@ export default function PartParameterTemplateTable() { // Callback for row actions const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { return [ RowEditAction({ hidden: !user.hasChangeRole(UserRoles.part), diff --git a/src/frontend/src/tables/part/PartTestTemplateTable.tsx b/src/frontend/src/tables/part/PartTestTemplateTable.tsx index 1545663a2e..2a8f3c3e1b 100644 --- a/src/frontend/src/tables/part/PartTestTemplateTable.tsx +++ b/src/frontend/src/tables/part/PartTestTemplateTable.tsx @@ -22,7 +22,7 @@ import { TableColumn } from '../Column'; import { BooleanColumn, DescriptionColumn } from '../ColumnRenderers'; import { TableFilter } from '../Filter'; import { InvenTreeTable } from '../InvenTreeTable'; -import { RowDeleteAction, RowEditAction } from '../RowActions'; +import { RowAction, RowDeleteAction, RowEditAction } from '../RowActions'; import { TableHoverCard } from '../TableHoverCard'; export default function PartTestTemplateTable({ @@ -192,7 +192,7 @@ export default function PartTestTemplateTable({ }); const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { const can_edit = user.hasChangeRole(UserRoles.part); const can_delete = user.hasDeleteRole(UserRoles.part); diff --git a/src/frontend/src/tables/part/RelatedPartTable.tsx b/src/frontend/src/tables/part/RelatedPartTable.tsx index 8b4c23004b..85090a6d5f 100644 --- a/src/frontend/src/tables/part/RelatedPartTable.tsx +++ b/src/frontend/src/tables/part/RelatedPartTable.tsx @@ -17,7 +17,7 @@ import { apiUrl } from '../../states/ApiState'; import { useUserState } from '../../states/UserState'; import { TableColumn } from '../Column'; import { InvenTreeTable } from '../InvenTreeTable'; -import { RowDeleteAction } from '../RowActions'; +import { RowAction, RowDeleteAction } from '../RowActions'; /** * Construct a table listing related parts for a given part @@ -111,7 +111,7 @@ export function RelatedPartTable({ partId }: { partId: number }): ReactNode { }, [user]); const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { return [ RowDeleteAction({ hidden: !user.hasDeleteRole(UserRoles.part), diff --git a/src/frontend/src/tables/plugin/PluginListTable.tsx b/src/frontend/src/tables/plugin/PluginListTable.tsx index b4123b5473..98f5aaf730 100644 --- a/src/frontend/src/tables/plugin/PluginListTable.tsx +++ b/src/frontend/src/tables/plugin/PluginListTable.tsx @@ -351,7 +351,7 @@ export default function PluginListTable() { // Determine available actions for a given plugin const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { // TODO: Plugin actions should be updated based on on the users's permissions let actions: RowAction[] = []; diff --git a/src/frontend/src/tables/purchasing/ManufacturerPartParameterTable.tsx b/src/frontend/src/tables/purchasing/ManufacturerPartParameterTable.tsx index 29520d8a40..2bae10254e 100644 --- a/src/frontend/src/tables/purchasing/ManufacturerPartParameterTable.tsx +++ b/src/frontend/src/tables/purchasing/ManufacturerPartParameterTable.tsx @@ -15,7 +15,7 @@ import { apiUrl } from '../../states/ApiState'; import { useUserState } from '../../states/UserState'; import { TableColumn } from '../Column'; import { InvenTreeTable } from '../InvenTreeTable'; -import { RowDeleteAction, RowEditAction } from '../RowActions'; +import { RowAction, RowDeleteAction, RowEditAction } from '../RowActions'; export default function ManufacturerPartParameterTable({ params @@ -80,7 +80,7 @@ export default function ManufacturerPartParameterTable({ }); const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { return [ RowEditAction({ hidden: !user.hasChangeRole(UserRoles.purchase_order), diff --git a/src/frontend/src/tables/purchasing/ManufacturerPartTable.tsx b/src/frontend/src/tables/purchasing/ManufacturerPartTable.tsx index 6b4cc45ded..3d1d2e49ee 100644 --- a/src/frontend/src/tables/purchasing/ManufacturerPartTable.tsx +++ b/src/frontend/src/tables/purchasing/ManufacturerPartTable.tsx @@ -18,7 +18,7 @@ import { useUserState } from '../../states/UserState'; import { TableColumn } from '../Column'; import { DescriptionColumn, LinkColumn, PartColumn } from '../ColumnRenderers'; import { InvenTreeTable } from '../InvenTreeTable'; -import { RowDeleteAction, RowEditAction } from '../RowActions'; +import { RowAction, RowDeleteAction, RowEditAction } from '../RowActions'; /* * Construct a table listing manufacturer parts @@ -108,7 +108,7 @@ export function ManufacturerPartTable({ params }: { params: any }): ReactNode { }, [user]); const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { return [ RowEditAction({ hidden: !user.hasChangeRole(UserRoles.purchase_order), diff --git a/src/frontend/src/tables/purchasing/PurchaseOrderLineItemTable.tsx b/src/frontend/src/tables/purchasing/PurchaseOrderLineItemTable.tsx index 415d862899..a875ec02e8 100644 --- a/src/frontend/src/tables/purchasing/PurchaseOrderLineItemTable.tsx +++ b/src/frontend/src/tables/purchasing/PurchaseOrderLineItemTable.tsx @@ -37,6 +37,7 @@ import { } from '../ColumnRenderers'; import { InvenTreeTable } from '../InvenTreeTable'; import { + RowAction, RowDeleteAction, RowDuplicateAction, RowEditAction @@ -290,7 +291,7 @@ export function PurchaseOrderLineItemTable({ }, [order, poStatus]); const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { let received = (record?.received ?? 0) >= (record?.quantity ?? 0); return [ diff --git a/src/frontend/src/tables/purchasing/SupplierPartTable.tsx b/src/frontend/src/tables/purchasing/SupplierPartTable.tsx index b7fc308627..861a031709 100644 --- a/src/frontend/src/tables/purchasing/SupplierPartTable.tsx +++ b/src/frontend/src/tables/purchasing/SupplierPartTable.tsx @@ -26,7 +26,7 @@ import { } from '../ColumnRenderers'; import { TableFilter } from '../Filter'; import { InvenTreeTable } from '../InvenTreeTable'; -import { RowDeleteAction, RowEditAction } from '../RowActions'; +import { RowAction, RowDeleteAction, RowEditAction } from '../RowActions'; import { TableHoverCard } from '../TableHoverCard'; /* @@ -221,7 +221,7 @@ export function SupplierPartTable({ params }: { params: any }): ReactNode { // Row action callback const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { return [ RowEditAction({ hidden: !user.hasChangeRole(UserRoles.purchase_order), diff --git a/src/frontend/src/tables/purchasing/SupplierPriceBreakTable.tsx b/src/frontend/src/tables/purchasing/SupplierPriceBreakTable.tsx index b470083097..e87a10ed8c 100644 --- a/src/frontend/src/tables/purchasing/SupplierPriceBreakTable.tsx +++ b/src/frontend/src/tables/purchasing/SupplierPriceBreakTable.tsx @@ -20,7 +20,7 @@ import { apiUrl } from '../../states/ApiState'; import { useUserState } from '../../states/UserState'; import { TableColumn } from '../Column'; import { InvenTreeTable } from '../InvenTreeTable'; -import { RowDeleteAction, RowEditAction } from '../RowActions'; +import { RowAction, RowDeleteAction, RowEditAction } from '../RowActions'; export function calculateSupplierPartUnitPrice(record: any) { let pack_quantity = record?.part_detail?.pack_quantity_native ?? 1; @@ -175,7 +175,7 @@ export default function SupplierPriceBreakTable({ }, [user]); const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { return [ RowEditAction({ hidden: !user.hasChangeRole(UserRoles.purchase_order), diff --git a/src/frontend/src/tables/sales/ReturnOrderLineItemTable.tsx b/src/frontend/src/tables/sales/ReturnOrderLineItemTable.tsx index 6b0c7f9b6b..25a7a9fe72 100644 --- a/src/frontend/src/tables/sales/ReturnOrderLineItemTable.tsx +++ b/src/frontend/src/tables/sales/ReturnOrderLineItemTable.tsx @@ -8,6 +8,7 @@ import { ApiEndpoints } from '../../enums/ApiEndpoints'; import { ModelType } from '../../enums/ModelType'; import { UserRoles } from '../../enums/Roles'; import { useReturnOrderLineItemFields } from '../../forms/ReturnOrderForms'; +import { notYetImplemented } from '../../functions/notifications'; import { useCreateApiFormModal, useDeleteApiFormModal, @@ -27,7 +28,7 @@ import { } from '../ColumnRenderers'; import { StatusFilterOptions, TableFilter } from '../Filter'; import { InvenTreeTable } from '../InvenTreeTable'; -import { RowDeleteAction, RowEditAction } from '../RowActions'; +import { RowAction, RowDeleteAction, RowEditAction } from '../RowActions'; export default function ReturnOrderLineItemTable({ orderId, @@ -148,14 +149,15 @@ export default function ReturnOrderLineItemTable({ }, [user, orderId]); const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { const received: boolean = !!record?.received_date; return [ { hidden: received || !user.hasChangeRole(UserRoles.return_order), title: t`Receive Item`, - icon: + icon: , + onClick: notYetImplemented }, RowEditAction({ hidden: !user.hasChangeRole(UserRoles.return_order), diff --git a/src/frontend/src/tables/sales/SalesOrderAllocationTable.tsx b/src/frontend/src/tables/sales/SalesOrderAllocationTable.tsx index 8d2a2907c3..e281eec6f4 100644 --- a/src/frontend/src/tables/sales/SalesOrderAllocationTable.tsx +++ b/src/frontend/src/tables/sales/SalesOrderAllocationTable.tsx @@ -15,6 +15,7 @@ import { } from '../ColumnRenderers'; import { TableFilter } from '../Filter'; import { InvenTreeTable } from '../InvenTreeTable'; +import { RowAction } from '../RowActions'; export default function SalesOrderAllocationTable({ partId, @@ -102,7 +103,7 @@ export default function SalesOrderAllocationTable({ }, []); const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { return []; }, [user] diff --git a/src/frontend/src/tables/sales/SalesOrderLineItemTable.tsx b/src/frontend/src/tables/sales/SalesOrderLineItemTable.tsx index a1c20485c3..240e3a5ccf 100644 --- a/src/frontend/src/tables/sales/SalesOrderLineItemTable.tsx +++ b/src/frontend/src/tables/sales/SalesOrderLineItemTable.tsx @@ -15,6 +15,7 @@ import { ModelType } from '../../enums/ModelType'; import { UserRoles } from '../../enums/Roles'; import { useBuildOrderFields } from '../../forms/BuildForms'; import { useSalesOrderLineItemFields } from '../../forms/SalesOrderForms'; +import { notYetImplemented } from '../../functions/notifications'; import { useCreateApiFormModal, useDeleteApiFormModal, @@ -27,6 +28,7 @@ import { TableColumn } from '../Column'; import { DateColumn, LinkColumn, PartColumn } from '../ColumnRenderers'; import { InvenTreeTable } from '../InvenTreeTable'; import { + RowAction, RowDeleteAction, RowDuplicateAction, RowEditAction @@ -248,7 +250,7 @@ export default function SalesOrderLineItemTable({ }, [user, orderId]); const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { const allocated = (record?.allocated ?? 0) > (record?.quantity ?? 0); return [ @@ -259,7 +261,8 @@ export default function SalesOrderLineItemTable({ !user.hasChangeRole(UserRoles.sales_order), title: t`Allocate stock`, icon: , - color: 'green' + color: 'green', + onClick: notYetImplemented }, { hidden: @@ -285,7 +288,8 @@ export default function SalesOrderLineItemTable({ !record?.part_detail?.purchaseable, title: t`Order stock`, icon: , - color: 'blue' + color: 'blue', + onClick: notYetImplemented }, RowEditAction({ hidden: !editable || !user.hasChangeRole(UserRoles.sales_order), diff --git a/src/frontend/src/tables/sales/SalesOrderShipmentTable.tsx b/src/frontend/src/tables/sales/SalesOrderShipmentTable.tsx index 90108fba5c..fc6474172d 100644 --- a/src/frontend/src/tables/sales/SalesOrderShipmentTable.tsx +++ b/src/frontend/src/tables/sales/SalesOrderShipmentTable.tsx @@ -6,6 +6,7 @@ import { AddItemButton } from '../../components/buttons/AddItemButton'; import { ApiEndpoints } from '../../enums/ApiEndpoints'; import { UserRoles } from '../../enums/Roles'; import { useSalesOrderShipmentFields } from '../../forms/SalesOrderForms'; +import { notYetImplemented } from '../../functions/notifications'; import { useCreateApiFormModal, useDeleteApiFormModal, @@ -18,7 +19,7 @@ import { TableColumn } from '../Column'; import { DateColumn, LinkColumn, NoteColumn } from '../ColumnRenderers'; import { TableFilter } from '../Filter'; import { InvenTreeTable } from '../InvenTreeTable'; -import { RowDeleteAction, RowEditAction } from '../RowActions'; +import { RowAction, RowDeleteAction, RowEditAction } from '../RowActions'; export default function SalesOrderShipmentTable({ orderId @@ -97,14 +98,15 @@ export default function SalesOrderShipmentTable({ }, []); const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { const shipped: boolean = !!record.shipment_date; return [ { hidden: shipped || !user.hasChangeRole(UserRoles.sales_order), title: t`Complete Shipment`, - icon: + icon: , + onClick: notYetImplemented }, RowEditAction({ hidden: !user.hasChangeRole(UserRoles.sales_order), diff --git a/src/frontend/src/tables/settings/TemplateTable.tsx b/src/frontend/src/tables/settings/TemplateTable.tsx index c6bc59c9f7..e5019a3d3e 100644 --- a/src/frontend/src/tables/settings/TemplateTable.tsx +++ b/src/frontend/src/tables/settings/TemplateTable.tsx @@ -15,6 +15,7 @@ import { AttachmentLink } from '../../components/items/AttachmentLink'; import { DetailDrawer } from '../../components/nav/DetailDrawer'; import { ApiEndpoints } from '../../enums/ApiEndpoints'; import { ModelType } from '../../enums/ModelType'; +import { notYetImplemented } from '../../functions/notifications'; import { useFilters } from '../../hooks/UseFilter'; import { useCreateApiFormModal, @@ -187,8 +188,9 @@ export function TemplateTable({ } }), RowDuplicateAction({ - hidden: true + hidden: true, // TODO: Duplicate selected template + onClick: notYetImplemented }), RowDeleteAction({ hidden: !user.hasDeletePermission(templateProps.modelType), diff --git a/src/frontend/src/tables/stock/LocationTypesTable.tsx b/src/frontend/src/tables/stock/LocationTypesTable.tsx index aa4983f9d4..93e0526f0f 100644 --- a/src/frontend/src/tables/stock/LocationTypesTable.tsx +++ b/src/frontend/src/tables/stock/LocationTypesTable.tsx @@ -16,7 +16,7 @@ import { apiUrl } from '../../states/ApiState'; import { useUserState } from '../../states/UserState'; import { TableColumn } from '../Column'; import { InvenTreeTable } from '../InvenTreeTable'; -import { RowDeleteAction, RowEditAction } from '../RowActions'; +import { RowAction, RowDeleteAction, RowEditAction } from '../RowActions'; export default function LocationTypesTable() { const table = useTable('location-types'); @@ -81,7 +81,7 @@ export default function LocationTypesTable() { }, []); const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { return [ RowEditAction({ hidden: !user.hasChangeRole(UserRoles.stock_location), diff --git a/src/frontend/src/tables/stock/StockItemTable.tsx b/src/frontend/src/tables/stock/StockItemTable.tsx index cf63493286..9c8d0e234c 100644 --- a/src/frontend/src/tables/stock/StockItemTable.tsx +++ b/src/frontend/src/tables/stock/StockItemTable.tsx @@ -21,6 +21,7 @@ import { useTransferStockItem } from '../../forms/StockForms'; import { InvenTreeIcon } from '../../functions/icons'; +import { notYetImplemented } from '../../functions/notifications'; import { useCreateApiFormModal } from '../../hooks/UseForm'; import { useTable } from '../../hooks/UseTable'; import { apiUrl } from '../../states/ApiState'; @@ -506,7 +507,8 @@ export function StockItemTable({ name: t`Order stock`, icon: , tooltip: t`Order new stock`, - disabled: !can_add_order || !can_change_order + disabled: !can_add_order || !can_change_order, + onClick: notYetImplemented }, { name: t`Assign to customer`, diff --git a/src/frontend/src/tables/stock/StockItemTestResultTable.tsx b/src/frontend/src/tables/stock/StockItemTestResultTable.tsx index bdce4cea02..fe41d0ac12 100644 --- a/src/frontend/src/tables/stock/StockItemTestResultTable.tsx +++ b/src/frontend/src/tables/stock/StockItemTestResultTable.tsx @@ -32,7 +32,12 @@ import { TableColumn } from '../Column'; import { DateColumn, DescriptionColumn, NoteColumn } from '../ColumnRenderers'; import { TableFilter } from '../Filter'; import { InvenTreeTable } from '../InvenTreeTable'; -import { RowActions, RowDeleteAction, RowEditAction } from '../RowActions'; +import { + RowAction, + RowActions, + RowDeleteAction, + RowEditAction +} from '../RowActions'; export default function StockItemTestResultTable({ partId, @@ -301,7 +306,7 @@ export default function StockItemTestResultTable({ ); const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { if (record.stock_item != undefined && record.stock_item != itemId) { // Test results for other stock items cannot be edited return []; diff --git a/src/frontend/src/tables/stock/StockLocationTable.tsx b/src/frontend/src/tables/stock/StockLocationTable.tsx index 5e60330b44..46f4e445ee 100644 --- a/src/frontend/src/tables/stock/StockLocationTable.tsx +++ b/src/frontend/src/tables/stock/StockLocationTable.tsx @@ -20,7 +20,7 @@ import { TableColumn } from '../Column'; import { BooleanColumn, DescriptionColumn } from '../ColumnRenderers'; import { TableFilter } from '../Filter'; import { InvenTreeTable } from '../InvenTreeTable'; -import { RowEditAction } from '../RowActions'; +import { RowAction, RowEditAction } from '../RowActions'; /** * Stock location table @@ -138,7 +138,7 @@ export function StockLocationTable({ parentId }: { parentId?: any }) { }, [user]); const rowActions = useCallback( - (record: any) => { + (record: any): RowAction[] => { let can_edit = user.hasChangeRole(UserRoles.stock_location); return [