CEC-2548 Fixed delete confirmation not being pulled up (#202)

Co-authored-by: Alexander Andrews <aandrews@fiskerinc.com>
This commit is contained in:
Alexander Andrews
2022-09-27 15:07:43 -04:00
committed by GitHub
parent b622e42286
commit 63e2d2b18f
2 changed files with 17 additions and 8 deletions

View File

@@ -3329,7 +3329,6 @@ exports[`App Route /packages authenticated 1`] = `
/> />
</svg> </svg>
</a> </a>
<div />
</div> </div>
</td> </td>
</tr> </tr>
@@ -3460,6 +3459,7 @@ exports[`App Route /packages authenticated 1`] = `
</tr> </tr>
</tfoot> </tfoot>
</table> </table>
<div />
</div> </div>
</div> </div>
</main> </main>

View File

@@ -68,7 +68,11 @@ const MainForm = () => {
const [orderBy, setOrderBy] = useState("id"); const [orderBy, setOrderBy] = useState("id");
const [order, setOrder] = useState("asc"); const [order, setOrder] = useState("asc");
const [search, setSearch] = useState(""); const [search, setSearch] = useState("");
const [showDeleteModal, setShowDeleteModal] = useState(false); const [showDeleteModal, setShowDeleteModal] = useState(false);
const [deleteId, setDeleteId] = useState("");
const [deleteRowName, setDeleteRowName] = useState("");
const { getManifests, deleteManifest, manifests, totalManifests } = const { getManifests, deleteManifest, manifests, totalManifests } =
useManifestsContext(); useManifestsContext();
const { setMessage, setTitle, setSitePath } = useStatusContext(); const { setMessage, setTitle, setSitePath } = useStatusContext();
@@ -133,6 +137,12 @@ const MainForm = () => {
setSearch(query); setSearch(query);
}; };
const setDeletePopup = (id, row) => {
setDeleteId(id);
setDeleteRowName(`${row.name} ${row.version}`);
setShowDeleteModal(true);
}
const onDelete = async (manifest_id) => { const onDelete = async (manifest_id) => {
try { try {
await deleteManifest(parseInt(manifest_id), token); await deleteManifest(parseInt(manifest_id), token);
@@ -182,16 +192,10 @@ const MainForm = () => {
return ( return (
<div> <div>
<Tooltip key={`delete-${action.id}`} title={action.tip}> <Tooltip key={`delete-${action.id}`} title={action.tip}>
<Link to="#" onClick={() => onDelete(action.id)}> <Link to="#" onClick={() => setDeletePopup(action.id, row)}>
{action.icon} {action.icon}
</Link> </Link>
</Tooltip> </Tooltip>
<DeleteConfirmation
message={action.id}
open={showDeleteModal}
close={() => setShowDeleteModal(false)}
deleteFunction={() => onDelete(action.id)}
/>
</div> </div>
); );
} }
@@ -261,6 +265,11 @@ const MainForm = () => {
</TableRow> </TableRow>
</TableFooter> </TableFooter>
</Table> </Table>
<DeleteConfirmation
message={deleteRowName}
open={showDeleteModal}
close={() => setShowDeleteModal(false)}
deleteFunction={() => onDelete(deleteId)} />
</div> </div>
); );
}; };