Skip to content

Commit

Permalink
making visualization expression function and renderer np_ready (#51966)…
Browse files Browse the repository at this point in the history
… (#55041)
  • Loading branch information
ppisljar authored Jan 16, 2020
1 parent a1b3f73 commit 6a78b56
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Original file line number Diff line number Diff line change
Expand Up @@ -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' }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -114,7 +106,7 @@ export const visualization = (): ExpressionFunctionVisualization => ({
filters: get(context, 'filters', null),
uiState,
inspectorAdapters: handlers.inspectorAdapters,
queryFilter,
queryFilter: getFilterManager(),
forceFetch: true,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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';
/**
Expand Down Expand Up @@ -106,6 +108,7 @@ export class VisualizationsPlugin
setHttp(core.http);
setSavedObjects(core.savedObjects);
setIndexPatterns(data.indexPatterns);
setFilterManager(data.query.filterManager);

return {
types,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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'
);
Expand Down

0 comments on commit 6a78b56

Please sign in to comment.