Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use core.getStartServices to get uiActions #61421

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion x-pack/legacy/plugins/lens/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
11 changes: 4 additions & 7 deletions x-pack/legacy/plugins/lens/public/xy_visualization/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,22 @@
*/

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';
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;
formatFactory: Promise<FormatFactory>;
editorFrame: EditorFrameSetup;
}

interface XyVisualizationPluginStartPlugins {
export interface XyVisualizationPluginStartPlugins {
uiActions: UiActionsStart;
}

Expand All @@ -38,7 +37,7 @@ export class XyVisualization {
constructor() {}

setup(
core: CoreSetup,
core: CoreSetup<XyVisualizationPluginStartPlugins>,
{ expressions, formatFactory, editorFrame }: XyVisualizationPluginSetupPlugins
) {
expressions.registerFunction(() => legendConfig);
Expand All @@ -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);
}
}
12 changes: 0 additions & 12 deletions x-pack/legacy/plugins/lens/public/xy_visualization/services.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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> = T extends React.FunctionComponent<infer P> ? P : T;
type SeriesSpec = InferPropType<typeof LineSeries> &
Expand Down Expand Up @@ -110,6 +111,7 @@ export const getXyChartRenderer = (dependencies: {
formatFactory: Promise<FormatFactory>;
chartTheme: PartialTheme;
timeZone: string;
core: CoreSetup<XyVisualizationPluginStartPlugins>;
}): ExpressionRenderDefinition<XYChartProps> => ({
name: 'lens_xy_chart_renderer',
displayName: 'XY chart',
Expand All @@ -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(
Expand All @@ -129,7 +131,7 @@ export const getXyChartRenderer = (dependencies: {
formatFactory={formatFactory}
chartTheme={dependencies.chartTheme}
timeZone={dependencies.timeZone}
executeTriggerActions={executeTriggerActions}
executeTriggerActions={startPluginServices.uiActions.executeTriggerActions}
/>
</I18nProvider>,
domNode,
Expand Down