Skip to content

Commit

Permalink
[Fleet] fix flickering create agent policy when adding agent (#134890) (
Browse files Browse the repository at this point in the history
#134909)

(cherry picked from commit d74d26f)

Co-authored-by: Mark Hopkin <mark.hopkin@elastic.co>
  • Loading branch information
kibanamachine and hop-dev authored Jun 22, 2022
1 parent a20413e commit d88b972
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const getSelectAgentPolicyStep = ({
}): EuiStepProps => {
return {
title:
eligibleFleetServerPolicies.length === 0
eligibleFleetServerPolicies.length === 0 && !policyId
? i18n.translate('xpack.fleet.fleetServerSetup.stepCreateAgentPolicyTitle', {
defaultMessage: 'Create a policy for Fleet Server',
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ export const SelectCreateAgentPolicy: React.FC<Props> = ({
);

useEffect(() => {
setShowCreatePolicy(regularAgentPolicies.length === 0);
setShowCreatePolicy(regularAgentPolicies.length === 0 && !selectedPolicyId);
setNewName(incrementPolicyName(regularAgentPolicies, isFleetServerPolicy));
}, [regularAgentPolicies, isFleetServerPolicy]);
}, [regularAgentPolicies, isFleetServerPolicy, selectedPolicyId]);

const onAgentPolicyCreated = useCallback(
async (policy: AgentPolicy | null, errorMessage?: JSX.Element) => {
Expand Down

0 comments on commit d88b972

Please sign in to comment.