[SIEM] Client NP Cutover (#64251)

* Move SIEM public/ folder to NP plugin

This is solely renames; fixes come next.

* Update relative imports in our API tests

* Fix linter errors following move to NP folder

These paths got a little shorter, so some lines could be collapsed.

* Move client dependencies to NP package.json

I'm removing the @types/js-yaml for now because I'm not sure we need it;
I'll add it back later if we do.

* Fix relative imports to other plugins

* Fix errant uses of ui/chrome

* Remove legacy plugin shim

* Move feature registration into plugin

This previously had to be part of legacy bootstrapping due to an order
of operations issue.

* Disconnect legacy plugin

The index file should now be redundant with what's in the plugin:

* app registration
* feature registration

* Move public gitattributes

* Remove references to legacy embeddables

We can now use the NP API. Maps embeddable will not work here until
their work is merged, but this should prevent us from importing legacy
code and thus breaking the build.

* Add our frontend dependencies to kibana.json

These are all required for now, because that's how they're typed. If
they _should_ be optional (and I think several should), we need to
update the type and handle the null case within the app.

* Replace use of ui/new_platform mocks in embeddable utils

* Fix remaining jest tests

* Replace build-breaking ui/new_platform mocks with equivalents in core
proper
* Remove unnecessary mocks of ui/new_platform

* Remove references to legacy SIEM folder

* I left the reference in CODEOWNERS in case someone tries to sneak
something back
* I left the .gitignore reference for the same reason

* Fix mocks of relative paths

These were not caught by typescript and were causing test failures.

* Export our client plugin contracts

They're empty for now.

* Move from deprecated appmount API

The new one dropped a param we weren't using.

* Add missing mock causing test failures

* Don't re-export core types from our plugin

Import them from core where we need them, instead

* Move Actions UI registry outside of mount

This is already imported, there's no benefit (and potential timing
issues) with doing this inside the mount.

* Add security's setup contract to our StartServices

This doesn't change what's used, only how we're typing it. The types are now a
little more truthful as:

* our StartPlugins don't include setup contracts
* our StartServices includes everything we use at Start time, including
the one setup plugin.

* Add order and icon back to the sidebar link

* Replace plugin class properties with constants

These are shared, and should be consistent.

* Enable our UI on NP

* Add missed plugin dependencies

We're not using their contracts, but we are importing code from them.

* Revert use of constant in translation

Can't do that, whoops

* i18n our feature catalogue entry

* Remove unnecessary array from single element

* Remove unused keys

These were the legacy translations used... well, I don't know where they
were used.

* Ignore circular dependencies in external plugins

* Normalize exclusions

* Add undeclared dependencies to kibana.json

We import our maps embeddable from maps, and we pass inspector to the
embeddable. I just missed these in my audit. This was causing errors in
the map embeddable.

* Await our call to setLayerList

This is an async call that we need to complete before we can render.

* Reduce siem plugin size

When we load our initial plugin (before our app is loaded), were were
implicitly importing all of kibana_react with this import. While a
global module prevents this from affecting our bundle size currently,
that could change in the future. Since we only need a reference to our
class, we just import that instead.
This commit is contained in:
Ryland Herrick 2020-04-27 17:59:21 -05:00 committed by GitHub
parent 54dc148226
commit 4cc5b3a4d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1697 changed files with 549 additions and 690 deletions

View file

@ -562,7 +562,7 @@ module.exports = {
*/
{
// front end typescript and javascript files only
files: ['x-pack/legacy/plugins/siem/public/**/*.{js,ts,tsx}'],
files: ['x-pack/plugins/siem/public/**/*.{js,ts,tsx}'],
rules: {
'import/no-nodejs-modules': 'error',
'no-restricted-imports': [
@ -611,7 +611,7 @@ module.exports = {
// {
// // will introduced after the other warns are fixed
// // typescript and javascript for front end react performance
// files: ['x-pack/legacy/plugins/siem/public/**/!(*.test).{js,ts,tsx}'],
// files: ['x-pack/plugins/siem/public/**/!(*.test).{js,ts,tsx}'],
// plugins: ['react-perf'],
// rules: {
// // 'react-perf/jsx-no-new-object-as-prop': 'error',

2
Jenkinsfile vendored
View file

@ -42,7 +42,7 @@ kibanaPipeline(timeoutMinutes: 135, checkPrChanges: true) {
'xpack-ciGroup10': kibanaPipeline.xpackCiGroupProcess(10),
'xpack-accessibility': kibanaPipeline.functionalTestProcess('xpack-accessibility', './test/scripts/jenkins_xpack_accessibility.sh'),
'xpack-siemCypress': { processNumber ->
whenChanged(['x-pack/plugins/siem/', 'x-pack/legacy/plugins/siem/', 'x-pack/test/siem_cypress/']) {
whenChanged(['x-pack/plugins/siem/', 'x-pack/test/siem_cypress/']) {
kibanaPipeline.functionalTestProcess('xpack-siemCypress', './test/scripts/jenkins_siem_cypress.sh')(processNumber)
}
},

View file

@ -36,7 +36,7 @@
"xpack.searchProfiler": "plugins/searchprofiler",
"xpack.security": ["legacy/plugins/security", "plugins/security"],
"xpack.server": "legacy/server",
"xpack.siem": ["plugins/siem", "legacy/plugins/siem"],
"xpack.siem": "plugins/siem",
"xpack.snapshotRestore": "plugins/snapshot_restore",
"xpack.spaces": ["legacy/plugins/spaces", "plugins/spaces"],
"xpack.taskManager": "legacy/plugins/task_manager",

View file

@ -17,7 +17,6 @@ import { spaces } from './legacy/plugins/spaces';
import { canvas } from './legacy/plugins/canvas';
import { infra } from './legacy/plugins/infra';
import { taskManager } from './legacy/plugins/task_manager';
import { siem } from './legacy/plugins/siem';
import { remoteClusters } from './legacy/plugins/remote_clusters';
import { upgradeAssistant } from './legacy/plugins/upgrade_assistant';
import { uptime } from './legacy/plugins/uptime';
@ -42,7 +41,6 @@ module.exports = function(kibana) {
indexManagement(kibana),
infra(kibana),
taskManager(kibana),
siem(kibana),
remoteClusters(kibana),
upgradeAssistant(kibana),
uptime(kibana),

View file

@ -1,5 +0,0 @@
# Auto-collapse generated files in GitHub
# https://help.github.com/en/articles/customizing-how-changed-files-appear-on-github
x-pack/legacy/plugins/siem/public/graphql/types.ts linguist-generated=true
x-pack/legacy/plugins/siem/public/graphql/introspection.json linguist-generated=true

View file

@ -1,56 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { i18n } from '@kbn/i18n';
import { resolve } from 'path';
import { Root } from 'joi';
import { APP_ID, APP_NAME } from '../../../plugins/siem/common/constants';
import { DEFAULT_APP_CATEGORIES } from '../../../../src/core/utils';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const siem = (kibana: any) => {
return new kibana.Plugin({
id: APP_ID,
configPrefix: 'xpack.siem',
publicDir: resolve(__dirname, 'public'),
require: ['kibana', 'elasticsearch', 'alerting', 'actions', 'triggers_actions_ui'],
uiExports: {
app: {
description: i18n.translate('xpack.siem.securityDescription', {
defaultMessage: 'Explore your SIEM App',
}),
main: 'plugins/siem/legacy',
euiIconType: 'securityAnalyticsApp',
title: APP_NAME,
listed: false,
url: `/app/${APP_ID}`,
},
home: ['plugins/siem/register_feature'],
links: [
{
description: i18n.translate('xpack.siem.linkSecurityDescription', {
defaultMessage: 'Explore your SIEM App',
}),
euiIconType: 'securityAnalyticsApp',
id: 'siem',
order: 9000,
title: APP_NAME,
url: `/app/${APP_ID}`,
category: DEFAULT_APP_CATEGORIES.security,
},
],
},
config(Joi: Root) {
return Joi.object()
.keys({
enabled: Joi.boolean().default(true),
})
.unknown(true)
.default();
},
});
};

View file

@ -1,16 +0,0 @@
{
"author": "Elastic",
"name": "siem-legacy-ui",
"version": "8.0.0",
"private": true,
"license": "Elastic-License",
"scripts": {},
"devDependencies": {
"@types/lodash": "^4.14.110",
"@types/js-yaml": "^3.12.1"
},
"dependencies": {
"lodash": "^4.17.15",
"react-markdown": "^4.0.6"
}
}

View file

@ -1,16 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { npSetup, npStart } from 'ui/new_platform';
import { PluginInitializerContext } from '../../../../../src/core/public';
import { plugin } from './';
import { SetupPlugins, StartPlugins } from './plugin';
const pluginInstance = plugin({} as PluginInitializerContext);
pluginInstance.setup(npSetup.core, (npSetup.plugins as unknown) as SetupPlugins);
pluginInstance.start(npStart.core, (npStart.plugins as unknown) as StartPlugins);

View file

@ -1,27 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { StartServices } from '../../plugin';
type GlobalServices = Pick<StartServices, 'http' | 'uiSettings'>;
export class KibanaServices {
private static services?: GlobalServices;
public static init({ http, uiSettings }: StartServices) {
this.services = { http, uiSettings };
}
public static get(): GlobalServices {
if (!this.services) {
throw new Error(
'Kibana services not set - are you trying to import this module from outside of the SIEM app?'
);
}
return this.services;
}
}

View file

@ -1,13 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { createUiNewPlatformMock } from 'ui/new_platform/__mocks__/helpers';
export const createKibanaCoreSetupMock = () => createUiNewPlatformMock().npSetup.core;
export const createKibanaPluginsSetupMock = () => createUiNewPlatformMock().npSetup.plugins;
export const createKibanaCoreStartMock = () => createUiNewPlatformMock().npStart.core;
export const createKibanaPluginsStartMock = () => createUiNewPlatformMock().npStart.plugins;

View file

@ -1,93 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import {
AppMountParameters,
CoreSetup,
CoreStart,
PluginInitializerContext,
Plugin as IPlugin,
} from '../../../../../src/core/public';
import { HomePublicPluginSetup } from '../../../../../src/plugins/home/public';
import { DataPublicPluginStart } from '../../../../../src/plugins/data/public';
import { EmbeddableStart } from '../../../../../src/plugins/embeddable/public';
import { Start as NewsfeedStart } from '../../../../../src/plugins/newsfeed/public';
import { Start as InspectorStart } from '../../../../../src/plugins/inspector/public';
import { UiActionsStart } from '../../../../../src/plugins/ui_actions/public';
import { UsageCollectionSetup } from '../../../../../src/plugins/usage_collection/public';
import { initTelemetry } from './lib/telemetry';
import { KibanaServices } from './lib/kibana';
import { serviceNowActionType } from './lib/connectors';
import {
TriggersAndActionsUIPublicPluginSetup,
TriggersAndActionsUIPublicPluginStart,
} from '../../../../plugins/triggers_actions_ui/public';
import { SecurityPluginSetup } from '../../../../plugins/security/public';
export { AppMountParameters, CoreSetup, CoreStart, PluginInitializerContext };
export interface SetupPlugins {
home: HomePublicPluginSetup;
security: SecurityPluginSetup;
triggers_actions_ui: TriggersAndActionsUIPublicPluginSetup;
usageCollection: UsageCollectionSetup;
}
export interface StartPlugins {
data: DataPublicPluginStart;
embeddable: EmbeddableStart;
inspector: InspectorStart;
newsfeed?: NewsfeedStart;
security: SecurityPluginSetup;
triggers_actions_ui: TriggersAndActionsUIPublicPluginStart;
uiActions: UiActionsStart;
}
export type StartServices = CoreStart & StartPlugins;
export type Setup = ReturnType<Plugin['setup']>;
export type Start = ReturnType<Plugin['start']>;
export class Plugin implements IPlugin<Setup, Start> {
public id = 'siem';
public name = 'SIEM';
constructor(
// @ts-ignore this is added to satisfy the New Platform typing constraint,
// but we're not leveraging any of its functionality yet.
private readonly initializerContext: PluginInitializerContext
) {}
public setup(core: CoreSetup, plugins: SetupPlugins) {
initTelemetry(plugins.usageCollection, this.id);
const security = plugins.security;
core.application.register({
id: this.id,
title: this.name,
async mount(context, params) {
const [coreStart, startPlugins] = await core.getStartServices();
const { renderApp } = await import('./app');
plugins.triggers_actions_ui.actionTypeRegistry.register(serviceNowActionType());
return renderApp(coreStart, { ...startPlugins, security } as StartPlugins, params);
},
});
return {};
}
public start(core: CoreStart, plugins: StartPlugins) {
KibanaServices.init({ ...core, ...plugins });
return {};
}
public stop() {
return {};
}
}

View file

@ -1,20 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { npSetup } from 'ui/new_platform';
import { FeatureCatalogueCategory } from '../../../../../src/plugins/home/public';
import { APP_ID } from '../../../../plugins/siem/common/constants';
// TODO(rylnd): move this into Plugin.setup once we're on NP
npSetup.plugins.home.featureCatalogue.register({
id: APP_ID,
title: 'SIEM',
description: 'Explore security metrics and logs for events and alerts',
icon: 'securityAnalyticsApp',
path: `/app/${APP_ID}`,
showOnHomePage: true,
category: FeatureCatalogueCategory.DATA,
});

View file

@ -1 +0,0 @@
../../../../yarn.lock

View file

@ -1,4 +1,6 @@
# Auto-collapse generated files in GitHub
# https://help.github.com/en/articles/customizing-how-changed-files-appear-on-github
x-pack/plugins/siem/server/graphql/types.ts linguist-generated=true
x-pack/plugins/siem/public/graphql/types.ts linguist-generated=true
x-pack/plugins/siem/public/graphql/introspection.json linguist-generated=true

View file

@ -6,6 +6,8 @@
export const APP_ID = 'siem';
export const APP_NAME = 'SIEM';
export const APP_ICON = 'securityAnalyticsApp';
export const APP_PATH = `/app/${APP_ID}`;
export const DEFAULT_BYTES_FORMAT = 'format:bytes:defaultPattern';
export const DEFAULT_DATE_FORMAT = 'dateFormat';
export const DEFAULT_DATE_FORMAT_TZ = 'dateFormat:tz';

View file

@ -3,8 +3,23 @@
"version": "8.0.0",
"kibanaVersion": "kibana",
"configPath": ["xpack", "siem"],
"requiredPlugins": ["actions", "alerting", "features", "licensing"],
"optionalPlugins": ["encryptedSavedObjects", "ml", "security", "spaces"],
"requiredPlugins": [
"actions",
"alerting",
"data",
"embeddable",
"esUiShared",
"features",
"home",
"inspector",
"kibanaUtils",
"licensing",
"maps",
"triggers_actions_ui",
"uiActions",
"usageCollection"
],
"optionalPlugins": ["encryptedSavedObjects", "ml", "newsfeed", "security", "spaces"],
"server": true,
"ui": false
"ui": true
}

View file

@ -5,7 +5,7 @@
"private": true,
"license": "Elastic-License",
"scripts": {
"extract-mitre-attacks": "node scripts/extract_tactics_techniques_mitre.js && node ../../../scripts/eslint ../../legacy/plugins/siem/public/pages/detection_engine/mitre/mitre_tactics_techniques.ts --fix",
"extract-mitre-attacks": "node scripts/extract_tactics_techniques_mitre.js && node ../../../scripts/eslint ./public/pages/detection_engine/mitre/mitre_tactics_techniques.ts --fix",
"build-graphql-types": "node scripts/generate_types_from_graphql.js",
"cypress:open": "cypress open --config-file ./cypress/cypress.json",
"cypress:run": "cypress run --spec ./cypress/integration/**/*.spec.ts --config-file ./cypress/cypress.json --reporter ../../node_modules/cypress-multi-reporters --reporter-options configFile=./cypress/reporter_config.json; status=$?; ../../node_modules/.bin/mochawesome-merge --reportDir ../../../target/kibana-siem/cypress/results > ../../../target/kibana-siem/cypress/results/output.json; ../../../node_modules/.bin/marge ../../../target/kibana-siem/cypress/results/output.json --reportDir ../../../target/kibana-siem/cypress/results; mkdir -p ../../../target/junit && cp ../../../target/kibana-siem/cypress/results/*.xml ../../../target/junit/ && exit $status;",
@ -15,6 +15,7 @@
"@types/lodash": "^4.14.110"
},
"dependencies": {
"lodash": "^4.17.15"
"lodash": "^4.17.15",
"react-markdown": "^4.0.6"
}
}

View file

@ -18,13 +18,13 @@ import { BehaviorSubject } from 'rxjs';
import { pluck } from 'rxjs/operators';
import { KibanaContextProvider, useKibana, useUiSetting$ } from '../lib/kibana';
import { Storage } from '../../../../../../src/plugins/kibana_utils/public';
import { Storage } from '../../../../../src/plugins/kibana_utils/public';
import { DEFAULT_DARK_MODE } from '../../../../../plugins/siem/common/constants';
import { DEFAULT_DARK_MODE } from '../../common/constants';
import { ErrorToastDispatcher } from '../components/error_toast_dispatcher';
import { compose } from '../lib/compose/kibana_compose';
import { AppFrontendLibs, AppApolloClient } from '../lib/lib';
import { CoreStart, StartPlugins } from '../plugin';
import { StartServices } from '../plugin';
import { PageRouter } from '../routes';
import { createStore, createInitialState } from '../store';
import { GlobalToaster, ManageGlobalToaster } from '../components/toasters';
@ -95,21 +95,18 @@ const StartAppComponent: FC<AppFrontendLibs> = libs => {
const StartApp = memo(StartAppComponent);
interface SiemAppComponentProps {
core: CoreStart;
plugins: StartPlugins;
services: StartServices;
}
const SiemAppComponent: React.FC<SiemAppComponentProps> = ({ core, plugins }) => (
const SiemAppComponent: React.FC<SiemAppComponentProps> = ({ services }) => (
<KibanaContextProvider
services={{
appName: 'siem',
storage: new Storage(localStorage),
...core,
...plugins,
savedObjects: core.savedObjects,
...services,
}}
>
<StartApp {...compose(core)} />
<StartApp {...compose(services)} />
</KibanaContextProvider>
);

View file

@ -7,14 +7,11 @@
import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import { CoreStart, StartPlugins, AppMountParameters } from '../plugin';
import { AppMountParameters } from '../../../../../src/core/public';
import { StartServices } from '../plugin';
import { SiemApp } from './app';
export const renderApp = (
core: CoreStart,
plugins: StartPlugins,
{ element }: AppMountParameters
) => {
render(<SiemApp core={core} plugins={plugins} />, element);
export const renderApp = (services: StartServices, { element }: AppMountParameters) => {
render(<SiemApp services={services} />, element);
return () => unmountComponentAtNode(element);
};

View file

@ -6,7 +6,7 @@
import React, { useMemo } from 'react';
import { Filter } from '../../../../../../../src/plugins/data/public';
import { Filter } from '../../../../../../src/plugins/data/public';
import { StatefulEventsViewer } from '../events_viewer';
import * as i18n from './translations';
import { alertsDefaultModel } from './default_headers';

View file

@ -6,7 +6,7 @@
import React, { useEffect, useCallback, useMemo } from 'react';
import numeral from '@elastic/numeral';
import { DEFAULT_NUMBER_FORMAT } from '../../../../../../plugins/siem/common/constants';
import { DEFAULT_NUMBER_FORMAT } from '../../../common/constants';
import { AlertsComponentsQueryProps } from './types';
import { AlertsTable } from './alerts_table';
import * as i18n from './translations';

View file

@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { Filter } from '../../../../../../../src/plugins/data/public';
import { Filter } from '../../../../../../src/plugins/data/public';
import { HostsComponentsQueryProps } from '../../pages/hosts/navigation/types';
import { NetworkComponentQueryProps } from '../../pages/network/navigation/types';
import { MatrixHistogramOption } from '../matrix_histogram/types';

View file

@ -11,7 +11,7 @@ import euiLightVars from '@elastic/eui/dist/eui_theme_light.json';
import {
QuerySuggestion,
QuerySuggestionTypes,
} from '../../../../../../../../src/plugins/data/public';
} from '../../../../../../../src/plugins/data/public';
import { SuggestionItem } from '../suggestion_item';
const suggestion: QuerySuggestion = {

View file

@ -10,10 +10,7 @@ import { mount, shallow } from 'enzyme';
import { noop } from 'lodash/fp';
import React from 'react';
import { ThemeProvider } from 'styled-components';
import {
QuerySuggestion,
QuerySuggestionTypes,
} from '../../../../../../../src/plugins/data/public';
import { QuerySuggestion, QuerySuggestionTypes } from '../../../../../../src/plugins/data/public';
import { TestProviders } from '../../mock';

View file

@ -11,9 +11,9 @@ import {
EuiPanel,
} from '@elastic/eui';
import React from 'react';
import { QuerySuggestion } from '../../../../../../../src/plugins/data/public';
import { QuerySuggestion } from '../../../../../../src/plugins/data/public';
import euiStyled from '../../../../../common/eui_styled_components';
import euiStyled from '../../../../../legacy/common/eui_styled_components';
import { SuggestionItem } from './suggestion_item';

View file

@ -8,8 +8,8 @@ import { EuiIcon } from '@elastic/eui';
import { transparentize } from 'polished';
import React from 'react';
import styled from 'styled-components';
import euiStyled from '../../../../../common/eui_styled_components';
import { QuerySuggestion } from '../../../../../../../src/plugins/data/public';
import euiStyled from '../../../../../legacy/common/eui_styled_components';
import { QuerySuggestion } from '../../../../../../src/plugins/data/public';
interface SuggestionItemProps {
isSelected?: boolean;

View file

@ -19,7 +19,7 @@ import {
import React, { useMemo } from 'react';
import styled from 'styled-components';
import { DEFAULT_DARK_MODE } from '../../../../../../plugins/siem/common/constants';
import { DEFAULT_DARK_MODE } from '../../../common/constants';
import { useUiSetting } from '../../lib/kibana';
export const defaultChartHeight = '100%';

View file

@ -13,7 +13,7 @@ import { wait } from '../../lib/helpers';
import { useKibana } from '../../lib/kibana';
import { TestProviders } from '../../mock';
import { createKibanaCoreStartMock } from '../../mock/kibana_core';
import { FilterManager } from '../../../../../../../src/plugins/data/public';
import { FilterManager } from '../../../../../../src/plugins/data/public';
import { TimelineContext } from '../timeline/timeline_context';
import { DraggableWrapperHoverContent } from './draggable_wrapper_hover_content';

View file

@ -8,13 +8,9 @@ import { EuiLink, EuiText } from '@elastic/eui';
import React, { useEffect, useState } from 'react';
import { createPortalNode, InPortal } from 'react-reverse-portal';
import styled, { css } from 'styled-components';
import { npStart } from 'ui/new_platform';
import {
EmbeddablePanel,
ErrorEmbeddable,
} from '../../../../../../../src/plugins/embeddable/public';
import { DEFAULT_INDEX_KEY } from '../../../../../../plugins/siem/common/constants';
import { EmbeddablePanel, ErrorEmbeddable } from '../../../../../../src/plugins/embeddable/public';
import { DEFAULT_INDEX_KEY } from '../../../common/constants';
import { getIndexPatternTitleIdMapping } from '../../hooks/api/helpers';
import { useIndexPatterns } from '../../hooks/use_index_patterns';
import { Loader } from '../loader';
@ -26,10 +22,10 @@ import { IndexPatternsMissingPrompt } from './index_patterns_missing_prompt';
import { MapToolTip } from './map_tool_tip/map_tool_tip';
import * as i18n from './translations';
import { SetQuery } from './types';
import { MapEmbeddable } from '../../../../../plugins/maps/public';
import { Query, Filter } from '../../../../../../../src/plugins/data/public';
import { MapEmbeddable } from '../../../../../legacy/plugins/maps/public';
import { Query, Filter } from '../../../../../../src/plugins/data/public';
import { useKibana, useUiSetting$ } from '../../lib/kibana';
import { getSavedObjectFinder } from '../../../../../../../src/plugins/saved_objects/public';
import { getSavedObjectFinder } from '../../../../../../src/plugins/saved_objects/public';
interface EmbeddableMapProps {
maintainRatio?: boolean;
@ -203,8 +199,8 @@ export const EmbeddedMapComponent = ({
data-test-subj="embeddable-panel"
embeddable={embeddable}
getActions={services.uiActions.getTriggerCompatibleActions}
getEmbeddableFactory={npStart.plugins.embeddable.getEmbeddableFactory}
getAllEmbeddableFactories={npStart.plugins.embeddable.getEmbeddableFactories}
getEmbeddableFactory={services.embeddable.getEmbeddableFactory}
getAllEmbeddableFactories={services.embeddable.getEmbeddableFactories}
notifications={services.notifications}
overlays={services.overlays}
inspector={services.inspector}

View file

@ -4,8 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { embeddablePluginMock } from '../../../../../../src/plugins/embeddable/public/mocks';
import { createEmbeddable, findMatchingIndexPatterns } from './embedded_map_helpers';
import { createUiNewPlatformMock } from 'ui/new_platform/__mocks__/helpers';
import { createPortalNode } from 'react-reverse-portal';
import {
mockAPMIndexPattern,
@ -16,10 +16,9 @@ import {
mockGlobIndexPattern,
} from './__mocks__/mock';
jest.mock('ui/new_platform');
const mockEmbeddable = embeddablePluginMock.createStartContract();
const { npStart } = createUiNewPlatformMock();
npStart.plugins.embeddable.getEmbeddableFactory = jest.fn().mockImplementation(() => ({
mockEmbeddable.getEmbeddableFactory = jest.fn().mockImplementation(() => ({
create: () => ({
reload: jest.fn(),
setRenderTooltipContent: jest.fn(),
@ -39,7 +38,7 @@ describe('embedded_map_helpers', () => {
0,
setQueryMock,
createPortalNode(),
npStart.plugins.embeddable
mockEmbeddable
);
expect(setQueryMock).toHaveBeenCalledTimes(1);
});
@ -54,7 +53,7 @@ describe('embedded_map_helpers', () => {
0,
setQueryMock,
createPortalNode(),
npStart.plugins.embeddable
mockEmbeddable
);
expect(setQueryMock.mock.calls[0][0].refetch).not.toBe(embeddable.reload);
setQueryMock.mock.results[0].value();

Some files were not shown because too many files have changed in this diff Show more