Skip to content

Commit

Permalink
Fix #380 by clearing incident checkboxes as actions are requested, ra…
Browse files Browse the repository at this point in the history
…ther than completed and potentially filtered out, to avoid react-table's toggleAllRowsSelected behaviour of only working on currently filtered rows

Signed-off-by: Gavin Reynolds <[email protected]>
  • Loading branch information
gsreynolds committed Jan 3, 2024
1 parent 8efb8dc commit 4f12c0e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions cypress/e2e/Incidents/incidents.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ describe('Manage Open Incidents', { failFast: { enabled: true } }, () => {
selectIncident(0);
cy.get('#incident-action-resolve-button').click();
checkActionAlertsModalContent('have been resolved');
// and now show all resolved status (#380)
cy.get('.query-status-resolved-button').check({ force: true });
waitForIncidentTable();
});

it('Update priority of singular incidents', () => {
Expand Down
14 changes: 9 additions & 5 deletions src/components/IncidentTable/IncidentTableComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -441,11 +441,15 @@ const IncidentTableComponent = () => {
// Handle deselecting rows after incident action has completed
useEffect(() => {
// TODO: Get user feedback on this workflow
if (incidentActionsStatus === 'ACTION_COMPLETED') {
toggleAllRowsSelected(false);
} else if (
!incidentActionsStatus.includes('TOGGLE')
&& incidentActionsStatus.includes('COMPLETED')
// toggleAllRowsSelected only works on the currently filtered rows, therefore
// to fix #380 we can't wait for the incidentActionsStatus to be COMPLETED
//
// Workarounds using the stateReducer to clear selectedRowIds also don't appear to work on filtered out rows
// Therefore, clearing the checkbox in the UI before it is filtered out is the best we can do for now
if (
incidentActionsStatus === 'ACTION_COMPLETED'
|| (!incidentActionsStatus.includes('TOGGLE')
&& (incidentActionsStatus.includes('REQUESTED') || incidentActionsStatus.includes('COMPLETED')))
) {
toggleAllRowsSelected(false);
}
Expand Down

0 comments on commit 4f12c0e

Please sign in to comment.