From 4f12c0e620cf29dc7497aad920e854f4a9b125f5 Mon Sep 17 00:00:00 2001 From: Gavin Reynolds Date: Wed, 3 Jan 2024 11:31:14 +0000 Subject: [PATCH] Fix #380 by clearing incident checkboxes as actions are requested, rather 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 --- cypress/e2e/Incidents/incidents.spec.js | 3 +++ .../IncidentTable/IncidentTableComponent.jsx | 14 +++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/cypress/e2e/Incidents/incidents.spec.js b/cypress/e2e/Incidents/incidents.spec.js index aa0e78ed..3bcc3ec2 100644 --- a/cypress/e2e/Incidents/incidents.spec.js +++ b/cypress/e2e/Incidents/incidents.spec.js @@ -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', () => { diff --git a/src/components/IncidentTable/IncidentTableComponent.jsx b/src/components/IncidentTable/IncidentTableComponent.jsx index c98595d4..a37835c6 100644 --- a/src/components/IncidentTable/IncidentTableComponent.jsx +++ b/src/components/IncidentTable/IncidentTableComponent.jsx @@ -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); }