diff --git a/config/serverless.es.yml b/config/serverless.es.yml index 4261f29488002..ade2b7da90270 100644 --- a/config/serverless.es.yml +++ b/config/serverless.es.yml @@ -34,6 +34,7 @@ xpack.cloud.serverless.project_type: search ## Enable the Serverless Search plugin xpack.serverless.search.enabled: true +xpack.searchIndices.enabled: true ## Set the home route uiSettings.overrides.defaultRoute: /app/elasticsearch diff --git a/x-pack/plugins/search_indices/common/index.ts b/x-pack/plugins/search_indices/common/index.ts index e640397e3936d..3b8ffc5081261 100644 --- a/x-pack/plugins/search_indices/common/index.ts +++ b/x-pack/plugins/search_indices/common/index.ts @@ -12,4 +12,6 @@ export const PLUGIN_NAME = 'searchIndices'; export const START_APP_ID: SearchStart = 'elasticsearchStart'; export const INDICES_APP_ID: SearchIndices = 'elasticsearchIndices'; +export const GLOBAL_EMPTY_STATE_FEATURE_FLAG_ID = 'searchIndices:globalEmptyStateEnabled'; + export type { IndicesStatusResponse, UserStartPrivilegesResponse } from './types'; diff --git a/x-pack/plugins/search_indices/public/feature_flags.ts b/x-pack/plugins/search_indices/public/feature_flags.ts new file mode 100644 index 0000000000000..ec114506d4f8c --- /dev/null +++ b/x-pack/plugins/search_indices/public/feature_flags.ts @@ -0,0 +1,13 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { IUiSettingsClient } from '@kbn/core/public'; +import { GLOBAL_EMPTY_STATE_FEATURE_FLAG_ID } from '../common'; + +export function isGlobalEmptyStateEnabled(uiSettings: IUiSettingsClient): boolean { + return uiSettings.get(GLOBAL_EMPTY_STATE_FEATURE_FLAG_ID, false); +} diff --git a/x-pack/plugins/search_indices/public/plugin.ts b/x-pack/plugins/search_indices/public/plugin.ts index 39c3151cf7615..5772115198edf 100644 --- a/x-pack/plugins/search_indices/public/plugin.ts +++ b/x-pack/plugins/search_indices/public/plugin.ts @@ -18,13 +18,25 @@ import type { import { initQueryClient } from './services/query_client'; import { INDICES_APP_ID, START_APP_ID } from '../common'; import { INDICES_APP_BASE, START_APP_BASE } from './routes'; +import { isGlobalEmptyStateEnabled } from './feature_flags'; export class SearchIndicesPlugin implements Plugin { + private pluginEnabled: boolean = false; + public setup( core: CoreSetup ): SearchIndicesPluginSetup { + if (!isGlobalEmptyStateEnabled(core.uiSettings)) { + return { + enabled: this.pluginEnabled, + startAppId: START_APP_ID, + startRoute: START_APP_BASE, + }; + } + this.pluginEnabled = true; + const queryClient = initQueryClient(core.notifications.toasts); core.application.register({ @@ -72,7 +84,7 @@ export class SearchIndicesPlugin public start(core: CoreStart): SearchIndicesPluginStart { docLinks.setDocLinks(core.docLinks.links); return { - enabled: true, + enabled: this.pluginEnabled, startAppId: START_APP_ID, startRoute: START_APP_BASE, }; diff --git a/x-pack/plugins/serverless_search/public/plugin.ts b/x-pack/plugins/serverless_search/public/plugin.ts index 211a1cb2384d2..c223b9a6b11db 100644 --- a/x-pack/plugins/serverless_search/public/plugin.ts +++ b/x-pack/plugins/serverless_search/public/plugin.ts @@ -159,7 +159,10 @@ export class ServerlessSearchPlugin serverless.setProjectHome(homeRoute); const navigationTree$ = of( - navigationTree(services.searchIndices?.startAppId, useGlobalEmptyState) + navigationTree( + useGlobalEmptyState ? services.searchIndices?.startAppId : undefined, + useGlobalEmptyState + ) ); serverless.initNavigation('search', navigationTree$, { dataTestSubj: 'svlSearchSideNav' }); diff --git a/x-pack/test_serverless/functional/test_suites/search/config.feature_flags.ts b/x-pack/test_serverless/functional/test_suites/search/config.feature_flags.ts index ebd539fd34f42..85724f48d38cc 100644 --- a/x-pack/test_serverless/functional/test_suites/search/config.feature_flags.ts +++ b/x-pack/test_serverless/functional/test_suites/search/config.feature_flags.ts @@ -26,7 +26,7 @@ export default createTestConfig({ `--xpack.cloud.organization_url=/account/members`, `--xpack.security.roleManagementEnabled=true`, `--xpack.spaces.maxSpaces=100`, // enables spaces UI capabilities - `--xpack.searchIndices.enabled=true`, // global empty state FF + `--uiSettings.overrides.searchIndices:globalEmptyStateEnabled=true`, // global empty state FF ], // load tests in the index file testFiles: [require.resolve('./index.feature_flags.ts')],