-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] [Platform] Adds state to remember what was in data view or index pattern selection when switching between the two #136448
Conversation
…on when switching between the two
@elasticmachine merge upstream |
…xpected to be nullish but the form state has it set to an empty string, added that extra check into the EQL query bar validator
@elasticmachine merge upstream |
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.
thanks @dhurley14. It looks good overall, I've also did some testing: selected values are kept when switching between index and data views.
Also left few minor comments
...ck/plugins/security_solution/public/detections/components/rules/data_view_selector/index.tsx
Outdated
Show resolved
Hide resolved
...ck/plugins/security_solution/public/detections/components/rules/data_view_selector/index.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/public/detections/components/rules/step_define_rule/index.tsx
Outdated
Show resolved
Hide resolved
...ck/plugins/security_solution/public/detections/components/rules/data_view_selector/index.tsx
Show resolved
Hide resolved
x-pack/plugins/security_solution/public/detections/components/rules/step_define_rule/index.tsx
Outdated
Show resolved
Hide resolved
...k/plugins/security_solution/public/detections/pages/detection_engine/rules/create/helpers.ts
Outdated
Show resolved
Hide resolved
…rules/step_define_rule/index.tsx Co-authored-by: Vitalii Dmyterko <[email protected]>
…rules/step_define_rule/index.tsx Co-authored-by: Vitalii Dmyterko <[email protected]>
…rules/data_view_selector/index.tsx Co-authored-by: Vitalii Dmyterko <[email protected]>
…rules/data_view_selector/index.tsx Co-authored-by: Vitalii Dmyterko <[email protected]>
💚 Build SucceededMetrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
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.
I did a high-level review of the changes and I didn't check them thoroughly and didn't test the PR locally.
Please check my few comments.
Also, I feel like we need to simplify the implementation of the rule creation/editing forms because it looks hairy and every fix and feature adds complexity on top of what is already there. But that's a separate story 🙂 I'll make a note to open a ticket for refactoring.
if (dataSourceType === DataSourceType.DataView) { | ||
const fetchDataView = async () => { | ||
if (dataView != null) { | ||
const dv = await data.dataViews.get(dataView); | ||
setDataViewTitle(dv.title); | ||
setIndexPattern(dv); | ||
} | ||
}; | ||
|
||
fetchDataView(); | ||
} |
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.
Using react-query
might help for keeping dataView
parameter (it's a name or an id, right?) in sync with the data view saved object that needs to be fetched. We used this library for the Rules Table and for fetching rule execution results and events in #126063. It simplifies code in such cases and makes it clean and robust.
export enum DataSourceType { | ||
IndexPatterns = 'indexPatterns', | ||
DataView = 'dataView', | ||
} |
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.
Is this defined on the FE side only, or at the API and/or BE level as well?
We might benefit from defining it under the common
folder because we need to distinguish rules with these two types of data sources in tests as well, for example: #136822 (comment)
Summary
Related: #134783 (review)
Also addressed: #135516
In collaboration with @nkhristinin
When switching between data views and index patterns on the rule creation form, the user could lose previously selected index patterns or data views. Depending on which was originally saved in the rule form.
The small problem which I found, is that validation on DataViewSelector is triggered right away we click on the Data View button, which can be a bit confusing because users don’t touch this field.