Skip to content

Commit

Permalink
[Fleet] Fix add fleet server flow from agent policy page (#149507)
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet authored Jan 26, 2023
1 parent 1d5e25a commit da83d96
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export const Instructions = (props: InstructionProps) => {
refreshAgentPolicies,
} = props;
const fleetStatus = useFleetStatus();
const { isUnhealthy: isFleetServerUnhealthy } = useFleetServerUnhealthy();
const { isUnhealthy: isFleetServerUnhealthy, isLoading: isLoadingFleetServerHealth } =
useFleetServerUnhealthy();

useEffect(() => {
refreshAgentPolicies();
Expand All @@ -66,14 +67,17 @@ export const Instructions = (props: InstructionProps) => {

const fleetServers = agents?.items || [];

if (isLoadingAgents || isLoadingAgentPolicies) return <Loading size="l" />;
if (isLoadingAgents || isLoadingAgentPolicies || isLoadingFleetServerHealth)
return <Loading size="l" />;

const hasNoFleetServerHost = fleetStatus.isReady && (fleetServerHosts?.length ?? 0) === 0;

const showAgentEnrollment =
fleetStatus.isReady &&
(isFleetServerPolicySelected ||
(!isFleetServerUnhealthy && fleetServers.length > 0 && (fleetServerHosts?.length ?? 0) > 0));
isFleetServerPolicySelected ||
(fleetStatus.isReady &&
!isFleetServerUnhealthy &&
fleetServers.length > 0 &&
(fleetServerHosts?.length ?? 0) > 0);

const showFleetServerEnrollment =
!isFleetServerPolicySelected &&
Expand Down

0 comments on commit da83d96

Please sign in to comment.