[Enterprise Search] introduce ui settings for feature flags (#139723)

* [Enterprise Search] introduce ui settings for feature flags

Added ui settings for the enterprise search plugin to store feature
flags and feature flagged the new powerups tab for the index page in the
content plugin.

* [Enterprise Search] define ui settings category name

* powerups tab will be limited to connectors, for now

* use transforms instead of powerups for new index tab

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Rodney Norris 2022-08-31 10:17:14 -05:00 committed by GitHub
parent cb7b03106f
commit 38fda420ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 80 additions and 1 deletions

View file

@ -44,6 +44,9 @@ const names: Record<string, string> = {
securitySolution: i18n.translate('advancedSettings.categoryNames.securitySolutionLabel', {
defaultMessage: 'Security Solution',
}),
enterpriseSearch: i18n.translate('advancedSettings.categoryNames.enterpriseSearchLabel', {
defaultMessage: 'Enterprise Search',
}),
};
export function getCategoryName(category?: string) {

View file

@ -542,4 +542,8 @@ export const stackManagementSchema: MakeSchemaFrom<UsageStats> = {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
},
'enterpriseSearch:enableIndexTransformsTab': {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
},
};

View file

@ -145,4 +145,5 @@ export interface UsageStats {
'securitySolution:enableGroupedNav': boolean;
'securitySolution:showRelatedIntegrations': boolean;
'visualization:visualize:legacyGaugeChartsLibrary': boolean;
'enterpriseSearch:enableIndexTransformsTab': boolean;
}

View file

@ -8580,6 +8580,12 @@
"_meta": {
"description": "Non-default value of setting."
}
},
"enterpriseSearch:enableIndexTransformsTab": {
"type": "boolean",
"_meta": {
"description": "Non-default value of setting."
}
}
}
},

View file

@ -0,0 +1,9 @@
/*
* 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.
*/
export const enterpriseSearchFeatureId = 'enterpriseSearch';
export const enableIndexTransformsTab = 'enterpriseSearch:enableIndexTransformsTab';

View file

@ -14,8 +14,10 @@ import { useValues } from 'kea';
import { EuiTabbedContent, EuiTabbedContentTab } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { Status } from '../../../../../common/types/api';
import { enableIndexTransformsTab } from '../../../../../common/ui_settings_keys';
import { generateEncodedPath } from '../../../shared/encode_path_params';
import { KibanaLogic } from '../../../shared/kibana';
import { FetchIndexApiLogic } from '../../api/index/fetch_index_api_logic';
@ -46,6 +48,7 @@ export enum SearchIndexTabId {
// connector indices
CONFIGURATION = 'configuration',
SCHEDULING = 'scheduling',
TRANSFORMS = 'transforms',
// crawler indices
DOMAIN_MANAGEMENT = 'domain_management',
}
@ -56,9 +59,14 @@ export const SearchIndex: React.FC = () => {
const { tabId = SearchIndexTabId.OVERVIEW } = useParams<{
tabId?: string;
}>();
const {
services: { uiSettings },
} = useKibana();
const { indexName } = useValues(IndexNameLogic);
const transformsEnabled = uiSettings?.get<boolean>(enableIndexTransformsTab) ?? false;
const ALL_INDICES_TABS: EuiTabbedContentTab[] = [
{
content: <SearchIndexOverview />,
@ -117,10 +125,21 @@ export const SearchIndex: React.FC = () => {
},
];
const TRANSFORMS_TAB: EuiTabbedContentTab[] = [
{
content: <div />,
id: SearchIndexTabId.TRANSFORMS,
name: i18n.translate('xpack.enterpriseSearch.content.searchIndex.transformsTabLabel', {
defaultMessage: 'Transforms',
}),
},
];
const tabs: EuiTabbedContentTab[] = [
...ALL_INDICES_TABS,
...(isConnectorIndex(indexData) ? CONNECTOR_TABS : []),
...(isCrawlerIndex(indexData) ? CRAWLER_TABS : []),
...(transformsEnabled && isConnectorIndex(indexData) ? TRANSFORMS_TAB : []),
];
const selectedTab = tabs.find((tab) => tab.id === tabId);

View file

@ -59,6 +59,8 @@ import { appSearchTelemetryType } from './saved_objects/app_search/telemetry';
import { enterpriseSearchTelemetryType } from './saved_objects/enterprise_search/telemetry';
import { workplaceSearchTelemetryType } from './saved_objects/workplace_search/telemetry';
import { uiSettings as enterpriseSearchUISettings } from './ui_settings';
import { ConfigType } from '.';
interface PluginsSetup {
@ -92,7 +94,7 @@ export class EnterpriseSearchPlugin implements Plugin {
}
public setup(
{ capabilities, http, savedObjects, getStartServices }: CoreSetup<PluginsStart>,
{ capabilities, http, savedObjects, getStartServices, uiSettings }: CoreSetup<PluginsStart>,
{ usageCollection, security, features, infra, customIntegrations }: PluginsSetup
) {
const config = this.config;
@ -128,6 +130,11 @@ export class EnterpriseSearchPlugin implements Plugin {
privileges: null,
});
/**
* Register Enterprise Search UI Settings
*/
uiSettings.register(enterpriseSearchUISettings);
/**
* Register user access to the Enterprise Search plugins
*/

View file

@ -0,0 +1,30 @@
/*
* 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 { schema } from '@kbn/config-schema';
import { UiSettingsParams } from '@kbn/core/types';
import { i18n } from '@kbn/i18n';
import { enterpriseSearchFeatureId, enableIndexTransformsTab } from '../common/ui_settings_keys';
/**
* uiSettings definitions for Enterprise Search
*/
export const uiSettings: Record<string, UiSettingsParams<boolean>> = {
[enableIndexTransformsTab]: {
category: [enterpriseSearchFeatureId],
description: i18n.translate('xpack.enterpriseSearch.uiSettings.indexTransforms.description', {
defaultMessage: 'Enable the new index transforms tab in Enterprise Search.',
}),
name: i18n.translate('xpack.enterpriseSearch.uiSettings.indexTransforms.name', {
defaultMessage: 'Enable index transforms',
}),
requiresPageReload: false,
schema: schema.boolean(),
value: false,
},
};