-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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][Endpoint] Consistent pending actions agent status label #117875
Merged
ashokaditya
merged 9 commits into
elastic:main
from
ashokaditya:fix/olm-pending_agent_status_label-2105
Nov 16, 2021
Merged
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ed38d03
pull more than default 10 records!!
ashokaditya cf632cb
commit using ashokaditya@elastic.co
ashokaditya e3769a2
show correct isolation status badge when pending actions data is updated
ashokaditya 3389b0c
fix typo
ashokaditya 6b946d2
remove redundant dependencies
ashokaditya 4f17df9
show `isolated` right after pending state is refreshed
ashokaditya b015338
Merge branch 'main' into fix/olm-pending_agent_status_label-2105
kibanamachine 6058831
recompute only on prop change
ashokaditya 0562eab
Merge branch 'main' into fix/olm-pending_agent_status_label-2105
kibanamachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'm having a hard time understanding why we need to
useRef
which given you a non-mutable const. Looking at this logic, it seem that these two variables are set only once - when the component renders for the very first time, and then they are never updated again. If that is truly what you mean with this change, then usinguseState()
like this would do the trick:but I have to ask: is that really what you expect? that these will never be updated even if the component is called with different props?
Also - since the entire returned value is already memoized, you might just want to move this logic inside of the
useMemo()
's factory callback as:NOTE: the reason I always pay closer attention when using
useRef
is that it can get you in trouble. Example: see my comment below for usage inuseMemo
dependenciesThere 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.
Actually,
useRef
returns a mutable object. Since, the component re-renders anyway whenpendingIsolate
andpendingUnIsolate
change, passing the dependency array will have the same "effect".Overall, the idea is when the component starts to render(before returning display nodes), we want to use the old state of these values (old
isolated
badge) to decide which badge to show next. The endpoint metadata doesn't update theEndpoint.state.isolation
value as fast as the action response indices update the pending actions count.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.
Right. And since you only want it to be set on first render, you don't really need a mutable object. You can just use a
useState()
with an initial value right (like the suggestion in my prior comment)?I'm approving since the end result I think is the same and you and confirmed that you truly only want this value to be capture on the very first render and even if they differ in subsequent re-renders, they will not be seen.