Skip to content

Commit

Permalink
Change copy and memoize values
Browse files Browse the repository at this point in the history
  • Loading branch information
Zacqary committed Apr 29, 2021
1 parent a8f5ead commit 1714d10
Showing 1 changed file with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,23 @@ export const AgentPolicyPackageBadges: React.FunctionComponent<Props> = ({
return [...uniquePackages.values()];
}, [agentPolicy]);

const showFleetServerWarning = useMemo(
() => excludeFleetServer && packages?.some((pkg) => pkg.name === FLEET_SERVER_PACKAGE),
[packages, excludeFleetServer]
);

const collectedIntegrationsCount = useMemo(
() =>
packages
? packages.filter((pkg) => !excludeFleetServer || pkg.name !== FLEET_SERVER_PACKAGE).length
: 0,
[packages, excludeFleetServer]
);

if (!agentPolicy || !packages) {
return null;
}

const showFleetServerWarning =
excludeFleetServer && packages.some((pkg) => pkg.name === FLEET_SERVER_PACKAGE);

const collectedIntegrationsCount = packages.filter(
(pkg) => !excludeFleetServer || pkg.name !== FLEET_SERVER_PACKAGE
).length;

return (
<>
{!hideTitle && (
Expand Down Expand Up @@ -115,8 +121,7 @@ export const AgentPolicyPackageBadges: React.FunctionComponent<Props> = ({
title={i18n.translate(
'xpack.fleet.agentReassignPolicy.packageBadgeFleetServerWarning',
{
defaultMessage:
'The Fleet Server integration will not collect data in standalone mode.',
defaultMessage: 'Fleet Server will not be enabled in standalone mode.',
}
)}
/>
Expand Down

0 comments on commit 1714d10

Please sign in to comment.