Skip to content

Commit fb276ef

Browse files
fix: implement confirmation window for multi-select actions (#1288)
2 parents 9f6fdcd + c6ec8a2 commit fb276ef

2 files changed

Lines changed: 35 additions & 6 deletions

File tree

apps/e2e/cypress/e2e/instruments.cy.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,8 @@ context('Instrument tests', () => {
642642

643643
cy.get('[data-cy="bulk-reassign-reviews"]').click();
644644

645+
cy.get('[data-cy="confirm-ok"]').click();
646+
645647
cy.get('@createdProposal2Id').then((proposalId) => {
646648
cy.get('[data-cy="multi-instrument-alert"]').contains(`${proposalId}`);
647649
});

apps/frontend/src/components/proposal/ProposalTableOfficer.tsx

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import GetAppIcon from '@mui/icons-material/GetApp';
1414
import GridOnIcon from '@mui/icons-material/GridOn';
1515
import GroupWork from '@mui/icons-material/GroupWork';
1616
import ReduceCapacityIcon from '@mui/icons-material/ReduceCapacity';
17+
import Warning from '@mui/icons-material/Warning';
1718
import { IconButton, Tooltip } from '@mui/material';
1819
import Box from '@mui/material/Box';
1920
import Button from '@mui/material/Button';
@@ -462,6 +463,30 @@ const ProposalTableOfficer = ({
462463
searchParams.getAll('selection').includes(item.primaryKey.toString())
463464
);
464465

466+
const runWithMultiSelectConfirm = (action: () => void) => {
467+
const selectedCount = getSelectedProposalPks().length;
468+
469+
if (selectedCount > 1) {
470+
confirm(action, {
471+
title: 'Are you sure? Multiple proposals selected!',
472+
description: (
473+
<Box display="flex" alignItems="center">
474+
<Warning color="warning" sx={{ marginRight: 1 }} />
475+
<span>
476+
<b>{selectedCount}</b> proposals are selected. This action will
477+
run on all of the selected proposals. Are you sure you want to
478+
proceed?
479+
</span>
480+
</Box>
481+
),
482+
confirmationText: 'Yes, proceed',
483+
cancellationText: 'Cancel',
484+
})();
485+
} else {
486+
action();
487+
}
488+
};
489+
465490
const handleClose = (selectedOption: string) => {
466491
const firstSelectedProposalTitle = getSelectedProposalsData()[0].title;
467492
if (selectedOption === PdfDownloadMenuOption.PDF) {
@@ -780,9 +805,10 @@ const ProposalTableOfficer = ({
780805
{
781806
icon: FileCopy,
782807
tooltip: 'Clone proposals to call',
783-
onClick: () => {
784-
setOpenCallSelection(true);
785-
},
808+
onClick: () =>
809+
runWithMultiSelectConfirm(() => {
810+
setOpenCallSelection(true);
811+
}),
786812
position: 'toolbarOnSelect',
787813
},
788814
{
@@ -817,8 +843,7 @@ const ProposalTableOfficer = ({
817843
},
818844
{
819845
title: 'Delete proposals',
820-
description:
821-
'This action will delete proposals and all data associated with them.',
846+
description: `This action will delete ${selectedProposalsData.length} proposal(s) and all data associated with them.`,
822847
}
823848
)();
824849
},
@@ -911,7 +936,9 @@ const ProposalTableOfficer = ({
911936
tableActions.push({
912937
icon: ReduceCapacityIconComponent,
913938
tooltip: 'Reassign selected Techniqual Reviews',
914-
onClick: handleBulkTechnicalReviewsReassign,
939+
onClick: () => {
940+
runWithMultiSelectConfirm(handleBulkTechnicalReviewsReassign);
941+
},
915942
position: 'toolbarOnSelect',
916943
});
917944

0 commit comments

Comments
 (0)