making visualization expression function and renderer np_ready (#51966)
This commit is contained in:
parent
5c19c82d4a
commit
3b8398fb1f
|
@ -27,4 +27,6 @@ export {
|
|||
} from '../../../ui/public/agg_types/buckets/date_histogram';
|
||||
export { createFormat } from '../../../ui/public/visualize/loader/pipeline_helpers/utilities';
|
||||
export { I18nContext } from '../../../ui/public/i18n';
|
||||
import chrome from '../../../ui/public/chrome';
|
||||
export { chrome as legacyChrome };
|
||||
import '../../../ui/public/directives/bind';
|
||||
|
|
|
@ -29,8 +29,9 @@
|
|||
|
||||
import { EventEmitter } from 'events';
|
||||
import _ from 'lodash';
|
||||
import { PersistedState } from '../../../../ui/public/persisted_state';
|
||||
import { getTypes } from '../np_ready/public/services';
|
||||
import { PersistedState } from '../../../legacy_imports';
|
||||
|
||||
import { getTypes } from '../services';
|
||||
|
||||
export class Vis extends EventEmitter {
|
||||
constructor(visState = { type: 'histogram' }) {
|
|
@ -19,13 +19,10 @@
|
|||
|
||||
import { get } from 'lodash';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import chrome from 'ui/chrome';
|
||||
import { FilterBarQueryFilterProvider } from 'ui/filter_manager/query_filter';
|
||||
import { PersistedState } from 'ui/persisted_state';
|
||||
import { VisResponseValue } from 'src/plugins/visualizations/public';
|
||||
import { ExpressionFunction, Render } from 'src/plugins/expressions/public';
|
||||
import { npStart } from 'ui/new_platform';
|
||||
import { getTypes } from '../np_ready/public/services';
|
||||
import { PersistedState } from '../../../legacy_imports';
|
||||
import { getTypes, getIndexPatterns, getFilterManager } from '../services';
|
||||
|
||||
interface Arguments {
|
||||
index?: string | null;
|
||||
|
@ -90,15 +87,10 @@ export const visualization = (): ExpressionFunctionVisualization => ({
|
|||
},
|
||||
},
|
||||
async fn(context, args, handlers) {
|
||||
const $injector = await chrome.dangerouslyGetActiveInjector();
|
||||
const Private = $injector.get('Private') as any;
|
||||
const indexPatterns = npStart.plugins.data.indexPatterns;
|
||||
const queryFilter = Private(FilterBarQueryFilterProvider);
|
||||
|
||||
const visConfigParams = args.visConfig ? JSON.parse(args.visConfig) : {};
|
||||
const schemas = args.schemas ? JSON.parse(args.schemas) : {};
|
||||
const visType = getTypes().get(args.type || 'histogram') as any;
|
||||
const indexPattern = args.index ? await indexPatterns.get(args.index) : null;
|
||||
const indexPattern = args.index ? await getIndexPatterns().get(args.index) : null;
|
||||
|
||||
const uiStateParams = args.uiState ? JSON.parse(args.uiState) : {};
|
||||
const uiState = new PersistedState(uiStateParams);
|
||||
|
@ -114,7 +106,7 @@ export const visualization = (): ExpressionFunctionVisualization => ({
|
|||
filters: get(context, 'filters', null),
|
||||
uiState,
|
||||
inspectorAdapters: handlers.inspectorAdapters,
|
||||
queryFilter,
|
||||
queryFilter: getFilterManager(),
|
||||
forceFetch: true,
|
||||
});
|
||||
}
|
|
@ -17,12 +17,12 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import chrome from 'ui/chrome';
|
||||
import React from 'react';
|
||||
import { render, unmountComponentAtNode } from 'react-dom';
|
||||
import { legacyChrome } from '../../../legacy_imports';
|
||||
// @ts-ignore
|
||||
import { Vis } from './vis';
|
||||
import { Visualization } from '../np_ready/public/components';
|
||||
import { Visualization } from '../components';
|
||||
|
||||
export const visualization = () => ({
|
||||
name: 'visualization',
|
||||
|
@ -31,7 +31,7 @@ export const visualization = () => ({
|
|||
render: async (domNode: HTMLElement, config: any, handlers: any) => {
|
||||
const { visData, visConfig, params } = config;
|
||||
const visType = config.visType || visConfig.type;
|
||||
const $injector = await chrome.dangerouslyGetActiveInjector();
|
||||
const $injector = await legacyChrome.dangerouslyGetActiveInjector();
|
||||
const $rootScope = $injector.get('$rootScope') as any;
|
||||
|
||||
if (handlers.vis) {
|
|
@ -16,6 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from 'src/core/public';
|
||||
import { TypesService, TypesSetup, TypesStart } from './types';
|
||||
import {
|
||||
|
@ -27,13 +28,14 @@ import {
|
|||
setIndexPatterns,
|
||||
setSavedObjects,
|
||||
setUsageCollector,
|
||||
setFilterManager,
|
||||
} from './services';
|
||||
import { VisualizeEmbeddableFactory } from '../../embeddable/visualize_embeddable_factory';
|
||||
import { VISUALIZE_EMBEDDABLE_TYPE } from '../../embeddable';
|
||||
import { ExpressionsSetup } from '../../../../../../plugins/expressions/public';
|
||||
import { IEmbeddableSetup } from '../../../../../../plugins/embeddable/public';
|
||||
import { visualization as visualizationFunction } from '../../expressions/visualization_function';
|
||||
import { visualization as visualizationRenderer } from '../../expressions/visualization_renderer';
|
||||
import { visualization as visualizationFunction } from './expressions/visualization_function';
|
||||
import { visualization as visualizationRenderer } from './expressions/visualization_renderer';
|
||||
import { DataPublicPluginStart } from '../../../../../../plugins/data/public';
|
||||
import { UsageCollectionSetup } from '../../../../../../plugins/usage_collection/public';
|
||||
/**
|
||||
|
@ -106,6 +108,7 @@ export class VisualizationsPlugin
|
|||
setHttp(core.http);
|
||||
setSavedObjects(core.savedObjects);
|
||||
setIndexPatterns(data.indexPatterns);
|
||||
setFilterManager(data.query.filterManager);
|
||||
|
||||
return {
|
||||
types,
|
||||
|
|
|
@ -26,7 +26,7 @@ import {
|
|||
} from 'src/core/public';
|
||||
import { TypesStart } from './types';
|
||||
import { createGetterSetter } from '../../../../../../plugins/kibana_utils/public';
|
||||
import { IndexPatternsContract } from '../../../../../../plugins/data/public';
|
||||
import { FilterManager, IndexPatternsContract } from '../../../../../../plugins/data/public';
|
||||
import { UsageCollectionSetup } from '../../../../../../plugins/usage_collection/public';
|
||||
|
||||
export const [getUISettings, setUISettings] = createGetterSetter<IUiSettingsClient>('UISettings');
|
||||
|
@ -43,6 +43,10 @@ export const [getTypes, setTypes] = createGetterSetter<TypesStart>('Types');
|
|||
|
||||
export const [getI18n, setI18n] = createGetterSetter<I18nStart>('I18n');
|
||||
|
||||
export const [getFilterManager, setFilterManager] = createGetterSetter<FilterManager>(
|
||||
'FilterManager'
|
||||
);
|
||||
|
||||
export const [getIndexPatterns, setIndexPatterns] = createGetterSetter<IndexPatternsContract>(
|
||||
'IndexPatterns'
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue