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:
Tristan Timblin
2023-09-18 13:59:45 -07:00
committed by GitHub
parent 9f16e1ebf5
commit 3177d65e3d
27 changed files with 215 additions and 422 deletions

View File

@@ -9,6 +9,7 @@ import {
TableRow,
} from "@material-ui/core";
import CancelIcon from "@material-ui/icons/Cancel";
import ReplayIcon from "@material-ui/icons/Replay";
import React, { useEffect, useState } from "react";
import { Link } from "react-router-dom";
@@ -71,6 +72,7 @@ const MainForm = ({ vin, token }) => {
const [order, setOrder] = useState("desc");
const {
cancelUpdate,
deployUpdate,
getCarUpdates,
carUpdates,
totalCarUpdates,
@@ -158,6 +160,31 @@ const MainForm = ({ vin, token }) => {
}
};
const sendDeploy = async (row) => {
try {
await deployUpdate(row.id, token);
setMessage(`Sent deploy for ${updateName(row)}`);
} catch (e) {
setMessage(e.message);
}
};
const isRedeployAvailable = (status) => {
switch (status) {
case "manifest_succeeded":
case "manifest_canceled":
case "manifest_error":
case "manifest_cancel_pending":
case "rollback_succeeded":
case "manifest_rejected":
case "rollback_failed":
case "cleanup_succeeded":
return true;
default:
return false;
}
}
return (
<Table>
<TableHeaderSortable
@@ -208,6 +235,14 @@ const MainForm = ({ vin, token }) => {
>
<CancelIcon fontSize="inherit" />
</IconButton>
<IconButton
onClick={() => sendDeploy(row)}
aria-label={`Send deploy for ${row.vin}`}
size="small"
disabled={!isRedeployAvailable(row.status)}
>
<ReplayIcon fontSize="inherit" />
</IconButton>
</RoleWrap>
</TableCell>
</TableRow>