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] [Platform] Adds state to remember what was in data view or index pattern selection when switching between the two #136448

Merged
merged 23 commits into from
Jul 25, 2022

Conversation

dhurley14
Copy link
Contributor

@dhurley14 dhurley14 commented Jul 14, 2022

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.

  • Keep both fields index and dataView on the form
  • Made a DataViewSelector more controlled component and moved logic about fetch and state to a parent (step_define_rule)
  • Depends on chosen data type I omit some fields from the 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.

@dhurley14 dhurley14 changed the title adds state to remember what was in data view or index pattern selecti… adds state to remember what was in data view or index pattern selection when switching between the two Jul 14, 2022
@dhurley14 dhurley14 self-assigned this Jul 14, 2022
@dhurley14 dhurley14 added review release_note:skip Skip the PR/issue when compiling release notes Feature:Detection Rules Security Solution rules and Detection Engine Team:Security Solution Platform Security Solution Platform Team v8.4.0 labels Jul 14, 2022
@dhurley14 dhurley14 marked this pull request as ready for review July 14, 2022 20:20
@dhurley14 dhurley14 requested a review from a team as a code owner July 14, 2022 20:20
@dhurley14 dhurley14 requested a review from vitaliidm July 14, 2022 20:20
@dhurley14 dhurley14 changed the title adds state to remember what was in data view or index pattern selection when switching between the two [Security Solution] [Platform] Adds state to remember what was in data view or index pattern selection when switching between the two Jul 14, 2022
@nkhristinin
Copy link
Contributor

@elasticmachine merge upstream

kibanamachine and others added 3 commits July 19, 2022 14:26
…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
@dhurley14 dhurley14 enabled auto-merge (squash) July 20, 2022 01:38
@nkhristinin
Copy link
Contributor

@elasticmachine merge upstream

Copy link
Contributor

@vitaliidm vitaliidm left a 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

nkhristinin and others added 5 commits July 21, 2022 18:35
…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]>
@dhurley14 dhurley14 removed the request for review from nkhristinin July 22, 2022 15:58
@banderror banderror self-requested a review July 25, 2022 13:55
@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 5.2MB 5.2MB +1.2KB

History

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

cc @dhurley14 @nkhristinin

Copy link
Contributor

@banderror banderror left a 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.

Comment on lines +273 to +283
if (dataSourceType === DataSourceType.DataView) {
const fetchDataView = async () => {
if (dataView != null) {
const dv = await data.dataViews.get(dataView);
setDataViewTitle(dv.title);
setIndexPattern(dv);
}
};

fetchDataView();
}
Copy link
Contributor

@banderror banderror Jul 25, 2022

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.

Comment on lines +136 to +139
export enum DataSourceType {
IndexPatterns = 'indexPatterns',
DataView = 'dataView',
}
Copy link
Contributor

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)

@dhurley14 dhurley14 merged commit c2985c4 into elastic:main Jul 25, 2022
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Jul 25, 2022
@dhurley14 dhurley14 deleted the dv-bug-fixes branch July 25, 2022 18:42
@tylersmalley tylersmalley added ci:cloud-deploy Create or update a Cloud deployment and removed ci:deploy-cloud labels Aug 17, 2022
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 ci:cloud-deploy Create or update a Cloud deployment Feature:Detection Rules Security Solution rules and Detection Engine release_note:skip Skip the PR/issue when compiling release notes review Team:Security Solution Platform Security Solution Platform Team v8.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants