Skip to content

Commit

Permalink
Toggle all rules button on detector edit page (opensearch-project#239) (
Browse files Browse the repository at this point in the history
opensearch-project#251)

* toggle all rules button on detector edit page

Signed-off-by: Aleksandar Djindjic <[email protected]>

* adding toggle all - adds hidden button into table

Signed-off-by: Aleksandar Djindjic <[email protected]>

Signed-off-by: Aleksandar Djindjic <[email protected]>
(cherry picked from commit 24a5dab)

Co-authored-by: Aleksandar Djindjic <[email protected]>
Signed-off-by: AWSHurneyt <[email protected]>
  • Loading branch information
2 people authored and AWSHurneyt committed Oct 12, 2023
1 parent 84adb56 commit 57e45e1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cypress/integration/1_detectors.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ describe('Detectors', () => {
cy.contains('tr', 'USB Device Plugged').within(() => {
// Of note, timeout can sometimes work instead of wait here, but is very unreliable from case to case.
cy.wait(1000);
cy.get('button').eq(0).click();
cy.get('button').eq(1).click();
});

// Save changes
Expand All @@ -246,7 +246,7 @@ describe('Detectors', () => {
// Toggle single search result to checked
cy.contains('tr', 'USB Device Plugged').within(() => {
cy.wait(2000);
cy.get('button').eq(0).click({ force: true });
cy.get('button').eq(1).click({ force: true });
});

// Save changes
Expand Down
6 changes: 6 additions & 0 deletions public/pages/Detectors/components/UpdateRules/UpdateRules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ export const UpdateDetectorRules: React.FC<UpdateDetectorRulesProps> = (props) =
}
};

const onAllRulesToggle = (isActive: boolean) => {
setCustomRuleItems(customRuleItems.map((rule) => ({ ...rule, active: isActive })));
setPrePackagedRuleItems(prePackagedRuleItems.map((rule) => ({ ...rule, active: isActive })));
};

const onCancel = useCallback(() => {
props.history.replace({
pathname: `${ROUTES.DETECTOR_DETAILS}/${detectorId}`,
Expand Down Expand Up @@ -216,6 +221,7 @@ export const UpdateDetectorRules: React.FC<UpdateDetectorRulesProps> = (props) =
loading={loading}
ruleItems={ruleItems}
onRuleActivationToggle={onToggle}
onAllRulesToggled={onAllRulesToggle}
/>

<EuiSpacer size="xl" />
Expand Down

0 comments on commit 57e45e1

Please sign in to comment.