Skip to content

Commit

Permalink
Merge pull request #1458 from janvi01/bulkdeletionsConfirmation
Browse files Browse the repository at this point in the history
Added confirmation for bulk deletion of rows
  • Loading branch information
shamsmosowi authored Nov 8, 2023
2 parents b64bdbc + bb552a5 commit 46826bc
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/components/TableToolbar/TableToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import {
userRolesAtom,
compatibleRowyRunVersionAtom,
rowyRunModalAtom,
altPressAtom,
confirmDialogAtom,
} from "@src/atoms/projectScope";
import {
tableScope,
Expand Down Expand Up @@ -91,6 +93,8 @@ function RowSelectedToolBar({
}) {
const [serverDocCount] = useAtom(serverDocCountAtom, tableScope);
const deleteRow = useSetAtom(deleteRowAtom, tableScope);
const [altPress] = useAtom(altPressAtom, projectScope);
const confirm = useSetAtom(confirmDialogAtom, projectScope);

const handleDelete = async () => {
await deleteRow({ path: Object.keys(selectedRows) });
Expand All @@ -107,7 +111,20 @@ function RowSelectedToolBar({
variant="outlined"
startIcon={<DeleteIcon fontSize="small" />}
color="error"
onClick={handleDelete}
onClick={
altPress
? handleDelete
: () => {
confirm({
title: `Delete ${
Object.values(selectedRows).length
} of ${serverDocCount} selected rows?`,
confirm: "Delete",
confirmColor: "error",
handleConfirm: handleDelete,
});
}
}
>
Delete
</Button>
Expand Down

0 comments on commit 46826bc

Please sign in to comment.