From 2a9a88ab9c7b8f0e0a641681112a8a22f80c4744 Mon Sep 17 00:00:00 2001 From: Tim Roes Date: Thu, 26 Mar 2020 11:14:45 +0100 Subject: [PATCH] Use core.getStartServices to get uiActions --- x-pack/legacy/plugins/lens/public/plugin.tsx | 1 - .../plugins/lens/public/xy_visualization/index.ts | 11 ++++------- .../plugins/lens/public/xy_visualization/services.ts | 12 ------------ .../lens/public/xy_visualization/xy_expression.tsx | 8 +++++--- 4 files changed, 9 insertions(+), 23 deletions(-) delete mode 100644 x-pack/legacy/plugins/lens/public/xy_visualization/services.ts diff --git a/x-pack/legacy/plugins/lens/public/plugin.tsx b/x-pack/legacy/plugins/lens/public/plugin.tsx index fad1371199e6a..8c6793fad7091 100644 --- a/x-pack/legacy/plugins/lens/public/plugin.tsx +++ b/x-pack/legacy/plugins/lens/public/plugin.tsx @@ -219,7 +219,6 @@ export class LensPlugin { start(core: CoreStart, startDependencies: LensPluginStartDependencies) { this.createEditorFrame = this.editorFrameService.start(core, startDependencies).createInstance; - this.xyVisualization.start(core, startDependencies); } stop() { diff --git a/x-pack/legacy/plugins/lens/public/xy_visualization/index.ts b/x-pack/legacy/plugins/lens/public/xy_visualization/index.ts index 8cc5abb44d6e1..3b091275d2009 100644 --- a/x-pack/legacy/plugins/lens/public/xy_visualization/index.ts +++ b/x-pack/legacy/plugins/lens/public/xy_visualization/index.ts @@ -5,7 +5,7 @@ */ import { EUI_CHARTS_THEME_DARK, EUI_CHARTS_THEME_LIGHT } from '@elastic/eui/dist/eui_charts_theme'; -import { CoreSetup, IUiSettingsClient, CoreStart } from 'src/core/public'; +import { CoreSetup, IUiSettingsClient } from 'src/core/public'; import moment from 'moment-timezone'; import { ExpressionsSetup } from '../../../../../../src/plugins/expressions/public'; import { xyVisualization } from './xy_visualization'; @@ -13,7 +13,6 @@ import { xyChart, getXyChartRenderer } from './xy_expression'; import { legendConfig, xConfig, layerConfig } from './types'; import { EditorFrameSetup, FormatFactory } from '../types'; import { UiActionsStart } from '../../../../../../src/plugins/ui_actions/public'; -import { setExecuteTriggerActions } from './services'; export interface XyVisualizationPluginSetupPlugins { expressions: ExpressionsSetup; @@ -21,7 +20,7 @@ export interface XyVisualizationPluginSetupPlugins { editorFrame: EditorFrameSetup; } -interface XyVisualizationPluginStartPlugins { +export interface XyVisualizationPluginStartPlugins { uiActions: UiActionsStart; } @@ -38,7 +37,7 @@ export class XyVisualization { constructor() {} setup( - core: CoreSetup, + core: CoreSetup, { expressions, formatFactory, editorFrame }: XyVisualizationPluginSetupPlugins ) { expressions.registerFunction(() => legendConfig); @@ -53,12 +52,10 @@ export class XyVisualization { ? EUI_CHARTS_THEME_DARK.theme : EUI_CHARTS_THEME_LIGHT.theme, timeZone: getTimeZone(core.uiSettings), + core, }) ); editorFrame.registerVisualization(xyVisualization); } - start(core: CoreStart, { uiActions }: XyVisualizationPluginStartPlugins) { - setExecuteTriggerActions(uiActions.executeTriggerActions); - } } diff --git a/x-pack/legacy/plugins/lens/public/xy_visualization/services.ts b/x-pack/legacy/plugins/lens/public/xy_visualization/services.ts deleted file mode 100644 index af683efb86534..0000000000000 --- a/x-pack/legacy/plugins/lens/public/xy_visualization/services.ts +++ /dev/null @@ -1,12 +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 { createGetterSetter } from '../../../../../../src/plugins/kibana_utils/public'; -import { UiActionsStart } from '../../../../../../src/plugins/ui_actions/public'; - -export const [getExecuteTriggerActions, setExecuteTriggerActions] = createGetterSetter< - UiActionsStart['executeTriggerActions'] ->('executeTriggerActions'); diff --git a/x-pack/legacy/plugins/lens/public/xy_visualization/xy_expression.tsx b/x-pack/legacy/plugins/lens/public/xy_visualization/xy_expression.tsx index eaf3acf7bb2a7..c9ce01c4a3d92 100644 --- a/x-pack/legacy/plugins/lens/public/xy_visualization/xy_expression.tsx +++ b/x-pack/legacy/plugins/lens/public/xy_visualization/xy_expression.tsx @@ -28,14 +28,15 @@ import { import { EuiIcon, EuiText, IconType, EuiSpacer } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; +import { CoreSetup } from 'kibana/public'; import { EmbeddableVisTriggerContext } from '../../../../../../src/plugins/embeddable/public'; import { VIS_EVENT_TO_TRIGGER } from '../../../../../../src/legacy/core_plugins/visualizations/public/np_ready/public/embeddable/events'; import { LensMultiTable, FormatFactory } from '../types'; +import { XyVisualizationPluginStartPlugins } from './index'; import { XYArgs, SeriesType, visualizationTypes } from './types'; import { VisualizationContainer } from '../visualization_container'; import { isHorizontalChart } from './state_helpers'; import { UiActionsStart } from '../../../../../../src/plugins/ui_actions/public'; -import { getExecuteTriggerActions } from './services'; type InferPropType = T extends React.FunctionComponent ? P : T; type SeriesSpec = InferPropType & @@ -110,6 +111,7 @@ export const getXyChartRenderer = (dependencies: { formatFactory: Promise; chartTheme: PartialTheme; timeZone: string; + core: CoreSetup; }): ExpressionRenderDefinition => ({ name: 'lens_xy_chart_renderer', displayName: 'XY chart', @@ -119,7 +121,7 @@ export const getXyChartRenderer = (dependencies: { validate: () => undefined, reuseDomNode: true, render: async (domNode: Element, config: XYChartProps, handlers: IInterpreterRenderHandlers) => { - const executeTriggerActions = getExecuteTriggerActions(); + const [, startPluginServices] = await dependencies.core.getStartServices(); handlers.onDestroy(() => ReactDOM.unmountComponentAtNode(domNode)); const formatFactory = await dependencies.formatFactory; ReactDOM.render( @@ -129,7 +131,7 @@ export const getXyChartRenderer = (dependencies: { formatFactory={formatFactory} chartTheme={dependencies.chartTheme} timeZone={dependencies.timeZone} - executeTriggerActions={executeTriggerActions} + executeTriggerActions={startPluginServices.uiActions.executeTriggerActions} /> , domNode,