CEC-4920: Add redeploy bulk-action (#420)
* standardize bulk actions * add redploy bulk-action * add cases to disable redeploy * update status check * rename func
This commit is contained in:
@@ -9,8 +9,8 @@ import TaskRunner from "../../../utils/taskRunner";
|
||||
import vehiclesAPI from "../../../services/vehiclesAPI";
|
||||
|
||||
export default forwardRef(({
|
||||
vins,
|
||||
vinCSV,
|
||||
ids,
|
||||
idCSV,
|
||||
}, ref) => {
|
||||
const { setMessage } = useStatusContext();
|
||||
const { token: { idToken: { jwtToken: token } } } = useUserContext();
|
||||
@@ -20,11 +20,11 @@ export default forwardRef(({
|
||||
useImperativeHandle(ref, () => ({
|
||||
async submit() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const taskRunner = new TaskRunner(5, vins.length);
|
||||
const taskRunner = new TaskRunner(5, ids.length);
|
||||
let errorCount = 0;
|
||||
|
||||
const task = (vin, index) => {
|
||||
const progressMessage = `${index + 1}/${vins.length}`;
|
||||
const progressMessage = `${index + 1}/${ids.length}`;
|
||||
return async () => vehiclesAPI.updateConfig(vin, forcePush, token)
|
||||
.then((response) => {
|
||||
if (response.error) {
|
||||
@@ -38,12 +38,12 @@ export default forwardRef(({
|
||||
.catch((error) => reject(error));
|
||||
}
|
||||
|
||||
vins.forEach((vin, i) => {
|
||||
ids.forEach((vin, i) => {
|
||||
taskRunner.push(task(vin, i));
|
||||
});
|
||||
|
||||
taskRunner.onComplete().then((responses) => {
|
||||
const completeMessage = `${vins.length - errorCount}/${vins.length}`;
|
||||
const completeMessage = `${ids.length - errorCount}/${ids.length}`;
|
||||
setMessage(`Successfully updated ${completeMessage} vehicles.`);
|
||||
resolve(responses);
|
||||
});
|
||||
@@ -58,7 +58,7 @@ export default forwardRef(({
|
||||
return (
|
||||
<div>
|
||||
<p>
|
||||
You are updating the config for the following VINs: {vinCSV}.
|
||||
You are updating the config for the following VINs: {idCSV}.
|
||||
</p>
|
||||
<FormControlLabel
|
||||
label="Force Push"
|
||||
|
||||
Reference in New Issue
Block a user