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 #59149

Merged
merged 6 commits into from
Mar 4, 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
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ import {

import { DiscoverStartPlugins } from './plugin';
import { SharePluginStart } from '../../../../../plugins/share/public';
import { SavedSearch } from './np_ready/types';
import { DocViewsRegistry } from './np_ready/doc_views/doc_views_registry';
import { ChartsPluginStart } from '../../../../../plugins/charts/public';
import { VisualizationsStart } from '../../../visualizations/public';
import { createSavedSearchesLoader } from '../../../../../plugins/discover/public';
import { createSavedSearchesLoader, SavedSearch } from '../../../../../plugins/discover/public';

export interface DiscoverServices {
addBasePath: (path: string) => string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import {
Embeddable,
} from '../../../../../embeddable_api/public/np_ready/public';
import * as columnActions from '../angular/doc_table/actions/columns';
import { SavedSearch } from '../types';
import searchTemplate from './search_template.html';
import { ISearchEmbeddable, SearchInput, SearchOutput } from './types';
import { SortOrder } from '../angular/doc_table/components/table_header/helpers';
Expand All @@ -51,6 +50,7 @@ import {
ISearchSource,
} from '../../kibana_services';
import { SEARCH_EMBEDDABLE_TYPE } from './constants';
import { SavedSearch } from '../../../../../../../plugins/discover/public';

interface SearchScope extends ng.IScope {
columns?: string[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
*/

import { EmbeddableInput, EmbeddableOutput, IEmbeddable } from 'src/plugins/embeddable/public';
import { SavedSearch } from '../types';
import { SortOrder } from '../angular/doc_table/components/table_header/helpers';
import { Filter, IIndexPattern, TimeRange, Query } from '../../../../../../../plugins/data/public';
import { SavedSearch } from '../../../../../../../plugins/discover/public';

export interface SearchInput extends EmbeddableInput {
timeRange: TimeRange;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import { DefaultEditorControls } from './controls';
import { setStateParamValue, useEditorReducer, useEditorFormState, discardChanges } from './state';
import { DefaultEditorAggCommonProps } from '../agg_common_props';
import { SidebarTitle } from './sidebar_title';
import { SavedSearch } from '../../../../kibana/public/discover/np_ready/types';
import { PersistedState } from '../../../../../../plugins/visualizations/public';
import { SavedSearch } from '../../../../../../plugins/discover/public';

interface DefaultEditorSideBarProps {
isCollapsed: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';

import { Vis } from 'src/legacy/core_plugins/visualizations/public';
import { SavedSearch } from '../../../../kibana/public/discover/np_ready/types';
import { SavedSearch } from '../../../../../../plugins/discover/public';

interface LinkedSearchProps {
savedSearch: SavedSearch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,5 @@
* under the License.
*/

// @ts-ignore
export { defaultFeedbackMessage } from 'ui/vis/default_feedback_message';
// @ts-ignore
export { timezoneProvider } from 'ui/vis/lib/timezone';
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
*/

import { i18n } from '@kbn/i18n';
import { defaultFeedbackMessage } from './legacy_imports';

// @ts-ignore
import { metricsRequestHandler } from './request_handler';
// @ts-ignore
import { EditorController } from './editor_controller';
// @ts-ignore
import { PANEL_TYPES } from '../../../../plugins/vis_type_timeseries/common/panel_types';
import { defaultFeedbackMessage } from '../../visualizations/public';

export const metricsVisDefinition = {
name: 'metrics',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
* under the License.
*/

// @ts-ignore
export { defaultFeedbackMessage } from 'ui/vis/default_feedback_message';
// @ts-ignore
export { KibanaMapLayer } from 'ui/vis/map/kibana_map_layer';
// @ts-ignore
Expand Down
3 changes: 1 addition & 2 deletions src/legacy/core_plugins/vis_type_vega/public/vega_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

import { i18n } from '@kbn/i18n';
// @ts-ignore
import { defaultFeedbackMessage } from './legacy_imports';
import { Status } from '../../visualizations/public';
import { Status, defaultFeedbackMessage } from '../../visualizations/public';
import { DefaultEditorSize } from '../../vis_default_editor/public';
import { VegaVisualizationDependencies } from './plugin';
import { VegaVisEditor } from './components';
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/visualizations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const visualizations: LegacyPluginInitializer = kibana =>
new kibana.Plugin({
id: 'visualizations',
publicDir: resolve(__dirname, 'public'),
require: ['vis_default_editor'],
require: [],
uiExports: {
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
},
Expand Down
9 changes: 0 additions & 9 deletions src/legacy/core_plugins/visualizations/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@
* under the License.
*/

/**
* Static legacy code which hasn't been moved to this plugin yet, but
* should be eventually.
*
* @public
*/
// @ts-ignore Used only by tsvb, vega, input control vis
export { defaultFeedbackMessage } from 'ui/vis/default_feedback_message';

/**
* Static np-ready code, re-exported here so consumers can import from
* `src/legacy/core_plugins/visualizations/public`
Expand Down
21 changes: 0 additions & 21 deletions src/legacy/core_plugins/visualizations/public/legacy_mocks.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"version": "kibana",
"server": false,
"ui": true,
"requiredPlugins": ["data", "search", "expressions", "uiActions"]
"requiredPlugins": ["data", "expressions", "uiActions", "embeddable", "usageCollection"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,4 @@ export { buildPipeline, buildVislibDimensions, SchemaConfig } from './legacy/bui
export { updateOldState } from './legacy/vis_update_state';
export { calculateObjectHash } from './legacy/calculate_object_hash';
export { createSavedVisLoader } from './saved_visualizations/saved_visualizations';
export { defaultFeedbackMessage } from './misc/default_feedback_message';
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

/* eslint-disable @kbn/eslint/no-restricted-paths */
import { npSetup, npStart } from 'ui/new_platform';
import { start as legacyDataStart } from '../../../../data/public/legacy';
/* eslint-enable @kbn/eslint/no-restricted-paths */

import { PluginInitializerContext } from '../../../../../../core/public';
Expand All @@ -28,4 +29,9 @@ import { plugin } from '.';
const pluginInstance = plugin({} as PluginInitializerContext);

export const setup = pluginInstance.setup(npSetup.core, npSetup.plugins);
export const start = pluginInstance.start(npStart.core, npStart.plugins);
export const start = pluginInstance.start(npStart.core, {
...npStart.plugins,
__LEGACY: {
aggs: legacyDataStart.search.aggs,
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ import {
Schemas,
} from './build_pipeline';
import { Vis } from '..';
import { IAggConfig } from '../../../legacy_imports';
import { searchSourceMock } from '../../../legacy_mocks';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { searchSourceMock } from '../../../../../../../plugins/data/public/search/search_source/mocks';
import { IAggConfig } from '../../../../../data/public';

jest.mock('ui/new_platform');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import { cloneDeep, get } from 'lodash';
import moment from 'moment';
import { SerializedFieldFormat } from '../../../../../../../plugins/expressions/public';
import { fieldFormats, ISearchSource } from '../../../../../../../plugins/data/public';
import { IAggConfig, setBounds, isDateHistogramBucketAggConfig } from '../../../legacy_imports';
import { Vis, VisParams } from '../types';
import { IAggConfig, isDateHistogramBucketAggConfig, setBounds } from '../../../../../data/public';
Copy link
Contributor Author

@Dosant Dosant Mar 3, 2020

Choose a reason for hiding this comment

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

setBounds is not static, but I decided to leave it as, because it is properly addressed by #58805


interface SchemaConfigParams {
precision?: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
* under the License.
*/

export {
IAggConfig,
IAggConfigs,
isDateHistogramBucketAggConfig,
setBounds,
} from '../../data/public';
export { createAggConfigs } from 'ui/agg_types';
export { createSavedSearchesLoader } from '../../../../plugins/discover/public';
import { defaultFeedbackMessage } from './default_feedback_message';

test('default feedback message with link', () => {
expect(defaultFeedbackMessage).toMatchInlineSnapshot(
`"Have feedback? Please create an issue in <a href=\\"https://github.com/elastic/kibana/issues/new/choose\\" rel=\\"noopener noreferrer\\" target=\\"_blank\\">GitHub</a>."`
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import { i18n } from '@kbn/i18n';

export const defaultFeedbackMessage = i18n.translate('common.ui.vis.defaultFeedbackMessage', {
export const defaultFeedbackMessage = i18n.translate('visualizations.defaultFeedbackMessage', {
defaultMessage: 'Have feedback? Please create an issue in {link}.',
values: {
link:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@
* under the License.
*/

jest.mock('ui/vis/vis_filters');
jest.mock('ui/vis/default_feedback_message');
jest.mock('ui/vis/vis_factory');
jest.mock('ui/registry/vis_types');
jest.mock('./types/vis_type_alias_registry');

import { PluginInitializerContext } from '../../../../../../core/public';
import { VisualizationsSetup, VisualizationsStart } from './';
import { VisualizationsPlugin } from './plugin';
Expand Down Expand Up @@ -67,6 +61,11 @@ const createInstance = async () => {
data: dataPluginMock.createStartContract(),
expressions: expressionsPluginMock.createStartContract(),
uiActions: uiActionsPluginMock.createStartContract(),
__LEGACY: {
aggs: {
createAggConfigs: jest.fn(),
} as any,
},
});

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
setUiActions,
setSavedVisualizationsLoader,
setTimeFilter,
setAggs,
} from './services';
import { VISUALIZE_EMBEDDABLE_TYPE, VisualizeEmbeddableFactory } from './embeddable';
import { ExpressionsSetup, ExpressionsStart } from '../../../../../../plugins/expressions/public';
Expand All @@ -53,6 +54,7 @@ import { createSavedVisLoader, SavedVisualizationsLoader } from './saved_visuali
import { VisImpl, VisImplConstructor } from './vis_impl';
import { showNewVisModal } from './wizard';
import { UiActionsStart } from '../../../../../../plugins/ui_actions/public';
import { DataStart as LegacyDataStart } from '../../../../data/public';

/**
* Interface for this plugin's returned setup/start contracts.
Expand Down Expand Up @@ -81,6 +83,9 @@ export interface VisualizationsStartDeps {
data: DataPublicPluginStart;
expressions: ExpressionsStart;
uiActions: UiActionsStart;
__LEGACY: {
aggs: LegacyDataStart['search']['aggs'];
};
}

/**
Expand Down Expand Up @@ -123,7 +128,7 @@ export class VisualizationsPlugin

public start(
core: CoreStart,
{ data, expressions, uiActions }: VisualizationsStartDeps
{ data, expressions, uiActions, __LEGACY: { aggs } }: VisualizationsStartDeps
): VisualizationsStart {
const types = this.types.start();
setI18n(core.i18n);
Expand All @@ -136,6 +141,7 @@ export class VisualizationsPlugin
setExpressions(expressions);
setUiActions(uiActions);
setTimeFilter(data.query.timefilter.timefilter);
setAggs(aggs);
const savedVisualizationsLoader = createSavedVisLoader({
savedObjectsClient: core.savedObjects.client,
indexPatterns: data.indexPatterns,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { UsageCollectionSetup } from '../../../../../../plugins/usage_collection
import { ExpressionsStart } from '../../../../../../plugins/expressions/public';
import { UiActionsStart } from '../../../../../../plugins/ui_actions/public';
import { SavedVisualizationsLoader } from './saved_visualizations';
import { DataStart as LegacyDataStart } from '../../../../data/public';

export const [getUISettings, setUISettings] = createGetterSetter<IUiSettingsClient>('UISettings');

Expand Down Expand Up @@ -71,3 +72,7 @@ export const [getUiActions, setUiActions] = createGetterSetter<UiActionsStart>('
export const [getSavedVisualizationsLoader, setSavedVisualizationsLoader] = createGetterSetter<
SavedVisualizationsLoader
>('SavedVisualisationsLoader');

export const [getAggs, setAggs] = createGetterSetter<LegacyDataStart['search']['aggs']>(
'AggConfigs'
);
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { SavedObject } from '../../../../../../plugins/saved_objects/public';
import { Vis, VisState, VisParams, VisualizationController } from './vis';
import { ISearchSource } from '../../../../../../plugins/data/public/';
import { SavedSearch } from '../../../../kibana/public/discover/np_ready/types';
import { SavedSearch } from '../../../../../../plugins/discover/public';

export { Vis, VisState, VisParams, VisualizationController };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/

import { VisType } from './vis_types';
import { IAggConfigs } from '../../legacy_imports';
import { Status } from './legacy/update_status';
import { IAggConfigs } from '../../../../data/public';

export interface Vis {
type: VisType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@
import { EventEmitter } from 'events';
import _ from 'lodash';
import { PersistedState } from '../../../../../../../src/plugins/visualizations/public';
import { createAggConfigs } from '../../legacy_imports';
import { updateVisualizationConfig } from './legacy/vis_update';
import { getTypes } from './services';
import { getTypes, getAggs } from './services';

class VisImpl extends EventEmitter {
constructor(indexPattern, visState) {
Expand Down Expand Up @@ -83,7 +82,7 @@ class VisImpl extends EventEmitter {
updateVisualizationConfig(state.params, this.params);

if (state.aggs || !this.aggs) {
this.aggs = createAggConfigs(
this.aggs = getAggs().createAggConfigs(
this.indexPattern,
state.aggs ? state.aggs.aggs || state.aggs : [],
this.type.schemas.all
Expand Down Expand Up @@ -125,7 +124,7 @@ class VisImpl extends EventEmitter {

copyCurrentState(includeDisabled = false) {
const state = this.getCurrentState(includeDisabled);
state.aggs = createAggConfigs(
state.aggs = getAggs().createAggConfigs(
this.indexPattern,
state.aggs.aggs || state.aggs,
this.type.schemas.all
Expand Down
1 change: 1 addition & 0 deletions src/plugins/discover/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
*/

export { createSavedSearchesLoader } from './saved_searches/saved_searches';
export { SavedSearchLoader, SavedSearch } from './saved_searches/types';
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
* under the License.
*/

import { ISearchSource } from '../kibana_services';
import { SortOrder } from './angular/doc_table/components/table_header/helpers';
import { ISearchSource } from '../../../data/public';

export type SortOrder = [string, string];
export interface SavedSearch {
readonly id: string;
title: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import React, { createContext, useContext, FC } from 'react';

import { IUiSettingsClient } from 'kibana/public';

import { SavedSearch } from '../../../../../../../../src/legacy/core_plugins/kibana/public/discover/np_ready/types';
import {
IndexPattern,
IndexPatternsContract,
} from '../../../../../../../../src/plugins/data/public';
import { SavedSearch } from '../../../../../../../../src/plugins/discover/public/';

interface UninitializedKibanaContextValue {
initialized: false;
Expand Down
Loading