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 21 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
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
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/kibana/public/visualize/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,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 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 @@ -25,8 +25,5 @@ export {
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';
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ import {
EmbeddableFactory,
EmbeddableOutput,
ErrorEmbeddable,
} from '../../../../../plugins/embeddable/public';
import { SavedVisualizations } from '../../../kibana/public/visualize/np_ready/types';
} from '../../../../../../../plugins/embeddable/public';
import { DisabledLabEmbeddable } from './disabled_lab_embeddable';
import { getIndexPattern } from './get_index_pattern';
import {
VisSavedObject,
VisualizeEmbeddable,
VisualizeInput,
VisualizeOutput,
} from './visualize_embeddable';
import { VisualizeEmbeddable, VisualizeInput, VisualizeOutput } from './visualize_embeddable';
import { VisSavedObject } from '../types';
import { VISUALIZE_EMBEDDABLE_TYPE } from './constants';

import { getCapabilities, getHttp, getTypes, getUISettings } from '../np_ready/public/services';
import { showNewVisModal } from '../np_ready/public/wizard';
import { TimefilterContract } from '../../../../../plugins/data/public';
import {
getCapabilities,
getHttp,
getTypes,
getUISettings,
getSavedVisualizationsLoader,
getTimeFilter,
} from '../services';
import { showNewVisModal } from '../wizard';

interface VisualizationAttributes extends SavedObjectAttributes {
visState: string;
Expand All @@ -52,10 +52,7 @@ export class VisualizeEmbeddableFactory extends EmbeddableFactory<
> {
public readonly type = VISUALIZE_EMBEDDABLE_TYPE;

constructor(
private timefilter: TimefilterContract,
private getSavedVisualizationsLoader: () => SavedVisualizations
) {
constructor() {
super({
savedObjectMetaData: {
name: i18n.translate('visualizations.savedObjectName', { defaultMessage: 'Visualization' }),
Expand Down Expand Up @@ -101,7 +98,7 @@ export class VisualizeEmbeddableFactory extends EmbeddableFactory<
input: Partial<VisualizeInput> & { id: string },
parent?: Container
): Promise<VisualizeEmbeddable | ErrorEmbeddable | DisabledLabEmbeddable> {
const savedVisualizations = this.getSavedVisualizationsLoader();
const savedVisualizations = getSavedVisualizationsLoader();

try {
const visId = savedObject.id as string;
Expand All @@ -118,7 +115,7 @@ export class VisualizeEmbeddableFactory extends EmbeddableFactory<
const indexPattern = await getIndexPattern(savedObject);
const indexPatterns = indexPattern ? [indexPattern] : [];
return new VisualizeEmbeddable(
this.timefilter,
getTimeFilter(),
{
savedVisualization: savedObject,
indexPatterns,
Expand All @@ -141,7 +138,7 @@ export class VisualizeEmbeddableFactory extends EmbeddableFactory<
input: Partial<VisualizeInput> & { id: string },
parent?: Container
): Promise<VisualizeEmbeddable | ErrorEmbeddable | DisabledLabEmbeddable> {
const savedVisualizations = this.getSavedVisualizationsLoader();
const savedVisualizations = getSavedVisualizationsLoader();

try {
const savedObject = await savedVisualizations.get(savedObjectId);
Expand Down
Loading