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
Conversation
Pinging @elastic/security-solution (Team: SecuritySolution) |
💚 Build Succeeded
Metrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: cc @maximpn |
<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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
if (state.filterOptions.enabled !== undefined) { | ||
urlStateToSave.enabled = state.filterOptions.enabled; | ||
storageStateToSave.enabled = state.filterOptions.enabled; | ||
} | ||
|
There was a problem hiding this comment.
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).
Also seeing this Typescript error, but when debugging it seems to go into that function and work fine:
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Sessions Storage
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?
There was a problem hiding this 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. 👍
Pinging @elastic/security-detections-response (Team:Detections and Resp) |
…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)
…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)
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