Skip to content

Commit

Permalink
Remove src/plugins/vis_default_editor -> src/plugins/visualizations c…
Browse files Browse the repository at this point in the history
…yclic dependencies (#86988) (#87804)

* Remove src/plugins/vis_default_editor -> src/plugins/visualizations cyclic dependencies

Part of #86758

* Update agg_common_props.ts

* Schemas -> visualizations

* fix JEST

* make Schemas class private for visualizations plugin

* fix type error

* fix markdown app in visualize app

* remove visualizations from kibana.json's

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
alexwizp and kibanamachine authored Jan 11, 2021
1 parent 6ccb14e commit 7e15ecf
Show file tree
Hide file tree
Showing 39 changed files with 195 additions and 174 deletions.
1 change: 0 additions & 1 deletion src/dev/run_find_plugins_with_circular_deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ interface Options {
type CircularDepList = Set<string>;

const allowedList: CircularDepList = new Set([
'src/plugins/vis_default_editor -> src/plugins/visualizations',
'src/plugins/visualizations -> src/plugins/visualize',
'x-pack/plugins/actions -> x-pack/plugins/case',
'x-pack/plugins/case -> x-pack/plugins/security_solution',
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/region_map/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"requiredBundles": [
"kibanaUtils",
"charts",
"charts",
"visDefaultEditor"
]
}
5 changes: 2 additions & 3 deletions src/plugins/region_map/public/region_map_type.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { mapToLayerWithId } from './util';
import { createRegionMapVisualization } from './region_map_visualization';
import { RegionMapOptions } from './components/region_map_options';
import { truncatedColorSchemas } from '../../charts/public';
import { Schemas } from '../../vis_default_editor/public';
import { ORIGIN } from '../../maps_legacy/public';
import { getDeprecationMessage } from './get_deprecation_message';

Expand Down Expand Up @@ -64,7 +63,7 @@ provided base maps, or add your own. Darker colors represent higher values.',
vectorLayers: [],
tmsLayers: [],
},
schemas: new Schemas([
schemas: [
{
group: 'metrics',
name: 'metric',
Expand Down Expand Up @@ -98,7 +97,7 @@ provided base maps, or add your own. Darker colors represent higher values.',
max: 1,
aggFilter: ['terms'],
},
]),
],
},
setup: async (vis) => {
const serviceSettings = await getServiceSettings();
Expand Down
5 changes: 2 additions & 3 deletions src/plugins/tile_map/public/tile_map_type.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import React from 'react';
import { i18n } from '@kbn/i18n';
import { convertToGeoJson, MapTypes } from '../../maps_legacy/public';
import { Schemas } from '../../vis_default_editor/public';
import { createTileMapVisualization } from './tile_map_visualization';
import { TileMapOptions } from './components/tile_map_options';
import { supportsCssFilters } from './css_filters';
Expand Down Expand Up @@ -115,7 +114,7 @@ export function createTileMapTypeDefinition(dependencies) {
tmsLayers: [],
},
optionsTemplate: (props) => <TileMapOptions {...props} />,
schemas: new Schemas([
schemas: [
{
group: 'metrics',
name: 'metric',
Expand All @@ -137,7 +136,7 @@ export function createTileMapTypeDefinition(dependencies) {
min: 1,
max: 1,
},
]),
],
},
setup: async (vis) => {
let tmsLayers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import { mount, shallow } from 'enzyme';
import { act } from 'react-dom/test-utils';

import { IndexPattern, IAggType, AggGroupNames } from 'src/plugins/data/public';
import type { Schema } from '../../../visualizations/public';

import { DefaultEditorAgg, DefaultEditorAggProps } from './agg';
import { DefaultEditorAggParams } from './agg_params';
import { AGGS_ACTION_KEYS } from './agg_group_state';
import { Schema } from '../schemas';
import { EditorVisState } from './sidebar/state/reducers';

jest.mock('./agg_params', () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
import { IAggConfig, AggGroupNames } from '../../../data/public';
import { Schema } from '../schemas';
import type { Schema } from '../../../visualizations/public';

interface DefaultEditorAggAddProps {
group?: IAggConfig[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
* under the License.
*/

import { VisParams } from 'src/plugins/visualizations/public';
import { IAggType, IAggConfig, AggGroupName } from 'src/plugins/data/public';
import { Schema } from '../schemas';
import { EditorVisState } from './sidebar/state/reducers';
import type { VisParams, Schema } from 'src/plugins/visualizations/public';
import type { IAggType, IAggConfig, AggGroupName } from 'src/plugins/data/public';

import type { EditorVisState } from './sidebar/state/reducers';

type AggId = IAggConfig['id'];
type AggParams = IAggConfig['params'];
Expand Down
33 changes: 20 additions & 13 deletions src/plugins/vis_default_editor/public/components/agg_group.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,28 @@
import React from 'react';
import { mount, shallow } from 'enzyme';
import { act } from 'react-dom/test-utils';
import { IAggConfigs, IAggConfig } from 'src/plugins/data/public';
import type { IAggConfigs, IAggConfig } from 'src/plugins/data/public';
import { ISchemas } from 'src/plugins/visualizations/public';
import { createMockedVisEditorSchemas } from 'src/plugins/visualizations/public/mocks';

import { DefaultEditorAggGroup, DefaultEditorAggGroupProps } from './agg_group';
import { DefaultEditorAgg } from './agg';
import { DefaultEditorAggAdd } from './agg_add';
import { ISchemas, Schemas } from '../schemas';
import { EditorVisState } from './sidebar/state/reducers';

jest.mock('@elastic/eui', () => ({
EuiTitle: 'eui-title',
EuiDragDropContext: 'eui-drag-drop-context',
EuiDroppable: 'eui-droppable',
EuiDraggable: (props: any) => props.children({ dragHandleProps: {} }),
EuiSpacer: 'eui-spacer',
EuiPanel: 'eui-panel',
}));
import type { EditorVisState } from './sidebar/state/reducers';

jest.mock('@elastic/eui', () => {
const original = jest.requireActual('@elastic/eui');

return {
...original,
EuiTitle: 'eui-title',
EuiDragDropContext: 'eui-drag-drop-context',
EuiDroppable: 'eui-droppable',
EuiDraggable: (props: any) => props.children({ dragHandleProps: {} }),
EuiSpacer: 'eui-spacer',
EuiPanel: 'eui-panel',
};
});

jest.mock('./agg', () => ({
DefaultEditorAgg: () => <div />,
Expand All @@ -56,7 +63,7 @@ describe('DefaultEditorAgg component', () => {
setTouched = jest.fn();
setValidity = jest.fn();
reorderAggs = jest.fn();
schemas = new Schemas([
schemas = createMockedVisEditorSchemas([
{
name: 'metrics',
group: 'metrics',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
import { i18n } from '@kbn/i18n';

import { AggGroupNames, AggGroupLabels, IAggConfig, TimeRange } from '../../../data/public';
import type { Schema } from '../../../visualizations/public';
import { DefaultEditorAgg } from './agg';
import { DefaultEditorAggAdd } from './agg_add';
import { AddSchema, ReorderAggs, DefaultEditorAggCommonProps } from './agg_common_props';
Expand All @@ -41,7 +42,6 @@ import {
getEnabledMetricAggsCount,
} from './agg_group_helper';
import { aggGroupReducer, initAggsState, AGGS_ACTION_KEYS } from './agg_group_state';
import { Schema } from '../schemas';

export interface DefaultEditorAggGroupProps extends DefaultEditorAggCommonProps {
schemas: Schema[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
* under the License.
*/

import { IAggConfig } from 'src/plugins/data/public';
import type { IAggConfig } from 'src/plugins/data/public';
import type { Schema } from 'src/plugins/visualizations/public';

import {
isAggRemovable,
calcAggIsTooLow,
isInvalidAggsTouched,
getEnabledMetricAggsCount,
} from './agg_group_helper';
import { AggsState } from './agg_group_state';
import { Schema } from '../schemas';

describe('DefaultEditorGroup helpers', () => {
let group: IAggConfig[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
*/

import { findIndex, isEmpty } from 'lodash';
import { IAggConfig } from 'src/plugins/data/public';
import { AggsState } from './agg_group_state';
import { Schema, getSchemaByName } from '../schemas';
import type { IAggConfig } from 'src/plugins/data/public';
import type { Schema } from 'src/plugins/visualizations/public';

import { getSchemaByName } from '../schemas';
import type { AggsState } from './agg_group_state';

const isAggRemovable = (agg: IAggConfig, group: IAggConfig[], schemas: Schema[]) => {
const schema = getSchemaByName(schemas, agg.schema);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import {
IndexPatternField,
OptionedValueProp,
} from 'src/plugins/data/public';
import type { Schema } from 'src/plugins/visualizations/public';
import { ComboBoxGroupedOptions } from '../utils';
import { EditorConfig } from './utils';
import { Schema } from '../schemas';
import { EditorVisState } from './sidebar/state/reducers';

// NOTE: we cannot export the interface with export { InterfaceName }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { i18n } from '@kbn/i18n';
import useUnmount from 'react-use/lib/useUnmount';

import { IAggConfig, IndexPattern, AggGroupNames } from '../../../data/public';
import type { Schema } from '../../../visualizations/public';

import { DefaultEditorAggSelect } from './agg_select';
import { DefaultEditorAggParam } from './agg_param';
Expand All @@ -39,7 +40,7 @@ import {
} from './agg_params_state';
import { DefaultEditorCommonProps } from './agg_common_props';
import { EditorParamConfig, TimeIntervalParam, FixedParam, getEditorConfig } from './utils';
import { Schema, getSchemaByName } from '../schemas';
import { getSchemaByName } from '../schemas';
import { useKibana } from '../../../kibana_react/public';
import { VisDefaultEditorKibanaServices } from '../types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ import {
IAggType,
IndexPattern,
} from 'src/plugins/data/public';
import type { Schema } from 'src/plugins/visualizations/public';

import {
getAggParamsToRender,
getAggTypeOptions,
isInvalidParamsTouched,
} from './agg_params_helper';
import { FieldParamEditor, OrderByParamEditor } from './controls';
import { EditorConfig } from './utils';
import { Schema } from '../schemas';
import { EditorVisState } from './sidebar/state/reducers';
import { groupAndSortBy } from '../utils';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ import {
IndexPattern,
IndexPatternField,
} from '../../../data/public';
import type { Schema } from '../../../visualizations/public';

import { filterAggTypes, filterAggTypeFields } from '../agg_filters';
import { groupAndSortBy, ComboBoxGroupedOptions } from '../utils';
import { AggTypeState, AggParamsState } from './agg_params_state';
import { AggParamEditorProps } from './agg_param_props';
import { aggParamsMap } from './agg_params_map';
import { EditorConfig } from './utils';
import { Schema, getSchemaByName } from '../schemas';
import { getSchemaByName } from '../schemas';
import { EditorVisState } from './sidebar/state/reducers';

interface ParamInstanceBase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
search,
TimeRange,
} from '../../../../data/public';
import type { ISchemas } from '../../../../visualizations/public';
import { DefaultEditorAggGroup } from '../agg_group';
import {
EditorAction,
Expand All @@ -38,9 +39,8 @@ import {
changeAggType,
toggleEnabledAgg,
} from './state';
import { AddSchema, ReorderAggs, DefaultEditorAggCommonProps } from '../agg_common_props';
import { ISchemas } from '../../schemas';
import { EditorVisState } from './state/reducers';
import type { AddSchema, ReorderAggs, DefaultEditorAggCommonProps } from '../agg_common_props';
import type { EditorVisState } from './state/reducers';

export interface DefaultEditorDataTabProps {
dispatch: React.Dispatch<EditorAction>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ import {
PersistedState,
VisualizeEmbeddableContract,
} from 'src/plugins/visualizations/public';
import type { Schema } from 'src/plugins/visualizations/public';
import { TimeRange } from 'src/plugins/data/public';
import { SavedObject } from 'src/plugins/saved_objects/public';
import { DefaultEditorNavBar } from './navbar';
import { DefaultEditorControls } from './controls';
import { setStateParamValue, useEditorReducer, useEditorFormState, discardChanges } from './state';
import { DefaultEditorAggCommonProps } from '../agg_common_props';
import { SidebarTitle } from './sidebar_title';
import { Schema } from '../../schemas';
import { useOptionTabs } from './use_option_tabs';

interface DefaultEditorSideBarProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
* under the License.
*/

import { Vis, VisParams } from 'src/plugins/visualizations/public';
import { IAggConfig } from 'src/plugins/data/public';
import { Vis, VisParams, Schema } from 'src/plugins/visualizations/public';
import type { IAggConfig } from 'src/plugins/data/public';

import { EditorStateActionTypes } from './constants';
import { Schema } from '../../../schemas';

export interface ActionType<T, P> {
type: T;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export interface OptionTab {
export const useOptionTabs = ({ type: visType }: Vis): [OptionTab[], (name: string) => void] => {
const [optionTabs, setOptionTabs] = useState<OptionTab[]>(() => {
const tabs = [
...(visType.schemas.buckets || visType.schemas.metrics
...(visType.schemas.buckets?.length || visType.schemas.metrics?.length
? [
{
name: 'data',
Expand Down
1 change: 0 additions & 1 deletion src/plugins/vis_default_editor/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export { RangesParamEditor, RangeValues } from './components/controls/ranges';
export * from './editor_size';
export * from './vis_options_props';
export * from './utils';
export { ISchemas, Schemas, Schema } from './schemas';

export const plugin = (context: PluginInitializerContext) => {
return new VisDefaultEditorPlugin();
Expand Down
Loading

0 comments on commit 7e15ecf

Please sign in to comment.