Skip to content

Commit

Permalink
Merge branch 'main' into fix/x-pack-test-types
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Sep 27, 2023
2 parents 555deac + 7f79665 commit 386bab7
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 22 deletions.
1 change: 1 addition & 0 deletions config/serverless.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ xpack.apm.enabled: false

xpack.cloudSecurityPosture.enabled: false
xpack.infra.enabled: false
xpack.observabilityLogExplorer.enabled: false
xpack.observability.enabled: false
xpack.securitySolution.enabled: false
xpack.serverless.observability.enabled: false
Expand Down
1 change: 1 addition & 0 deletions config/serverless.security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
enterpriseSearch.enabled: false
xpack.apm.enabled: false
xpack.infra.enabled: false
xpack.observabilityLogExplorer.enabled: false
xpack.observability.enabled: false
xpack.uptime.enabled: false
xpack.legacy_uptime.enabled: false
Expand Down
33 changes: 18 additions & 15 deletions x-pack/plugins/ml/public/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,33 @@ import { sharePluginMock } from '@kbn/share-plugin/public/mocks';
import { type ElasticModels } from './application/services/elastic_models_service';
import type { MlPluginSetup, MlPluginStart } from './plugin';

const createElasticModelsMock = (): jest.Mocked<ElasticModels> => {
return {
getELSER: jest.fn().mockResolvedValue({
version: 2,
default: true,
config: {
input: {
field_names: ['text_field'],
},
},
description: 'Elastic Learned Sparse EncodeR v2 (Tech Preview)',
name: '.elser_model_2',
}),
} as unknown as jest.Mocked<ElasticModels>;
};

const createSetupContract = (): jest.Mocked<MlPluginSetup> => {
return {
locator: sharePluginMock.createLocator(),
elasticModels: createElasticModelsMock(),
};
};

const createStartContract = (): jest.Mocked<MlPluginStart> => {
return {
locator: sharePluginMock.createLocator(),
elasticModels: {
getELSER: jest.fn(() =>
Promise.resolve({
version: 2,
default: true,
config: {
input: {
field_names: ['text_field'],
},
},
description: 'Elastic Learned Sparse EncodeR v2 (Tech Preview)',
name: '.elser_model_2',
})
),
} as unknown as jest.Mocked<ElasticModels>,
elasticModels: createElasticModelsMock(),
};
};

Expand Down
16 changes: 12 additions & 4 deletions x-pack/plugins/ml/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { take } from 'rxjs/operators';

import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public';
import type { ManagementSetup } from '@kbn/management-plugin/public';
import type { SharePluginSetup, SharePluginStart } from '@kbn/share-plugin/public';
import type { LocatorPublic, SharePluginSetup, SharePluginStart } from '@kbn/share-plugin/public';
import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
import type { HomePublicPluginSetup } from '@kbn/home-plugin/public';
import type { EmbeddableSetup, EmbeddableStart } from '@kbn/embeddable-plugin/public';
Expand Down Expand Up @@ -54,7 +54,7 @@ import {
MlSharedServices,
} from './application/services/get_shared_ml_services';
import { registerManagementSection } from './application/management';
import { MlLocatorDefinition, type MlLocator } from './locator';
import { MlLocatorDefinition, MlLocatorParams, type MlLocator } from './locator';
import { setDependencyCache } from './application/util/dependency_cache';
import { registerHomeFeature } from './register_home_feature';
import { isFullLicense, isMlEnabled } from '../common/license';
Expand All @@ -67,6 +67,7 @@ import {
type ConfigSchema,
} from '../common/constants/app';
import type { MlCapabilities } from './shared';
import { ElasticModels } from './application/services/elastic_models_service';

export interface MlStartDependencies {
dataViewEditor: DataViewEditorStart;
Expand Down Expand Up @@ -131,7 +132,10 @@ export class MlPlugin implements Plugin<MlPluginSetup, MlPluginStart> {
initEnabledFeatures(this.enabledFeatures, initializerContext.config.get());
}

setup(core: MlCoreSetup, pluginsSetup: MlSetupDependencies) {
setup(
core: MlCoreSetup,
pluginsSetup: MlSetupDependencies
): { locator?: LocatorPublic<MlLocatorParams>; elasticModels?: ElasticModels } {
this.sharedMlServices = getMlSharedServices(core.http);

core.application.register({
Expand Down Expand Up @@ -262,10 +266,14 @@ export class MlPlugin implements Plugin<MlPluginSetup, MlPluginStart> {

return {
locator: this.locator,
elasticModels: this.sharedMlServices.elasticModels,
};
}

start(core: CoreStart, deps: MlStartDependencies) {
start(
core: CoreStart,
deps: MlStartDependencies
): { locator?: LocatorPublic<MlLocatorParams>; elasticModels?: ElasticModels } {
setDependencyCache({
docLinks: core.docLinks!,
basePath: core.http.basePath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* 2.0.
*/

import React, { useEffect } from 'react';
import React, { useEffect, useState } from 'react';
import deepEqual from 'fast-deep-equal';
import useObservable from 'react-use/lib/useObservable';
import { type BehaviorSubject, distinctUntilChanged } from 'rxjs';
import { type BehaviorSubject, distinctUntilChanged, filter, take } from 'rxjs';
import { HeaderMenuPortal } from '@kbn/observability-shared-plugin/public';
import { AppMountParameters } from '@kbn/core-application-browser';
import {
Expand Down Expand Up @@ -111,6 +111,16 @@ const StatefulTopNav = ({
}: LogExplorerTopNavMenuProps) => {
const { euiTheme } = useEuiTheme();

/**
* Since the breadcrumbsAppendExtension might be set only during a plugin start (e.g. search session)
* we retrieve the latest valid extension in order to restore it once we unmount the beta badge.
*/
const [previousAppendExtension$] = useState(() =>
services.chrome.getBreadcrumbsAppendExtension$().pipe(filter(Boolean), take(1))
);

const previousAppendExtension = useObservable(previousAppendExtension$);

useEffect(() => {
const { chrome, i18n, theme } = services;

Expand All @@ -137,7 +147,13 @@ const StatefulTopNav = ({
),
});
}
}, [euiTheme, services]);

return () => {
if (chrome) {
chrome.setBreadcrumbsAppendExtension(previousAppendExtension);
}
};
}, [euiTheme, services, previousAppendExtension]);

return (
<HeaderMenuPortal setHeaderActionMenu={setHeaderActionMenu} theme$={theme$}>
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/observability_log_explorer/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export class ObservabilityLogExplorerPlugin
? AppNavLinkStatus.visible
: AppNavLinkStatus.hidden,
searchable: true,
keywords: ['logs', 'log', 'explorer', 'logs explorer'],
mount: async (appMountParams) => {
const [coreStart, pluginsStart, ownPluginStart] = await core.getStartServices();

Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/observability_log_explorer/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { PluginConfigDescriptor } from '@kbn/core/server';
import { ObservabilityLogExplorerConfig } from '../common/plugin_config';

export const configSchema = schema.object({
enabled: schema.boolean({ defaultValue: true }),
navigation: schema.object({
showAppLink: offeringBasedSchema({
serverless: schema.boolean({
Expand Down

0 comments on commit 386bab7

Please sign in to comment.