Skip to content

Commit

Permalink
[Search][Onboarding] Enable search indices & gate with a feature flag (
Browse files Browse the repository at this point in the history
…#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 <[email protected]>
Co-authored-by: Jean-Louis Leysens <[email protected]>
  • Loading branch information
3 people authored Oct 11, 2024
1 parent ac2a5d2 commit 8577d13
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 3 deletions.
1 change: 1 addition & 0 deletions config/serverless.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/search_indices/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
13 changes: 13 additions & 0 deletions x-pack/plugins/search_indices/public/feature_flags.ts
Original file line number Diff line number Diff line change
@@ -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<boolean>(GLOBAL_EMPTY_STATE_FEATURE_FLAG_ID, false);
}
14 changes: 13 additions & 1 deletion x-pack/plugins/search_indices/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<SearchIndicesPluginSetup, SearchIndicesPluginStart>
{
private pluginEnabled: boolean = false;

public setup(
core: CoreSetup<SearchIndicesAppPluginStartDependencies, SearchIndicesPluginStart>
): 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({
Expand Down Expand Up @@ -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,
};
Expand Down
5 changes: 4 additions & 1 deletion x-pack/plugins/serverless_search/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')],
Expand Down

0 comments on commit 8577d13

Please sign in to comment.