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

[Detections][Alerts] fixes saved_query rule validation issue #142602

Merged
merged 10 commits into from
Oct 10, 2022

Conversation

vitaliidm
Copy link
Contributor

@vitaliidm vitaliidm commented Oct 4, 2022

Summary

Before

saved_query_bug.mp4

After

Screen.Recording.2022-10-04.at.18.15.43.mov

As side effect, it reduced number of requests for saved query:

Before

2 requests were sent
Screenshot 2022-10-05 at 09 39 09

After

Only one request sent

Checklist

Screenshot 2022-10-05 at 09 37 12

Delete any items that are not applicable to this PR.

@vitaliidm vitaliidm self-assigned this Oct 4, 2022
@vitaliidm vitaliidm added fixed Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Detection Alerts Security Detection Alerts Area Team backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) v8.5.0 v8.6.0 Team:Detections and Resp Security Detection Response Team release_note:skip Skip the PR/issue when compiling release notes and removed fixed labels Oct 4, 2022
@vitaliidm vitaliidm marked this pull request as ready for review October 5, 2022 08:42
@vitaliidm vitaliidm requested review from a team as code owners October 5, 2022 08:42
@vitaliidm vitaliidm requested a review from maximpn October 5, 2022 08:42
@elasticmachine
Copy link
Contributor

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

@elasticmachine
Copy link
Contributor

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

Copy link
Contributor

@maximpn maximpn left a comment

Choose a reason for hiding this comment

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

@vitaliidm overall the changes look good, though there is a couple of comments worth to check.

@@ -98,6 +100,11 @@ const EditRulePageComponent: FC = () => {
const [ruleLoading, rule] = useRule(ruleId);
const loading = ruleLoading || userInfoLoading || listsConfigLoading;

const { isSavedQueryLoading, savedQueryBar, savedQuery } = useGetSavedQuery(rule?.saved_id, {
ruleType: rule?.type,
onError: noop,
Copy link
Contributor

Choose a reason for hiding this comment

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

onError: noop, reduces straightness of the code since it requires knowledge what's going on under the hood and suppressing of that behaviour when necessary. I'd recommend to consider removing the default error handling functionality inside, exposing of showErrorToastHandler and passing it directly when necessary. Though it uses toasts then it makes sense to expose a hook like useShowErrorToastHandler() which can be composable and reusable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@maximpn
Toast is not displayed in this case because error is displayed on edit form when saved query is not loaded. Thus it's prevents showing duplicated notifications

Screenshot 2022-10-10 at 11 58 27

<StepPanel loading={loading} title={ruleI18n.DEFINITION}>
{defineStep.data != null && (
<StepPanel loading={loading || isSavedQueryLoading} title={ruleI18n.DEFINITION}>
{defineStepDataWithSavedQuery != null && !isSavedQueryLoading && (
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting that defineStepDataWithSavedQuery is either a specific object or undefined but there is a non strict check for null

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.

non strict check for null eliminates undefined, so the value of defineStepDataWithSavedQuery will be object of DefineStepRule type.

Fairly common pattern across Kibana codebase (example from previous implementation):

            <StepPanel loading={loading} title={ruleI18n.DEFINITION}>
              {defineStep.data != null && (

@vitaliidm vitaliidm requested a review from maximpn October 10, 2022 11:06
@vitaliidm
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@maximpn maximpn left a comment

Choose a reason for hiding this comment

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

@vitaliidm LGTM

@vitaliidm vitaliidm enabled auto-merge (squash) October 10, 2022 16:15
@vitaliidm vitaliidm merged commit 4feb397 into elastic:main Oct 10, 2022
@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Security Solution Tests #4 / Row renderers Selected renderer can be disabled and enabled

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 6.6MB 6.6MB +746.0B

History

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

cc @vitaliidm

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Oct 10, 2022
…#142602)

## Summary

- addresses elastic#141758
- loads saved query on rules edit page before form rendering, thus prevents validation run on uncompleted data(saved query wasn't fetched before QueryBar component renders). Then fetched saved query passed to QueryBarDefineRule component

### Before

https://user-images.githubusercontent.com/92328789/193884969-3647e06b-085a-4923-82e8-546bedabeb3e.mp4

### After

https://user-images.githubusercontent.com/92328789/193884323-629fb879-3a51-4412-8b63-2f36afc618cb.mov

As side effect, it reduced number of requests for saved query:
#### Before
2 requests were sent
<img width="1995" alt="Screenshot 2022-10-05 at 09 39 09" src="https://user-images.githubusercontent.com/92328789/194018652-5612a032-e908-4e01-9858-2049c8e453e2.png">

#### After
Only one request sent

### Checklist
<img width="1996" alt="Screenshot 2022-10-05 at 09 37 12" src="https://user-images.githubusercontent.com/92328789/194018637-770a08df-832b-4838-a060-05058c436ed6.png">

Delete any items that are not applicable to this PR.

- [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

(cherry picked from commit 4feb397)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.5

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Oct 10, 2022
#143008)

## Summary

- addresses #141758
- loads saved query on rules edit page before form rendering, thus prevents validation run on uncompleted data(saved query wasn't fetched before QueryBar component renders). Then fetched saved query passed to QueryBarDefineRule component

### Before

https://user-images.githubusercontent.com/92328789/193884969-3647e06b-085a-4923-82e8-546bedabeb3e.mp4

### After

https://user-images.githubusercontent.com/92328789/193884323-629fb879-3a51-4412-8b63-2f36afc618cb.mov

As side effect, it reduced number of requests for saved query:
#### Before
2 requests were sent
<img width="1995" alt="Screenshot 2022-10-05 at 09 39 09" src="https://user-images.githubusercontent.com/92328789/194018652-5612a032-e908-4e01-9858-2049c8e453e2.png">

#### After
Only one request sent

### Checklist
<img width="1996" alt="Screenshot 2022-10-05 at 09 37 12" src="https://user-images.githubusercontent.com/92328789/194018637-770a08df-832b-4838-a060-05058c436ed6.png">

Delete any items that are not applicable to this PR.

- [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

(cherry picked from commit 4feb397)

Co-authored-by: Vitalii Dmyterko <[email protected]>
@vitaliidm vitaliidm deleted the alerts/saved_query_ux_validation branch March 4, 2024 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) release_note:skip Skip the PR/issue when compiling release notes Team:Detection Alerts Security Detection Alerts Area Team Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v8.5.0 v8.6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants