Skip to content

Commit

Permalink
Remove src/plugins/visualizations -> src/plugins/visualize cyclic dep…
Browse files Browse the repository at this point in the history
…endencies (elastic#87797)

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

Part of elastic#84750

* fix types
  • Loading branch information
alexwizp committed Jan 12, 2021
1 parent 2bee289 commit cc2d67d
Show file tree
Hide file tree
Showing 14 changed files with 73 additions and 55 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/visualizations -> src/plugins/visualize',
'x-pack/plugins/actions -> x-pack/plugins/case',
'x-pack/plugins/case -> x-pack/plugins/security_solution',
'x-pack/plugins/apm -> x-pack/plugins/infra',
Expand Down
7 changes: 5 additions & 2 deletions src/plugins/vis_default_editor/public/default_editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ import 'brace/mode/json';
import React, { useEffect, useRef, useState, useCallback } from 'react';
import { EventEmitter } from 'events';

import { EditorRenderProps } from 'src/plugins/visualize/public';
import { Vis, VisualizeEmbeddableContract } from 'src/plugins/visualizations/public';
import {
Vis,
VisualizeEmbeddableContract,
EditorRenderProps,
} from 'src/plugins/visualizations/public';
import { KibanaContextProvider, PanelsContainer, Panel } from '../../kibana_react/public';
import { Storage } from '../../kibana_utils/public';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ import { render, unmountComponentAtNode } from 'react-dom';
import { EventEmitter } from 'events';
import { EuiErrorBoundary, EuiLoadingChart } from '@elastic/eui';

import { EditorRenderProps, IEditorController } from 'src/plugins/visualize/public';
import { Vis, VisualizeEmbeddableContract } from 'src/plugins/visualizations/public';
import {
Vis,
IEditorController,
EditorRenderProps,
VisualizeEmbeddableContract,
} from 'src/plugins/visualizations/public';

// @ts-ignore
const DefaultEditor = lazy(() => import('./default_editor'));
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/visualizations/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export type {
ReactVisTypeOptions,
Schema,
ISchemas,
VisEditorConstructor,
IEditorController,
EditorRenderProps,
} from './vis_types';
export { VisParams, SerializedVis, SerializedVisData, VisData } from './vis';
export type VisualizeEmbeddableFactoryContract = PublicContract<VisualizeEmbeddableFactory>;
Expand Down
9 changes: 8 additions & 1 deletion src/plugins/visualizations/public/vis_types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
export * from './types_service';
export { Schemas } from './schemas';
export { VisGroups } from './types';
export type { VisType, ISchemas, Schema } from './types';
export type {
VisType,
ISchemas,
Schema,
IEditorController,
VisEditorConstructor,
EditorRenderProps,
} from './types';
export type { BaseVisTypeOptions } from './base_vis_type';
export type { ReactVisTypeOptions } from './react_vis_type';
43 changes: 40 additions & 3 deletions src/plugins/visualizations/public/vis_types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,24 @@
* specific language governing permissions and limitations
* under the License.
*/

import { EventEmitter } from 'events';
import { IconType } from '@elastic/eui';
import React, { ReactNode } from 'react';
import { Adapters } from 'src/plugins/inspector';
import { VisEditorConstructor } from 'src/plugins/visualize/public';
import { IndexPattern, AggGroupNames, AggParam, AggGroupName } from '../../../data/public';
import { CoreStart } from 'src/core/public';
import { SavedObject } from 'src/plugins/saved_objects/public';
import {
IndexPattern,
AggGroupNames,
AggParam,
AggGroupName,
DataPublicPluginStart,
Filter,
TimeRange,
Query,
} from '../../../data/public';
import { Vis, VisParams, VisToExpressionAst, VisualizationControllerConstructor } from '../types';
import { PersistedState, VisualizeEmbeddableContract } from '../index';

export interface VisTypeOptions {
showTimePicker: boolean;
Expand Down Expand Up @@ -152,3 +163,29 @@ export interface VisType<TVisParams = unknown> {
readonly editorConfig: Record<string, any>;
readonly visConfig: Record<string, any>;
}

export type VisEditorConstructor = new (
element: HTMLElement,
vis: Vis,
eventEmitter: EventEmitter,
embeddableHandler: VisualizeEmbeddableContract
) => IEditorController;

export interface IEditorController {
render(props: EditorRenderProps): Promise<void> | void;
destroy(): void;
}

export interface EditorRenderProps {
core: CoreStart;
data: DataPublicPluginStart;
filters: Filter[];
timeRange: TimeRange;
query?: Query;
savedSearch?: SavedObject;
uiState: PersistedState;
/**
* Flag to determine if visualiztion is linked to the saved search
*/
linked: boolean;
}
30 changes: 1 addition & 29 deletions src/plugins/visualize/public/application/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
*/

import { History } from 'history';
import { TimeRange, Query, Filter, DataPublicPluginStart } from 'src/plugins/data/public';
import { Query, Filter, DataPublicPluginStart } from 'src/plugins/data/public';
import {
PersistedState,
SavedVisState,
VisualizationsStart,
Vis,
Expand All @@ -45,7 +44,6 @@ import { SharePluginStart } from 'src/plugins/share/public';
import { SavedObjectsStart, SavedObject } from 'src/plugins/saved_objects/public';
import { EmbeddableStart, EmbeddableStateTransfer } from 'src/plugins/embeddable/public';
import { UrlForwardingStart } from 'src/plugins/url_forwarding/public';
import { EventEmitter } from 'events';
import { DashboardStart } from '../../../dashboard/public';
import type { SavedObjectsTaggingApi } from '../../../saved_objects_tagging_oss/public';

Expand Down Expand Up @@ -80,20 +78,6 @@ export type VisualizeAppStateContainer = ReduxLikeStateContainer<
VisualizeAppStateTransitions
>;

export interface EditorRenderProps {
core: CoreStart;
data: DataPublicPluginStart;
filters: Filter[];
timeRange: TimeRange;
query?: Query;
savedSearch?: SavedObject;
uiState: PersistedState;
/**
* Flag to determine if visualiztion is linked to the saved search
*/
linked: boolean;
}

export interface VisualizeServices extends CoreStart {
stateTransferService: EmbeddableStateTransfer;
embeddable: EmbeddableStart;
Expand Down Expand Up @@ -135,15 +119,3 @@ export interface ByValueVisInstance {
}

export type VisualizeEditorVisInstance = SavedVisInstance | ByValueVisInstance;

export type VisEditorConstructor = new (
element: HTMLElement,
vis: Vis,
eventEmitter: EventEmitter,
embeddableHandler: VisualizeEmbeddableContract
) => IEditorController;

export interface IEditorController {
render(props: EditorRenderProps): Promise<void> | void;
destroy(): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@ import { renderHook, act } from '@testing-library/react-hooks';
import { EventEmitter } from 'events';

import { useEditorUpdates } from './use_editor_updates';
import {
VisualizeServices,
VisualizeAppStateContainer,
SavedVisInstance,
IEditorController,
} from '../../types';
import { VisualizeServices, VisualizeAppStateContainer, SavedVisInstance } from '../../types';
import type { IEditorController } from '../../../../../visualizations/public';
import { visualizeAppStateStub } from '../stubs';
import { createVisualizeServicesMock } from '../mocks';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import {
VisualizeServices,
VisualizeAppState,
VisualizeAppStateContainer,
IEditorController,
VisualizeEditorVisInstance,
} from '../../types';
import type { IEditorController } from '../../../../../visualizations/public';

export const useEditorUpdates = (
services: VisualizeServices,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ import { redirectWhenMissing } from '../../../../../kibana_utils/public';

import { getVisualizationInstance } from '../get_visualization_instance';
import { getEditBreadcrumbs, getCreateBreadcrumbs } from '../breadcrumbs';
import { SavedVisInstance, IEditorController, VisualizeServices } from '../../types';
import { SavedVisInstance, VisualizeServices } from '../../types';
import { VisualizeConstants } from '../../visualize_constants';
import { getDefaultEditor } from '../../../services';
import type { IEditorController } from '../../../../../visualizations/public';

/**
* This effect is responsible for instantiating a saved vis or creating a new one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import { EventEmitter } from 'events';
import { useEffect, useRef, useState } from 'react';
import { VisualizeInput } from 'src/plugins/visualizations/public';
import { ByValueVisInstance, IEditorController, VisualizeServices } from '../../types';
import { ByValueVisInstance, VisualizeServices } from '../../types';
import type { IEditorController } from '../../../../../visualizations/public';
import { getVisualizationInstanceFromInput } from '../get_visualization_instance';
import { getEditBreadcrumbs } from '../breadcrumbs';
import { getDefaultEditor } from '../../../services';
Expand Down
5 changes: 0 additions & 5 deletions src/plugins/visualize/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@
import { PluginInitializerContext } from 'kibana/public';
import { VisualizePlugin, VisualizePluginSetup } from './plugin';

export type {
EditorRenderProps,
IEditorController,
VisEditorConstructor,
} from './application/types';
export { VisualizeConstants } from './application/visualize_constants';

export { VisualizePluginSetup };
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/visualize/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ import { DataPublicPluginStart, DataPublicPluginSetup, esFilters } from '../../d
import { NavigationPublicPluginStart as NavigationStart } from '../../navigation/public';
import { SharePluginStart, SharePluginSetup } from '../../share/public';
import { UrlForwardingSetup, UrlForwardingStart } from '../../url_forwarding/public';
import { VisualizationsStart } from '../../visualizations/public';
import { VisualizationsStart, VisEditorConstructor } from '../../visualizations/public';
import { VisualizeConstants } from './application/visualize_constants';
import { FeatureCatalogueCategory, HomePublicPluginSetup } from '../../home/public';
import { VisEditorConstructor, VisualizeServices } from './application/types';
import { VisualizeServices } from './application/types';
import { DEFAULT_APP_CATEGORIES } from '../../../core/public';
import { SavedObjectsStart } from '../../saved_objects/public';
import { EmbeddableStart } from '../../embeddable/public';
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/visualize/public/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import { ApplicationStart, IUiSettingsClient } from '../../../core/public';
import { createGetterSetter } from '../../../plugins/kibana_utils/public';
import { IndexPatternsContract, DataPublicPluginStart } from '../../../plugins/data/public';
import { VisEditorConstructor } from '../../../plugins/visualizations/public';
import { SharePluginStart } from '../../../plugins/share/public';
import { VisEditorConstructor } from './application/types';

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

Expand Down

0 comments on commit cc2d67d

Please sign in to comment.