Skip to content

Commit

Permalink
Merge branch 'main' into feature/eui-70.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
1Copenut authored Dec 1, 2022
2 parents ee34833 + d3b4d39 commit 80ef488
Show file tree
Hide file tree
Showing 27 changed files with 517 additions and 162 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -582,4 +582,8 @@ export const stackManagementSchema: MakeSchemaFrom<UsageStats> = {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
},
'enterpriseSearch:enableEnginesSection': {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,5 @@ export interface UsageStats {
'securitySolution:showRelatedIntegrations': boolean;
'visualization:visualize:legacyGaugeChartsLibrary': boolean;
'enterpriseSearch:enableBehavioralAnalyticsSection': boolean;
'enterpriseSearch:enableEnginesSection': boolean;
}
6 changes: 6 additions & 0 deletions src/plugins/telemetry/schema/oss_plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -9125,6 +9125,12 @@
"_meta": {
"description": "Non-default value of setting."
}
},
"enterpriseSearch:enableEnginesSection": {
"type": "boolean",
"_meta": {
"description": "Non-default value of setting."
}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@

export const enterpriseSearchFeatureId = 'enterpriseSearch';
export const enableBehavioralAnalyticsSection = 'enterpriseSearch:enableBehavioralAnalyticsSection';
export const enableEnginesSection = 'enterpriseSearch:enableEnginesSection';
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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 React from 'react';

import { i18n } from '@kbn/i18n';

import { EnterpriseSearchContentPageTemplate } from '../layout/page_template';

export const EnginesList = () => {
return (
<EnterpriseSearchContentPageTemplate
pageChrome={[
i18n.translate('xpack.enterpriseSearch.content.engines.breadcrumb', {
defaultMessage: 'Engines',
}),
]}
pageHeader={{
pageTitle: i18n.translate('xpack.enterpriseSearch.content.engines.headerTitle', {
defaultMessage: 'Engines',
}),
}}
pageViewTelemetry="Engines"
isLoading={false}
>
<div />
</EnterpriseSearchContentPageTemplate>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* 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 React from 'react';
import { Route, Switch } from 'react-router-dom';

import { useValues } from 'kea';

import { enableEnginesSection } from '../../../../../common/ui_settings_keys';
import { KibanaLogic } from '../../../shared/kibana';
import { ENGINES_PATH } from '../../routes';

import { NotFound } from '../not_found';

import { EnginesList } from './engines_list';

export const EnginesRouter: React.FC = () => {
const { uiSettings } = useValues(KibanaLogic);
const enginesSectionEnabled = uiSettings?.get<boolean>(enableEnginesSection, false);
if (!enginesSectionEnabled) {
return (
<Switch>
<Route>
<NotFound />
</Route>
</Switch>
);
}
return (
<Switch>
<Route exact path={ENGINES_PATH}>
<EnginesList />
</Route>
<Route>
<NotFound />
</Route>
</Switch>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@ import { HttpLogic } from '../shared/http';
import { KibanaLogic } from '../shared/kibana';
import { VersionMismatchPage } from '../shared/version_mismatch';

import { EnginesRouter } from './components/engines/engines_router';
import { ErrorConnecting } from './components/error_connecting';
import { NotFound } from './components/not_found';
import { SearchIndicesRouter } from './components/search_indices';
import { Settings } from './components/settings';
import { SETUP_GUIDE_PATH, ROOT_PATH, SEARCH_INDICES_PATH, SETTINGS_PATH } from './routes';
import {
SETUP_GUIDE_PATH,
ROOT_PATH,
SEARCH_INDICES_PATH,
SETTINGS_PATH,
ENGINES_PATH,
} from './routes';

export const EnterpriseSearchContent: React.FC<InitialAppData> = (props) => {
const { config } = useValues(KibanaLogic);
Expand Down Expand Up @@ -74,6 +81,9 @@ export const EnterpriseSearchContentConfigured: React.FC<Required<InitialAppData
<Route path={SETTINGS_PATH}>
<Settings />
</Route>
<Route path={ENGINES_PATH}>
<EnginesRouter />
</Route>
<Route>
<NotFound />
</Route>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ export const SEARCH_INDEX_TAB_PATH = `${SEARCH_INDEX_PATH}/:tabId`;
export const SEARCH_INDEX_CRAWLER_DOMAIN_DETAIL_PATH = `${SEARCH_INDEX_PATH}/crawler/domains/:domainId`;
export const SEARCH_INDEX_SELECT_CONNECTOR_PATH = `${SEARCH_INDEX_PATH}/select_connector`;

export const ENGINES_PATH = `${ROOT_PATH}engines`;

export const ML_MANAGE_TRAINED_MODELS_PATH = '/app/ml/trained_models';
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import { setMockValues, mockKibanaValues } from '../../__mocks__/kea_logic';

import { ProductAccess } from '../../../../common/types';

import { enableBehavioralAnalyticsSection } from '../../../../common/ui_settings_keys';
import {
enableBehavioralAnalyticsSection,
enableEnginesSection,
} from '../../../../common/ui_settings_keys';

import { useEnterpriseSearchNav } from './nav';

Expand Down Expand Up @@ -53,6 +56,11 @@ describe('useEnterpriseSearchContentNav', () => {
],
name: 'Content',
},
{
id: 'enterpiseSearchEngines',
name: 'Engines',
href: '/app/enterprise_search/content/engines',
},
{
id: 'enterpriseSearchAnalytics',
items: [
Expand Down Expand Up @@ -95,6 +103,7 @@ describe('useEnterpriseSearchContentNav', () => {
enableBehavioralAnalyticsSection,
false
);
expect(mockKibanaValues.uiSettings.get).toHaveBeenCalledWith(enableEnginesSection, false);
});

it('excludes legacy products when the user has no access to them', () => {
Expand All @@ -104,8 +113,12 @@ describe('useEnterpriseSearchContentNav', () => {
};

setMockValues({ productAccess: noProductAccess });
mockKibanaValues.uiSettings.get.mockReturnValue(false);

expect(useEnterpriseSearchNav()[3]).toEqual({
const esNav = useEnterpriseSearchNav();
const searchNav = esNav.find((item) => item.id === 'search');
expect(searchNav).not.toBeUndefined();
expect(searchNav).toEqual({
id: 'search',
items: [
{
Expand All @@ -131,7 +144,10 @@ describe('useEnterpriseSearchContentNav', () => {

setMockValues({ productAccess: workplaceSearchProductAccess });

expect(useEnterpriseSearchNav()[3]).toEqual({
const esNav = useEnterpriseSearchNav();
const searchNav = esNav.find((item) => item.id === 'search');
expect(searchNav).not.toBeUndefined();
expect(searchNav).toEqual({
id: 'search',
items: [
{
Expand Down Expand Up @@ -162,7 +178,10 @@ describe('useEnterpriseSearchContentNav', () => {

setMockValues({ productAccess: appSearchProductAccess });

expect(useEnterpriseSearchNav()[3]).toEqual({
const esNav = useEnterpriseSearchNav();
const searchNav = esNav.find((item) => item.id === 'search');
expect(searchNav).not.toBeUndefined();
expect(searchNav).toEqual({
id: 'search',
items: [
{
Expand All @@ -184,4 +203,50 @@ describe('useEnterpriseSearchContentNav', () => {
name: 'Search',
});
});

it('excludes analytics when feature flag is off', () => {
const fullProductAccess: ProductAccess = {
hasAppSearchAccess: true,
hasWorkplaceSearchAccess: true,
};
setMockValues({ productAccess: fullProductAccess });

const esNav = useEnterpriseSearchNav();
expect(esNav.find((item) => item.id === 'enterpriseSearchAnalytics')).toBeUndefined();
});
it('includes analytics when feature flag is off', () => {
const fullProductAccess: ProductAccess = {
hasAppSearchAccess: true,
hasWorkplaceSearchAccess: true,
};
setMockValues({ productAccess: fullProductAccess });
mockKibanaValues.uiSettings.get.mockReturnValueOnce(true).mockReturnValue(false);

const esNav = useEnterpriseSearchNav();
expect(esNav.find((item) => item.id === 'enterpriseSearchAnalytics')).not.toBeUndefined();
});
it('excludes engines when feature flag is off', () => {
const fullProductAccess: ProductAccess = {
hasAppSearchAccess: true,
hasWorkplaceSearchAccess: true,
};
setMockValues({ productAccess: fullProductAccess });

const esNav = useEnterpriseSearchNav();
expect(esNav.find((item) => item.id === 'enterpiseSearchEngines')).toBeUndefined();
});
it('includes engines when feature flag is on', () => {
const fullProductAccess: ProductAccess = {
hasAppSearchAccess: true,
hasWorkplaceSearchAccess: true,
};
setMockValues({ productAccess: fullProductAccess });
mockKibanaValues.uiSettings.get
.mockReturnValueOnce(false)
.mockReturnValueOnce(true)
.mockReturnValue(false);

const esNav = useEnterpriseSearchNav();
expect(esNav.find((item) => item.id === 'enterpiseSearchEngines')).not.toBeUndefined();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,15 @@ import {
SEARCH_EXPERIENCES_PLUGIN,
WORKPLACE_SEARCH_PLUGIN,
} from '../../../../common/constants';
import { enableBehavioralAnalyticsSection } from '../../../../common/ui_settings_keys';
import { SEARCH_INDICES_PATH, SETTINGS_PATH } from '../../enterprise_search_content/routes';
import {
enableBehavioralAnalyticsSection,
enableEnginesSection,
} from '../../../../common/ui_settings_keys';
import {
ENGINES_PATH,
SEARCH_INDICES_PATH,
SETTINGS_PATH,
} from '../../enterprise_search_content/routes';
import { KibanaLogic } from '../kibana';

import { generateNavLink } from './nav_link_helpers';
Expand All @@ -29,6 +36,7 @@ export const useEnterpriseSearchNav = () => {
const { productAccess, uiSettings } = useValues(KibanaLogic);

const analyticsSectionEnabled = uiSettings?.get<boolean>(enableBehavioralAnalyticsSection, false);
const enginesSectionEnabled = uiSettings?.get<boolean>(enableEnginesSection, false);

const navItems: Array<EuiSideNavItemType<unknown>> = [
{
Expand Down Expand Up @@ -71,6 +79,21 @@ export const useEnterpriseSearchNav = () => {
defaultMessage: 'Content',
}),
},
...(enginesSectionEnabled
? [
{
id: 'enterpiseSearchEngines',
name: i18n.translate('xpack.enterpriseSearch.nav.enginesTitle', {
defaultMessage: 'Engines',
}),
...generateNavLink({
shouldNotCreateHref: true,
shouldShowActiveForSubroutes: true,
to: ENTERPRISE_SEARCH_CONTENT_PLUGIN.URL + ENGINES_PATH,
}),
},
]
: []),
...(analyticsSectionEnabled
? [
{
Expand Down
18 changes: 17 additions & 1 deletion x-pack/plugins/enterprise_search/server/ui_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,25 @@
* 2.0.
*/

import { schema } from '@kbn/config-schema';
import { UiSettingsParams } from '@kbn/core/types';
import { i18n } from '@kbn/i18n';

import { enterpriseSearchFeatureId, enableEnginesSection } from '../common/ui_settings_keys';
/**
* uiSettings definitions for Enterprise Search
*/
export const uiSettings: Record<string, UiSettingsParams<boolean>> = {};
export const uiSettings: Record<string, UiSettingsParams<boolean>> = {
[enableEnginesSection]: {
category: [enterpriseSearchFeatureId],
description: i18n.translate('xpack.enterpriseSearch.uiSettings.engines.description', {
defaultMessage: 'Enable the new Engines section in Enterprise Search.',
}),
name: i18n.translate('xpack.enterpriseSearch.uiSettings.engines.name', {
defaultMessage: 'Enable Engines',
}),
requiresPageReload: false,
schema: schema.boolean(),
value: false,
},
};
10 changes: 10 additions & 0 deletions x-pack/plugins/security_solution/common/experimental_features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ export const allowedExperimentalValues = Object.freeze({
* Enables the `get-file` endpoint response action
*/
responseActionGetFileEnabled: false,

/**
* Keep DEPRECATED experimental flags that are documented to prevent failed upgrades.
* https://www.elastic.co/guide/en/security/current/user-risk-score.html
* https://www.elastic.co/guide/en/security/current/host-risk-score.html
*
* Issue: https://github.com/elastic/kibana/issues/146777
*/
riskyHostsEnabled: false, // DEPRECATED
riskyUsersEnabled: false, // DEPRECATED
});

type ExperimentalConfigKeys = Array<keyof ExperimentalFeatures>;
Expand Down
Loading

0 comments on commit 80ef488

Please sign in to comment.