Skip to content

Toggle all rules button on detector edit page #239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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