Skip to content

Commit

Permalink
Expose xy chart types component (#95275)
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 authored and kibanamachine committed Mar 29, 2021
1 parent a542d12 commit 6d64e53
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions x-pack/plugins/lens/public/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const createStartContract = (): Start => {
EmbeddableComponent: jest.fn(() => null),
canUseEditor: jest.fn(() => true),
navigateToPrefilledEditor: jest.fn(),
getXyVisTypes: jest.fn(),
};
return startContract;
};
Expand Down
11 changes: 10 additions & 1 deletion x-pack/plugins/lens/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import {
VISUALIZE_FIELD_TRIGGER,
} from '../../../../src/plugins/ui_actions/public';
import { APP_ID, getEditPath, NOT_INTERNATIONALIZED_PRODUCT_NAME } from '../common';
import { EditorFrameStart } from './types';
import type { EditorFrameStart, VisualizationType } from './types';
import { getLensAliasConfig } from './vis_type_alias';
import { visualizeFieldAction } from './trigger_actions/visualize_field_actions';
import { getSearchProvider } from './search_provider';
Expand Down Expand Up @@ -101,6 +101,11 @@ export interface LensPublicStart {
* Method which returns true if the user has permission to use Lens as defined by application capabilities.
*/
canUseEditor: () => boolean;

/**
* Method which returns xy VisualizationTypes array keeping this async as to not impact page load bundle
*/
getXyVisTypes: () => Promise<VisualizationType[]>;
}

export class LensPlugin {
Expand Down Expand Up @@ -257,6 +262,10 @@ export class LensPlugin {
canUseEditor: () => {
return Boolean(core.application.capabilities.visualize?.show);
},
getXyVisTypes: async () => {
const { visualizationTypes } = await import('./xy_visualization/types');
return visualizationTypes;
},
};
}

Expand Down

0 comments on commit 6d64e53

Please sign in to comment.