diff --git a/src/dev/run_find_plugins_with_circular_deps.ts b/src/dev/run_find_plugins_with_circular_deps.ts index 75faf3d8c17a7..fc599ad738dfa 100644 --- a/src/dev/run_find_plugins_with_circular_deps.ts +++ b/src/dev/run_find_plugins_with_circular_deps.ts @@ -31,7 +31,6 @@ interface Options { type CircularDepList = Set; 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', diff --git a/src/plugins/vis_default_editor/public/default_editor.tsx b/src/plugins/vis_default_editor/public/default_editor.tsx index a7251acfdf75d..719766544d4f2 100644 --- a/src/plugins/vis_default_editor/public/default_editor.tsx +++ b/src/plugins/vis_default_editor/public/default_editor.tsx @@ -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'; diff --git a/src/plugins/vis_default_editor/public/default_editor_controller.tsx b/src/plugins/vis_default_editor/public/default_editor_controller.tsx index f44ea3e203b05..ebeb056cc89c1 100644 --- a/src/plugins/vis_default_editor/public/default_editor_controller.tsx +++ b/src/plugins/vis_default_editor/public/default_editor_controller.tsx @@ -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')); diff --git a/src/plugins/visualizations/public/index.ts b/src/plugins/visualizations/public/index.ts index 854e04325b078..ad56f6a34c368 100644 --- a/src/plugins/visualizations/public/index.ts +++ b/src/plugins/visualizations/public/index.ts @@ -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; diff --git a/src/plugins/visualizations/public/vis_types/index.ts b/src/plugins/visualizations/public/vis_types/index.ts index 43de5d1ecce53..68c613f11f8df 100644 --- a/src/plugins/visualizations/public/vis_types/index.ts +++ b/src/plugins/visualizations/public/vis_types/index.ts @@ -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'; diff --git a/src/plugins/visualizations/public/vis_types/types.ts b/src/plugins/visualizations/public/vis_types/types.ts index 88a4dad106897..c51c2415af041 100644 --- a/src/plugins/visualizations/public/vis_types/types.ts +++ b/src/plugins/visualizations/public/vis_types/types.ts @@ -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; @@ -152,3 +163,29 @@ export interface VisType { readonly editorConfig: Record; readonly visConfig: Record; } + +export type VisEditorConstructor = new ( + element: HTMLElement, + vis: Vis, + eventEmitter: EventEmitter, + embeddableHandler: VisualizeEmbeddableContract +) => IEditorController; + +export interface IEditorController { + render(props: EditorRenderProps): Promise | 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; +} diff --git a/src/plugins/visualize/public/application/types.ts b/src/plugins/visualize/public/application/types.ts index 1729d273e24bc..78727492ac012 100644 --- a/src/plugins/visualize/public/application/types.ts +++ b/src/plugins/visualize/public/application/types.ts @@ -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, @@ -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'; @@ -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; @@ -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; - destroy(): void; -} diff --git a/src/plugins/visualize/public/application/utils/use/use_editor_updates.test.ts b/src/plugins/visualize/public/application/utils/use/use_editor_updates.test.ts index 23894368d606c..c9ffc8c27a978 100644 --- a/src/plugins/visualize/public/application/utils/use/use_editor_updates.test.ts +++ b/src/plugins/visualize/public/application/utils/use/use_editor_updates.test.ts @@ -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'; diff --git a/src/plugins/visualize/public/application/utils/use/use_editor_updates.ts b/src/plugins/visualize/public/application/utils/use/use_editor_updates.ts index c29f6337a6246..1edb5564b48a7 100644 --- a/src/plugins/visualize/public/application/utils/use/use_editor_updates.ts +++ b/src/plugins/visualize/public/application/utils/use/use_editor_updates.ts @@ -25,9 +25,9 @@ import { VisualizeServices, VisualizeAppState, VisualizeAppStateContainer, - IEditorController, VisualizeEditorVisInstance, } from '../../types'; +import type { IEditorController } from '../../../../../visualizations/public'; export const useEditorUpdates = ( services: VisualizeServices, diff --git a/src/plugins/visualize/public/application/utils/use/use_saved_vis_instance.ts b/src/plugins/visualize/public/application/utils/use/use_saved_vis_instance.ts index 3f9b3ca9b8b73..a8d17a3cdfadb 100644 --- a/src/plugins/visualize/public/application/utils/use/use_saved_vis_instance.ts +++ b/src/plugins/visualize/public/application/utils/use/use_saved_vis_instance.ts @@ -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 diff --git a/src/plugins/visualize/public/application/utils/use/use_vis_byvalue.ts b/src/plugins/visualize/public/application/utils/use/use_vis_byvalue.ts index 9e222d208f460..6c9a464d64a72 100644 --- a/src/plugins/visualize/public/application/utils/use/use_vis_byvalue.ts +++ b/src/plugins/visualize/public/application/utils/use/use_vis_byvalue.ts @@ -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'; diff --git a/src/plugins/visualize/public/index.ts b/src/plugins/visualize/public/index.ts index c9ac85c5123ce..385313f81ff68 100644 --- a/src/plugins/visualize/public/index.ts +++ b/src/plugins/visualize/public/index.ts @@ -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 }; diff --git a/src/plugins/visualize/public/plugin.ts b/src/plugins/visualize/public/plugin.ts index 5eef58a336eab..b1507155316e2 100644 --- a/src/plugins/visualize/public/plugin.ts +++ b/src/plugins/visualize/public/plugin.ts @@ -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'; diff --git a/src/plugins/visualize/public/services.ts b/src/plugins/visualize/public/services.ts index 7994ad14543d5..5a8ac00430fbf 100644 --- a/src/plugins/visualize/public/services.ts +++ b/src/plugins/visualize/public/services.ts @@ -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('UISettings');