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

visualizations plugin np_ready #57983

Merged
merged 27 commits into from
Feb 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions src/legacy/core_plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export * from '../common';
export { FilterStateManager } from './filter/filter_manager';
export {
// agg_types TODO need to group these under a namespace or prefix
AggConfigs,
AggParamType,
AggTypeFilters, // TODO convert to interface
aggTypeFilters,
Expand All @@ -66,6 +67,7 @@ export {
convertIPRangeToString,
intervalOptions, // only used in Discover
isDateHistogramBucketAggConfig,
setBounds,
isStringType,
isType,
isValidInterval,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { VisualizationsStart } from '../../../visualizations/public';
import { SavedVisualizations } from './np_ready/types';
import { UsageCollectionSetup } from '../../../../../plugins/usage_collection/public';
import { KibanaLegacyStart } from '../../../../../plugins/kibana_legacy/public';
import { DefaultEditorController } from '../../../vis_default_editor/public';

export interface VisualizeKibanaServices {
pluginInitializerContext: PluginInitializerContext;
Expand All @@ -60,6 +61,7 @@ export interface VisualizeKibanaServices {
usageCollection?: UsageCollectionSetup;
I18nContext: I18nStart['Context'];
setActiveUrl: (newUrl: string) => void;
DefaultVisualizationEditor: typeof DefaultEditorController;
lizozom marked this conversation as resolved.
Show resolved Hide resolved
}

let services: VisualizeKibanaServices | null = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ export { absoluteToParsedUrl } from 'ui/url/absolute_to_parsed_url';
export { KibanaParsedUrl } from 'ui/url/kibana_parsed_url';
export { wrapInI18nContext } from 'ui/i18n';
export { DashboardConstants } from '../dashboard/np_ready/dashboard_constants';
export { VisSavedObject } from '../../../visualizations/public/embeddable/visualize_embeddable';
export { VISUALIZE_EMBEDDABLE_TYPE } from '../../../visualizations/public/embeddable';
export { VisSavedObject, VISUALIZE_EMBEDDABLE_TYPE } from '../../../visualizations/public/';
export {
configureAppAngularModule,
ensureDefaultIndexPattern,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function initVisEditorDirective(app, deps) {
appState: '=',
},
link: function($scope, element) {
const Editor = $scope.savedObj.vis.type.editor;
const Editor = $scope.savedObj.vis.type.editor || deps.DefaultVisualizationEditor;
const editor = new Editor(element[0], $scope.savedObj);

$scope.renderFunction = () => {
Expand Down
4 changes: 3 additions & 1 deletion src/legacy/core_plugins/kibana/public/visualize/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import {
HomePublicPluginSetup,
} from '../../../../../plugins/home/public';
import { UsageCollectionSetup } from '../../../../../plugins/usage_collection/public';
import { DefaultEditorController } from '../../../vis_default_editor/public';

export interface VisualizePluginStartDependencies {
data: DataPublicPluginStart;
Expand Down Expand Up @@ -139,7 +140,7 @@ export class VisualizePlugin implements Plugin {
localStorage: new Storage(localStorage),
navigation,
savedObjectsClient,
savedVisualizations: visualizations.getSavedVisualizationsLoader(),
savedVisualizations: visualizations.savedVisualizationsLoader,
savedQueryService: dataStart.query.savedQueries,
share,
toastNotifications: coreStart.notifications.toasts,
Expand All @@ -150,6 +151,7 @@ export class VisualizePlugin implements Plugin {
usageCollection,
I18nContext: coreStart.i18n.Context,
setActiveUrl,
DefaultVisualizationEditor: DefaultEditorController,
};
setServices(deps);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
import React, { useEffect, useRef, useState, useCallback } from 'react';

import { EditorRenderProps } from '../../kibana/public/visualize/np_ready/types';
import { VisualizeEmbeddable } from '../../visualizations/public/embeddable';
import { VisualizeEmbeddableFactory } from '../../visualizations/public/embeddable/visualize_embeddable_factory';
import {
VisualizeEmbeddableContract as VisualizeEmbeddable,
VisualizeEmbeddableFactoryContract as VisualizeEmbeddableFactory,
} from '../../visualizations/public/';
import { PanelsContainer, Panel } from '../../../../plugins/kibana_react/public';

import './vis_type_agg_filter';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { i18n } from '@kbn/i18n';
import { I18nProvider } from '@kbn/i18n/react';

import { EditorRenderProps } from 'src/legacy/core_plugins/kibana/public/visualize/np_ready/types';
import { VisSavedObject } from 'src/legacy/core_plugins/visualizations/public/embeddable/visualize_embeddable';
import { VisSavedObject } from 'src/legacy/core_plugins/visualizations/public/';
import { Storage } from '../../../../plugins/kibana_utils/public';
import { KibanaContextProvider } from '../../../../plugins/kibana_react/public';
import { DefaultEditor } from './default_editor';
Expand Down

This file was deleted.

2 changes: 0 additions & 2 deletions src/legacy/core_plugins/visualizations/public/index.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
@import 'src/legacy/ui/public/styles/styling_constants';

@import './embeddable/index';
@import './np_ready/public/index';
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,5 @@ export {
IAggConfigs,
isDateHistogramBucketAggConfig,
setBounds,
} from '../../../ui/public/agg_types';
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';
} from '../../data/public';
export { createSavedSearchesLoader } from '../../kibana/public/discover/saved_searches/';
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,5 @@
"version": "kibana",
"server": false,
"ui": true,
"requiredPlugins": [
"data",
"search"
]
"requiredPlugins": ["data", "search", "expressions", "uiActions"]
Copy link
Contributor

@lizozom lizozom Feb 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a search plugin at all?

Copy link
Contributor Author

@Dosant Dosant Feb 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure :D
This will be fixed during cutover anyway. Bunch of plugins are missing here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we remove this one?

}
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
@import 'wizard/index';
@import 'embeddable/index';
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import React from 'react';
import ReactDOM from 'react-dom';
import { Embeddable, EmbeddableOutput } from '../../../../../plugins/embeddable/public';
import { Embeddable, EmbeddableOutput } from '../../../../../../../plugins/embeddable/public';

import { DisabledLabVisualization } from './disabled_lab_visualization';
import { VisualizeInput } from './visualize_embeddable';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
* under the License.
*/

import { VisSavedObject } from './visualize_embeddable';
import { VisSavedObject } from '../types';
import {
indexPatterns,
IIndexPattern,
IndexPatternAttributes,
} from '../../../../../plugins/data/public';
import { getUISettings, getSavedObjects } from '../np_ready/public/services';
} from '../../../../../../../plugins/data/public';
import { getUISettings, getSavedObjects } from '../services';

export async function getIndexPattern(
savedVis: VisSavedObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
*/
export { DisabledLabEmbeddable } from './disabled_lab_embeddable';
export { VisualizeEmbeddable, VisualizeInput } from './visualize_embeddable';
export { VisualizeEmbeddableFactory } from './visualize_embeddable_factory';
export { VISUALIZE_EMBEDDABLE_TYPE } from './constants';
Original file line number Diff line number Diff line change
Expand Up @@ -18,51 +18,39 @@
*/

import _, { get } from 'lodash';
import { PersistedState } from 'ui/persisted_state';
import { Subscription } from 'rxjs';
import * as Rx from 'rxjs';
import { buildPipeline } from 'ui/visualize/loader/pipeline_helpers';
import { npStart } from 'ui/new_platform';
import { IExpressionLoaderParams } from 'src/plugins/expressions/public';
import { EmbeddableVisTriggerContext } from 'src/plugins/embeddable/public';
import { VISUALIZE_EMBEDDABLE_TYPE } from './constants';
import {
IIndexPattern,
TimeRange,
Query,
esFilters,
Filter,
ISearchSource,
TimefilterContract,
} from '../../../../../plugins/data/public';
} from '../../../../../../../plugins/data/public';
import {
EmbeddableInput,
EmbeddableOutput,
Embeddable,
Container,
selectRangeTrigger,
valueClickTrigger,
} from '../../../../../plugins/embeddable/public';
import { dispatchRenderComplete } from '../../../../../plugins/kibana_utils/public';
import { SavedObject } from '../../../../../plugins/saved_objects/public';
import { SavedSearch } from '../../../kibana/public/discover/np_ready/types';
import { Vis } from '../np_ready/public';
EmbeddableVisTriggerContext,
} from '../../../../../../../plugins/embeddable/public';
import { dispatchRenderComplete } from '../../../../../../../plugins/kibana_utils/public';
import {
IExpressionLoaderParams,
ExpressionsStart,
} from '../../../../../../../plugins/expressions/public';
import { buildPipeline } from '../legacy/build_pipeline';
import { Vis } from '../vis';
import { getExpressions, getUiActions } from '../services';
import { PersistedState } from '../../../legacy_imports';
import { VisSavedObject } from '../types';

const getKeys = <T extends {}>(o: T): Array<keyof T> => Object.keys(o) as Array<keyof T>;

export interface VisSavedObject extends SavedObject {
vis: Vis;
description?: string;
searchSource: ISearchSource;
title: string;
uiStateJSON?: string;
destroy: () => void;
savedSearchRefName?: string;
savedSearchId?: string;
savedSearch?: SavedSearch;
visState: any;
}

export interface VisualizeEmbeddableConfiguration {
savedVisualization: VisSavedObject;
indexPatterns?: IIndexPattern[];
Expand Down Expand Up @@ -90,7 +78,7 @@ export interface VisualizeOutput extends EmbeddableOutput {
visTypeName: string;
}

type ExpressionLoader = InstanceType<typeof npStart.plugins.expressions.ExpressionLoader>;
type ExpressionLoader = InstanceType<ExpressionsStart['ExpressionLoader']>;

export class VisualizeEmbeddable extends Embeddable<VisualizeInput, VisualizeOutput> {
private handler?: ExpressionLoader;
Expand Down Expand Up @@ -281,7 +269,8 @@ export class VisualizeEmbeddable extends Embeddable<VisualizeInput, VisualizeOut
domNode.appendChild(div);
this.domNode = div;

this.handler = new npStart.plugins.expressions.ExpressionLoader(this.domNode);
const expressions = getExpressions();
this.handler = new expressions.ExpressionLoader(this.domNode);

this.subscriptions.push(
this.handler.events$.subscribe(async event => {
Expand Down Expand Up @@ -309,7 +298,9 @@ export class VisualizeEmbeddable extends Embeddable<VisualizeInput, VisualizeOut
timeFieldName: this.vis.indexPattern.timeFieldName,
data: event.data,
};
npStart.plugins.uiActions.getTrigger(triggerId).exec(context);
getUiActions()
.getTrigger(triggerId)
.exec(context);
}
})
);
Expand Down
Loading