diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/hooks.test.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/hooks.test.tsx index 85a241fe828c9..3349a9a2bc624 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/hooks.test.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/hooks.test.tsx @@ -683,6 +683,11 @@ describe('useFleetServerHostsOptions', () => { "inputDisplay": "Default (currently Default)", "value": "@@##DEFAULT_SELECT##@@", }, + Object { + "disabled": false, + "inputDisplay": "Default", + "value": "default-host", + }, Object { "disabled": true, "inputDisplay": "Internal", diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/hooks.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/hooks.tsx index 7409f75a593dd..0e6e80be6902f 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/hooks.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/hooks.tsx @@ -155,7 +155,7 @@ export function useOutputOptions(agentPolicy: Partial) { +export function useDownloadSourcesOptions() { const downloadSourcesRequest = useGetDownloadSources(); const dataDownloadSourceOptions = useMemo(() => { @@ -168,14 +168,12 @@ export function useDownloadSourcesOptions(agentPolicy: Partial !item.is_default) - .map((item) => { - return { - value: item.id, - inputDisplay: item.name, - }; - }), + ...downloadSourcesRequest.data.items.map((item) => { + return { + value: item.id, + inputDisplay: item.name, + }; + }), ]; }, [downloadSourcesRequest]); @@ -221,17 +219,15 @@ export function useFleetServerHostsOptions(agentPolicy: Partial !item.is_default) - .map((item) => { - const isInternalFleetServerHost = !!item.is_internal; + ...fleetServerHostsRequest.data.items.map((item) => { + const isInternalFleetServerHost = !!item.is_internal; - return { - value: item.id, - inputDisplay: item.name, - disabled: isInternalFleetServerHost, - }; - }), + return { + value: item.id, + inputDisplay: item.name, + disabled: isInternalFleetServerHost, + }; + }), ]; }, [fleetServerHostsRequest]); diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.tsx index 305148584f545..de3c65994f204 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.tsx @@ -112,7 +112,7 @@ export const AgentPolicyAdvancedOptionsContent: React.FunctionComponent = maxAgentPoliciesWithInactivityTimeout !== undefined && totalAgentPoliciesWithInactivityTimeout > (maxAgentPoliciesWithInactivityTimeout ?? 0); const { dataDownloadSourceOptions, isLoading: isLoadingDownloadSources } = - useDownloadSourcesOptions(agentPolicy); + useDownloadSourcesOptions(); const { fleetServerHostsOptions, isLoading: isLoadingFleetServerHostsOption } = useFleetServerHostsOptions(agentPolicy);