-
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
[Fleet] refresh policies on create and flyout open #125499
Conversation
Pinging @elastic/fleet (Team:Fleet) |
data: agentPoliciesData, | ||
isLoading: isLoadingAgentPolicies, | ||
resendRequest: refreshAgentPolicies, | ||
} = useGetAgentPolicies({ |
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 decided to load/refresh agent policies here in AgentEnrollmentFlyout.
The reason is that AgentEnrollmentFlyout is being called from 7 places, from which 4 are used without agentPolicies, 3 with agentPolicies. It would be too much duplication to reload agentPolicies from all those caller sites.
AgentEnrollmentFlyout Props should be cleaned up so that agentPolicies is not passed as a prop.
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.
What do you think of creating a hook like useAgentEnrollmentFlyoutData
that contains this and the useMemo
below, to start separating more business and presentation in this component?
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 going to create a hook in a next pr, also clean up some unused props
|
||
type Props = BaseProps; | ||
export const StandaloneInstructions = React.memo<InstructionProps>( | ||
({ agentPolicy, agentPolicies, refreshAgentPolicies }) => { |
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.
the only change in this file is refreshAgentPolicies, the others are whitespace
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.
It works as expected 🚀!
💚 Build SucceededMetrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
* refresh policies on create and flyout open * fix checks * fixed scenario when newly created policy should be preselected (cherry picked from commit b4855ba)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
* refresh policies on create and flyout open * fix checks * fixed scenario when newly created policy should be preselected (cherry picked from commit b4855ba) Co-authored-by: Julia Bardi <[email protected]>
Summary
Fixes #125481
Steps to reproduce: