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

[SecuritySolution] Close field editor when page context is lost #124378

Merged
merged 4 commits into from
Feb 3, 2022

Conversation

semd
Copy link
Contributor

@semd semd commented Feb 2, 2022

Summary

issue: #123209

Implemented the close action on the field editor, by leveraging the returned function from the dataViewFieldEditor.openEditor function call.

The reference is needed here because the button that triggers the field editor flyout is unmounted when it is clicked. The closeEditor action needs to be triggered when the original component that opened the "fieldBrowser" in the first place is unmounted (alerts tables) or it is hidden (timeline):

close_field_editor_flyout_fix.mov

Checklist

@semd semd added bug Fixes for quality problems that affect the customer experience v8.0.0 release_note:skip Skip the PR/issue when compiling release notes Team:Threat Hunting Security Solution Threat Hunting Team v8.1.0 Team:Threat Hunting:Explore labels Feb 2, 2022
@semd semd requested a review from a team as a code owner February 2, 2022 16:59
@semd semd self-assigned this Feb 2, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-threat-hunting (Team:Threat Hunting)

Copy link
Member

@machadoum machadoum left a comment

Choose a reason for hiding this comment

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

The code looks great. I just noticed one edge case. Because timeline only closed the field editor when show value changes. It doesn't close the editor when you navigate to a security solutions page that doesn't have a timeline (Endpoint page).

@semd
Copy link
Contributor Author

semd commented Feb 3, 2022

Hi @machadoum , very good catches! I addressed your suggestions and I improved the tests a little bit more. Thanks!

Copy link
Member

@machadoum machadoum left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -137,6 +142,10 @@ const StatefulEventsViewerComponent: React.FC<Props> = ({
}
return () => {
deleteEventQuery({ id, inputId: 'global' });
if (editorActionsRef.current) {
// eslint-disable-next-line react-hooks/exhaustive-deps
Copy link
Contributor

Choose a reason for hiding this comment

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

do you need this here? i thought just above the dependency array

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, It is needed here too, this error pops if not diabled:

The ref value 'fieldEditorActionsRef.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy 'fieldEditorActionsRef.current' to a variable inside the effect, and use that variable in the cleanup function

sortDirection: Direction.desc,
},
];
const defaultProps: ColumnHeadersComponentProps = {
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for cleaning this up!

Copy link
Contributor

@stephmilovic stephmilovic left a comment

Choose a reason for hiding this comment

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

just a question about that type exception. tested locally and LGTM. thanks @semd !

@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 4.7MB 4.7MB +426.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
securitySolution 447 449 +2

Total ESLint disabled count

id before after diff
securitySolution 515 517 +2

History

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

cc @semd

@semd semd merged commit 21710df into elastic:main Feb 3, 2022
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Feb 7, 2022
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 124378 or prevent reminders by adding the backport:skip label.

semd added a commit to semd/kibana that referenced this pull request Feb 8, 2022
…tic#124378)

* close field editor when context is lost

* tests added

* typecheck clean

* close editor when timeline is unmounted

(cherry picked from commit 21710df)
semd added a commit to semd/kibana that referenced this pull request Feb 8, 2022
…tic#124378)

* close field editor when context is lost

* tests added

* typecheck clean

* close editor when timeline is unmounted

(cherry picked from commit 21710df)

# Conflicts:
#	x-pack/plugins/security_solution/public/timelines/components/create_field_button/index.tsx
semd added a commit that referenced this pull request Feb 8, 2022
) (#124934)

* close field editor when context is lost

* tests added

* typecheck clean

* close editor when timeline is unmounted

(cherry picked from commit 21710df)
@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.

1 similar comment
@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.

@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.

semd added a commit that referenced this pull request Feb 11, 2022
…#124378) (#124935)

* [SecuritySolution] Close field editor when page context is lost (#124378)

* close field editor when context is lost

* tests added

* typecheck clean

* close editor when timeline is unmounted

(cherry picked from commit 21710df)

# Conflicts:
#	x-pack/plugins/security_solution/public/timelines/components/create_field_button/index.tsx

* fix test

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Feb 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience release_note:skip Skip the PR/issue when compiling release notes Team:Threat Hunting:Explore Team:Threat Hunting Security Solution Threat Hunting Team v8.0.0 v8.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants