diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/search_and_filter_bar.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/search_and_filter_bar.tsx index 76fd291155139..3dab659e64232 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/search_and_filter_bar.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/search_and_filter_bar.tsx @@ -22,6 +22,8 @@ import type { Agent, AgentPolicy } from '../../../../types'; import { SearchBar } from '../../../../components'; import { AGENTS_INDEX, AGENTS_PREFIX } from '../../../../constants'; +import { useStartServices } from '../../../../hooks'; + import { AgentBulkActions } from './bulk_actions'; import type { SelectionMode } from './types'; import { AgentActivityButton } from './agent_activity_button'; @@ -91,6 +93,7 @@ export const SearchAndFilterBar: React.FunctionComponent { const { isFirstTimeAgentUser, isLoading: isFirstTimeAgentUserLoading } = useIsFirstTimeAgentUserQuery(); + const { cloud } = useStartServices(); return ( <> @@ -107,23 +110,25 @@ export const SearchAndFilterBar: React.FunctionComponent - - - } - > - - - - - + {!cloud?.isServerlessEnabled && ( + + + } + > + + + + + + )} { expect(res).toEqual({ body: { item: { id: 'host1' } } }); }); + it('should return ok on put in serverless if host urls are not passed', async () => { + jest.spyOn(appContextService, 'getCloud').mockReturnValue({ isServerlessEnabled: true } as any); + + const res = await putFleetServerHostHandler( + mockContext, + { body: { name: ['Renamed'] }, params: { outputId: 'host1' } } as any, + mockResponse as any + ); + + expect(res).toEqual({ body: { item: { id: 'host1' } } }); + }); + it('should return ok on put in stateful if host url is different from default', async () => { jest .spyOn(appContextService, 'getCloud') diff --git a/x-pack/plugins/fleet/server/routes/output/handler.test.ts b/x-pack/plugins/fleet/server/routes/output/handler.test.ts index be1c162d7056b..c24863d1cc08f 100644 --- a/x-pack/plugins/fleet/server/routes/output/handler.test.ts +++ b/x-pack/plugins/fleet/server/routes/output/handler.test.ts @@ -178,6 +178,21 @@ describe('output handler', () => { expect(res).toEqual({ body: { item: { id: 'output1' } } }); }); + it('should return ok on put elasticsearch output in serverless if host url is not passed', async () => { + jest.spyOn(appContextService, 'getCloud').mockReturnValue({ isServerlessEnabled: true } as any); + + const res = await putOutputHandler( + mockContext, + { + body: { type: 'elasticsearch', name: 'Renamed output' }, + params: { outputId: 'output1' }, + } as any, + mockResponse as any + ); + + expect(res).toEqual({ body: { item: { id: 'output1' } } }); + }); + it('should return ok on put elasticsearch output in stateful if host url is different from default', async () => { jest .spyOn(appContextService, 'getCloud') diff --git a/x-pack/plugins/fleet/server/routes/output/handler.ts b/x-pack/plugins/fleet/server/routes/output/handler.ts index 237ff2986703c..14598a3b628f4 100644 --- a/x-pack/plugins/fleet/server/routes/output/handler.ts +++ b/x-pack/plugins/fleet/server/routes/output/handler.ts @@ -170,6 +170,10 @@ async function validateOutputServerless( throw Boom.badRequest('Output type remote_elasticsearch not supported in serverless'); } // Elasticsearch outputs must have the default host URL in serverless. + // No need to validate on update if hosts are not passed. + if (outputId && !output.hosts) { + return; + } const defaultOutput = await outputService.get(soClient, SERVERLESS_DEFAULT_OUTPUT_ID); let originalOutput; if (outputId) {