diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/agent_policy_selection.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/agent_policy_selection.tsx index 8d639b48681e3..bcedb23b32d5d 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/agent_policy_selection.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/agent_policy_selection.tsx @@ -18,6 +18,7 @@ import { AgentPolicyPackageBadges } from '../agent_policy_package_badges'; type Props = { agentPolicies?: AgentPolicy[]; onAgentPolicyChange?: (key: string) => void; + excludeFleetServer?: boolean; } & ( | { withKeySelection: true; @@ -30,7 +31,7 @@ type Props = { export const EnrollmentStepAgentPolicy: React.FC = (props) => { const { notifications } = useStartServices(); - const { withKeySelection, agentPolicies, onAgentPolicyChange } = props; + const { withKeySelection, agentPolicies, onAgentPolicyChange, excludeFleetServer } = props; const onKeyChange = props.withKeySelection && props.onKeyChange; const [isAuthenticationSettingsOpen, setIsAuthenticationSettingsOpen] = useState(false); @@ -182,7 +183,10 @@ export const EnrollmentStepAgentPolicy: React.FC = (props) => { /> {selectedState.agentPolicyId && ( - + )} {withKeySelection && onKeyChange && ( <> diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/standalone_instructions.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/standalone_instructions.tsx index 7ccdfe05724f1..1d830b2c578b1 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/standalone_instructions.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/standalone_instructions.tsx @@ -76,7 +76,7 @@ export const StandaloneInstructions = React.memo(({ agentPolicies }) => { const yaml = useMemo(() => fullAgentPolicyToYaml(fullAgentPolicy), [fullAgentPolicy]); const steps: EuiContainedStepProps[] = [ DownloadStep(), - AgentPolicySelectionStep({ agentPolicies, setSelectedPolicyId }), + AgentPolicySelectionStep({ agentPolicies, setSelectedPolicyId, excludeFleetServer: true }), { title: i18n.translate('xpack.fleet.agentEnrollment.stepConfigureAgentTitle', { defaultMessage: 'Configure the agent', diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/steps.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/steps.tsx index 08b1cbdb341d5..6a446e888a19f 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/steps.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/steps.tsx @@ -51,14 +51,19 @@ export const AgentPolicySelectionStep = ({ setSelectedAPIKeyId, setSelectedPolicyId, setIsFleetServerPolicySelected, + excludeFleetServer, }: { agentPolicies?: AgentPolicy[]; setSelectedAPIKeyId?: (key: string) => void; setSelectedPolicyId?: (policyId: string) => void; setIsFleetServerPolicySelected?: (selected: boolean) => void; + excludeFleetServer?: boolean; }) => { const regularAgentPolicies = Array.isArray(agentPolicies) - ? agentPolicies.filter((policy) => policy && !policy.is_managed) + ? agentPolicies.filter( + (policy) => + policy && !policy.is_managed && (!excludeFleetServer || !policy.is_default_fleet_server) + ) : []; const onAgentPolicyChange = useCallback( @@ -93,6 +98,7 @@ export const AgentPolicySelectionStep = ({ withKeySelection={setSelectedAPIKeyId ? true : false} onKeyChange={setSelectedAPIKeyId} onAgentPolicyChange={onAgentPolicyChange} + excludeFleetServer={excludeFleetServer} /> ), }; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_policy_package_badges.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_policy_package_badges.tsx index cff0dc55515c4..89ac1b4f43b5f 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_policy_package_badges.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_policy_package_badges.tsx @@ -6,8 +6,11 @@ */ import React, { useMemo } from 'react'; +import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import { EuiSpacer, EuiText, EuiFlexGroup, EuiFlexItem, EuiBadge } from '@elastic/eui'; +import { EuiSpacer, EuiText, EuiFlexGroup, EuiFlexItem, EuiBadge, EuiCallOut } from '@elastic/eui'; + +import { FLEET_SERVER_PACKAGE } from '../../../../../../common/constants'; import type { PackagePolicy, PackagePolicyPackage } from '../../../types'; import { useGetOneAgentPolicy } from '../../../hooks'; @@ -16,11 +19,13 @@ import { PackageIcon } from '../../../components/package_icon'; interface Props { agentPolicyId: string; hideTitle?: boolean; + excludeFleetServer?: boolean; } export const AgentPolicyPackageBadges: React.FunctionComponent = ({ agentPolicyId, hideTitle, + excludeFleetServer, }) => { const agentPolicyRequest = useGetOneAgentPolicy(agentPolicyId); const agentPolicy = agentPolicyRequest.data ? agentPolicyRequest.data.item : null; @@ -45,6 +50,19 @@ export const AgentPolicyPackageBadges: React.FunctionComponent = ({ 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; } @@ -58,8 +76,8 @@ export const AgentPolicyPackageBadges: React.FunctionComponent = ({ id="xpack.fleet.agentReassignPolicy.policyDescription" defaultMessage="The selected agent policy will collect data for {count, plural, one {{countValue} integration} other {{countValue} integrations}}:" values={{ - count: packages.length, - countValue: {packages.length}, + count: collectedIntegrationsCount, + countValue: {collectedIntegrationsCount}, }} /> @@ -68,7 +86,11 @@ export const AgentPolicyPackageBadges: React.FunctionComponent = ({ )} {packages.map((pkg, idx) => { return ( - + = ({ ); })} + {showFleetServerWarning && ( + <> + + + + )} ); };