diff --git a/src/components/BulkActions/actions/UpdateFlashpackNumbers.jsx b/src/components/BulkActions/actions/UpdateFlashpackNumbers.jsx index 120a507..675c02e 100644 --- a/src/components/BulkActions/actions/UpdateFlashpackNumbers.jsx +++ b/src/components/BulkActions/actions/UpdateFlashpackNumbers.jsx @@ -6,6 +6,8 @@ import vehiclesAPI from "../../../services/vehiclesAPI"; export default forwardRef(({ ids, idCSV, + fleet, + selectAll, }, ref) => { const { setMessage } = useStatusContext(); const { token: { idToken: { jwtToken: token } } } = useUserContext(); @@ -13,10 +15,12 @@ export default forwardRef(({ useImperativeHandle(ref, () => ({ async submit() { return vehiclesAPI - .flashpackVersionBulkUpdate(ids, token) + .flashpackVersionBulkUpdate(selectAll, fleet, ids, token) .then((data) => { if (data.error) { setMessage(`${data.error}: ${data.message}`); + } else if (selectAll) { + setMessage(`Updating flashpack number all VINs in ${fleet}`); } else if (ids.length === 1) { setMessage(`Updating flashpack number for ${ids[0]}`); } else { @@ -26,11 +30,21 @@ export default forwardRef(({ }, })); - return ( -
- You are updating flashpack numbers for the following VINs: {idCSV}. -
-+ You are updating flashpack numbers for all VINs in the following fleet: {fleet}. +
++ You are updating flashpack numbers for the following VINs: {idCSV}. +
+ + ) + } +}); diff --git a/src/components/BulkActions/index.jsx b/src/components/BulkActions/index.jsx index 1f1d62b..9c5e0e2 100644 --- a/src/components/BulkActions/index.jsx +++ b/src/components/BulkActions/index.jsx @@ -21,6 +21,7 @@ export default function BulkActions({ ids = [], actions = [], fleet = undefined, + selectAll = false, callback = (active, ids, context) => { }, // context is raised from the action itself }) { const [open, setOpen] = useState(false); @@ -92,6 +93,7 @@ export default function BulkActions({ ids, idCSV: (ids && ids.length > 0) ? truncateCSV(ids, 10) : "N/A", fleet, + selectAll, ref: activeRef }; @@ -112,7 +114,7 @@ export default function BulkActions({ setEmbedded(action?.embedded); }, [active, filteredActions]); - if (!ids || ids.length === 0) return <>>; + if (!selectAll && (!ids || ids.length === 0)) return <>>; return ( <> diff --git a/src/components/Fleets/Status/Vehicles/Table/__snapshots__/index.test.jsx.snap b/src/components/Fleets/Status/Vehicles/Table/__snapshots__/index.test.jsx.snap index f828335..3dbb472 100644 --- a/src/components/Fleets/Status/Vehicles/Table/__snapshots__/index.test.jsx.snap +++ b/src/components/Fleets/Status/Vehicles/Table/__snapshots__/index.test.jsx.snap @@ -38,12 +38,53 @@ exports[`FleetVehiclesTable Render 1`] = ` +