From bd2361d2a40a6329b8c024cef72068cbeac07078 Mon Sep 17 00:00:00 2001 From: Dima Arnautov Date: Thu, 4 Aug 2022 11:02:02 +0200 Subject: [PATCH 1/8] [ML] Fix the Dashboard saving indicator with Anomaly Swim Lane embeddable (#137989) --- .../anomaly_swimlane_embeddable.tsx | 4 +++ .../anomaly_swimlane_initializer.tsx | 30 +++++++++---------- .../anomaly_swimlane_setup_flyout.tsx | 7 ++--- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_embeddable.tsx b/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_embeddable.tsx index bb239868aed77..639136b169471 100644 --- a/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_embeddable.tsx +++ b/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_embeddable.tsx @@ -53,6 +53,10 @@ export class AnomalySwimlaneEmbeddable extends Embeddable< ); } + public reportsEmbeddableLoad() { + return true; + } + public onLoading() { this.renderComplete.dispatchInProgress(); this.updateOutput({ loading: true, error: undefined }); diff --git a/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_initializer.tsx b/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_initializer.tsx index 4fc43fc640b98..e5e2c2fd3b6be 100644 --- a/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_initializer.tsx +++ b/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_initializer.tsx @@ -25,17 +25,19 @@ import { i18n } from '@kbn/i18n'; import { SWIMLANE_TYPE, SwimlaneType } from '../../application/explorer/explorer_constants'; import { AnomalySwimlaneEmbeddableInput } from '..'; +interface ExplicitInput { + panelTitle: string; + swimlaneType: SwimlaneType; + viewBy?: string; +} + export interface AnomalySwimlaneInitializerProps { defaultTitle: string; influencers: string[]; initialInput?: Partial< Pick >; - onCreate: (swimlaneProps: { - panelTitle: string; - swimlaneType: SwimlaneType; - viewBy?: string; - }) => void; + onCreate: (swimlaneProps: ExplicitInput) => void; onCancel: () => void; } @@ -47,7 +49,7 @@ export const AnomalySwimlaneInitializer: FC = ( initialInput, }) => { const [panelTitle, setPanelTitle] = useState(defaultTitle); - const [swimlaneType, setSwimlaneType] = useState( + const [swimlaneType, setSwimlaneType] = useState( initialInput?.swimlaneType ?? SWIMLANE_TYPE.OVERALL ); const [viewBySwimlaneFieldName, setViewBySwimlaneFieldName] = useState(initialInput?.viewBy); @@ -81,6 +83,12 @@ export const AnomalySwimlaneInitializer: FC = ( (swimlaneType === SWIMLANE_TYPE.OVERALL || (swimlaneType === SWIMLANE_TYPE.VIEW_BY && !!viewBySwimlaneFieldName)); + const resultInput = { + panelTitle, + swimlaneType, + ...(viewBySwimlaneFieldName ? { viewBy: viewBySwimlaneFieldName } : {}), + }; + return ( @@ -162,15 +170,7 @@ export const AnomalySwimlaneInitializer: FC = ( /> - + { + onCreate={(explicitInput) => { modalSession.close(); resolve({ jobIds, - title: panelTitle, - swimlaneType, - viewBy, + title: explicitInput.panelTitle, + ...explicitInput, }); }} onCancel={() => { From 6325eb8af972d0737ef734510594f5175661b83f Mon Sep 17 00:00:00 2001 From: Stratoula Kalafateli Date: Thu, 4 Aug 2022 13:34:04 +0300 Subject: [PATCH 2/8] [Lens] Move visualizations under the visualizations folder (#137950) * [Lens] Move visualizations under the visualizations folder * Move datatable visualization --- x-pack/plugins/lens/public/async_services.ts | 20 ++++++++-------- .../embeddable/embeddable_component.tsx | 6 ++--- x-pack/plugins/lens/public/index.ts | 6 ++--- .../lens/public/mocks/lens_plugin_mock.tsx | 2 +- x-pack/plugins/lens/public/plugin.ts | 12 +++++----- .../shared_components/axis_title_settings.tsx | 2 +- x-pack/plugins/lens/public/types.ts | 4 ++-- .../__snapshots__/table_basic.test.tsx.snap | 0 .../datatable}/components/cell_value.test.tsx | 2 +- .../datatable}/components/cell_value.tsx | 8 +++---- .../datatable}/components/columns.tsx | 4 ++-- .../datatable}/components/constants.ts | 0 .../components/dimension_editor.scss | 0 .../components/dimension_editor.test.tsx | 8 +++---- .../components/dimension_editor.tsx | 8 +++---- ...mension_editor_additional_section.test.tsx | 6 ++--- .../dimension_editor_addtional_section.tsx | 8 +++---- .../components/row_height_settings.tsx | 0 .../components/table_actions.test.ts | 2 +- .../datatable}/components/table_actions.ts | 4 ++-- .../datatable}/components/table_basic.scss | 0 .../components/table_basic.test.tsx | 6 ++--- .../datatable}/components/table_basic.tsx | 14 +++++------ .../datatable}/components/toolbar.test.tsx | 4 ++-- .../datatable}/components/toolbar.tsx | 4 ++-- .../datatable}/components/types.ts | 6 ++--- .../datatable}/datatable_visualization.ts | 0 .../datatable}/expression.test.tsx | 6 ++--- .../datatable}/expression.tsx | 8 +++---- .../datatable}/index.ts | 8 ++++--- .../datatable}/visualization.test.tsx | 6 ++--- .../datatable}/visualization.tsx | 10 ++++---- .../heatmap}/constants.ts | 0 .../heatmap}/dimension_editor.scss | 0 .../heatmap}/dimension_editor.tsx | 4 ++-- .../heatmap}/heatmap_visualization.ts | 0 .../heatmap}/index.ts | 4 ++-- .../heatmap}/suggestions.test.ts | 2 +- .../heatmap}/suggestions.ts | 4 ++-- .../heatmap}/toolbar_component.scss | 0 .../heatmap}/toolbar_component.tsx | 10 ++++---- .../heatmap}/types.ts | 2 +- .../heatmap}/utils.ts | 2 +- .../heatmap}/visualization.test.ts | 6 ++--- .../heatmap}/visualization.tsx | 4 ++-- .../legacy_metric}/dimension_editor.scss | 0 .../legacy_metric}/dimension_editor.test.tsx | 10 ++++---- .../legacy_metric}/dimension_editor.tsx | 8 +++---- .../legacy_metric}/index.ts | 4 ++-- .../metric_config_panel/align_options.tsx | 2 +- .../appearance_options_popover.tsx | 6 ++--- .../metric_config_panel/index.tsx | 4 ++-- .../metric_config_panel/size_options.tsx | 2 +- .../text_formatting_options.tsx | 2 +- .../title_position_option.tsx | 2 +- .../legacy_metric}/metric_suggestions.test.ts | 2 +- .../legacy_metric}/metric_suggestions.ts | 8 +++---- .../legacy_metric}/metric_visualization.ts | 0 .../legacy_metric}/palette_config.tsx | 2 +- .../legacy_metric}/visualization.test.ts | 12 +++++----- .../legacy_metric}/visualization.tsx | 8 +++---- .../partition}/constants.ts | 0 .../partition}/index.ts | 4 ++-- .../partition}/partition_charts_meta.ts | 19 +++++++++------ .../partition}/pie_visualization.ts | 0 .../partition}/render_helpers.test.ts | 2 +- .../partition}/render_helpers.ts | 2 +- .../partition}/suggestions.test.ts | 6 ++--- .../partition}/suggestions.ts | 10 +++++--- .../partition}/to_expression.ts | 6 ++--- .../partition}/toolbar.scss | 0 .../partition}/toolbar.tsx | 8 +++---- .../partition}/visualization.test.ts | 10 ++++---- .../partition}/visualization.tsx | 6 ++--- .../__snapshots__/to_expression.test.ts.snap | 0 .../xy}/annotations/helpers.test.ts | 2 +- .../xy}/annotations/helpers.tsx | 8 +++---- .../xy}/axes_configuration.test.ts | 2 +- .../xy}/axes_configuration.ts | 4 ++-- .../xy}/color_assignment.test.ts | 4 ++-- .../xy}/color_assignment.ts | 4 ++-- .../xy}/index.ts | 8 +++---- .../xy}/reference_line_helpers.test.ts | 2 +- .../xy}/reference_line_helpers.tsx | 8 +++---- .../xy}/state_helpers.ts | 2 +- .../xy}/to_expression.test.ts | 6 ++--- .../xy}/to_expression.ts | 8 +++---- .../xy}/types.ts | 24 +++++++++---------- .../xy}/visualization.test.ts | 8 +++---- .../xy}/visualization.tsx | 8 +++---- .../xy}/visualization_helpers.tsx | 12 +++++----- .../annotations_panel.tsx | 10 +++++--- .../annotations_config_panel/icon_set.ts | 2 +- .../annotations_config_panel/index.scss | 0 .../annotations_config_panel/index.test.tsx | 6 ++--- .../annotations_config_panel/index.tsx | 0 .../axis_settings_popover.scss | 0 .../axis_settings_popover.test.tsx | 4 ++-- .../xy_config_panel/axis_settings_popover.tsx | 10 ++++---- .../xy}/xy_config_panel/color_picker.tsx | 2 +- .../xy}/xy_config_panel/dimension_editor.tsx | 8 +++---- .../xy}/xy_config_panel/index.tsx | 10 ++++---- .../xy}/xy_config_panel/layer_header.tsx | 8 +++---- .../reference_line_config_panel/icon_set.ts | 0 .../reference_line_config_panel/index.tsx | 0 .../reference_line_panel.tsx | 6 ++--- .../xy_config_panel/shared/icon_select.tsx | 0 .../shared/line_style_settings.tsx | 0 .../shared/marker_decoration_settings.tsx | 2 +- .../end_value_definitions.ts | 0 .../fill_opacity_option.test.tsx | 0 .../fill_opacity_option.tsx | 2 +- .../fitting_function_definitions.ts | 0 .../visual_options_popover/index.tsx | 4 ++-- .../line_curve_option.test.tsx | 0 .../line_curve_option.tsx | 0 .../missing_value_option.test.tsx | 0 .../missing_values_option.tsx | 0 .../visual_options_popover.test.tsx | 8 +++---- .../xy_config_panel/xy_config_panel.test.tsx | 6 ++--- .../xy}/xy_suggestions.test.ts | 8 +++---- .../xy}/xy_suggestions.ts | 4 ++-- .../xy}/xy_visualization.ts | 0 123 files changed, 291 insertions(+), 276 deletions(-) rename x-pack/plugins/lens/public/{datatable_visualization => visualizations/datatable}/components/__snapshots__/table_basic.test.tsx.snap (100%) rename x-pack/plugins/lens/public/{datatable_visualization => visualizations/datatable}/components/cell_value.test.tsx (98%) rename x-pack/plugins/lens/public/{datatable_visualization => visualizations/datatable}/components/cell_value.tsx (91%) rename x-pack/plugins/lens/public/{datatable_visualization => visualizations/datatable}/components/columns.tsx (98%) rename x-pack/plugins/lens/public/{datatable_visualization => visualizations/datatable}/components/constants.ts (100%) rename x-pack/plugins/lens/public/{datatable_visualization => visualizations/datatable}/components/dimension_editor.scss (100%) rename x-pack/plugins/lens/public/{datatable_visualization => visualizations/datatable}/components/dimension_editor.test.tsx (97%) rename x-pack/plugins/lens/public/{datatable_visualization => visualizations/datatable}/components/dimension_editor.tsx (98%) rename x-pack/plugins/lens/public/{datatable_visualization => visualizations/datatable}/components/dimension_editor_additional_section.test.tsx (97%) rename x-pack/plugins/lens/public/{datatable_visualization => visualizations/datatable}/components/dimension_editor_addtional_section.tsx (95%) rename x-pack/plugins/lens/public/{datatable_visualization => visualizations/datatable}/components/row_height_settings.tsx (100%) rename x-pack/plugins/lens/public/{datatable_visualization => visualizations/datatable}/components/table_actions.test.ts (99%) rename x-pack/plugins/lens/public/{datatable_visualization => visualizations/datatable}/components/table_actions.ts (96%) rename x-pack/plugins/lens/public/{datatable_visualization => visualizations/datatable}/components/table_basic.scss (100%) rename x-pack/plugins/lens/public/{datatable_visualization => visualizations/datatable}/components/table_basic.test.tsx (99%) rename x-pack/plugins/lens/public/{datatable_visualization => visualizations/datatable}/components/table_basic.tsx (96%) rename x-pack/plugins/lens/public/{datatable_visualization => visualizations/datatable}/components/toolbar.test.tsx (98%) rename x-pack/plugins/lens/public/{datatable_visualization => visualizations/datatable}/components/toolbar.tsx (96%) rename x-pack/plugins/lens/public/{datatable_visualization => visualizations/datatable}/components/types.ts (95%) rename x-pack/plugins/lens/public/{datatable_visualization => visualizations/datatable}/datatable_visualization.ts (100%) rename x-pack/plugins/lens/public/{datatable_visualization => visualizations/datatable}/expression.test.tsx (92%) rename x-pack/plugins/lens/public/{datatable_visualization => visualizations/datatable}/expression.tsx (92%) rename x-pack/plugins/lens/public/{datatable_visualization => visualizations/datatable}/index.ts (91%) rename x-pack/plugins/lens/public/{datatable_visualization => visualizations/datatable}/visualization.test.tsx (99%) rename x-pack/plugins/lens/public/{datatable_visualization => visualizations/datatable}/visualization.tsx (98%) rename x-pack/plugins/lens/public/{heatmap_visualization => visualizations/heatmap}/constants.ts (100%) rename x-pack/plugins/lens/public/{heatmap_visualization => visualizations/heatmap}/dimension_editor.scss (100%) rename x-pack/plugins/lens/public/{heatmap_visualization => visualizations/heatmap}/dimension_editor.tsx (96%) rename x-pack/plugins/lens/public/{heatmap_visualization => visualizations/heatmap}/heatmap_visualization.ts (100%) rename x-pack/plugins/lens/public/{heatmap_visualization => visualizations/heatmap}/index.ts (86%) rename x-pack/plugins/lens/public/{heatmap_visualization => visualizations/heatmap}/suggestions.test.ts (99%) rename x-pack/plugins/lens/public/{heatmap_visualization => visualizations/heatmap}/suggestions.ts (97%) rename x-pack/plugins/lens/public/{heatmap_visualization => visualizations/heatmap}/toolbar_component.scss (100%) rename x-pack/plugins/lens/public/{heatmap_visualization => visualizations/heatmap}/toolbar_component.tsx (96%) rename x-pack/plugins/lens/public/{heatmap_visualization => visualizations/heatmap}/types.ts (94%) rename x-pack/plugins/lens/public/{heatmap_visualization => visualizations/heatmap}/utils.ts (93%) rename x-pack/plugins/lens/public/{heatmap_visualization => visualizations/heatmap}/visualization.test.ts (99%) rename x-pack/plugins/lens/public/{heatmap_visualization => visualizations/heatmap}/visualization.tsx (99%) rename x-pack/plugins/lens/public/{metric_visualization => visualizations/legacy_metric}/dimension_editor.scss (100%) rename x-pack/plugins/lens/public/{metric_visualization => visualizations/legacy_metric}/dimension_editor.test.tsx (97%) rename x-pack/plugins/lens/public/{metric_visualization => visualizations/legacy_metric}/dimension_editor.tsx (96%) rename x-pack/plugins/lens/public/{metric_visualization => visualizations/legacy_metric}/index.ts (91%) rename x-pack/plugins/lens/public/{metric_visualization => visualizations/legacy_metric}/metric_config_panel/align_options.tsx (96%) rename x-pack/plugins/lens/public/{metric_visualization => visualizations/legacy_metric}/metric_config_panel/appearance_options_popover.tsx (87%) rename x-pack/plugins/lens/public/{metric_visualization => visualizations/legacy_metric}/metric_config_panel/index.tsx (89%) rename x-pack/plugins/lens/public/{metric_visualization => visualizations/legacy_metric}/metric_config_panel/size_options.tsx (97%) rename x-pack/plugins/lens/public/{metric_visualization => visualizations/legacy_metric}/metric_config_panel/text_formatting_options.tsx (95%) rename x-pack/plugins/lens/public/{metric_visualization => visualizations/legacy_metric}/metric_config_panel/title_position_option.tsx (96%) rename x-pack/plugins/lens/public/{metric_visualization => visualizations/legacy_metric}/metric_suggestions.test.ts (98%) rename x-pack/plugins/lens/public/{metric_visualization => visualizations/legacy_metric}/metric_suggestions.ts (89%) rename x-pack/plugins/lens/public/{metric_visualization => visualizations/legacy_metric}/metric_visualization.ts (100%) rename x-pack/plugins/lens/public/{metric_visualization => visualizations/legacy_metric}/palette_config.tsx (96%) rename x-pack/plugins/lens/public/{metric_visualization => visualizations/legacy_metric}/visualization.test.ts (97%) rename x-pack/plugins/lens/public/{metric_visualization => visualizations/legacy_metric}/visualization.tsx (98%) rename x-pack/plugins/lens/public/{pie_visualization => visualizations/partition}/constants.ts (100%) rename x-pack/plugins/lens/public/{pie_visualization => visualizations/partition}/index.ts (88%) rename x-pack/plugins/lens/public/{pie_visualization => visualizations/partition}/partition_charts_meta.ts (91%) rename x-pack/plugins/lens/public/{pie_visualization => visualizations/partition}/pie_visualization.ts (100%) rename x-pack/plugins/lens/public/{pie_visualization => visualizations/partition}/render_helpers.test.ts (97%) rename x-pack/plugins/lens/public/{pie_visualization => visualizations/partition}/render_helpers.ts (93%) rename x-pack/plugins/lens/public/{pie_visualization => visualizations/partition}/suggestions.test.ts (99%) rename x-pack/plugins/lens/public/{pie_visualization => visualizations/partition}/suggestions.ts (98%) rename x-pack/plugins/lens/public/{pie_visualization => visualizations/partition}/to_expression.ts (98%) rename x-pack/plugins/lens/public/{pie_visualization => visualizations/partition}/toolbar.scss (100%) rename x-pack/plugins/lens/public/{pie_visualization => visualizations/partition}/toolbar.tsx (98%) rename x-pack/plugins/lens/public/{pie_visualization => visualizations/partition}/visualization.test.ts (95%) rename x-pack/plugins/lens/public/{pie_visualization => visualizations/partition}/visualization.tsx (99%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/__snapshots__/to_expression.test.ts.snap (100%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/annotations/helpers.test.ts (99%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/annotations/helpers.tsx (98%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/axes_configuration.test.ts (99%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/axes_configuration.ts (98%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/color_assignment.test.ts (98%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/color_assignment.ts (98%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/index.ts (86%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/reference_line_helpers.test.ts (99%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/reference_line_helpers.tsx (98%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/state_helpers.ts (97%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/to_expression.test.ts (99%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/to_expression.ts (98%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/types.ts (88%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/visualization.test.ts (99%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/visualization.tsx (98%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/visualization_helpers.tsx (97%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_config_panel/annotations_config_panel/annotations_panel.tsx (98%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_config_panel/annotations_config_panel/icon_set.ts (97%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_config_panel/annotations_config_panel/index.scss (100%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_config_panel/annotations_config_panel/index.test.tsx (97%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_config_panel/annotations_config_panel/index.tsx (100%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_config_panel/axis_settings_popover.scss (100%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_config_panel/axis_settings_popover.test.tsx (98%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_config_panel/axis_settings_popover.tsx (98%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_config_panel/color_picker.tsx (98%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_config_panel/dimension_editor.tsx (96%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_config_panel/index.tsx (98%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_config_panel/layer_header.tsx (94%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_config_panel/reference_line_config_panel/icon_set.ts (100%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_config_panel/reference_line_config_panel/index.tsx (100%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_config_panel/reference_line_config_panel/reference_line_panel.tsx (97%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_config_panel/shared/icon_select.tsx (100%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_config_panel/shared/line_style_settings.tsx (100%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_config_panel/shared/marker_decoration_settings.tsx (99%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_config_panel/visual_options_popover/end_value_definitions.ts (100%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_config_panel/visual_options_popover/fill_opacity_option.test.tsx (100%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_config_panel/visual_options_popover/fill_opacity_option.tsx (95%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_config_panel/visual_options_popover/fitting_function_definitions.ts (100%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_config_panel/visual_options_popover/index.tsx (97%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_config_panel/visual_options_popover/line_curve_option.test.tsx (100%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_config_panel/visual_options_popover/line_curve_option.tsx (100%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_config_panel/visual_options_popover/missing_value_option.test.tsx (100%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_config_panel/visual_options_popover/missing_values_option.tsx (100%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_config_panel/visual_options_popover/visual_options_popover.test.tsx (97%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_config_panel/xy_config_panel.test.tsx (99%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_suggestions.test.ts (99%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_suggestions.ts (99%) rename x-pack/plugins/lens/public/{xy_visualization => visualizations/xy}/xy_visualization.ts (100%) diff --git a/x-pack/plugins/lens/public/async_services.ts b/x-pack/plugins/lens/public/async_services.ts index cd2a9787c9cef..9025b738c2e1f 100644 --- a/x-pack/plugins/lens/public/async_services.ts +++ b/x-pack/plugins/lens/public/async_services.ts @@ -14,18 +14,18 @@ * This file causes all of them to be served in a single request. */ -export * from './datatable_visualization/datatable_visualization'; -export * from './datatable_visualization'; -export * from './metric_visualization/metric_visualization'; -export * from './metric_visualization'; +export * from './visualizations/datatable/datatable_visualization'; +export * from './visualizations/datatable'; +export * from './visualizations/legacy_metric/metric_visualization'; +export * from './visualizations/legacy_metric'; export * from './visualizations/metric/metric_visualization'; export * from './visualizations/metric'; -export * from './pie_visualization/pie_visualization'; -export * from './pie_visualization'; -export * from './xy_visualization/xy_visualization'; -export * from './xy_visualization'; -export * from './heatmap_visualization/heatmap_visualization'; -export * from './heatmap_visualization'; +export * from './visualizations/partition/pie_visualization'; +export * from './visualizations/partition'; +export * from './visualizations/xy/xy_visualization'; +export * from './visualizations/xy'; +export * from './visualizations/heatmap/heatmap_visualization'; +export * from './visualizations/heatmap'; export * from './visualizations/gauge/gauge_visualization'; export * from './visualizations/gauge'; diff --git a/x-pack/plugins/lens/public/embeddable/embeddable_component.tsx b/x-pack/plugins/lens/public/embeddable/embeddable_component.tsx index 6797ca674a06b..78aae56c5b9ad 100644 --- a/x-pack/plugins/lens/public/embeddable/embeddable_component.tsx +++ b/x-pack/plugins/lens/public/embeddable/embeddable_component.tsx @@ -23,10 +23,10 @@ import { import type { LensByReferenceInput, LensByValueInput } from './embeddable'; import type { Document } from '../persistence'; import type { IndexPatternPersistedState } from '../indexpattern_datasource/types'; -import type { XYState } from '../xy_visualization/types'; +import type { XYState } from '../visualizations/xy/types'; import type { PieVisualizationState, MetricState } from '../../common'; -import type { DatatableVisualizationState } from '../datatable_visualization/visualization'; -import type { HeatmapVisualizationState } from '../heatmap_visualization/types'; +import type { DatatableVisualizationState } from '../visualizations/datatable/visualization'; +import type { HeatmapVisualizationState } from '../visualizations/heatmap/types'; import type { GaugeVisualizationState } from '../visualizations/gauge/constants'; type LensAttributes = Omit< diff --git a/x-pack/plugins/lens/public/index.ts b/x-pack/plugins/lens/public/index.ts index f0dae2ca28409..82e510dbb6393 100644 --- a/x-pack/plugins/lens/public/index.ts +++ b/x-pack/plugins/lens/public/index.ts @@ -21,7 +21,7 @@ export type { YAxisMode, SeriesType, YConfig, -} from './xy_visualization/types'; +} from './visualizations/xy/types'; export type { DatasourcePublicAPI, DataType, @@ -39,8 +39,8 @@ export type { SharedPieLayerState, } from '../common/types'; -export type { DatatableVisualizationState } from './datatable_visualization/visualization'; -export type { HeatmapVisualizationState } from './heatmap_visualization/types'; +export type { DatatableVisualizationState } from './visualizations/datatable/visualization'; +export type { HeatmapVisualizationState } from './visualizations/heatmap/types'; export type { GaugeVisualizationState } from './visualizations/gauge/constants'; export type { IndexPatternPersistedState, diff --git a/x-pack/plugins/lens/public/mocks/lens_plugin_mock.tsx b/x-pack/plugins/lens/public/mocks/lens_plugin_mock.tsx index 09bf2f065c60c..cbf310cb2f50a 100644 --- a/x-pack/plugins/lens/public/mocks/lens_plugin_mock.tsx +++ b/x-pack/plugins/lens/public/mocks/lens_plugin_mock.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { createFormulaPublicApi } from '../async_services'; import { LensPublicStart } from '..'; -import { visualizationTypes } from '../xy_visualization/types'; +import { visualizationTypes } from '../visualizations/xy/types'; type Start = jest.Mocked; diff --git a/x-pack/plugins/lens/public/plugin.ts b/x-pack/plugins/lens/public/plugin.ts index c66d538ed0511..99585a0fd9a77 100644 --- a/x-pack/plugins/lens/public/plugin.ts +++ b/x-pack/plugins/lens/public/plugin.ts @@ -54,21 +54,21 @@ import type { import type { XyVisualization as XyVisualizationType, XyVisualizationPluginSetupPlugins, -} from './xy_visualization'; +} from './visualizations/xy'; import type { LegacyMetricVisualization as LegacyMetricVisualizationType, LegacyMetricVisualizationPluginSetupPlugins, -} from './metric_visualization'; +} from './visualizations/legacy_metric'; import type { MetricVisualization as MetricVisualizationType } from './visualizations/metric'; import type { DatatableVisualization as DatatableVisualizationType, DatatableVisualizationPluginSetupPlugins, -} from './datatable_visualization'; +} from './visualizations/datatable'; import type { PieVisualization as PieVisualizationType, PieVisualizationPluginSetupPlugins, -} from './pie_visualization'; -import type { HeatmapVisualization as HeatmapVisualizationType } from './heatmap_visualization'; +} from './visualizations/partition'; +import type { HeatmapVisualization as HeatmapVisualizationType } from './visualizations/heatmap'; import type { GaugeVisualization as GaugeVisualizationType } from './visualizations/gauge'; import { APP_ID, getEditPath, NOT_INTERNATIONALIZED_PRODUCT_NAME } from '../common/constants'; @@ -504,7 +504,7 @@ export class LensPlugin { return Boolean(core.application.capabilities.visualize?.show); }, getXyVisTypes: async () => { - const { visualizationTypes } = await import('./xy_visualization/types'); + const { visualizationTypes } = await import('./visualizations/xy/types'); return visualizationTypes; }, diff --git a/x-pack/plugins/lens/public/shared_components/axis_title_settings.tsx b/x-pack/plugins/lens/public/shared_components/axis_title_settings.tsx index 5c1cc704671be..5378859fdc94c 100644 --- a/x-pack/plugins/lens/public/shared_components/axis_title_settings.tsx +++ b/x-pack/plugins/lens/public/shared_components/axis_title_settings.tsx @@ -8,7 +8,7 @@ import React, { useCallback, useMemo } from 'react'; import { EuiSpacer, EuiFormRow } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { AxesSettingsConfig } from '../xy_visualization/types'; +import { AxesSettingsConfig } from '../visualizations/xy/types'; import { LabelMode, useDebouncedValue, VisLabel } from '.'; type AxesSettingsConfigKeys = keyof AxesSettingsConfig; diff --git a/x-pack/plugins/lens/public/types.ts b/x-pack/plugins/lens/public/types.ts index 56492d801d7c8..78f104ce943fb 100644 --- a/x-pack/plugins/lens/public/types.ts +++ b/x-pack/plugins/lens/public/types.ts @@ -32,14 +32,14 @@ import type { LensResizeActionData, LensToggleActionData, LensPagesizeActionData, -} from './datatable_visualization/components/types'; +} from './visualizations/datatable/components/types'; import { LENS_EDIT_SORT_ACTION, LENS_EDIT_RESIZE_ACTION, LENS_TOGGLE_ACTION, LENS_EDIT_PAGESIZE_ACTION, -} from './datatable_visualization/components/constants'; +} from './visualizations/datatable/components/constants'; import type { LensInspector } from './lens_inspector_service'; export type ErrorCallback = (e: { message: string }) => void; diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/__snapshots__/table_basic.test.tsx.snap b/x-pack/plugins/lens/public/visualizations/datatable/components/__snapshots__/table_basic.test.tsx.snap similarity index 100% rename from x-pack/plugins/lens/public/datatable_visualization/components/__snapshots__/table_basic.test.tsx.snap rename to x-pack/plugins/lens/public/visualizations/datatable/components/__snapshots__/table_basic.test.tsx.snap diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/cell_value.test.tsx b/x-pack/plugins/lens/public/visualizations/datatable/components/cell_value.test.tsx similarity index 98% rename from x-pack/plugins/lens/public/datatable_visualization/components/cell_value.test.tsx rename to x-pack/plugins/lens/public/visualizations/datatable/components/cell_value.test.tsx index 94a55a393814c..f6092e3dc299a 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/cell_value.test.tsx +++ b/x-pack/plugins/lens/public/visualizations/datatable/components/cell_value.test.tsx @@ -14,7 +14,7 @@ import { Datatable } from '@kbn/expressions-plugin/public'; import { IUiSettingsClient } from '@kbn/core/public'; import { act } from 'react-dom/test-utils'; import { ReactWrapper } from 'enzyme'; -import { DatatableArgs, ColumnConfigArg } from '../../../common/expressions'; +import { DatatableArgs, ColumnConfigArg } from '../../../../common/expressions'; import { DataContextType } from './types'; import { chartPluginMock } from '@kbn/charts-plugin/public/mocks'; diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/cell_value.tsx b/x-pack/plugins/lens/public/visualizations/datatable/components/cell_value.tsx similarity index 91% rename from x-pack/plugins/lens/public/datatable_visualization/components/cell_value.tsx rename to x-pack/plugins/lens/public/visualizations/datatable/components/cell_value.tsx index e43c08aec6375..4db92a65f9c4d 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/cell_value.tsx +++ b/x-pack/plugins/lens/public/visualizations/datatable/components/cell_value.tsx @@ -9,11 +9,11 @@ import React, { useContext, useEffect } from 'react'; import type { EuiDataGridCellValueElementProps } from '@elastic/eui'; import type { IUiSettingsClient } from '@kbn/core/public'; import classNames from 'classnames'; -import type { FormatFactory } from '../../../common'; -import { getOriginalId } from '../../../common/expressions'; -import type { ColumnConfig } from '../../../common/expressions'; +import type { FormatFactory } from '../../../../common'; +import { getOriginalId } from '../../../../common/expressions'; +import type { ColumnConfig } from '../../../../common/expressions'; import type { DataContextType } from './types'; -import { getContrastColor, getNumericValue } from '../../shared_components/coloring/utils'; +import { getContrastColor, getNumericValue } from '../../../shared_components/coloring/utils'; export const createGridCell = ( formatters: Record>, diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/columns.tsx b/x-pack/plugins/lens/public/visualizations/datatable/components/columns.tsx similarity index 98% rename from x-pack/plugins/lens/public/datatable_visualization/components/columns.tsx rename to x-pack/plugins/lens/public/visualizations/datatable/components/columns.tsx index fd3a0acb2b0fd..81b73b8f267b7 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/columns.tsx +++ b/x-pack/plugins/lens/public/visualizations/datatable/components/columns.tsx @@ -18,8 +18,8 @@ import type { DatatableColumn, DatatableColumnMeta, } from '@kbn/expressions-plugin/common'; -import type { FormatFactory } from '../../../common'; -import type { ColumnConfig } from '../../../common/expressions'; +import type { FormatFactory } from '../../../../common'; +import type { ColumnConfig } from '../../../../common/expressions'; export const createGridColumns = ( bucketColumns: string[], diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/constants.ts b/x-pack/plugins/lens/public/visualizations/datatable/components/constants.ts similarity index 100% rename from x-pack/plugins/lens/public/datatable_visualization/components/constants.ts rename to x-pack/plugins/lens/public/visualizations/datatable/components/constants.ts diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/dimension_editor.scss b/x-pack/plugins/lens/public/visualizations/datatable/components/dimension_editor.scss similarity index 100% rename from x-pack/plugins/lens/public/datatable_visualization/components/dimension_editor.scss rename to x-pack/plugins/lens/public/visualizations/datatable/components/dimension_editor.scss diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/dimension_editor.test.tsx b/x-pack/plugins/lens/public/visualizations/datatable/components/dimension_editor.test.tsx similarity index 97% rename from x-pack/plugins/lens/public/datatable_visualization/components/dimension_editor.test.tsx rename to x-pack/plugins/lens/public/visualizations/datatable/components/dimension_editor.test.tsx index d56c1eee1c522..d182a9151d51c 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/dimension_editor.test.tsx +++ b/x-pack/plugins/lens/public/visualizations/datatable/components/dimension_editor.test.tsx @@ -12,15 +12,15 @@ import { FramePublicAPI, OperationDescriptor, VisualizationDimensionEditorProps, -} from '../../types'; +} from '../../../types'; import { DatatableVisualizationState } from '../visualization'; -import { createMockDatasource, createMockFramePublicAPI } from '../../mocks'; +import { createMockDatasource, createMockFramePublicAPI } from '../../../mocks'; import { mountWithIntl } from '@kbn/test-jest-helpers'; import { TableDimensionEditor } from './dimension_editor'; import { chartPluginMock } from '@kbn/charts-plugin/public/mocks'; import { act } from 'react-dom/test-utils'; -import { PalettePanelContainer } from '../../shared_components'; -import { layerTypes } from '../../../common'; +import { PalettePanelContainer } from '../../../shared_components'; +import { layerTypes } from '../../../../common'; describe('data table dimension editor', () => { let frame: FramePublicAPI; diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/dimension_editor.tsx b/x-pack/plugins/lens/public/visualizations/datatable/components/dimension_editor.tsx similarity index 98% rename from x-pack/plugins/lens/public/datatable_visualization/components/dimension_editor.tsx rename to x-pack/plugins/lens/public/visualizations/datatable/components/dimension_editor.tsx index ff4019e08549e..da1f28ba579f2 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/dimension_editor.tsx +++ b/x-pack/plugins/lens/public/visualizations/datatable/components/dimension_editor.tsx @@ -18,7 +18,7 @@ import { EuiButtonEmpty, } from '@elastic/eui'; import { CustomizablePalette, PaletteRegistry, FIXED_PROGRESSION } from '@kbn/coloring'; -import { VisualizationDimensionEditorProps } from '../../types'; +import { VisualizationDimensionEditorProps } from '../../../types'; import { DatatableVisualizationState } from '../visualization'; import { @@ -26,11 +26,11 @@ import { defaultPaletteParams, PalettePanelContainer, findMinMaxByColumnId, -} from '../../shared_components'; -import { isNumericFieldForDatatable, getOriginalId } from '../../../common/expressions'; +} from '../../../shared_components'; +import { isNumericFieldForDatatable, getOriginalId } from '../../../../common/expressions'; import './dimension_editor.scss'; -import { CollapseSetting } from '../../shared_components/collapse_setting'; +import { CollapseSetting } from '../../../shared_components/collapse_setting'; const idPrefix = htmlIdGenerator()(); diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/dimension_editor_additional_section.test.tsx b/x-pack/plugins/lens/public/visualizations/datatable/components/dimension_editor_additional_section.test.tsx similarity index 97% rename from x-pack/plugins/lens/public/datatable_visualization/components/dimension_editor_additional_section.test.tsx rename to x-pack/plugins/lens/public/visualizations/datatable/components/dimension_editor_additional_section.test.tsx index ddf8468e9929b..859c3867b0cef 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/dimension_editor_additional_section.test.tsx +++ b/x-pack/plugins/lens/public/visualizations/datatable/components/dimension_editor_additional_section.test.tsx @@ -8,13 +8,13 @@ import React from 'react'; import { EuiComboBox, EuiFieldText } from '@elastic/eui'; import type { PaletteRegistry } from '@kbn/coloring'; -import { FramePublicAPI, VisualizationDimensionEditorProps } from '../../types'; +import { FramePublicAPI, VisualizationDimensionEditorProps } from '../../../types'; import { DatatableVisualizationState } from '../visualization'; -import { createMockDatasource, createMockFramePublicAPI } from '../../mocks'; +import { createMockDatasource, createMockFramePublicAPI } from '../../../mocks'; import { mountWithIntl } from '@kbn/test-jest-helpers'; import { TableDimensionEditorAdditionalSection } from './dimension_editor_addtional_section'; import { chartPluginMock } from '@kbn/charts-plugin/public/mocks'; -import { layerTypes } from '../../../common'; +import { layerTypes } from '../../../../common'; describe('data table dimension editor additional section', () => { let frame: FramePublicAPI; diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/dimension_editor_addtional_section.tsx b/x-pack/plugins/lens/public/visualizations/datatable/components/dimension_editor_addtional_section.tsx similarity index 95% rename from x-pack/plugins/lens/public/datatable_visualization/components/dimension_editor_addtional_section.tsx rename to x-pack/plugins/lens/public/visualizations/datatable/components/dimension_editor_addtional_section.tsx index 9105435e7ab3f..c61a512991b62 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/dimension_editor_addtional_section.tsx +++ b/x-pack/plugins/lens/public/visualizations/datatable/components/dimension_editor_addtional_section.tsx @@ -10,17 +10,17 @@ import { i18n } from '@kbn/i18n'; import { css } from '@emotion/react'; import { EuiFormRow, EuiFieldText, EuiText, useEuiTheme, EuiComboBox } from '@elastic/eui'; import { PaletteRegistry } from '@kbn/coloring'; -import { VisualizationDimensionEditorProps } from '../../types'; +import { VisualizationDimensionEditorProps } from '../../../types'; import { DatatableVisualizationState } from '../visualization'; -import { useDebouncedValue } from '../../shared_components'; -import type { ColumnState } from '../../../common/expressions'; +import { useDebouncedValue } from '../../../shared_components'; +import type { ColumnState } from '../../../../common/expressions'; import { isNumericFieldForDatatable, getDefaultSummaryLabel, getFinalSummaryConfiguration, getSummaryRowOptions, -} from '../../../common/expressions'; +} from '../../../../common/expressions'; import './dimension_editor.scss'; diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/row_height_settings.tsx b/x-pack/plugins/lens/public/visualizations/datatable/components/row_height_settings.tsx similarity index 100% rename from x-pack/plugins/lens/public/datatable_visualization/components/row_height_settings.tsx rename to x-pack/plugins/lens/public/visualizations/datatable/components/row_height_settings.tsx diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/table_actions.test.ts b/x-pack/plugins/lens/public/visualizations/datatable/components/table_actions.test.ts similarity index 99% rename from x-pack/plugins/lens/public/datatable_visualization/components/table_actions.test.ts rename to x-pack/plugins/lens/public/visualizations/datatable/components/table_actions.test.ts index 3d3352309c102..760145e06c33a 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/table_actions.test.ts +++ b/x-pack/plugins/lens/public/visualizations/datatable/components/table_actions.test.ts @@ -17,7 +17,7 @@ import { createGridHideHandler, createTransposeColumnFilterHandler, } from './table_actions'; -import { LensGridDirection, ColumnConfig } from '../../../common/expressions'; +import { LensGridDirection, ColumnConfig } from '../../../../common/expressions'; function getDefaultConfig(): ColumnConfig { return { diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/table_actions.ts b/x-pack/plugins/lens/public/visualizations/datatable/components/table_actions.ts similarity index 96% rename from x-pack/plugins/lens/public/datatable_visualization/components/table_actions.ts rename to x-pack/plugins/lens/public/visualizations/datatable/components/table_actions.ts index 5d06584003ae1..b4075ef848989 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/table_actions.ts +++ b/x-pack/plugins/lens/public/visualizations/datatable/components/table_actions.ts @@ -9,8 +9,8 @@ import type { EuiDataGridSorting } from '@elastic/eui'; import type { Datatable, DatatableColumn } from '@kbn/expressions-plugin/common'; import { ClickTriggerEvent } from '@kbn/charts-plugin/public'; import type { LensResizeAction, LensSortAction, LensToggleAction } from './types'; -import type { ColumnConfig, LensGridDirection } from '../../../common/expressions'; -import { getOriginalId } from '../../../common/expressions'; +import type { ColumnConfig, LensGridDirection } from '../../../../common/expressions'; +import { getOriginalId } from '../../../../common/expressions'; export const createGridResizeHandler = ( diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/table_basic.scss b/x-pack/plugins/lens/public/visualizations/datatable/components/table_basic.scss similarity index 100% rename from x-pack/plugins/lens/public/datatable_visualization/components/table_basic.scss rename to x-pack/plugins/lens/public/visualizations/datatable/components/table_basic.scss diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/table_basic.test.tsx b/x-pack/plugins/lens/public/visualizations/datatable/components/table_basic.test.tsx similarity index 99% rename from x-pack/plugins/lens/public/datatable_visualization/components/table_basic.test.tsx rename to x-pack/plugins/lens/public/visualizations/datatable/components/table_basic.test.tsx index 44600b2c03b94..e40b7b0c079ec 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/table_basic.test.tsx +++ b/x-pack/plugins/lens/public/visualizations/datatable/components/table_basic.test.tsx @@ -12,11 +12,11 @@ import { mountWithIntl } from '@kbn/test-jest-helpers'; import { EuiDataGrid } from '@elastic/eui'; import { IAggType } from '@kbn/data-plugin/public'; import { IFieldFormat, SerializedFieldFormat } from '@kbn/field-formats-plugin/common'; -import { VisualizationContainer } from '../../visualization_container'; +import { VisualizationContainer } from '../../../visualization_container'; import { EmptyPlaceholder } from '@kbn/charts-plugin/public'; -import { LensIconChartDatatable } from '../../assets/chart_datatable'; +import { LensIconChartDatatable } from '../../../assets/chart_datatable'; import { DataContext, DatatableComponent } from './table_basic'; -import { DatatableProps } from '../../../common/expressions'; +import { DatatableProps } from '../../../../common/expressions'; import { chartPluginMock } from '@kbn/charts-plugin/public/mocks'; import { IUiSettingsClient } from '@kbn/core/public'; import { Datatable, RenderMode } from '@kbn/expressions-plugin/common'; diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/table_basic.tsx b/x-pack/plugins/lens/public/visualizations/datatable/components/table_basic.tsx similarity index 96% rename from x-pack/plugins/lens/public/datatable_visualization/components/table_basic.tsx rename to x-pack/plugins/lens/public/visualizations/datatable/components/table_basic.tsx index 97d14bed8d06c..0262d3d7cab40 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/table_basic.tsx +++ b/x-pack/plugins/lens/public/visualizations/datatable/components/table_basic.tsx @@ -29,12 +29,12 @@ import { } from '@elastic/eui'; import { EmptyPlaceholder } from '@kbn/charts-plugin/public'; import { ClickTriggerEvent } from '@kbn/charts-plugin/public'; -import type { LensTableRowContextMenuEvent } from '../../types'; -import type { FormatFactory } from '../../../common'; -import type { LensGridDirection } from '../../../common/expressions'; -import { VisualizationContainer } from '../../visualization_container'; -import { findMinMaxByColumnId } from '../../shared_components'; -import { LensIconChartDatatable } from '../../assets/chart_datatable'; +import type { LensTableRowContextMenuEvent } from '../../../types'; +import type { FormatFactory } from '../../../../common'; +import type { LensGridDirection } from '../../../../common/expressions'; +import { VisualizationContainer } from '../../../visualization_container'; +import { findMinMaxByColumnId } from '../../../shared_components'; +import { LensIconChartDatatable } from '../../../assets/chart_datatable'; import type { DataContextType, DatatableRenderProps, @@ -52,7 +52,7 @@ import { createGridSortingConfig, createTransposeColumnFilterHandler, } from './table_actions'; -import { getOriginalId, getFinalSummaryConfiguration } from '../../../common/expressions'; +import { getOriginalId, getFinalSummaryConfiguration } from '../../../../common/expressions'; export const DataContext = React.createContext({}); diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/toolbar.test.tsx b/x-pack/plugins/lens/public/visualizations/datatable/components/toolbar.test.tsx similarity index 98% rename from x-pack/plugins/lens/public/datatable_visualization/components/toolbar.test.tsx rename to x-pack/plugins/lens/public/visualizations/datatable/components/toolbar.test.tsx index 6c69b855dd65a..281c4ef9c86a5 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/toolbar.test.tsx +++ b/x-pack/plugins/lens/public/visualizations/datatable/components/toolbar.test.tsx @@ -9,10 +9,10 @@ import React, { ChangeEvent, FormEvent } from 'react'; import { mountWithIntl } from '@kbn/test-jest-helpers'; import { DataTableToolbar } from './toolbar'; import { DatatableVisualizationState } from '../visualization'; -import { FramePublicAPI, VisualizationToolbarProps } from '../../types'; +import { FramePublicAPI, VisualizationToolbarProps } from '../../../types'; import { ToolbarButton } from '@kbn/kibana-react-plugin/public'; import { ReactWrapper } from 'enzyme'; -import { PagingState } from '../../../common/expressions'; +import { PagingState } from '../../../../common/expressions'; import { EuiButtonGroup, EuiRange } from '@elastic/eui'; // mocking random id generator function diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/toolbar.tsx b/x-pack/plugins/lens/public/visualizations/datatable/components/toolbar.tsx similarity index 96% rename from x-pack/plugins/lens/public/datatable_visualization/components/toolbar.tsx rename to x-pack/plugins/lens/public/visualizations/datatable/components/toolbar.tsx index 656f8efcc09ee..fee76d99593fd 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/toolbar.tsx +++ b/x-pack/plugins/lens/public/visualizations/datatable/components/toolbar.tsx @@ -8,8 +8,8 @@ import React, { useCallback } from 'react'; import { i18n } from '@kbn/i18n'; import { EuiFlexGroup, EuiFormRow, EuiSwitch, EuiToolTip } from '@elastic/eui'; -import { ToolbarPopover } from '../../shared_components'; -import type { VisualizationToolbarProps } from '../../types'; +import { ToolbarPopover } from '../../../shared_components'; +import type { VisualizationToolbarProps } from '../../../types'; import type { DatatableVisualizationState } from '../visualization'; import { RowHeightSettings } from './row_height_settings'; import { DEFAULT_PAGE_SIZE } from './table_basic'; diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/types.ts b/x-pack/plugins/lens/public/visualizations/datatable/components/types.ts similarity index 95% rename from x-pack/plugins/lens/public/datatable_visualization/components/types.ts rename to x-pack/plugins/lens/public/visualizations/datatable/components/types.ts index c6a1560ce4675..3338e9da8f4ae 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/types.ts +++ b/x-pack/plugins/lens/public/visualizations/datatable/components/types.ts @@ -10,15 +10,15 @@ import type { PaletteRegistry } from '@kbn/coloring'; import { CustomPaletteState } from '@kbn/charts-plugin/public'; import type { IAggType } from '@kbn/data-plugin/public'; import type { Datatable, RenderMode } from '@kbn/expressions-plugin/common'; -import type { ILensInterpreterRenderHandlers, LensEditEvent } from '../../types'; +import type { ILensInterpreterRenderHandlers, LensEditEvent } from '../../../types'; import { LENS_EDIT_SORT_ACTION, LENS_EDIT_RESIZE_ACTION, LENS_TOGGLE_ACTION, LENS_EDIT_PAGESIZE_ACTION, } from './constants'; -import type { FormatFactory } from '../../../common'; -import type { DatatableProps, LensGridDirection } from '../../../common/expressions'; +import type { FormatFactory } from '../../../../common'; +import type { DatatableProps, LensGridDirection } from '../../../../common/expressions'; export interface LensSortActionData { columnId: string | undefined; diff --git a/x-pack/plugins/lens/public/datatable_visualization/datatable_visualization.ts b/x-pack/plugins/lens/public/visualizations/datatable/datatable_visualization.ts similarity index 100% rename from x-pack/plugins/lens/public/datatable_visualization/datatable_visualization.ts rename to x-pack/plugins/lens/public/visualizations/datatable/datatable_visualization.ts diff --git a/x-pack/plugins/lens/public/datatable_visualization/expression.test.tsx b/x-pack/plugins/lens/public/visualizations/datatable/expression.test.tsx similarity index 92% rename from x-pack/plugins/lens/public/datatable_visualization/expression.test.tsx rename to x-pack/plugins/lens/public/visualizations/datatable/expression.test.tsx index 6bf6d27f35edd..7bd3bac4e9502 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/expression.test.tsx +++ b/x-pack/plugins/lens/public/visualizations/datatable/expression.test.tsx @@ -5,10 +5,10 @@ * 2.0. */ -import type { DatatableProps } from '../../common/expressions'; +import type { DatatableProps } from '../../../common/expressions'; import { createMockExecutionContext } from '@kbn/expressions-plugin/common/mocks'; -import type { FormatFactory } from '../../common'; -import { getDatatable } from '../../common/expressions'; +import type { FormatFactory } from '../../../common'; +import { getDatatable } from '../../../common/expressions'; import { Datatable } from '@kbn/expressions-plugin/common'; function sampleArgs() { diff --git a/x-pack/plugins/lens/public/datatable_visualization/expression.tsx b/x-pack/plugins/lens/public/visualizations/datatable/expression.tsx similarity index 92% rename from x-pack/plugins/lens/public/datatable_visualization/expression.tsx rename to x-pack/plugins/lens/public/visualizations/datatable/expression.tsx index a7ce6b2a9f67c..93a41f9baf532 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/expression.tsx +++ b/x-pack/plugins/lens/public/visualizations/datatable/expression.tsx @@ -14,12 +14,12 @@ import type { IAggType } from '@kbn/data-plugin/public'; import { IUiSettingsClient, ThemeServiceStart } from '@kbn/core/public'; import { ExpressionRenderDefinition } from '@kbn/expressions-plugin/common'; import { KibanaThemeProvider } from '@kbn/kibana-react-plugin/public'; -import { trackUiCounterEvents } from '../lens_ui_telemetry'; +import { trackUiCounterEvents } from '../../lens_ui_telemetry'; import { DatatableComponent } from './components/table_basic'; -import type { ILensInterpreterRenderHandlers } from '../types'; -import type { FormatFactory } from '../../common'; -import type { DatatableProps } from '../../common/expressions'; +import type { ILensInterpreterRenderHandlers } from '../../types'; +import type { FormatFactory } from '../../../common'; +import type { DatatableProps } from '../../../common/expressions'; export const getDatatableRenderer = (dependencies: { formatFactory: FormatFactory; diff --git a/x-pack/plugins/lens/public/datatable_visualization/index.ts b/x-pack/plugins/lens/public/visualizations/datatable/index.ts similarity index 91% rename from x-pack/plugins/lens/public/datatable_visualization/index.ts rename to x-pack/plugins/lens/public/visualizations/datatable/index.ts index 1d2821cb49c0e..7999e7246a594 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/index.ts +++ b/x-pack/plugins/lens/public/visualizations/datatable/index.ts @@ -9,8 +9,8 @@ import type { CoreSetup } from '@kbn/core/public'; import type { ChartsPluginSetup } from '@kbn/charts-plugin/public'; import type { ExpressionsSetup } from '@kbn/expressions-plugin/public'; import type { DataPublicPluginStart } from '@kbn/data-plugin/public'; -import type { EditorFrameSetup } from '../types'; -import type { FormatFactory } from '../../common'; +import type { EditorFrameSetup } from '../../types'; +import type { FormatFactory } from '../../../common'; interface DatatableVisualizationPluginStartPlugins { data: DataPublicPluginStart; @@ -28,7 +28,9 @@ export class DatatableVisualization { { expressions, formatFactory, editorFrame, charts }: DatatableVisualizationPluginSetupPlugins ) { editorFrame.registerVisualization(async () => { - const { getDatatableRenderer, getDatatableVisualization } = await import('../async_services'); + const { getDatatableRenderer, getDatatableVisualization } = await import( + '../../async_services' + ); const palettes = await charts.palettes.getPalettes(); expressions.registerRenderer(() => getDatatableRenderer({ diff --git a/x-pack/plugins/lens/public/datatable_visualization/visualization.test.tsx b/x-pack/plugins/lens/public/visualizations/datatable/visualization.test.tsx similarity index 99% rename from x-pack/plugins/lens/public/datatable_visualization/visualization.test.tsx rename to x-pack/plugins/lens/public/visualizations/datatable/visualization.test.tsx index 87dc93b71f871..494be445670ae 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/visualization.test.tsx +++ b/x-pack/plugins/lens/public/visualizations/datatable/visualization.test.tsx @@ -7,7 +7,7 @@ import { Ast } from '@kbn/interpreter'; import { buildExpression } from '@kbn/expressions-plugin/public'; -import { createMockDatasource, createMockFramePublicAPI, DatasourceMock } from '../mocks'; +import { createMockDatasource, createMockFramePublicAPI, DatasourceMock } from '../../mocks'; import { DatatableVisualizationState, getDatatableVisualization } from './visualization'; import { Operation, @@ -15,9 +15,9 @@ import { FramePublicAPI, TableSuggestionColumn, VisualizationDimensionGroupConfig, -} from '../types'; +} from '../../types'; import { chartPluginMock } from '@kbn/charts-plugin/public/mocks'; -import { layerTypes } from '../../common'; +import { layerTypes } from '../../../common'; import { themeServiceMock } from '@kbn/core/public/mocks'; function mockFrame(): FramePublicAPI { diff --git a/x-pack/plugins/lens/public/datatable_visualization/visualization.tsx b/x-pack/plugins/lens/public/visualizations/datatable/visualization.tsx similarity index 98% rename from x-pack/plugins/lens/public/datatable_visualization/visualization.tsx rename to x-pack/plugins/lens/public/visualizations/datatable/visualization.tsx index 71399a7d10996..2ccef5a89b1ba 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/visualization.tsx +++ b/x-pack/plugins/lens/public/visualizations/datatable/visualization.tsx @@ -19,13 +19,13 @@ import type { Visualization, VisualizationSuggestion, DatasourceLayers, -} from '../types'; -import { LensIconChartDatatable } from '../assets/chart_datatable'; +} from '../../types'; +import { LensIconChartDatatable } from '../../assets/chart_datatable'; import { TableDimensionEditor } from './components/dimension_editor'; import { TableDimensionEditorAdditionalSection } from './components/dimension_editor_addtional_section'; -import { LayerType, layerTypes } from '../../common'; -import { getDefaultSummaryLabel, PagingState } from '../../common/expressions'; -import type { ColumnState, SortingState } from '../../common/expressions'; +import { LayerType, layerTypes } from '../../../common'; +import { getDefaultSummaryLabel, PagingState } from '../../../common/expressions'; +import type { ColumnState, SortingState } from '../../../common/expressions'; import { DataTableToolbar } from './components/toolbar'; export interface DatatableVisualizationState { diff --git a/x-pack/plugins/lens/public/heatmap_visualization/constants.ts b/x-pack/plugins/lens/public/visualizations/heatmap/constants.ts similarity index 100% rename from x-pack/plugins/lens/public/heatmap_visualization/constants.ts rename to x-pack/plugins/lens/public/visualizations/heatmap/constants.ts diff --git a/x-pack/plugins/lens/public/heatmap_visualization/dimension_editor.scss b/x-pack/plugins/lens/public/visualizations/heatmap/dimension_editor.scss similarity index 100% rename from x-pack/plugins/lens/public/heatmap_visualization/dimension_editor.scss rename to x-pack/plugins/lens/public/visualizations/heatmap/dimension_editor.scss diff --git a/x-pack/plugins/lens/public/heatmap_visualization/dimension_editor.tsx b/x-pack/plugins/lens/public/visualizations/heatmap/dimension_editor.tsx similarity index 96% rename from x-pack/plugins/lens/public/heatmap_visualization/dimension_editor.tsx rename to x-pack/plugins/lens/public/visualizations/heatmap/dimension_editor.tsx index ae7f01a7cebd3..ef0700b7ca9fe 100644 --- a/x-pack/plugins/lens/public/heatmap_visualization/dimension_editor.tsx +++ b/x-pack/plugins/lens/public/visualizations/heatmap/dimension_editor.tsx @@ -15,8 +15,8 @@ import { EuiButtonEmpty, } from '@elastic/eui'; import { CustomizablePalette, FIXED_PROGRESSION, PaletteRegistry } from '@kbn/coloring'; -import type { VisualizationDimensionEditorProps } from '../types'; -import { PalettePanelContainer } from '../shared_components'; +import type { VisualizationDimensionEditorProps } from '../../types'; +import { PalettePanelContainer } from '../../shared_components'; import './dimension_editor.scss'; import type { HeatmapVisualizationState } from './types'; import { getSafePaletteParams } from './utils'; diff --git a/x-pack/plugins/lens/public/heatmap_visualization/heatmap_visualization.ts b/x-pack/plugins/lens/public/visualizations/heatmap/heatmap_visualization.ts similarity index 100% rename from x-pack/plugins/lens/public/heatmap_visualization/heatmap_visualization.ts rename to x-pack/plugins/lens/public/visualizations/heatmap/heatmap_visualization.ts diff --git a/x-pack/plugins/lens/public/heatmap_visualization/index.ts b/x-pack/plugins/lens/public/visualizations/heatmap/index.ts similarity index 86% rename from x-pack/plugins/lens/public/heatmap_visualization/index.ts rename to x-pack/plugins/lens/public/visualizations/heatmap/index.ts index e6bebd087c5b3..dd132c371d715 100644 --- a/x-pack/plugins/lens/public/heatmap_visualization/index.ts +++ b/x-pack/plugins/lens/public/visualizations/heatmap/index.ts @@ -7,7 +7,7 @@ import type { CoreSetup } from '@kbn/core/public'; import type { ChartsPluginSetup } from '@kbn/charts-plugin/public'; -import type { EditorFrameSetup } from '../types'; +import type { EditorFrameSetup } from '../../types'; export interface HeatmapVisualizationPluginSetupPlugins { editorFrame: EditorFrameSetup; @@ -17,7 +17,7 @@ export interface HeatmapVisualizationPluginSetupPlugins { export class HeatmapVisualization { setup(core: CoreSetup, { editorFrame, charts }: HeatmapVisualizationPluginSetupPlugins) { editorFrame.registerVisualization(async () => { - const { getHeatmapVisualization } = await import('../async_services'); + const { getHeatmapVisualization } = await import('../../async_services'); const palettes = await charts.palettes.getPalettes(); return getHeatmapVisualization({ paletteService: palettes, theme: core.theme }); diff --git a/x-pack/plugins/lens/public/heatmap_visualization/suggestions.test.ts b/x-pack/plugins/lens/public/visualizations/heatmap/suggestions.test.ts similarity index 99% rename from x-pack/plugins/lens/public/heatmap_visualization/suggestions.test.ts rename to x-pack/plugins/lens/public/visualizations/heatmap/suggestions.test.ts index dbe2d9a7c9771..70db8e0d4165a 100644 --- a/x-pack/plugins/lens/public/heatmap_visualization/suggestions.test.ts +++ b/x-pack/plugins/lens/public/visualizations/heatmap/suggestions.test.ts @@ -9,7 +9,7 @@ import { Position } from '@elastic/charts'; import { getSuggestions } from './suggestions'; import type { HeatmapVisualizationState } from './types'; import { HEATMAP_GRID_FUNCTION, LEGEND_FUNCTION } from './constants'; -import { layerTypes } from '../../common'; +import { layerTypes } from '../../../common'; describe('heatmap suggestions', () => { describe('rejects suggestions', () => { diff --git a/x-pack/plugins/lens/public/heatmap_visualization/suggestions.ts b/x-pack/plugins/lens/public/visualizations/heatmap/suggestions.ts similarity index 97% rename from x-pack/plugins/lens/public/heatmap_visualization/suggestions.ts rename to x-pack/plugins/lens/public/visualizations/heatmap/suggestions.ts index c13b6eb655e3b..a302be4cfceb6 100644 --- a/x-pack/plugins/lens/public/heatmap_visualization/suggestions.ts +++ b/x-pack/plugins/lens/public/visualizations/heatmap/suggestions.ts @@ -8,10 +8,10 @@ import { partition } from 'lodash'; import { Position } from '@elastic/charts'; import { i18n } from '@kbn/i18n'; -import type { Visualization } from '../types'; +import type { Visualization } from '../../types'; import type { HeatmapVisualizationState } from './types'; import { CHART_SHAPES, HEATMAP_GRID_FUNCTION, LEGEND_FUNCTION } from './constants'; -import { layerTypes } from '../../common'; +import { layerTypes } from '../../../common'; export const getSuggestions: Visualization['getSuggestions'] = ({ table, diff --git a/x-pack/plugins/lens/public/heatmap_visualization/toolbar_component.scss b/x-pack/plugins/lens/public/visualizations/heatmap/toolbar_component.scss similarity index 100% rename from x-pack/plugins/lens/public/heatmap_visualization/toolbar_component.scss rename to x-pack/plugins/lens/public/visualizations/heatmap/toolbar_component.scss diff --git a/x-pack/plugins/lens/public/heatmap_visualization/toolbar_component.tsx b/x-pack/plugins/lens/public/visualizations/heatmap/toolbar_component.tsx similarity index 96% rename from x-pack/plugins/lens/public/heatmap_visualization/toolbar_component.tsx rename to x-pack/plugins/lens/public/visualizations/heatmap/toolbar_component.tsx index d653649dc1048..b0a80ca297a0a 100644 --- a/x-pack/plugins/lens/public/heatmap_visualization/toolbar_component.tsx +++ b/x-pack/plugins/lens/public/visualizations/heatmap/toolbar_component.tsx @@ -10,18 +10,18 @@ import { EuiFlexGroup, EuiFlexItem, IconType } from '@elastic/eui'; import { Position } from '@elastic/charts'; import { i18n } from '@kbn/i18n'; import { LegendSize } from '@kbn/visualizations-plugin/public'; -import type { VisualizationToolbarProps } from '../types'; +import type { VisualizationToolbarProps } from '../../types'; import { LegendSettingsPopover, ToolbarPopover, ValueLabelsSettings, AxisTitleSettings, TooltipWrapper, -} from '../shared_components'; -import { EuiIconAxisLeft } from '../assets/axis_left'; -import { EuiIconAxisBottom } from '../assets/axis_bottom'; +} from '../../shared_components'; +import { EuiIconAxisLeft } from '../../assets/axis_left'; +import { EuiIconAxisBottom } from '../../assets/axis_bottom'; import type { HeatmapVisualizationState } from './types'; -import { getDefaultVisualValuesForLayer } from '../shared_components/datasource_default_values'; +import { getDefaultVisualValuesForLayer } from '../../shared_components/datasource_default_values'; import './toolbar_component.scss'; const legendOptions: Array<{ id: string; value: 'auto' | 'show' | 'hide'; label: string }> = [ diff --git a/x-pack/plugins/lens/public/heatmap_visualization/types.ts b/x-pack/plugins/lens/public/visualizations/heatmap/types.ts similarity index 94% rename from x-pack/plugins/lens/public/heatmap_visualization/types.ts rename to x-pack/plugins/lens/public/visualizations/heatmap/types.ts index 1b92dca12ac25..08913ad25a7d3 100644 --- a/x-pack/plugins/lens/public/heatmap_visualization/types.ts +++ b/x-pack/plugins/lens/public/visualizations/heatmap/types.ts @@ -7,7 +7,7 @@ import type { PaletteOutput, CustomPaletteParams } from '@kbn/coloring'; import type { HeatmapArguments } from '@kbn/expression-heatmap-plugin/common'; -import type { LayerType } from '../../common'; +import type { LayerType } from '../../../common'; export type ChartShapes = 'heatmap'; export type HeatmapLayerState = HeatmapArguments & { diff --git a/x-pack/plugins/lens/public/heatmap_visualization/utils.ts b/x-pack/plugins/lens/public/visualizations/heatmap/utils.ts similarity index 93% rename from x-pack/plugins/lens/public/heatmap_visualization/utils.ts rename to x-pack/plugins/lens/public/visualizations/heatmap/utils.ts index 66c70381a560d..5e09ce2987bae 100644 --- a/x-pack/plugins/lens/public/heatmap_visualization/utils.ts +++ b/x-pack/plugins/lens/public/visualizations/heatmap/utils.ts @@ -7,7 +7,7 @@ import type { PaletteRegistry } from '@kbn/coloring'; import type { Datatable } from '@kbn/expressions-plugin/common'; -import { applyPaletteParams, findMinMaxByColumnId } from '../shared_components'; +import { applyPaletteParams, findMinMaxByColumnId } from '../../shared_components'; import { DEFAULT_PALETTE_NAME } from './constants'; import type { HeatmapVisualizationState, Palette } from './types'; diff --git a/x-pack/plugins/lens/public/heatmap_visualization/visualization.test.ts b/x-pack/plugins/lens/public/visualizations/heatmap/visualization.test.ts similarity index 99% rename from x-pack/plugins/lens/public/heatmap_visualization/visualization.test.ts rename to x-pack/plugins/lens/public/visualizations/heatmap/visualization.test.ts index 7ef8d3ab132d1..ee6a7030a0c9d 100644 --- a/x-pack/plugins/lens/public/heatmap_visualization/visualization.test.ts +++ b/x-pack/plugins/lens/public/visualizations/heatmap/visualization.test.ts @@ -10,7 +10,7 @@ import { getHeatmapVisualization, isCellValueSupported, } from './visualization'; -import { createMockDatasource, createMockFramePublicAPI } from '../mocks'; +import { createMockDatasource, createMockFramePublicAPI } from '../../mocks'; import { CHART_SHAPES, FUNCTION_NAME, @@ -20,9 +20,9 @@ import { } from './constants'; import { Position } from '@elastic/charts'; import type { HeatmapVisualizationState } from './types'; -import type { DatasourceLayers, OperationDescriptor } from '../types'; +import type { DatasourceLayers, OperationDescriptor } from '../../types'; import { chartPluginMock } from '@kbn/charts-plugin/public/mocks'; -import { layerTypes } from '../../common'; +import { layerTypes } from '../../../common'; import { themeServiceMock } from '@kbn/core/public/mocks'; function exampleState(): HeatmapVisualizationState { diff --git a/x-pack/plugins/lens/public/heatmap_visualization/visualization.tsx b/x-pack/plugins/lens/public/visualizations/heatmap/visualization.tsx similarity index 99% rename from x-pack/plugins/lens/public/heatmap_visualization/visualization.tsx rename to x-pack/plugins/lens/public/visualizations/heatmap/visualization.tsx index 723779875f813..9c97aa4dab605 100644 --- a/x-pack/plugins/lens/public/heatmap_visualization/visualization.tsx +++ b/x-pack/plugins/lens/public/visualizations/heatmap/visualization.tsx @@ -16,7 +16,7 @@ import { ThemeServiceStart } from '@kbn/core/public'; import { KibanaThemeProvider } from '@kbn/kibana-react-plugin/public'; import { VIS_EVENT_TO_TRIGGER } from '@kbn/visualizations-plugin/public'; import { HeatmapIcon } from '@kbn/expression-heatmap-plugin/public'; -import type { OperationMetadata, Visualization } from '../types'; +import type { OperationMetadata, Visualization } from '../../types'; import type { HeatmapVisualizationState } from './types'; import { getSuggestions } from './suggestions'; import { @@ -32,7 +32,7 @@ import { import { HeatmapToolbar } from './toolbar_component'; import { HeatmapDimensionEditor } from './dimension_editor'; import { getSafePaletteParams } from './utils'; -import { layerTypes } from '../../common'; +import { layerTypes } from '../../../common'; const groupLabelForHeatmap = i18n.translate('xpack.lens.heatmapVisualization.heatmapGroupLabel', { defaultMessage: 'Magnitude', diff --git a/x-pack/plugins/lens/public/metric_visualization/dimension_editor.scss b/x-pack/plugins/lens/public/visualizations/legacy_metric/dimension_editor.scss similarity index 100% rename from x-pack/plugins/lens/public/metric_visualization/dimension_editor.scss rename to x-pack/plugins/lens/public/visualizations/legacy_metric/dimension_editor.scss diff --git a/x-pack/plugins/lens/public/metric_visualization/dimension_editor.test.tsx b/x-pack/plugins/lens/public/visualizations/legacy_metric/dimension_editor.test.tsx similarity index 97% rename from x-pack/plugins/lens/public/metric_visualization/dimension_editor.test.tsx rename to x-pack/plugins/lens/public/visualizations/legacy_metric/dimension_editor.test.tsx index c83e83aad7b1b..0deb214979786 100644 --- a/x-pack/plugins/lens/public/metric_visualization/dimension_editor.test.tsx +++ b/x-pack/plugins/lens/public/visualizations/legacy_metric/dimension_editor.test.tsx @@ -7,8 +7,8 @@ import React from 'react'; import { EuiButtonGroup } from '@elastic/eui'; -import { FramePublicAPI, VisualizationDimensionEditorProps } from '../types'; -import { createMockDatasource, createMockFramePublicAPI } from '../mocks'; +import { FramePublicAPI, VisualizationDimensionEditorProps } from '../../types'; +import { createMockDatasource, createMockFramePublicAPI } from '../../mocks'; import { mountWithIntl } from '@kbn/test-jest-helpers'; import { MetricDimensionEditor } from './dimension_editor'; import { chartPluginMock } from '@kbn/charts-plugin/public/mocks'; @@ -21,9 +21,9 @@ import { } from '@kbn/coloring'; import { act } from 'react-dom/test-utils'; -import { PalettePanelContainer } from '../shared_components'; -import { layerTypes } from '../../common'; -import type { MetricState } from '../../common/types'; +import { PalettePanelContainer } from '../../shared_components'; +import { layerTypes } from '../../../common'; +import type { MetricState } from '../../../common/types'; // mocking random id generator function jest.mock('@elastic/eui', () => { diff --git a/x-pack/plugins/lens/public/metric_visualization/dimension_editor.tsx b/x-pack/plugins/lens/public/visualizations/legacy_metric/dimension_editor.tsx similarity index 96% rename from x-pack/plugins/lens/public/metric_visualization/dimension_editor.tsx rename to x-pack/plugins/lens/public/visualizations/legacy_metric/dimension_editor.tsx index b3a2e7207e77d..5acfe97c5b3ef 100644 --- a/x-pack/plugins/lens/public/metric_visualization/dimension_editor.tsx +++ b/x-pack/plugins/lens/public/visualizations/legacy_metric/dimension_editor.tsx @@ -22,10 +22,10 @@ import { import { i18n } from '@kbn/i18n'; import React, { useCallback, useState } from 'react'; import { ColorMode } from '@kbn/charts-plugin/common'; -import type { MetricState } from '../../common/types'; -import { isNumericFieldForDatatable } from '../../common/expressions'; -import { applyPaletteParams, PalettePanelContainer } from '../shared_components'; -import type { VisualizationDimensionEditorProps } from '../types'; +import type { MetricState } from '../../../common/types'; +import { isNumericFieldForDatatable } from '../../../common/expressions'; +import { applyPaletteParams, PalettePanelContainer } from '../../shared_components'; +import type { VisualizationDimensionEditorProps } from '../../types'; import { defaultPaletteParams } from './palette_config'; import './dimension_editor.scss'; diff --git a/x-pack/plugins/lens/public/metric_visualization/index.ts b/x-pack/plugins/lens/public/visualizations/legacy_metric/index.ts similarity index 91% rename from x-pack/plugins/lens/public/metric_visualization/index.ts rename to x-pack/plugins/lens/public/visualizations/legacy_metric/index.ts index ce733a033b6da..933bf4dab6ae8 100644 --- a/x-pack/plugins/lens/public/metric_visualization/index.ts +++ b/x-pack/plugins/lens/public/visualizations/legacy_metric/index.ts @@ -7,7 +7,7 @@ import type { CoreSetup } from '@kbn/core/public'; import type { ChartsPluginSetup } from '@kbn/charts-plugin/public'; -import type { EditorFrameSetup } from '../types'; +import type { EditorFrameSetup } from '../../types'; export interface LegacyMetricVisualizationPluginSetupPlugins { editorFrame: EditorFrameSetup; @@ -18,7 +18,7 @@ export class LegacyMetricVisualization { setup(core: CoreSetup, { editorFrame, charts }: LegacyMetricVisualizationPluginSetupPlugins) { editorFrame.registerVisualization(async () => { const { getLegacyMetricVisualization: getMetricVisualization } = await import( - '../async_services' + '../../async_services' ); const palettes = await charts.palettes.getPalettes(); diff --git a/x-pack/plugins/lens/public/metric_visualization/metric_config_panel/align_options.tsx b/x-pack/plugins/lens/public/visualizations/legacy_metric/metric_config_panel/align_options.tsx similarity index 96% rename from x-pack/plugins/lens/public/metric_visualization/metric_config_panel/align_options.tsx rename to x-pack/plugins/lens/public/visualizations/legacy_metric/metric_config_panel/align_options.tsx index cf077e6eaa77f..0da058db3d5b5 100644 --- a/x-pack/plugins/lens/public/metric_visualization/metric_config_panel/align_options.tsx +++ b/x-pack/plugins/lens/public/visualizations/legacy_metric/metric_config_panel/align_options.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { EuiButtonGroup } from '@elastic/eui'; -import { MetricState } from '../../../common/types'; +import { MetricState } from '../../../../common/types'; export interface TitlePositionProps { state: MetricState; diff --git a/x-pack/plugins/lens/public/metric_visualization/metric_config_panel/appearance_options_popover.tsx b/x-pack/plugins/lens/public/visualizations/legacy_metric/metric_config_panel/appearance_options_popover.tsx similarity index 87% rename from x-pack/plugins/lens/public/metric_visualization/metric_config_panel/appearance_options_popover.tsx rename to x-pack/plugins/lens/public/visualizations/legacy_metric/metric_config_panel/appearance_options_popover.tsx index 280a036ab5daf..14cf0860db2f1 100644 --- a/x-pack/plugins/lens/public/metric_visualization/metric_config_panel/appearance_options_popover.tsx +++ b/x-pack/plugins/lens/public/visualizations/legacy_metric/metric_config_panel/appearance_options_popover.tsx @@ -7,10 +7,10 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; -import { ToolbarPopover, TooltipWrapper } from '../../shared_components'; +import { ToolbarPopover, TooltipWrapper } from '../../../shared_components'; import { TitlePositionOptions } from './title_position_option'; -import { FramePublicAPI } from '../../types'; -import type { MetricState } from '../../../common/types'; +import { FramePublicAPI } from '../../../types'; +import type { MetricState } from '../../../../common/types'; import { TextFormattingOptions } from './text_formatting_options'; export interface VisualOptionsPopoverProps { diff --git a/x-pack/plugins/lens/public/metric_visualization/metric_config_panel/index.tsx b/x-pack/plugins/lens/public/visualizations/legacy_metric/metric_config_panel/index.tsx similarity index 89% rename from x-pack/plugins/lens/public/metric_visualization/metric_config_panel/index.tsx rename to x-pack/plugins/lens/public/visualizations/legacy_metric/metric_config_panel/index.tsx index 947115fcee5db..0988aefa24492 100644 --- a/x-pack/plugins/lens/public/metric_visualization/metric_config_panel/index.tsx +++ b/x-pack/plugins/lens/public/visualizations/legacy_metric/metric_config_panel/index.tsx @@ -7,8 +7,8 @@ import React, { memo } from 'react'; import { EuiFlexGroup, EuiFlexItem, htmlIdGenerator } from '@elastic/eui'; -import type { VisualizationToolbarProps } from '../../types'; -import type { MetricState } from '../../../common/types'; +import type { VisualizationToolbarProps } from '../../../types'; +import type { MetricState } from '../../../../common/types'; import { AppearanceOptionsPopover } from './appearance_options_popover'; diff --git a/x-pack/plugins/lens/public/metric_visualization/metric_config_panel/size_options.tsx b/x-pack/plugins/lens/public/visualizations/legacy_metric/metric_config_panel/size_options.tsx similarity index 97% rename from x-pack/plugins/lens/public/metric_visualization/metric_config_panel/size_options.tsx rename to x-pack/plugins/lens/public/visualizations/legacy_metric/metric_config_panel/size_options.tsx index 40af2d9a0e717..94efe0e00231e 100644 --- a/x-pack/plugins/lens/public/metric_visualization/metric_config_panel/size_options.tsx +++ b/x-pack/plugins/lens/public/visualizations/legacy_metric/metric_config_panel/size_options.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { EuiButtonIcon, EuiSuperSelect } from '@elastic/eui'; -import type { MetricState } from '../../../common/types'; +import type { MetricState } from '../../../../common/types'; export interface TitlePositionProps { state: MetricState; diff --git a/x-pack/plugins/lens/public/metric_visualization/metric_config_panel/text_formatting_options.tsx b/x-pack/plugins/lens/public/visualizations/legacy_metric/metric_config_panel/text_formatting_options.tsx similarity index 95% rename from x-pack/plugins/lens/public/metric_visualization/metric_config_panel/text_formatting_options.tsx rename to x-pack/plugins/lens/public/visualizations/legacy_metric/metric_config_panel/text_formatting_options.tsx index 149d66a2db3cb..8a1f97cd8251e 100644 --- a/x-pack/plugins/lens/public/metric_visualization/metric_config_panel/text_formatting_options.tsx +++ b/x-pack/plugins/lens/public/visualizations/legacy_metric/metric_config_panel/text_formatting_options.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { EuiFormRow, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; -import type { MetricState } from '../../../common/types'; +import type { MetricState } from '../../../../common/types'; import { SizeOptions } from './size_options'; import { AlignOptions } from './align_options'; diff --git a/x-pack/plugins/lens/public/metric_visualization/metric_config_panel/title_position_option.tsx b/x-pack/plugins/lens/public/visualizations/legacy_metric/metric_config_panel/title_position_option.tsx similarity index 96% rename from x-pack/plugins/lens/public/metric_visualization/metric_config_panel/title_position_option.tsx rename to x-pack/plugins/lens/public/visualizations/legacy_metric/metric_config_panel/title_position_option.tsx index 63abd195d6e5e..233a2e382669f 100644 --- a/x-pack/plugins/lens/public/metric_visualization/metric_config_panel/title_position_option.tsx +++ b/x-pack/plugins/lens/public/visualizations/legacy_metric/metric_config_panel/title_position_option.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { EuiButtonGroup, EuiFormRow } from '@elastic/eui'; -import type { MetricState } from '../../../common/types'; +import type { MetricState } from '../../../../common/types'; export interface TitlePositionProps { state: MetricState; diff --git a/x-pack/plugins/lens/public/metric_visualization/metric_suggestions.test.ts b/x-pack/plugins/lens/public/visualizations/legacy_metric/metric_suggestions.test.ts similarity index 98% rename from x-pack/plugins/lens/public/metric_visualization/metric_suggestions.test.ts rename to x-pack/plugins/lens/public/visualizations/legacy_metric/metric_suggestions.test.ts index 791d282bfe9d5..e1803e106f2eb 100644 --- a/x-pack/plugins/lens/public/metric_visualization/metric_suggestions.test.ts +++ b/x-pack/plugins/lens/public/visualizations/legacy_metric/metric_suggestions.test.ts @@ -6,7 +6,7 @@ */ import { getSuggestions } from './metric_suggestions'; -import { TableSuggestionColumn, TableSuggestion } from '../types'; +import { TableSuggestionColumn, TableSuggestion } from '../../types'; describe('metric_suggestions', () => { function numCol(columnId: string): TableSuggestionColumn { diff --git a/x-pack/plugins/lens/public/metric_visualization/metric_suggestions.ts b/x-pack/plugins/lens/public/visualizations/legacy_metric/metric_suggestions.ts similarity index 89% rename from x-pack/plugins/lens/public/metric_visualization/metric_suggestions.ts rename to x-pack/plugins/lens/public/visualizations/legacy_metric/metric_suggestions.ts index 4485571ffdb8d..32a5831618251 100644 --- a/x-pack/plugins/lens/public/metric_visualization/metric_suggestions.ts +++ b/x-pack/plugins/lens/public/visualizations/legacy_metric/metric_suggestions.ts @@ -5,10 +5,10 @@ * 2.0. */ -import { SuggestionRequest, VisualizationSuggestion, TableSuggestion } from '../types'; -import type { MetricState } from '../../common/types'; -import { layerTypes } from '../../common'; -import { LensIconChartMetric } from '../assets/chart_metric'; +import { SuggestionRequest, VisualizationSuggestion, TableSuggestion } from '../../types'; +import type { MetricState } from '../../../common/types'; +import { layerTypes } from '../../../common'; +import { LensIconChartMetric } from '../../assets/chart_metric'; import { legacyMetricSupportedTypes } from './visualization'; /** diff --git a/x-pack/plugins/lens/public/metric_visualization/metric_visualization.ts b/x-pack/plugins/lens/public/visualizations/legacy_metric/metric_visualization.ts similarity index 100% rename from x-pack/plugins/lens/public/metric_visualization/metric_visualization.ts rename to x-pack/plugins/lens/public/visualizations/legacy_metric/metric_visualization.ts diff --git a/x-pack/plugins/lens/public/metric_visualization/palette_config.tsx b/x-pack/plugins/lens/public/visualizations/legacy_metric/palette_config.tsx similarity index 96% rename from x-pack/plugins/lens/public/metric_visualization/palette_config.tsx rename to x-pack/plugins/lens/public/visualizations/legacy_metric/palette_config.tsx index b44e94d84e0a9..e34533c058e7f 100644 --- a/x-pack/plugins/lens/public/metric_visualization/palette_config.tsx +++ b/x-pack/plugins/lens/public/visualizations/legacy_metric/palette_config.tsx @@ -6,7 +6,7 @@ */ import { RequiredPaletteParamTypes } from '@kbn/coloring'; -import { defaultPaletteParams as sharedDefaultParams } from '../shared_components'; +import { defaultPaletteParams as sharedDefaultParams } from '../../shared_components'; export const DEFAULT_PALETTE_NAME = 'status'; export const DEFAULT_COLOR_STEPS = 3; diff --git a/x-pack/plugins/lens/public/metric_visualization/visualization.test.ts b/x-pack/plugins/lens/public/visualizations/legacy_metric/visualization.test.ts similarity index 97% rename from x-pack/plugins/lens/public/metric_visualization/visualization.test.ts rename to x-pack/plugins/lens/public/visualizations/legacy_metric/visualization.test.ts index d6b14e5e574c8..399c29797ff83 100644 --- a/x-pack/plugins/lens/public/metric_visualization/visualization.test.ts +++ b/x-pack/plugins/lens/public/visualizations/legacy_metric/visualization.test.ts @@ -6,16 +6,16 @@ */ import { getLegacyMetricVisualization } from './visualization'; -import type { MetricState } from '../../common/types'; -import { layerTypes } from '../../common'; -import { createMockDatasource, createMockFramePublicAPI } from '../mocks'; -import { generateId } from '../id_generator'; -import { DatasourcePublicAPI, FramePublicAPI } from '../types'; +import type { MetricState } from '../../../common/types'; +import { layerTypes } from '../../../common'; +import { createMockDatasource, createMockFramePublicAPI } from '../../mocks'; +import { generateId } from '../../id_generator'; +import { DatasourcePublicAPI, FramePublicAPI } from '../../types'; import { chartPluginMock } from '@kbn/charts-plugin/public/mocks'; import { ColorMode } from '@kbn/charts-plugin/common'; import { themeServiceMock } from '@kbn/core/public/mocks'; -jest.mock('../id_generator'); +jest.mock('../../id_generator'); function exampleState(): MetricState { return { diff --git a/x-pack/plugins/lens/public/metric_visualization/visualization.tsx b/x-pack/plugins/lens/public/visualizations/legacy_metric/visualization.tsx similarity index 98% rename from x-pack/plugins/lens/public/metric_visualization/visualization.tsx rename to x-pack/plugins/lens/public/visualizations/legacy_metric/visualization.tsx index e9d23469be7c6..5550341a81e8b 100644 --- a/x-pack/plugins/lens/public/metric_visualization/visualization.tsx +++ b/x-pack/plugins/lens/public/visualizations/legacy_metric/visualization.tsx @@ -15,10 +15,10 @@ import { KibanaThemeProvider } from '@kbn/kibana-react-plugin/public'; import { ColorMode, CustomPaletteState } from '@kbn/charts-plugin/common'; import { VIS_EVENT_TO_TRIGGER } from '@kbn/visualizations-plugin/public'; import { getSuggestions } from './metric_suggestions'; -import { LensIconChartMetric } from '../assets/chart_metric'; -import { Visualization, OperationMetadata, DatasourceLayers } from '../types'; -import type { MetricState } from '../../common/types'; -import { layerTypes } from '../../common'; +import { LensIconChartMetric } from '../../assets/chart_metric'; +import { Visualization, OperationMetadata, DatasourceLayers } from '../../types'; +import type { MetricState } from '../../../common/types'; +import { layerTypes } from '../../../common'; import { MetricDimensionEditor } from './dimension_editor'; import { MetricToolbar } from './metric_config_panel'; import { DEFAULT_TITLE_POSITION } from './metric_config_panel/title_position_option'; diff --git a/x-pack/plugins/lens/public/pie_visualization/constants.ts b/x-pack/plugins/lens/public/visualizations/partition/constants.ts similarity index 100% rename from x-pack/plugins/lens/public/pie_visualization/constants.ts rename to x-pack/plugins/lens/public/visualizations/partition/constants.ts diff --git a/x-pack/plugins/lens/public/pie_visualization/index.ts b/x-pack/plugins/lens/public/visualizations/partition/index.ts similarity index 88% rename from x-pack/plugins/lens/public/pie_visualization/index.ts rename to x-pack/plugins/lens/public/visualizations/partition/index.ts index 6b7a9d68115d6..09e98c6c6c806 100644 --- a/x-pack/plugins/lens/public/pie_visualization/index.ts +++ b/x-pack/plugins/lens/public/visualizations/partition/index.ts @@ -8,7 +8,7 @@ import type { CoreSetup } from '@kbn/core/public'; import type { UiActionsStart } from '@kbn/ui-actions-plugin/public'; import type { ChartsPluginSetup } from '@kbn/charts-plugin/public'; -import type { EditorFrameSetup } from '../types'; +import type { EditorFrameSetup } from '../../types'; export interface PieVisualizationPluginSetupPlugins { editorFrame: EditorFrameSetup; @@ -22,7 +22,7 @@ export interface PieVisualizationPluginStartPlugins { export class PieVisualization { setup(core: CoreSetup, { editorFrame, charts }: PieVisualizationPluginSetupPlugins) { editorFrame.registerVisualization(async () => { - const { getPieVisualization } = await import('../async_services'); + const { getPieVisualization } = await import('../../async_services'); const palettes = await charts.palettes.getPalettes(); return getPieVisualization({ paletteService: palettes, kibanaTheme: core.theme }); diff --git a/x-pack/plugins/lens/public/pie_visualization/partition_charts_meta.ts b/x-pack/plugins/lens/public/visualizations/partition/partition_charts_meta.ts similarity index 91% rename from x-pack/plugins/lens/public/pie_visualization/partition_charts_meta.ts rename to x-pack/plugins/lens/public/visualizations/partition/partition_charts_meta.ts index be2ddda9372b9..6d948ce4332fc 100644 --- a/x-pack/plugins/lens/public/pie_visualization/partition_charts_meta.ts +++ b/x-pack/plugins/lens/public/visualizations/partition/partition_charts_meta.ts @@ -9,13 +9,18 @@ import { i18n } from '@kbn/i18n'; import type { EuiIconProps } from '@elastic/eui'; import type { DatatableColumn } from '@kbn/expressions-plugin/common'; -import { LensIconChartDonut } from '../assets/chart_donut'; -import { LensIconChartPie } from '../assets/chart_pie'; -import { LensIconChartTreemap } from '../assets/chart_treemap'; -import { LensIconChartMosaic } from '../assets/chart_mosaic'; -import { LensIconChartWaffle } from '../assets/chart_waffle'; -import { CategoryDisplay, NumberDisplay, SharedPieLayerState, EmptySizeRatios } from '../../common'; -import type { PieChartType } from '../../common/types'; +import { LensIconChartDonut } from '../../assets/chart_donut'; +import { LensIconChartPie } from '../../assets/chart_pie'; +import { LensIconChartTreemap } from '../../assets/chart_treemap'; +import { LensIconChartMosaic } from '../../assets/chart_mosaic'; +import { LensIconChartWaffle } from '../../assets/chart_waffle'; +import { + CategoryDisplay, + NumberDisplay, + SharedPieLayerState, + EmptySizeRatios, +} from '../../../common'; +import type { PieChartType } from '../../../common/types'; interface PartitionChartMeta { icon: ({ title, titleId, ...props }: Omit) => JSX.Element; diff --git a/x-pack/plugins/lens/public/pie_visualization/pie_visualization.ts b/x-pack/plugins/lens/public/visualizations/partition/pie_visualization.ts similarity index 100% rename from x-pack/plugins/lens/public/pie_visualization/pie_visualization.ts rename to x-pack/plugins/lens/public/visualizations/partition/pie_visualization.ts diff --git a/x-pack/plugins/lens/public/pie_visualization/render_helpers.test.ts b/x-pack/plugins/lens/public/visualizations/partition/render_helpers.test.ts similarity index 97% rename from x-pack/plugins/lens/public/pie_visualization/render_helpers.test.ts rename to x-pack/plugins/lens/public/visualizations/partition/render_helpers.test.ts index 6fe4d9b60420e..b7137c3f8e067 100644 --- a/x-pack/plugins/lens/public/pie_visualization/render_helpers.test.ts +++ b/x-pack/plugins/lens/public/visualizations/partition/render_helpers.test.ts @@ -8,7 +8,7 @@ import type { Datatable } from '@kbn/expressions-plugin/public'; import { checkTableForContainsSmallValues, shouldShowValuesInLegend } from './render_helpers'; -import { PieLayerState, PieChartTypes } from '../../common'; +import { PieLayerState, PieChartTypes } from '../../../common'; describe('render helpers', () => { describe('#checkTableForContainsSmallValues', () => { diff --git a/x-pack/plugins/lens/public/pie_visualization/render_helpers.ts b/x-pack/plugins/lens/public/visualizations/partition/render_helpers.ts similarity index 93% rename from x-pack/plugins/lens/public/pie_visualization/render_helpers.ts rename to x-pack/plugins/lens/public/visualizations/partition/render_helpers.ts index b34385d55b44f..bce1031d22133 100644 --- a/x-pack/plugins/lens/public/pie_visualization/render_helpers.ts +++ b/x-pack/plugins/lens/public/visualizations/partition/render_helpers.ts @@ -6,7 +6,7 @@ */ import type { Datatable } from '@kbn/expressions-plugin/public'; -import type { PieChartType, PieLayerState } from '../../common/types'; +import type { PieChartType, PieLayerState } from '../../../common/types'; import { PartitionChartsMeta } from './partition_charts_meta'; export const isPartitionShape = (shape: PieChartType | string) => diff --git a/x-pack/plugins/lens/public/pie_visualization/suggestions.test.ts b/x-pack/plugins/lens/public/visualizations/partition/suggestions.test.ts similarity index 99% rename from x-pack/plugins/lens/public/pie_visualization/suggestions.test.ts rename to x-pack/plugins/lens/public/visualizations/partition/suggestions.test.ts index 44fbaebf91fc0..fc449113adfa2 100644 --- a/x-pack/plugins/lens/public/pie_visualization/suggestions.test.ts +++ b/x-pack/plugins/lens/public/visualizations/partition/suggestions.test.ts @@ -7,7 +7,7 @@ import type { PaletteOutput } from '@kbn/coloring'; import { suggestions } from './suggestions'; -import type { DataType, SuggestionRequest } from '../types'; +import type { DataType, SuggestionRequest } from '../../types'; import { CategoryDisplay, LegendDisplay, @@ -15,8 +15,8 @@ import { PieChartTypes, PieLayerState, PieVisualizationState, -} from '../../common'; -import { layerTypes } from '../../common'; +} from '../../../common'; +import { layerTypes } from '../../../common'; describe('suggestions', () => { describe('pie', () => { diff --git a/x-pack/plugins/lens/public/pie_visualization/suggestions.ts b/x-pack/plugins/lens/public/visualizations/partition/suggestions.ts similarity index 98% rename from x-pack/plugins/lens/public/pie_visualization/suggestions.ts rename to x-pack/plugins/lens/public/visualizations/partition/suggestions.ts index 176fa2d5026ee..f2541493be339 100644 --- a/x-pack/plugins/lens/public/pie_visualization/suggestions.ts +++ b/x-pack/plugins/lens/public/visualizations/partition/suggestions.ts @@ -7,7 +7,11 @@ import { partition } from 'lodash'; import { i18n } from '@kbn/i18n'; -import type { SuggestionRequest, TableSuggestionColumn, VisualizationSuggestion } from '../types'; +import type { + SuggestionRequest, + TableSuggestionColumn, + VisualizationSuggestion, +} from '../../types'; import { CategoryDisplay, layerTypes, @@ -15,8 +19,8 @@ import { NumberDisplay, PieChartTypes, PieVisualizationState, -} from '../../common'; -import type { PieChartType } from '../../common/types'; +} from '../../../common'; +import type { PieChartType } from '../../../common/types'; import { PartitionChartsMeta } from './partition_charts_meta'; import { isPartitionShape } from './render_helpers'; diff --git a/x-pack/plugins/lens/public/pie_visualization/to_expression.ts b/x-pack/plugins/lens/public/visualizations/partition/to_expression.ts similarity index 98% rename from x-pack/plugins/lens/public/pie_visualization/to_expression.ts rename to x-pack/plugins/lens/public/visualizations/partition/to_expression.ts index 20b7199bbc4cd..6fa209a26a829 100644 --- a/x-pack/plugins/lens/public/pie_visualization/to_expression.ts +++ b/x-pack/plugins/lens/public/visualizations/partition/to_expression.ts @@ -10,7 +10,7 @@ import { Position } from '@elastic/charts'; import type { PaletteOutput, PaletteRegistry } from '@kbn/coloring'; import { buildExpression, buildExpressionFunction } from '@kbn/expressions-plugin/public'; -import type { Operation, DatasourcePublicAPI, DatasourceLayers } from '../types'; +import type { Operation, DatasourcePublicAPI, DatasourceLayers } from '../../types'; import { DEFAULT_PERCENT_DECIMALS } from './constants'; import { shouldShowValuesInLegend } from './render_helpers'; import { @@ -21,8 +21,8 @@ import { PieVisualizationState, EmptySizeRatios, LegendDisplay, -} from '../../common'; -import { getDefaultVisualValuesForLayer } from '../shared_components/datasource_default_values'; +} from '../../../common'; +import { getDefaultVisualValuesForLayer } from '../../shared_components/datasource_default_values'; interface Attributes { isPreview: boolean; diff --git a/x-pack/plugins/lens/public/pie_visualization/toolbar.scss b/x-pack/plugins/lens/public/visualizations/partition/toolbar.scss similarity index 100% rename from x-pack/plugins/lens/public/pie_visualization/toolbar.scss rename to x-pack/plugins/lens/public/visualizations/partition/toolbar.scss diff --git a/x-pack/plugins/lens/public/pie_visualization/toolbar.tsx b/x-pack/plugins/lens/public/visualizations/partition/toolbar.tsx similarity index 98% rename from x-pack/plugins/lens/public/pie_visualization/toolbar.tsx rename to x-pack/plugins/lens/public/visualizations/partition/toolbar.tsx index aa17098cfad5d..e72bc705ae237 100644 --- a/x-pack/plugins/lens/public/pie_visualization/toolbar.tsx +++ b/x-pack/plugins/lens/public/visualizations/partition/toolbar.tsx @@ -21,15 +21,15 @@ import type { PaletteRegistry } from '@kbn/coloring'; import { LegendSize } from '@kbn/visualizations-plugin/public'; import { DEFAULT_PERCENT_DECIMALS } from './constants'; import { PartitionChartsMeta } from './partition_charts_meta'; -import { LegendDisplay, PieVisualizationState, SharedPieLayerState } from '../../common'; -import { VisualizationDimensionEditorProps, VisualizationToolbarProps } from '../types'; +import { LegendDisplay, PieVisualizationState, SharedPieLayerState } from '../../../common'; +import { VisualizationDimensionEditorProps, VisualizationToolbarProps } from '../../types'; import { ToolbarPopover, LegendSettingsPopover, useDebouncedValue, PalettePicker, -} from '../shared_components'; -import { getDefaultVisualValuesForLayer } from '../shared_components/datasource_default_values'; +} from '../../shared_components'; +import { getDefaultVisualValuesForLayer } from '../../shared_components/datasource_default_values'; import { shouldShowValuesInLegend } from './render_helpers'; const legendOptions: Array<{ diff --git a/x-pack/plugins/lens/public/pie_visualization/visualization.test.ts b/x-pack/plugins/lens/public/visualizations/partition/visualization.test.ts similarity index 95% rename from x-pack/plugins/lens/public/pie_visualization/visualization.test.ts rename to x-pack/plugins/lens/public/visualizations/partition/visualization.test.ts index a911b5f0e1ba3..1b46c6eefea58 100644 --- a/x-pack/plugins/lens/public/pie_visualization/visualization.test.ts +++ b/x-pack/plugins/lens/public/visualizations/partition/visualization.test.ts @@ -12,14 +12,14 @@ import { CategoryDisplay, NumberDisplay, LegendDisplay, -} from '../../common'; -import { layerTypes } from '../../common'; +} from '../../../common'; +import { layerTypes } from '../../../common'; import { chartPluginMock } from '@kbn/charts-plugin/public/mocks'; -import { createMockDatasource, createMockFramePublicAPI } from '../mocks'; -import { FramePublicAPI } from '../types'; +import { createMockDatasource, createMockFramePublicAPI } from '../../mocks'; +import { FramePublicAPI } from '../../types'; import { themeServiceMock } from '@kbn/core/public/mocks'; -jest.mock('../id_generator'); +jest.mock('../../id_generator'); const LAYER_ID = 'l1'; diff --git a/x-pack/plugins/lens/public/pie_visualization/visualization.tsx b/x-pack/plugins/lens/public/visualizations/partition/visualization.tsx similarity index 99% rename from x-pack/plugins/lens/public/pie_visualization/visualization.tsx rename to x-pack/plugins/lens/public/visualizations/partition/visualization.tsx index 27961c91c0e95..5e453838aef51 100644 --- a/x-pack/plugins/lens/public/pie_visualization/visualization.tsx +++ b/x-pack/plugins/lens/public/visualizations/partition/visualization.tsx @@ -18,14 +18,14 @@ import type { OperationMetadata, AccessorConfig, VisualizationDimensionGroupConfig, -} from '../types'; +} from '../../types'; import { getSortedGroups, toExpression, toPreviewExpression } from './to_expression'; -import { CategoryDisplay, layerTypes, LegendDisplay, NumberDisplay } from '../../common'; +import { CategoryDisplay, layerTypes, LegendDisplay, NumberDisplay } from '../../../common'; import { suggestions } from './suggestions'; import { PartitionChartsMeta } from './partition_charts_meta'; import { DimensionEditor, PieToolbar } from './toolbar'; import { checkTableForContainsSmallValues } from './render_helpers'; -import { PieChartTypes, PieLayerState, PieVisualizationState } from '../../common'; +import { PieChartTypes, PieLayerState, PieVisualizationState } from '../../../common'; function newLayerState(layerId: string): PieLayerState { return { diff --git a/x-pack/plugins/lens/public/xy_visualization/__snapshots__/to_expression.test.ts.snap b/x-pack/plugins/lens/public/visualizations/xy/__snapshots__/to_expression.test.ts.snap similarity index 100% rename from x-pack/plugins/lens/public/xy_visualization/__snapshots__/to_expression.test.ts.snap rename to x-pack/plugins/lens/public/visualizations/xy/__snapshots__/to_expression.test.ts.snap diff --git a/x-pack/plugins/lens/public/xy_visualization/annotations/helpers.test.ts b/x-pack/plugins/lens/public/visualizations/xy/annotations/helpers.test.ts similarity index 99% rename from x-pack/plugins/lens/public/xy_visualization/annotations/helpers.test.ts rename to x-pack/plugins/lens/public/visualizations/xy/annotations/helpers.test.ts index 1e02f929e90ce..1f923f85ee1be 100644 --- a/x-pack/plugins/lens/public/xy_visualization/annotations/helpers.test.ts +++ b/x-pack/plugins/lens/public/visualizations/xy/annotations/helpers.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { FramePublicAPI } from '../../types'; +import { FramePublicAPI } from '../../../types'; import { getStaticDate } from './helpers'; const frame = { diff --git a/x-pack/plugins/lens/public/xy_visualization/annotations/helpers.tsx b/x-pack/plugins/lens/public/visualizations/xy/annotations/helpers.tsx similarity index 98% rename from x-pack/plugins/lens/public/xy_visualization/annotations/helpers.tsx rename to x-pack/plugins/lens/public/visualizations/xy/annotations/helpers.tsx index 800366a71afea..480417ab2cbad 100644 --- a/x-pack/plugins/lens/public/xy_visualization/annotations/helpers.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/annotations/helpers.tsx @@ -13,8 +13,8 @@ import { isRangeAnnotation, } from '@kbn/event-annotation-plugin/public'; import { EventAnnotationConfig } from '@kbn/event-annotation-plugin/common'; -import { layerTypes } from '../../../common'; -import type { FramePublicAPI, Visualization } from '../../types'; +import { layerTypes } from '../../../../common'; +import type { FramePublicAPI, Visualization } from '../../../types'; import { isHorizontalChart } from '../state_helpers'; import type { XYState, XYDataLayerConfig, XYAnnotationLayerConfig, XYLayerConfig } from '../types'; import { @@ -24,8 +24,8 @@ import { getDataLayers, isAnnotationsLayer, } from '../visualization_helpers'; -import { LensIconChartBarAnnotations } from '../../assets/chart_bar_annotations'; -import { generateId } from '../../id_generator'; +import { LensIconChartBarAnnotations } from '../../../assets/chart_bar_annotations'; +import { generateId } from '../../../id_generator'; const MAX_DATE = 8640000000000000; const MIN_DATE = -8640000000000000; diff --git a/x-pack/plugins/lens/public/xy_visualization/axes_configuration.test.ts b/x-pack/plugins/lens/public/visualizations/xy/axes_configuration.test.ts similarity index 99% rename from x-pack/plugins/lens/public/xy_visualization/axes_configuration.test.ts rename to x-pack/plugins/lens/public/visualizations/xy/axes_configuration.test.ts index 0b14b54f27074..568cd38635acc 100644 --- a/x-pack/plugins/lens/public/xy_visualization/axes_configuration.test.ts +++ b/x-pack/plugins/lens/public/visualizations/xy/axes_configuration.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { layerTypes } from '../../common'; +import { layerTypes } from '../../../common'; import { Datatable } from '@kbn/expressions-plugin/public'; import { getAxesConfiguration } from './axes_configuration'; import { XYDataLayerConfig } from './types'; diff --git a/x-pack/plugins/lens/public/xy_visualization/axes_configuration.ts b/x-pack/plugins/lens/public/visualizations/xy/axes_configuration.ts similarity index 98% rename from x-pack/plugins/lens/public/xy_visualization/axes_configuration.ts rename to x-pack/plugins/lens/public/visualizations/xy/axes_configuration.ts index d33604ea4508d..0c8e829f7dc0c 100644 --- a/x-pack/plugins/lens/public/xy_visualization/axes_configuration.ts +++ b/x-pack/plugins/lens/public/visualizations/xy/axes_configuration.ts @@ -8,12 +8,12 @@ import { AxisExtentConfig } from '@kbn/expression-xy-plugin/common'; import { Datatable } from '@kbn/expressions-plugin/public'; import type { IFieldFormat, SerializedFieldFormat } from '@kbn/field-formats-plugin/common'; -import { FormatFactory } from '../../common'; +import { FormatFactory } from '../../../common'; import { getDataBounds, validateAxisDomain, validateZeroInclusivityExtent, -} from '../shared_components'; +} from '../../shared_components'; import { XYDataLayerConfig } from './types'; interface FormattedMetric { diff --git a/x-pack/plugins/lens/public/xy_visualization/color_assignment.test.ts b/x-pack/plugins/lens/public/visualizations/xy/color_assignment.test.ts similarity index 98% rename from x-pack/plugins/lens/public/xy_visualization/color_assignment.test.ts rename to x-pack/plugins/lens/public/visualizations/xy/color_assignment.test.ts index 666f729ffb79c..b59aadda1fdfa 100644 --- a/x-pack/plugins/lens/public/xy_visualization/color_assignment.test.ts +++ b/x-pack/plugins/lens/public/visualizations/xy/color_assignment.test.ts @@ -6,8 +6,8 @@ */ import { getColorAssignments } from './color_assignment'; -import type { FormatFactory } from '../../common'; -import { layerTypes } from '../../common'; +import type { FormatFactory } from '../../../common'; +import { layerTypes } from '../../../common'; import { XYDataLayerConfig } from './types'; import { Datatable } from '@kbn/expressions-plugin/common'; diff --git a/x-pack/plugins/lens/public/xy_visualization/color_assignment.ts b/x-pack/plugins/lens/public/visualizations/xy/color_assignment.ts similarity index 98% rename from x-pack/plugins/lens/public/xy_visualization/color_assignment.ts rename to x-pack/plugins/lens/public/visualizations/xy/color_assignment.ts index e7853384ec797..4a3dbc94d35ac 100644 --- a/x-pack/plugins/lens/public/xy_visualization/color_assignment.ts +++ b/x-pack/plugins/lens/public/visualizations/xy/color_assignment.ts @@ -14,9 +14,9 @@ import { defaultAnnotationRangeColor, isRangeAnnotation, } from '@kbn/event-annotation-plugin/public'; -import type { AccessorConfig, FramePublicAPI } from '../types'; +import type { AccessorConfig, FramePublicAPI } from '../../types'; import { getColumnToLabelMap } from './state_helpers'; -import { FormatFactory } from '../../common'; +import { FormatFactory } from '../../../common'; import { isDataLayer, isReferenceLayer, isAnnotationsLayer } from './visualization_helpers'; import { getAnnotationsAccessorColorConfig } from './annotations/helpers'; import { diff --git a/x-pack/plugins/lens/public/xy_visualization/index.ts b/x-pack/plugins/lens/public/visualizations/xy/index.ts similarity index 86% rename from x-pack/plugins/lens/public/xy_visualization/index.ts rename to x-pack/plugins/lens/public/visualizations/xy/index.ts index a7de5374c92d1..88a3a4a4ce048 100644 --- a/x-pack/plugins/lens/public/xy_visualization/index.ts +++ b/x-pack/plugins/lens/public/visualizations/xy/index.ts @@ -10,9 +10,9 @@ import { EventAnnotationPluginSetup } from '@kbn/event-annotation-plugin/public' import type { ExpressionsSetup } from '@kbn/expressions-plugin/public'; import type { ChartsPluginSetup } from '@kbn/charts-plugin/public'; import { LEGACY_TIME_AXIS } from '@kbn/charts-plugin/common'; -import type { EditorFrameSetup } from '../types'; -import type { LensPluginStartDependencies } from '../plugin'; -import type { FormatFactory } from '../../common'; +import type { EditorFrameSetup } from '../../types'; +import type { LensPluginStartDependencies } from '../../plugin'; +import type { FormatFactory } from '../../../common'; export interface XyVisualizationPluginSetupPlugins { expressions: ExpressionsSetup; @@ -28,7 +28,7 @@ export class XyVisualization { { editorFrame }: XyVisualizationPluginSetupPlugins ) { editorFrame.registerVisualization(async () => { - const { getXyVisualization } = await import('../async_services'); + const { getXyVisualization } = await import('../../async_services'); const [, { charts, data, fieldFormats, eventAnnotation }] = await core.getStartServices(); const palettes = await charts.palettes.getPalettes(); const eventAnnotationService = await eventAnnotation.getService(); diff --git a/x-pack/plugins/lens/public/xy_visualization/reference_line_helpers.test.ts b/x-pack/plugins/lens/public/visualizations/xy/reference_line_helpers.test.ts similarity index 99% rename from x-pack/plugins/lens/public/xy_visualization/reference_line_helpers.test.ts rename to x-pack/plugins/lens/public/visualizations/xy/reference_line_helpers.test.ts index d83847cb54ca4..61f32b3adfc66 100644 --- a/x-pack/plugins/lens/public/xy_visualization/reference_line_helpers.test.ts +++ b/x-pack/plugins/lens/public/visualizations/xy/reference_line_helpers.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { FramePublicAPI } from '../types'; +import { FramePublicAPI } from '../../types'; import { computeOverallDataDomain, getStaticValue } from './reference_line_helpers'; import { XYDataLayerConfig } from './types'; diff --git a/x-pack/plugins/lens/public/xy_visualization/reference_line_helpers.tsx b/x-pack/plugins/lens/public/visualizations/xy/reference_line_helpers.tsx similarity index 98% rename from x-pack/plugins/lens/public/xy_visualization/reference_line_helpers.tsx rename to x-pack/plugins/lens/public/visualizations/xy/reference_line_helpers.tsx index fb308fc43c24f..293dd8e67db8f 100644 --- a/x-pack/plugins/lens/public/xy_visualization/reference_line_helpers.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/reference_line_helpers.tsx @@ -8,8 +8,8 @@ import { groupBy, partition } from 'lodash'; import { i18n } from '@kbn/i18n'; import { Datatable } from '@kbn/expressions-plugin/public'; -import { layerTypes } from '../../common'; -import type { DatasourceLayers, FramePublicAPI, Visualization } from '../types'; +import { layerTypes } from '../../../common'; +import type { DatasourceLayers, FramePublicAPI, Visualization } from '../../types'; import { groupAxesByType } from './axes_configuration'; import { isHorizontalChart, isPercentageSeries, isStackedChart } from './state_helpers'; import type { @@ -27,8 +27,8 @@ import { isNumericMetric, isReferenceLayer, } from './visualization_helpers'; -import { generateId } from '../id_generator'; -import { LensIconChartBarReferenceLine } from '../assets/chart_bar_reference_line'; +import { generateId } from '../../id_generator'; +import { LensIconChartBarReferenceLine } from '../../assets/chart_bar_reference_line'; import { defaultReferenceLineColor } from './color_assignment'; export interface ReferenceLineBase { diff --git a/x-pack/plugins/lens/public/xy_visualization/state_helpers.ts b/x-pack/plugins/lens/public/visualizations/xy/state_helpers.ts similarity index 97% rename from x-pack/plugins/lens/public/xy_visualization/state_helpers.ts rename to x-pack/plugins/lens/public/visualizations/xy/state_helpers.ts index 975676e241b76..4831c05b12afa 100644 --- a/x-pack/plugins/lens/public/xy_visualization/state_helpers.ts +++ b/x-pack/plugins/lens/public/visualizations/xy/state_helpers.ts @@ -6,7 +6,7 @@ */ import { EuiIconType } from '@elastic/eui/src/components/icon/icon'; -import type { FramePublicAPI, DatasourcePublicAPI } from '../types'; +import type { FramePublicAPI, DatasourcePublicAPI } from '../../types'; import { visualizationTypes, XYLayerConfig, diff --git a/x-pack/plugins/lens/public/xy_visualization/to_expression.test.ts b/x-pack/plugins/lens/public/visualizations/xy/to_expression.test.ts similarity index 99% rename from x-pack/plugins/lens/public/xy_visualization/to_expression.test.ts rename to x-pack/plugins/lens/public/visualizations/xy/to_expression.test.ts index f0a2b9f28623d..02b36d6b27c4f 100644 --- a/x-pack/plugins/lens/public/xy_visualization/to_expression.test.ts +++ b/x-pack/plugins/lens/public/visualizations/xy/to_expression.test.ts @@ -10,9 +10,9 @@ import { Position } from '@elastic/charts'; import { chartPluginMock } from '@kbn/charts-plugin/public/mocks'; import { createDatatableUtilitiesMock } from '@kbn/data-plugin/common/mocks'; import { getXyVisualization } from './xy_visualization'; -import { OperationDescriptor } from '../types'; -import { createMockDatasource, createMockFramePublicAPI } from '../mocks'; -import { layerTypes } from '../../common'; +import { OperationDescriptor } from '../../types'; +import { createMockDatasource, createMockFramePublicAPI } from '../../mocks'; +import { layerTypes } from '../../../common'; import { fieldFormatsServiceMock } from '@kbn/field-formats-plugin/public/mocks'; import { eventAnnotationServiceMock } from '@kbn/event-annotation-plugin/public/mocks'; import { defaultReferenceLineColor } from './color_assignment'; diff --git a/x-pack/plugins/lens/public/xy_visualization/to_expression.ts b/x-pack/plugins/lens/public/visualizations/xy/to_expression.ts similarity index 98% rename from x-pack/plugins/lens/public/xy_visualization/to_expression.ts rename to x-pack/plugins/lens/public/visualizations/xy/to_expression.ts index 6c06891f530e0..491f392c7b6e7 100644 --- a/x-pack/plugins/lens/public/xy_visualization/to_expression.ts +++ b/x-pack/plugins/lens/public/visualizations/xy/to_expression.ts @@ -19,11 +19,11 @@ import { AxisConfig, } from './types'; import type { ValidXYDataLayerConfig } from './types'; -import { OperationMetadata, DatasourcePublicAPI, DatasourceLayers } from '../types'; +import { OperationMetadata, DatasourcePublicAPI, DatasourceLayers } from '../../types'; import { getColumnToLabelMap } from './state_helpers'; import { hasIcon } from './xy_config_panel/shared/icon_select'; import { defaultReferenceLineColor } from './color_assignment'; -import { getDefaultVisualValuesForLayer } from '../shared_components/datasource_default_values'; +import { getDefaultVisualValuesForLayer } from '../../shared_components/datasource_default_values'; import { getLayerTypeOptions, getDataLayers, @@ -31,8 +31,8 @@ import { getAnnotationsLayers, } from './visualization_helpers'; import { getUniqueLabels } from './annotations/helpers'; -import { layerTypes } from '../../common'; -import { axisExtentConfigToExpression } from '../shared_components'; +import { layerTypes } from '../../../common'; +import { axisExtentConfigToExpression } from '../../shared_components'; export const getSortedAccessors = ( datasource: DatasourcePublicAPI, diff --git a/x-pack/plugins/lens/public/xy_visualization/types.ts b/x-pack/plugins/lens/public/visualizations/xy/types.ts similarity index 88% rename from x-pack/plugins/lens/public/xy_visualization/types.ts rename to x-pack/plugins/lens/public/visualizations/xy/types.ts index 58c4cfb7e26c4..c2ca25c61c42e 100644 --- a/x-pack/plugins/lens/public/xy_visualization/types.ts +++ b/x-pack/plugins/lens/public/visualizations/xy/types.ts @@ -22,19 +22,19 @@ import type { YAxisConfig, } from '@kbn/expression-xy-plugin/common'; import { EventAnnotationConfig } from '@kbn/event-annotation-plugin/common'; -import { LensIconChartArea } from '../assets/chart_area'; -import { LensIconChartAreaStacked } from '../assets/chart_area_stacked'; -import { LensIconChartAreaPercentage } from '../assets/chart_area_percentage'; -import { LensIconChartBar } from '../assets/chart_bar'; -import { LensIconChartBarStacked } from '../assets/chart_bar_stacked'; -import { LensIconChartBarPercentage } from '../assets/chart_bar_percentage'; -import { LensIconChartBarHorizontal } from '../assets/chart_bar_horizontal'; -import { LensIconChartBarHorizontalStacked } from '../assets/chart_bar_horizontal_stacked'; -import { LensIconChartBarHorizontalPercentage } from '../assets/chart_bar_horizontal_percentage'; -import { LensIconChartLine } from '../assets/chart_line'; +import { LensIconChartArea } from '../../assets/chart_area'; +import { LensIconChartAreaStacked } from '../../assets/chart_area_stacked'; +import { LensIconChartAreaPercentage } from '../../assets/chart_area_percentage'; +import { LensIconChartBar } from '../../assets/chart_bar'; +import { LensIconChartBarStacked } from '../../assets/chart_bar_stacked'; +import { LensIconChartBarPercentage } from '../../assets/chart_bar_percentage'; +import { LensIconChartBarHorizontal } from '../../assets/chart_bar_horizontal'; +import { LensIconChartBarHorizontalStacked } from '../../assets/chart_bar_horizontal_stacked'; +import { LensIconChartBarHorizontalPercentage } from '../../assets/chart_bar_horizontal_percentage'; +import { LensIconChartLine } from '../../assets/chart_line'; -import type { VisualizationType, Suggestion } from '../types'; -import type { ValueLabelConfig } from '../../common/types'; +import type { VisualizationType, Suggestion } from '../../types'; +import type { ValueLabelConfig } from '../../../common/types'; export const YAxisModes = { AUTO: 'auto', diff --git a/x-pack/plugins/lens/public/xy_visualization/visualization.test.ts b/x-pack/plugins/lens/public/visualizations/xy/visualization.test.ts similarity index 99% rename from x-pack/plugins/lens/public/xy_visualization/visualization.test.ts rename to x-pack/plugins/lens/public/visualizations/xy/visualization.test.ts index 397bbb25d8c9d..a9848561ecded 100644 --- a/x-pack/plugins/lens/public/xy_visualization/visualization.test.ts +++ b/x-pack/plugins/lens/public/visualizations/xy/visualization.test.ts @@ -7,7 +7,7 @@ import { getXyVisualization } from './visualization'; import { Position } from '@elastic/charts'; -import { Operation, VisualizeEditorContext, Suggestion, OperationDescriptor } from '../types'; +import { Operation, VisualizeEditorContext, Suggestion, OperationDescriptor } from '../../types'; import type { State, XYState, @@ -18,9 +18,9 @@ import type { SeriesType, } from './types'; import { createDatatableUtilitiesMock } from '@kbn/data-plugin/common/mocks'; -import { layerTypes } from '../../common'; -import { createMockDatasource, createMockFramePublicAPI } from '../mocks'; -import { LensIconChartBar } from '../assets/chart_bar'; +import { layerTypes } from '../../../common'; +import { createMockDatasource, createMockFramePublicAPI } from '../../mocks'; +import { LensIconChartBar } from '../../assets/chart_bar'; import type { VisualizeEditorLayersContext } from '@kbn/visualizations-plugin/public'; import { chartPluginMock } from '@kbn/charts-plugin/public/mocks'; import { fieldFormatsServiceMock } from '@kbn/field-formats-plugin/public/mocks'; diff --git a/x-pack/plugins/lens/public/xy_visualization/visualization.tsx b/x-pack/plugins/lens/public/visualizations/xy/visualization.tsx similarity index 98% rename from x-pack/plugins/lens/public/xy_visualization/visualization.tsx rename to x-pack/plugins/lens/public/visualizations/xy/visualization.tsx index f49e44b678457..f5d241738dd4e 100644 --- a/x-pack/plugins/lens/public/xy_visualization/visualization.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/visualization.tsx @@ -22,7 +22,7 @@ import { getSuggestions } from './xy_suggestions'; import { XyToolbar } from './xy_config_panel'; import { DimensionEditor } from './xy_config_panel/dimension_editor'; import { LayerHeader } from './xy_config_panel/layer_header'; -import type { Visualization, AccessorConfig, FramePublicAPI } from '../types'; +import type { Visualization, AccessorConfig, FramePublicAPI } from '../../types'; import { State, visualizationTypes, @@ -33,7 +33,7 @@ import { YAxisMode, SeriesType, } from './types'; -import { layerTypes } from '../../common'; +import { layerTypes } from '../../../common'; import { isHorizontalChart } from './state_helpers'; import { toExpression, toPreviewExpression, getSortedAccessors } from './to_expression'; import { getAccessorColorConfigs, getColorAssignments } from './color_assignment'; @@ -74,9 +74,9 @@ import { groupAxesByType } from './axes_configuration'; import { XYState } from './types'; import { ReferenceLinePanel } from './xy_config_panel/reference_line_config_panel'; import { AnnotationsPanel } from './xy_config_panel/annotations_config_panel'; -import { DimensionTrigger } from '../shared_components/dimension_trigger'; +import { DimensionTrigger } from '../../shared_components/dimension_trigger'; import { defaultAnnotationLabel } from './annotations/helpers'; -import { onDropForVisualization } from '../editor_frame_service/editor_frame/config_panel/buttons/drop_targets_utils'; +import { onDropForVisualization } from '../../editor_frame_service/editor_frame/config_panel/buttons/drop_targets_utils'; export const getXyVisualization = ({ datatableUtilities, diff --git a/x-pack/plugins/lens/public/xy_visualization/visualization_helpers.tsx b/x-pack/plugins/lens/public/visualizations/xy/visualization_helpers.tsx similarity index 97% rename from x-pack/plugins/lens/public/xy_visualization/visualization_helpers.tsx rename to x-pack/plugins/lens/public/visualizations/xy/visualization_helpers.tsx index e89edab464bfd..c36916f7f0306 100644 --- a/x-pack/plugins/lens/public/xy_visualization/visualization_helpers.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/visualization_helpers.tsx @@ -7,7 +7,7 @@ import { i18n } from '@kbn/i18n'; import { uniq } from 'lodash'; -import { DatasourceLayers, OperationMetadata, VisualizationType } from '../types'; +import { DatasourceLayers, OperationMetadata, VisualizationType } from '../../types'; import { State, visualizationTypes, @@ -19,11 +19,11 @@ import { SeriesType, } from './types'; import { isHorizontalChart } from './state_helpers'; -import { layerTypes } from '..'; -import { LensIconChartBarHorizontal } from '../assets/chart_bar_horizontal'; -import { LensIconChartMixedXy } from '../assets/chart_mixed_xy'; -import { LensIconChartBarStacked } from '../assets/chart_bar_stacked'; -import { LayerType } from '../../common'; +import { layerTypes } from '../..'; +import { LensIconChartBarHorizontal } from '../../assets/chart_bar_horizontal'; +import { LensIconChartMixedXy } from '../../assets/chart_mixed_xy'; +import { LensIconChartBarStacked } from '../../assets/chart_bar_stacked'; +import { LayerType } from '../../../common'; export function getAxisName( axis: 'x' | 'y' | 'yLeft' | 'yRight', diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/annotations_config_panel/annotations_panel.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/annotations_config_panel/annotations_panel.tsx similarity index 98% rename from x-pack/plugins/lens/public/xy_visualization/xy_config_panel/annotations_config_panel/annotations_panel.tsx rename to x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/annotations_config_panel/annotations_panel.tsx index 5d6a807a262b3..6c6a425c14096 100644 --- a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/annotations_config_panel/annotations_panel.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/annotations_config_panel/annotations_panel.tsx @@ -36,8 +36,12 @@ import { } from '@kbn/event-annotation-plugin/public'; import Color from 'color'; import { getDataLayers } from '../../visualization_helpers'; -import { FormatFactory } from '../../../../common'; -import { DimensionEditorSection, NameInput, useDebouncedValue } from '../../../shared_components'; +import { FormatFactory } from '../../../../../common'; +import { + DimensionEditorSection, + NameInput, + useDebouncedValue, +} from '../../../../shared_components'; import { isHorizontalChart } from '../../state_helpers'; import { defaultAnnotationLabel, defaultRangeAnnotationLabel } from '../../annotations/helpers'; import { ColorPicker } from '../color_picker'; @@ -45,7 +49,7 @@ import { IconSelectSetting, TextDecorationSetting } from '../shared/marker_decor import { LineStyleSettings } from '../shared/line_style_settings'; import { updateLayer } from '..'; import { annotationsIconSet } from './icon_set'; -import type { FramePublicAPI, VisualizationDimensionEditorProps } from '../../../types'; +import type { FramePublicAPI, VisualizationDimensionEditorProps } from '../../../../types'; import { State, XYState, XYAnnotationLayerConfig, XYDataLayerConfig } from '../../types'; export const toRangeAnnotationColor = (color = defaultAnnotationColor) => { diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/annotations_config_panel/icon_set.ts b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/annotations_config_panel/icon_set.ts similarity index 97% rename from x-pack/plugins/lens/public/xy_visualization/xy_config_panel/annotations_config_panel/icon_set.ts rename to x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/annotations_config_panel/icon_set.ts index 32721285a4477..80cf7eccc9622 100644 --- a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/annotations_config_panel/icon_set.ts +++ b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/annotations_config_panel/icon_set.ts @@ -7,7 +7,7 @@ import { i18n } from '@kbn/i18n'; import { AvailableAnnotationIcon } from '@kbn/event-annotation-plugin/common'; -import { IconTriangle, IconCircle } from '../../../assets/annotation_icons'; +import { IconTriangle, IconCircle } from '../../../../assets/annotation_icons'; import { IconSet } from '../shared/icon_select'; export const annotationsIconSet: IconSet = [ diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/annotations_config_panel/index.scss b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/annotations_config_panel/index.scss similarity index 100% rename from x-pack/plugins/lens/public/xy_visualization/xy_config_panel/annotations_config_panel/index.scss rename to x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/annotations_config_panel/index.scss diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/annotations_config_panel/index.test.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/annotations_config_panel/index.test.tsx similarity index 97% rename from x-pack/plugins/lens/public/xy_visualization/xy_config_panel/annotations_config_panel/index.test.tsx rename to x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/annotations_config_panel/index.test.tsx index 40d367072d1ef..330fbf1f55da6 100644 --- a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/annotations_config_panel/index.test.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/annotations_config_panel/index.test.tsx @@ -9,9 +9,9 @@ import React from 'react'; import { mountWithIntl as mount } from '@kbn/test-jest-helpers'; import { createDatatableUtilitiesMock } from '@kbn/data-plugin/common/mocks'; import { AnnotationsPanel } from '.'; -import { FramePublicAPI } from '../../../types'; -import { layerTypes } from '../../..'; -import { createMockFramePublicAPI } from '../../../mocks'; +import { FramePublicAPI } from '../../../../types'; +import { layerTypes } from '../../../..'; +import { createMockFramePublicAPI } from '../../../../mocks'; import { State } from '../../types'; import { Position } from '@elastic/charts'; import { chartPluginMock } from '@kbn/charts-plugin/public/mocks'; diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/annotations_config_panel/index.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/annotations_config_panel/index.tsx similarity index 100% rename from x-pack/plugins/lens/public/xy_visualization/xy_config_panel/annotations_config_panel/index.tsx rename to x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/annotations_config_panel/index.tsx diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/axis_settings_popover.scss b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/axis_settings_popover.scss similarity index 100% rename from x-pack/plugins/lens/public/xy_visualization/xy_config_panel/axis_settings_popover.scss rename to x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/axis_settings_popover.scss diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/axis_settings_popover.test.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/axis_settings_popover.test.tsx similarity index 98% rename from x-pack/plugins/lens/public/xy_visualization/xy_config_panel/axis_settings_popover.test.tsx rename to x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/axis_settings_popover.test.tsx index 692aa25845b6e..3589e0ff23d80 100644 --- a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/axis_settings_popover.test.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/axis_settings_popover.test.tsx @@ -8,8 +8,8 @@ import React from 'react'; import { shallowWithIntl as shallow } from '@kbn/test-jest-helpers'; import { AxisSettingsPopover, AxisSettingsPopoverProps } from './axis_settings_popover'; -import { ToolbarPopover } from '../../shared_components'; -import { layerTypes } from '../../../common'; +import { ToolbarPopover } from '../../../shared_components'; +import { layerTypes } from '../../../../common'; import { ShallowWrapper } from 'enzyme'; function getRangeInputComponent(component: ShallowWrapper) { diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/axis_settings_popover.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/axis_settings_popover.tsx similarity index 98% rename from x-pack/plugins/lens/public/xy_visualization/xy_config_panel/axis_settings_popover.tsx rename to x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/axis_settings_popover.tsx index 263a9131e1296..65d7b94281486 100644 --- a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/axis_settings_popover.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/axis_settings_popover.tsx @@ -25,12 +25,12 @@ import { AxisTitleSettings, RangeInputField, BucketAxisBoundsControl, -} from '../../shared_components'; +} from '../../../shared_components'; import { isHorizontalChart } from '../state_helpers'; -import { EuiIconAxisBottom } from '../../assets/axis_bottom'; -import { EuiIconAxisLeft } from '../../assets/axis_left'; -import { EuiIconAxisRight } from '../../assets/axis_right'; -import { EuiIconAxisTop } from '../../assets/axis_top'; +import { EuiIconAxisBottom } from '../../../assets/axis_bottom'; +import { EuiIconAxisLeft } from '../../../assets/axis_left'; +import { EuiIconAxisRight } from '../../../assets/axis_right'; +import { EuiIconAxisTop } from '../../../assets/axis_top'; import { validateExtent } from '../axes_configuration'; import './axis_settings_popover.scss'; diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/color_picker.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/color_picker.tsx similarity index 98% rename from x-pack/plugins/lens/public/xy_visualization/xy_config_panel/color_picker.tsx rename to x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/color_picker.tsx index 2f3b00befc2d4..2d0b28f4fac9a 100644 --- a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/color_picker.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/color_picker.tsx @@ -16,7 +16,7 @@ import { EuiIcon, euiPaletteColorBlind, } from '@elastic/eui'; -import { TooltipWrapper } from '../../shared_components'; +import { TooltipWrapper } from '../../../shared_components'; const tooltipContent = { auto: i18n.translate('xpack.lens.configPanel.color.tooltip.auto', { diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/dimension_editor.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/dimension_editor.tsx similarity index 96% rename from x-pack/plugins/lens/public/xy_visualization/xy_config_panel/dimension_editor.tsx rename to x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/dimension_editor.tsx index 4e3e23c4b1da7..3c0c2239aaf2c 100644 --- a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/dimension_editor.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/dimension_editor.tsx @@ -10,16 +10,16 @@ import { i18n } from '@kbn/i18n'; import { EuiButtonGroup, EuiFormRow, htmlIdGenerator } from '@elastic/eui'; import type { PaletteRegistry } from '@kbn/coloring'; import type { DatatableUtilitiesService } from '@kbn/data-plugin/common'; -import type { VisualizationDimensionEditorProps } from '../../types'; +import type { VisualizationDimensionEditorProps } from '../../../types'; import { State, XYState, XYDataLayerConfig, YConfig, YAxisMode } from '../types'; -import { FormatFactory } from '../../../common'; +import { FormatFactory } from '../../../../common'; import { getSeriesColor, isHorizontalChart } from '../state_helpers'; import { ColorPicker } from './color_picker'; -import { PalettePicker, useDebouncedValue } from '../../shared_components'; +import { PalettePicker, useDebouncedValue } from '../../../shared_components'; import { getDataLayers, isAnnotationsLayer, isReferenceLayer } from '../visualization_helpers'; import { ReferenceLinePanel } from './reference_line_config_panel'; import { AnnotationsPanel } from './annotations_config_panel'; -import { CollapseSetting } from '../../shared_components/collapse_setting'; +import { CollapseSetting } from '../../../shared_components/collapse_setting'; import { getSortedAccessors } from '../to_expression'; import { getColorAssignments, getAssignedColorConfig } from '../color_assignment'; diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/index.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/index.tsx similarity index 98% rename from x-pack/plugins/lens/public/xy_visualization/xy_config_panel/index.tsx rename to x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/index.tsx index 4a160cf34240c..d771edd9f10d9 100644 --- a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/index.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/index.tsx @@ -11,18 +11,18 @@ import { Position, ScaleType } from '@elastic/charts'; import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import { AxisExtentConfig } from '@kbn/expression-xy-plugin/common'; import { LegendSize } from '@kbn/visualizations-plugin/public'; -import type { VisualizationToolbarProps, FramePublicAPI } from '../../types'; +import type { VisualizationToolbarProps, FramePublicAPI } from '../../../types'; import { State, XYState, AxesSettingsConfig } from '../types'; import { isHorizontalChart } from '../state_helpers'; -import { hasNumericHistogramDimension, LegendSettingsPopover } from '../../shared_components'; +import { hasNumericHistogramDimension, LegendSettingsPopover } from '../../../shared_components'; import { AxisSettingsPopover } from './axis_settings_popover'; import { getAxesConfiguration, getXDomain, GroupsConfiguration } from '../axes_configuration'; import { VisualOptionsPopover } from './visual_options_popover'; import { getScaleType } from '../to_expression'; -import { TooltipWrapper } from '../../shared_components'; -import { getDefaultVisualValuesForLayer } from '../../shared_components/datasource_default_values'; +import { TooltipWrapper } from '../../../shared_components'; +import { getDefaultVisualValuesForLayer } from '../../../shared_components/datasource_default_values'; import { getDataLayers } from '../visualization_helpers'; -import { LegendSettingsPopoverProps } from '../../shared_components/legend_settings_popover'; +import { LegendSettingsPopoverProps } from '../../../shared_components/legend_settings_popover'; type UnwrapArray = T extends Array ? P : T; type AxesSettingsConfigKeys = keyof AxesSettingsConfig; diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/layer_header.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/layer_header.tsx similarity index 94% rename from x-pack/plugins/lens/public/xy_visualization/xy_config_panel/layer_header.tsx rename to x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/layer_header.tsx index d5523a0b10914..44d9f342cfcd7 100644 --- a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/layer_header.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/layer_header.tsx @@ -9,12 +9,12 @@ import React, { useState } from 'react'; import { i18n } from '@kbn/i18n'; import { EuiIcon, EuiPopover, EuiSelectable, EuiText, EuiPopoverTitle } from '@elastic/eui'; import { ToolbarButton } from '@kbn/kibana-react-plugin/public'; -import type { VisualizationLayerWidgetProps, VisualizationType } from '../../types'; +import type { VisualizationLayerWidgetProps, VisualizationType } from '../../../types'; import { State, visualizationTypes, SeriesType } from '../types'; import { isHorizontalChart, isHorizontalSeries } from '../state_helpers'; -import { StaticHeader } from '../../shared_components'; -import { LensIconChartBarReferenceLine } from '../../assets/chart_bar_reference_line'; -import { LensIconChartBarAnnotations } from '../../assets/chart_bar_annotations'; +import { StaticHeader } from '../../../shared_components'; +import { LensIconChartBarReferenceLine } from '../../../assets/chart_bar_reference_line'; +import { LensIconChartBarAnnotations } from '../../../assets/chart_bar_annotations'; import { updateLayer } from '.'; import { isAnnotationsLayer, isDataLayer, isReferenceLayer } from '../visualization_helpers'; diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/reference_line_config_panel/icon_set.ts b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/reference_line_config_panel/icon_set.ts similarity index 100% rename from x-pack/plugins/lens/public/xy_visualization/xy_config_panel/reference_line_config_panel/icon_set.ts rename to x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/reference_line_config_panel/icon_set.ts diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/reference_line_config_panel/index.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/reference_line_config_panel/index.tsx similarity index 100% rename from x-pack/plugins/lens/public/xy_visualization/xy_config_panel/reference_line_config_panel/index.tsx rename to x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/reference_line_config_panel/index.tsx diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/reference_line_config_panel/reference_line_panel.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/reference_line_config_panel/reference_line_panel.tsx similarity index 97% rename from x-pack/plugins/lens/public/xy_visualization/xy_config_panel/reference_line_config_panel/reference_line_panel.tsx rename to x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/reference_line_config_panel/reference_line_panel.tsx index fd4cad44c3244..a64e9b07f488b 100644 --- a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/reference_line_config_panel/reference_line_panel.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/reference_line_config_panel/reference_line_panel.tsx @@ -10,13 +10,13 @@ import { i18n } from '@kbn/i18n'; import { EuiButtonGroup, EuiFormRow } from '@elastic/eui'; import type { PaletteRegistry } from '@kbn/coloring'; import { FillStyle } from '@kbn/expression-xy-plugin/common'; -import type { VisualizationDimensionEditorProps } from '../../../types'; +import type { VisualizationDimensionEditorProps } from '../../../../types'; import { State, XYState, XYReferenceLineLayerConfig, YConfig } from '../../types'; -import { FormatFactory } from '../../../../common'; +import { FormatFactory } from '../../../../../common'; import { ColorPicker } from '../color_picker'; import { updateLayer } from '..'; -import { useDebouncedValue } from '../../../shared_components'; +import { useDebouncedValue } from '../../../../shared_components'; import { idPrefix } from '../dimension_editor'; import { isHorizontalChart } from '../../state_helpers'; import { diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/shared/icon_select.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/shared/icon_select.tsx similarity index 100% rename from x-pack/plugins/lens/public/xy_visualization/xy_config_panel/shared/icon_select.tsx rename to x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/shared/icon_select.tsx diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/shared/line_style_settings.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/shared/line_style_settings.tsx similarity index 100% rename from x-pack/plugins/lens/public/xy_visualization/xy_config_panel/shared/line_style_settings.tsx rename to x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/shared/line_style_settings.tsx diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/shared/marker_decoration_settings.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/shared/marker_decoration_settings.tsx similarity index 99% rename from x-pack/plugins/lens/public/xy_visualization/xy_config_panel/shared/marker_decoration_settings.tsx rename to x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/shared/marker_decoration_settings.tsx index 561e336400a37..e11c69f766a32 100644 --- a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/shared/marker_decoration_settings.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/shared/marker_decoration_settings.tsx @@ -11,7 +11,7 @@ import { EuiButtonGroup, EuiFormRow } from '@elastic/eui'; import { IconPosition } from '@kbn/expression-xy-plugin/common'; import { YAxisMode } from '../../types'; -import { TooltipWrapper } from '../../../shared_components'; +import { TooltipWrapper } from '../../../../shared_components'; import { hasIcon, IconSelect, IconSet } from './icon_select'; import { idPrefix } from '../dimension_editor'; diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/end_value_definitions.ts b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/visual_options_popover/end_value_definitions.ts similarity index 100% rename from x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/end_value_definitions.ts rename to x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/visual_options_popover/end_value_definitions.ts diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/fill_opacity_option.test.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/visual_options_popover/fill_opacity_option.test.tsx similarity index 100% rename from x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/fill_opacity_option.test.tsx rename to x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/visual_options_popover/fill_opacity_option.test.tsx diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/fill_opacity_option.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/visual_options_popover/fill_opacity_option.tsx similarity index 95% rename from x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/fill_opacity_option.tsx rename to x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/visual_options_popover/fill_opacity_option.tsx index 09b381dd03f7a..236fc4c9eec7f 100644 --- a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/fill_opacity_option.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/visual_options_popover/fill_opacity_option.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { EuiFormRow, EuiRange } from '@elastic/eui'; -import { useDebouncedValue } from '../../../shared_components'; +import { useDebouncedValue } from '../../../../shared_components'; export interface FillOpacityOptionProps { /** diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/fitting_function_definitions.ts b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/visual_options_popover/fitting_function_definitions.ts similarity index 100% rename from x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/fitting_function_definitions.ts rename to x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/visual_options_popover/fitting_function_definitions.ts diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/index.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/visual_options_popover/index.tsx similarity index 97% rename from x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/index.tsx rename to x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/visual_options_popover/index.tsx index ba8a246043bf2..dc621b8b236e0 100644 --- a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/index.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/visual_options_popover/index.tsx @@ -7,13 +7,13 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; -import { ToolbarPopover, TooltipWrapper, ValueLabelsSettings } from '../../../shared_components'; +import { ToolbarPopover, TooltipWrapper, ValueLabelsSettings } from '../../../../shared_components'; import { MissingValuesOptions } from './missing_values_option'; import { LineCurveOption } from './line_curve_option'; import { FillOpacityOption } from './fill_opacity_option'; import { XYState } from '../../types'; import { hasHistogramSeries } from '../../state_helpers'; -import type { FramePublicAPI } from '../../../types'; +import type { FramePublicAPI } from '../../../../types'; import { getDataLayers } from '../../visualization_helpers'; function getValueLabelDisableReason({ diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/line_curve_option.test.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/visual_options_popover/line_curve_option.test.tsx similarity index 100% rename from x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/line_curve_option.test.tsx rename to x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/visual_options_popover/line_curve_option.test.tsx diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/line_curve_option.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/visual_options_popover/line_curve_option.tsx similarity index 100% rename from x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/line_curve_option.tsx rename to x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/visual_options_popover/line_curve_option.tsx diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/missing_value_option.test.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/visual_options_popover/missing_value_option.test.tsx similarity index 100% rename from x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/missing_value_option.test.tsx rename to x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/visual_options_popover/missing_value_option.test.tsx diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/missing_values_option.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/visual_options_popover/missing_values_option.tsx similarity index 100% rename from x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/missing_values_option.tsx rename to x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/visual_options_popover/missing_values_option.tsx diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/visual_options_popover.test.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/visual_options_popover/visual_options_popover.test.tsx similarity index 97% rename from x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/visual_options_popover.test.tsx rename to x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/visual_options_popover/visual_options_popover.test.tsx index 5b91ee70c6945..f48b8710d26d2 100644 --- a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/visual_options_popover.test.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/visual_options_popover/visual_options_popover.test.tsx @@ -8,14 +8,14 @@ import React from 'react'; import { shallowWithIntl as shallow } from '@kbn/test-jest-helpers'; import { Position } from '@elastic/charts'; -import type { FramePublicAPI } from '../../../types'; -import { createMockDatasource, createMockFramePublicAPI } from '../../../mocks'; +import type { FramePublicAPI } from '../../../../types'; +import { createMockDatasource, createMockFramePublicAPI } from '../../../../mocks'; import { State, XYLayerConfig } from '../../types'; import { VisualOptionsPopover } from '.'; -import { ToolbarPopover, ValueLabelsSettings } from '../../../shared_components'; +import { ToolbarPopover, ValueLabelsSettings } from '../../../../shared_components'; import { MissingValuesOptions } from './missing_values_option'; import { FillOpacityOption } from './fill_opacity_option'; -import { layerTypes } from '../../../../common'; +import { layerTypes } from '../../../../../common'; describe('Visual options popover', () => { let frame: FramePublicAPI; diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/xy_config_panel.test.tsx b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/xy_config_panel.test.tsx similarity index 99% rename from x-pack/plugins/lens/public/xy_visualization/xy_config_panel/xy_config_panel.test.tsx rename to x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/xy_config_panel.test.tsx index f28e932ae2ca5..83a14812b606f 100644 --- a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/xy_config_panel.test.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/xy_config_panel/xy_config_panel.test.tsx @@ -12,13 +12,13 @@ import { createDatatableUtilitiesMock } from '@kbn/data-plugin/common/mocks'; import { XyToolbar } from '.'; import { DimensionEditor } from './dimension_editor'; import { AxisSettingsPopover } from './axis_settings_popover'; -import { FramePublicAPI } from '../../types'; +import { FramePublicAPI } from '../../../types'; import { State, XYState, XYDataLayerConfig } from '../types'; import { Position } from '@elastic/charts'; -import { createMockFramePublicAPI, createMockDatasource } from '../../mocks'; +import { createMockFramePublicAPI, createMockDatasource } from '../../../mocks'; import { chartPluginMock } from '@kbn/charts-plugin/public/mocks'; import { EuiColorPicker } from '@elastic/eui'; -import { layerTypes } from '../../../common'; +import { layerTypes } from '../../../../common'; import { act } from 'react-dom/test-utils'; jest.mock('lodash', () => { diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_suggestions.test.ts b/x-pack/plugins/lens/public/visualizations/xy/xy_suggestions.test.ts similarity index 99% rename from x-pack/plugins/lens/public/xy_visualization/xy_suggestions.test.ts rename to x-pack/plugins/lens/public/visualizations/xy/xy_suggestions.test.ts index 14750dd34a127..52039d68a9fee 100644 --- a/x-pack/plugins/lens/public/xy_visualization/xy_suggestions.test.ts +++ b/x-pack/plugins/lens/public/visualizations/xy/xy_suggestions.test.ts @@ -6,7 +6,7 @@ */ import { getSuggestions } from './xy_suggestions'; -import type { TableSuggestionColumn, VisualizationSuggestion, TableSuggestion } from '../types'; +import type { TableSuggestionColumn, VisualizationSuggestion, TableSuggestion } from '../../types'; import { State, XYState, @@ -14,17 +14,17 @@ import { XYAnnotationLayerConfig, XYDataLayerConfig, } from './types'; -import { generateId } from '../id_generator'; +import { generateId } from '../../id_generator'; import { getXyVisualization } from './xy_visualization'; import { chartPluginMock } from '@kbn/charts-plugin/public/mocks'; import { createDatatableUtilitiesMock } from '@kbn/data-plugin/common/mocks'; import { eventAnnotationServiceMock } from '@kbn/event-annotation-plugin/public/mocks'; import type { PaletteOutput } from '@kbn/coloring'; -import { layerTypes } from '../../common'; +import { layerTypes } from '../../../common'; import { fieldFormatsServiceMock } from '@kbn/field-formats-plugin/public/mocks'; import { themeServiceMock } from '@kbn/core/public/mocks'; -jest.mock('../id_generator'); +jest.mock('../../id_generator'); const xyVisualization = getXyVisualization({ datatableUtilities: createDatatableUtilitiesMock(), diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_suggestions.ts b/x-pack/plugins/lens/public/visualizations/xy/xy_suggestions.ts similarity index 99% rename from x-pack/plugins/lens/public/xy_visualization/xy_suggestions.ts rename to x-pack/plugins/lens/public/visualizations/xy/xy_suggestions.ts index ca42aabe616b6..7ae9374f0de98 100644 --- a/x-pack/plugins/lens/public/xy_visualization/xy_suggestions.ts +++ b/x-pack/plugins/lens/public/visualizations/xy/xy_suggestions.ts @@ -15,7 +15,7 @@ import { TableSuggestionColumn, TableSuggestion, TableChangeType, -} from '../types'; +} from '../../types'; import { State, XYState, @@ -24,7 +24,7 @@ import { XYDataLayerConfig, SeriesType, } from './types'; -import { layerTypes } from '../../common'; +import { layerTypes } from '../../../common'; import { getIconForSeries } from './state_helpers'; import { getDataLayers, isDataLayer } from './visualization_helpers'; diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_visualization.ts b/x-pack/plugins/lens/public/visualizations/xy/xy_visualization.ts similarity index 100% rename from x-pack/plugins/lens/public/xy_visualization/xy_visualization.ts rename to x-pack/plugins/lens/public/visualizations/xy/xy_visualization.ts From 19749ded870e15e90556eeb948cc279cc4d70326 Mon Sep 17 00:00:00 2001 From: Gloria Hornero Date: Thu, 4 Aug 2022 13:47:50 +0200 Subject: [PATCH 3/8] [Security Solution] Removes flakiness from Inspect tests (#137959) Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../security_solution/cypress/integration/hosts/inspect.spec.ts | 2 -- .../cypress/integration/network/inspect.spec.ts | 2 -- 2 files changed, 4 deletions(-) diff --git a/x-pack/plugins/security_solution/cypress/integration/hosts/inspect.spec.ts b/x-pack/plugins/security_solution/cypress/integration/hosts/inspect.spec.ts index 892fc1eb4c7f3..8246222f5598d 100644 --- a/x-pack/plugins/security_solution/cypress/integration/hosts/inspect.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/hosts/inspect.spec.ts @@ -13,7 +13,6 @@ import { clickInspectButton, closesModal, openStatsAndTables } from '../../tasks import { login, visit, visitHostDetailsPage } from '../../tasks/login'; import { HOSTS_URL } from '../../urls/navigation'; -import { waitForPageToBeLoaded } from '../../tasks/common'; describe('Inspect', () => { before(() => { @@ -22,7 +21,6 @@ describe('Inspect', () => { context('Hosts stats and tables', () => { before(() => { visit(HOSTS_URL); - waitForPageToBeLoaded(); }); afterEach(() => { closesModal(); diff --git a/x-pack/plugins/security_solution/cypress/integration/network/inspect.spec.ts b/x-pack/plugins/security_solution/cypress/integration/network/inspect.spec.ts index 58ba46616cdac..c54072799b290 100644 --- a/x-pack/plugins/security_solution/cypress/integration/network/inspect.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/network/inspect.spec.ts @@ -6,7 +6,6 @@ */ import { INSPECT_MODAL, INSPECT_NETWORK_BUTTONS_IN_SECURITY } from '../../screens/inspect'; -import { waitForPageToBeLoaded } from '../../tasks/common'; import { closesModal, openStatsAndTables } from '../../tasks/inspect'; import { login, visit } from '../../tasks/login'; @@ -18,7 +17,6 @@ describe('Inspect', () => { before(() => { login(); visit(NETWORK_URL); - waitForPageToBeLoaded(); }); afterEach(() => { closesModal(); From 025f6f3ccd11b4dd12dfa6fd252207f289b08ce8 Mon Sep 17 00:00:00 2001 From: Daniel Ferullo <56368752+ferullo@users.noreply.github.com> Date: Thu, 4 Aug 2022 08:10:14 -0400 Subject: [PATCH 4/8] rename remediate to self_healing (#137774) --- .../common/endpoint/models/policy_config.ts | 2 +- .../security_solution/common/endpoint/types/index.ts | 2 +- .../security_solution/common/license/policy_config.test.ts | 6 +++--- .../security_solution/common/license/policy_config.ts | 4 ++-- .../pages/policy/models/advanced_policy_schema.ts | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/x-pack/plugins/security_solution/common/endpoint/models/policy_config.ts b/x-pack/plugins/security_solution/common/endpoint/models/policy_config.ts index a6e40325cac4e..3ae8c8f6d0644 100644 --- a/x-pack/plugins/security_solution/common/endpoint/models/policy_config.ts +++ b/x-pack/plugins/security_solution/common/endpoint/models/policy_config.ts @@ -153,7 +153,7 @@ export const policyFactoryWithoutPaidFeatures = ( ): PolicyConfig => { const rollbackConfig = { rollback: { - remediation: { + self_healing: { enabled: false, }, }, diff --git a/x-pack/plugins/security_solution/common/endpoint/types/index.ts b/x-pack/plugins/security_solution/common/endpoint/types/index.ts index 2f66b9848fb9f..6e72d411768e5 100644 --- a/x-pack/plugins/security_solution/common/endpoint/types/index.ts +++ b/x-pack/plugins/security_solution/common/endpoint/types/index.ts @@ -923,7 +923,7 @@ export interface PolicyConfig { alerts?: { [key: string]: unknown; rollback: { - remediation: { + self_healing: { enabled: boolean; }; }; diff --git a/x-pack/plugins/security_solution/common/license/policy_config.test.ts b/x-pack/plugins/security_solution/common/license/policy_config.test.ts index 97e18399cd260..d0066eeb051a8 100644 --- a/x-pack/plugins/security_solution/common/license/policy_config.test.ts +++ b/x-pack/plugins/security_solution/common/license/policy_config.test.ts @@ -125,14 +125,14 @@ describe('policy_config and licenses', () => { it('allows advanced rollback option when Platinum', () => { const policy = policyFactory(); - policy.windows.advanced = { alerts: { rollback: { remediation: { enabled: true } } } }; // make policy change + policy.windows.advanced = { alerts: { rollback: { self_healing: { enabled: true } } } }; // make policy change const valid = isEndpointPolicyValidForLicense(policy, Platinum); expect(valid).toBeTruthy(); }); it('blocks advanced rollback option when below Platinum', () => { const policy = policyFactory(); - policy.windows.advanced = { alerts: { rollback: { remediation: { enabled: true } } } }; // make policy change + policy.windows.advanced = { alerts: { rollback: { self_healing: { enabled: true } } } }; // make policy change let valid = isEndpointPolicyValidForLicense(policy, Gold); expect(valid).toBeFalsy(); @@ -515,7 +515,7 @@ describe('policy_config and licenses', () => { policy.windows.advanced = { alerts: { rollback: { - remediation: { + self_healing: { enabled: true, }, }, diff --git a/x-pack/plugins/security_solution/common/license/policy_config.ts b/x-pack/plugins/security_solution/common/license/policy_config.ts index ac5f0458958d3..5e2774ef6a018 100644 --- a/x-pack/plugins/security_solution/common/license/policy_config.ts +++ b/x-pack/plugins/security_solution/common/license/policy_config.ts @@ -234,8 +234,8 @@ function isEndpointAdvancedPolicyValidForLicense(policy: PolicyConfig, license: // only platinum or higher may use rollback if ( - policy.windows.advanced?.alerts?.rollback.remediation.enabled !== - defaults.windows.advanced?.alerts?.rollback.remediation.enabled + policy.windows.advanced?.alerts?.rollback.self_healing.enabled !== + defaults.windows.advanced?.alerts?.rollback.self_healing.enabled ) { return false; } diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/models/advanced_policy_schema.ts b/x-pack/plugins/security_solution/public/management/pages/policy/models/advanced_policy_schema.ts index ba96d43994401..6208416252cdd 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/models/advanced_policy_schema.ts +++ b/x-pack/plugins/security_solution/public/management/pages/policy/models/advanced_policy_schema.ts @@ -938,13 +938,13 @@ export const AdvancedPolicySchema: AdvancedPolicySchemaType[] = [ ), }, { - key: 'windows.advanced.alerts.rollback.remediation.enabled', + key: 'windows.advanced.alerts.rollback.self_healing.enabled', first_supported_version: '8.4', documentation: i18n.translate( - 'xpack.securitySolution.endpoint.policy.advanced.windows.advanced.alerts.rollback.remediation.enabled', + 'xpack.securitySolution.endpoint.policy.advanced.windows.advanced.alerts.rollback.self_healing.enabled', { defaultMessage: - 'Remediate malware artifacts when prevention alerts are triggered. Warning: data loss can occur. Default: false', + 'Self-healing erases attack artifacts when prevention alerts are triggered. Warning: data loss can occur. Default: false', } ), license: 'platinum', From c3a55d1aa8d9e914e96ef2f691f973bed89e38ef Mon Sep 17 00:00:00 2001 From: Christos Nasikas Date: Thu, 4 Aug 2022 15:22:09 +0300 Subject: [PATCH 5/8] [Cases] User profile hooks (#137830) * Refactoring services, auth * Adding suggest api and tests * Working integration tests * Switching suggest api tags * Adding tests for size and owner * Adding api tag tests * Addressing feedback * Create suggest query * Add tests * Add security as dependency and fix types * Add bulk get profiles query * Rename folder * Revert security solution optional * PR feedback * Reduce size * Make security required * Fix tests * Do not retry suggestions Co-authored-by: Jonathan Buttner Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- x-pack/plugins/cases/common/constants.ts | 6 ++ x-pack/plugins/cases/kibana.json | 4 +- .../cases/public/containers/constants.ts | 8 ++ .../containers/user_profiles/__mocks__/api.ts | 15 ++++ .../containers/user_profiles/api.mock.ts | 43 ++++++++++ .../containers/user_profiles/api.test.ts | 82 ++++++++++++++++++ .../public/containers/user_profiles/api.ts | 46 ++++++++++ .../use_bulk_get_user_profiles.test.ts | 66 +++++++++++++++ .../use_bulk_get_user_profiles.ts | 41 +++++++++ .../use_suggest_user_profiles.test.ts | 83 +++++++++++++++++++ .../use_suggest_user_profiles.ts | 65 +++++++++++++++ x-pack/plugins/cases/public/types.ts | 8 +- x-pack/plugins/observability/kibana.json | 3 +- x-pack/plugins/observability/public/plugin.ts | 3 + .../security_solution/public/plugin.tsx | 2 +- .../plugins/security_solution/public/types.ts | 4 +- 16 files changed, 468 insertions(+), 11 deletions(-) create mode 100644 x-pack/plugins/cases/public/containers/user_profiles/__mocks__/api.ts create mode 100644 x-pack/plugins/cases/public/containers/user_profiles/api.mock.ts create mode 100644 x-pack/plugins/cases/public/containers/user_profiles/api.test.ts create mode 100644 x-pack/plugins/cases/public/containers/user_profiles/api.ts create mode 100644 x-pack/plugins/cases/public/containers/user_profiles/use_bulk_get_user_profiles.test.ts create mode 100644 x-pack/plugins/cases/public/containers/user_profiles/use_bulk_get_user_profiles.ts create mode 100644 x-pack/plugins/cases/public/containers/user_profiles/use_suggest_user_profiles.test.ts create mode 100644 x-pack/plugins/cases/public/containers/user_profiles/use_suggest_user_profiles.ts diff --git a/x-pack/plugins/cases/common/constants.ts b/x-pack/plugins/cases/common/constants.ts index e88a7baf2f583..9e85d6e4cbf7a 100644 --- a/x-pack/plugins/cases/common/constants.ts +++ b/x-pack/plugins/cases/common/constants.ts @@ -157,3 +157,9 @@ export const READ_CASES_CAPABILITY = 'read_cases' as const; export const UPDATE_CASES_CAPABILITY = 'update_cases' as const; export const DELETE_CASES_CAPABILITY = 'delete_cases' as const; export const PUSH_CASES_CAPABILITY = 'push_cases' as const; + +/** + * User profiles + */ + +export const DEFAULT_USER_SIZE = 10; diff --git a/x-pack/plugins/cases/kibana.json b/x-pack/plugins/cases/kibana.json index 00b630cb7cab7..d027023b7c96a 100644 --- a/x-pack/plugins/cases/kibana.json +++ b/x-pack/plugins/cases/kibana.json @@ -11,7 +11,6 @@ "kibanaVersion":"kibana", "optionalPlugins":[ "home", - "security", "taskManager", "usageCollection" ], @@ -30,7 +29,8 @@ "kibanaUtils", "triggersActionsUi", "management", - "spaces" + "spaces", + "security" ], "requiredBundles": [ "savedObjects" diff --git a/x-pack/plugins/cases/public/containers/constants.ts b/x-pack/plugins/cases/public/containers/constants.ts index cfd7d5020e20f..3a04b411cb8e7 100644 --- a/x-pack/plugins/cases/public/containers/constants.ts +++ b/x-pack/plugins/cases/public/containers/constants.ts @@ -16,3 +16,11 @@ export const CASE_LIST_CACHE_KEY = 'case-list'; export const CASE_CONNECTORS_CACHE_KEY = 'case-connectors'; export const CASE_LICENSE_CACHE_KEY = 'case-license-action'; export const CASE_TAGS_CACHE_KEY = 'case-tags'; + +/** + * User profiles + */ + +export const USER_PROFILES_CACHE_KEY = 'user-profiles'; +export const USER_PROFILES_SUGGEST_CACHE_KEY = 'suggest'; +export const USER_PROFILES_BULK_GET_CACHE_KEY = 'bulk-get'; diff --git a/x-pack/plugins/cases/public/containers/user_profiles/__mocks__/api.ts b/x-pack/plugins/cases/public/containers/user_profiles/__mocks__/api.ts new file mode 100644 index 0000000000000..36c88451124ca --- /dev/null +++ b/x-pack/plugins/cases/public/containers/user_profiles/__mocks__/api.ts @@ -0,0 +1,15 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { UserProfile } from '@kbn/security-plugin/common'; +import { userProfiles } from '../api.mock'; + +export const suggestUserProfiles = async (): Promise => + Promise.resolve(userProfiles); + +export const bulkGetUserProfiles = async (): Promise => + Promise.resolve(userProfiles); diff --git a/x-pack/plugins/cases/public/containers/user_profiles/api.mock.ts b/x-pack/plugins/cases/public/containers/user_profiles/api.mock.ts new file mode 100644 index 0000000000000..b84e84d3523b8 --- /dev/null +++ b/x-pack/plugins/cases/public/containers/user_profiles/api.mock.ts @@ -0,0 +1,43 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { UserProfile } from '@kbn/security-plugin/common'; + +export const userProfiles: UserProfile[] = [ + { + uid: 'u_J41Oh6L9ki-Vo2tOogS8WRTENzhHurGtRc87NgEAlkc_0', + data: {}, + user: { + username: 'damaged_raccoon', + email: 'damaged_raccoon@elastic.co', + full_name: 'Damaged Raccoon', + }, + enabled: true, + }, + { + uid: 'u_A_tM4n0wPkdiQ9smmd8o0Hr_h61XQfu8aRPh9GMoRoc_0', + data: {}, + user: { + username: 'physical_dinosaur', + email: 'physical_dinosaur@elastic.co', + full_name: 'Physical Dinosaur', + }, + enabled: true, + }, + { + uid: 'u_9xDEQqUqoYCnFnPPLq5mIRHKL8gBTo_NiKgOnd5gGk0_0', + data: {}, + user: { + username: 'wet_dingo', + email: 'wet_dingo@elastic.co', + full_name: 'Wet Dingo', + }, + enabled: true, + }, +]; + +export const userProfilesIds = userProfiles.map((profile) => profile.uid); diff --git a/x-pack/plugins/cases/public/containers/user_profiles/api.test.ts b/x-pack/plugins/cases/public/containers/user_profiles/api.test.ts new file mode 100644 index 0000000000000..7234cc9fb54fe --- /dev/null +++ b/x-pack/plugins/cases/public/containers/user_profiles/api.test.ts @@ -0,0 +1,82 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { GENERAL_CASES_OWNER } from '../../../common/constants'; +import { createStartServicesMock } from '../../common/lib/kibana/kibana_react.mock'; +import { bulkGetUserProfiles, suggestUserProfiles } from './api'; +import { userProfiles, userProfilesIds } from './api.mock'; + +describe('User profiles API', () => { + describe('suggestUserProfiles', () => { + const abortCtrl = new AbortController(); + const { http } = createStartServicesMock(); + + beforeEach(() => { + jest.clearAllMocks(); + http.post = jest.fn().mockResolvedValue(userProfiles); + }); + + it('returns the user profiles correctly', async () => { + const res = await suggestUserProfiles({ + http, + name: 'elastic', + owner: [GENERAL_CASES_OWNER], + signal: abortCtrl.signal, + }); + + expect(res).toEqual(userProfiles); + }); + + it('calls http.post correctly', async () => { + await suggestUserProfiles({ + http, + name: 'elastic', + owner: [GENERAL_CASES_OWNER], + signal: abortCtrl.signal, + }); + + expect(http.post).toHaveBeenCalledWith('/internal/cases/_suggest_user_profiles', { + body: '{"name":"elastic","size":10,"owner":["cases"]}', + signal: abortCtrl.signal, + }); + }); + }); + + describe('bulkGetUserProfiles', () => { + const { security } = createStartServicesMock(); + + beforeEach(() => { + jest.clearAllMocks(); + security.userProfiles.bulkGet = jest.fn().mockResolvedValue(userProfiles); + }); + + it('returns the user profiles correctly', async () => { + const res = await bulkGetUserProfiles({ + security, + uids: userProfilesIds, + }); + + expect(res).toEqual(userProfiles); + }); + + it('calls http.post correctly', async () => { + await bulkGetUserProfiles({ + security, + uids: userProfilesIds, + }); + + expect(security.userProfiles.bulkGet).toHaveBeenCalledWith({ + dataPath: 'avatar', + uids: new Set([ + 'u_J41Oh6L9ki-Vo2tOogS8WRTENzhHurGtRc87NgEAlkc_0', + 'u_A_tM4n0wPkdiQ9smmd8o0Hr_h61XQfu8aRPh9GMoRoc_0', + 'u_9xDEQqUqoYCnFnPPLq5mIRHKL8gBTo_NiKgOnd5gGk0_0', + ]), + }); + }); + }); +}); diff --git a/x-pack/plugins/cases/public/containers/user_profiles/api.ts b/x-pack/plugins/cases/public/containers/user_profiles/api.ts new file mode 100644 index 0000000000000..6da84d1991423 --- /dev/null +++ b/x-pack/plugins/cases/public/containers/user_profiles/api.ts @@ -0,0 +1,46 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { HttpStart } from '@kbn/core/public'; +import { UserProfile } from '@kbn/security-plugin/common'; +import { SecurityPluginStart } from '@kbn/security-plugin/public'; +import { INTERNAL_SUGGEST_USER_PROFILES_URL, DEFAULT_USER_SIZE } from '../../../common/constants'; + +export interface SuggestUserProfilesArgs { + http: HttpStart; + name: string; + owner: string[]; + signal: AbortSignal; + size?: number; +} + +export const suggestUserProfiles = async ({ + http, + name, + size = DEFAULT_USER_SIZE, + owner, + signal, +}: SuggestUserProfilesArgs): Promise => { + const response = await http.post(INTERNAL_SUGGEST_USER_PROFILES_URL, { + body: JSON.stringify({ name, size, owner }), + signal, + }); + + return response; +}; + +export interface BulkGetUserProfilesArgs { + security: SecurityPluginStart; + uids: string[]; +} + +export const bulkGetUserProfiles = async ({ + security, + uids, +}: BulkGetUserProfilesArgs): Promise => { + return security.userProfiles.bulkGet({ uids: new Set(uids), dataPath: 'avatar' }); +}; diff --git a/x-pack/plugins/cases/public/containers/user_profiles/use_bulk_get_user_profiles.test.ts b/x-pack/plugins/cases/public/containers/user_profiles/use_bulk_get_user_profiles.test.ts new file mode 100644 index 0000000000000..7591bf394d5c1 --- /dev/null +++ b/x-pack/plugins/cases/public/containers/user_profiles/use_bulk_get_user_profiles.test.ts @@ -0,0 +1,66 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { renderHook } from '@testing-library/react-hooks'; +import { useToasts } from '../../common/lib/kibana'; +import { AppMockRenderer, createAppMockRenderer } from '../../common/mock'; +import * as api from './api'; +import { useBulkGetUserProfiles } from './use_bulk_get_user_profiles'; +import { userProfilesIds } from './api.mock'; + +jest.mock('../../common/lib/kibana'); +jest.mock('./api'); + +describe('useBulkGetUserProfiles', () => { + const props = { + uids: userProfilesIds, + }; + + const addSuccess = jest.fn(); + (useToasts as jest.Mock).mockReturnValue({ addSuccess, addError: jest.fn() }); + + let appMockRender: AppMockRenderer; + + beforeEach(() => { + appMockRender = createAppMockRenderer(); + jest.clearAllMocks(); + }); + + it('calls bulkGetUserProfiles with correct arguments', async () => { + const spyOnSuggestUserProfiles = jest.spyOn(api, 'bulkGetUserProfiles'); + + const { result, waitFor } = renderHook(() => useBulkGetUserProfiles(props), { + wrapper: appMockRender.AppWrapper, + }); + + await waitFor(() => result.current.isSuccess); + + expect(spyOnSuggestUserProfiles).toBeCalledWith({ + ...props, + security: expect.anything(), + }); + }); + + it('shows a toast error message when an error occurs in the response', async () => { + const spyOnSuggestUserProfiles = jest.spyOn(api, 'bulkGetUserProfiles'); + + spyOnSuggestUserProfiles.mockImplementation(() => { + throw new Error('Something went wrong'); + }); + + const addError = jest.fn(); + (useToasts as jest.Mock).mockReturnValue({ addSuccess, addError }); + + const { result, waitFor } = renderHook(() => useBulkGetUserProfiles(props), { + wrapper: appMockRender.AppWrapper, + }); + + await waitFor(() => result.current.isError); + + expect(addError).toHaveBeenCalled(); + }); +}); diff --git a/x-pack/plugins/cases/public/containers/user_profiles/use_bulk_get_user_profiles.ts b/x-pack/plugins/cases/public/containers/user_profiles/use_bulk_get_user_profiles.ts new file mode 100644 index 0000000000000..cdaee1848613c --- /dev/null +++ b/x-pack/plugins/cases/public/containers/user_profiles/use_bulk_get_user_profiles.ts @@ -0,0 +1,41 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { useQuery, UseQueryResult } from 'react-query'; +import { UserProfile } from '@kbn/security-plugin/common'; +import * as i18n from '../translations'; +import { useKibana, useToasts } from '../../common/lib/kibana'; +import { ServerError } from '../../types'; +import { USER_PROFILES_CACHE_KEY, USER_PROFILES_BULK_GET_CACHE_KEY } from '../constants'; +import { bulkGetUserProfiles } from './api'; + +export const useBulkGetUserProfiles = ({ uids }: { uids: string[] }) => { + const { security } = useKibana().services; + + const toasts = useToasts(); + + return useQuery( + [USER_PROFILES_CACHE_KEY, USER_PROFILES_BULK_GET_CACHE_KEY, uids], + () => { + return bulkGetUserProfiles({ security, uids }); + }, + { + onError: (error: ServerError) => { + if (error.name !== 'AbortError') { + toasts.addError( + error.body && error.body.message ? new Error(error.body.message) : error, + { + title: i18n.ERROR_TITLE, + } + ); + } + }, + } + ); +}; + +export type UseSuggestUserProfiles = UseQueryResult; diff --git a/x-pack/plugins/cases/public/containers/user_profiles/use_suggest_user_profiles.test.ts b/x-pack/plugins/cases/public/containers/user_profiles/use_suggest_user_profiles.test.ts new file mode 100644 index 0000000000000..5ae16c8fa6e00 --- /dev/null +++ b/x-pack/plugins/cases/public/containers/user_profiles/use_suggest_user_profiles.test.ts @@ -0,0 +1,83 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { GENERAL_CASES_OWNER } from '../../../common/constants'; +import { renderHook } from '@testing-library/react-hooks'; +import { useToasts } from '../../common/lib/kibana'; +import { AppMockRenderer, createAppMockRenderer } from '../../common/mock'; +import * as api from './api'; +import { useSuggestUserProfiles } from './use_suggest_user_profiles'; + +jest.mock('../../common/lib/kibana'); +jest.mock('./api'); + +describe('useSuggestUserProfiles', () => { + const props = { + name: 'elastic', + owner: [GENERAL_CASES_OWNER], + }; + + const addSuccess = jest.fn(); + (useToasts as jest.Mock).mockReturnValue({ addSuccess, addError: jest.fn() }); + + let appMockRender: AppMockRenderer; + + beforeAll(() => { + jest.useFakeTimers(); + }); + + beforeEach(() => { + appMockRender = createAppMockRenderer(); + jest.clearAllMocks(); + }); + + afterEach(() => { + jest.clearAllTimers(); + }); + + afterAll(() => { + jest.useRealTimers(); + }); + + it('calls suggestUserProfiles with correct arguments', async () => { + const spyOnSuggestUserProfiles = jest.spyOn(api, 'suggestUserProfiles'); + + const { result, waitFor } = renderHook(() => useSuggestUserProfiles(props), { + wrapper: appMockRender.AppWrapper, + }); + + jest.advanceTimersByTime(500); + await waitFor(() => result.current.isSuccess); + + expect(spyOnSuggestUserProfiles).toBeCalledWith({ + ...props, + size: 10, + http: expect.anything(), + signal: expect.anything(), + }); + }); + + it('shows a toast error message when an error occurs in the response', async () => { + const spyOnSuggestUserProfiles = jest.spyOn(api, 'suggestUserProfiles'); + + spyOnSuggestUserProfiles.mockImplementation(() => { + throw new Error('Something went wrong'); + }); + + const addError = jest.fn(); + (useToasts as jest.Mock).mockReturnValue({ addSuccess, addError }); + + const { result, waitFor } = renderHook(() => useSuggestUserProfiles(props), { + wrapper: appMockRender.AppWrapper, + }); + + jest.advanceTimersByTime(500); + await waitFor(() => result.current.isError); + + expect(addError).toHaveBeenCalled(); + }); +}); diff --git a/x-pack/plugins/cases/public/containers/user_profiles/use_suggest_user_profiles.ts b/x-pack/plugins/cases/public/containers/user_profiles/use_suggest_user_profiles.ts new file mode 100644 index 0000000000000..3705224e1d0c8 --- /dev/null +++ b/x-pack/plugins/cases/public/containers/user_profiles/use_suggest_user_profiles.ts @@ -0,0 +1,65 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { useState } from 'react'; +import { useQuery, UseQueryResult } from 'react-query'; +import useDebounce from 'react-use/lib/useDebounce'; +import { UserProfile } from '@kbn/security-plugin/common'; +import { DEFAULT_USER_SIZE } from '../../../common/constants'; +import * as i18n from '../translations'; +import { useKibana, useToasts } from '../../common/lib/kibana'; +import { ServerError } from '../../types'; +import { USER_PROFILES_CACHE_KEY, USER_PROFILES_SUGGEST_CACHE_KEY } from '../constants'; +import { suggestUserProfiles, SuggestUserProfilesArgs } from './api'; + +const DEBOUNCE_MS = 500; + +export const useSuggestUserProfiles = ({ + name, + owner, + size = DEFAULT_USER_SIZE, +}: Omit) => { + const { http } = useKibana().services; + const [debouncedName, setDebouncedName] = useState(name); + + useDebounce(() => setDebouncedName(name), DEBOUNCE_MS, [name]); + + const toasts = useToasts(); + + return useQuery( + [ + USER_PROFILES_CACHE_KEY, + USER_PROFILES_SUGGEST_CACHE_KEY, + { name: debouncedName, owner, size }, + ], + () => { + const abortCtrlRef = new AbortController(); + return suggestUserProfiles({ + http, + name: debouncedName, + owner, + size, + signal: abortCtrlRef.signal, + }); + }, + { + retry: false, + onError: (error: ServerError) => { + if (error.name !== 'AbortError') { + toasts.addError( + error.body && error.body.message ? new Error(error.body.message) : error, + { + title: i18n.ERROR_TITLE, + } + ); + } + }, + } + ); +}; + +export type UseSuggestUserProfiles = UseQueryResult; diff --git a/x-pack/plugins/cases/public/types.ts b/x-pack/plugins/cases/public/types.ts index 90d4179553771..00ffa538c2f90 100644 --- a/x-pack/plugins/cases/public/types.ts +++ b/x-pack/plugins/cases/public/types.ts @@ -15,7 +15,7 @@ import type { HomePublicPluginSetup } from '@kbn/home-plugin/public'; import type { ManagementSetup, ManagementAppMountParams } from '@kbn/management-plugin/public'; import type { FeaturesPluginStart } from '@kbn/features-plugin/public'; import type { LensPublicStart } from '@kbn/lens-plugin/public'; -import type { SecurityPluginSetup } from '@kbn/security-plugin/public'; +import type { SecurityPluginSetup, SecurityPluginStart } from '@kbn/security-plugin/public'; import type { SpacesPluginStart } from '@kbn/spaces-plugin/public'; import type { TriggersAndActionsUIPublicPluginStart as TriggersActionsStart } from '@kbn/triggers-actions-ui-plugin/public'; import type { DistributiveOmit } from '@elastic/eui'; @@ -57,6 +57,7 @@ export interface CasesPluginStart { storage: Storage; triggersActionsUi: TriggersActionsStart; features: FeaturesPluginStart; + security: SecurityPluginStart; spaces?: SpacesPluginStart; } @@ -66,10 +67,7 @@ export interface CasesPluginStart { * Leaving it out currently in lieu of RBAC changes */ -export type StartServices = CoreStart & - CasesPluginStart & { - security: SecurityPluginSetup; - }; +export type StartServices = CoreStart & CasesPluginStart; export interface RenderAppProps { mountParams: ManagementAppMountParams; diff --git a/x-pack/plugins/observability/kibana.json b/x-pack/plugins/observability/kibana.json index 32fa629762885..5464bffccd9cd 100644 --- a/x-pack/plugins/observability/kibana.json +++ b/x-pack/plugins/observability/kibana.json @@ -31,7 +31,8 @@ "triggersActionsUi", "inspector", "unifiedSearch", - "sharedUX" + "sharedUX", + "security" ], "ui": true, "server": true, diff --git a/x-pack/plugins/observability/public/plugin.ts b/x-pack/plugins/observability/public/plugin.ts index 15cc0463feef3..617dce2959f1e 100644 --- a/x-pack/plugins/observability/public/plugin.ts +++ b/x-pack/plugins/observability/public/plugin.ts @@ -37,6 +37,7 @@ import { ActionTypeRegistryContract, RuleTypeRegistryContract, } from '@kbn/triggers-actions-ui-plugin/public'; +import { SecurityPluginStart } from '@kbn/security-plugin/public'; import { observabilityAppId, observabilityFeatureId, casesPath } from '../common'; import { createLazyObservabilityPageTemplate } from './components/shared'; import { registerDataHandler } from './data_handler'; @@ -51,6 +52,7 @@ import { getExploratoryViewEmbeddable } from './components/shared/exploratory_vi import { createExploratoryViewUrl } from './components/shared/exploratory_view/configurations/exploratory_view_url'; import { createUseRulesLink } from './hooks/create_use_rules_link'; import getAppDataView from './utils/observability_data_views/get_app_data_view'; + export type ObservabilityPublicSetup = ReturnType; export interface ObservabilityPublicPluginsSetup { @@ -73,6 +75,7 @@ export interface ObservabilityPublicPluginsStart { sharedUX: SharedUXPluginStart; ruleTypeRegistry: RuleTypeRegistryContract; actionTypeRegistry: ActionTypeRegistryContract; + security: SecurityPluginStart; } export type ObservabilityPublicStart = ReturnType; diff --git a/x-pack/plugins/security_solution/public/plugin.tsx b/x-pack/plugins/security_solution/public/plugin.tsx index e7b92c5f5f756..42924f4a40886 100644 --- a/x-pack/plugins/security_solution/public/plugin.tsx +++ b/x-pack/plugins/security_solution/public/plugin.tsx @@ -137,7 +137,7 @@ export class Plugin implements IPlugin Date: Thu, 4 Aug 2022 14:39:47 +0200 Subject: [PATCH 6/8] Fix unable to open host or user detail pages when their names conflict with tabs (#137719) * Fix Unable to open user detail pages when user names conflict with tabs * Fix Unable to open host detail pages when host names conflict with tabs * Preserve tab name on user and host compatibility redirect --- .../ml/ml_conditional_links.spec.ts | 6 ++--- .../cypress/integration/urls/state.spec.ts | 4 ++-- .../components/link_to/redirect_to_hosts.tsx | 4 ++-- .../components/link_to/redirect_to_users.tsx | 4 ++-- .../common/components/links/index.test.tsx | 4 ++-- .../ml_host_conditional_container.tsx | 4 +++- .../navigation/breadcrumbs/index.test.ts | 8 +++---- .../navigation/tab_navigation/index.test.tsx | 2 +- .../hosts/pages/details/details_tabs.test.tsx | 2 +- .../public/hosts/pages/details/nav_tabs.tsx | 2 +- .../public/hosts/pages/index.tsx | 23 +++++++++++++++---- .../public/hosts/pages/types.ts | 2 +- .../field_renderers.test.tsx.snap | 4 ++-- .../public/users/pages/constants.ts | 2 +- .../public/users/pages/details/nav_tabs.tsx | 2 +- .../public/users/pages/index.tsx | 23 ++++++++++++++++--- 16 files changed, 65 insertions(+), 31 deletions(-) diff --git a/x-pack/plugins/security_solution/cypress/integration/ml/ml_conditional_links.spec.ts b/x-pack/plugins/security_solution/cypress/integration/ml/ml_conditional_links.spec.ts index 5ab92be404c9d..b288ecc537e99 100644 --- a/x-pack/plugins/security_solution/cypress/integration/ml/ml_conditional_links.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/ml/ml_conditional_links.spec.ts @@ -146,7 +146,7 @@ describe('ml conditional links', () => { visitWithoutDateRange(mlHostSingleHostNullKqlQuery); cy.url().should( 'include', - '/app/security/hosts/siem-windows/anomalies?sourcerer=(default:(id:security-solution-default,selectedPatterns:!(%27auditbeat-*%27)))&timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)))' + '/app/security/hosts/name/siem-windows/anomalies?sourcerer=(default:(id:security-solution-default,selectedPatterns:!(%27auditbeat-*%27)))&timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)))' ); }); @@ -154,7 +154,7 @@ describe('ml conditional links', () => { visitWithoutDateRange(mlHostSingleHostKqlQueryVariable); cy.url().should( 'include', - '/app/security/hosts/siem-windows/anomalies?sourcerer=(default:(id:security-solution-default,selectedPatterns:!(%27auditbeat-*%27)))&timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)))' + '/app/security/hosts/name/siem-windows/anomalies?sourcerer=(default:(id:security-solution-default,selectedPatterns:!(%27auditbeat-*%27)))&timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)))' ); }); @@ -162,7 +162,7 @@ describe('ml conditional links', () => { visitWithoutDateRange(mlHostSingleHostKqlQuery); cy.url().should( 'include', - '/app/security/hosts/siem-windows/anomalies?sourcerer=(default:(id:security-solution-default,selectedPatterns:!(%27auditbeat-*%27)))&query=(language:kuery,query:%27(process.name:%20%22conhost.exe%22%20or%20process.name:%20%22sc.exe%22)%27)&timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)))' + '/app/security/hosts/name/siem-windows/anomalies?sourcerer=(default:(id:security-solution-default,selectedPatterns:!(%27auditbeat-*%27)))&query=(language:kuery,query:%27(process.name:%20%22conhost.exe%22%20or%20process.name:%20%22sc.exe%22)%27)&timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)))' ); }); diff --git a/x-pack/plugins/security_solution/cypress/integration/urls/state.spec.ts b/x-pack/plugins/security_solution/cypress/integration/urls/state.spec.ts index faedd11b1d12b..cc1cfdf40009c 100644 --- a/x-pack/plugins/security_solution/cypress/integration/urls/state.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/urls/state.spec.ts @@ -255,7 +255,7 @@ describe('url state', () => { cy.get(ANOMALIES_TAB).should( 'have.attr', 'href', - "/app/security/hosts/siem-kibana/anomalies?sourcerer=(default:(id:security-solution-default,selectedPatterns:!('auditbeat-*')))&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-08-01T20:03:29.186Z',kind:absolute,to:'2023-01-01T21:33:29.186Z')),timeline:(linkTo:!(global),timerange:(from:'2019-08-01T20:03:29.186Z',kind:absolute,to:'2023-01-01T21:33:29.186Z')))&query=(language:kuery,query:'agent.type:%20%22auditbeat%22%20')" + "/app/security/hosts/name/siem-kibana/anomalies?sourcerer=(default:(id:security-solution-default,selectedPatterns:!('auditbeat-*')))&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-08-01T20:03:29.186Z',kind:absolute,to:'2023-01-01T21:33:29.186Z')),timeline:(linkTo:!(global),timerange:(from:'2019-08-01T20:03:29.186Z',kind:absolute,to:'2023-01-01T21:33:29.186Z')))&query=(language:kuery,query:'agent.type:%20%22auditbeat%22%20')" ); cy.get(BREADCRUMBS) @@ -270,7 +270,7 @@ describe('url state', () => { .should( 'have.attr', 'href', - `/app/security/hosts/siem-kibana?sourcerer=(default:(id:security-solution-default,selectedPatterns:!('auditbeat-*')))&query=(language:kuery,query:'agent.type:%20%22auditbeat%22%20')&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-08-01T20:03:29.186Z',kind:absolute,to:'2023-01-01T21:33:29.186Z')),timeline:(linkTo:!(global),timerange:(from:'2019-08-01T20:03:29.186Z',kind:absolute,to:'2023-01-01T21:33:29.186Z')))` + `/app/security/hosts/name/siem-kibana?sourcerer=(default:(id:security-solution-default,selectedPatterns:!('auditbeat-*')))&query=(language:kuery,query:'agent.type:%20%22auditbeat%22%20')&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-08-01T20:03:29.186Z',kind:absolute,to:'2023-01-01T21:33:29.186Z')),timeline:(linkTo:!(global),timerange:(from:'2019-08-01T20:03:29.186Z',kind:absolute,to:'2023-01-01T21:33:29.186Z')))` ); }); diff --git a/x-pack/plugins/security_solution/public/common/components/link_to/redirect_to_hosts.tsx b/x-pack/plugins/security_solution/public/common/components/link_to/redirect_to_hosts.tsx index 831ac9bb4f4c0..caa9c00e1a90c 100644 --- a/x-pack/plugins/security_solution/public/common/components/link_to/redirect_to_hosts.tsx +++ b/x-pack/plugins/security_solution/public/common/components/link_to/redirect_to_hosts.tsx @@ -15,10 +15,10 @@ export const getTabsOnHostsUrl = (tabName: HostsTableType, search?: string) => `/${tabName}${appendSearch(search)}`; export const getHostDetailsUrl = (detailName: string, search?: string) => - `/${detailName}${appendSearch(search)}`; + `/name/${detailName}${appendSearch(search)}`; export const getTabsOnHostDetailsUrl = ( detailName: string, tabName: HostsTableType, search?: string -) => `/${detailName}/${tabName}${appendSearch(search)}`; +) => `/name/${detailName}/${tabName}${appendSearch(search)}`; diff --git a/x-pack/plugins/security_solution/public/common/components/link_to/redirect_to_users.tsx b/x-pack/plugins/security_solution/public/common/components/link_to/redirect_to_users.tsx index 20171634ad6ea..8a90810228d01 100644 --- a/x-pack/plugins/security_solution/public/common/components/link_to/redirect_to_users.tsx +++ b/x-pack/plugins/security_solution/public/common/components/link_to/redirect_to_users.tsx @@ -9,10 +9,10 @@ import type { UsersTableType } from '../../../users/store/model'; import { appendSearch } from './helpers'; export const getUsersDetailsUrl = (detailName: string, search?: string) => - `/${detailName}${appendSearch(search)}`; + `/name/${detailName}${appendSearch(search)}`; export const getTabsOnUsersDetailsUrl = ( detailName: string, tabName: UsersTableType, search?: string -) => `/${detailName}/${tabName}${appendSearch(search)}`; +) => `/name/${detailName}/${tabName}${appendSearch(search)}`; diff --git a/x-pack/plugins/security_solution/public/common/components/links/index.test.tsx b/x-pack/plugins/security_solution/public/common/components/links/index.test.tsx index 13fdb96b86aeb..478916c2b6c0d 100644 --- a/x-pack/plugins/security_solution/public/common/components/links/index.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/links/index.test.tsx @@ -60,13 +60,13 @@ describe('Custom Links', () => { describe('HostDetailsLink', () => { test('should render valid link to Host Details with hostName as the display text', () => { const wrapper = mount(); - expect(wrapper.find('EuiLink').prop('href')).toEqual(`/${encodeURIComponent(hostName)}`); + expect(wrapper.find('EuiLink').prop('href')).toEqual(`/name/${encodeURIComponent(hostName)}`); expect(wrapper.text()).toEqual(hostName); }); test('should render valid link to Host Details with child text as the display text', () => { const wrapper = mount({hostName}); - expect(wrapper.find('EuiLink').prop('href')).toEqual(`/${encodeURIComponent(hostName)}`); + expect(wrapper.find('EuiLink').prop('href')).toEqual(`/name/${encodeURIComponent(hostName)}`); expect(wrapper.text()).toEqual(hostName); }); }); diff --git a/x-pack/plugins/security_solution/public/common/components/ml/conditional_links/ml_host_conditional_container.tsx b/x-pack/plugins/security_solution/public/common/components/ml/conditional_links/ml_host_conditional_container.tsx index a18d51cb63773..17b46ca398191 100644 --- a/x-pack/plugins/security_solution/public/common/components/ml/conditional_links/ml_host_conditional_container.tsx +++ b/x-pack/plugins/security_solution/public/common/components/ml/conditional_links/ml_host_conditional_container.tsx @@ -88,7 +88,9 @@ export const MlHostConditionalContainer = React.memo(() => { }); return ( - + ); } }} diff --git a/x-pack/plugins/security_solution/public/common/components/navigation/breadcrumbs/index.test.ts b/x-pack/plugins/security_solution/public/common/components/navigation/breadcrumbs/index.test.ts index 43ed208148caa..585e5f094da77 100644 --- a/x-pack/plugins/security_solution/public/common/components/navigation/breadcrumbs/index.test.ts +++ b/x-pack/plugins/security_solution/public/common/components/navigation/breadcrumbs/index.test.ts @@ -240,7 +240,7 @@ describe('Navigation Breadcrumbs', () => { hostsBreadcrumbs, { text: 'siem-kibana', - href: 'securitySolutionUI/hosts/siem-kibana', + href: 'securitySolutionUI/hosts/name/siem-kibana', }, { text: 'Authentications', href: '' }, ]); @@ -458,7 +458,7 @@ describe('Navigation Breadcrumbs', () => { }), expect.objectContaining({ text: 'siem-kibana', - href: 'securitySolutionUI/hosts/siem-kibana', + href: 'securitySolutionUI/hosts/name/siem-kibana', onClick: expect.any(Function), }), { @@ -556,7 +556,7 @@ describe('Navigation Breadcrumbs', () => { hostsBreadcrumbs, { text: 'siem-kibana', - href: 'securitySolutionUI/hosts/siem-kibana', + href: 'securitySolutionUI/hosts/name/siem-kibana', }, { text: 'Authentications', href: '' }, ]); @@ -787,7 +787,7 @@ describe('Navigation Breadcrumbs', () => { }), expect.objectContaining({ text: 'siem-kibana', - href: 'securitySolutionUI/hosts/siem-kibana', + href: 'securitySolutionUI/hosts/name/siem-kibana', onClick: expect.any(Function), }), { diff --git a/x-pack/plugins/security_solution/public/common/components/navigation/tab_navigation/index.test.tsx b/x-pack/plugins/security_solution/public/common/components/navigation/tab_navigation/index.test.tsx index 2648ac258b114..c5aa5fbfce880 100644 --- a/x-pack/plugins/security_solution/public/common/components/navigation/tab_navigation/index.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/navigation/tab_navigation/index.test.tsx @@ -89,7 +89,7 @@ describe('Table Navigation', () => { `EuiTab[data-test-subj="navigation-${HostsTableType.authentications}"]` ); expect(firstTab.props().href).toBe( - `/app/securitySolutionUI/hosts/siem-window/authentications${SEARCH_QUERY}` + `/app/securitySolutionUI/hosts/name/siem-window/authentications${SEARCH_QUERY}` ); }); diff --git a/x-pack/plugins/security_solution/public/hosts/pages/details/details_tabs.test.tsx b/x-pack/plugins/security_solution/public/hosts/pages/details/details_tabs.test.tsx index da7495d79695f..e40c32883e0cd 100644 --- a/x-pack/plugins/security_solution/public/hosts/pages/details/details_tabs.test.tsx +++ b/x-pack/plugins/security_solution/public/hosts/pages/details/details_tabs.test.tsx @@ -97,7 +97,7 @@ describe('body', () => { test(`it should pass expected object properties to ${componentName}`, () => { const wrapper = mount( - + - `${HOSTS_PATH}/${hostName}/${tabName}`; + `${HOSTS_PATH}/name/${hostName}/${tabName}`; export const navTabsHostDetails = ({ hasMlUserPermissions, diff --git a/x-pack/plugins/security_solution/public/hosts/pages/index.tsx b/x-pack/plugins/security_solution/public/hosts/pages/index.tsx index 105ab3e6e4157..57f164ddd3b24 100644 --- a/x-pack/plugins/security_solution/public/hosts/pages/index.tsx +++ b/x-pack/plugins/security_solution/public/hosts/pages/index.tsx @@ -55,7 +55,7 @@ export const HostsContainer = React.memo(() => ( /> )} /> - ( }) => ( )} /> - - ( + + )} + /> + ( diff --git a/x-pack/plugins/security_solution/public/hosts/pages/types.ts b/x-pack/plugins/security_solution/public/hosts/pages/types.ts index a102d9b06072c..17e2af205f799 100644 --- a/x-pack/plugins/security_solution/public/hosts/pages/types.ts +++ b/x-pack/plugins/security_solution/public/hosts/pages/types.ts @@ -13,7 +13,7 @@ import type { GlobalTimeArgs } from '../../common/containers/use_global_time'; import type { InputsModelId } from '../../common/store/inputs/constants'; import { HOSTS_PATH } from '../../../common/constants'; -export const hostDetailsPagePath = `${HOSTS_PATH}/:detailName`; +export const hostDetailsPagePath = `${HOSTS_PATH}/name/:detailName`; export type HostsTabsProps = GlobalTimeArgs & { filterQuery: string; diff --git a/x-pack/plugins/security_solution/public/timelines/components/field_renderers/__snapshots__/field_renderers.test.tsx.snap b/x-pack/plugins/security_solution/public/timelines/components/field_renderers/__snapshots__/field_renderers.test.tsx.snap index 063ebe2952cc0..fd3617f3b5ae5 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/field_renderers/__snapshots__/field_renderers.test.tsx.snap +++ b/x-pack/plugins/security_solution/public/timelines/components/field_renderers/__snapshots__/field_renderers.test.tsx.snap @@ -146,7 +146,7 @@ exports[`Field Renderers #hostIdRenderer it renders correctly against snapshot 1 raspberrypi @@ -201,7 +201,7 @@ exports[`Field Renderers #hostNameRenderer it renders correctly against snapshot raspberrypi diff --git a/x-pack/plugins/security_solution/public/users/pages/constants.ts b/x-pack/plugins/security_solution/public/users/pages/constants.ts index b8788fb5ac29e..c128de47236a4 100644 --- a/x-pack/plugins/security_solution/public/users/pages/constants.ts +++ b/x-pack/plugins/security_solution/public/users/pages/constants.ts @@ -8,7 +8,7 @@ import { USERS_PATH } from '../../../common/constants'; import { UsersTableType } from '../store/model'; -export const usersDetailsPagePath = `${USERS_PATH}/:detailName`; +export const usersDetailsPagePath = `${USERS_PATH}/name/:detailName`; export const usersTabPath = `${USERS_PATH}/:tabName(${UsersTableType.allUsers}|${UsersTableType.authentications}|${UsersTableType.anomalies}|${UsersTableType.risk}|${UsersTableType.events}|)`; diff --git a/x-pack/plugins/security_solution/public/users/pages/details/nav_tabs.tsx b/x-pack/plugins/security_solution/public/users/pages/details/nav_tabs.tsx index b57d1014e0167..90bc856e0d058 100644 --- a/x-pack/plugins/security_solution/public/users/pages/details/nav_tabs.tsx +++ b/x-pack/plugins/security_solution/public/users/pages/details/nav_tabs.tsx @@ -12,7 +12,7 @@ import { UsersTableType } from '../../store/model'; import { USERS_PATH } from '../../../../common/constants'; const getTabsOnUsersDetailsUrl = (userName: string, tabName: UsersTableType) => - `${USERS_PATH}/${userName}/${tabName}`; + `${USERS_PATH}/name/${userName}/${tabName}`; export const navTabsUsersDetails = ( userName: string, diff --git a/x-pack/plugins/security_solution/public/users/pages/index.tsx b/x-pack/plugins/security_solution/public/users/pages/index.tsx index 055bb2bb71ab2..b75959b5265a9 100644 --- a/x-pack/plugins/security_solution/public/users/pages/index.tsx +++ b/x-pack/plugins/security_solution/public/users/pages/index.tsx @@ -34,7 +34,7 @@ export const UsersContainer = React.memo(() => { /> )} /> - { }) => ( )} /> - ( + + )} + /> + ( From bfe35cca671d82b8496963f8722f3c6a1f3352c5 Mon Sep 17 00:00:00 2001 From: Stratoula Kalafateli Date: Thu, 4 Aug 2022 15:56:43 +0300 Subject: [PATCH 7/8] [Unified search] Allows rendering the datepicker without the refresh button (#137941) * [Unified search] Allows rendering the datepicker without the refresh button * Add another story * fixes --- .../public/__stories__/search_bar.stories.tsx | 18 ++++++++++++++++++ .../query_bar_top_row.test.tsx | 18 ++++++++++++++++++ .../query_string_input/query_bar_top_row.tsx | 10 +++++----- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/src/plugins/unified_search/public/__stories__/search_bar.stories.tsx b/src/plugins/unified_search/public/__stories__/search_bar.stories.tsx index 551915a34b11f..bff5becf3c743 100644 --- a/src/plugins/unified_search/public/__stories__/search_bar.stories.tsx +++ b/src/plugins/unified_search/public/__stories__/search_bar.stories.tsx @@ -430,6 +430,24 @@ storiesOf('SearchBar', module) showSubmitButton: false, } as SearchBarProps) ) + .add('show only datepicker without submit', () => + wrapSearchBarInContext({ + showDatePicker: true, + showFilterBar: false, + showAutoRefreshOnly: false, + showQueryInput: false, + showSubmitButton: false, + } as SearchBarProps) + ) + .add('show only query bar and timepicker without submit', () => + wrapSearchBarInContext({ + showDatePicker: true, + showFilterBar: false, + showAutoRefreshOnly: false, + showQueryInput: true, + showSubmitButton: false, + } as SearchBarProps) + ) .add('with filter bar on but pinning option is hidden from menus', () => wrapSearchBarInContext({ showDatePicker: false, diff --git a/src/plugins/unified_search/public/query_string_input/query_bar_top_row.test.tsx b/src/plugins/unified_search/public/query_string_input/query_bar_top_row.test.tsx index fd1ea2e9bce78..1f879ebcae9a8 100644 --- a/src/plugins/unified_search/public/query_string_input/query_bar_top_row.test.tsx +++ b/src/plugins/unified_search/public/query_string_input/query_bar_top_row.test.tsx @@ -113,6 +113,7 @@ function wrapQueryBarTopRowInContext(testProps: any) { describe('QueryBarTopRowTopRow', () => { const QUERY_INPUT_SELECTOR = 'QueryStringInputUI'; const TIMEPICKER_SELECTOR = 'Memo(EuiSuperDatePicker)'; + const REFRESH_BUTTON_SELECTOR = 'EuiSuperUpdateButton'; const TIMEPICKER_DURATION = '[data-shared-timefilter-duration]'; beforeEach(() => { @@ -195,6 +196,23 @@ describe('QueryBarTopRowTopRow', () => { expect(component.find(TIMEPICKER_SELECTOR).length).toBe(1); }); + it('Should render timepicker without the submit button if showSubmitButton is false', () => { + const component = mount( + wrapQueryBarTopRowInContext({ + isDirty: false, + screenTitle: 'Another Screen', + showDatePicker: true, + showSubmitButton: false, + dateRangeFrom: 'now-7d', + dateRangeTo: 'now', + timeHistory: mockTimeHistory, + }) + ); + + expect(component.find(REFRESH_BUTTON_SELECTOR).length).toBe(0); + expect(component.find(TIMEPICKER_SELECTOR).length).toBe(1); + }); + it('Should render the timefilter duration container for sharing', () => { const component = mount( wrapQueryBarTopRowInContext({ diff --git a/src/plugins/unified_search/public/query_string_input/query_bar_top_row.tsx b/src/plugins/unified_search/public/query_string_input/query_bar_top_row.tsx index 200398137176e..acad2a39d4c4f 100644 --- a/src/plugins/unified_search/public/query_string_input/query_bar_top_row.tsx +++ b/src/plugins/unified_search/public/query_string_input/query_bar_top_row.tsx @@ -375,10 +375,9 @@ export const QueryBarTopRow = React.memo( } function renderUpdateButton() { - if (!shouldRenderUpdatebutton()) { + if (!shouldRenderUpdatebutton() && !shouldRenderDatePicker()) { return null; } - const buttonLabelUpdate = i18n.translate('unifiedSearch.queryBarTopRow.submitButton.update', { defaultMessage: 'Needs updating', }); @@ -421,7 +420,8 @@ export const QueryBarTopRow = React.memo( ); - if (!shouldRenderDatePicker()) { + // allows to render the button without the datepicker + if (!shouldRenderDatePicker() && shouldRenderUpdatebutton()) { return button; } @@ -429,8 +429,8 @@ export const QueryBarTopRow = React.memo( - {renderDatePicker()} - {button} + {shouldRenderDatePicker() ? renderDatePicker() : null} + {shouldRenderUpdatebutton() ? button : null} From 70efbf0ea3ec6eecd4663d53912ab01b7184c117 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Thu, 4 Aug 2022 15:23:36 +0200 Subject: [PATCH 8/8] [ML] Explain Log Rate Spikes: Fix error handling. (#137947) - Errors on the application level were not correctly surfaced in the UI. This PR fixes it by combining "transport" stream errors and application errors in a callout above the analysis results table. - This also fixes the problem where a partly populated results table would turn empty again when used with the error prop of EUI's table. We now keep the table on display an show the errors above it in the callout. --- examples/response_stream/README.md | 2 +- .../app/pages/page_reducer_stream/index.tsx | 10 ++-- .../pages/page_simple_string_stream/index.tsx | 14 ++++- .../ml/aiops_utils/src/fetch_stream.ts | 29 ++++++---- .../ml/aiops_utils/src/use_fetch_stream.ts | 16 ++++-- .../api/explain_log_rate_spikes/actions.ts | 12 ++-- .../api/explain_log_rate_spikes/index.ts | 2 +- .../aiops/common/api/stream_reducer.test.ts | 1 + .../aiops/common/api/stream_reducer.ts | 4 ++ .../explain_log_rate_spikes_analysis.tsx | 55 +++++++++++++++---- .../spike_analysis_table.tsx | 3 - .../server/routes/explain_log_rate_spikes.ts | 6 +- .../apis/aiops/explain_log_rate_spikes.ts | 2 +- 13 files changed, 106 insertions(+), 50 deletions(-) diff --git a/examples/response_stream/README.md b/examples/response_stream/README.md index 3582f06fd216b..9f66fc19f2393 100644 --- a/examples/response_stream/README.md +++ b/examples/response_stream/README.md @@ -21,7 +21,7 @@ The request's headers get passed on to automatically identify if compression is On the client, the custom hook is used like this: ```ts -const { error, start, cancel, data, isRunning } = useFetchStream< +const { errors, start, cancel, data, isRunning } = useFetchStream< ApiSimpleStringStream, typeof basePath >(`${basePath}/internal/response_stream/simple_string_stream`); ``` diff --git a/examples/response_stream/public/containers/app/pages/page_reducer_stream/index.tsx b/examples/response_stream/public/containers/app/pages/page_reducer_stream/index.tsx index 8f5687db1749d..0755765374330 100644 --- a/examples/response_stream/public/containers/app/pages/page_reducer_stream/index.tsx +++ b/examples/response_stream/public/containers/app/pages/page_reducer_stream/index.tsx @@ -45,7 +45,7 @@ export const PageReducerStream: FC = () => { const [simulateErrors, setSimulateErrors] = useState(false); - const { dispatch, start, cancel, data, error, isCancelled, isRunning } = useFetchStream< + const { dispatch, start, cancel, data, errors, isCancelled, isRunning } = useFetchStream< ApiReducerStream, typeof basePath >( @@ -65,13 +65,15 @@ export const PageReducerStream: FC = () => { } }; + // TODO This approach needs to be adapted as it might miss when error messages arrive bulk. // This is for low level errors on the stream/HTTP level. useEffect(() => { - if (error) { - notifications.toasts.addDanger(error); + if (errors.length > 0) { + notifications.toasts.addDanger(errors[errors.length - 1]); } - }, [error, notifications.toasts]); + }, [errors, notifications.toasts]); + // TODO This approach needs to be adapted as it might miss when error messages arrive bulk. // This is for errors on the application level useEffect(() => { if (data.errors.length > 0) { diff --git a/examples/response_stream/public/containers/app/pages/page_simple_string_stream/index.tsx b/examples/response_stream/public/containers/app/pages/page_simple_string_stream/index.tsx index ba159887edfaf..cfa76688d9701 100644 --- a/examples/response_stream/public/containers/app/pages/page_simple_string_stream/index.tsx +++ b/examples/response_stream/public/containers/app/pages/page_simple_string_stream/index.tsx @@ -21,7 +21,7 @@ export const PageSimpleStringStream: FC = () => { const { core } = useDeps(); const basePath = core.http?.basePath.get() ?? ''; - const { dispatch, error, start, cancel, data, isRunning } = useFetchStream< + const { dispatch, errors, start, cancel, data, isRunning } = useFetchStream< ApiSimpleStringStream, typeof basePath >(`${basePath}/internal/response_stream/simple_string_stream`, { timeout: 500 }); @@ -61,9 +61,17 @@ export const PageSimpleStringStream: FC = () => {

{data}

- {error && ( + {errors.length > 0 && ( -

{error}

+ {errors.length === 1 ? ( +

{errors[0]}

+ ) : ( +
    + {errors.map((e, i) => ( +
  • {e}
  • + ))} +
+ )}{' '}
)} diff --git a/x-pack/packages/ml/aiops_utils/src/fetch_stream.ts b/x-pack/packages/ml/aiops_utils/src/fetch_stream.ts index 4a1ed282c3ee7..d8d71adc81bc3 100644 --- a/x-pack/packages/ml/aiops_utils/src/fetch_stream.ts +++ b/x-pack/packages/ml/aiops_utils/src/fetch_stream.ts @@ -44,17 +44,24 @@ export async function* fetchStream | Array> | undefined] > { - const stream = await fetch(endpoint, { - signal: abortCtrl.current.signal, - method: 'POST', - headers: { - // This refers to the format of the request body, - // not the response, which will be a uint8array Buffer. - 'Content-Type': 'application/json', - 'kbn-xsrf': 'stream', - }, - ...(Object.keys(body).length > 0 ? { body: JSON.stringify(body) } : {}), - }); + let stream: Response; + + try { + stream = await fetch(endpoint, { + signal: abortCtrl.current.signal, + method: 'POST', + headers: { + // This refers to the format of the request body, + // not the response, which will be a uint8array Buffer. + 'Content-Type': 'application/json', + 'kbn-xsrf': 'stream', + }, + ...(Object.keys(body).length > 0 ? { body: JSON.stringify(body) } : {}), + }); + } catch (error) { + yield [error.toString(), undefined]; + return; + } if (!stream.ok) { yield [`Error ${stream.status}: ${stream.statusText}`, undefined]; diff --git a/x-pack/packages/ml/aiops_utils/src/use_fetch_stream.ts b/x-pack/packages/ml/aiops_utils/src/use_fetch_stream.ts index 13436efc6d471..516a63e165ffb 100644 --- a/x-pack/packages/ml/aiops_utils/src/use_fetch_stream.ts +++ b/x-pack/packages/ml/aiops_utils/src/use_fetch_stream.ts @@ -41,7 +41,7 @@ interface UseFetchStreamReturnType { cancel: () => void; data: Data; dispatch: Dispatch; - error: string | undefined; + errors: string[]; isCancelled: boolean; isRunning: boolean; start: () => Promise; @@ -76,7 +76,7 @@ export function useFetchStream } ): UseFetchStreamReturnType, ReducerAction> { - const [error, setError] = useState(); + const [errors, setErrors] = useState([]); const [isCancelled, setIsCancelled] = useState(false); const [isRunning, setIsRunning] = useState(false); @@ -87,13 +87,17 @@ export function useFetchStream { + setErrors((prevErrors) => [...prevErrors, error]); + }; + const start = async () => { if (isRunning) { - setError('Restart not supported yet.'); + addError('Restart not supported yet.'); return; } - setError(undefined); + setErrors([]); setIsRunning(true); setIsCancelled(false); @@ -104,7 +108,7 @@ export function useFetchStream(endpoint, abortCtrl, body, options !== undefined)) { if (fetchStreamError !== null) { - setError(fetchStreamError); + addError(fetchStreamError); } else if (actions.length > 0) { dispatch(actions as ReducerAction); } @@ -128,7 +132,7 @@ export function useFetchStream { loaded: 50, loadingState: 'Loaded 50%', changePoints: [], + errors: [], }); }); diff --git a/x-pack/plugins/aiops/common/api/stream_reducer.ts b/x-pack/plugins/aiops/common/api/stream_reducer.ts index 597527e80daef..4a19ecfdd035e 100644 --- a/x-pack/plugins/aiops/common/api/stream_reducer.ts +++ b/x-pack/plugins/aiops/common/api/stream_reducer.ts @@ -12,6 +12,7 @@ import { API_ACTION_NAME, AiopsExplainLogRateSpikesApiAction } from './explain_l interface StreamState { ccsWarning: boolean; changePoints: ChangePoint[]; + errors: string[]; loaded: number; loadingState: string; } @@ -19,6 +20,7 @@ interface StreamState { export const initialState: StreamState = { ccsWarning: false, changePoints: [], + errors: [], loaded: 0, loadingState: '', }; @@ -45,6 +47,8 @@ export function streamReducer( return cp; }); return { ...state, changePoints }; + case API_ACTION_NAME.ADD_ERROR: + return { ...state, errors: [...state.errors, action.payload] }; case API_ACTION_NAME.RESET: return initialState; case API_ACTION_NAME.UPDATE_LOADING_STATE: diff --git a/x-pack/plugins/aiops/public/components/explain_log_rate_spikes/explain_log_rate_spikes_analysis.tsx b/x-pack/plugins/aiops/public/components/explain_log_rate_spikes/explain_log_rate_spikes_analysis.tsx index 18b99b9e68f61..c9b74a634001e 100644 --- a/x-pack/plugins/aiops/public/components/explain_log_rate_spikes/explain_log_rate_spikes_analysis.tsx +++ b/x-pack/plugins/aiops/public/components/explain_log_rate_spikes/explain_log_rate_spikes_analysis.tsx @@ -8,12 +8,13 @@ import React, { useEffect, useMemo, useState, FC } from 'react'; import { isEqual } from 'lodash'; -import { EuiEmptyPrompt } from '@elastic/eui'; +import { EuiCallOut, EuiEmptyPrompt, EuiSpacer, EuiText } from '@elastic/eui'; import type { DataView } from '@kbn/data-views-plugin/public'; import { ProgressControls } from '@kbn/aiops-components'; import { useFetchStream } from '@kbn/aiops-utils'; import type { WindowParameters } from '@kbn/aiops-utils'; +import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; import type { ChangePoint } from '@kbn/ml-agg-utils'; import type { Query } from '@kbn/es-query'; @@ -59,10 +60,13 @@ export const ExplainLogRateSpikesAnalysis: FC WindowParameters | undefined >(); - const { cancel, start, data, isRunning, error } = useFetchStream< - ApiExplainLogRateSpikes, - typeof basePath - >( + const { + cancel, + start, + data, + isRunning, + errors: streamErrors, + } = useFetchStream( `${basePath}/internal/aiops/explain_log_rate_spikes`, { start: earliest, @@ -76,11 +80,7 @@ export const ExplainLogRateSpikesAnalysis: FC { reducer: streamReducer, initialState } ); - useEffect(() => { - setCurrentAnalysisWindowParameters(windowParameters); - start(); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); + const errors = useMemo(() => [...streamErrors, ...data.errors], [streamErrors, data.errors]); // Start handler clears possibly hovered or pinned // change points on analysis refresh. @@ -96,6 +96,12 @@ export const ExplainLogRateSpikesAnalysis: FC start(); } + useEffect(() => { + setCurrentAnalysisWindowParameters(windowParameters); + start(); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + const shouldRerunAnalysis = useMemo( () => currentAnalysisWindowParameters !== undefined && @@ -115,6 +121,7 @@ export const ExplainLogRateSpikesAnalysis: FC onCancel={cancel} shouldRerunAnalysis={shouldRerunAnalysis} /> + {!isRunning && !showSpikeAnalysisTable && ( } /> )} + {errors.length > 0 && ( + <> + + + {errors.length === 1 ? ( +

{errors[0]}

+ ) : ( +
    + {errors.map((e, i) => ( +
  • {e}
  • + ))} +
+ )} +
+
+ + + )} {showSpikeAnalysisTable && ( void; onSelectedChangePoint?: (changePoint: ChangePoint | null) => void; @@ -43,7 +42,6 @@ interface SpikeAnalysisTableProps { export const SpikeAnalysisTable: FC = ({ changePoints, - error, loading, onPinnedChangePoint, onSelectedChangePoint, @@ -218,7 +216,6 @@ export const SpikeAnalysisTable: FC = ({ onChange={onChange} pagination={pagination} loading={false} - error={error} sorting={sorting as EuiTableSortingType} rowProps={(changePoint) => { return { diff --git a/x-pack/plugins/aiops/server/routes/explain_log_rate_spikes.ts b/x-pack/plugins/aiops/server/routes/explain_log_rate_spikes.ts index 2f8a3a314ecd3..9fba2b9e100a5 100644 --- a/x-pack/plugins/aiops/server/routes/explain_log_rate_spikes.ts +++ b/x-pack/plugins/aiops/server/routes/explain_log_rate_spikes.ts @@ -21,7 +21,7 @@ import { addChangePointsAction, addChangePointsHistogramAction, aiopsExplainLogRateSpikesSchema, - errorAction, + addErrorAction, resetAction, updateLoadingStateAction, AiopsExplainLogRateSpikesApiAction, @@ -112,7 +112,7 @@ export const defineExplainLogRateSpikesRoute = ( try { fieldCandidates = await fetchFieldCandidates(client, request.body); } catch (e) { - push(errorAction(e.toString())); + push(addErrorAction(e.toString())); end(); return; } @@ -154,7 +154,7 @@ export const defineExplainLogRateSpikesRoute = ( try { pValues = await fetchChangePointPValues(client, request.body, fieldCandidatesChunk); } catch (e) { - push(errorAction(e.toString())); + push(addErrorAction(e.toString())); end(); return; } diff --git a/x-pack/test/api_integration/apis/aiops/explain_log_rate_spikes.ts b/x-pack/test/api_integration/apis/aiops/explain_log_rate_spikes.ts index 5bf3ae04a2743..9261dc8b1bea9 100644 --- a/x-pack/test/api_integration/apis/aiops/explain_log_rate_spikes.ts +++ b/x-pack/test/api_integration/apis/aiops/explain_log_rate_spikes.ts @@ -40,7 +40,7 @@ export default ({ getService }: FtrProviderContext) => { noIndexActionsLength: 3, changePointFilter: 'add_change_points', histogramFilter: 'add_change_points_histogram', - errorFilter: 'error', + errorFilter: 'add_error', changePoints: [ { fieldName: 'day_of_week',