Skip to content
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

[Security Solution] Add an enable or disabled state rules filter #150153

Merged
merged 3 commits into from Feb 4, 2023

Conversation

maximpn
Copy link
Contributor

@maximpn maximpn commented Feb 2, 2023

Addresses: #132497

Summary

This PR adds a rules table filter for the enabled and disabled state.

Filter in action:

Screen.Recording.2023-02-02.at.12.45.17.mov

Since the added filter occupies some space the search field may shrink too much. To address this issue wrapping was enabled for the filter row.

Layout responsiveness:

Screen.Recording.2023-02-02.at.17.16.44.mov

Checklist

@maximpn maximpn added backport:skip This commit does not require backporting Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. release_note:feature Makes this part of the condensed release notes Feature:Rule Management Security Solution Detection Rule Management Team:Detection Rule Management Security Detection Rule Management Team Team:Detection Alerts Security Detection Alerts Area Team v8.7.0 labels Feb 2, 2023
@maximpn maximpn self-assigned this Feb 2, 2023
@maximpn maximpn marked this pull request as ready for review February 2, 2023 12:04
@maximpn maximpn requested a review from a team as a code owner February 2, 2023 12:04
@maximpn maximpn requested a review from spong February 2, 2023 12:04
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

@banderror banderror added release_note:enhancement and removed release_note:feature Makes this part of the condensed release notes labels Feb 2, 2023
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 12.9MB 12.9MB +2.4KB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @maximpn

Comment on lines +116 to +131
<EuiFilterGroup>
<EuiFilterButton
hasActiveFilters={enabled === true}
onClick={handleShowEnabledRulesClick}
data-test-subj="showEnabledRulesFilterButton"
withNext
>
{i18n.ENABLED_RULES}
</EuiFilterButton>
<EuiFilterButton
hasActiveFilters={enabled === false}
onClick={handleShowDisabledRulesClick}
data-test-subj="showDisabledRulesFilterButton"
>
{i18n.DISABLED_RULES}
</EuiFilterButton>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since space is of concern with regards to shrinking the search bar, we could always use a drop down for Rule state like they're doing on the Stack Mgmt Rules table (though w/o the extra width 😅):

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need something like that for 8.8 since we plan to add even more filters. For now I'd like to keep it simple.

Comment on lines +53 to +57
if (state.filterOptions.enabled !== undefined) {
urlStateToSave.enabled = state.filterOptions.enabled;
storageStateToSave.enabled = state.filterOptions.enabled;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commenting here since this is where sessionStorage.set() is called below to set the local storage values.

In testing, I had cleared my localstorage via devtools, and now I'm not seeing it be set again? I did a clean deployment and am still seeing this behavior. I'm seeing the urlParams get set, but not localstorage... 🤔

When debugging, for some reason RULES_TABLE_STATE_STORAGE_KEY is showing as undefined (even though it is definitely in the constants file).

image


Also seeing this Typescript error, but when debugging it seems to go into that function and work fine:

image

Copy link
Contributor Author

@maximpn maximpn Feb 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spong thank you for the review!

Could you describe a reproduction scenario when you don't see the state restored in the session storage?

Basically something should happen to update the saved state in the session storage, for example a page reload or state update. I've tested in Chrome and FF and it works well though I have issues with displaying all the session and local storage values in newest Chrome. It worked well after reinstalling Chrome but I have the same problem again. Maybe you experience the same.

Regarding unavailability of RULES_TABLE_STATE_STORAGE_KEY value for debugging. I experience the same but it looks related to the dev tool or it's transpiled the way when constants are inlined.

Regarding TS errors it seems like a local issue. I don't see anything like that. If you just switched a branch and IDE hasn't updated its cache or installed another TS version locally it can be an issue.

I'll double check with the PR implementing the persistence rules table state test plan.

Copy link
Member

@spong spong Feb 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you describe a reproduction scenario when you don't see the state restored in the session storage?

Basically something should happen to update the saved state in the session storage, for example a page reload or state update. I've tested in Chrome and FF and it works well though I have issues with displaying all the session and local storage values in newest Chrome. It worked well after reinstalling Chrome but I have the same problem again. Maybe you experience the same.

Interesting... 🤔 As for repro steps, the only thing I did here was manually delete the securitySolution.rulesTable key under Application -> Local Storage in Dev Tools (at least I recall it being Local Storage, not Session). After poking around a bit more though, it seems it's being added back to the Session Storage section in dev tools instead of Local Storage where the other securitySolution keys are:

Local Storage

image

Sessions Storage

image

I guess this explains why the app is working as expected, as I didn't notice that it was storing to session vs local storage. I was pretty sure I first saw the key in Local Storage, but I could be mistaken here. Either way, sounds like everything is 👍 here and working as expected.


Regarding unavailability of RULES_TABLE_STATE_STORAGE_KEY value for debugging. I experience the same but it looks related to the dev tool or it's transpiled the way when constants are inlined.

Regarding TS errors it seems like a local issue. I don't see anything like that. If you just switched a branch and IDE hasn't updated its cache or installed another TS version locally it can be an issue.

Yeah that was my thought as well (as I often see type issues the end up getting resolved when clicking through to the source). Though with this now merged on main and after a fresh bootstrap, I'm still seeing the same type error. Modifying line 34 to be const urlStateToSave: RisonValue = {}; instead of RulesTableUrlSavedState resolves the error, or of course as casting urlStateToSave as RisonValue inline on line 93 as well. So seems RulesTableUrlSavedState should extend from RisonValue or we should update our types in useReplaceUrlParams() then?

Copy link
Member

@spong spong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked out, tested locally, and code reviewed -- LGTM!

I had one question about localstorage as once I cleared my localstorage via devtools I'm no longer seeing it being set, but if there's no issue there then this is good to merge. 👍

@banderror banderror added Team:Detections and Resp Security Detection Response Team and removed Team:Detection Alerts Security Detection Alerts Area Team labels Feb 3, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-detections-response (Team:Detections and Resp)

@maximpn maximpn merged commit 949cb58 into elastic:main Feb 4, 2023
darnautov pushed a commit to darnautov/kibana that referenced this pull request Feb 7, 2023
…stic#150153)

**Addresses:** elastic#132497

## Summary

This PR adds a rules table filter for the enabled and disabled state.

*Filter in action*:

https://user-images.githubusercontent.com/3775283/216316405-27ad8b21-6392-4705-8af8-53c746a00acf.mov

Since the added filter occupies some space the search field may shrink too much. To address this issue wrapping was enabled for the filter row.

*Layout responsiveness:*

https://user-images.githubusercontent.com/3775283/216380837-3bda2072-4f5b-4754-8e57-8978c5e2b0d5.mov

### Checklist

- [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials
- [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
- [x] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [x] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [x] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [x] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers)
@maximpn maximpn deleted the filter-rules-by-enabled-field branch February 7, 2023 12:59
benakansara pushed a commit to benakansara/kibana that referenced this pull request Feb 7, 2023
…stic#150153)

**Addresses:** elastic#132497

## Summary

This PR adds a rules table filter for the enabled and disabled state.

*Filter in action*:

https://user-images.githubusercontent.com/3775283/216316405-27ad8b21-6392-4705-8af8-53c746a00acf.mov

Since the added filter occupies some space the search field may shrink too much. To address this issue wrapping was enabled for the filter row.

*Layout responsiveness:*

https://user-images.githubusercontent.com/3775283/216380837-3bda2072-4f5b-4754-8e57-8978c5e2b0d5.mov

### Checklist

- [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials
- [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
- [x] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [x] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [x] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [x] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Rule Management Security Solution Detection Rule Management release_note:enhancement Team:Detection Rule Management Security Detection Rule Management Team Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v8.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Security Solution] Add a way to filter rules on enabled or disabled state
5 participants