From 8577d1357e2c59f66e397a480ec39b2c405787db Mon Sep 17 00:00:00 2001 From: Rodney Norris Date: Fri, 11 Oct 2024 12:21:47 -0500 Subject: [PATCH] [Search][Onboarding] Enable search indices & gate with a feature flag (#195802) ## Summary This PR enables the `search_indices` plugin in serverless search. But then gates it with a UI settings feature flag until we are ready to ship the new onboarding experience to all users. ### Testing Locally you can add this to your `kibana.dev.yml` to enable the FF: ``` uiSettings.overrides.searchIndices:globalEmptyStateEnabled: true ``` Or you can enable the ui setting via Dev Tools and refresh the browser: ``` POST kbn:/internal/kibana/settings/searchIndices:globalEmptyStateEnabled {"value": true} ``` ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed Co-authored-by: Elastic Machine Co-authored-by: Jean-Louis Leysens --- config/serverless.es.yml | 1 + x-pack/plugins/search_indices/common/index.ts | 2 ++ .../plugins/search_indices/public/feature_flags.ts | 13 +++++++++++++ x-pack/plugins/search_indices/public/plugin.ts | 14 +++++++++++++- x-pack/plugins/serverless_search/public/plugin.ts | 5 ++++- .../test_suites/search/config.feature_flags.ts | 2 +- 6 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 x-pack/plugins/search_indices/public/feature_flags.ts 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')],