From 7c367e41cead28bb8739537d6a63d2625d25a861 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Wed, 7 Apr 2021 14:43:33 +0100 Subject: [PATCH 01/37] [ML] Moving file data vizualizer to file upload plugin --- .../plugins/file_upload/common/constants.ts | 12 + x-pack/plugins/file_upload/common/types.ts | 17 ++ x-pack/plugins/file_upload/kibana.json | 19 +- .../plugins/file_upload/public/api/index.ts | 15 + .../public/application}/_index.scss | 0 .../application}/components/_index.scss | 0 .../components/about_panel/_about_panel.scss | 0 .../components/about_panel/_index.scss | 0 .../components/about_panel/about_panel.tsx | 0 .../components/about_panel/index.ts | 0 .../about_panel/welcome_content.tsx | 13 +- .../analysis_summary/_analysis_summary.scss | 0 .../components/analysis_summary/_index.scss | 0 .../analysis_summary/analysis_summary.tsx | 2 +- .../components/analysis_summary/index.ts | 0 .../components/bottom_bar/bottom_bar.tsx | 0 .../components/bottom_bar/index.ts | 0 .../combined_fields/combined_field_label.tsx | 0 .../combined_fields/combined_fields_form.tsx | 2 +- .../combined_fields_read_only_form.tsx | 0 .../components/combined_fields/geo_point.tsx | 2 +- .../components/combined_fields/index.ts | 0 .../components/combined_fields/types.ts | 0 .../components/combined_fields/utils.test.ts | 0 .../components/combined_fields/utils.ts | 6 +- .../__snapshots__/overrides.test.js.snap | 0 .../components/edit_flyout/_edit_flyout.scss | 0 .../components/edit_flyout/_index.scss | 0 .../components/edit_flyout/edit_flyout.js | 0 .../components/edit_flyout/index.js | 0 .../components/edit_flyout/options/index.js | 0 .../edit_flyout/options/option_lists.js | 0 .../components/edit_flyout/options/options.js | 0 .../components/edit_flyout/overrides.js | 2 +- .../components/edit_flyout/overrides.test.js | 2 +- .../edit_flyout/overrides_validation.js | 0 .../examples_list/examples_list.tsx | 59 ++++ .../components/examples_list}/index.ts | 2 +- .../expanded_row/file_based_expanded_row.tsx | 6 +- .../geo_point_content/format_utils.ts | 20 +- .../geo_point_content/geo_point_content.tsx | 12 +- .../expanded_row/geo_point_content/index.ts | 0 .../components/expanded_row/index.ts | 0 .../_experimental_badge.scss | 0 .../components/experimental_badge/_index.scss | 0 .../experimental_badge/experimental_badge.tsx | 0 .../components/experimental_badge/index.ts | 0 .../explanation_flyout/explanation_flyout.tsx | 2 +- .../components/explanation_flyout/index.ts | 0 .../components/field_data_row/index.ts | 0 .../field_data_row/number_content_preview.tsx | 2 +- .../field_names_filter/field_names_filter.tsx | 4 +- .../components/field_names_filter/index.ts | 0 .../field_type_icon.test.tsx.snap | 16 + .../field_type_icon/field_type_icon.test.tsx | 52 ++++ .../field_type_icon/field_type_icon.tsx | 130 ++++++++ .../components/field_type_icon}/index.ts | 2 +- .../field_types_filter/field_types_filter.tsx | 20 +- .../components/field_types_filter/index.ts | 0 .../fields_stats/_field_stats_card.scss | 0 .../fields_stats/_fields_stats.scss | 0 .../fields_stats_grid/create_fields.ts | 8 +- .../fields_stats_grid/fields_stats_grid.tsx | 30 +- .../fields_stats_grid/filter_fields.ts | 4 +- .../fields_stats_grid/get_field_names.ts | 7 +- .../components/fields_stats_grid/index.ts | 0 .../file_contents/_file_contents.scss | 0 .../components/file_contents/_index.scss | 0 .../file_contents/file_contents.tsx | 2 +- .../components/file_contents/index.ts | 0 .../_file_datavisualizer_view.scss | 0 .../file_datavisualizer_view/_index.scss | 0 .../file_datavisualizer_view/constants.ts | 0 .../file_datavisualizer_view.js | 14 +- .../file_error_callouts.tsx | 14 +- .../file_datavisualizer_view/index.js | 0 .../filebeat_config_flyout/filebeat_config.ts | 2 +- .../filebeat_config_flyout.tsx | 10 +- .../filebeat_config_flyout/index.ts | 0 .../components/import_errors/errors.tsx | 0 .../components/import_errors/index.ts | 0 .../import_progress/import_progress.tsx | 0 .../components/import_progress/index.ts | 0 .../components/import_settings/advanced.tsx | 4 +- .../import_settings/import_settings.tsx | 2 +- .../components/import_settings/index.ts | 0 .../components/import_settings/simple.tsx | 0 .../import_summary/_import_sumary.scss | 0 .../components/import_summary/_index.scss | 0 .../components/import_summary/failures.tsx | 0 .../import_summary/import_summary.tsx | 0 .../components/import_summary/index.ts | 0 .../components/import_view/import_view.js | 57 ++-- .../components/import_view/index.js | 0 .../components/ml_embedded_map/_index.scss | 1 + .../ml_embedded_map/_ml_embedded_map.scss | 8 + .../components/ml_embedded_map}/index.ts | 2 +- .../ml_embedded_map/ml_embedded_map.tsx | 157 ++++++++++ .../components/ml_job_editor/index.ts | 8 + .../ml_job_editor/ml_job_editor.tsx | 58 ++++ .../components/multi_select_picker/index.ts | 8 + .../multi_select_picker.tsx | 145 +++++++++ .../components/results_links/index.ts | 8 + .../results_links/results_links.tsx | 37 ++- .../components/results_view/_index.scss | 0 .../results_view/_results_view.scss | 0 .../components/results_view/index.ts | 0 .../components/results_view/results_view.tsx | 2 +- .../stats_table/_field_data_row.scss | 86 ++++++ .../components/stats_table/_index.scss | 56 ++++ .../expanded_row_field_header.tsx | 15 + .../expanded_row_field_header/index.ts | 8 + .../components/field_count_stats/_index.scss | 3 + .../components/field_count_stats/index.ts | 13 + .../field_count_stats/metric_fields_count.tsx | 68 +++++ .../field_count_stats/total_fields_count.tsx | 67 +++++ .../field_data_expanded_row/_index.scss | 7 + .../_number_content.scss | 4 + .../boolean_content.tsx | 145 +++++++++ .../field_data_expanded_row/date_content.tsx | 87 ++++++ .../document_stats.tsx | 93 ++++++ .../expanded_row_content.tsx | 25 ++ .../field_data_expanded_row/index.ts | 15 + .../field_data_expanded_row/ip_content.tsx | 27 ++ .../keyword_content.tsx | 25 ++ .../number_content.tsx | 154 ++++++++++ .../field_data_expanded_row/other_content.tsx | 28 ++ .../field_data_expanded_row/text_content.tsx | 66 +++++ .../components/field_data_row/_index.scss | 3 + .../boolean_content_preview.tsx | 43 +++ .../field_data_row/column_chart.scss | 32 ++ .../field_data_row/column_chart.tsx | 84 ++++++ .../field_data_row/distinct_values.tsx | 24 ++ .../field_data_row/document_stats.tsx | 33 +++ .../field_data_row/field_histograms.ts | 68 +++++ .../components/field_data_row/index.ts | 8 + .../field_data_row/number_content_preview.tsx | 81 +++++ .../field_data_row/top_values_preview.tsx | 44 +++ .../field_data_row/use_column_chart.test.tsx | 177 +++++++++++ .../field_data_row/use_column_chart.tsx | 206 +++++++++++++ .../metric_distribution_chart/index.ts | 9 + .../metric_distribution_chart.tsx | 105 +++++++ ...metric_distribution_chart_data_builder.tsx | 156 ++++++++++ ...tric_distribution_chart_tooltip_header.tsx | 54 ++++ .../data_visualizer_stats_table.tsx | 277 ++++++++++++++++++ .../stats_table/hooks/color_range_legend.tsx | 146 +++++++++ .../components/stats_table/hooks/index.ts | 8 + .../stats_table/hooks/use_color_range.test.ts | 58 ++++ .../stats_table/hooks/use_color_range.ts | 201 +++++++++++++ .../hooks/use_data_viz_chart_theme.ts | 55 ++++ .../components/stats_table/index.ts | 8 + .../stats_table/types/field_data_row.ts | 12 + .../stats_table/types/field_vis_config.ts | 98 +++++++ .../components/stats_table/types/index.ts | 16 + .../stats_table/use_table_settings.ts | 94 ++++++ .../components/stats_table/utils.ts | 38 +++ .../components/top_values/_top_values.scss | 19 ++ .../components/top_values/index.ts | 8 + .../components/top_values/top_values.tsx | 112 +++++++ .../components/utils/format_value.ts | 88 ++++++ .../application/components/utils/index.ts | 12 + .../components/utils/kibana_field_format.ts | 19 ++ .../utils/number_as_ordinal.test.ts | 29 ++ .../components/utils/number_as_ordinal.ts | 20 ++ .../utils/round_to_decimal_place.test.ts | 38 +++ .../utils/round_to_decimal_place.ts | 20 ++ .../application}/components/utils/utils.ts | 3 +- .../application/file_datavisualizer.tsx | 44 +++ .../file_upload/public/application/index.ts | 10 + .../public/application/kibana_context.ts | 23 ++ .../public/application/shared_imports.ts | 12 + .../util/field_types_utils.test.ts | 84 ++++++ .../application/util/field_types_utils.ts | 87 ++++++ .../public/application/util/util.ts | 51 ++++ x-pack/plugins/file_upload/public/index.ts | 2 + x-pack/plugins/file_upload/public/plugin.ts | 2 + x-pack/plugins/file_upload/tsconfig.json | 2 + .../analytics_list/use_table_settings.ts | 10 +- .../file_based/file_datavisualizer.tsx | 38 --- .../search_panel/field_type_filter.tsx | 2 +- .../field_data_expanded_row/index.ts | 1 - .../data_visualizer_stats_table.tsx | 4 +- .../routes/datavisualizer/file_based.tsx | 18 +- 183 files changed, 4713 insertions(+), 182 deletions(-) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/_index.scss (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/_index.scss (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/about_panel/_about_panel.scss (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/about_panel/_index.scss (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/about_panel/about_panel.tsx (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/about_panel/index.ts (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/about_panel/welcome_content.tsx (94%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/analysis_summary/_analysis_summary.scss (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/analysis_summary/_index.scss (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/analysis_summary/analysis_summary.tsx (97%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/analysis_summary/index.ts (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/bottom_bar/bottom_bar.tsx (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/bottom_bar/index.ts (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/combined_fields/combined_field_label.tsx (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/combined_fields/combined_fields_form.tsx (98%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/combined_fields/combined_fields_read_only_form.tsx (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/combined_fields/geo_point.tsx (98%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/combined_fields/index.ts (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/combined_fields/types.ts (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/combined_fields/utils.test.ts (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/combined_fields/utils.ts (97%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/edit_flyout/__snapshots__/overrides.test.js.snap (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/edit_flyout/_edit_flyout.scss (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/edit_flyout/_index.scss (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/edit_flyout/edit_flyout.js (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/edit_flyout/index.js (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/edit_flyout/options/index.js (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/edit_flyout/options/option_lists.js (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/edit_flyout/options/options.js (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/edit_flyout/overrides.js (99%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/edit_flyout/overrides.test.js (94%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/edit_flyout/overrides_validation.js (100%) create mode 100644 x-pack/plugins/file_upload/public/application/components/examples_list/examples_list.tsx rename x-pack/plugins/{ml/public/application/datavisualizer/file_based/components/results_links => file_upload/public/application/components/examples_list}/index.ts (84%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/expanded_row/file_based_expanded_row.tsx (86%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/expanded_row/geo_point_content/format_utils.ts (74%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/expanded_row/geo_point_content/geo_point_content.tsx (81%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/expanded_row/geo_point_content/index.ts (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/expanded_row/index.ts (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/experimental_badge/_experimental_badge.scss (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/experimental_badge/_index.scss (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/experimental_badge/experimental_badge.tsx (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/experimental_badge/index.ts (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/explanation_flyout/explanation_flyout.tsx (96%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/explanation_flyout/index.ts (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/field_data_row/index.ts (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/field_data_row/number_content_preview.tsx (96%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/field_names_filter/field_names_filter.tsx (90%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/field_names_filter/index.ts (100%) create mode 100644 x-pack/plugins/file_upload/public/application/components/field_type_icon/__snapshots__/field_type_icon.test.tsx.snap create mode 100644 x-pack/plugins/file_upload/public/application/components/field_type_icon/field_type_icon.test.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/field_type_icon/field_type_icon.tsx rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application/components/field_type_icon}/index.ts (79%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/field_types_filter/field_types_filter.tsx (70%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/field_types_filter/index.ts (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/fields_stats/_field_stats_card.scss (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/fields_stats/_fields_stats.scss (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/fields_stats_grid/create_fields.ts (91%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/fields_stats_grid/fields_stats_grid.tsx (79%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/fields_stats_grid/filter_fields.ts (88%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/fields_stats_grid/get_field_names.ts (83%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/fields_stats_grid/index.ts (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/file_contents/_file_contents.scss (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/file_contents/_index.scss (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/file_contents/file_contents.tsx (94%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/file_contents/index.ts (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/file_datavisualizer_view/_file_datavisualizer_view.scss (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/file_datavisualizer_view/_index.scss (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/file_datavisualizer_view/constants.ts (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/file_datavisualizer_view/file_datavisualizer_view.js (96%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/file_datavisualizer_view/file_error_callouts.tsx (94%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/file_datavisualizer_view/index.js (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/filebeat_config_flyout/filebeat_config.ts (95%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/filebeat_config_flyout/filebeat_config_flyout.tsx (95%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/filebeat_config_flyout/index.ts (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/import_errors/errors.tsx (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/import_errors/index.ts (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/import_progress/import_progress.tsx (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/import_progress/index.ts (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/import_settings/advanced.tsx (97%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/import_settings/import_settings.tsx (97%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/import_settings/index.ts (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/import_settings/simple.tsx (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/import_summary/_import_sumary.scss (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/import_summary/_index.scss (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/import_summary/failures.tsx (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/import_summary/import_summary.tsx (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/import_summary/index.ts (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/import_view/import_view.js (94%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/import_view/index.js (100%) create mode 100644 x-pack/plugins/file_upload/public/application/components/ml_embedded_map/_index.scss create mode 100644 x-pack/plugins/file_upload/public/application/components/ml_embedded_map/_ml_embedded_map.scss rename x-pack/plugins/{ml/public/application/datavisualizer/file_based/components/utils => file_upload/public/application/components/ml_embedded_map}/index.ts (72%) create mode 100644 x-pack/plugins/file_upload/public/application/components/ml_embedded_map/ml_embedded_map.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/ml_job_editor/index.ts create mode 100644 x-pack/plugins/file_upload/public/application/components/ml_job_editor/ml_job_editor.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/multi_select_picker/index.ts create mode 100644 x-pack/plugins/file_upload/public/application/components/multi_select_picker/multi_select_picker.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/results_links/index.ts rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/results_links/results_links.tsx (91%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/results_view/_index.scss (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/results_view/_results_view.scss (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/results_view/index.ts (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/results_view/results_view.tsx (97%) create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/_field_data_row.scss create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/_index.scss create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/expanded_row_field_header/expanded_row_field_header.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/expanded_row_field_header/index.ts create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/_index.scss create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/index.ts create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/metric_fields_count.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/total_fields_count.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/_index.scss create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/_number_content.scss create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/boolean_content.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/date_content.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/document_stats.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/expanded_row_content.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/index.ts create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/ip_content.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/keyword_content.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/number_content.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/other_content.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/text_content.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/_index.scss create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/boolean_content_preview.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/column_chart.scss create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/column_chart.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/distinct_values.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/document_stats.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/field_histograms.ts create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/index.ts create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/number_content_preview.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/top_values_preview.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/use_column_chart.test.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/index.ts create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart_data_builder.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart_tooltip_header.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/data_visualizer_stats_table.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/hooks/color_range_legend.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/hooks/index.ts create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/hooks/use_color_range.test.ts create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/hooks/use_color_range.ts create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/hooks/use_data_viz_chart_theme.ts create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/index.ts create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/types/field_data_row.ts create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/types/field_vis_config.ts create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/types/index.ts create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/use_table_settings.ts create mode 100644 x-pack/plugins/file_upload/public/application/components/stats_table/utils.ts create mode 100644 x-pack/plugins/file_upload/public/application/components/top_values/_top_values.scss create mode 100644 x-pack/plugins/file_upload/public/application/components/top_values/index.ts create mode 100644 x-pack/plugins/file_upload/public/application/components/top_values/top_values.tsx create mode 100644 x-pack/plugins/file_upload/public/application/components/utils/format_value.ts create mode 100644 x-pack/plugins/file_upload/public/application/components/utils/index.ts create mode 100644 x-pack/plugins/file_upload/public/application/components/utils/kibana_field_format.ts create mode 100644 x-pack/plugins/file_upload/public/application/components/utils/number_as_ordinal.test.ts create mode 100644 x-pack/plugins/file_upload/public/application/components/utils/number_as_ordinal.ts create mode 100644 x-pack/plugins/file_upload/public/application/components/utils/round_to_decimal_place.test.ts create mode 100644 x-pack/plugins/file_upload/public/application/components/utils/round_to_decimal_place.ts rename x-pack/plugins/{ml/public/application/datavisualizer/file_based => file_upload/public/application}/components/utils/utils.ts (96%) create mode 100644 x-pack/plugins/file_upload/public/application/file_datavisualizer.tsx create mode 100644 x-pack/plugins/file_upload/public/application/index.ts create mode 100644 x-pack/plugins/file_upload/public/application/kibana_context.ts create mode 100644 x-pack/plugins/file_upload/public/application/shared_imports.ts create mode 100644 x-pack/plugins/file_upload/public/application/util/field_types_utils.test.ts create mode 100644 x-pack/plugins/file_upload/public/application/util/field_types_utils.ts create mode 100644 x-pack/plugins/file_upload/public/application/util/util.ts delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx diff --git a/x-pack/plugins/file_upload/common/constants.ts b/x-pack/plugins/file_upload/common/constants.ts index ea36e51466703..6c4e62698e8af 100644 --- a/x-pack/plugins/file_upload/common/constants.ts +++ b/x-pack/plugins/file_upload/common/constants.ts @@ -17,3 +17,15 @@ export const FILE_SIZE_DISPLAY_FORMAT = '0,0.[0] b'; // Value to use in the Elasticsearch index mapping meta data to identify the // index as having been created by the ML File Data Visualizer. export const INDEX_META_DATA_CREATED_BY = 'ml-file-data-visualizer'; + +export const ML_JOB_FIELD_TYPES = { + BOOLEAN: 'boolean', + DATE: 'date', + GEO_POINT: 'geo_point', + GEO_SHAPE: 'geo_shape', + IP: 'ip', + KEYWORD: 'keyword', + NUMBER: 'number', + TEXT: 'text', + UNKNOWN: 'unknown', +} as const; diff --git a/x-pack/plugins/file_upload/common/types.ts b/x-pack/plugins/file_upload/common/types.ts index 11cf4ac3615bf..7ecb2f5a5c732 100644 --- a/x-pack/plugins/file_upload/common/types.ts +++ b/x-pack/plugins/file_upload/common/types.ts @@ -7,6 +7,7 @@ import type { estypes } from '@elastic/elasticsearch'; import { ES_FIELD_TYPES } from '../../../../src/plugins/data/common'; +import { ML_JOB_FIELD_TYPES } from './constants'; export interface HasImportPermission { hasImportPermission: boolean; @@ -127,3 +128,19 @@ export interface IngestPipeline { description: string; processors: any[]; } + +export type MlJobFieldType = typeof ML_JOB_FIELD_TYPES[keyof typeof ML_JOB_FIELD_TYPES]; + +interface ListingPageUrlState { + pageSize: number; + pageIndex: number; + sortField: string; + sortDirection: string; + queryText?: string; +} + +export interface DataVisualizerFileBasedAppState extends Omit { + visibleFieldTypes?: string[]; + visibleFieldNames?: string[]; + showDistributions?: boolean; +} diff --git a/x-pack/plugins/file_upload/kibana.json b/x-pack/plugins/file_upload/kibana.json index a1c585e534333..a25f718e7bc14 100644 --- a/x-pack/plugins/file_upload/kibana.json +++ b/x-pack/plugins/file_upload/kibana.json @@ -4,7 +4,20 @@ "kibanaVersion": "kibana", "server": true, "ui": true, - "requiredPlugins": ["data", "usageCollection"], - "optionalPlugins": ["security"], - "requiredBundles": ["kibanaReact"] + "requiredPlugins": [ + "data", + "usageCollection", + "embeddable" + ], + "optionalPlugins": [ + "security", + "maps" + ], + "requiredBundles": [ + "esUiShared", + "kibanaReact" + ], + "extraPublicDirs": [ + "common" + ] } diff --git a/x-pack/plugins/file_upload/public/api/index.ts b/x-pack/plugins/file_upload/public/api/index.ts index 281537cbbde16..946c3ac38efd5 100644 --- a/x-pack/plugins/file_upload/public/api/index.ts +++ b/x-pack/plugins/file_upload/public/api/index.ts @@ -16,6 +16,7 @@ export interface FileUploadStartApi { getMaxBytes(): number; getMaxBytesFormatted(): string; hasImportPermission(params: HasImportPermissionParams): Promise; + analyzeFile(file: string, params: Record): Promise; } export async function getFileUploadComponent(): Promise< @@ -52,3 +53,17 @@ export async function hasImportPermission(params: HasImportPermissionParams): Pr return false; } } + +export async function analyzeFile( + file: string, + params: Record = {} +): Promise { + const body = JSON.stringify(file); + const fileUploadModules = await lazyLoadFileUploadModules(); + return await fileUploadModules.getHttp().fetch({ + path: `/api/file_upload/analyze_file`, + method: 'POST', + body, + query: params, + }); +} diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/_index.scss b/x-pack/plugins/file_upload/public/application/_index.scss similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/_index.scss rename to x-pack/plugins/file_upload/public/application/_index.scss diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/_index.scss b/x-pack/plugins/file_upload/public/application/components/_index.scss similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/_index.scss rename to x-pack/plugins/file_upload/public/application/components/_index.scss diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/about_panel/_about_panel.scss b/x-pack/plugins/file_upload/public/application/components/about_panel/_about_panel.scss similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/about_panel/_about_panel.scss rename to x-pack/plugins/file_upload/public/application/components/about_panel/_about_panel.scss diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/about_panel/_index.scss b/x-pack/plugins/file_upload/public/application/components/about_panel/_index.scss similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/about_panel/_index.scss rename to x-pack/plugins/file_upload/public/application/components/about_panel/_index.scss diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/about_panel/about_panel.tsx b/x-pack/plugins/file_upload/public/application/components/about_panel/about_panel.tsx similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/about_panel/about_panel.tsx rename to x-pack/plugins/file_upload/public/application/components/about_panel/about_panel.tsx diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/about_panel/index.ts b/x-pack/plugins/file_upload/public/application/components/about_panel/index.ts similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/about_panel/index.ts rename to x-pack/plugins/file_upload/public/application/components/about_panel/index.ts diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/about_panel/welcome_content.tsx b/x-pack/plugins/file_upload/public/application/components/about_panel/welcome_content.tsx similarity index 94% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/about_panel/welcome_content.tsx rename to x-pack/plugins/file_upload/public/application/components/about_panel/welcome_content.tsx index 2c441e42dea2f..7bfb6006322b2 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/about_panel/welcome_content.tsx +++ b/x-pack/plugins/file_upload/public/application/components/about_panel/welcome_content.tsx @@ -21,7 +21,7 @@ import { import { ExperimentalBadge } from '../experimental_badge'; -import { useMlKibana } from '../../../../contexts/kibana'; +import { getMaxBytesFormatted } from '../../../get_max_bytes'; export const WelcomeContent: FC = () => { const toolTipContent = i18n.translate( @@ -31,16 +31,7 @@ export const WelcomeContent: FC = () => { } ); - const { - services: { fileUpload }, - } = useMlKibana(); - - if (fileUpload === undefined) { - // eslint-disable-next-line no-console - console.error('File upload plugin not available'); - return null; - } - const maxFileSize = fileUpload.getMaxBytesFormatted(); + const maxFileSize = getMaxBytesFormatted(); return ( diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/analysis_summary/_analysis_summary.scss b/x-pack/plugins/file_upload/public/application/components/analysis_summary/_analysis_summary.scss similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/analysis_summary/_analysis_summary.scss rename to x-pack/plugins/file_upload/public/application/components/analysis_summary/_analysis_summary.scss diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/analysis_summary/_index.scss b/x-pack/plugins/file_upload/public/application/components/analysis_summary/_index.scss similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/analysis_summary/_index.scss rename to x-pack/plugins/file_upload/public/application/components/analysis_summary/_index.scss diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/analysis_summary/analysis_summary.tsx b/x-pack/plugins/file_upload/public/application/components/analysis_summary/analysis_summary.tsx similarity index 97% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/analysis_summary/analysis_summary.tsx rename to x-pack/plugins/file_upload/public/application/components/analysis_summary/analysis_summary.tsx index d787ee5cb844e..3e321143e1275 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/analysis_summary/analysis_summary.tsx +++ b/x-pack/plugins/file_upload/public/application/components/analysis_summary/analysis_summary.tsx @@ -9,7 +9,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import React, { FC } from 'react'; import { EuiTitle, EuiSpacer, EuiDescriptionList } from '@elastic/eui'; -import { FindFileStructureResponse } from '../../../../../../../file_upload/common'; +import { FindFileStructureResponse } from '../../../../common'; export const AnalysisSummary: FC<{ results: FindFileStructureResponse }> = ({ results }) => { const items = createDisplayItems(results); diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/analysis_summary/index.ts b/x-pack/plugins/file_upload/public/application/components/analysis_summary/index.ts similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/analysis_summary/index.ts rename to x-pack/plugins/file_upload/public/application/components/analysis_summary/index.ts diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/bottom_bar/bottom_bar.tsx b/x-pack/plugins/file_upload/public/application/components/bottom_bar/bottom_bar.tsx similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/bottom_bar/bottom_bar.tsx rename to x-pack/plugins/file_upload/public/application/components/bottom_bar/bottom_bar.tsx diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/bottom_bar/index.ts b/x-pack/plugins/file_upload/public/application/components/bottom_bar/index.ts similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/bottom_bar/index.ts rename to x-pack/plugins/file_upload/public/application/components/bottom_bar/index.ts diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/combined_fields/combined_field_label.tsx b/x-pack/plugins/file_upload/public/application/components/combined_fields/combined_field_label.tsx similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/combined_fields/combined_field_label.tsx rename to x-pack/plugins/file_upload/public/application/components/combined_fields/combined_field_label.tsx diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/combined_fields/combined_fields_form.tsx b/x-pack/plugins/file_upload/public/application/components/combined_fields/combined_fields_form.tsx similarity index 98% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/combined_fields/combined_fields_form.tsx rename to x-pack/plugins/file_upload/public/application/components/combined_fields/combined_fields_form.tsx index 02ead5c26f959..828647ebac92f 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/combined_fields/combined_fields_form.tsx +++ b/x-pack/plugins/file_upload/public/application/components/combined_fields/combined_fields_form.tsx @@ -29,7 +29,7 @@ import { removeCombinedFieldsFromMappings, removeCombinedFieldsFromPipeline, } from './utils'; -import { FindFileStructureResponse } from '../../../../../../../file_upload/common'; +import { FindFileStructureResponse } from '../../../../common'; interface Props { mappingsString: string; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/combined_fields/combined_fields_read_only_form.tsx b/x-pack/plugins/file_upload/public/application/components/combined_fields/combined_fields_read_only_form.tsx similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/combined_fields/combined_fields_read_only_form.tsx rename to x-pack/plugins/file_upload/public/application/components/combined_fields/combined_fields_read_only_form.tsx diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/combined_fields/geo_point.tsx b/x-pack/plugins/file_upload/public/application/components/combined_fields/geo_point.tsx similarity index 98% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/combined_fields/geo_point.tsx rename to x-pack/plugins/file_upload/public/application/components/combined_fields/geo_point.tsx index 5ae2e5de681c3..3c80ccb8f59ff 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/combined_fields/geo_point.tsx +++ b/x-pack/plugins/file_upload/public/application/components/combined_fields/geo_point.tsx @@ -29,7 +29,7 @@ import { getFieldNames, getNameCollisionMsg, } from './utils'; -import { FindFileStructureResponse } from '../../../../../../../file_upload/common'; +import { FindFileStructureResponse } from '../../../../common'; interface Props { addCombinedField: (combinedField: CombinedField) => void; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/combined_fields/index.ts b/x-pack/plugins/file_upload/public/application/components/combined_fields/index.ts similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/combined_fields/index.ts rename to x-pack/plugins/file_upload/public/application/components/combined_fields/index.ts diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/combined_fields/types.ts b/x-pack/plugins/file_upload/public/application/components/combined_fields/types.ts similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/combined_fields/types.ts rename to x-pack/plugins/file_upload/public/application/components/combined_fields/types.ts diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/combined_fields/utils.test.ts b/x-pack/plugins/file_upload/public/application/components/combined_fields/utils.test.ts similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/combined_fields/utils.test.ts rename to x-pack/plugins/file_upload/public/application/components/combined_fields/utils.test.ts diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/combined_fields/utils.ts b/x-pack/plugins/file_upload/public/application/components/combined_fields/utils.ts similarity index 97% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/combined_fields/utils.ts rename to x-pack/plugins/file_upload/public/application/components/combined_fields/utils.ts index ab08398fcda02..3a5570a966d1f 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/combined_fields/utils.ts +++ b/x-pack/plugins/file_upload/public/application/components/combined_fields/utils.ts @@ -9,11 +9,7 @@ import { i18n } from '@kbn/i18n'; import { cloneDeep } from 'lodash'; import uuid from 'uuid/v4'; import { CombinedField } from './types'; -import { - FindFileStructureResponse, - IngestPipeline, - Mappings, -} from '../../../../../../../file_upload/common'; +import { FindFileStructureResponse, IngestPipeline, Mappings } from '../../../../common'; const COMMON_LAT_NAMES = ['latitude', 'lat']; const COMMON_LON_NAMES = ['longitude', 'long', 'lon']; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/edit_flyout/__snapshots__/overrides.test.js.snap b/x-pack/plugins/file_upload/public/application/components/edit_flyout/__snapshots__/overrides.test.js.snap similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/edit_flyout/__snapshots__/overrides.test.js.snap rename to x-pack/plugins/file_upload/public/application/components/edit_flyout/__snapshots__/overrides.test.js.snap diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/edit_flyout/_edit_flyout.scss b/x-pack/plugins/file_upload/public/application/components/edit_flyout/_edit_flyout.scss similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/edit_flyout/_edit_flyout.scss rename to x-pack/plugins/file_upload/public/application/components/edit_flyout/_edit_flyout.scss diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/edit_flyout/_index.scss b/x-pack/plugins/file_upload/public/application/components/edit_flyout/_index.scss similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/edit_flyout/_index.scss rename to x-pack/plugins/file_upload/public/application/components/edit_flyout/_index.scss diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/edit_flyout/edit_flyout.js b/x-pack/plugins/file_upload/public/application/components/edit_flyout/edit_flyout.js similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/edit_flyout/edit_flyout.js rename to x-pack/plugins/file_upload/public/application/components/edit_flyout/edit_flyout.js diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/edit_flyout/index.js b/x-pack/plugins/file_upload/public/application/components/edit_flyout/index.js similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/edit_flyout/index.js rename to x-pack/plugins/file_upload/public/application/components/edit_flyout/index.js diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/edit_flyout/options/index.js b/x-pack/plugins/file_upload/public/application/components/edit_flyout/options/index.js similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/edit_flyout/options/index.js rename to x-pack/plugins/file_upload/public/application/components/edit_flyout/options/index.js diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/edit_flyout/options/option_lists.js b/x-pack/plugins/file_upload/public/application/components/edit_flyout/options/option_lists.js similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/edit_flyout/options/option_lists.js rename to x-pack/plugins/file_upload/public/application/components/edit_flyout/options/option_lists.js diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/edit_flyout/options/options.js b/x-pack/plugins/file_upload/public/application/components/edit_flyout/options/options.js similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/edit_flyout/options/options.js rename to x-pack/plugins/file_upload/public/application/components/edit_flyout/options/options.js diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/edit_flyout/overrides.js b/x-pack/plugins/file_upload/public/application/components/edit_flyout/overrides.js similarity index 99% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/edit_flyout/overrides.js rename to x-pack/plugins/file_upload/public/application/components/edit_flyout/overrides.js index 23c7b869f5e6f..eb21a740ebce3 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/edit_flyout/overrides.js +++ b/x-pack/plugins/file_upload/public/application/components/edit_flyout/overrides.js @@ -31,7 +31,7 @@ import { // getCharsetOptions, } from './options'; import { isTimestampFormatValid } from './overrides_validation'; -import { withKibana } from '../../../../../../../../../src/plugins/kibana_react/public'; +import { withKibana } from '../../../../../../../src/plugins/kibana_react/public'; import { TIMESTAMP_OPTIONS, CUSTOM_DROPDOWN_OPTION } from './options/option_lists'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/edit_flyout/overrides.test.js b/x-pack/plugins/file_upload/public/application/components/edit_flyout/overrides.test.js similarity index 94% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/edit_flyout/overrides.test.js rename to x-pack/plugins/file_upload/public/application/components/edit_flyout/overrides.test.js index 764ae6fb2b536..8e11d5150359d 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/edit_flyout/overrides.test.js +++ b/x-pack/plugins/file_upload/public/application/components/edit_flyout/overrides.test.js @@ -10,7 +10,7 @@ import React from 'react'; import { Overrides } from './overrides'; -jest.mock('../../../../../../../../../src/plugins/kibana_react/public', () => ({ +jest.mock('../../../../../../../src/plugins/kibana_react/public', () => ({ withKibana: (comp) => { return comp; }, diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/edit_flyout/overrides_validation.js b/x-pack/plugins/file_upload/public/application/components/edit_flyout/overrides_validation.js similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/edit_flyout/overrides_validation.js rename to x-pack/plugins/file_upload/public/application/components/edit_flyout/overrides_validation.js diff --git a/x-pack/plugins/file_upload/public/application/components/examples_list/examples_list.tsx b/x-pack/plugins/file_upload/public/application/components/examples_list/examples_list.tsx new file mode 100644 index 0000000000000..6697cf8b1be5f --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/examples_list/examples_list.tsx @@ -0,0 +1,59 @@ +/* + * 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 React, { FC } from 'react'; + +import { EuiListGroup, EuiListGroupItem } from '@elastic/eui'; + +import { FormattedMessage } from '@kbn/i18n/react'; +import { ExpandedRowFieldHeader } from '../stats_table/components/expanded_row_field_header'; +interface Props { + examples: Array; +} + +export const ExamplesList: FC = ({ examples }) => { + if (examples === undefined || examples === null || !Array.isArray(examples)) { + return null; + } + let examplesContent; + if (examples.length === 0) { + examplesContent = ( + + ); + } else { + examplesContent = examples.map((example, i) => { + return ( + + ); + }); + } + + return ( +
+ + + + + {examplesContent} + +
+ ); +}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/results_links/index.ts b/x-pack/plugins/file_upload/public/application/components/examples_list/index.ts similarity index 84% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/results_links/index.ts rename to x-pack/plugins/file_upload/public/application/components/examples_list/index.ts index 59cb9df6f9ce6..966c844987002 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/results_links/index.ts +++ b/x-pack/plugins/file_upload/public/application/components/examples_list/index.ts @@ -5,4 +5,4 @@ * 2.0. */ -export { ResultsLinks } from './results_links'; +export { ExamplesList } from './examples_list'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/expanded_row/file_based_expanded_row.tsx b/x-pack/plugins/file_upload/public/application/components/expanded_row/file_based_expanded_row.tsx similarity index 86% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/expanded_row/file_based_expanded_row.tsx rename to x-pack/plugins/file_upload/public/application/components/expanded_row/file_based_expanded_row.tsx index 01b5da5c42ccc..e36a9e4dd9e53 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/expanded_row/file_based_expanded_row.tsx +++ b/x-pack/plugins/file_upload/public/application/components/expanded_row/file_based_expanded_row.tsx @@ -14,10 +14,10 @@ import { OtherContent, TextContent, NumberContent, -} from '../../../stats_table/components/field_data_expanded_row'; +} from '../stats_table/components/field_data_expanded_row'; import { GeoPointContent } from './geo_point_content/geo_point_content'; -import { ML_JOB_FIELD_TYPES } from '../../../../../../common/constants/field_types'; -import type { FileBasedFieldVisConfig } from '../../../stats_table/types/field_vis_config'; +import { ML_JOB_FIELD_TYPES } from '../../../../common'; +import type { FileBasedFieldVisConfig } from '../stats_table/types/field_vis_config'; export const FileBasedDataVisualizerExpandedRow = ({ item }: { item: FileBasedFieldVisConfig }) => { const config = item; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/expanded_row/geo_point_content/format_utils.ts b/x-pack/plugins/file_upload/public/application/components/expanded_row/geo_point_content/format_utils.ts similarity index 74% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/expanded_row/geo_point_content/format_utils.ts rename to x-pack/plugins/file_upload/public/application/components/expanded_row/geo_point_content/format_utils.ts index 30e07a6040dab..61b05278c0a4a 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/expanded_row/geo_point_content/format_utils.ts +++ b/x-pack/plugins/file_upload/public/application/components/expanded_row/geo_point_content/format_utils.ts @@ -8,7 +8,25 @@ import { Feature, Point } from 'geojson'; import { euiPaletteColorBlind } from '@elastic/eui'; import { DEFAULT_GEO_REGEX } from './geo_point_content'; -import { SOURCE_TYPES } from '../../../../../../../../maps/common/constants'; +// import { SOURCE_TYPES } from '../../../../../../maps/common/constants'; + +// TODO - copied from maps, fix import link, resolve circular dependency +export enum SOURCE_TYPES { + EMS_TMS = 'EMS_TMS', + EMS_FILE = 'EMS_FILE', + ES_GEO_GRID = 'ES_GEO_GRID', + ES_GEO_LINE = 'ES_GEO_LINE', + ES_SEARCH = 'ES_SEARCH', + ES_PEW_PEW = 'ES_PEW_PEW', + ES_TERM_SOURCE = 'ES_TERM_SOURCE', + EMS_XYZ = 'EMS_XYZ', // identifies a custom TMS source. Name is a little unfortunate. + WMS = 'WMS', + KIBANA_TILEMAP = 'KIBANA_TILEMAP', + REGIONMAP_FILE = 'REGIONMAP_FILE', + GEOJSON_FILE = 'GEOJSON_FILE', + MVT_SINGLE_LAYER = 'MVT_SINGLE_LAYER', + TABLE_SOURCE = 'TABLE_SOURCE', +} export const convertWKTGeoToLonLat = ( value: string | number diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/expanded_row/geo_point_content/geo_point_content.tsx b/x-pack/plugins/file_upload/public/application/components/expanded_row/geo_point_content/geo_point_content.tsx similarity index 81% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/expanded_row/geo_point_content/geo_point_content.tsx rename to x-pack/plugins/file_upload/public/application/components/expanded_row/geo_point_content/geo_point_content.tsx index b420ab43f56f4..eb708db7c2ab5 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/expanded_row/geo_point_content/geo_point_content.tsx +++ b/x-pack/plugins/file_upload/public/application/components/expanded_row/geo_point_content/geo_point_content.tsx @@ -9,12 +9,12 @@ import React, { FC, useMemo } from 'react'; import { EuiFlexItem } from '@elastic/eui'; import { Feature, Point } from 'geojson'; -import type { FieldDataRowProps } from '../../../../stats_table/types/field_data_row'; -import { DocumentStatsTable } from '../../../../stats_table/components/field_data_expanded_row/document_stats'; -import { MlEmbeddedMapComponent } from '../../../../../components/ml_embedded_map'; +import type { FieldDataRowProps } from '../../stats_table/types/field_data_row'; +import { DocumentStatsTable } from '../../stats_table/components/field_data_expanded_row/document_stats'; +// import { MlEmbeddedMapComponent } from '../../ml_embedded_map'; import { convertWKTGeoToLonLat, getGeoPointsLayer } from './format_utils'; -import { ExpandedRowContent } from '../../../../stats_table/components/field_data_expanded_row/expanded_row_content'; -import { ExamplesList } from '../../../../index_based/components/field_data_row/examples_list'; +import { ExpandedRowContent } from '../../stats_table/components/field_data_expanded_row/expanded_row_content'; +import { ExamplesList } from '../../examples_list'; export const DEFAULT_GEO_REGEX = RegExp('(?.+) (?.+)'); @@ -72,7 +72,7 @@ export const GeoPointContent: FC = ({ config }) => { className={'mlDataVisualizerMapWrapper'} data-test-subj={'mlDataVisualizerEmbeddedMap'} > - + {/* */} )} diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/expanded_row/geo_point_content/index.ts b/x-pack/plugins/file_upload/public/application/components/expanded_row/geo_point_content/index.ts similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/expanded_row/geo_point_content/index.ts rename to x-pack/plugins/file_upload/public/application/components/expanded_row/geo_point_content/index.ts diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/expanded_row/index.ts b/x-pack/plugins/file_upload/public/application/components/expanded_row/index.ts similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/expanded_row/index.ts rename to x-pack/plugins/file_upload/public/application/components/expanded_row/index.ts diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/experimental_badge/_experimental_badge.scss b/x-pack/plugins/file_upload/public/application/components/experimental_badge/_experimental_badge.scss similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/experimental_badge/_experimental_badge.scss rename to x-pack/plugins/file_upload/public/application/components/experimental_badge/_experimental_badge.scss diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/experimental_badge/_index.scss b/x-pack/plugins/file_upload/public/application/components/experimental_badge/_index.scss similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/experimental_badge/_index.scss rename to x-pack/plugins/file_upload/public/application/components/experimental_badge/_index.scss diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/experimental_badge/experimental_badge.tsx b/x-pack/plugins/file_upload/public/application/components/experimental_badge/experimental_badge.tsx similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/experimental_badge/experimental_badge.tsx rename to x-pack/plugins/file_upload/public/application/components/experimental_badge/experimental_badge.tsx diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/experimental_badge/index.ts b/x-pack/plugins/file_upload/public/application/components/experimental_badge/index.ts similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/experimental_badge/index.ts rename to x-pack/plugins/file_upload/public/application/components/experimental_badge/index.ts diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/explanation_flyout/explanation_flyout.tsx b/x-pack/plugins/file_upload/public/application/components/explanation_flyout/explanation_flyout.tsx similarity index 96% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/explanation_flyout/explanation_flyout.tsx rename to x-pack/plugins/file_upload/public/application/components/explanation_flyout/explanation_flyout.tsx index 579f2e3340954..93e276dceb024 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/explanation_flyout/explanation_flyout.tsx +++ b/x-pack/plugins/file_upload/public/application/components/explanation_flyout/explanation_flyout.tsx @@ -20,7 +20,7 @@ import { EuiText, EuiSubSteps, } from '@elastic/eui'; -import { FindFileStructureResponse } from '../../../../../../../file_upload/common'; +import { FindFileStructureResponse } from '../../../../common'; interface Props { results: FindFileStructureResponse; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/explanation_flyout/index.ts b/x-pack/plugins/file_upload/public/application/components/explanation_flyout/index.ts similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/explanation_flyout/index.ts rename to x-pack/plugins/file_upload/public/application/components/explanation_flyout/index.ts diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/field_data_row/index.ts b/x-pack/plugins/file_upload/public/application/components/field_data_row/index.ts similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/field_data_row/index.ts rename to x-pack/plugins/file_upload/public/application/components/field_data_row/index.ts diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/field_data_row/number_content_preview.tsx b/x-pack/plugins/file_upload/public/application/components/field_data_row/number_content_preview.tsx similarity index 96% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/field_data_row/number_content_preview.tsx rename to x-pack/plugins/file_upload/public/application/components/field_data_row/number_content_preview.tsx index dc164b5bf3453..a3622202e1d9e 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/field_data_row/number_content_preview.tsx +++ b/x-pack/plugins/file_upload/public/application/components/field_data_row/number_content_preview.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; -import { FileBasedFieldVisConfig } from '../../../stats_table/types'; +import { FileBasedFieldVisConfig } from '../stats_table/types'; export const FileBasedNumberContentPreview = ({ config }: { config: FileBasedFieldVisConfig }) => { const stats = config.stats; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/field_names_filter/field_names_filter.tsx b/x-pack/plugins/file_upload/public/application/components/field_names_filter/field_names_filter.tsx similarity index 90% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/field_names_filter/field_names_filter.tsx rename to x-pack/plugins/file_upload/public/application/components/field_names_filter/field_names_filter.tsx index 9bd16ff5dbefa..45ffb9f5dbb86 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/field_names_filter/field_names_filter.tsx +++ b/x-pack/plugins/file_upload/public/application/components/field_names_filter/field_names_filter.tsx @@ -7,11 +7,11 @@ import React, { FC, useMemo } from 'react'; import { i18n } from '@kbn/i18n'; -import { MultiSelectPicker } from '../../../../components/multi_select_picker'; +import { MultiSelectPicker } from '../multi_select_picker'; import type { FileBasedFieldVisConfig, FileBasedUnknownFieldVisConfig, -} from '../../../stats_table/types/field_vis_config'; +} from '../stats_table/types/field_vis_config'; interface Props { fields: Array; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/field_names_filter/index.ts b/x-pack/plugins/file_upload/public/application/components/field_names_filter/index.ts similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/field_names_filter/index.ts rename to x-pack/plugins/file_upload/public/application/components/field_names_filter/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/field_type_icon/__snapshots__/field_type_icon.test.tsx.snap b/x-pack/plugins/file_upload/public/application/components/field_type_icon/__snapshots__/field_type_icon.test.tsx.snap new file mode 100644 index 0000000000000..769ebdeba9955 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/field_type_icon/__snapshots__/field_type_icon.test.tsx.snap @@ -0,0 +1,16 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`FieldTypeIcon render component when type matches a field type 1`] = ` + + + +`; diff --git a/x-pack/plugins/file_upload/public/application/components/field_type_icon/field_type_icon.test.tsx b/x-pack/plugins/file_upload/public/application/components/field_type_icon/field_type_icon.test.tsx new file mode 100644 index 0000000000000..e054b2b868caf --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/field_type_icon/field_type_icon.test.tsx @@ -0,0 +1,52 @@ +/* + * 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 React from 'react'; +import { mount, shallow } from 'enzyme'; + +import { FieldTypeIcon } from './field_type_icon'; +import { ML_JOB_FIELD_TYPES } from '../../../../common'; + +describe('FieldTypeIcon', () => { + test(`render component when type matches a field type`, () => { + const typeIconComponent = shallow( + + ); + expect(typeIconComponent).toMatchSnapshot(); + }); + + test(`render with tooltip and test hovering`, () => { + // Use fake timers so we don't have to wait for the EuiToolTip timeout + jest.useFakeTimers(); + + const typeIconComponent = mount( + + ); + const container = typeIconComponent.find({ 'data-test-subj': 'mlFieldTypeIcon' }); + + expect(typeIconComponent.find('EuiToolTip').children()).toHaveLength(1); + + container.simulate('mouseover'); + + // Run the timers so the EuiTooltip will be visible + jest.runAllTimers(); + + typeIconComponent.update(); + expect(typeIconComponent.find('EuiToolTip').children()).toHaveLength(2); + + container.simulate('mouseout'); + + // Run the timers so the EuiTooltip will be hidden again + jest.runAllTimers(); + + typeIconComponent.update(); + expect(typeIconComponent.find('EuiToolTip').children()).toHaveLength(1); + + // Clearing all mocks will also reset fake timers. + jest.clearAllMocks(); + }); +}); diff --git a/x-pack/plugins/file_upload/public/application/components/field_type_icon/field_type_icon.tsx b/x-pack/plugins/file_upload/public/application/components/field_type_icon/field_type_icon.tsx new file mode 100644 index 0000000000000..dbfbf2b230619 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/field_type_icon/field_type_icon.tsx @@ -0,0 +1,130 @@ +/* + * 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 React, { FC } from 'react'; + +import { EuiToken, EuiToolTip } from '@elastic/eui'; + +import { i18n } from '@kbn/i18n'; + +import { getMLJobTypeAriaLabel } from '../../util/field_types_utils'; +import { ML_JOB_FIELD_TYPES } from '../../../../common'; +import type { MlJobFieldType } from '../../../../common'; + +interface FieldTypeIconProps { + tooltipEnabled: boolean; + type: MlJobFieldType; + fieldName?: string; + needsAria: boolean; +} + +interface FieldTypeIconContainerProps { + ariaLabel: string | null; + iconType: string; + color: string; + needsAria: boolean; + [key: string]: any; +} + +export const FieldTypeIcon: FC = ({ + tooltipEnabled = false, + type, + fieldName, + needsAria = true, +}) => { + const ariaLabel = getMLJobTypeAriaLabel(type); + + let iconType = 'questionInCircle'; + let color = 'euiColorVis6'; + + switch (type) { + // Set icon types and colors + case ML_JOB_FIELD_TYPES.BOOLEAN: + iconType = 'tokenBoolean'; + color = 'euiColorVis5'; + break; + case ML_JOB_FIELD_TYPES.DATE: + iconType = 'tokenDate'; + color = 'euiColorVis7'; + break; + case ML_JOB_FIELD_TYPES.GEO_POINT: + case ML_JOB_FIELD_TYPES.GEO_SHAPE: + iconType = 'tokenGeo'; + color = 'euiColorVis8'; + break; + case ML_JOB_FIELD_TYPES.TEXT: + iconType = 'document'; + color = 'euiColorVis9'; + break; + case ML_JOB_FIELD_TYPES.IP: + iconType = 'tokenIP'; + color = 'euiColorVis3'; + break; + case ML_JOB_FIELD_TYPES.KEYWORD: + iconType = 'tokenText'; + color = 'euiColorVis0'; + break; + case ML_JOB_FIELD_TYPES.NUMBER: + iconType = 'tokenNumber'; + color = fieldName !== undefined ? 'euiColorVis1' : 'euiColorVis2'; + break; + case ML_JOB_FIELD_TYPES.UNKNOWN: + // Use defaults + break; + } + + const containerProps = { + ariaLabel, + iconType, + color, + needsAria, + }; + + if (tooltipEnabled === true) { + // wrap the inner component inside because EuiToolTip doesn't seem + // to support having another component directly inside the tooltip anchor + // see https://github.com/elastic/eui/issues/839 + return ( + + + + ); + } + + return ; +}; + +// If the tooltip is used, it will apply its events to its first inner child. +// To pass on its properties we apply `rest` to the outer `span` element. +const FieldTypeIconContainer: FC = ({ + ariaLabel, + iconType, + color, + needsAria, + ...rest +}) => { + const wrapperProps: { className: string; 'aria-label'?: string } = { + className: 'field-type-icon', + }; + if (needsAria && ariaLabel) { + wrapperProps['aria-label'] = ariaLabel; + } + + return ( + + + + + + ); +}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/index.ts b/x-pack/plugins/file_upload/public/application/components/field_type_icon/index.ts similarity index 79% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/index.ts rename to x-pack/plugins/file_upload/public/application/components/field_type_icon/index.ts index bb5c2a4f3182b..fa825e447be30 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/index.ts +++ b/x-pack/plugins/file_upload/public/application/components/field_type_icon/index.ts @@ -5,4 +5,4 @@ * 2.0. */ -export { FileDataVisualizerPage } from './file_datavisualizer'; +export { FieldTypeIcon } from './field_type_icon'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/field_types_filter/field_types_filter.tsx b/x-pack/plugins/file_upload/public/application/components/field_types_filter/field_types_filter.tsx similarity index 70% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/field_types_filter/field_types_filter.tsx rename to x-pack/plugins/file_upload/public/application/components/field_types_filter/field_types_filter.tsx index 6ad6cfc84061d..043f25f57627a 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/field_types_filter/field_types_filter.tsx +++ b/x-pack/plugins/file_upload/public/application/components/field_types_filter/field_types_filter.tsx @@ -8,13 +8,25 @@ import React, { FC, useMemo } from 'react'; import { i18n } from '@kbn/i18n'; import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; -import { MultiSelectPicker, Option } from '../../../../components/multi_select_picker'; +import { MultiSelectPicker, Option } from '../multi_select_picker'; import type { FileBasedFieldVisConfig, FileBasedUnknownFieldVisConfig, -} from '../../../stats_table/types/field_vis_config'; -import { FieldTypeIcon } from '../../../../components/field_type_icon'; -import { ML_JOB_FIELD_TYPES_OPTIONS } from '../../../index_based/components/search_panel/field_type_filter'; +} from '../stats_table/types/field_vis_config'; +import { FieldTypeIcon } from '../field_type_icon'; +import { ML_JOB_FIELD_TYPES } from '../../../../common'; + +const ML_JOB_FIELD_TYPES_OPTIONS = { + [ML_JOB_FIELD_TYPES.BOOLEAN]: { name: 'Boolean', icon: 'tokenBoolean' }, + [ML_JOB_FIELD_TYPES.DATE]: { name: 'Date', icon: 'tokenDate' }, + [ML_JOB_FIELD_TYPES.GEO_POINT]: { name: 'Geo point', icon: 'tokenGeo' }, + [ML_JOB_FIELD_TYPES.GEO_SHAPE]: { name: 'Geo shape', icon: 'tokenGeo' }, + [ML_JOB_FIELD_TYPES.IP]: { name: 'IP address', icon: 'tokenIP' }, + [ML_JOB_FIELD_TYPES.KEYWORD]: { name: 'Keyword', icon: 'tokenKeyword' }, + [ML_JOB_FIELD_TYPES.NUMBER]: { name: 'Number', icon: 'tokenNumber' }, + [ML_JOB_FIELD_TYPES.TEXT]: { name: 'Text', icon: 'tokenString' }, + [ML_JOB_FIELD_TYPES.UNKNOWN]: { name: 'Unknown' }, +}; interface Props { fields: Array; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/field_types_filter/index.ts b/x-pack/plugins/file_upload/public/application/components/field_types_filter/index.ts similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/field_types_filter/index.ts rename to x-pack/plugins/file_upload/public/application/components/field_types_filter/index.ts diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/fields_stats/_field_stats_card.scss b/x-pack/plugins/file_upload/public/application/components/fields_stats/_field_stats_card.scss similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/fields_stats/_field_stats_card.scss rename to x-pack/plugins/file_upload/public/application/components/fields_stats/_field_stats_card.scss diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/fields_stats/_fields_stats.scss b/x-pack/plugins/file_upload/public/application/components/fields_stats/_fields_stats.scss similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/fields_stats/_fields_stats.scss rename to x-pack/plugins/file_upload/public/application/components/fields_stats/_fields_stats.scss diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/fields_stats_grid/create_fields.ts b/x-pack/plugins/file_upload/public/application/components/fields_stats_grid/create_fields.ts similarity index 91% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/fields_stats_grid/create_fields.ts rename to x-pack/plugins/file_upload/public/application/components/fields_stats_grid/create_fields.ts index fdbb35d27c531..995a28c20d0db 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/fields_stats_grid/create_fields.ts +++ b/x-pack/plugins/file_upload/public/application/components/fields_stats_grid/create_fields.ts @@ -5,11 +5,11 @@ * 2.0. */ -import { FindFileStructureResponse } from '../../../../../../../file_upload/common'; +import { FindFileStructureResponse } from '../../../../common'; import { getFieldNames, getSupportedFieldType } from './get_field_names'; -import { FileBasedFieldVisConfig } from '../../../stats_table/types'; -import { ML_JOB_FIELD_TYPES } from '../../../../../../common/constants/field_types'; -import { roundToDecimalPlace } from '../../../../formatters/round_to_decimal_place'; +import { FileBasedFieldVisConfig } from '../stats_table/types'; +import { ML_JOB_FIELD_TYPES } from '../../../../common'; +import { roundToDecimalPlace } from '../utils'; export function createFields(results: FindFileStructureResponse) { const { diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/fields_stats_grid/fields_stats_grid.tsx b/x-pack/plugins/file_upload/public/application/components/fields_stats_grid/fields_stats_grid.tsx similarity index 79% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/fields_stats_grid/fields_stats_grid.tsx rename to x-pack/plugins/file_upload/public/application/components/fields_stats_grid/fields_stats_grid.tsx index 1029d58b4c639..534f32bcf1fa5 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/fields_stats_grid/fields_stats_grid.tsx +++ b/x-pack/plugins/file_upload/public/application/components/fields_stats_grid/fields_stats_grid.tsx @@ -7,27 +7,21 @@ import React, { useMemo, FC } from 'react'; import { EuiFlexGroup, EuiSpacer } from '@elastic/eui'; -import type { FindFileStructureResponse } from '../../../../../../../file_upload/common'; -import { DataVisualizerTable, ItemIdToExpandedRowMap } from '../../../stats_table'; -import type { FileBasedFieldVisConfig } from '../../../stats_table/types/field_vis_config'; +import type { FindFileStructureResponse } from '../../../../common'; +import { DataVisualizerTable, ItemIdToExpandedRowMap } from '../stats_table'; +import type { FileBasedFieldVisConfig } from '../stats_table/types/field_vis_config'; import { FileBasedDataVisualizerExpandedRow } from '../expanded_row'; import { DataVisualizerFieldNamesFilter } from '../field_names_filter'; import { DataVisualizerFieldTypesFilter } from '../field_types_filter'; import { createFields } from './create_fields'; import { filterFields } from './filter_fields'; -import { usePageUrlState } from '../../../../util/url_state'; -import { ML_PAGES } from '../../../../../../common/constants/ml_url_generator'; -import { - MetricFieldsCount, - TotalFieldsCount, -} from '../../../stats_table/components/field_count_stats'; -import type { DataVisualizerFileBasedAppState } from '../../../../../../common/types/ml_url_generator'; +import { MetricFieldsCount, TotalFieldsCount } from '../stats_table/components/field_count_stats'; interface Props { results: FindFileStructureResponse; } -export const getDefaultDataVisualizerListState = (): Required => ({ +export const getDefaultDataVisualizerListState = () => ({ pageIndex: 0, pageSize: 10, sortField: 'fieldName', @@ -52,13 +46,9 @@ function getItemIdToExpandedRowMap( export const FieldsStatsGrid: FC = ({ results }) => { const restorableDefaults = getDefaultDataVisualizerListState(); - const [ - dataVisualizerListState, - setDataVisualizerListState, - ] = usePageUrlState( - ML_PAGES.DATA_VISUALIZER_FILE, - restorableDefaults - ); + + const dataVisualizerListState = restorableDefaults; + const setDataVisualizerListState = (a: any) => {}; const visibleFieldTypes = dataVisualizerListState.visibleFieldTypes ?? restorableDefaults.visibleFieldTypes; const setVisibleFieldTypes = (values: string[]) => { @@ -73,11 +63,11 @@ export const FieldsStatsGrid: FC = ({ results }) => { const { fields, totalFieldsCount, totalMetricFieldsCount } = useMemo( () => createFields(results), - [results, visibleFieldNames, visibleFieldTypes] + [results] ); const { filteredFields, visibleFieldsCount, visibleMetricsCount } = useMemo( () => filterFields(fields, visibleFieldNames, visibleFieldTypes), - [results, visibleFieldNames, visibleFieldTypes] + [fields, visibleFieldNames, visibleFieldTypes] ); const fieldsCountStats = { visibleFieldsCount, totalFieldsCount }; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/fields_stats_grid/filter_fields.ts b/x-pack/plugins/file_upload/public/application/components/fields_stats_grid/filter_fields.ts similarity index 88% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/fields_stats_grid/filter_fields.ts rename to x-pack/plugins/file_upload/public/application/components/fields_stats_grid/filter_fields.ts index 2c43d11c3d447..8cccdf73b4625 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/fields_stats_grid/filter_fields.ts +++ b/x-pack/plugins/file_upload/public/application/components/fields_stats_grid/filter_fields.ts @@ -5,11 +5,11 @@ * 2.0. */ -import { ML_JOB_FIELD_TYPES } from '../../../../../../common/constants/field_types'; +import { ML_JOB_FIELD_TYPES } from '../../../../common'; import type { FileBasedFieldVisConfig, FileBasedUnknownFieldVisConfig, -} from '../../../stats_table/types/field_vis_config'; +} from '../stats_table/types/field_vis_config'; export function filterFields( fields: Array, diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/fields_stats_grid/get_field_names.ts b/x-pack/plugins/file_upload/public/application/components/fields_stats_grid/get_field_names.ts similarity index 83% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/fields_stats_grid/get_field_names.ts rename to x-pack/plugins/file_upload/public/application/components/fields_stats_grid/get_field_names.ts index d1cb361a84a72..4b9f65b0ff93f 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/fields_stats_grid/get_field_names.ts +++ b/x-pack/plugins/file_upload/public/application/components/fields_stats_grid/get_field_names.ts @@ -6,10 +6,9 @@ */ import { difference } from 'lodash'; -import type { FindFileStructureResponse } from '../../../../../../../file_upload/common'; -import { MlJobFieldType } from '../../../../../../common/types/field_types'; -import { ML_JOB_FIELD_TYPES } from '../../../../../../common/constants/field_types'; -import { ES_FIELD_TYPES } from '../../../../../../../../../src/plugins/data/common'; +import type { FindFileStructureResponse, MlJobFieldType } from '../../../../common'; +import { ES_FIELD_TYPES } from '../../../../../../../src/plugins/data/common'; +import { ML_JOB_FIELD_TYPES } from '../../../../common'; export function getFieldNames(results: FindFileStructureResponse) { const { mappings, field_stats: fieldStats, column_names: columnNames } = results; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/fields_stats_grid/index.ts b/x-pack/plugins/file_upload/public/application/components/fields_stats_grid/index.ts similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/fields_stats_grid/index.ts rename to x-pack/plugins/file_upload/public/application/components/fields_stats_grid/index.ts diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_contents/_file_contents.scss b/x-pack/plugins/file_upload/public/application/components/file_contents/_file_contents.scss similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_contents/_file_contents.scss rename to x-pack/plugins/file_upload/public/application/components/file_contents/_file_contents.scss diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_contents/_index.scss b/x-pack/plugins/file_upload/public/application/components/file_contents/_index.scss similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_contents/_index.scss rename to x-pack/plugins/file_upload/public/application/components/file_contents/_index.scss diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_contents/file_contents.tsx b/x-pack/plugins/file_upload/public/application/components/file_contents/file_contents.tsx similarity index 94% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_contents/file_contents.tsx rename to x-pack/plugins/file_upload/public/application/components/file_contents/file_contents.tsx index 3de8e5851183d..d8ed48dad3573 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_contents/file_contents.tsx +++ b/x-pack/plugins/file_upload/public/application/components/file_contents/file_contents.tsx @@ -10,7 +10,7 @@ import React, { FC } from 'react'; import { EuiTitle, EuiSpacer } from '@elastic/eui'; -import { MLJobEditor, ML_EDITOR_MODE } from '../../../../jobs/jobs_list/components/ml_job_editor'; +import { MLJobEditor, ML_EDITOR_MODE } from '../ml_job_editor'; interface Props { data: string; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_contents/index.ts b/x-pack/plugins/file_upload/public/application/components/file_contents/index.ts similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_contents/index.ts rename to x-pack/plugins/file_upload/public/application/components/file_contents/index.ts diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_datavisualizer_view/_file_datavisualizer_view.scss b/x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/_file_datavisualizer_view.scss similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_datavisualizer_view/_file_datavisualizer_view.scss rename to x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/_file_datavisualizer_view.scss diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_datavisualizer_view/_index.scss b/x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/_index.scss similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_datavisualizer_view/_index.scss rename to x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/_index.scss diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_datavisualizer_view/constants.ts b/x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/constants.ts similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_datavisualizer_view/constants.ts rename to x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/constants.ts diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_datavisualizer_view/file_datavisualizer_view.js b/x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/file_datavisualizer_view.js similarity index 96% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_datavisualizer_view/file_datavisualizer_view.js rename to x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/file_datavisualizer_view.js index b184913e51b14..ad864a47acf68 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_datavisualizer_view/file_datavisualizer_view.js +++ b/x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/file_datavisualizer_view.js @@ -12,7 +12,6 @@ import { EuiSpacer } from '@elastic/eui'; import { isEqual } from 'lodash'; -import { ml } from '../../../../services/ml_api_service'; import { AboutPanel, LoadingPanel } from '../about_panel'; import { BottomBar } from '../bottom_bar'; import { ResultsView } from '../results_view'; @@ -21,7 +20,8 @@ import { EditFlyout } from '../edit_flyout'; import { ExplanationFlyout } from '../explanation_flyout'; import { ImportView } from '../import_view'; import { DEFAULT_LINES_TO_SAMPLE, readFile, createUrlOverrides, processResults } from '../utils'; -import { getFileUpload } from '../../../../util/dependency_cache'; +import { getMaxBytes } from '../../../get_max_bytes'; +import { hasImportPermission, analyzeFile } from '../../../api'; import { MODE } from './constants'; @@ -54,14 +54,16 @@ export class FileDataVisualizerView extends Component { this.originalSettings = { linesToSample: DEFAULT_LINES_TO_SAMPLE, }; - this.maxFileUploadBytes = getFileUpload().getMaxBytes(); + + this.savedObjectsClient = props.savedObjectsClient; + this.maxFileUploadBytes = getMaxBytes(); } async componentDidMount() { // check the user has the correct permission to import data. // note, calling hasImportPermission with no arguments just checks the // cluster privileges, the user will still need index privileges to create and ingest - const hasPermissionToImport = await getFileUpload().hasImportPermission({ + const hasPermissionToImport = await hasImportPermission({ checkCreateIndexPattern: false, checkHasManagePipeline: true, }); @@ -126,7 +128,7 @@ export class FileDataVisualizerView extends Component { async analyzeFile(fileContents, overrides, isRetry = false) { try { - const resp = await ml.fileDatavisualizer.analyzeFile(fileContents, overrides); + const resp = await analyzeFile(fileContents, overrides); const serverSettings = processResults(resp); const serverOverrides = resp.overrides; @@ -345,9 +347,9 @@ export class FileDataVisualizerView extends Component { fileContents={fileContents} data={data} indexPatterns={this.props.indexPatterns} - kibanaConfig={this.props.kibanaConfig} showBottomBar={this.showBottomBar} hideBottomBar={this.hideBottomBar} + savedObjectsClient={this.savedObjectsClient} /> {bottomBarVisible && ( diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_datavisualizer_view/file_error_callouts.tsx b/x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/file_error_callouts.tsx similarity index 94% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_datavisualizer_view/file_error_callouts.tsx rename to x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/file_error_callouts.tsx index 0fa7de4732c39..1b5b41733e3ef 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_datavisualizer_view/file_error_callouts.tsx +++ b/x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/file_error_callouts.tsx @@ -11,8 +11,18 @@ import React, { FC } from 'react'; import { EuiCallOut, EuiSpacer, EuiButtonEmpty, EuiHorizontalRule } from '@elastic/eui'; import numeral from '@elastic/numeral'; -import { ErrorResponse } from '../../../../../../common/types/errors'; -import { FILE_SIZE_DISPLAY_FORMAT } from '../../../../../../../file_upload/public'; +import { FILE_SIZE_DISPLAY_FORMAT } from '../../../../common'; + +export interface ErrorResponse { + // TODO MOVE THIS OR REPLACE WITH COMMON RESPONSE + body: { + statusCode: number; + error: string; + message: string; + attributes?: any; + }; + name: string; +} interface FileTooLargeProps { fileSize: number; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_datavisualizer_view/index.js b/x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/index.js similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_datavisualizer_view/index.js rename to x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/index.js diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/filebeat_config_flyout/filebeat_config.ts b/x-pack/plugins/file_upload/public/application/components/filebeat_config_flyout/filebeat_config.ts similarity index 95% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/filebeat_config_flyout/filebeat_config.ts rename to x-pack/plugins/file_upload/public/application/components/filebeat_config_flyout/filebeat_config.ts index 2254110432bdb..746140e07ad22 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/filebeat_config_flyout/filebeat_config.ts +++ b/x-pack/plugins/file_upload/public/application/components/filebeat_config_flyout/filebeat_config.ts @@ -6,7 +6,7 @@ */ import { i18n } from '@kbn/i18n'; -import { FindFileStructureResponse } from '../../../../../../../file_upload/common'; +import { FindFileStructureResponse } from '../../../../common'; export function createFilebeatConfig( index: string, diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/filebeat_config_flyout/filebeat_config_flyout.tsx b/x-pack/plugins/file_upload/public/application/components/filebeat_config_flyout/filebeat_config_flyout.tsx similarity index 95% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/filebeat_config_flyout/filebeat_config_flyout.tsx rename to x-pack/plugins/file_upload/public/application/components/filebeat_config_flyout/filebeat_config_flyout.tsx index c3b53d4430087..07f906051e5bb 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/filebeat_config_flyout/filebeat_config_flyout.tsx +++ b/x-pack/plugins/file_upload/public/application/components/filebeat_config_flyout/filebeat_config_flyout.tsx @@ -22,8 +22,8 @@ import { EuiCopy, } from '@elastic/eui'; import { createFilebeatConfig } from './filebeat_config'; -import { useMlKibana } from '../../../../contexts/kibana'; -import { FindFileStructureResponse } from '../../../../../../../file_upload/common'; +import { useFileUploadKibana } from '../../kibana_context'; // copy context? +import { FindFileStructureResponse } from '../../../../common'; export enum EDITOR_MODE { HIDDEN, @@ -48,7 +48,7 @@ export const FilebeatConfigFlyout: FC = ({ const [username, setUsername] = useState(null); const { services: { security }, - } = useMlKibana(); + } = useFileUploadKibana(); useEffect(() => { if (security !== undefined) { @@ -56,12 +56,12 @@ export const FilebeatConfigFlyout: FC = ({ setUsername(user.username === undefined ? null : user.username); }); } - }, []); + }, [security]); useEffect(() => { const config = createFilebeatConfig(index, results, ingestPipelineId, username); setFileBeatConfig(config); - }, [username]); + }, [username, index, ingestPipelineId, results]); return ( diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/filebeat_config_flyout/index.ts b/x-pack/plugins/file_upload/public/application/components/filebeat_config_flyout/index.ts similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/filebeat_config_flyout/index.ts rename to x-pack/plugins/file_upload/public/application/components/filebeat_config_flyout/index.ts diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_errors/errors.tsx b/x-pack/plugins/file_upload/public/application/components/import_errors/errors.tsx similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_errors/errors.tsx rename to x-pack/plugins/file_upload/public/application/components/import_errors/errors.tsx diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_errors/index.ts b/x-pack/plugins/file_upload/public/application/components/import_errors/index.ts similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_errors/index.ts rename to x-pack/plugins/file_upload/public/application/components/import_errors/index.ts diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_progress/import_progress.tsx b/x-pack/plugins/file_upload/public/application/components/import_progress/import_progress.tsx similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_progress/import_progress.tsx rename to x-pack/plugins/file_upload/public/application/components/import_progress/import_progress.tsx diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_progress/index.ts b/x-pack/plugins/file_upload/public/application/components/import_progress/index.ts similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_progress/index.ts rename to x-pack/plugins/file_upload/public/application/components/import_progress/index.ts diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_settings/advanced.tsx b/x-pack/plugins/file_upload/public/application/components/import_settings/advanced.tsx similarity index 97% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_settings/advanced.tsx rename to x-pack/plugins/file_upload/public/application/components/import_settings/advanced.tsx index eb0e09973f0e3..bd3faa4746078 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_settings/advanced.tsx +++ b/x-pack/plugins/file_upload/public/application/components/import_settings/advanced.tsx @@ -19,8 +19,8 @@ import { } from '@elastic/eui'; import { CombinedField, CombinedFieldsForm } from '../combined_fields'; -import { MLJobEditor, ML_EDITOR_MODE } from '../../../../jobs/jobs_list/components/ml_job_editor'; -import { FindFileStructureResponse } from '../../../../../../../file_upload/common'; +import { MLJobEditor, ML_EDITOR_MODE } from '../ml_job_editor'; +import { FindFileStructureResponse } from '../../../../common'; const EDITOR_HEIGHT = '300px'; interface Props { diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_settings/import_settings.tsx b/x-pack/plugins/file_upload/public/application/components/import_settings/import_settings.tsx similarity index 97% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_settings/import_settings.tsx rename to x-pack/plugins/file_upload/public/application/components/import_settings/import_settings.tsx index 5a9597723a0b5..68c6d7a63b1c2 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_settings/import_settings.tsx +++ b/x-pack/plugins/file_upload/public/application/components/import_settings/import_settings.tsx @@ -13,7 +13,7 @@ import { EuiTabbedContent, EuiSpacer } from '@elastic/eui'; import { SimpleSettings } from './simple'; import { AdvancedSettings } from './advanced'; import { CombinedField } from '../combined_fields'; -import { FindFileStructureResponse } from '../../../../../../../file_upload/common'; +import { FindFileStructureResponse } from '../../../../common'; interface Props { index: string; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_settings/index.ts b/x-pack/plugins/file_upload/public/application/components/import_settings/index.ts similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_settings/index.ts rename to x-pack/plugins/file_upload/public/application/components/import_settings/index.ts diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_settings/simple.tsx b/x-pack/plugins/file_upload/public/application/components/import_settings/simple.tsx similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_settings/simple.tsx rename to x-pack/plugins/file_upload/public/application/components/import_settings/simple.tsx diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_summary/_import_sumary.scss b/x-pack/plugins/file_upload/public/application/components/import_summary/_import_sumary.scss similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_summary/_import_sumary.scss rename to x-pack/plugins/file_upload/public/application/components/import_summary/_import_sumary.scss diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_summary/_index.scss b/x-pack/plugins/file_upload/public/application/components/import_summary/_index.scss similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_summary/_index.scss rename to x-pack/plugins/file_upload/public/application/components/import_summary/_index.scss diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_summary/failures.tsx b/x-pack/plugins/file_upload/public/application/components/import_summary/failures.tsx similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_summary/failures.tsx rename to x-pack/plugins/file_upload/public/application/components/import_summary/failures.tsx diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_summary/import_summary.tsx b/x-pack/plugins/file_upload/public/application/components/import_summary/import_summary.tsx similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_summary/import_summary.tsx rename to x-pack/plugins/file_upload/public/application/components/import_summary/import_summary.tsx diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_summary/index.ts b/x-pack/plugins/file_upload/public/application/components/import_summary/index.ts similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_summary/index.ts rename to x-pack/plugins/file_upload/public/application/components/import_summary/index.ts diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_view/import_view.js b/x-pack/plugins/file_upload/public/application/components/import_view/import_view.js similarity index 94% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_view/import_view.js rename to x-pack/plugins/file_upload/public/application/components/import_view/import_view.js index 04175f46c9201..0299cf38b6c1c 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_view/import_view.js +++ b/x-pack/plugins/file_upload/public/application/components/import_view/import_view.js @@ -20,8 +20,7 @@ import { import { i18n } from '@kbn/i18n'; import { debounce } from 'lodash'; -import { getFileUpload } from '../../../../util/dependency_cache'; -import { ResultsLinks } from '../results_links'; +// import { ResultsLinks } from '../results_links'; import { FilebeatConfigFlyout } from '../filebeat_config_flyout'; import { ImportProgress, IMPORT_STATUS } from '../import_progress'; import { ImportErrors } from '../import_errors'; @@ -33,8 +32,7 @@ import { getDefaultCombinedFields, } from '../combined_fields'; import { ExperimentalBadge } from '../experimental_badge'; -import { getIndexPatternNames, loadIndexPatterns } from '../../../../util/index_utils'; -import { ml } from '../../../../services/ml_api_service'; +import { hasImportPermission, importerFactory } from '../../../api'; const DEFAULT_TIME_FIELD = '@timestamp'; const DEFAULT_INDEX_SETTINGS = { number_of_shards: 1 }; @@ -81,6 +79,7 @@ export class ImportView extends Component { super(props); this.state = getDefaultState(DEFAULT_STATE, this.props.results); + this.savedObjectsClient = props.savedObjectsClient; } componentDidMount() { @@ -100,7 +99,7 @@ export class ImportView extends Component { // TODO - sort this function out. it's a mess async import() { - const { data, results, indexPatterns, kibanaConfig, showBottomBar } = this.props; + const { data, results, indexPatterns, showBottomBar } = this.props; const { format } = results; let { timeFieldName } = this.state; @@ -124,7 +123,7 @@ export class ImportView extends Component { async () => { // check to see if the user has permission to create and ingest data into the specified index if ( - (await getFileUpload().hasImportPermission({ + (await hasImportPermission({ checkCreateIndexPattern: createIndexPattern, checkHasManagePipeline: true, indexName: index, @@ -221,7 +220,7 @@ export class ImportView extends Component { } if (success) { - const importer = await getFileUpload().importerFactory(format, { + const importer = await importerFactory(format, { excludeLinesPattern: results.exclude_lines_pattern, multilineStartPattern: results.multiline_start_pattern, }); @@ -294,8 +293,7 @@ export class ImportView extends Component { const indexPatternResp = await createKibanaIndexPattern( indexPatternName, indexPatterns, - timeFieldName, - kibanaConfig + timeFieldName ); success = indexPatternResp.success; this.setState({ @@ -354,16 +352,16 @@ export class ImportView extends Component { return; } - const { exists } = await ml.checkIndexExists({ index }); - const indexNameError = exists ? ( - - ) : ( - isIndexNameValid(index) - ); - + // const { exists } = await ml.checkIndexExists({ index }); + // const indexNameError = exists ? ( + // + // ) : ( + // isIndexNameValid(index) + // ); + const indexNameError = isIndexNameValid(index); // TODO - REMOVE THIS LINE AND COPY INDEX EXISTS this.setState({ checkingValidIndex: false, indexNameError }); }, 500); @@ -427,9 +425,19 @@ export class ImportView extends Component { }; async loadIndexPatternNames() { - await loadIndexPatterns(this.props.indexPatterns); - const indexPatternNames = getIndexPatternNames(); - this.setState({ indexPatternNames }); + try { + const indexPatternNames = ( + await this.savedObjectsClient.find({ + type: 'index-pattern', + fields: ['title'], + perPage: 10000, + }) + ).savedObjects.map(({ attributes }) => attributes && attributes.title); + + this.setState({ indexPatternNames }); + } catch (error) { + console.error('failed to load index patterns', error); + } } render() { @@ -459,7 +467,6 @@ export class ImportView extends Component { pipelineString, indexNameError, indexPatternNameError, - timeFieldName, isFilebeatFlyoutVisible, checkingValidIndex, combinedFields, @@ -588,14 +595,14 @@ export class ImportView extends Component { - + /> */} {isFilebeatFlyoutVisible && ( JSX.Element; +}) { + const [embeddable, setEmbeddable] = useState(); + + const embeddableRoot: React.RefObject = useRef(null); + const baseLayers = useRef(); + + const { + services: { embeddable: embeddablePlugin, maps: mapsPlugin }, + } = useFileUploadKibana(); + + const factory: + | EmbeddableFactory + | undefined = embeddablePlugin + ? embeddablePlugin.getEmbeddableFactory(MAP_SAVED_OBJECT_TYPE) + : undefined; + + // Update the layer list with updated geo points upon refresh + useEffect(() => { + async function updateIndexPatternSearchLayer() { + if ( + embeddable && + !isErrorEmbeddable(embeddable) && + Array.isArray(layerList) && + Array.isArray(baseLayers.current) + ) { + embeddable.setLayerList([...baseLayers.current, ...layerList]); + } + } + updateIndexPatternSearchLayer(); + }, [embeddable, layerList]); + + useEffect(() => { + async function setupEmbeddable() { + if (!factory) { + // eslint-disable-next-line no-console + console.error('Map embeddable not found.'); + return; + } + const input: MapEmbeddableInput = { + id: htmlIdGenerator()(), + attributes: { title: '' }, + filters: [], + hidePanelTitles: true, + refreshConfig: { + value: 0, + pause: false, + }, + viewMode: ViewMode.VIEW, + isLayerTOCOpen: false, + hideFilterActions: true, + // can use mapSettings to center map on anomalies + mapSettings: { + disableInteractive: false, + hideToolbarOverlay: false, + hideLayerControl: false, + hideViewControl: false, + initialLocation: INITIAL_LOCATION.AUTO_FIT_TO_BOUNDS, // this will startup based on data-extent + autoFitToDataBounds: true, // this will auto-fit when there are changes to the filter and/or query + }, + }; + + const embeddableObject = await factory.create(input); + + if (embeddableObject && !isErrorEmbeddable(embeddableObject)) { + const basemapLayerDescriptor = mapsPlugin + ? await mapsPlugin.createLayerDescriptors.createBasemapLayerDescriptor() + : null; + + if (basemapLayerDescriptor) { + baseLayers.current = [basemapLayerDescriptor]; + await embeddableObject.setLayerList(baseLayers.current); + } + } + + setEmbeddable(embeddableObject); + } + + setupEmbeddable(); + // we want this effect to execute exactly once after the component mounts + // eslint-disable-next-line + }, []); + + useEffect(() => { + if (embeddable && !isErrorEmbeddable(embeddable) && mapEmbeddableInput !== undefined) { + embeddable.updateInput(mapEmbeddableInput); + } + }, [embeddable, mapEmbeddableInput]); + + useEffect(() => { + if (embeddable && !isErrorEmbeddable(embeddable) && renderTooltipContent !== undefined) { + embeddable.setRenderTooltipContent(renderTooltipContent); + } + }, [embeddable, renderTooltipContent]); + + // We can only render after embeddable has already initialized + useEffect(() => { + if (embeddableRoot.current && embeddable) { + embeddable.render(embeddableRoot.current); + } + }, [embeddable, embeddableRoot]); + + if (!embeddablePlugin) { + // eslint-disable-next-line no-console + console.error('Embeddable start plugin not found'); + return null; + } + if (!mapsPlugin) { + // eslint-disable-next-line no-console + console.error('Maps start plugin not found'); + return null; + } + + return ( +
+ ); +} +*/ diff --git a/x-pack/plugins/file_upload/public/application/components/ml_job_editor/index.ts b/x-pack/plugins/file_upload/public/application/components/ml_job_editor/index.ts new file mode 100644 index 0000000000000..272157ae968a3 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/ml_job_editor/index.ts @@ -0,0 +1,8 @@ +/* + * 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. + */ + +export { MLJobEditor, ML_EDITOR_MODE } from './ml_job_editor'; diff --git a/x-pack/plugins/file_upload/public/application/components/ml_job_editor/ml_job_editor.tsx b/x-pack/plugins/file_upload/public/application/components/ml_job_editor/ml_job_editor.tsx new file mode 100644 index 0000000000000..a20f75863a37f --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/ml_job_editor/ml_job_editor.tsx @@ -0,0 +1,58 @@ +/* + * 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 React, { FC } from 'react'; + +import { EuiCodeEditor, EuiCodeEditorProps } from '@elastic/eui'; +import { expandLiteralStrings, XJsonMode } from '../../shared_imports'; + +export const ML_EDITOR_MODE = { TEXT: 'text', JSON: 'json', XJSON: new XJsonMode() }; + +interface MlJobEditorProps { + value: string; + height?: string; + width?: string; + mode?: typeof ML_EDITOR_MODE[keyof typeof ML_EDITOR_MODE]; + readOnly?: boolean; + syntaxChecking?: boolean; + theme?: string; + onChange?: EuiCodeEditorProps['onChange']; +} +export const MLJobEditor: FC = ({ + value, + height = '500px', + width = '100%', + mode = ML_EDITOR_MODE.JSON, + readOnly = false, + syntaxChecking = true, + theme = 'textmate', + onChange = () => {}, +}) => { + if (mode === ML_EDITOR_MODE.XJSON) { + value = expandLiteralStrings(value); + } + + return ( + + ); +}; diff --git a/x-pack/plugins/file_upload/public/application/components/multi_select_picker/index.ts b/x-pack/plugins/file_upload/public/application/components/multi_select_picker/index.ts new file mode 100644 index 0000000000000..9d32228e1c4bc --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/multi_select_picker/index.ts @@ -0,0 +1,8 @@ +/* + * 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. + */ + +export { MultiSelectPicker, Option } from './multi_select_picker'; diff --git a/x-pack/plugins/file_upload/public/application/components/multi_select_picker/multi_select_picker.tsx b/x-pack/plugins/file_upload/public/application/components/multi_select_picker/multi_select_picker.tsx new file mode 100644 index 0000000000000..03db3127c85c0 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/multi_select_picker/multi_select_picker.tsx @@ -0,0 +1,145 @@ +/* + * 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 { + EuiFieldSearch, + EuiFilterButton, + EuiFilterGroup, + EuiFilterSelectItem, + EuiIcon, + EuiPopover, + EuiPopoverTitle, + EuiSpacer, +} from '@elastic/eui'; +import React, { FC, ReactNode, useEffect, useState } from 'react'; +import { FormattedMessage } from '@kbn/i18n/react'; + +export interface Option { + name?: string | ReactNode; + value: string; + checked?: 'on' | 'off'; +} + +const NoFilterItems = () => { + return ( +
+
+ + +

+ +

+
+
+ ); +}; + +export const MultiSelectPicker: FC<{ + options: Option[]; + onChange?: (items: string[]) => void; + title?: string; + checkedOptions: string[]; + dataTestSubj: string; +}> = ({ options, onChange, title, checkedOptions, dataTestSubj }) => { + const [items, setItems] = useState(options); + const [searchTerm, setSearchTerm] = useState(''); + + useEffect(() => { + if (searchTerm === '') { + setItems(options); + } else { + const filteredOptions = options.filter((o) => o?.value?.includes(searchTerm)); + setItems(filteredOptions); + } + }, [options, searchTerm]); + + const [isPopoverOpen, setIsPopoverOpen] = useState(false); + + const onButtonClick = () => { + setIsPopoverOpen(!isPopoverOpen); + }; + + const closePopover = () => { + setIsPopoverOpen(false); + }; + + const handleOnChange = (index: number) => { + if (!items[index] || !Array.isArray(checkedOptions) || onChange === undefined) { + return; + } + const item = items[index]; + const foundIndex = checkedOptions.findIndex((fieldValue) => fieldValue === item.value); + if (foundIndex > -1) { + onChange(checkedOptions.filter((_, idx) => idx !== foundIndex)); + } else { + onChange([...checkedOptions, item.value]); + } + }; + + const button = ( + 0} + numActiveFilters={checkedOptions && checkedOptions.length} + > + {title} + + ); + + return ( + + + + setSearchTerm(e.target.value)} + data-test-subj={`${dataTestSubj}-searchInput`} + /> + +
+ {Array.isArray(items) && items.length > 0 ? ( + items.map((item, index) => { + const checked = + checkedOptions && + checkedOptions.findIndex((fieldValue) => fieldValue === item.value) > -1; + + return ( + handleOnChange(index)} + style={{ flexDirection: 'row' }} + data-test-subj={`${dataTestSubj}-option-${item.value}${ + checked ? '-checked' : '' + }`} + > + {item.name ?? item.value} + + ); + }) + ) : ( + + )} +
+
+
+ ); +}; diff --git a/x-pack/plugins/file_upload/public/application/components/results_links/index.ts b/x-pack/plugins/file_upload/public/application/components/results_links/index.ts new file mode 100644 index 0000000000000..c2ab2dc7a582d --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/results_links/index.ts @@ -0,0 +1,8 @@ +/* + * 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. + */ + +// export { ResultsLinks } from './results_links'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/results_links/results_links.tsx b/x-pack/plugins/file_upload/public/application/components/results_links/results_links.tsx similarity index 91% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/results_links/results_links.tsx rename to x-pack/plugins/file_upload/public/application/components/results_links/results_links.tsx index 90b8fb4ac0cbb..1eb26852d657d 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/results_links/results_links.tsx +++ b/x-pack/plugins/file_upload/public/application/components/results_links/results_links.tsx @@ -5,22 +5,23 @@ * 2.0. */ +/* import React, { FC, useState, useEffect } from 'react'; import moment from 'moment'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiFlexGroup, EuiFlexItem, EuiCard, EuiIcon } from '@elastic/eui'; -import { ml } from '../../../../services/ml_api_service'; -import { isFullLicense } from '../../../../license'; +// import { ml } from '../../../../services/ml_api_service'; // pass in http service +import { isFullLicense } from '../../../../license'; // is this needed? import { checkPermission } from '../../../../capabilities/check_capabilities'; import { mlNodesAvailable } from '../../../../ml_nodes_check/check_ml_nodes'; -import { useMlKibana, useMlUrlGenerator } from '../../../../contexts/kibana'; -import { ML_PAGES } from '../../../../../../common/constants/ml_url_generator'; -import { MlCommonGlobalState } from '../../../../../../common/types/ml_url_generator'; +import { useMlKibana, useMlUrlGenerator } from '../../../../contexts/kibana'; // copy context? +import { ML_PAGES } from '../../../../../../common/constants/ml_url_generator'; // copy component? +import { MlCommonGlobalState } from '../../../../../../common/types/ml_url_generator'; // copy component? import { DISCOVER_APP_URL_GENERATOR, DiscoverUrlGeneratorState, -} from '../../../../../../../../../src/plugins/discover/public'; -import { FindFileStructureResponse } from '../../../../../../../file_upload/common'; +} from '../../../../../../../src/plugins/discover/public'; +import { FindFileStructureResponse } from '../../../../common'; const RECHECK_DELAY_MS = 3000; @@ -297,15 +298,21 @@ export const ResultsLinks: FC = ({ }; async function getFullTimeRange(index: string, timeFieldName: string) { - const query = { bool: { must: [{ query_string: { analyze_wildcard: true, query: '*' } }] } }; - const resp = await ml.getTimeFieldRange({ - index, - timeFieldName, - query, - }); + // const query = { bool: { must: [{ query_string: { analyze_wildcard: true, query: '*' } }] } }; + // const resp = await ml.getTimeFieldRange({ + // index, + // timeFieldName, + // query, + // }); + // return { + // from: moment(resp.start.epoch).toISOString(), + // to: moment(resp.end.epoch).toISOString(), + // }; + // TODO FIX return { - from: moment(resp.start.epoch).toISOString(), - to: moment(resp.end.epoch).toISOString(), + from: moment(0).toISOString(), + to: moment(0).toISOString(), }; } +*/ diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/results_view/_index.scss b/x-pack/plugins/file_upload/public/application/components/results_view/_index.scss similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/results_view/_index.scss rename to x-pack/plugins/file_upload/public/application/components/results_view/_index.scss diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/results_view/_results_view.scss b/x-pack/plugins/file_upload/public/application/components/results_view/_results_view.scss similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/results_view/_results_view.scss rename to x-pack/plugins/file_upload/public/application/components/results_view/_results_view.scss diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/results_view/index.ts b/x-pack/plugins/file_upload/public/application/components/results_view/index.ts similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/results_view/index.ts rename to x-pack/plugins/file_upload/public/application/components/results_view/index.ts diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/results_view/results_view.tsx b/x-pack/plugins/file_upload/public/application/components/results_view/results_view.tsx similarity index 97% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/results_view/results_view.tsx rename to x-pack/plugins/file_upload/public/application/components/results_view/results_view.tsx index 7431bfd4295e4..3167cbba28bd7 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/results_view/results_view.tsx +++ b/x-pack/plugins/file_upload/public/application/components/results_view/results_view.tsx @@ -20,7 +20,7 @@ import { EuiFlexGroup, EuiFlexItem, } from '@elastic/eui'; -import { FindFileStructureResponse } from '../../../../../../../file_upload/common'; +import { FindFileStructureResponse } from '../../../../common'; import { FileContents } from '../file_contents'; import { AnalysisSummary } from '../analysis_summary'; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/_field_data_row.scss b/x-pack/plugins/file_upload/public/application/components/stats_table/_field_data_row.scss new file mode 100644 index 0000000000000..1832b0f78b895 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/_field_data_row.scss @@ -0,0 +1,86 @@ +.mlFieldDataCard { + height: 420px; + box-shadow: none; + border-color: $euiBorderColor; + + // Note the names of these styles need to match the type of the field they are displaying. + .boolean { + color: $euiColorVis5; + border-color: $euiColorVis5; + } + + .date { + color: $euiColorVis7; + border-color: $euiColorVis7; + } + + .document_count { + color: $euiColorVis2; + border-color: $euiColorVis2; + } + + .geo_point { + color: $euiColorVis8; + border-color: $euiColorVis8; + } + + .ip { + color: $euiColorVis3; + border-color: $euiColorVis3; + } + + .keyword { + color: $euiColorVis0; + border-color: $euiColorVis0; + } + + .number { + color: $euiColorVis1; + border-color: $euiColorVis1; + } + + .text { + color: $euiColorVis9; + border-color: $euiColorVis9; + } + + .type-other, + .unknown { + color: $euiColorVis6; + border-color: $euiColorVis6; + } + + .mlFieldDataCard__content { + @include euiFontSizeS; + height: 385px; + overflow: hidden; + } + + .mlFieldDataCard__codeContent { + @include euiCodeFont; + } + + .mlFieldDataCard__geoContent { + z-index: auto; + flex: 1; + display: flex; + flex-direction: column; + height: 100%; + position: relative; + .embPanel__content { + display: flex; + flex: 1 1 100%; + z-index: 1; + min-height: 0; // Absolute must for Firefox to scroll contents + } + } + + .mlFieldDataCard__stats { + padding: $euiSizeS $euiSizeS 0 $euiSizeS; + text-align: center; + } + + .mlFieldDataCard__valuesTitle { + text-transform: uppercase; + } +} diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/_index.scss b/x-pack/plugins/file_upload/public/application/components/stats_table/_index.scss new file mode 100644 index 0000000000000..9e838c180713f --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/_index.scss @@ -0,0 +1,56 @@ +@import 'components/field_data_expanded_row/index'; +@import 'components/field_count_stats/index'; +@import 'components/field_data_row/index'; + +.mlDataVisualizerFieldExpandedRow { + padding-left: $euiSize * 4; + width: 100%; + + .mlFieldDataCard__valuesTitle { + text-transform: uppercase; + text-align: left; + color: $euiColorDarkShade; + font-weight: bold; + padding-bottom: $euiSizeS; + } + + .mlFieldDataCard__codeContent { + @include euiCodeFont; + } +} + +.mlDataVisualizer { + .euiTableRow > .euiTableRowCell { + border-bottom: 0; + border-top: $euiBorderThin; + + } + .euiTableRow-isExpandedRow { + + .euiTableRowCell { + background-color: $euiColorEmptyShade !important; + border-top: 0; + border-bottom: $euiBorderThin; + &:hover { + background-color: $euiColorEmptyShade !important; + } + } + } + .mlDataVisualizerSummaryTable { + max-width: 350px; + min-width: 250px; + .euiTableRow > .euiTableRowCell { + border-bottom: 0; + } + .euiTableHeaderCell { + display: none; + } + } + .mlDataVisualizerSummaryTableWrapper { + max-width: 300px; + } + .mlDataVisualizerMapWrapper { + min-height: 300px; + min-width: 600px; + } +} diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/expanded_row_field_header/expanded_row_field_header.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/expanded_row_field_header/expanded_row_field_header.tsx new file mode 100644 index 0000000000000..6c82e103a831f --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/expanded_row_field_header/expanded_row_field_header.tsx @@ -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 { EuiText } from '@elastic/eui'; +import React from 'react'; + +export const ExpandedRowFieldHeader = ({ children }: { children: React.ReactNode }) => ( + + {children} + +); diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/expanded_row_field_header/index.ts b/x-pack/plugins/file_upload/public/application/components/stats_table/components/expanded_row_field_header/index.ts new file mode 100644 index 0000000000000..a92fa7f1e0659 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/expanded_row_field_header/index.ts @@ -0,0 +1,8 @@ +/* + * 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. + */ + +export { ExpandedRowFieldHeader } from './expanded_row_field_header'; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/_index.scss b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/_index.scss new file mode 100644 index 0000000000000..7154d0da2c09c --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/_index.scss @@ -0,0 +1,3 @@ +.mlDataVisualizerFieldCountContainer { + max-width: 300px; +} diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/index.ts b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/index.ts new file mode 100644 index 0000000000000..d841ee2959f62 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/index.ts @@ -0,0 +1,13 @@ +/* + * 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. + */ + +export { TotalFieldsCount, TotalFieldsCountProps, TotalFieldsStats } from './total_fields_count'; +export { + MetricFieldsCount, + MetricFieldsCountProps, + MetricFieldsStats, +} from './metric_fields_count'; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/metric_fields_count.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/metric_fields_count.tsx new file mode 100644 index 0000000000000..dae22cf6daab8 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/metric_fields_count.tsx @@ -0,0 +1,68 @@ +/* + * 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 { EuiFlexGroup, EuiFlexItem, EuiNotificationBadge, EuiText } from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n/react'; +import React, { FC } from 'react'; + +export interface MetricFieldsStats { + visibleMetricsCount: number; + totalMetricFieldsCount: number; +} +export interface MetricFieldsCountProps { + metricsStats?: MetricFieldsStats; +} + +export const MetricFieldsCount: FC = ({ metricsStats }) => { + if ( + !metricsStats || + metricsStats.visibleMetricsCount === undefined || + metricsStats.totalMetricFieldsCount === undefined + ) + return null; + return ( + <> + {metricsStats && ( + + + +
+ +
+
+
+ + + {metricsStats.visibleMetricsCount} + + + + + + + +
+ )} + + ); +}; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/total_fields_count.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/total_fields_count.tsx new file mode 100644 index 0000000000000..aacd7172903f5 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/total_fields_count.tsx @@ -0,0 +1,67 @@ +/* + * 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 { EuiFlexGroup, EuiFlexItem, EuiNotificationBadge, EuiText } from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n/react'; +import React, { FC } from 'react'; + +export interface TotalFieldsStats { + visibleFieldsCount: number; + totalFieldsCount: number; +} + +export interface TotalFieldsCountProps { + fieldsCountStats?: TotalFieldsStats; +} + +export const TotalFieldsCount: FC = ({ fieldsCountStats }) => { + if ( + !fieldsCountStats || + fieldsCountStats.visibleFieldsCount === undefined || + fieldsCountStats.totalFieldsCount === undefined + ) + return null; + + return ( + + + +
+ +
+
+
+ + + + {fieldsCountStats.visibleFieldsCount} + + + + + + + +
+ ); +}; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/_index.scss b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/_index.scss new file mode 100644 index 0000000000000..799beec093cca --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/_index.scss @@ -0,0 +1,7 @@ +@import 'number_content'; + +.mlDataVisualizerExpandedRow { + @include euiBreakpoint('xs', 's', 'm') { + flex-direction: column; + } +} diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/_number_content.scss b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/_number_content.scss new file mode 100644 index 0000000000000..066f405b39cd6 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/_number_content.scss @@ -0,0 +1,4 @@ +.mlMetricDistributionChartContainer { + padding-top: $euiSizeXS; + width: 100%; +} diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/boolean_content.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/boolean_content.tsx new file mode 100644 index 0000000000000..fbcd6b0793a66 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/boolean_content.tsx @@ -0,0 +1,145 @@ +/* + * 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 React, { FC, ReactNode, useMemo } from 'react'; +import { EuiBasicTable, EuiFlexItem, EuiSpacer } from '@elastic/eui'; +import { Axis, BarSeries, Chart, Settings } from '@elastic/charts'; + +import { FormattedMessage } from '@kbn/i18n/react'; +import { i18n } from '@kbn/i18n'; +import type { FieldDataRowProps } from '../../types/field_data_row'; +import { ExpandedRowFieldHeader } from '../expanded_row_field_header'; +import { getTFPercentage } from '../../utils'; +import { roundToDecimalPlace } from '../../../utils'; +import { useDataVizChartTheme } from '../../hooks'; +import { DocumentStatsTable } from './document_stats'; +import { ExpandedRowContent } from './expanded_row_content'; + +function getPercentLabel(value: number): string { + if (value === 0) { + return '0%'; + } + if (value >= 0.1) { + return `${roundToDecimalPlace(value)}%`; + } else { + return '< 0.1%'; + } +} + +function getFormattedValue(value: number, totalCount: number): string { + const percentage = (value / totalCount) * 100; + return `${value} (${getPercentLabel(percentage)})`; +} + +const BOOLEAN_DISTRIBUTION_CHART_HEIGHT = 100; + +export const BooleanContent: FC = ({ config }) => { + const fieldFormat = 'fieldFormat' in config ? config.fieldFormat : undefined; + const formattedPercentages = useMemo(() => getTFPercentage(config), [config]); + const theme = useDataVizChartTheme(); + if (!formattedPercentages) return null; + + const { trueCount, falseCount, count } = formattedPercentages; + const summaryTableItems = [ + { + function: 'true', + display: ( + + ), + value: getFormattedValue(trueCount, count), + }, + { + function: 'false', + display: ( + + ), + value: getFormattedValue(falseCount, count), + }, + ]; + const summaryTableColumns = [ + { + name: '', + render: (summaryItem: { display: ReactNode }) => summaryItem.display, + width: '75px', + }, + { + field: 'value', + name: '', + render: (v: string) => {v}, + }, + ]; + + const summaryTableTitle = i18n.translate( + 'xpack.ml.fieldDataCardExpandedRow.booleanContent.summaryTableTitle', + { + defaultMessage: 'Summary', + } + ); + + return ( + + + + + {summaryTableTitle} + + + + + + + + + + + getFormattedValue(d, count)} + /> + + + + + + + ); +}; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/date_content.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/date_content.tsx new file mode 100644 index 0000000000000..ad773ba5a3b16 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/date_content.tsx @@ -0,0 +1,87 @@ +/* + * 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 React, { FC, ReactNode } from 'react'; +import { EuiBasicTable, EuiFlexItem } from '@elastic/eui'; +// @ts-ignore +import { formatDate } from '@elastic/eui/lib/services/format'; +import { FormattedMessage } from '@kbn/i18n/react'; + +import { i18n } from '@kbn/i18n'; +import type { FieldDataRowProps } from '../../types/field_data_row'; +import { ExpandedRowFieldHeader } from '../expanded_row_field_header'; +import { DocumentStatsTable } from './document_stats'; +import { ExpandedRowContent } from './expanded_row_content'; +const TIME_FORMAT = 'MMM D YYYY, HH:mm:ss.SSS'; +interface SummaryTableItem { + function: string; + display: ReactNode; + value: number | string | undefined | null; +} + +export const DateContent: FC = ({ config }) => { + const { stats } = config; + if (stats === undefined) return null; + + const { earliest, latest } = stats; + + const summaryTableTitle = i18n.translate('xpack.ml.fieldDataCard.cardDate.summaryTableTitle', { + defaultMessage: 'Summary', + }); + const summaryTableItems = [ + { + function: 'earliest', + display: ( + + ), + value: typeof earliest === 'string' ? earliest : formatDate(earliest, TIME_FORMAT), + }, + { + function: 'latest', + display: ( + + ), + value: typeof latest === 'string' ? latest : formatDate(latest, TIME_FORMAT), + }, + ]; + const summaryTableColumns = [ + { + name: '', + render: (summaryItem: { display: ReactNode }) => summaryItem.display, + width: '75px', + }, + { + field: 'value', + name: '', + render: (v: string) => {v}, + }, + ]; + + return ( + + + + {summaryTableTitle} + + className={'mlDataVisualizerSummaryTable'} + data-test-subj={'mlDateSummaryTable'} + compressed + items={summaryTableItems} + columns={summaryTableColumns} + tableCaption={summaryTableTitle} + tableLayout="auto" + /> + + + ); +}; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/document_stats.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/document_stats.tsx new file mode 100644 index 0000000000000..a22bb93319ac1 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/document_stats.tsx @@ -0,0 +1,93 @@ +/* + * 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 { FormattedMessage } from '@kbn/i18n/react'; +import React, { FC, ReactNode } from 'react'; +import { i18n } from '@kbn/i18n'; +import { EuiBasicTable, EuiFlexItem } from '@elastic/eui'; +import { ExpandedRowFieldHeader } from '../expanded_row_field_header'; +import { FieldDataRowProps } from '../../types'; +import { roundToDecimalPlace } from '../../../utils'; + +const metaTableColumns = [ + { + name: '', + render: (metaItem: { display: ReactNode }) => metaItem.display, + width: '75px', + }, + { + field: 'value', + name: '', + render: (v: string) => {v}, + }, +]; + +const metaTableTitle = i18n.translate( + 'xpack.ml.fieldDataCardExpandedRow.documentStatsTable.metaTableTitle', + { + defaultMessage: 'Documents stats', + } +); + +export const DocumentStatsTable: FC = ({ config }) => { + if ( + config?.stats === undefined || + config.stats.cardinality === undefined || + config.stats.count === undefined || + config.stats.sampleCount === undefined + ) + return null; + const { cardinality, count, sampleCount } = config.stats; + const metaTableItems = [ + { + function: 'count', + display: ( + + ), + value: count, + }, + { + function: 'percentage', + display: ( + + ), + value: `${roundToDecimalPlace((count / sampleCount) * 100)}%`, + }, + { + function: 'distinctValues', + display: ( + + ), + value: cardinality, + }, + ]; + + return ( + + {metaTableTitle} + + + ); +}; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/expanded_row_content.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/expanded_row_content.tsx new file mode 100644 index 0000000000000..8e14945b32a7f --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/expanded_row_content.tsx @@ -0,0 +1,25 @@ +/* + * 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 React, { FC, ReactNode } from 'react'; +import { EuiFlexGroup } from '@elastic/eui'; + +interface Props { + children: ReactNode; + dataTestSubj: string; +} +export const ExpandedRowContent: FC = ({ children, dataTestSubj }) => { + return ( + + {children} + + ); +}; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/index.ts b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/index.ts new file mode 100644 index 0000000000000..c8db31146936d --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/index.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. + */ + +export { BooleanContent } from './boolean_content'; +export { DateContent } from './date_content'; +export { GeoPointContent } from '../../../expanded_row/geo_point_content/geo_point_content'; +export { KeywordContent } from './keyword_content'; +export { IpContent } from './ip_content'; +export { NumberContent } from './number_content'; +export { OtherContent } from './other_content'; +export { TextContent } from './text_content'; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/ip_content.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/ip_content.tsx new file mode 100644 index 0000000000000..07adf3103b78e --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/ip_content.tsx @@ -0,0 +1,27 @@ +/* + * 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 React, { FC } from 'react'; +import type { FieldDataRowProps } from '../../types/field_data_row'; +import { TopValues } from '../../../top_values'; +import { DocumentStatsTable } from './document_stats'; +import { ExpandedRowContent } from './expanded_row_content'; + +export const IpContent: FC = ({ config }) => { + const { stats } = config; + if (stats === undefined) return null; + const { count, sampleCount, cardinality } = stats; + if (count === undefined || sampleCount === undefined || cardinality === undefined) return null; + const fieldFormat = 'fieldFormat' in config ? config.fieldFormat : undefined; + + return ( + + + + + ); +}; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/keyword_content.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/keyword_content.tsx new file mode 100644 index 0000000000000..3f1a7aad5463f --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/keyword_content.tsx @@ -0,0 +1,25 @@ +/* + * 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 React, { FC } from 'react'; +import type { FieldDataRowProps } from '../../types/field_data_row'; +import { TopValues } from '../../../top_values'; +import { DocumentStatsTable } from './document_stats'; +import { ExpandedRowContent } from './expanded_row_content'; + +export const KeywordContent: FC = ({ config }) => { + const { stats } = config; + const fieldFormat = 'fieldFormat' in config ? config.fieldFormat : undefined; + + return ( + + + + + + ); +}; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/number_content.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/number_content.tsx new file mode 100644 index 0000000000000..aa11063b809c5 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/number_content.tsx @@ -0,0 +1,154 @@ +/* + * 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 React, { FC, ReactNode, useEffect, useState } from 'react'; +import { EuiBasicTable, EuiFlexItem, EuiText } from '@elastic/eui'; + +import { FormattedMessage } from '@kbn/i18n/react'; +import { i18n } from '@kbn/i18n'; +import type { FieldDataRowProps } from '../../types/field_data_row'; +import { kibanaFieldFormat, numberAsOrdinal } from '../../../utils'; +import { + MetricDistributionChart, + MetricDistributionChartData, + buildChartDataFromStats, +} from '../metric_distribution_chart'; +import { TopValues } from '../../../top_values'; +import { ExpandedRowFieldHeader } from '../expanded_row_field_header'; +import { DocumentStatsTable } from './document_stats'; +import { ExpandedRowContent } from './expanded_row_content'; + +const METRIC_DISTRIBUTION_CHART_WIDTH = 325; +const METRIC_DISTRIBUTION_CHART_HEIGHT = 200; + +interface SummaryTableItem { + function: string; + display: ReactNode; + value: number | string | undefined | null; +} + +export const NumberContent: FC = ({ config }) => { + const { stats } = config; + + useEffect(() => { + const chartData = buildChartDataFromStats(stats, METRIC_DISTRIBUTION_CHART_WIDTH); + setDistributionChartData(chartData); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + + const defaultChartData: MetricDistributionChartData[] = []; + const [distributionChartData, setDistributionChartData] = useState(defaultChartData); + + if (stats === undefined) return null; + const { min, median, max, distribution } = stats; + const fieldFormat = 'fieldFormat' in config ? config.fieldFormat : undefined; + + const summaryTableItems = [ + { + function: 'min', + display: ( + + ), + value: kibanaFieldFormat(min, fieldFormat), + }, + { + function: 'median', + display: ( + + ), + value: kibanaFieldFormat(median, fieldFormat), + }, + { + function: 'max', + display: ( + + ), + value: kibanaFieldFormat(max, fieldFormat), + }, + ]; + const summaryTableColumns = [ + { + name: '', + render: (summaryItem: { display: ReactNode }) => summaryItem.display, + width: '75px', + }, + { + field: 'value', + name: '', + render: (v: string) => {v}, + }, + ]; + + const summaryTableTitle = i18n.translate( + 'xpack.ml.fieldDataCardExpandedRow.numberContent.summaryTableTitle', + { + defaultMessage: 'Summary', + } + ); + return ( + + + + {summaryTableTitle} + + className={'mlDataVisualizerSummaryTable'} + compressed + items={summaryTableItems} + columns={summaryTableColumns} + tableCaption={summaryTableTitle} + data-test-subj={'mlNumberSummaryTable'} + /> + + + {stats && ( + + )} + {distribution && ( + + + + + + + + + + + + + + + + + )} + + ); +}; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/other_content.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/other_content.tsx new file mode 100644 index 0000000000000..cb1605331551e --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/other_content.tsx @@ -0,0 +1,28 @@ +/* + * 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 React, { FC } from 'react'; +import { EuiFlexItem } from '@elastic/eui'; +import type { FieldDataRowProps } from '../../types/field_data_row'; +import { ExamplesList } from '../../../examples_list'; +import { DocumentStatsTable } from './document_stats'; +import { ExpandedRowContent } from './expanded_row_content'; + +export const OtherContent: FC = ({ config }) => { + const { stats } = config; + if (stats === undefined) return null; + return ( + + + {Array.isArray(stats.examples) && ( + + + + )} + + ); +}; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/text_content.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/text_content.tsx new file mode 100644 index 0000000000000..85e7c2de20113 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/text_content.tsx @@ -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 React, { FC, Fragment } from 'react'; +import { EuiCallOut, EuiFlexItem, EuiSpacer } from '@elastic/eui'; + +import { FormattedMessage } from '@kbn/i18n/react'; +import { i18n } from '@kbn/i18n'; + +import type { FieldDataRowProps } from '../../types/field_data_row'; +import { ExamplesList } from '../../../examples_list'; +import { ExpandedRowContent } from './expanded_row_content'; + +export const TextContent: FC = ({ config }) => { + const { stats } = config; + if (stats === undefined) return null; + + const { examples } = stats; + if (examples === undefined) return null; + + const numExamples = examples.length; + + return ( + + + {numExamples > 0 && } + {numExamples === 0 && ( + + + + _source, + }} + /> + + + + copy_to, + sourceParam: _source, + includesParam: includes, + excludesParam: excludes, + }} + /> + + + )} + + + ); +}; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/_index.scss b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/_index.scss new file mode 100644 index 0000000000000..27483feb573b8 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/_index.scss @@ -0,0 +1,3 @@ +.mlDataVisualizerColumnHeaderIcon { + max-width: $euiSizeM; +} diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/boolean_content_preview.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/boolean_content_preview.tsx new file mode 100644 index 0000000000000..c6c28da0baf04 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/boolean_content_preview.tsx @@ -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 React, { FC, useMemo } from 'react'; +// import { EuiDataGridColumn } from '@elastic/eui'; +import { OrdinalChartData } from './field_histograms'; +// import { ColumnChart } from '../../../../../../components/data_grid/column_chart'; // TODO copy component +import { FieldDataRowProps } from '../../types'; +import { getTFPercentage } from '../../utils'; + +export const BooleanContentPreview: FC = ({ config }) => { + const chartData = useMemo(() => { + const results = getTFPercentage(config); + if (results) { + const data = [ + { key: 'true', key_as_string: 'true', doc_count: results.trueCount }, + { key: 'false', key_as_string: 'false', doc_count: results.falseCount }, + ]; + return { id: config.fieldName, cardinality: 2, data, type: 'boolean' } as OrdinalChartData; + } + }, [config]); + if (!chartData || config.fieldName === undefined) return null; + + // const columnType: EuiDataGridColumn = { + // id: config.fieldName, + // schema: undefined, + // }; + // const dataTestSubj = `mlDataGridChart-${config.fieldName}`; + + return ( + <> + // + ); +}; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/column_chart.scss b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/column_chart.scss new file mode 100644 index 0000000000000..756804a0e6aa0 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/column_chart.scss @@ -0,0 +1,32 @@ +.mlDataGridChart__histogram { + width: 100%; + height: $euiSizeXL + $euiSizeXXL; +} + +.mlDataGridChart__legend { + @include euiTextTruncate; + @include euiFontSizeXS; + + color: $euiColorMediumShade; + display: block; + overflow-x: hidden; + margin: $euiSizeXS 0 0 0; + font-style: italic; + font-weight: normal; + text-align: left; +} + +.mlDataGridChart__legend--numeric { + text-align: right; +} + +.mlDataGridChart__legendBoolean { + width: 100%; + min-width: $euiButtonMinWidth; + td { text-align: center } +} + +/* Override to align column header to bottom of cell when no chart is available */ +.mlDataGrid .euiDataGridHeaderCell__content { + margin-top: auto; +} diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/column_chart.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/column_chart.tsx new file mode 100644 index 0000000000000..c074d105bedc1 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/column_chart.tsx @@ -0,0 +1,84 @@ +/* + * 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 React, { FC } from 'react'; +import classNames from 'classnames'; + +import { BarSeries, Chart, Settings } from '@elastic/charts'; +import { EuiDataGridColumn } from '@elastic/eui'; + +import './column_chart.scss'; + +import { isUnsupportedChartData, ChartData } from './field_histograms'; + +import { useColumnChart } from './use_column_chart'; + +interface Props { + chartData: ChartData; + columnType: EuiDataGridColumn; + dataTestSubj: string; + hideLabel?: boolean; + maxChartColumns?: number; +} + +const columnChartTheme = { + background: { color: 'transparent' }, + chartMargins: { + left: 0, + right: 0, + top: 0, + bottom: 1, + }, + chartPaddings: { + left: 0, + right: 0, + top: 0, + bottom: 0, + }, + scales: { barsPadding: 0.1 }, +}; +export const ColumnChart: FC = ({ + chartData, + columnType, + dataTestSubj, + hideLabel, + maxChartColumns, +}) => { + const { data, legendText, xScaleType } = useColumnChart(chartData, columnType, maxChartColumns); + + return ( +
+ {!isUnsupportedChartData(chartData) && data.length > 0 && ( +
+ + + d.datum.color} + data={data} + /> + +
+ )} +
+ {legendText} +
+ {!hideLabel &&
{columnType.id}
} +
+ ); +}; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/distinct_values.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/distinct_values.tsx new file mode 100644 index 0000000000000..acbe081599c62 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/distinct_values.tsx @@ -0,0 +1,24 @@ +/* + * 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 { EuiFlexGroup, EuiFlexItem, EuiIcon, EuiText } from '@elastic/eui'; + +import React from 'react'; + +export const DistinctValues = ({ cardinality }: { cardinality?: number }) => { + if (cardinality === undefined) return null; + return ( + + + + + + {cardinality} + + + ); +}; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/document_stats.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/document_stats.tsx new file mode 100644 index 0000000000000..903b60c4a3082 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/document_stats.tsx @@ -0,0 +1,33 @@ +/* + * 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 { EuiFlexGroup, EuiFlexItem, EuiIcon, EuiText } from '@elastic/eui'; + +import React from 'react'; +import type { FieldDataRowProps } from '../../types/field_data_row'; +import { roundToDecimalPlace } from '../../../utils'; + +export const DocumentStat = ({ config }: FieldDataRowProps) => { + const { stats } = config; + if (stats === undefined) return null; + + const { count, sampleCount } = stats; + if (count === undefined || sampleCount === undefined) return null; + + const docsPercent = roundToDecimalPlace((count / sampleCount) * 100); + + return ( + + + + + + {count} ({docsPercent}%) + + + ); +}; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/field_histograms.ts b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/field_histograms.ts new file mode 100644 index 0000000000000..22b0195a579ac --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/field_histograms.ts @@ -0,0 +1,68 @@ +/* + * 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. + */ + +export interface NumericDataItem { + key: number; + key_as_string?: string | number; + doc_count: number; +} + +export interface NumericChartData { + data: NumericDataItem[]; + id: string; + interval: number; + stats: [number, number]; + type: 'numeric'; +} + +export const isNumericChartData = (arg: any): arg is NumericChartData => { + return ( + typeof arg === 'object' && + arg.hasOwnProperty('data') && + arg.hasOwnProperty('id') && + arg.hasOwnProperty('interval') && + arg.hasOwnProperty('stats') && + arg.hasOwnProperty('type') && + arg.type === 'numeric' + ); +}; + +export interface OrdinalDataItem { + key: string; + key_as_string?: string; + doc_count: number; +} + +export interface OrdinalChartData { + cardinality: number; + data: OrdinalDataItem[]; + id: string; + type: 'ordinal' | 'boolean'; +} + +export const isOrdinalChartData = (arg: any): arg is OrdinalChartData => { + return ( + typeof arg === 'object' && + arg.hasOwnProperty('data') && + arg.hasOwnProperty('cardinality') && + arg.hasOwnProperty('id') && + arg.hasOwnProperty('type') && + (arg.type === 'ordinal' || arg.type === 'boolean') + ); +}; + +export interface UnsupportedChartData { + id: string; + type: 'unsupported'; +} + +export const isUnsupportedChartData = (arg: any): arg is UnsupportedChartData => { + return typeof arg === 'object' && arg.hasOwnProperty('type') && arg.type === 'unsupported'; +}; + +export type ChartDataItem = NumericDataItem | OrdinalDataItem; +export type ChartData = NumericChartData | OrdinalChartData | UnsupportedChartData; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/index.ts b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/index.ts new file mode 100644 index 0000000000000..e4c0cc80eeb35 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/index.ts @@ -0,0 +1,8 @@ +/* + * 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. + */ + +export { BooleanContentPreview } from './boolean_content_preview'; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/number_content_preview.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/number_content_preview.tsx new file mode 100644 index 0000000000000..59ffc59caf5ab --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/number_content_preview.tsx @@ -0,0 +1,81 @@ +/* + * 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 React, { FC, useEffect, useState } from 'react'; +import { EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui'; +import classNames from 'classnames'; +import { + MetricDistributionChart, + MetricDistributionChartData, + buildChartDataFromStats, +} from '../metric_distribution_chart'; +import { FieldVisConfig } from '../../types'; +import { kibanaFieldFormat, formatSingleValue } from '../../../utils'; + +const METRIC_DISTRIBUTION_CHART_WIDTH = 150; +const METRIC_DISTRIBUTION_CHART_HEIGHT = 80; + +export interface NumberContentPreviewProps { + config: FieldVisConfig; +} + +export const IndexBasedNumberContentPreview: FC = ({ config }) => { + const { stats, fieldFormat, fieldName } = config; + const defaultChartData: MetricDistributionChartData[] = []; + const [distributionChartData, setDistributionChartData] = useState(defaultChartData); + const [legendText, setLegendText] = useState<{ min: number; max: number } | undefined>(); + const dataTestSubj = `mlDataGridChart-${fieldName}`; + useEffect(() => { + const chartData = buildChartDataFromStats(stats, METRIC_DISTRIBUTION_CHART_WIDTH); + if ( + Array.isArray(chartData) && + chartData[0].x !== undefined && + chartData[chartData.length - 1].x !== undefined + ) { + setDistributionChartData(chartData); + setLegendText({ + min: formatSingleValue(chartData[0].x), + max: formatSingleValue(chartData[chartData.length - 1].x), + }); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + + return ( +
+
+ +
+
+ {legendText && ( + <> + + + + {kibanaFieldFormat(legendText.min, fieldFormat)} + + + {kibanaFieldFormat(legendText.max, fieldFormat)} + + + + )} +
+
+ ); +}; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/top_values_preview.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/top_values_preview.tsx new file mode 100644 index 0000000000000..63b15fdf30b3b --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/top_values_preview.tsx @@ -0,0 +1,44 @@ +/* + * 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 React, { FC } from 'react'; +import { EuiDataGridColumn } from '@elastic/eui'; +import { ChartData, OrdinalDataItem } from './field_histograms'; +import { ColumnChart } from './column_chart'; +import type { FieldDataRowProps } from '../../types/field_data_row'; + +export const TopValuesPreview: FC = ({ config }) => { + const { stats } = config; + if (stats === undefined) return null; + const { topValues, cardinality } = stats; + if (cardinality === undefined || topValues === undefined || config.fieldName === undefined) + return null; + + const data: OrdinalDataItem[] = topValues.map((d) => ({ + ...d, + key: d.key.toString(), + })); + const chartData: ChartData = { + cardinality, + data, + id: config.fieldName, + type: 'ordinal', + }; + const columnType: EuiDataGridColumn = { + id: config.fieldName, + schema: undefined, + }; + return ( + + ); +}; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/use_column_chart.test.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/use_column_chart.test.tsx new file mode 100644 index 0000000000000..2c92c366b2d73 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/use_column_chart.test.tsx @@ -0,0 +1,177 @@ +/* + * 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 React from 'react'; +import { render } from '@testing-library/react'; +import { renderHook } from '@testing-library/react-hooks'; +import '@testing-library/jest-dom/extend-expect'; + +import { KBN_FIELD_TYPES } from '../../../../../../../../../src/plugins/data/public'; + +import { + isNumericChartData, + isOrdinalChartData, + isUnsupportedChartData, + NumericChartData, + OrdinalChartData, + UnsupportedChartData, +} from './field_histograms'; + +import { getFieldType, getLegendText, getXScaleType, useColumnChart } from './use_column_chart'; + +describe('getFieldType()', () => { + it('should return the Kibana field type for a given EUI data grid schema', () => { + expect(getFieldType('text')).toBe('string'); + expect(getFieldType('datetime')).toBe('date'); + expect(getFieldType('numeric')).toBe('number'); + expect(getFieldType('boolean')).toBe('boolean'); + expect(getFieldType('json')).toBe('object'); + expect(getFieldType('non-aggregatable')).toBe(undefined); + }); +}); + +describe('getXScaleType()', () => { + it('should return the corresponding x axis scale type for a Kibana field type', () => { + expect(getXScaleType(KBN_FIELD_TYPES.BOOLEAN)).toBe('ordinal'); + expect(getXScaleType(KBN_FIELD_TYPES.IP)).toBe('ordinal'); + expect(getXScaleType(KBN_FIELD_TYPES.STRING)).toBe('ordinal'); + expect(getXScaleType(KBN_FIELD_TYPES.DATE)).toBe('time'); + expect(getXScaleType(KBN_FIELD_TYPES.NUMBER)).toBe('linear'); + expect(getXScaleType(undefined)).toBe(undefined); + }); +}); + +const validNumericChartData: NumericChartData = { + data: [], + id: 'the-id', + interval: 10, + stats: [0, 0], + type: 'numeric', +}; + +const validOrdinalChartData: OrdinalChartData = { + cardinality: 10, + data: [], + id: 'the-id', + type: 'ordinal', +}; + +const validUnsupportedChartData: UnsupportedChartData = { id: 'the-id', type: 'unsupported' }; + +describe('isNumericChartData()', () => { + it('should return true for valid numeric chart data', () => { + expect(isNumericChartData(validNumericChartData)).toBe(true); + }); + it('should return false for invalid numeric chart data', () => { + expect(isNumericChartData(undefined)).toBe(false); + expect(isNumericChartData({})).toBe(false); + expect(isNumericChartData({ data: [] })).toBe(false); + expect(isNumericChartData(validOrdinalChartData)).toBe(false); + expect(isNumericChartData(validUnsupportedChartData)).toBe(false); + }); +}); + +describe('isOrdinalChartData()', () => { + it('should return true for valid ordinal chart data', () => { + expect(isOrdinalChartData(validOrdinalChartData)).toBe(true); + }); + it('should return false for invalid ordinal chart data', () => { + expect(isOrdinalChartData(undefined)).toBe(false); + expect(isOrdinalChartData({})).toBe(false); + expect(isOrdinalChartData({ data: [] })).toBe(false); + expect(isOrdinalChartData(validNumericChartData)).toBe(false); + expect(isOrdinalChartData(validUnsupportedChartData)).toBe(false); + }); +}); + +describe('isUnsupportedChartData()', () => { + it('should return true for unsupported chart data', () => { + expect(isUnsupportedChartData(validUnsupportedChartData)).toBe(true); + }); + it('should return false for invalid unsupported chart data', () => { + expect(isUnsupportedChartData(undefined)).toBe(false); + expect(isUnsupportedChartData({})).toBe(false); + expect(isUnsupportedChartData({ data: [] })).toBe(false); + expect(isUnsupportedChartData(validNumericChartData)).toBe(false); + expect(isUnsupportedChartData(validOrdinalChartData)).toBe(false); + }); +}); + +describe('getLegendText()', () => { + it('should return the chart legend text for unsupported chart types', () => { + expect(getLegendText(validUnsupportedChartData)).toBe('Chart not supported.'); + }); + it('should return the chart legend text for empty datasets', () => { + expect(getLegendText(validNumericChartData)).toBe('0 documents contain field.'); + }); + it('should return the chart legend text for boolean chart types', () => { + const { getByText } = render( + <> + {getLegendText({ + cardinality: 2, + data: [ + { key: 'true', key_as_string: 'true', doc_count: 10 }, + { key: 'false', key_as_string: 'false', doc_count: 20 }, + ], + id: 'the-id', + type: 'boolean', + })} + + ); + expect(getByText('true')).toBeInTheDocument(); + expect(getByText('false')).toBeInTheDocument(); + }); + it('should return the chart legend text for ordinal chart data with less than max categories', () => { + expect(getLegendText({ ...validOrdinalChartData, data: [{ key: 'cat', doc_count: 10 }] })).toBe( + '10 categories' + ); + }); + it('should return the chart legend text for ordinal chart data with more than max categories', () => { + expect( + getLegendText({ + ...validOrdinalChartData, + cardinality: 30, + data: [{ key: 'cat', doc_count: 10 }], + }) + ).toBe('top 20 of 30 categories'); + }); + it('should return the chart legend text for numeric datasets', () => { + expect( + getLegendText({ + ...validNumericChartData, + data: [{ key: 1, doc_count: 10 }], + stats: [1, 100], + }) + ).toBe('1 - 100'); + expect( + getLegendText({ + ...validNumericChartData, + data: [{ key: 1, doc_count: 10 }], + stats: [100, 100], + }) + ).toBe('100'); + expect( + getLegendText({ + ...validNumericChartData, + data: [{ key: 1, doc_count: 10 }], + stats: [1.2345, 6.3456], + }) + ).toBe('1.23 - 6.35'); + }); +}); + +describe('useColumnChart()', () => { + it('should return the column chart hook data', () => { + const { result } = renderHook(() => + useColumnChart(validNumericChartData, { id: 'the-id', schema: 'numeric' }) + ); + + expect(result.current.data).toStrictEqual([]); + expect(result.current.legendText).toBe('0 documents contain field.'); + expect(result.current.xScaleType).toBe('linear'); + }); +}); diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx new file mode 100644 index 0000000000000..912f930a89e07 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx @@ -0,0 +1,206 @@ +/* + * 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 moment from 'moment'; +import { BehaviorSubject } from 'rxjs'; +import React from 'react'; + +import useObservable from 'react-use/lib/useObservable'; + +import { euiPaletteColorBlind, EuiDataGridColumn } from '@elastic/eui'; + +import { i18n } from '@kbn/i18n'; + +import { KBN_FIELD_TYPES } from '../../../../../../../../../src/plugins/data/public'; + +import { + isNumericChartData, + isOrdinalChartData, + ChartData, + ChartDataItem, + NumericDataItem, + OrdinalDataItem, +} from './field_histograms'; + +const NON_AGGREGATABLE = 'non-aggregatable'; + +export const hoveredRow$ = new BehaviorSubject(null); + +export const BAR_COLOR = euiPaletteColorBlind()[0]; +const BAR_COLOR_BLUR = euiPaletteColorBlind({ rotations: 2 })[10]; +const MAX_CHART_COLUMNS = 20; + +type XScaleType = 'ordinal' | 'time' | 'linear' | undefined; +export const getXScaleType = (kbnFieldType: KBN_FIELD_TYPES | undefined): XScaleType => { + switch (kbnFieldType) { + case KBN_FIELD_TYPES.BOOLEAN: + case KBN_FIELD_TYPES.IP: + case KBN_FIELD_TYPES.STRING: + return 'ordinal'; + case KBN_FIELD_TYPES.DATE: + return 'time'; + case KBN_FIELD_TYPES.NUMBER: + return 'linear'; + } +}; + +export const getFieldType = (schema: EuiDataGridColumn['schema']): KBN_FIELD_TYPES | undefined => { + if (schema === NON_AGGREGATABLE) { + return undefined; + } + + let fieldType: KBN_FIELD_TYPES; + + switch (schema) { + case 'datetime': + fieldType = KBN_FIELD_TYPES.DATE; + break; + case 'numeric': + fieldType = KBN_FIELD_TYPES.NUMBER; + break; + case 'boolean': + fieldType = KBN_FIELD_TYPES.BOOLEAN; + break; + case 'json': + fieldType = KBN_FIELD_TYPES.OBJECT; + break; + default: + fieldType = KBN_FIELD_TYPES.STRING; + } + + return fieldType; +}; + +type LegendText = string | JSX.Element; +export const getLegendText = ( + chartData: ChartData, + maxChartColumns = MAX_CHART_COLUMNS +): LegendText => { + if (chartData.type === 'unsupported') { + return i18n.translate('xpack.ml.dataGridChart.histogramNotAvailable', { + defaultMessage: 'Chart not supported.', + }); + } + + if (chartData.data.length === 0) { + return i18n.translate('xpack.ml.dataGridChart.notEnoughData', { + defaultMessage: `0 documents contain field.`, + }); + } + + if (chartData.type === 'boolean') { + return ( + + + + {chartData.data[0] !== undefined && } + {chartData.data[1] !== undefined && } + + +
{chartData.data[0].key_as_string}{chartData.data[1].key_as_string}
+ ); + } + + if (isOrdinalChartData(chartData) && chartData.cardinality <= maxChartColumns) { + return i18n.translate('xpack.ml.dataGridChart.singleCategoryLegend', { + defaultMessage: `{cardinality, plural, one {# category} other {# categories}}`, + values: { cardinality: chartData.cardinality }, + }); + } + + if (isOrdinalChartData(chartData) && chartData.cardinality > maxChartColumns) { + return i18n.translate('xpack.ml.dataGridChart.topCategoriesLegend', { + defaultMessage: `top {maxChartColumns} of {cardinality} categories`, + values: { cardinality: chartData.cardinality, maxChartColumns }, + }); + } + + if (isNumericChartData(chartData)) { + const fromValue = Math.round(chartData.stats[0] * 100) / 100; + const toValue = Math.round(chartData.stats[1] * 100) / 100; + + return fromValue !== toValue ? `${fromValue} - ${toValue}` : '' + fromValue; + } + + return ''; +}; + +interface ColumnChart { + data: ChartDataItem[]; + legendText: LegendText; + xScaleType: XScaleType; +} + +export const useColumnChart = ( + chartData: ChartData, + columnType: EuiDataGridColumn, + maxChartColumns?: number +): ColumnChart => { + const fieldType = getFieldType(columnType.schema); + + const hoveredRow = useObservable(hoveredRow$); + + const xScaleType = getXScaleType(fieldType); + + const getColor = (d: ChartDataItem) => { + if (hoveredRow === undefined || hoveredRow === null) { + return BAR_COLOR; + } + + if ( + isOrdinalChartData(chartData) && + xScaleType === 'ordinal' && + hoveredRow._source[columnType.id] === d.key + ) { + return BAR_COLOR; + } + + if ( + isNumericChartData(chartData) && + xScaleType === 'linear' && + hoveredRow._source[columnType.id] >= +d.key && + hoveredRow._source[columnType.id] < +d.key + chartData.interval + ) { + return BAR_COLOR; + } + + if ( + isNumericChartData(chartData) && + xScaleType === 'time' && + moment(hoveredRow._source[columnType.id]).unix() * 1000 >= +d.key && + moment(hoveredRow._source[columnType.id]).unix() * 1000 < +d.key + chartData.interval + ) { + return BAR_COLOR; + } + + return BAR_COLOR_BLUR; + }; + + let data: ChartDataItem[] = []; + + // The if/else if/else is a work-around because `.map()` doesn't work with union types. + // See TS Caveats for details: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-3.html#caveats + if (isOrdinalChartData(chartData)) { + data = chartData.data.map((d: OrdinalDataItem) => ({ + ...d, + key_as_string: d.key_as_string ?? d.key, + color: getColor(d), + })); + } else if (isNumericChartData(chartData)) { + data = chartData.data.map((d: NumericDataItem) => ({ + ...d, + key_as_string: d.key_as_string || d.key, + color: getColor(d), + })); + } + + return { + data, + legendText: getLegendText(chartData, maxChartColumns), + xScaleType, + }; +}; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/index.ts b/x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/index.ts new file mode 100644 index 0000000000000..72947f2953cb8 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/index.ts @@ -0,0 +1,9 @@ +/* + * 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. + */ + +export { MetricDistributionChart, MetricDistributionChartData } from './metric_distribution_chart'; +export { buildChartDataFromStats } from './metric_distribution_chart_data_builder'; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart.tsx new file mode 100644 index 0000000000000..8b5e5ec65bae4 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart.tsx @@ -0,0 +1,105 @@ +/* + * 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 React, { FC } from 'react'; + +import { i18n } from '@kbn/i18n'; + +import { + AreaSeries, + Axis, + Chart, + CurveType, + Position, + ScaleType, + Settings, + TooltipValue, + TooltipValueFormatter, +} from '@elastic/charts'; + +import { MetricDistributionChartTooltipHeader } from './metric_distribution_chart_tooltip_header'; +import { kibanaFieldFormat } from '../../../utils'; +import { useDataVizChartTheme } from '../../hooks'; + +interface ChartTooltipValue extends TooltipValue { + skipHeader?: boolean; +} + +export interface MetricDistributionChartData { + x: number; + y: number; + dataMin: number; + dataMax: number; + percent: number; +} + +interface Props { + width: number; + height: number; + chartData: MetricDistributionChartData[]; + fieldFormat?: any; // Kibana formatter for field being viewed + hideXAxis?: boolean; +} + +const SPEC_ID = 'metric_distribution'; + +export const MetricDistributionChart: FC = ({ + width, + height, + chartData, + fieldFormat, + hideXAxis, +}) => { + // This value is shown to label the y axis values in the tooltip. + // Ideally we wouldn't show these values at all in the tooltip, + // but this is not yet possible with Elastic charts. + const seriesName = i18n.translate('xpack.ml.fieldDataCard.metricDistributionChart.seriesName', { + defaultMessage: 'distribution', + }); + + const theme = useDataVizChartTheme(); + + const headerFormatter: TooltipValueFormatter = (tooltipData: ChartTooltipValue) => { + const xValue = tooltipData.value; + const chartPoint: MetricDistributionChartData | undefined = chartData.find( + (data) => data.x === xValue + ); + + return ( + + ); + }; + + return ( +
+ + + kibanaFieldFormat(d, fieldFormat)} + hide={hideXAxis === true} + /> + d.toFixed(3)} hide={true} /> + 0 ? chartData : [{ x: 0, y: 0 }]} + curve={CurveType.CURVE_STEP_AFTER} + /> + +
+ ); +}; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart_data_builder.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart_data_builder.tsx new file mode 100644 index 0000000000000..a65b6bdc7458f --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart_data_builder.tsx @@ -0,0 +1,156 @@ +/* + * 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. + */ + +const METRIC_DISTRIBUTION_CHART_MIN_BAR_WIDTH = 3; // Minimum bar width, in pixels. +const METRIC_DISTRIBUTION_CHART_MAX_BAR_HEIGHT_FACTOR = 20; // Max bar height relative to median bar height. + +import { MetricDistributionChartData } from './metric_distribution_chart'; + +interface DistributionPercentile { + minValue: number; + maxValue: number; + percent: number; +} + +interface DistributionChartBar { + x0: number; + x1: number; + y: number; + dataMin: number; + dataMax: number; + percent: number; + isMinWidth: boolean; +} + +export function buildChartDataFromStats( + stats: any, + chartWidth: number +): MetricDistributionChartData[] { + // Process the raw percentiles data so it is in a suitable format for plotting in the metric distribution chart. + let chartData: MetricDistributionChartData[] = []; + + const distribution = stats.distribution; + if (distribution === undefined) { + return chartData; + } + + const percentiles: DistributionPercentile[] = distribution.percentiles; + if (percentiles.length === 0) { + return chartData; + } + + // Adjust x axis min and max if there is a single bar. + const minX = percentiles[0].minValue; + const maxX = percentiles[percentiles.length - 1].maxValue; + + let xAxisMin: number = minX; + let xAxisMax: number = maxX; + if (maxX === minX) { + if (minX !== 0) { + xAxisMin = 0; + xAxisMax = 2 * minX; + } else { + xAxisMax = 1; + } + } + + // Adjust the right hand x coordinates so that each bar is at least METRIC_DISTRIBUTION_CHART_MIN_BAR_WIDTH. + const minBarWidth = + (METRIC_DISTRIBUTION_CHART_MIN_BAR_WIDTH / chartWidth) * (xAxisMax - xAxisMin); + const processedData: DistributionChartBar[] = []; + let lastBar: DistributionChartBar; + percentiles.forEach((data, index) => { + if (index === 0) { + const bar: DistributionChartBar = { + x0: data.minValue, + x1: Math.max(data.minValue + minBarWidth, data.maxValue), + y: 0, // Set below + dataMin: data.minValue, + dataMax: data.maxValue, + percent: data.percent, + isMinWidth: false, + }; + + // Scale the height of the bar according to the range of data values in the bar. + bar.y = + (data.percent / (bar.x1 - bar.x0)) * + Math.max(1, minBarWidth / Math.max(data.maxValue - data.minValue, 0.5 * minBarWidth)); + bar.isMinWidth = data.maxValue <= data.minValue + minBarWidth; + processedData.push(bar); + lastBar = bar; + } else { + if (lastBar.isMinWidth === false || data.maxValue > lastBar.x1) { + const bar = { + x0: lastBar.x1, + x1: Math.max(lastBar.x1 + minBarWidth, data.maxValue), + y: 0, // Set below + dataMin: data.minValue, + dataMax: data.maxValue, + percent: data.percent, + isMinWidth: false, + }; + + // Scale the height of the bar according to the range of data values in the bar. + bar.y = + (data.percent / (bar.x1 - bar.x0)) * + Math.max(1, minBarWidth / Math.max(data.maxValue - data.minValue, 0.5 * minBarWidth)); + bar.isMinWidth = data.maxValue <= lastBar.x1 + minBarWidth; + processedData.push(bar); + lastBar = bar; + } else { + // Combine bars which are less than minBarWidth apart. + lastBar.percent = lastBar.percent + data.percent; + lastBar.y = lastBar.percent / (lastBar.x1 - lastBar.x0); + lastBar.dataMax = data.maxValue; + } + } + }); + + if (maxX !== minX) { + xAxisMax = processedData[processedData.length - 1].x1; + } + + // Adjust the maximum bar height to be (METRIC_DISTRIBUTION_CHART_MAX_BAR_HEIGHT_FACTOR * median bar height). + let barHeights = processedData.map((data) => data.y); + barHeights = barHeights.sort((a, b) => a - b); + + let maxBarHeight = 0; + const processedDataLength = processedData.length; + if (Math.abs(processedDataLength % 2) === 1) { + maxBarHeight = + METRIC_DISTRIBUTION_CHART_MAX_BAR_HEIGHT_FACTOR * + barHeights[Math.floor(processedDataLength / 2)]; + } else { + maxBarHeight = + (METRIC_DISTRIBUTION_CHART_MAX_BAR_HEIGHT_FACTOR * + (barHeights[Math.floor(processedDataLength / 2) - 1] + + barHeights[Math.floor(processedDataLength / 2)])) / + 2; + } + + processedData.forEach((data) => { + data.y = Math.min(data.y, maxBarHeight); + }); + + // Convert the data to the format used by the chart. + chartData = processedData.map((data) => { + const { x0, y, dataMin, dataMax, percent } = data; + return { x: x0, y, dataMin, dataMax, percent }; + }); + + // Add a final point to drop the curve back to the y axis. + const last = processedData[processedData.length - 1]; + chartData.push({ + x: last.x1, + y: 0, + dataMin: last.dataMin, + dataMax: last.dataMax, + percent: last.percent, + }); + + return chartData; +} diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart_tooltip_header.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart_tooltip_header.tsx new file mode 100644 index 0000000000000..5038978e9388c --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart_tooltip_header.tsx @@ -0,0 +1,54 @@ +/* + * 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 React, { FC } from 'react'; + +import { FormattedMessage } from '@kbn/i18n/react'; + +import { MetricDistributionChartData } from './metric_distribution_chart'; +import { kibanaFieldFormat } from '../../../utils'; + +interface Props { + chartPoint: MetricDistributionChartData | undefined; + maxWidth: number; + fieldFormat?: any; // Kibana formatter for field being viewed +} + +export const MetricDistributionChartTooltipHeader: FC = ({ + chartPoint, + maxWidth, + fieldFormat, +}) => { + if (chartPoint === undefined) { + return null; + } + + return ( +
+ {chartPoint.dataMax > chartPoint.dataMin ? ( + + ) : ( + + )} +
+ ); +}; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/data_visualizer_stats_table.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/data_visualizer_stats_table.tsx new file mode 100644 index 0000000000000..584db22488faa --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/data_visualizer_stats_table.tsx @@ -0,0 +1,277 @@ +/* + * 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 React, { useMemo, useState } from 'react'; + +import { + CENTER_ALIGNMENT, + EuiBasicTableColumn, + EuiButtonIcon, + EuiFlexItem, + EuiIcon, + EuiInMemoryTable, + EuiText, + HorizontalAlignment, + LEFT_ALIGNMENT, + RIGHT_ALIGNMENT, +} from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import { EuiTableComputedColumnType } from '@elastic/eui/src/components/basic_table/table_types'; +import { + ML_JOB_FIELD_TYPES, + MlJobFieldType, + DataVisualizerFileBasedAppState, +} from '../../../../common'; +import { FieldTypeIcon } from '../field_type_icon'; +import { DocumentStat } from './components/field_data_row/document_stats'; +import { DistinctValues } from './components/field_data_row/distinct_values'; +import { IndexBasedNumberContentPreview } from './components/field_data_row/number_content_preview'; + +import { useTableSettings } from './use_table_settings'; +import { TopValuesPreview } from './components/field_data_row/top_values_preview'; +import { + FieldVisConfig, + FileBasedFieldVisConfig, + isIndexBasedFieldVisConfig, +} from './types/field_vis_config'; +import { FileBasedNumberContentPreview } from '../field_data_row'; +import { BooleanContentPreview } from './components/field_data_row'; + +const FIELD_NAME = 'fieldName'; + +type DataVisualizerIndexBasedAppState = any; // REMOVE + +export type ItemIdToExpandedRowMap = Record; + +type DataVisualizerTableItem = FieldVisConfig | FileBasedFieldVisConfig; +interface DataVisualizerTableProps { + items: T[]; + pageState: DataVisualizerIndexBasedAppState | DataVisualizerFileBasedAppState; + updatePageState: ( + update: Partial + ) => void; + getItemIdToExpandedRowMap: (itemIds: string[], items: T[]) => ItemIdToExpandedRowMap; + extendedColumns?: Array>; +} + +export const DataVisualizerTable = ({ + items, + pageState, + updatePageState, + getItemIdToExpandedRowMap, + extendedColumns, +}: DataVisualizerTableProps) => { + const [expandedRowItemIds, setExpandedRowItemIds] = useState([]); + const [expandAll, toggleExpandAll] = useState(false); + + const { onTableChange, pagination, sorting } = useTableSettings( + items, + pageState, + updatePageState + ); + const showDistributions: boolean = + ('showDistributions' in pageState && pageState.showDistributions) ?? true; + const toggleShowDistribution = () => { + updatePageState({ + ...pageState, + showDistributions: !showDistributions, + }); + }; + + function toggleDetails(item: DataVisualizerTableItem) { + if (item.fieldName === undefined) return; + const index = expandedRowItemIds.indexOf(item.fieldName); + if (index !== -1) { + expandedRowItemIds.splice(index, 1); + } else { + expandedRowItemIds.push(item.fieldName); + } + + // spread to a new array otherwise the component wouldn't re-render + setExpandedRowItemIds([...expandedRowItemIds]); + } + + const columns = useMemo(() => { + const expanderColumn: EuiTableComputedColumnType = { + name: ( + toggleExpandAll(!expandAll)} + aria-label={ + !expandAll + ? i18n.translate('xpack.ml.datavisualizer.dataGrid.expandDetailsForAllAriaLabel', { + defaultMessage: 'Expand details for all fields', + }) + : i18n.translate('xpack.ml.datavisualizer.dataGrid.collapseDetailsForAllAriaLabel', { + defaultMessage: 'Collapse details for all fields', + }) + } + iconType={expandAll ? 'arrowUp' : 'arrowDown'} + /> + ), + align: RIGHT_ALIGNMENT, + width: '40px', + isExpander: true, + render: (item: DataVisualizerTableItem) => { + if (item.fieldName === undefined) return null; + const direction = expandedRowItemIds.includes(item.fieldName) ? 'arrowUp' : 'arrowDown'; + return ( + toggleDetails(item)} + aria-label={ + expandedRowItemIds.includes(item.fieldName) + ? i18n.translate('xpack.ml.datavisualizer.dataGrid.rowCollapse', { + defaultMessage: 'Hide details for {fieldName}', + values: { fieldName: item.fieldName }, + }) + : i18n.translate('xpack.ml.datavisualizer.dataGrid.rowExpand', { + defaultMessage: 'Show details for {fieldName}', + values: { fieldName: item.fieldName }, + }) + } + iconType={direction} + /> + ); + }, + 'data-test-subj': 'mlDataVisualizerTableColumnDetailsToggle', + }; + + const baseColumns = [ + expanderColumn, + { + field: 'type', + name: i18n.translate('xpack.ml.datavisualizer.dataGrid.typeColumnName', { + defaultMessage: 'Type', + }), + render: (fieldType: MlJobFieldType) => { + return ; + }, + width: '75px', + sortable: true, + align: CENTER_ALIGNMENT as HorizontalAlignment, + 'data-test-subj': 'mlDataVisualizerTableColumnType', + }, + { + field: 'fieldName', + name: i18n.translate('xpack.ml.datavisualizer.dataGrid.nameColumnName', { + defaultMessage: 'Name', + }), + sortable: true, + truncateText: true, + render: (fieldName: string) => ( + + {fieldName} + + ), + align: LEFT_ALIGNMENT as HorizontalAlignment, + 'data-test-subj': 'mlDataVisualizerTableColumnName', + }, + { + field: 'docCount', + name: i18n.translate('xpack.ml.datavisualizer.dataGrid.documentsCountColumnName', { + defaultMessage: 'Documents (%)', + }), + render: (value: number | undefined, item: DataVisualizerTableItem) => ( + + ), + sortable: (item: DataVisualizerTableItem) => item?.stats?.count, + align: LEFT_ALIGNMENT as HorizontalAlignment, + 'data-test-subj': 'mlDataVisualizerTableColumnDocumentsCount', + }, + { + field: 'stats.cardinality', + name: i18n.translate('xpack.ml.datavisualizer.dataGrid.distinctValuesColumnName', { + defaultMessage: 'Distinct values', + }), + render: (cardinality?: number) => , + sortable: true, + align: LEFT_ALIGNMENT as HorizontalAlignment, + 'data-test-subj': 'mlDataVisualizerTableColumnDistinctValues', + }, + { + name: ( +
+ + {i18n.translate('xpack.ml.datavisualizer.dataGrid.distributionsColumnName', { + defaultMessage: 'Distributions', + })} + toggleShowDistribution()} + aria-label={i18n.translate( + 'xpack.ml.datavisualizer.dataGrid.showDistributionsAriaLabel', + { + defaultMessage: 'Show distributions', + } + )} + /> +
+ ), + render: (item: DataVisualizerTableItem) => { + if (item === undefined || showDistributions === false) return null; + if ( + (item.type === ML_JOB_FIELD_TYPES.KEYWORD || item.type === ML_JOB_FIELD_TYPES.IP) && + item.stats?.topValues !== undefined + ) { + return ; + } + + if (item.type === ML_JOB_FIELD_TYPES.NUMBER) { + if (isIndexBasedFieldVisConfig(item) && item.stats?.distribution !== undefined) { + return ; + } else { + return ; + } + } + + if (item.type === ML_JOB_FIELD_TYPES.BOOLEAN) { + return ; + } + + return null; + }, + align: LEFT_ALIGNMENT as HorizontalAlignment, + 'data-test-subj': 'mlDataVisualizerTableColumnDistribution', + }, + ]; + return extendedColumns ? [...baseColumns, ...extendedColumns] : baseColumns; + // eslint-disable-next-line + }, [expandAll, showDistributions, updatePageState, extendedColumns]); + + const itemIdToExpandedRowMap = useMemo(() => { + let itemIds = expandedRowItemIds; + if (expandAll) { + itemIds = items.map((i) => i[FIELD_NAME]).filter((f) => f !== undefined) as string[]; + } + return getItemIdToExpandedRowMap(itemIds, items); + // eslint-disable-next-line + }, [expandAll, items, expandedRowItemIds]); + + return ( + + + className={'mlDataVisualizer'} + items={items} + itemId={FIELD_NAME} + columns={columns} + pagination={pagination} + sorting={sorting} + isExpandable={true} + itemIdToExpandedRowMap={itemIdToExpandedRowMap} + isSelectable={false} + onTableChange={onTableChange} + data-test-subj={'mlDataVisualizerTable'} + rowProps={(item) => ({ + 'data-test-subj': `mlDataVisualizerRow row-${item.fieldName}`, + })} + /> + + ); +}; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/hooks/color_range_legend.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/hooks/color_range_legend.tsx new file mode 100644 index 0000000000000..5f0c0a401bedd --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/hooks/color_range_legend.tsx @@ -0,0 +1,146 @@ +/* + * 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 React, { useEffect, useRef, FC } from 'react'; +import d3 from 'd3'; + +import { EuiText } from '@elastic/eui'; + +const COLOR_RANGE_RESOLUTION = 10; + +interface ColorRangeLegendProps { + colorRange: (d: number) => string; + justifyTicks?: boolean; + showTicks?: boolean; + title?: string; + width?: number; +} + +/** + * Component to render a legend for color ranges to be used for color coding + * table cells and visualizations. + * + * This current version supports normalized value ranges (0-1) only. + * + * @param props ColorRangeLegendProps + */ +export const ColorRangeLegend: FC = ({ + colorRange, + justifyTicks = false, + showTicks = true, + title, + width = 250, +}) => { + const d3Container = useRef(null); + + const scale = d3.range(COLOR_RANGE_RESOLUTION + 1).map((d) => ({ + offset: (d / COLOR_RANGE_RESOLUTION) * 100, + stopColor: colorRange(d / COLOR_RANGE_RESOLUTION), + })); + + useEffect(() => { + if (d3Container.current === null) { + return; + } + + const wrapperHeight = 32; + const wrapperWidth = width; + + // top: 2 — adjust vertical alignment with title text + // bottom: 20 — room for axis ticks and labels + // left/right: 1 — room for first and last axis tick + // when justifyTicks is enabled, the left margin is increased to not cut off the first tick label + const margin = { top: 2, bottom: 20, left: justifyTicks || !showTicks ? 1 : 4, right: 1 }; + + const legendWidth = wrapperWidth - margin.left - margin.right; + const legendHeight = wrapperHeight - margin.top - margin.bottom; + + // remove, then redraw the legend + d3.select(d3Container.current).selectAll('*').remove(); + + const wrapper = d3 + .select(d3Container.current) + .classed('mlColorRangeLegend', true) + .attr('width', wrapperWidth) + .attr('height', wrapperHeight) + .append('g') + .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + // append gradient bar + const gradient = wrapper + .append('defs') + .append('linearGradient') + .attr('id', 'mlColorRangeGradient') + .attr('x1', '0%') + .attr('y1', '0%') + .attr('x2', '100%') + .attr('y2', '0%') + .attr('spreadMethod', 'pad'); + + scale.forEach(function (d) { + gradient + .append('stop') + .attr('offset', `${d.offset}%`) + .attr('stop-color', d.stopColor) + .attr('stop-opacity', 1); + }); + + wrapper + .append('rect') + .attr('x1', 0) + .attr('y1', 0) + .attr('width', legendWidth) + .attr('height', legendHeight) + .style('fill', 'url(#mlColorRangeGradient)'); + + const axisScale = d3.scale.linear().domain([0, 1]).range([0, legendWidth]); + + // Using this formatter ensures we get e.g. `0` and not `0.0`, but still `0.1`, `0.2` etc. + const tickFormat = d3.format(''); + const legendAxis = d3.svg + .axis() + .scale(axisScale) + .orient('bottom') + .tickFormat(tickFormat) + .tickSize(legendHeight + 4) + .ticks(legendWidth / 40); + + wrapper + .append('g') + .attr('class', 'legend axis') + .attr('transform', 'translate(0, 0)') + .call(legendAxis); + + // Adjust the alignment of the first and last tick text + // so that the tick labels don't overflow the color range. + if (justifyTicks || !showTicks) { + const text = wrapper.selectAll('text')[0]; + if (text.length > 1) { + d3.select(text[0]).style('text-anchor', 'start'); + d3.select(text[text.length - 1]).style('text-anchor', 'end'); + } + } + + if (!showTicks) { + wrapper.selectAll('.axis line').style('display', 'none'); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [JSON.stringify(scale), d3Container.current]); + + if (title === undefined) { + return ; + } + + return ( + <> + +

{title}

+
+ + + ); +}; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/hooks/index.ts b/x-pack/plugins/file_upload/public/application/components/stats_table/hooks/index.ts new file mode 100644 index 0000000000000..85d85f51a623f --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/hooks/index.ts @@ -0,0 +1,8 @@ +/* + * 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. + */ + +export { useDataVizChartTheme } from './use_data_viz_chart_theme'; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/hooks/use_color_range.test.ts b/x-pack/plugins/file_upload/public/application/components/stats_table/hooks/use_color_range.test.ts new file mode 100644 index 0000000000000..55888c607c287 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/hooks/use_color_range.test.ts @@ -0,0 +1,58 @@ +/* + * 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 { influencerColorScaleFactory } from './use_color_range'; + +describe('useColorRange', () => { + test('influencerColorScaleFactory(1)', () => { + const influencerColorScale = influencerColorScaleFactory(1); + + expect(influencerColorScale(0)).toBe(0); + expect(influencerColorScale(0.1)).toBe(0.1); + expect(influencerColorScale(0.2)).toBe(0.2); + expect(influencerColorScale(0.3)).toBe(0.3); + expect(influencerColorScale(0.4)).toBe(0.4); + expect(influencerColorScale(0.5)).toBe(0.5); + expect(influencerColorScale(0.6)).toBe(0.6); + expect(influencerColorScale(0.7)).toBe(0.7); + expect(influencerColorScale(0.8)).toBe(0.8); + expect(influencerColorScale(0.9)).toBe(0.9); + expect(influencerColorScale(1)).toBe(1); + }); + + test('influencerColorScaleFactory(2)', () => { + const influencerColorScale = influencerColorScaleFactory(2); + + expect(influencerColorScale(0)).toBe(0); + expect(influencerColorScale(0.1)).toBe(0); + expect(influencerColorScale(0.2)).toBe(0); + expect(influencerColorScale(0.3)).toBe(0); + expect(influencerColorScale(0.4)).toBe(0); + expect(influencerColorScale(0.5)).toBe(0); + expect(influencerColorScale(0.6)).toBe(0.04999999999999999); + expect(influencerColorScale(0.7)).toBe(0.09999999999999998); + expect(influencerColorScale(0.8)).toBe(0.15000000000000002); + expect(influencerColorScale(0.9)).toBe(0.2); + expect(influencerColorScale(1)).toBe(0.25); + }); + + test('influencerColorScaleFactory(3)', () => { + const influencerColorScale = influencerColorScaleFactory(3); + + expect(influencerColorScale(0)).toBe(0); + expect(influencerColorScale(0.1)).toBe(0); + expect(influencerColorScale(0.2)).toBe(0); + expect(influencerColorScale(0.3)).toBe(0); + expect(influencerColorScale(0.4)).toBe(0.05000000000000003); + expect(influencerColorScale(0.5)).toBe(0.125); + expect(influencerColorScale(0.6)).toBe(0.2); + expect(influencerColorScale(0.7)).toBe(0.27499999999999997); + expect(influencerColorScale(0.8)).toBe(0.35000000000000003); + expect(influencerColorScale(0.9)).toBe(0.425); + expect(influencerColorScale(1)).toBe(0.5); + }); +}); diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/hooks/use_color_range.ts b/x-pack/plugins/file_upload/public/application/components/stats_table/hooks/use_color_range.ts new file mode 100644 index 0000000000000..8376bb9281153 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/hooks/use_color_range.ts @@ -0,0 +1,201 @@ +/* + * 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 d3 from 'd3'; +import { useMemo } from 'react'; +import euiThemeLight from '@elastic/eui/dist/eui_theme_light.json'; +import euiThemeDark from '@elastic/eui/dist/eui_theme_dark.json'; + +import { i18n } from '@kbn/i18n'; + +import { useFileUploadKibana } from '../../../kibana_context'; + +/** + * Custom color scale factory that takes the amount of feature influencers + * into account to adjust the contrast of the color range. This is used for + * color coding for outlier detection where the amount of feature influencers + * affects the threshold from which the influencers value can actually be + * considered influential. + * + * @param n number of influencers + * @returns a function suitable as a preprocessor for d3.scale.linear() + */ +export const influencerColorScaleFactory = (n: number) => (t: number) => { + // for 1 influencer or less we fall back to a plain linear scale. + if (n <= 1) { + return t; + } + + if (t < 1 / n) { + return 0; + } + if (t < 3 / n) { + return (n / 4) * (t - 1 / n); + } + return 0.5 + (t - 3 / n); +}; + +export enum COLOR_RANGE_SCALE { + LINEAR = 'linear', + INFLUENCER = 'influencer', + SQRT = 'sqrt', +} + +/** + * Color range scale options in the format for EuiSelect's options prop. + */ +export const colorRangeScaleOptions = [ + { + value: COLOR_RANGE_SCALE.LINEAR, + text: i18n.translate('xpack.ml.components.colorRangeLegend.linearScaleLabel', { + defaultMessage: 'Linear', + }), + }, + { + value: COLOR_RANGE_SCALE.INFLUENCER, + text: i18n.translate('xpack.ml.components.colorRangeLegend.influencerScaleLabel', { + defaultMessage: 'Influencer custom scale', + }), + }, + { + value: COLOR_RANGE_SCALE.SQRT, + text: i18n.translate('xpack.ml.components.colorRangeLegend.sqrtScaleLabel', { + defaultMessage: 'Sqrt', + }), + }, +]; + +export enum COLOR_RANGE { + BLUE = 'blue', + RED = 'red', + RED_GREEN = 'red-green', + GREEN_RED = 'green-red', + YELLOW_GREEN_BLUE = 'yellow-green-blue', +} + +/** + * Color range options in the format for EuiSelect's options prop. + */ +export const colorRangeOptions = [ + { + value: COLOR_RANGE.BLUE, + text: i18n.translate('xpack.ml.components.colorRangeLegend.blueColorRangeLabel', { + defaultMessage: 'Blue', + }), + }, + { + value: COLOR_RANGE.RED, + text: i18n.translate('xpack.ml.components.colorRangeLegend.redColorRangeLabel', { + defaultMessage: 'Red', + }), + }, + { + value: COLOR_RANGE.RED_GREEN, + text: i18n.translate('xpack.ml.components.colorRangeLegend.redGreenColorRangeLabel', { + defaultMessage: 'Red - Green', + }), + }, + { + value: COLOR_RANGE.GREEN_RED, + text: i18n.translate('xpack.ml.components.colorRangeLegend.greenRedColorRangeLabel', { + defaultMessage: 'Green - Red', + }), + }, + { + value: COLOR_RANGE.YELLOW_GREEN_BLUE, + text: i18n.translate('xpack.ml.components.colorRangeLegend.yellowGreenBlueColorRangeLabel', { + defaultMessage: 'Yellow - Green - Blue', + }), + }, +]; + +/** + * A custom Yellow-Green-Blue color range to demonstrate the support + * for more complex ranges with more than two colors. + */ +const coloursYGB = [ + '#FFFFDD', + '#AAF191', + '#80D385', + '#61B385', + '#3E9583', + '#217681', + '#285285', + '#1F2D86', + '#000086', +]; +const colourRangeYGB = d3.range(0, 1, 1.0 / (coloursYGB.length - 1)); +colourRangeYGB.push(1); + +const colorDomains = { + [COLOR_RANGE.BLUE]: [0, 1], + [COLOR_RANGE.RED]: [0, 1], + [COLOR_RANGE.RED_GREEN]: [0, 1], + [COLOR_RANGE.GREEN_RED]: [0, 1], + [COLOR_RANGE.YELLOW_GREEN_BLUE]: colourRangeYGB, +}; + +/** + * Custom hook to get a d3 based color range to be used for color coding in table cells. + * + * @param colorRange COLOR_RANGE enum. + * @param colorRangeScale COLOR_RANGE_SCALE enum. + * @param featureCount + */ +export const useColorRange = ( + colorRange = COLOR_RANGE.BLUE, + colorRangeScale = COLOR_RANGE_SCALE.LINEAR, + featureCount = 1 +) => { + const { euiTheme } = useCurrentEuiTheme(); + + const colorRanges: Record = { + [COLOR_RANGE.BLUE]: [ + d3.rgb(euiTheme.euiColorEmptyShade).toString(), + d3.rgb(euiTheme.euiColorVis1).toString(), + ], + [COLOR_RANGE.RED]: [ + d3.rgb(euiTheme.euiColorEmptyShade).toString(), + d3.rgb(euiTheme.euiColorDanger).toString(), + ], + [COLOR_RANGE.RED_GREEN]: ['red', 'green'], + [COLOR_RANGE.GREEN_RED]: ['green', 'red'], + [COLOR_RANGE.YELLOW_GREEN_BLUE]: coloursYGB, + }; + + const linearScale = d3.scale + .linear() + .domain(colorDomains[colorRange]) + .range(colorRanges[colorRange]); + const influencerColorScale = influencerColorScaleFactory(featureCount); + const influencerScaleLinearWrapper = (n: number) => linearScale(influencerColorScale(n)); + + const scaleTypes = { + [COLOR_RANGE_SCALE.LINEAR]: linearScale, + [COLOR_RANGE_SCALE.INFLUENCER]: influencerScaleLinearWrapper, + [COLOR_RANGE_SCALE.SQRT]: d3.scale + .sqrt() + .domain(colorDomains[colorRange]) + // typings for .range() incorrectly don't allow passing in a color extent. + // @ts-ignore + .range(colorRanges[colorRange]), + }; + + return scaleTypes[colorRangeScale]; +}; + +export type EuiThemeType = typeof euiThemeLight | typeof euiThemeDark; + +export function useCurrentEuiTheme() { + const { + services: { uiSettings }, + } = useFileUploadKibana(); + return useMemo( + () => ({ euiTheme: uiSettings.get('theme:darkMode') ? euiThemeDark : euiThemeLight }), + [uiSettings] + ); +} diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/hooks/use_data_viz_chart_theme.ts b/x-pack/plugins/file_upload/public/application/components/stats_table/hooks/use_data_viz_chart_theme.ts new file mode 100644 index 0000000000000..ad31ca2d09420 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/hooks/use_data_viz_chart_theme.ts @@ -0,0 +1,55 @@ +/* + * 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 type { PartialTheme } from '@elastic/charts'; +import { useMemo } from 'react'; +import { useCurrentEuiTheme } from './use_color_range'; +export const useDataVizChartTheme = (): PartialTheme => { + const { euiTheme } = useCurrentEuiTheme(); + const chartTheme = useMemo(() => { + const AREA_SERIES_COLOR = euiTheme.euiColorVis0; + return { + axes: { + tickLabel: { + fontSize: parseInt(euiTheme.euiFontSizeXS, 10), + fontFamily: euiTheme.euiFontFamily, + fontStyle: 'italic', + }, + }, + background: { color: 'transparent' }, + chartMargins: { + left: 0, + right: 0, + top: 0, + bottom: 0, + }, + chartPaddings: { + left: 0, + right: 0, + top: 4, + bottom: 0, + }, + scales: { barsPadding: 0.1 }, + colors: { + vizColors: [AREA_SERIES_COLOR], + }, + areaSeriesStyle: { + line: { + strokeWidth: 1, + visible: true, + }, + point: { + visible: false, + radius: 0, + opacity: 0, + }, + area: { visible: true, opacity: 1 }, + }, + }; + }, [euiTheme]); + return chartTheme; +}; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/index.ts b/x-pack/plugins/file_upload/public/application/components/stats_table/index.ts new file mode 100644 index 0000000000000..3009470af4858 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/index.ts @@ -0,0 +1,8 @@ +/* + * 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. + */ + +export { DataVisualizerTable, ItemIdToExpandedRowMap } from './data_visualizer_stats_table'; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/types/field_data_row.ts b/x-pack/plugins/file_upload/public/application/components/stats_table/types/field_data_row.ts new file mode 100644 index 0000000000000..24209af23ceb4 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/types/field_data_row.ts @@ -0,0 +1,12 @@ +/* + * 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 type { FieldVisConfig, FileBasedFieldVisConfig } from './field_vis_config'; + +export interface FieldDataRowProps { + config: FieldVisConfig | FileBasedFieldVisConfig; +} diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/types/field_vis_config.ts b/x-pack/plugins/file_upload/public/application/components/stats_table/types/field_vis_config.ts new file mode 100644 index 0000000000000..7bf80dfcfb745 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/types/field_vis_config.ts @@ -0,0 +1,98 @@ +/* + * 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 { MlJobFieldType } from '../../../../../common'; + +export interface Percentile { + percent: number; + minValue: number; + maxValue: number; +} + +export interface MetricFieldVisStats { + avg?: number; + distribution?: { + percentiles: Percentile[]; + maxPercentile: number; + minPercentile: 0; + }; + max?: number; + median?: number; + min?: number; +} + +interface DocumentCountBuckets { + [key: string]: number; +} + +export interface FieldVisStats { + cardinality?: number; + count?: number; + sampleCount?: number; + trueCount?: number; + falseCount?: number; + earliest?: number; + latest?: number; + documentCounts?: { + buckets?: DocumentCountBuckets; + }; + avg?: number; + distribution?: { + percentiles: Percentile[]; + maxPercentile: number; + minPercentile: 0; + }; + fieldName?: string; + isTopValuesSampled?: boolean; + max?: number; + median?: number; + min?: number; + topValues?: Array<{ key: number | string; doc_count: number }>; + topValuesSampleSize?: number; + topValuesSamplerShardSize?: number; + examples?: Array; + timeRangeEarliest?: number; + timeRangeLatest?: number; +} + +// The internal representation of the configuration used to build the visuals +// which display the field information. +export interface FieldVisConfig { + type: MlJobFieldType; + fieldName?: string; + existsInDocs: boolean; + aggregatable: boolean; + loading: boolean; + stats?: FieldVisStats; + fieldFormat?: any; + isUnsupportedType?: boolean; +} + +export interface FileBasedFieldVisConfig { + type: MlJobFieldType; + fieldName?: string; + stats?: FieldVisStats; + format?: string; +} + +export interface FileBasedUnknownFieldVisConfig { + fieldName: string; + type: 'text' | 'unknown'; + stats: { mean: number; count: number; sampleCount: number; cardinality: number }; +} + +export function isFileBasedFieldVisConfig( + field: FieldVisConfig | FileBasedFieldVisConfig +): field is FileBasedFieldVisConfig { + return !field.hasOwnProperty('existsInDocs'); +} + +export function isIndexBasedFieldVisConfig( + field: FieldVisConfig | FileBasedFieldVisConfig +): field is FieldVisConfig { + return field.hasOwnProperty('existsInDocs'); +} diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/types/index.ts b/x-pack/plugins/file_upload/public/application/components/stats_table/types/index.ts new file mode 100644 index 0000000000000..161829461aa26 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/types/index.ts @@ -0,0 +1,16 @@ +/* + * 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. + */ + +export { FieldDataRowProps } from './field_data_row'; +export { + FieldVisConfig, + FileBasedFieldVisConfig, + FieldVisStats, + MetricFieldVisStats, + isFileBasedFieldVisConfig, + isIndexBasedFieldVisConfig, +} from './field_vis_config'; diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/use_table_settings.ts b/x-pack/plugins/file_upload/public/application/components/stats_table/use_table_settings.ts new file mode 100644 index 0000000000000..e29c5169394a0 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/use_table_settings.ts @@ -0,0 +1,94 @@ +/* + * 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 { Direction, EuiBasicTableProps, Pagination, PropertySort } from '@elastic/eui'; +import { useCallback, useMemo } from 'react'; +// import { ListingPageUrlState } from '../../../../../../../common/types/common'; +import { DataVisualizerFileBasedAppState } from '../../../../common'; + +type DataVisualizerIndexBasedAppState = any; // REMOVE + +export interface ListingPageUrlState { + pageSize: number; + pageIndex: number; + sortField: string; + sortDirection: string; + queryText?: string; +} + +const PAGE_SIZE_OPTIONS = [10, 25, 50]; + +// Copying from EUI EuiBasicTable types as type is not correctly picked up for table's onChange +// Can be removed when https://github.com/elastic/eui/issues/4011 is addressed in EUI +export interface Criteria { + page?: { + index: number; + size: number; + }; + sort?: { + field: keyof T; + direction: Direction; + }; +} +export interface CriteriaWithPagination extends Criteria { + page: { + index: number; + size: number; + }; +} + +interface UseTableSettingsReturnValue { + onTableChange: EuiBasicTableProps['onChange']; + pagination: Pagination; + sorting: { sort: PropertySort }; +} + +export function useTableSettings( + items: TypeOfItem[], + pageState: + | ListingPageUrlState + | DataVisualizerIndexBasedAppState + | DataVisualizerFileBasedAppState, + updatePageState: (update: Partial) => void +): UseTableSettingsReturnValue { + const { pageIndex, pageSize, sortField, sortDirection } = pageState; + + const onTableChange: EuiBasicTableProps['onChange'] = useCallback( + ({ page, sort }: CriteriaWithPagination) => { + const result = { + pageIndex: page?.index ?? pageState.pageIndex, + pageSize: page?.size ?? pageState.pageSize, + sortField: (sort?.field as string) ?? pageState.sortField, + sortDirection: sort?.direction ?? pageState.sortDirection, + }; + updatePageState(result); + }, + [pageState, updatePageState] + ); + + const pagination = useMemo( + () => ({ + pageIndex, + pageSize, + totalItemCount: items.length, + pageSizeOptions: PAGE_SIZE_OPTIONS, + }), + [items, pageIndex, pageSize] + ); + + const sorting = useMemo( + () => ({ + sort: { + field: sortField as string, + direction: sortDirection as Direction, + }, + }), + [sortField, sortDirection] + ); + + return { onTableChange, pagination, sorting }; +} diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/utils.ts b/x-pack/plugins/file_upload/public/application/components/stats_table/utils.ts new file mode 100644 index 0000000000000..27da91153b3ba --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/utils.ts @@ -0,0 +1,38 @@ +/* + * 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 { FileBasedFieldVisConfig } from './types'; + +export const getTFPercentage = (config: FileBasedFieldVisConfig) => { + const { stats } = config; + if (stats === undefined) return null; + const { count } = stats; + // use stats from index based config + let { trueCount, falseCount } = stats; + + // use stats from file based find structure results + if (stats.trueCount === undefined || stats.falseCount === undefined) { + if (config?.stats?.topValues) { + config.stats.topValues.forEach((doc) => { + if (doc.doc_count !== undefined) { + if (doc.key.toString().toLowerCase() === 'false') { + falseCount = doc.doc_count; + } + if (doc.key.toString().toLowerCase() === 'true') { + trueCount = doc.doc_count; + } + } + }); + } + } + if (count === undefined || trueCount === undefined || falseCount === undefined) return null; + return { + count, + trueCount, + falseCount, + }; +}; diff --git a/x-pack/plugins/file_upload/public/application/components/top_values/_top_values.scss b/x-pack/plugins/file_upload/public/application/components/top_values/_top_values.scss new file mode 100644 index 0000000000000..75ee6aef1b7eb --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/top_values/_top_values.scss @@ -0,0 +1,19 @@ +.mlFieldDataTopValuesContainer { + padding-top: $euiSizeXS; +} + +.mlTopValuesValueLabelContainer { + margin-right: $euiSizeM; + &.mlTopValuesValueLabelContainer--small { + width:70px; + } + + &.mlTopValuesValueLabelContainer--large { + width: 200px; + } +} + +.mlTopValuesPercentLabelContainer { + margin-left: $euiSizeM; + width:70px; +} diff --git a/x-pack/plugins/file_upload/public/application/components/top_values/index.ts b/x-pack/plugins/file_upload/public/application/components/top_values/index.ts new file mode 100644 index 0000000000000..c006b37fe2794 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/top_values/index.ts @@ -0,0 +1,8 @@ +/* + * 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. + */ + +export { TopValues } from './top_values'; diff --git a/x-pack/plugins/file_upload/public/application/components/top_values/top_values.tsx b/x-pack/plugins/file_upload/public/application/components/top_values/top_values.tsx new file mode 100644 index 0000000000000..8f179f60df7f6 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/top_values/top_values.tsx @@ -0,0 +1,112 @@ +/* + * 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 React, { FC, Fragment } from 'react'; +import { + EuiFlexGroup, + EuiFlexItem, + EuiProgress, + EuiSpacer, + EuiText, + EuiToolTip, +} from '@elastic/eui'; + +import { FormattedMessage } from '@kbn/i18n/react'; + +import classNames from 'classnames'; +import { roundToDecimalPlace, kibanaFieldFormat } from '../utils'; +import { ExpandedRowFieldHeader } from '../stats_table/components/expanded_row_field_header'; +import { FieldVisStats } from '../stats_table/types'; + +interface Props { + stats: FieldVisStats | undefined; + fieldFormat?: any; + barColor?: 'primary' | 'secondary' | 'danger' | 'subdued' | 'accent'; + compressed?: boolean; +} + +function getPercentLabel(docCount: number, topValuesSampleSize: number): string { + const percent = (100 * docCount) / topValuesSampleSize; + if (percent >= 0.1) { + return `${roundToDecimalPlace(percent, 1)}%`; + } else { + return '< 0.1%'; + } +} + +export const TopValues: FC = ({ stats, fieldFormat, barColor, compressed }) => { + if (stats === undefined) return null; + const { + topValues, + topValuesSampleSize, + topValuesSamplerShardSize, + count, + isTopValuesSampled, + } = stats; + const progressBarMax = isTopValuesSampled === true ? topValuesSampleSize : count; + return ( + + + + + +
+ {Array.isArray(topValues) && + topValues.map((value) => ( + + + + + {kibanaFieldFormat(value.key, fieldFormat)} + + + + + + + {progressBarMax !== undefined && ( + + + {getPercentLabel(value.doc_count, progressBarMax)} + + + )} + + ))} + {isTopValuesSampled === true && ( + + + + + + + )} +
+
+ ); +}; diff --git a/x-pack/plugins/file_upload/public/application/components/utils/format_value.ts b/x-pack/plugins/file_upload/public/application/components/utils/format_value.ts new file mode 100644 index 0000000000000..c62725b58b1e7 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/utils/format_value.ts @@ -0,0 +1,88 @@ +/* + * 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. + */ + +/* + * Formatter for 'typical' and 'actual' values from machine learning results. + * For detectors which use the time_of_week or time_of_day + * functions, the filter converts the raw number, which is the number of seconds since + * midnight, into a human-readable date/time format. + */ + +import moment from 'moment'; +const SIGFIGS_IF_ROUNDING = 3; // Number of sigfigs to use for values < 10 + +// Formats a single value according to the specified ML function. +// If a Kibana fieldFormat is not supplied, will fall back to default +// formatting depending on the magnitude of the value. +// For time_of_day or time_of_week functions the anomaly record +// containing the timestamp of the anomaly should be supplied in +// order to correctly format the day or week offset to the time of the anomaly. +export function formatSingleValue( + value: number, + mlFunction?: string, + fieldFormat?: any, + record?: any // TODO remove record, not needed for file upload +) { + if (value === undefined || value === null) { + return ''; + } + + // If the analysis function is time_of_week/day, format as day/time. + // For time_of_week / day, actual / typical is the UTC offset in seconds from the + // start of the week / day, so need to manipulate to UTC moment of the start of the week / day + // that the anomaly occurred using record timestamp if supplied, add on the offset, and finally + // revert back to configured timezone for formatting. + if (mlFunction === 'time_of_week') { + const d = + record !== undefined && record.timestamp !== undefined + ? new Date(record.timestamp) + : new Date(); + const utcMoment = moment.utc(d).startOf('week').add(value, 's'); + return moment(utcMoment.valueOf()).format('ddd HH:mm'); + } else if (mlFunction === 'time_of_day') { + const d = + record !== undefined && record.timestamp !== undefined + ? new Date(record.timestamp) + : new Date(); + const utcMoment = moment.utc(d).startOf('day').add(value, 's'); + return moment(utcMoment.valueOf()).format('HH:mm'); + } else { + if (fieldFormat !== undefined) { + return fieldFormat.convert(value, 'text'); + } else { + // If no Kibana FieldFormat object provided, + // format the value depending on its magnitude. + const absValue = Math.abs(value); + if (absValue >= 10000 || absValue === Math.floor(absValue)) { + // Output 0 decimal places if whole numbers or >= 10000 + if (fieldFormat !== undefined) { + return fieldFormat.convert(value, 'text'); + } else { + return Number(value.toFixed(0)); + } + } else if (absValue >= 10) { + // Output to 1 decimal place between 10 and 10000 + return Number(value.toFixed(1)); + } else { + // For values < 10, output to 3 significant figures + let multiple; + if (value > 0) { + multiple = Math.pow( + 10, + SIGFIGS_IF_ROUNDING - Math.floor(Math.log(value) / Math.LN10) - 1 + ); + } else { + multiple = Math.pow( + 10, + SIGFIGS_IF_ROUNDING - Math.floor(Math.log(-1 * value) / Math.LN10) - 1 + ); + } + return Math.round(value * multiple) / multiple; + } + } + } +} diff --git a/x-pack/plugins/file_upload/public/application/components/utils/index.ts b/x-pack/plugins/file_upload/public/application/components/utils/index.ts new file mode 100644 index 0000000000000..b4c491eee8fd4 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/utils/index.ts @@ -0,0 +1,12 @@ +/* + * 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. + */ + +export { createUrlOverrides, processResults, readFile, DEFAULT_LINES_TO_SAMPLE } from './utils'; +export { roundToDecimalPlace } from './round_to_decimal_place'; +export { kibanaFieldFormat } from './kibana_field_format'; +export { numberAsOrdinal } from './number_as_ordinal'; +export { formatSingleValue } from './format_value'; diff --git a/x-pack/plugins/file_upload/public/application/components/utils/kibana_field_format.ts b/x-pack/plugins/file_upload/public/application/components/utils/kibana_field_format.ts new file mode 100644 index 0000000000000..0218b7d62655c --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/utils/kibana_field_format.ts @@ -0,0 +1,19 @@ +/* + * 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. + */ + +/* + * Formatter which uses the fieldFormat object of a Kibana index pattern + * field to format the value of a field. + */ + +export function kibanaFieldFormat(value: any, fieldFormat: any) { + if (fieldFormat !== undefined && fieldFormat !== null) { + return fieldFormat.convert(value, 'text'); + } else { + return value; + } +} diff --git a/x-pack/plugins/file_upload/public/application/components/utils/number_as_ordinal.test.ts b/x-pack/plugins/file_upload/public/application/components/utils/number_as_ordinal.test.ts new file mode 100644 index 0000000000000..99dbd58d14624 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/utils/number_as_ordinal.test.ts @@ -0,0 +1,29 @@ +/* + * 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 { numberAsOrdinal } from './number_as_ordinal'; + +describe('ML - numberAsOrdinal formatter', () => { + const tests = [ + { number: 0, asOrdinal: '0th' }, + { number: 1, asOrdinal: '1st' }, + { number: 2.2, asOrdinal: '2nd' }, + { number: 3, asOrdinal: '3rd' }, + { number: 5, asOrdinal: '5th' }, + { number: 10, asOrdinal: '10th' }, + { number: 11, asOrdinal: '11th' }, + { number: 22, asOrdinal: '22nd' }, + { number: 33, asOrdinal: '33rd' }, + { number: 44.4, asOrdinal: '44th' }, + { number: 100, asOrdinal: '100th' }, + ]; + test('returns the expected numeral format', () => { + tests.forEach((test) => { + expect(numberAsOrdinal(test.number)).toBe(test.asOrdinal); + }); + }); +}); diff --git a/x-pack/plugins/file_upload/public/application/components/utils/number_as_ordinal.ts b/x-pack/plugins/file_upload/public/application/components/utils/number_as_ordinal.ts new file mode 100644 index 0000000000000..3a2707cc47783 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/utils/number_as_ordinal.ts @@ -0,0 +1,20 @@ +/* + * 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. + */ + +// @ts-ignore +import numeral from '@elastic/numeral'; + +/** + * Formats the supplied number as ordinal e.g. 15 as 15th. + * Formatting first converts the supplied number to an integer by flooring. + * @param {number} value to format as an ordinal + * @return {string} number formatted as an ordinal e.g. 15th + */ +export function numberAsOrdinal(num: number) { + const int = Math.floor(num); + return `${numeral(int).format('0o')}`; +} diff --git a/x-pack/plugins/file_upload/public/application/components/utils/round_to_decimal_place.test.ts b/x-pack/plugins/file_upload/public/application/components/utils/round_to_decimal_place.test.ts new file mode 100644 index 0000000000000..dc4cee37ec67e --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/utils/round_to_decimal_place.test.ts @@ -0,0 +1,38 @@ +/* + * 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 { roundToDecimalPlace } from './round_to_decimal_place'; + +describe('ML - roundToDecimalPlace formatter', () => { + it('returns the correct format using default decimal place', () => { + expect(roundToDecimalPlace(12)).toBe(12); + expect(roundToDecimalPlace(12.3)).toBe(12.3); + expect(roundToDecimalPlace(12.34)).toBe(12.34); + expect(roundToDecimalPlace(12.345)).toBe(12.35); + expect(roundToDecimalPlace(12.045)).toBe(12.05); + expect(roundToDecimalPlace(12.005)).toBe(12.01); + expect(roundToDecimalPlace(12.0005)).toBe(12); + expect(roundToDecimalPlace(0.05)).toBe(0.05); + expect(roundToDecimalPlace(0.005)).toBe('5.00e-3'); + expect(roundToDecimalPlace(0.0005)).toBe('5.00e-4'); + expect(roundToDecimalPlace(-0.0005)).toBe('-5.00e-4'); + expect(roundToDecimalPlace(-12.045)).toBe(-12.04); + expect(roundToDecimalPlace(0)).toBe(0); + }); + + it('returns the correct format using specified decimal place', () => { + expect(roundToDecimalPlace(12, 4)).toBe(12); + expect(roundToDecimalPlace(12.3, 4)).toBe(12.3); + expect(roundToDecimalPlace(12.3456, 4)).toBe(12.3456); + expect(roundToDecimalPlace(12.345678, 4)).toBe(12.3457); + expect(roundToDecimalPlace(0.05, 4)).toBe(0.05); + expect(roundToDecimalPlace(0.0005, 4)).toBe(0.0005); + expect(roundToDecimalPlace(0.00005, 4)).toBe('5.00e-5'); + expect(roundToDecimalPlace(-0.00005, 4)).toBe('-5.00e-5'); + expect(roundToDecimalPlace(0, 4)).toBe(0); + }); +}); diff --git a/x-pack/plugins/file_upload/public/application/components/utils/round_to_decimal_place.ts b/x-pack/plugins/file_upload/public/application/components/utils/round_to_decimal_place.ts new file mode 100644 index 0000000000000..88ab605a95369 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/components/utils/round_to_decimal_place.ts @@ -0,0 +1,20 @@ +/* + * 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. + */ + +export function roundToDecimalPlace(num?: number, dp: number = 2): number | string { + if (num === undefined) return ''; + if (num % 1 === 0) { + // no decimal place + return num; + } + + if (Math.abs(num) < Math.pow(10, -dp)) { + return Number.parseFloat(String(num)).toExponential(2); + } + const m = Math.pow(10, dp); + return Math.round(num * m) / m; +} diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/utils/utils.ts b/x-pack/plugins/file_upload/public/application/components/utils/utils.ts similarity index 96% rename from x-pack/plugins/ml/public/application/datavisualizer/file_based/components/utils/utils.ts rename to x-pack/plugins/file_upload/public/application/components/utils/utils.ts index 49e5da565b927..6899d8476322f 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/utils/utils.ts +++ b/x-pack/plugins/file_upload/public/application/components/utils/utils.ts @@ -6,8 +6,7 @@ */ import { isEqual } from 'lodash'; -import { AnalysisResult, InputOverrides } from '../../../../../../../file_upload/common'; -import { MB } from '../../../../../../../file_upload/public'; +import { AnalysisResult, InputOverrides, MB } from '../../../../common'; export const DEFAULT_LINES_TO_SAMPLE = 1000; const UPLOAD_SIZE_MB = 5; diff --git a/x-pack/plugins/file_upload/public/application/file_datavisualizer.tsx b/x-pack/plugins/file_upload/public/application/file_datavisualizer.tsx new file mode 100644 index 0000000000000..15476e19c1ce1 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/file_datavisualizer.tsx @@ -0,0 +1,44 @@ +/* + * 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 React, { FC } from 'react'; +import { DataPublicPluginStart } from 'src/plugins/data/public'; +import { CoreStart } from 'kibana/public'; +import { KibanaContextProvider } from '../../../../../src/plugins/kibana_react/public'; +import type { EmbeddableStart } from '../../../../../src/plugins/embeddable/public'; +// import type { MapsStartApi } from '../../../maps/public'; +import { SecurityPluginSetup } from '../../../security/public'; + +// @ts-ignore +import { FileDataVisualizerView } from './components/file_datavisualizer_view/index'; + +export interface FileDataVisualizerPageProps { + data: DataPublicPluginStart; + embeddable?: EmbeddableStart; + // maps?: MapsStartApi; + security?: SecurityPluginSetup; + coreStart: CoreStart; +} + +export const FileDataVisualizerPage: FC = ({ + data, + embeddable, + // maps, + security, + coreStart, +}) => { + const services = { data, embeddable, /* maps,*/ security, ...coreStart }; + + return ( + + + + ); +}; diff --git a/x-pack/plugins/file_upload/public/application/index.ts b/x-pack/plugins/file_upload/public/application/index.ts new file mode 100644 index 0000000000000..0476b9ead9db7 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/index.ts @@ -0,0 +1,10 @@ +/* + * 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. + */ + +export { FileDataVisualizerPage } from './file_datavisualizer'; + +// export { FileDataVisualizerView } from './components/file_datavisualizer_view/index'; diff --git a/x-pack/plugins/file_upload/public/application/kibana_context.ts b/x-pack/plugins/file_upload/public/application/kibana_context.ts new file mode 100644 index 0000000000000..be2609c89ccac --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/kibana_context.ts @@ -0,0 +1,23 @@ +/* + * 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 { DataPublicPluginStart } from 'src/plugins/data/public'; +import { CoreStart } from 'kibana/public'; +import { useKibana, KibanaReactContextValue } from '../../../../../src/plugins/kibana_react/public'; +import { SecurityPluginSetup } from '../../../security/public'; +import type { EmbeddableStart } from '../../../../../src/plugins/embeddable/public'; +// import type { MapsStartApi } from '../../../maps/public'; + +interface StartPlugins { + data: DataPublicPluginStart; + security?: SecurityPluginSetup; + embeddable: EmbeddableStart; + // maps?: MapsStartApi; +} +export type StartServices = CoreStart & StartPlugins; +export const useFileUploadKibana = () => useKibana(); +export type MlKibanaReactContextValue = KibanaReactContextValue; diff --git a/x-pack/plugins/file_upload/public/application/shared_imports.ts b/x-pack/plugins/file_upload/public/application/shared_imports.ts new file mode 100644 index 0000000000000..20481d2fde9be --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/shared_imports.ts @@ -0,0 +1,12 @@ +/* + * 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 { XJson } from '../../../../../src/plugins/es_ui_shared/public'; +const { collapseLiteralStrings, expandLiteralStrings } = XJson; + +export { XJsonMode } from '@kbn/ace'; +export { collapseLiteralStrings, expandLiteralStrings }; diff --git a/x-pack/plugins/file_upload/public/application/util/field_types_utils.test.ts b/x-pack/plugins/file_upload/public/application/util/field_types_utils.test.ts new file mode 100644 index 0000000000000..4f2cc74391427 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/util/field_types_utils.test.ts @@ -0,0 +1,84 @@ +/* + * 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 { IFieldType, KBN_FIELD_TYPES } from '../../../../../../src/plugins/data/public'; +import { ML_JOB_FIELD_TYPES } from '../../../common'; +import { + kbnTypeToMLJobType, + getMLJobTypeAriaLabel, + mlJobTypeAriaLabels, +} from './field_types_utils'; + +describe('ML - field type utils', () => { + describe('kbnTypeToMLJobType', () => { + test('returns correct ML_JOB_FIELD_TYPES for KBN_FIELD_TYPES', () => { + const field: IFieldType = { + type: KBN_FIELD_TYPES.NUMBER, + name: KBN_FIELD_TYPES.NUMBER, + aggregatable: true, + }; + expect(kbnTypeToMLJobType(field)).toBe(ML_JOB_FIELD_TYPES.NUMBER); + + field.type = KBN_FIELD_TYPES.DATE; + expect(kbnTypeToMLJobType(field)).toBe(ML_JOB_FIELD_TYPES.DATE); + + field.type = KBN_FIELD_TYPES.IP; + expect(kbnTypeToMLJobType(field)).toBe(ML_JOB_FIELD_TYPES.IP); + + field.type = KBN_FIELD_TYPES.BOOLEAN; + expect(kbnTypeToMLJobType(field)).toBe(ML_JOB_FIELD_TYPES.BOOLEAN); + + field.type = KBN_FIELD_TYPES.GEO_POINT; + expect(kbnTypeToMLJobType(field)).toBe(ML_JOB_FIELD_TYPES.GEO_POINT); + }); + + test('returns ML_JOB_FIELD_TYPES.KEYWORD for aggregatable KBN_FIELD_TYPES.STRING', () => { + const field: IFieldType = { + type: KBN_FIELD_TYPES.STRING, + name: KBN_FIELD_TYPES.STRING, + aggregatable: true, + }; + expect(kbnTypeToMLJobType(field)).toBe(ML_JOB_FIELD_TYPES.KEYWORD); + }); + + test('returns ML_JOB_FIELD_TYPES.TEXT for non-aggregatable KBN_FIELD_TYPES.STRING', () => { + const field: IFieldType = { + type: KBN_FIELD_TYPES.STRING, + name: KBN_FIELD_TYPES.STRING, + aggregatable: false, + }; + expect(kbnTypeToMLJobType(field)).toBe(ML_JOB_FIELD_TYPES.TEXT); + }); + + test('returns undefined for non-aggregatable "foo"', () => { + const field: IFieldType = { + type: 'foo', + name: 'foo', + aggregatable: false, + }; + expect(kbnTypeToMLJobType(field)).toBe(undefined); + }); + }); + + describe('getMLJobTypeAriaLabel: Getting a field type aria label by passing what it is stored in constants', () => { + test('should returns all ML_JOB_FIELD_TYPES labels exactly as it is for each correct value', () => { + const mlKeys = Object.keys(ML_JOB_FIELD_TYPES); + const receivedMlLabels: Record = {}; + const testStorage = mlJobTypeAriaLabels; + mlKeys.forEach((constant) => { + receivedMlLabels[constant] = getMLJobTypeAriaLabel( + ML_JOB_FIELD_TYPES[constant as keyof typeof ML_JOB_FIELD_TYPES] + ); + }); + + expect(receivedMlLabels).toEqual(testStorage); + }); + test('should returns NULL as ML_JOB_FIELD_TYPES does not contain such a keyword', () => { + expect(getMLJobTypeAriaLabel('ML_JOB_FIELD_TYPES')).toBe(null); + }); + }); +}); diff --git a/x-pack/plugins/file_upload/public/application/util/field_types_utils.ts b/x-pack/plugins/file_upload/public/application/util/field_types_utils.ts new file mode 100644 index 0000000000000..2d2a77feff30a --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/util/field_types_utils.ts @@ -0,0 +1,87 @@ +/* + * 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 { i18n } from '@kbn/i18n'; +import { ML_JOB_FIELD_TYPES } from '../../../common'; + +import { IFieldType, KBN_FIELD_TYPES } from '../../../../../../src/plugins/data/public'; + +// convert kibana types to ML Job types +// this is needed because kibana types only have string and not text and keyword. +// and we can't use ES_FIELD_TYPES because it has no NUMBER type +export function kbnTypeToMLJobType(field: IFieldType) { + // Return undefined if not one of the supported data visualizer field types. + let type; + switch (field.type) { + case KBN_FIELD_TYPES.STRING: + type = field.aggregatable ? ML_JOB_FIELD_TYPES.KEYWORD : ML_JOB_FIELD_TYPES.TEXT; + break; + case KBN_FIELD_TYPES.NUMBER: + type = ML_JOB_FIELD_TYPES.NUMBER; + break; + case KBN_FIELD_TYPES.DATE: + type = ML_JOB_FIELD_TYPES.DATE; + break; + case KBN_FIELD_TYPES.IP: + type = ML_JOB_FIELD_TYPES.IP; + break; + case KBN_FIELD_TYPES.BOOLEAN: + type = ML_JOB_FIELD_TYPES.BOOLEAN; + break; + case KBN_FIELD_TYPES.GEO_POINT: + type = ML_JOB_FIELD_TYPES.GEO_POINT; + break; + case KBN_FIELD_TYPES.GEO_SHAPE: + type = ML_JOB_FIELD_TYPES.GEO_SHAPE; + break; + + default: + break; + } + + return type; +} + +export const mlJobTypeAriaLabels = { + BOOLEAN: i18n.translate('xpack.ml.fieldTypeIcon.booleanTypeAriaLabel', { + defaultMessage: 'boolean type', + }), + DATE: i18n.translate('xpack.ml.fieldTypeIcon.dateTypeAriaLabel', { + defaultMessage: 'date type', + }), + GEO_POINT: i18n.translate('xpack.ml.fieldTypeIcon.geoPointTypeAriaLabel', { + defaultMessage: '{geoPointParam} type', + values: { + geoPointParam: 'geo point', + }, + }), + IP: i18n.translate('xpack.ml.fieldTypeIcon.ipTypeAriaLabel', { + defaultMessage: 'ip type', + }), + KEYWORD: i18n.translate('xpack.ml.fieldTypeIcon.keywordTypeAriaLabel', { + defaultMessage: 'keyword type', + }), + NUMBER: i18n.translate('xpack.ml.fieldTypeIcon.numberTypeAriaLabel', { + defaultMessage: 'number type', + }), + TEXT: i18n.translate('xpack.ml.fieldTypeIcon.textTypeAriaLabel', { + defaultMessage: 'text type', + }), + UNKNOWN: i18n.translate('xpack.ml.fieldTypeIcon.unknownTypeAriaLabel', { + defaultMessage: 'unknown type', + }), +}; + +export const getMLJobTypeAriaLabel = (type: string) => { + const requestedFieldType = Object.keys(ML_JOB_FIELD_TYPES).find( + (k) => ML_JOB_FIELD_TYPES[k as keyof typeof ML_JOB_FIELD_TYPES] === type + ); + if (requestedFieldType === undefined) { + return null; + } + return mlJobTypeAriaLabels[requestedFieldType as keyof typeof mlJobTypeAriaLabels]; +}; diff --git a/x-pack/plugins/file_upload/public/application/util/util.ts b/x-pack/plugins/file_upload/public/application/util/util.ts new file mode 100644 index 0000000000000..ed703d6b2e7e3 --- /dev/null +++ b/x-pack/plugins/file_upload/public/application/util/util.ts @@ -0,0 +1,51 @@ +/* + * 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. + */ + +// type LegacyUrlKeys = 'mlExplorerSwimlane'; + +// export type AppStateKey = +// | 'mlSelectSeverity' +// | 'mlSelectInterval' +// | 'mlAnomaliesTable' +// | MlPages +// | LegacyUrlKeys; + +// /** +// * Hook for managing the URL state of the page. +// */ +// export const usePageUrlState = ( +// pageKey: AppStateKey, +// defaultState?: PageUrlState +// ): [PageUrlState, (update: Partial, replaceState?: boolean) => void] => { +// const [appState, setAppState] = useUrlState('_a'); +// const pageState = appState?.[pageKey]; + +// const resultPageState: PageUrlState = useMemo(() => { +// return { +// ...(defaultState ?? {}), +// ...(pageState ?? {}), +// }; +// }, [pageState]); + +// const onStateUpdate = useCallback( +// (update: Partial, replaceState?: boolean) => { +// setAppState( +// pageKey, +// { +// ...resultPageState, +// ...update, +// }, +// replaceState +// ); +// }, +// [pageKey, resultPageState, setAppState] +// ); + +// return useMemo(() => { +// return [resultPageState, onStateUpdate]; +// }, [resultPageState, onStateUpdate]); +// }; diff --git a/x-pack/plugins/file_upload/public/index.ts b/x-pack/plugins/file_upload/public/index.ts index 0c81779130d87..f79b9a9815d2a 100644 --- a/x-pack/plugins/file_upload/public/index.ts +++ b/x-pack/plugins/file_upload/public/index.ts @@ -17,3 +17,5 @@ export * from './importer/types'; export { FileUploadPluginStart } from './plugin'; export { FileUploadComponentProps } from './lazy_load_bundle'; + +export { FileDataVisualizerPage } from './application'; diff --git a/x-pack/plugins/file_upload/public/plugin.ts b/x-pack/plugins/file_upload/public/plugin.ts index a4e386b85e182..19fe78ad318fa 100644 --- a/x-pack/plugins/file_upload/public/plugin.ts +++ b/x-pack/plugins/file_upload/public/plugin.ts @@ -11,6 +11,7 @@ import { getFileUploadComponent, importerFactory, hasImportPermission, + analyzeFile, } from './api'; import { setStartServices } from './kibana_services'; import { DataPublicPluginStart } from '../../../../src/plugins/data/public'; @@ -43,6 +44,7 @@ export class FileUploadPlugin getMaxBytes, getMaxBytesFormatted, hasImportPermission, + analyzeFile, }; } } diff --git a/x-pack/plugins/file_upload/tsconfig.json b/x-pack/plugins/file_upload/tsconfig.json index 887a05af31174..0f37b0bcf2a65 100644 --- a/x-pack/plugins/file_upload/tsconfig.json +++ b/x-pack/plugins/file_upload/tsconfig.json @@ -13,5 +13,7 @@ { "path": "../../../src/plugins/data/tsconfig.json" }, { "path": "../../../src/plugins/usage_collection/tsconfig.json" }, { "path": "../security/tsconfig.json" }, + // { "path": "../maps/tsconfig.json" }, + { "path": "../../../src/plugins/embeddable/tsconfig.json" }, ] } diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/use_table_settings.ts b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/use_table_settings.ts index 5ac7b00e8af67..b16ef72c0b660 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/use_table_settings.ts +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/use_table_settings.ts @@ -7,7 +7,7 @@ import { Direction, EuiBasicTableProps, Pagination, PropertySort } from '@elastic/eui'; import { useCallback, useMemo } from 'react'; -import { ListingPageUrlState } from '../../../../../../../common/types/common'; +// import { ListingPageUrlState } from '../../../../../../../common/types/common'; import { DataVisualizerFileBasedAppState, DataVisualizerIndexBasedAppState, @@ -15,6 +15,14 @@ import { const PAGE_SIZE_OPTIONS = [10, 25, 50]; +interface ListingPageUrlState { + pageSize: number; + pageIndex: number; + sortField: string; + sortDirection: string; + queryText?: string; +} + // Copying from EUI EuiBasicTable types as type is not correctly picked up for table's onChange // Can be removed when https://github.com/elastic/eui/issues/4011 is addressed in EUI export interface Criteria { diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx b/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx deleted file mode 100644 index a05677918da72..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 React, { FC, Fragment } from 'react'; -import { IUiSettingsClient } from 'kibana/public'; - -import { useTimefilter } from '../../contexts/kibana'; -import { NavigationMenu } from '../../components/navigation_menu'; -import { getIndexPatternsContract } from '../../util/index_utils'; -import { HelpMenu } from '../../components/help_menu'; -import { useMlKibana } from '../../contexts/kibana'; - -// @ts-ignore -import { FileDataVisualizerView } from './components/file_datavisualizer_view/index'; - -export interface FileDataVisualizerPageProps { - kibanaConfig: IUiSettingsClient; -} - -export const FileDataVisualizerPage: FC = ({ kibanaConfig }) => { - useTimefilter({ timeRangeSelector: false, autoRefreshSelector: false }); - const indexPatterns = getIndexPatternsContract(); - const { - services: { docLinks }, - } = useMlKibana(); - const helpLink = docLinks.links.ml.guide; - return ( - - - - - - ); -}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/search_panel/field_type_filter.tsx b/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/search_panel/field_type_filter.tsx index 7bc7260acf544..15ddf00c4e1d3 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/search_panel/field_type_filter.tsx +++ b/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/search_panel/field_type_filter.tsx @@ -13,7 +13,7 @@ import { FieldTypeIcon } from '../../../../components/field_type_icon'; import { ML_JOB_FIELD_TYPES } from '../../../../../../common/constants/field_types'; import type { MlJobFieldType } from '../../../../../../common/types/field_types'; -export const ML_JOB_FIELD_TYPES_OPTIONS = { +const ML_JOB_FIELD_TYPES_OPTIONS = { [ML_JOB_FIELD_TYPES.BOOLEAN]: { name: 'Boolean', icon: 'tokenBoolean' }, [ML_JOB_FIELD_TYPES.DATE]: { name: 'Date', icon: 'tokenDate' }, [ML_JOB_FIELD_TYPES.GEO_POINT]: { name: 'Geo point', icon: 'tokenGeo' }, diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/index.ts b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/index.ts index e0944711033a7..d35b0ae9688cf 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/index.ts +++ b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/index.ts @@ -7,7 +7,6 @@ export { BooleanContent } from './boolean_content'; export { DateContent } from './date_content'; -export { GeoPointContent } from '../../../file_based/components/expanded_row/geo_point_content/geo_point_content'; export { KeywordContent } from './keyword_content'; export { IpContent } from './ip_content'; export { NumberContent } from './number_content'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/data_visualizer_stats_table.tsx b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/data_visualizer_stats_table.tsx index 2a6a681c63210..0c5758f70a87a 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/data_visualizer_stats_table.tsx +++ b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/data_visualizer_stats_table.tsx @@ -38,7 +38,7 @@ import { FileBasedFieldVisConfig, isIndexBasedFieldVisConfig, } from './types/field_vis_config'; -import { FileBasedNumberContentPreview } from '../file_based/components/field_data_row'; +// import { FileBasedNumberContentPreview } from '../file_based/components/field_data_row'; import { BooleanContentPreview } from './components/field_data_row'; const FIELD_NAME = 'fieldName'; @@ -224,8 +224,6 @@ export const DataVisualizerTable = ({ if (item.type === ML_JOB_FIELD_TYPES.NUMBER) { if (isIndexBasedFieldVisConfig(item) && item.stats?.distribution !== undefined) { return ; - } else { - return ; } } diff --git a/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/file_based.tsx b/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/file_based.tsx index ae3b35bbb2b91..31a850a2ed43f 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/file_based.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/file_based.tsx @@ -8,15 +8,17 @@ import React, { FC } from 'react'; import { i18n } from '@kbn/i18n'; +import { CoreStart } from 'kibana/public'; import { NavigateToPath } from '../../../contexts/kibana'; import { MlRoute, PageLoader, PageProps } from '../../router'; import { useResolver } from '../../use_resolver'; -import { FileDataVisualizerPage } from '../../../datavisualizer/file_based'; +import { FileDataVisualizerPage } from '../../../../../../file_upload/public'; import { checkBasicLicense } from '../../../license'; import { checkFindFileStructurePrivilegeResolver } from '../../../capabilities/check_capabilities'; import { loadIndexPatterns } from '../../../util/index_utils'; +import { useMlKibana } from '../../../contexts/kibana'; import { getBreadcrumbWithUrlForApp } from '../../breadcrumbs'; @@ -47,9 +49,21 @@ const PageWrapper: FC = ({ location, deps }) => { checkFindFileStructurePrivilege: () => checkFindFileStructurePrivilegeResolver(redirectToMlAccessDeniedPage), }); + + const { + services: { data, embeddable, /* maps,*/ security, savedObjects }, + } = useMlKibana(); + const coreStart = { savedObjects } as CoreStart; + return ( - + ); }; From 96900b76be4703cdccfd8cad03a3a8eb2b20784e Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Wed, 7 Apr 2021 15:11:10 +0100 Subject: [PATCH 02/37] removing maps plug dependency --- x-pack/plugins/file_upload/kibana.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/x-pack/plugins/file_upload/kibana.json b/x-pack/plugins/file_upload/kibana.json index a25f718e7bc14..4c3f838339f5f 100644 --- a/x-pack/plugins/file_upload/kibana.json +++ b/x-pack/plugins/file_upload/kibana.json @@ -10,8 +10,7 @@ "embeddable" ], "optionalPlugins": [ - "security", - "maps" + "security" ], "requiredBundles": [ "esUiShared", From fa9059f07e1a9d80e00f99e219267d773996a019 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Wed, 7 Apr 2021 16:50:29 +0100 Subject: [PATCH 03/37] fixing imports --- .../file_upload/public/application/file_datavisualizer.tsx | 2 +- x-pack/plugins/ml/public/application/datavisualizer/_index.scss | 1 - .../datavisualizer/stats_table/data_visualizer_stats_table.tsx | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/x-pack/plugins/file_upload/public/application/file_datavisualizer.tsx b/x-pack/plugins/file_upload/public/application/file_datavisualizer.tsx index 15476e19c1ce1..69bdbf80008dd 100644 --- a/x-pack/plugins/file_upload/public/application/file_datavisualizer.tsx +++ b/x-pack/plugins/file_upload/public/application/file_datavisualizer.tsx @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ - +import './_index.scss'; import React, { FC } from 'react'; import { DataPublicPluginStart } from 'src/plugins/data/public'; import { CoreStart } from 'kibana/public'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/_index.scss b/x-pack/plugins/ml/public/application/datavisualizer/_index.scss index 195eeea72baa0..c02883c573ead 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/_index.scss +++ b/x-pack/plugins/ml/public/application/datavisualizer/_index.scss @@ -1,3 +1,2 @@ -@import 'file_based/index'; @import 'index_based/index'; @import 'stats_table/index'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/data_visualizer_stats_table.tsx b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/data_visualizer_stats_table.tsx index 0c5758f70a87a..2003d07efca82 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/data_visualizer_stats_table.tsx +++ b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/data_visualizer_stats_table.tsx @@ -38,7 +38,6 @@ import { FileBasedFieldVisConfig, isIndexBasedFieldVisConfig, } from './types/field_vis_config'; -// import { FileBasedNumberContentPreview } from '../file_based/components/field_data_row'; import { BooleanContentPreview } from './components/field_data_row'; const FIELD_NAME = 'fieldName'; From d1b4f86f08fa57e32aa1be7cc3f9f962ee939c70 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Wed, 7 Apr 2021 17:21:56 +0100 Subject: [PATCH 04/37] small refactor --- .../application/file_datavisualizer.tsx | 4 +- .../file_upload/public/application/index.ts | 4 +- x-pack/plugins/file_upload/public/index.ts | 4 +- .../file_based/file_datavisualizer.tsx | 37 +++++++++++++++++++ .../datavisualizer/file_based/index.tsx | 8 ++++ .../routes/datavisualizer/file_based.tsx | 19 ++-------- 6 files changed, 52 insertions(+), 24 deletions(-) create mode 100644 x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx create mode 100644 x-pack/plugins/ml/public/application/datavisualizer/file_based/index.tsx diff --git a/x-pack/plugins/file_upload/public/application/file_datavisualizer.tsx b/x-pack/plugins/file_upload/public/application/file_datavisualizer.tsx index 69bdbf80008dd..02db836d57242 100644 --- a/x-pack/plugins/file_upload/public/application/file_datavisualizer.tsx +++ b/x-pack/plugins/file_upload/public/application/file_datavisualizer.tsx @@ -16,7 +16,7 @@ import { SecurityPluginSetup } from '../../../security/public'; // @ts-ignore import { FileDataVisualizerView } from './components/file_datavisualizer_view/index'; -export interface FileDataVisualizerPageProps { +export interface FileDataVisualizerProps { data: DataPublicPluginStart; embeddable?: EmbeddableStart; // maps?: MapsStartApi; @@ -24,7 +24,7 @@ export interface FileDataVisualizerPageProps { coreStart: CoreStart; } -export const FileDataVisualizerPage: FC = ({ +export const FileDataVisualizer: FC = ({ data, embeddable, // maps, diff --git a/x-pack/plugins/file_upload/public/application/index.ts b/x-pack/plugins/file_upload/public/application/index.ts index 0476b9ead9db7..dba820519af94 100644 --- a/x-pack/plugins/file_upload/public/application/index.ts +++ b/x-pack/plugins/file_upload/public/application/index.ts @@ -5,6 +5,4 @@ * 2.0. */ -export { FileDataVisualizerPage } from './file_datavisualizer'; - -// export { FileDataVisualizerView } from './components/file_datavisualizer_view/index'; +export { FileDataVisualizer } from './file_datavisualizer'; diff --git a/x-pack/plugins/file_upload/public/index.ts b/x-pack/plugins/file_upload/public/index.ts index f79b9a9815d2a..c90c2975b6937 100644 --- a/x-pack/plugins/file_upload/public/index.ts +++ b/x-pack/plugins/file_upload/public/index.ts @@ -11,11 +11,9 @@ export function plugin() { return new FileUploadPlugin(); } -export * from '../common'; - export * from './importer/types'; export { FileUploadPluginStart } from './plugin'; export { FileUploadComponentProps } from './lazy_load_bundle'; -export { FileDataVisualizerPage } from './application'; +export { FileDataVisualizer } from './application'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx b/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx new file mode 100644 index 0000000000000..55ea0bc8d6662 --- /dev/null +++ b/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx @@ -0,0 +1,37 @@ +/* + * 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 React, { FC, Fragment } from 'react'; +import type { CoreStart } from 'kibana/public'; + +import { useTimefilter } from '../../contexts/kibana'; +import { NavigationMenu } from '../../components/navigation_menu'; +import { HelpMenu } from '../../components/help_menu'; +import { useMlKibana } from '../../contexts/kibana'; +import { FileDataVisualizer } from '../../../../../file_upload/public'; + +export const FileDataVisualizerPage: FC = () => { + useTimefilter({ timeRangeSelector: false, autoRefreshSelector: false }); + const { + services: { docLinks, data, embeddable, /* maps,*/ security, savedObjects }, + } = useMlKibana(); + const coreStart = { savedObjects } as CoreStart; + const helpLink = docLinks.links.ml.guide; + return ( + + + + + + ); +}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/index.tsx b/x-pack/plugins/ml/public/application/datavisualizer/file_based/index.tsx new file mode 100644 index 0000000000000..bb5c2a4f3182b --- /dev/null +++ b/x-pack/plugins/ml/public/application/datavisualizer/file_based/index.tsx @@ -0,0 +1,8 @@ +/* + * 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. + */ + +export { FileDataVisualizerPage } from './file_datavisualizer'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/file_based.tsx b/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/file_based.tsx index 31a850a2ed43f..5b16bf8352b27 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/file_based.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/file_based.tsx @@ -8,17 +8,15 @@ import React, { FC } from 'react'; import { i18n } from '@kbn/i18n'; -import { CoreStart } from 'kibana/public'; import { NavigateToPath } from '../../../contexts/kibana'; import { MlRoute, PageLoader, PageProps } from '../../router'; import { useResolver } from '../../use_resolver'; -import { FileDataVisualizerPage } from '../../../../../../file_upload/public'; +import { FileDataVisualizerPage } from '../../../datavisualizer/file_based'; import { checkBasicLicense } from '../../../license'; import { checkFindFileStructurePrivilegeResolver } from '../../../capabilities/check_capabilities'; import { loadIndexPatterns } from '../../../util/index_utils'; -import { useMlKibana } from '../../../contexts/kibana'; import { getBreadcrumbWithUrlForApp } from '../../breadcrumbs'; @@ -40,7 +38,7 @@ export const fileBasedRouteFactory = ( ], }); -const PageWrapper: FC = ({ location, deps }) => { +const PageWrapper: FC = ({ deps }) => { const { redirectToMlAccessDeniedPage } = deps; const { context } = useResolver(undefined, undefined, deps.config, { @@ -50,20 +48,9 @@ const PageWrapper: FC = ({ location, deps }) => { checkFindFileStructurePrivilegeResolver(redirectToMlAccessDeniedPage), }); - const { - services: { data, embeddable, /* maps,*/ security, savedObjects }, - } = useMlKibana(); - const coreStart = { savedObjects } as CoreStart; - return ( - + ); }; From 8db222b5180b110bebfc4895cf4161e28568f19e Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Thu, 8 Apr 2021 11:08:08 +0100 Subject: [PATCH 05/37] adding missing endpoints --- x-pack/plugins/file_upload/kibana.json | 4 +- .../plugins/file_upload/public/api/index.ts | 39 ++++++ .../components/import_view/import_view.js | 28 ++-- .../components/results_links/index.ts | 2 +- .../results_links/results_links.tsx | 122 ++++-------------- .../application/file_datavisualizer.tsx | 5 +- .../public/application/kibana_context.ts | 2 + .../server/get_time_field_range.ts | 54 ++++++++ x-pack/plugins/file_upload/server/routes.ts | 87 +++++++++++++ .../file_based/file_datavisualizer.tsx | 3 +- 10 files changed, 232 insertions(+), 114 deletions(-) create mode 100644 x-pack/plugins/file_upload/server/get_time_field_range.ts diff --git a/x-pack/plugins/file_upload/kibana.json b/x-pack/plugins/file_upload/kibana.json index 4c3f838339f5f..296fc36850ef0 100644 --- a/x-pack/plugins/file_upload/kibana.json +++ b/x-pack/plugins/file_upload/kibana.json @@ -7,7 +7,9 @@ "requiredPlugins": [ "data", "usageCollection", - "embeddable" + "embeddable", + "share", + "discover" ], "optionalPlugins": [ "security" diff --git a/x-pack/plugins/file_upload/public/api/index.ts b/x-pack/plugins/file_upload/public/api/index.ts index 946c3ac38efd5..67e1cb97fd774 100644 --- a/x-pack/plugins/file_upload/public/api/index.ts +++ b/x-pack/plugins/file_upload/public/api/index.ts @@ -19,6 +19,12 @@ export interface FileUploadStartApi { analyzeFile(file: string, params: Record): Promise; } +export interface GetTimeFieldRangeResponse { + success: boolean; + start: { epoch: number; string: string }; + end: { epoch: number; string: string }; +} + export async function getFileUploadComponent(): Promise< React.ComponentType > { @@ -67,3 +73,36 @@ export async function analyzeFile( query: params, }); } + +export async function checkIndexExists( + index: string, + params: Record = {} +): Promise { + const body = JSON.stringify({ index }); + const fileUploadModules = await lazyLoadFileUploadModules(); + return await fileUploadModules.getHttp().fetch({ + path: `/api/file_upload/index_exists`, + method: 'POST', + body, + query: params, + }); +} + +export async function getTimeFieldRange({ + index, + timeFieldName, + query, +}: { + index: string; + timeFieldName?: string; + query: any; +}) { + const body = JSON.stringify({ index, timeFieldName, query }); + + const fileUploadModules = await lazyLoadFileUploadModules(); + return await fileUploadModules.getHttp().fetch({ + path: `/api/file_upload/time_field_range`, + method: 'POST', + body, + }); +} diff --git a/x-pack/plugins/file_upload/public/application/components/import_view/import_view.js b/x-pack/plugins/file_upload/public/application/components/import_view/import_view.js index 0299cf38b6c1c..22b7bfbdeab9f 100644 --- a/x-pack/plugins/file_upload/public/application/components/import_view/import_view.js +++ b/x-pack/plugins/file_upload/public/application/components/import_view/import_view.js @@ -20,7 +20,7 @@ import { import { i18n } from '@kbn/i18n'; import { debounce } from 'lodash'; -// import { ResultsLinks } from '../results_links'; +import { ResultsLinks } from '../results_links'; import { FilebeatConfigFlyout } from '../filebeat_config_flyout'; import { ImportProgress, IMPORT_STATUS } from '../import_progress'; import { ImportErrors } from '../import_errors'; @@ -32,7 +32,7 @@ import { getDefaultCombinedFields, } from '../combined_fields'; import { ExperimentalBadge } from '../experimental_badge'; -import { hasImportPermission, importerFactory } from '../../../api'; +import { hasImportPermission, importerFactory, checkIndexExists } from '../../../api'; const DEFAULT_TIME_FIELD = '@timestamp'; const DEFAULT_INDEX_SETTINGS = { number_of_shards: 1 }; @@ -352,16 +352,15 @@ export class ImportView extends Component { return; } - // const { exists } = await ml.checkIndexExists({ index }); - // const indexNameError = exists ? ( - // - // ) : ( - // isIndexNameValid(index) - // ); - const indexNameError = isIndexNameValid(index); // TODO - REMOVE THIS LINE AND COPY INDEX EXISTS + const { exists } = await checkIndexExists(index); + const indexNameError = exists ? ( + + ) : ( + isIndexNameValid(index) + ); this.setState({ checkingValidIndex: false, indexNameError }); }, 500); @@ -467,6 +466,7 @@ export class ImportView extends Component { pipelineString, indexNameError, indexPatternNameError, + timeFieldName, isFilebeatFlyoutVisible, checkingValidIndex, combinedFields, @@ -595,14 +595,14 @@ export class ImportView extends Component { - {/* */} + /> {isFilebeatFlyoutVisible && ( = ({ fieldStats, index, @@ -46,16 +49,11 @@ export const ResultsLinks: FC = ({ from: 'now-30m', to: 'now', }); - const [showCreateJobLink, setShowCreateJobLink] = useState(false); - const [globalState, setGlobalState] = useState(); + const [globalState, setGlobalState] = useState(); const [discoverLink, setDiscoverLink] = useState(''); const [indexManagementLink, setIndexManagementLink] = useState(''); const [indexPatternManagementLink, setIndexPatternManagementLink] = useState(''); - const [dataVisualizerLink, setDataVisualizerLink] = useState(''); - const [createJobsSelectTypePage, setCreateJobsSelectTypePage] = useState(''); - - const mlUrlGenerator = useMlUrlGenerator(); const { services: { @@ -64,7 +62,7 @@ export const ResultsLinks: FC = ({ urlGenerators: { getUrlGenerator }, }, }, - } = useMlKibana(); + } = useFileUploadKibana(); useEffect(() => { let unmounted = false; @@ -99,34 +97,7 @@ export const ResultsLinks: FC = ({ } }; - const getDataVisualizerLink = async (): Promise => { - const _dataVisualizerLink = await mlUrlGenerator.createUrl({ - page: ML_PAGES.DATA_VISUALIZER_INDEX_VIEWER, - pageState: { - index: indexPatternId, - globalState, - }, - }); - if (!unmounted) { - setDataVisualizerLink(_dataVisualizerLink); - } - }; - const getADCreateJobsSelectTypePage = async (): Promise => { - const _createJobsSelectTypePage = await mlUrlGenerator.createUrl({ - page: ML_PAGES.ANOMALY_DETECTION_CREATE_JOB_SELECT_TYPE, - pageState: { - index: indexPatternId, - globalState, - }, - }); - if (!unmounted) { - setCreateJobsSelectTypePage(_createJobsSelectTypePage); - } - }; - getDiscoverUrl(); - getDataVisualizerLink(); - getADCreateJobsSelectTypePage(); if (!unmounted) { setIndexManagementLink( @@ -142,15 +113,16 @@ export const ResultsLinks: FC = ({ return () => { unmounted = true; }; + // eslint-disable-next-line react-hooks/exhaustive-deps }, [indexPatternId, getUrlGenerator, JSON.stringify(globalState)]); useEffect(() => { - setShowCreateJobLink(checkPermission('canCreateJob') && mlNodesAvailable()); updateTimeValues(); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); useEffect(() => { - const _globalState: MlCommonGlobalState = { + const _globalState: GlobalState = { time: { from: duration.from, to: duration.to, @@ -213,42 +185,6 @@ export const ResultsLinks: FC = ({ )} - {isFullLicense() === true && - timeFieldName !== undefined && - showCreateJobLink && - createIndexPattern && - createJobsSelectTypePage && ( - - } - title={ - - } - description="" - href={createJobsSelectTypePage} - /> - - )} - - {createIndexPattern && dataVisualizerLink && ( - - } - title={ - - } - description="" - href={dataVisualizerLink} - /> - - )} - {indexManagementLink && ( = ({ }; async function getFullTimeRange(index: string, timeFieldName: string) { - // const query = { bool: { must: [{ query_string: { analyze_wildcard: true, query: '*' } }] } }; - // const resp = await ml.getTimeFieldRange({ - // index, - // timeFieldName, - // query, - // }); + const query = { bool: { must: [{ query_string: { analyze_wildcard: true, query: '*' } }] } }; + const resp = await getTimeFieldRange({ + index, + timeFieldName, + query, + }); - // return { - // from: moment(resp.start.epoch).toISOString(), - // to: moment(resp.end.epoch).toISOString(), - // }; - // TODO FIX return { - from: moment(0).toISOString(), - to: moment(0).toISOString(), + from: moment(resp.start.epoch).toISOString(), + to: moment(resp.end.epoch).toISOString(), }; } -*/ diff --git a/x-pack/plugins/file_upload/public/application/file_datavisualizer.tsx b/x-pack/plugins/file_upload/public/application/file_datavisualizer.tsx index 02db836d57242..ed157249106c0 100644 --- a/x-pack/plugins/file_upload/public/application/file_datavisualizer.tsx +++ b/x-pack/plugins/file_upload/public/application/file_datavisualizer.tsx @@ -8,6 +8,7 @@ import './_index.scss'; import React, { FC } from 'react'; import { DataPublicPluginStart } from 'src/plugins/data/public'; import { CoreStart } from 'kibana/public'; +import type { SharePluginStart } from 'src/plugins/share/public'; import { KibanaContextProvider } from '../../../../../src/plugins/kibana_react/public'; import type { EmbeddableStart } from '../../../../../src/plugins/embeddable/public'; // import type { MapsStartApi } from '../../../maps/public'; @@ -22,6 +23,7 @@ export interface FileDataVisualizerProps { // maps?: MapsStartApi; security?: SecurityPluginSetup; coreStart: CoreStart; + share: SharePluginStart; } export const FileDataVisualizer: FC = ({ @@ -29,9 +31,10 @@ export const FileDataVisualizer: FC = ({ embeddable, // maps, security, + share, coreStart, }) => { - const services = { data, embeddable, /* maps,*/ security, ...coreStart }; + const services = { data, embeddable, share, /* maps,*/ security, ...coreStart }; return ( diff --git a/x-pack/plugins/file_upload/public/application/kibana_context.ts b/x-pack/plugins/file_upload/public/application/kibana_context.ts index be2609c89ccac..5ec378d7c6566 100644 --- a/x-pack/plugins/file_upload/public/application/kibana_context.ts +++ b/x-pack/plugins/file_upload/public/application/kibana_context.ts @@ -7,6 +7,7 @@ import { DataPublicPluginStart } from 'src/plugins/data/public'; import { CoreStart } from 'kibana/public'; +import type { SharePluginStart } from 'src/plugins/share/public'; import { useKibana, KibanaReactContextValue } from '../../../../../src/plugins/kibana_react/public'; import { SecurityPluginSetup } from '../../../security/public'; import type { EmbeddableStart } from '../../../../../src/plugins/embeddable/public'; @@ -16,6 +17,7 @@ interface StartPlugins { data: DataPublicPluginStart; security?: SecurityPluginSetup; embeddable: EmbeddableStart; + share: SharePluginStart; // maps?: MapsStartApi; } export type StartServices = CoreStart & StartPlugins; diff --git a/x-pack/plugins/file_upload/server/get_time_field_range.ts b/x-pack/plugins/file_upload/server/get_time_field_range.ts new file mode 100644 index 0000000000000..66a428128cbe1 --- /dev/null +++ b/x-pack/plugins/file_upload/server/get_time_field_range.ts @@ -0,0 +1,54 @@ +/* + * 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 { IScopedClusterClient } from 'kibana/server'; +export async function getTimeFieldRange( + client: IScopedClusterClient, + index: string[] | string, + timeFieldName: string, + query: any +): Promise<{ + success: boolean; + start: { epoch: number; string: string }; + end: { epoch: number; string: string }; +}> { + const obj = { success: true, start: { epoch: 0, string: '' }, end: { epoch: 0, string: '' } }; + + const { + body: { aggregations }, + } = await client.asCurrentUser.search({ + index, + size: 0, + body: { + ...(query ? { query } : {}), + aggs: { + earliest: { + min: { + field: timeFieldName, + }, + }, + latest: { + max: { + field: timeFieldName, + }, + }, + }, + }, + }); + + if (aggregations && aggregations.earliest && aggregations.latest) { + // @ts-expect-error fix search aggregation response + obj.start.epoch = aggregations.earliest.value; + // @ts-expect-error fix search aggregation response + obj.start.string = aggregations.earliest.value_as_string; + + // @ts-expect-error fix search aggregation response + obj.end.epoch = aggregations.latest.value; + // @ts-expect-error fix search aggregation response + obj.end.string = aggregations.latest.value_as_string; + } + return obj; +} diff --git a/x-pack/plugins/file_upload/server/routes.ts b/x-pack/plugins/file_upload/server/routes.ts index 6d7eb77f39069..43ef741698298 100644 --- a/x-pack/plugins/file_upload/server/routes.ts +++ b/x-pack/plugins/file_upload/server/routes.ts @@ -18,6 +18,7 @@ import { import { wrapError } from './error_wrapper'; import { analyzeFile } from './analyze_file'; import { importDataProvider } from './import_data'; +import { getTimeFieldRange } from './get_time_field_range'; import { updateTelemetry } from './telemetry'; import { analyzeFileQuerySchema, importFileBodySchema, importFileQuerySchema } from './schemas'; @@ -180,4 +181,90 @@ export function fileUploadRoutes(coreSetup: CoreSetup, logge } } ); + + /** + * @apiGroup FileDataVisualizer + * + * @api {post} /api/file_upload/index_exists ES Field caps wrapper checks if index exists + * @apiName IndexExists + */ + router.post( + { + path: '/api/file_upload/index_exists', + validate: { + body: schema.object({ index: schema.string() }), + }, + options: { + tags: ['access:fileUpload:analyzeFile'], + }, + }, + async (context, request, response) => { + try { + const { index } = request.body; + + const options = { + index: [index], + fields: ['*'], + ignore_unavailable: true, + allow_no_indices: true, + }; + + const { body } = await context.core.elasticsearch.client.asCurrentUser.fieldCaps(options); + const exists = Array.isArray(body.indices) && body.indices.length !== 0; + return response.ok({ + body: { exists }, + }); + } catch (e) { + return response.customError(wrapError(e)); + } + } + ); + + /** + * @apiGroup FileDataVisualizer + * + * @api {post} /api/file_upload/time_field_range Get time field range + * @apiName GetTimeFieldRange + * @apiDescription Returns the time range for the given index and query using the specified time range. + * + * @apiSchema (body) getTimeFieldRangeSchema + * + * @apiSuccess {Object} start start of time range with epoch and string properties. + * @apiSuccess {Object} end end of time range with epoch and string properties. + */ + router.post( + { + path: '/api/file_upload/time_field_range', + validate: { + body: schema.object({ + /** Index or indexes for which to return the time range. */ + index: schema.oneOf([schema.string(), schema.arrayOf(schema.string())]), + /** Name of the time field in the index. */ + timeFieldName: schema.string(), + /** Query to match documents in the index(es). */ + query: schema.maybe(schema.any()), + }), + }, + options: { + tags: ['access:fileUpload:analyzeFile'], + }, + }, + async (context, request, response) => { + try { + const { index, timeFieldName, query } = request.body; + const resp = await getTimeFieldRange( + context.core.elasticsearch.client, + index, + timeFieldName, + query + ); + + return response.ok({ + body: resp, + }); + } catch (e) { + return response.customError(wrapError(e)); + } + } + ); } diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx b/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx index 55ea0bc8d6662..c3adb6d357108 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx +++ b/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx @@ -17,7 +17,7 @@ import { FileDataVisualizer } from '../../../../../file_upload/public'; export const FileDataVisualizerPage: FC = () => { useTimefilter({ timeRangeSelector: false, autoRefreshSelector: false }); const { - services: { docLinks, data, embeddable, /* maps,*/ security, savedObjects }, + services: { docLinks, data, embeddable, share, /* maps,*/ security, savedObjects }, } = useMlKibana(); const coreStart = { savedObjects } as CoreStart; const helpLink = docLinks.links.ml.guide; @@ -28,6 +28,7 @@ export const FileDataVisualizerPage: FC = () => { coreStart={coreStart} data={data} embeddable={embeddable} + share={share} // maps={maps} security={security} /> From c0e46adfd83d40d7f4c6c07334922f288ab2e460 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Thu, 8 Apr 2021 11:56:56 +0100 Subject: [PATCH 06/37] fixing translations --- .../components/about_panel/about_panel.tsx | 4 +- .../about_panel/welcome_content.tsx | 18 +- .../analysis_summary/analysis_summary.tsx | 16 +- .../components/bottom_bar/bottom_bar.tsx | 10 +- .../combined_fields/combined_fields_form.tsx | 21 +-- .../combined_fields_read_only_form.tsx | 4 +- .../components/combined_fields/geo_point.tsx | 17 +- .../components/combined_fields/utils.ts | 2 +- .../__snapshots__/overrides.test.js.snap | 8 +- .../components/edit_flyout/edit_flyout.js | 6 +- .../components/edit_flyout/overrides.js | 37 ++-- .../edit_flyout/overrides_validation.js | 11 +- .../examples_list/examples_list.tsx | 4 +- .../experimental_badge/experimental_badge.tsx | 2 +- .../explanation_flyout/explanation_flyout.tsx | 6 +- .../field_data_row/number_content_preview.tsx | 12 +- .../field_names_filter/field_names_filter.tsx | 2 +- .../field_type_icon/field_type_icon.tsx | 2 +- .../field_types_filter/field_types_filter.tsx | 2 +- .../file_contents/file_contents.tsx | 4 +- .../file_datavisualizer_view.js | 2 +- .../file_error_callouts.tsx | 14 +- .../filebeat_config_flyout/filebeat_config.ts | 2 +- .../filebeat_config_flyout.tsx | 14 +- .../components/import_errors/errors.tsx | 20 +-- .../import_progress/import_progress.tsx | 103 +++++------ .../components/import_settings/advanced.tsx | 23 ++- .../import_settings/import_settings.tsx | 4 +- .../components/import_settings/simple.tsx | 15 +- .../components/import_summary/failures.tsx | 2 +- .../import_summary/import_summary.tsx | 19 +-- .../components/import_view/import_view.js | 24 +-- .../multi_select_picker.tsx | 2 +- .../results_links/results_links.tsx | 8 +- .../components/results_view/results_view.tsx | 6 +- .../field_count_stats/metric_fields_count.tsx | 4 +- .../field_count_stats/total_fields_count.tsx | 4 +- .../boolean_content.tsx | 8 +- .../field_data_expanded_row/date_content.tsx | 13 +- .../document_stats.tsx | 8 +- .../number_content.tsx | 12 +- .../field_data_expanded_row/text_content.tsx | 13 +- .../field_data_row/use_column_chart.tsx | 8 +- .../metric_distribution_chart.tsx | 9 +- ...tric_distribution_chart_tooltip_header.tsx | 4 +- .../data_visualizer_stats_table.tsx | 34 ++-- .../stats_table/hooks/use_color_range.ts | 23 +-- .../components/top_values/top_values.tsx | 7 +- .../application/util/field_types_utils.ts | 16 +- .../translations/translations/ja-JP.json | 159 ----------------- .../translations/translations/zh-CN.json | 161 ------------------ 51 files changed, 290 insertions(+), 639 deletions(-) diff --git a/x-pack/plugins/file_upload/public/application/components/about_panel/about_panel.tsx b/x-pack/plugins/file_upload/public/application/components/about_panel/about_panel.tsx index c768a422cfa5a..c8592179e18e3 100644 --- a/x-pack/plugins/file_upload/public/application/components/about_panel/about_panel.tsx +++ b/x-pack/plugins/file_upload/public/application/components/about_panel/about_panel.tsx @@ -43,7 +43,7 @@ export const AboutPanel: FC = ({ onFilePickerChange }) => { {

diff --git a/x-pack/plugins/file_upload/public/application/components/about_panel/welcome_content.tsx b/x-pack/plugins/file_upload/public/application/components/about_panel/welcome_content.tsx index 7bfb6006322b2..c753b224ab200 100644 --- a/x-pack/plugins/file_upload/public/application/components/about_panel/welcome_content.tsx +++ b/x-pack/plugins/file_upload/public/application/components/about_panel/welcome_content.tsx @@ -25,7 +25,7 @@ import { getMaxBytesFormatted } from '../../../get_max_bytes'; export const WelcomeContent: FC = () => { const toolTipContent = i18n.translate( - 'xpack.ml.fileDatavisualizer.welcomeContent.experimentalFeatureTooltip', + 'xpack.fileUpload.welcomeContent.experimentalFeatureTooltip', { defaultMessage: "Experimental feature. We'd love to hear your feedback.", } @@ -42,7 +42,7 @@ export const WelcomeContent: FC = () => {

, @@ -54,7 +54,7 @@ export const WelcomeContent: FC = () => {

@@ -64,7 +64,7 @@ export const WelcomeContent: FC = () => {

@@ -78,7 +78,7 @@ export const WelcomeContent: FC = () => {

@@ -94,7 +94,7 @@ export const WelcomeContent: FC = () => {

@@ -110,7 +110,7 @@ export const WelcomeContent: FC = () => {

@@ -121,7 +121,7 @@ export const WelcomeContent: FC = () => {

@@ -131,7 +131,7 @@ export const WelcomeContent: FC = () => {

= ({ re

@@ -37,7 +37,7 @@ function createDisplayItems(results: FindFileStructureResponse) { { title: ( ), @@ -53,7 +53,7 @@ function createDisplayItems(results: FindFileStructureResponse) { items.push({ title: ( ), @@ -64,7 +64,7 @@ function createDisplayItems(results: FindFileStructureResponse) { items.push({ title: ( ), @@ -74,7 +74,7 @@ function createDisplayItems(results: FindFileStructureResponse) { items.push({ title: ( ), @@ -87,7 +87,7 @@ function createDisplayItems(results: FindFileStructureResponse) { items.push({ title: ( ), @@ -99,7 +99,7 @@ function createDisplayItems(results: FindFileStructureResponse) { items.push({ title: ( ), @@ -111,7 +111,7 @@ function createDisplayItems(results: FindFileStructureResponse) { items.push({ title: ( = ({ mode, onChangeMode, onCancel, di content={ disableImport ? ( ) : null @@ -52,7 +52,7 @@ export const BottomBar: FC = ({ mode, onChangeMode, onCancel, di data-test-subj="mlFileDataVisOpenImportPageButton" > @@ -61,7 +61,7 @@ export const BottomBar: FC = ({ mode, onChangeMode, onCancel, di onCancel()}> @@ -76,7 +76,7 @@ export const BottomBar: FC = ({ mode, onChangeMode, onCancel, di onChangeMode(DATAVISUALIZER_MODE.READ)}> @@ -84,7 +84,7 @@ export const BottomBar: FC = ({ mode, onChangeMode, onCancel, di onCancel()}> diff --git a/x-pack/plugins/file_upload/public/application/components/combined_fields/combined_fields_form.tsx b/x-pack/plugins/file_upload/public/application/components/combined_fields/combined_fields_form.tsx index 828647ebac92f..b16f3ec79323a 100644 --- a/x-pack/plugins/file_upload/public/application/components/combined_fields/combined_fields_form.tsx +++ b/x-pack/plugins/file_upload/public/application/components/combined_fields/combined_fields_form.tsx @@ -114,7 +114,7 @@ export class CombinedFieldsForm extends Component { return JSON.parse(this.props.mappingsString); } catch (error) { throw new Error( - i18n.translate('xpack.ml.fileDatavisualizer.combinedFieldsForm.mappingsParseError', { + i18n.translate('xpack.fileUpload.combinedFieldsForm.mappingsParseError', { defaultMessage: 'Error parsing mappings: {error}', values: { error: error.message }, }) @@ -127,7 +127,7 @@ export class CombinedFieldsForm extends Component { return JSON.parse(this.props.pipelineString); } catch (error) { throw new Error( - i18n.translate('xpack.ml.fileDatavisualizer.combinedFieldsForm.pipelineParseError', { + i18n.translate('xpack.fileUpload.combinedFieldsForm.pipelineParseError', { defaultMessage: 'Error parsing pipeline: {error}', values: { error: error.message }, }) @@ -153,7 +153,7 @@ export class CombinedFieldsForm extends Component { }; render() { - const geoPointLabel = i18n.translate('xpack.ml.fileDatavisualizer.geoPointCombinedFieldLabel', { + const geoPointLabel = i18n.translate('xpack.fileUpload.geoPointCombinedFieldLabel', { defaultMessage: 'Add geo point field', }); const panels = [ @@ -180,7 +180,7 @@ export class CombinedFieldsForm extends Component { ]; return ( @@ -196,15 +196,12 @@ export class CombinedFieldsForm extends Component { iconType="trash" color="danger" onClick={this.removeCombinedField.bind(null, idx)} - title={i18n.translate('xpack.ml.fileDatavisualizer.removeCombinedFieldsLabel', { + title={i18n.translate('xpack.fileUpload.removeCombinedFieldsLabel', { + defaultMessage: 'Remove combined field', + })} + aria-label={i18n.translate('xpack.fileUpload.removeCombinedFieldsLabel', { defaultMessage: 'Remove combined field', })} - aria-label={i18n.translate( - 'xpack.ml.fileDatavisualizer.removeCombinedFieldsLabel', - { - defaultMessage: 'Remove combined field', - } - )} /> )} @@ -220,7 +217,7 @@ export class CombinedFieldsForm extends Component { isDisabled={this.props.isDisabled} > diff --git a/x-pack/plugins/file_upload/public/application/components/combined_fields/combined_fields_read_only_form.tsx b/x-pack/plugins/file_upload/public/application/components/combined_fields/combined_fields_read_only_form.tsx index dc8e839b7defe..630ad746720fc 100644 --- a/x-pack/plugins/file_upload/public/application/components/combined_fields/combined_fields_read_only_form.tsx +++ b/x-pack/plugins/file_upload/public/application/components/combined_fields/combined_fields_read_only_form.tsx @@ -20,10 +20,10 @@ export function CombinedFieldsReadOnlyForm({ }) { return combinedFields.length ? ( diff --git a/x-pack/plugins/file_upload/public/application/components/combined_fields/geo_point.tsx b/x-pack/plugins/file_upload/public/application/components/combined_fields/geo_point.tsx index 3c80ccb8f59ff..1b8f2de644d5f 100644 --- a/x-pack/plugins/file_upload/public/application/components/combined_fields/geo_point.tsx +++ b/x-pack/plugins/file_upload/public/application/components/combined_fields/geo_point.tsx @@ -119,7 +119,7 @@ export class GeoPointForm extends Component { return ( @@ -131,7 +131,7 @@ export class GeoPointForm extends Component { @@ -143,7 +143,7 @@ export class GeoPointForm extends Component { { value={this.state.geoPointField} onChange={this.onGeoPointFieldChange} isInvalid={this.state.geoPointFieldError !== ''} - aria-label={i18n.translate( - 'xpack.ml.fileDatavisualizer.geoPointForm.geoPointFieldAriaLabel', - { - defaultMessage: 'Geo point field, required field', - } - )} + aria-label={i18n.translate('xpack.fileUpload.geoPointForm.geoPointFieldAriaLabel', { + defaultMessage: 'Geo point field, required field', + })} /> @@ -179,7 +176,7 @@ export class GeoPointForm extends Component { onClick={this.onSubmit} > diff --git a/x-pack/plugins/file_upload/public/application/components/combined_fields/utils.ts b/x-pack/plugins/file_upload/public/application/components/combined_fields/utils.ts index 3a5570a966d1f..0527af9a8b225 100644 --- a/x-pack/plugins/file_upload/public/application/components/combined_fields/utils.ts +++ b/x-pack/plugins/file_upload/public/application/components/combined_fields/utils.ts @@ -123,7 +123,7 @@ export function createGeoPointCombinedField( } export function getNameCollisionMsg(name: string) { - return i18n.translate('xpack.ml.fileDatavisualizer.nameCollisionMsg', { + return i18n.translate('xpack.fileUpload.nameCollisionMsg', { defaultMessage: '"{name}" already exists, please provide a unique name', values: { name }, }); diff --git a/x-pack/plugins/file_upload/public/application/components/edit_flyout/__snapshots__/overrides.test.js.snap b/x-pack/plugins/file_upload/public/application/components/edit_flyout/__snapshots__/overrides.test.js.snap index 6ab89fe3e4b2d..18e63c7d6af05 100644 --- a/x-pack/plugins/file_upload/public/application/components/edit_flyout/__snapshots__/overrides.test.js.snap +++ b/x-pack/plugins/file_upload/public/application/components/edit_flyout/__snapshots__/overrides.test.js.snap @@ -13,7 +13,7 @@ exports[`Overrides render overrides 1`] = ` label={ } @@ -33,7 +33,7 @@ exports[`Overrides render overrides 1`] = ` label={ } @@ -94,7 +94,7 @@ exports[`Overrides render overrides 1`] = ` label={ } @@ -335,7 +335,7 @@ exports[`Overrides render overrides 1`] = ` label={ } diff --git a/x-pack/plugins/file_upload/public/application/components/edit_flyout/edit_flyout.js b/x-pack/plugins/file_upload/public/application/components/edit_flyout/edit_flyout.js index c26e504087b46..41a784c91a261 100644 --- a/x-pack/plugins/file_upload/public/application/components/edit_flyout/edit_flyout.js +++ b/x-pack/plugins/file_upload/public/application/components/edit_flyout/edit_flyout.js @@ -69,7 +69,7 @@ export class EditFlyout extends Component {

@@ -96,7 +96,7 @@ export class EditFlyout extends Component { @@ -108,7 +108,7 @@ export class EditFlyout extends Component { fill > diff --git a/x-pack/plugins/file_upload/public/application/components/edit_flyout/overrides.js b/x-pack/plugins/file_upload/public/application/components/edit_flyout/overrides.js index eb21a740ebce3..3a820bf5b9778 100644 --- a/x-pack/plugins/file_upload/public/application/components/edit_flyout/overrides.js +++ b/x-pack/plugins/file_upload/public/application/components/edit_flyout/overrides.js @@ -52,7 +52,7 @@ class OverridesUI extends Component { } linesToSampleErrors = i18n.translate( - 'xpack.ml.fileDatavisualizer.editFlyout.overrides.linesToSampleErrorMessage', + 'xpack.fileUpload.editFlyout.overrides.linesToSampleErrorMessage', { defaultMessage: 'Value must be greater than {min} and less than or equal to {max}', values: { @@ -63,7 +63,7 @@ class OverridesUI extends Component { ); customTimestampFormatErrors = i18n.translate( - 'xpack.ml.fileDatavisualizer.editFlyout.overrides.customTimestampFormatErrorMessage', + 'xpack.fileUpload.editFlyout.overrides.customTimestampFormatErrorMessage', { defaultMessage: `Timestamp format must be a combination of these Java date/time formats: yy, yyyy, M, MM, MMM, MMMM, d, dd, EEE, EEEE, H, HH, h, mm, ss, S through SSSSSSSSS, a, XX, XXX, zzz`, @@ -274,12 +274,9 @@ class OverridesUI extends Component { const timestampFormatHelp = ( - {i18n.translate( - 'xpack.ml.fileDatavisualizer.editFlyout.overrides.timestampFormatHelpText', - { - defaultMessage: 'See more on accepted formats', - } - )} + {i18n.translate('xpack.fileUpload.editFlyout.overrides.timestampFormatHelpText', { + defaultMessage: 'See more on accepted formats', + })} ); @@ -291,7 +288,7 @@ class OverridesUI extends Component { isInvalid={linesToSampleValid === false} label={ } @@ -306,7 +303,7 @@ class OverridesUI extends Component { } @@ -324,7 +321,7 @@ class OverridesUI extends Component { } @@ -341,7 +338,7 @@ class OverridesUI extends Component { } @@ -353,7 +350,7 @@ class OverridesUI extends Component { } @@ -372,7 +369,7 @@ class OverridesUI extends Component { id={'hasHeaderRow'} label={ } @@ -386,7 +383,7 @@ class OverridesUI extends Component { id={'shouldTrimFields'} label={ } @@ -401,7 +398,7 @@ class OverridesUI extends Component { } @@ -418,7 +415,7 @@ class OverridesUI extends Component { helpText={timestampFormatHelp} label={ } @@ -437,7 +434,7 @@ class OverridesUI extends Component { isInvalid={timestampFormatValid === false} label={ } @@ -453,7 +450,7 @@ class OverridesUI extends Component { } @@ -483,7 +480,7 @@ class OverridesUI extends Component {

diff --git a/x-pack/plugins/file_upload/public/application/components/edit_flyout/overrides_validation.js b/x-pack/plugins/file_upload/public/application/components/edit_flyout/overrides_validation.js index 79a44bd8b5ac6..1356f7dccf6a9 100644 --- a/x-pack/plugins/file_upload/public/application/components/edit_flyout/overrides_validation.js +++ b/x-pack/plugins/file_upload/public/application/components/edit_flyout/overrides_validation.js @@ -41,7 +41,7 @@ export function isTimestampFormatValid(timestampFormat) { if (timestampFormat.indexOf('?') >= 0) { result.isValid = false; result.errorMessage = i18n.translate( - 'xpack.ml.fileDatavisualizer.editFlyout.overrides.timestampQuestionMarkValidationErrorMessage', + 'xpack.fileUpload.editFlyout.overrides.timestampQuestionMarkValidationErrorMessage', { defaultMessage: 'Timestamp format {timestampFormat} not supported because it contains a question mark character ({fieldPlaceholder})', @@ -86,7 +86,7 @@ export function isTimestampFormatValid(timestampFormat) { result.isValid = false; result.errorMessage = i18n.translate( - 'xpack.ml.fileDatavisualizer.editFlyout.overrides.timestampLetterValidationErrorMessage', + 'xpack.fileUpload.editFlyout.overrides.timestampLetterValidationErrorMessage', { defaultMessage: 'Letter { length, plural, one { {lg} } other { group {lg} } } in {format} is not supported', @@ -101,9 +101,10 @@ export function isTimestampFormatValid(timestampFormat) { if (curChar === 'S') { // disable exceeds maximum line length error so i18n check passes result.errorMessage = i18n.translate( - 'xpack.ml.fileDatavisualizer.editFlyout.overrides.timestampLetterSValidationErrorMessage', + 'xpack.fileUpload.editFlyout.overrides.timestampLetterSValidationErrorMessage', { - defaultMessage: 'Letter { length, plural, one { {lg} } other { group {lg} } } in {format} is not supported because it is not preceded by ss and a separator from {sep}', // eslint-disable-line + defaultMessage: + 'Letter { length, plural, one { {lg} } other { group {lg} } } in {format} is not supported because it is not preceded by ss and a separator from {sep}', // eslint-disable-line values: { length, lg: letterGroup, @@ -127,7 +128,7 @@ export function isTimestampFormatValid(timestampFormat) { if (prevLetterGroup == null) { result.isValid = false; result.errorMessage = i18n.translate( - 'xpack.ml.fileDatavisualizer.editFlyout.overrides.timestampEmptyValidationErrorMessage', + 'xpack.fileUpload.editFlyout.overrides.timestampEmptyValidationErrorMessage', { defaultMessage: 'No time format letter groups in timestamp format {timestampFormat}', values: { diff --git a/x-pack/plugins/file_upload/public/application/components/examples_list/examples_list.tsx b/x-pack/plugins/file_upload/public/application/components/examples_list/examples_list.tsx index 6697cf8b1be5f..f02e853779b29 100644 --- a/x-pack/plugins/file_upload/public/application/components/examples_list/examples_list.tsx +++ b/x-pack/plugins/file_upload/public/application/components/examples_list/examples_list.tsx @@ -23,7 +23,7 @@ export const ExamplesList: FC = ({ examples }) => { if (examples.length === 0) { examplesContent = ( ); @@ -44,7 +44,7 @@ export const ExamplesList: FC = ({ examples }) => {
= ({ tooltipConte className="ml-experimental-badge" label={ } diff --git a/x-pack/plugins/file_upload/public/application/components/explanation_flyout/explanation_flyout.tsx b/x-pack/plugins/file_upload/public/application/components/explanation_flyout/explanation_flyout.tsx index 93e276dceb024..4c89307d286d1 100644 --- a/x-pack/plugins/file_upload/public/application/components/explanation_flyout/explanation_flyout.tsx +++ b/x-pack/plugins/file_upload/public/application/components/explanation_flyout/explanation_flyout.tsx @@ -34,7 +34,7 @@ export const ExplanationFlyout: FC = ({ results, closeFlyout }) => {

@@ -48,7 +48,7 @@ export const ExplanationFlyout: FC = ({ results, closeFlyout }) => { @@ -63,7 +63,7 @@ const Content: FC<{ explanation: string[] }> = ({ explanation }) => ( <> diff --git a/x-pack/plugins/file_upload/public/application/components/field_data_row/number_content_preview.tsx b/x-pack/plugins/file_upload/public/application/components/field_data_row/number_content_preview.tsx index a3622202e1d9e..fb097de7c2f1d 100644 --- a/x-pack/plugins/file_upload/public/application/components/field_data_row/number_content_preview.tsx +++ b/x-pack/plugins/file_upload/public/application/components/field_data_row/number_content_preview.tsx @@ -24,26 +24,20 @@ export const FileBasedNumberContentPreview = ({ config }: { config: FileBasedFie - + - + diff --git a/x-pack/plugins/file_upload/public/application/components/field_names_filter/field_names_filter.tsx b/x-pack/plugins/file_upload/public/application/components/field_names_filter/field_names_filter.tsx index 45ffb9f5dbb86..eb5b0fa48fe90 100644 --- a/x-pack/plugins/file_upload/public/application/components/field_names_filter/field_names_filter.tsx +++ b/x-pack/plugins/file_upload/public/application/components/field_names_filter/field_names_filter.tsx @@ -26,7 +26,7 @@ export const DataVisualizerFieldNamesFilter: FC = ({ }) => { const fieldNameTitle = useMemo( () => - i18n.translate('xpack.ml.dataVisualizer.fileBased.fieldNameSelect', { + i18n.translate('xpack.fileUpload.fieldNameSelect', { defaultMessage: 'Field name', }), [] diff --git a/x-pack/plugins/file_upload/public/application/components/field_type_icon/field_type_icon.tsx b/x-pack/plugins/file_upload/public/application/components/field_type_icon/field_type_icon.tsx index dbfbf2b230619..3d066a121c693 100644 --- a/x-pack/plugins/file_upload/public/application/components/field_type_icon/field_type_icon.tsx +++ b/x-pack/plugins/file_upload/public/application/components/field_type_icon/field_type_icon.tsx @@ -91,7 +91,7 @@ export const FieldTypeIcon: FC = ({ return ( = ({ }) => { const fieldNameTitle = useMemo( () => - i18n.translate('xpack.ml.dataVisualizer.fileBased.fieldTypeSelect', { + i18n.translate('xpack.fileUpload.fieldTypeSelect', { defaultMessage: 'Field type', }), [] diff --git a/x-pack/plugins/file_upload/public/application/components/file_contents/file_contents.tsx b/x-pack/plugins/file_upload/public/application/components/file_contents/file_contents.tsx index d8ed48dad3573..46bab8c44df46 100644 --- a/x-pack/plugins/file_upload/public/application/components/file_contents/file_contents.tsx +++ b/x-pack/plugins/file_upload/public/application/components/file_contents/file_contents.tsx @@ -31,7 +31,7 @@ export const FileContents: FC = ({ data, format, numberOfLines }) => {

@@ -39,7 +39,7 @@ export const FileContents: FC = ({ data, format, numberOfLines }) => {
), diff --git a/x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/file_error_callouts.tsx b/x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/file_error_callouts.tsx index 1b5b41733e3ef..21923a0b09980 100644 --- a/x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/file_error_callouts.tsx +++ b/x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/file_error_callouts.tsx @@ -41,7 +41,7 @@ export const FileTooLarge: FC = ({ fileSize, maxFileSize }) = errorText = (

= ({ fileSize, maxFileSize }) = errorText = (

= ({ fileSize, maxFileSize }) = } @@ -102,7 +102,7 @@ export const FileCouldNotBeRead: FC = ({ } @@ -113,13 +113,13 @@ export const FileCouldNotBeRead: FC = ({ {loaded === false && ( <>
@@ -132,7 +132,7 @@ export const FileCouldNotBeRead: FC = ({ <> diff --git a/x-pack/plugins/file_upload/public/application/components/filebeat_config_flyout/filebeat_config.ts b/x-pack/plugins/file_upload/public/application/components/filebeat_config_flyout/filebeat_config.ts index 746140e07ad22..f21138df10ac7 100644 --- a/x-pack/plugins/file_upload/public/application/components/filebeat_config_flyout/filebeat_config.ts +++ b/x-pack/plugins/file_upload/public/application/components/filebeat_config_flyout/filebeat_config.ts @@ -36,7 +36,7 @@ export function createFilebeatConfig( } function getPaths() { - const txt = i18n.translate('xpack.ml.fileDatavisualizer.fileBeatConfig.paths', { + const txt = i18n.translate('xpack.fileUpload.fileBeatConfig.paths', { defaultMessage: 'add path to your files here', }); return [' paths:', ` - '<${txt}>'`]; diff --git a/x-pack/plugins/file_upload/public/application/components/filebeat_config_flyout/filebeat_config_flyout.tsx b/x-pack/plugins/file_upload/public/application/components/filebeat_config_flyout/filebeat_config_flyout.tsx index 07f906051e5bb..b106d527f24f9 100644 --- a/x-pack/plugins/file_upload/public/application/components/filebeat_config_flyout/filebeat_config_flyout.tsx +++ b/x-pack/plugins/file_upload/public/application/components/filebeat_config_flyout/filebeat_config_flyout.tsx @@ -75,7 +75,7 @@ export const FilebeatConfigFlyout: FC = ({ @@ -85,7 +85,7 @@ export const FilebeatConfigFlyout: FC = ({ {(copy) => ( @@ -108,7 +108,7 @@ const Contents: FC<{

@@ -116,14 +116,14 @@ const Contents: FC<{

{index} }} />

filebeat.yml }} /> @@ -137,7 +137,7 @@ const Contents: FC<{

{username === null ? ( {''}, @@ -145,7 +145,7 @@ const Contents: FC<{ /> ) : ( {username}, diff --git a/x-pack/plugins/file_upload/public/application/components/import_errors/errors.tsx b/x-pack/plugins/file_upload/public/application/components/import_errors/errors.tsx index 37e90b5f5753b..719fcc8ba8001 100644 --- a/x-pack/plugins/file_upload/public/application/components/import_errors/errors.tsx +++ b/x-pack/plugins/file_upload/public/application/components/import_errors/errors.tsx @@ -38,56 +38,56 @@ function title(statuses: Statuses) { case statuses.readStatus: return ( ); case statuses.parseJSONStatus: return ( ); case statuses.indexCreatedStatus: return ( ); case statuses.ingestPipelineCreatedStatus: return ( ); case statuses.uploadStatus: return ( ); case statuses.indexPatternCreatedStatus: return ( ); case statuses.permissionCheckStatus: return ( ); default: return ( ); @@ -105,7 +105,7 @@ const ImportError: FC<{ error: any }> = ({ error }) => { id="more" buttonContent={ } @@ -151,7 +151,7 @@ function toString(error: any): ImportError { } return { - msg: i18n.translate('xpack.ml.fileDatavisualizer.importErrors.unknownErrorMessage', { + msg: i18n.translate('xpack.fileUpload.importErrors.unknownErrorMessage', { defaultMessage: 'Unknown error', }), }; diff --git a/x-pack/plugins/file_upload/public/application/components/import_progress/import_progress.tsx b/x-pack/plugins/file_upload/public/application/components/import_progress/import_progress.tsx index 40577a761cb03..44d3584e1262d 100644 --- a/x-pack/plugins/file_upload/public/application/components/import_progress/import_progress.tsx +++ b/x-pack/plugins/file_upload/public/application/components/import_progress/import_progress.tsx @@ -79,32 +79,23 @@ export const ImportProgress: FC<{ statuses: Statuses }> = ({ statuses }) => { completedStep = 5; } - let processFileTitle = i18n.translate( - 'xpack.ml.fileDatavisualizer.importProgress.processFileTitle', - { - defaultMessage: 'Process file', - } - ); - let createIndexTitle = i18n.translate( - 'xpack.ml.fileDatavisualizer.importProgress.createIndexTitle', - { - defaultMessage: 'Create index', - } - ); + let processFileTitle = i18n.translate('xpack.fileUpload.importProgress.processFileTitle', { + defaultMessage: 'Process file', + }); + let createIndexTitle = i18n.translate('xpack.fileUpload.importProgress.createIndexTitle', { + defaultMessage: 'Create index', + }); let createIngestPipelineTitle = i18n.translate( - 'xpack.ml.fileDatavisualizer.importProgress.createIngestPipelineTitle', + 'xpack.fileUpload.importProgress.createIngestPipelineTitle', { defaultMessage: 'Create ingest pipeline', } ); - let uploadingDataTitle = i18n.translate( - 'xpack.ml.fileDatavisualizer.importProgress.uploadDataTitle', - { - defaultMessage: 'Upload data', - } - ); + let uploadingDataTitle = i18n.translate('xpack.fileUpload.importProgress.uploadDataTitle', { + defaultMessage: 'Upload data', + }); let createIndexPatternTitle = i18n.translate( - 'xpack.ml.fileDatavisualizer.importProgress.createIndexPatternTitle', + 'xpack.fileUpload.importProgress.createIndexPatternTitle', { defaultMessage: 'Create index pattern', } @@ -113,7 +104,7 @@ export const ImportProgress: FC<{ statuses: Statuses }> = ({ statuses }) => { const creatingIndexStatus = (

@@ -122,53 +113,41 @@ export const ImportProgress: FC<{ statuses: Statuses }> = ({ statuses }) => { const creatingIndexAndIngestPipelineStatus = (

); if (completedStep >= 0) { - processFileTitle = i18n.translate( - 'xpack.ml.fileDatavisualizer.importProgress.processingFileTitle', - { - defaultMessage: 'Processing file', - } - ); + processFileTitle = i18n.translate('xpack.fileUpload.importProgress.processingFileTitle', { + defaultMessage: 'Processing file', + }); statusInfo = (

); } if (completedStep >= 1) { - processFileTitle = i18n.translate( - 'xpack.ml.fileDatavisualizer.importProgress.fileProcessedTitle', - { - defaultMessage: 'File processed', - } - ); - createIndexTitle = i18n.translate( - 'xpack.ml.fileDatavisualizer.importProgress.creatingIndexTitle', - { - defaultMessage: 'Creating index', - } - ); + processFileTitle = i18n.translate('xpack.fileUpload.importProgress.fileProcessedTitle', { + defaultMessage: 'File processed', + }); + createIndexTitle = i18n.translate('xpack.fileUpload.importProgress.creatingIndexTitle', { + defaultMessage: 'Creating index', + }); statusInfo = createPipeline === true ? creatingIndexAndIngestPipelineStatus : creatingIndexStatus; } if (completedStep >= 2) { - createIndexTitle = i18n.translate( - 'xpack.ml.fileDatavisualizer.importProgress.indexCreatedTitle', - { - defaultMessage: 'Index created', - } - ); + createIndexTitle = i18n.translate('xpack.fileUpload.importProgress.indexCreatedTitle', { + defaultMessage: 'Index created', + }); createIngestPipelineTitle = i18n.translate( - 'xpack.ml.fileDatavisualizer.importProgress.creatingIngestPipelineTitle', + 'xpack.fileUpload.importProgress.creatingIngestPipelineTitle', { defaultMessage: 'Creating ingest pipeline', } @@ -178,29 +157,23 @@ export const ImportProgress: FC<{ statuses: Statuses }> = ({ statuses }) => { } if (completedStep >= 3) { createIngestPipelineTitle = i18n.translate( - 'xpack.ml.fileDatavisualizer.importProgress.ingestPipelineCreatedTitle', + 'xpack.fileUpload.importProgress.ingestPipelineCreatedTitle', { defaultMessage: 'Ingest pipeline created', } ); - uploadingDataTitle = i18n.translate( - 'xpack.ml.fileDatavisualizer.importProgress.uploadingDataTitle', - { - defaultMessage: 'Uploading data', - } - ); + uploadingDataTitle = i18n.translate('xpack.fileUpload.importProgress.uploadingDataTitle', { + defaultMessage: 'Uploading data', + }); statusInfo = ; } if (completedStep >= 4) { - uploadingDataTitle = i18n.translate( - 'xpack.ml.fileDatavisualizer.importProgress.dataUploadedTitle', - { - defaultMessage: 'Data uploaded', - } - ); + uploadingDataTitle = i18n.translate('xpack.fileUpload.importProgress.dataUploadedTitle', { + defaultMessage: 'Data uploaded', + }); if (createIndexPattern === true) { createIndexPatternTitle = i18n.translate( - 'xpack.ml.fileDatavisualizer.importProgress.creatingIndexPatternTitle', + 'xpack.fileUpload.importProgress.creatingIndexPatternTitle', { defaultMessage: 'Creating index pattern', } @@ -208,7 +181,7 @@ export const ImportProgress: FC<{ statuses: Statuses }> = ({ statuses }) => { statusInfo = (

@@ -219,7 +192,7 @@ export const ImportProgress: FC<{ statuses: Statuses }> = ({ statuses }) => { } if (completedStep >= 5) { createIndexPatternTitle = i18n.translate( - 'xpack.ml.fileDatavisualizer.importProgress.indexPatternCreatedTitle', + 'xpack.fileUpload.importProgress.indexPatternCreatedTitle', { defaultMessage: 'Index pattern created', } @@ -293,7 +266,7 @@ const UploadFunctionProgress: FC<{ progress: number }> = ({ progress }) => {

diff --git a/x-pack/plugins/file_upload/public/application/components/import_settings/advanced.tsx b/x-pack/plugins/file_upload/public/application/components/import_settings/advanced.tsx index bd3faa4746078..b3671f8856095 100644 --- a/x-pack/plugins/file_upload/public/application/components/import_settings/advanced.tsx +++ b/x-pack/plugins/file_upload/public/application/components/import_settings/advanced.tsx @@ -69,7 +69,7 @@ export const AdvancedSettings: FC = ({ } @@ -78,7 +78,7 @@ export const AdvancedSettings: FC = ({ > = ({ disabled={initialized === true} onChange={onIndexChange} isInvalid={indexNameError !== ''} - aria-label={i18n.translate( - 'xpack.ml.fileDatavisualizer.advancedImportSettings.indexNameAriaLabel', - { - defaultMessage: 'Index name, required field', - } - )} + aria-label={i18n.translate('xpack.fileUpload.advancedImportSettings.indexNameAriaLabel', { + defaultMessage: 'Index name, required field', + })} /> @@ -102,7 +99,7 @@ export const AdvancedSettings: FC = ({ id="createIndexPattern" label={ } @@ -116,7 +113,7 @@ export const AdvancedSettings: FC = ({ } @@ -184,7 +181,7 @@ const IndexSettings: FC = ({ initialized, data, onChange }) => } @@ -209,7 +206,7 @@ const Mappings: FC = ({ initialized, data, onChange }) => { } @@ -234,7 +231,7 @@ const IngestPipeline: FC = ({ initialized, data, onChange }) => } diff --git a/x-pack/plugins/file_upload/public/application/components/import_settings/import_settings.tsx b/x-pack/plugins/file_upload/public/application/components/import_settings/import_settings.tsx index 68c6d7a63b1c2..7544ed962d02e 100644 --- a/x-pack/plugins/file_upload/public/application/components/import_settings/import_settings.tsx +++ b/x-pack/plugins/file_upload/public/application/components/import_settings/import_settings.tsx @@ -59,7 +59,7 @@ export const ImportSettings: FC = ({ const tabs = [ { id: 'simple-settings', - name: i18n.translate('xpack.ml.fileDatavisualizer.importSettings.simpleTabName', { + name: i18n.translate('xpack.fileUpload.importSettings.simpleTabName', { defaultMessage: 'Simple', }), content: ( @@ -80,7 +80,7 @@ export const ImportSettings: FC = ({ }, { id: 'advanced-settings', - name: i18n.translate('xpack.ml.fileDatavisualizer.importSettings.advancedTabName', { + name: i18n.translate('xpack.fileUpload.importSettings.advancedTabName', { defaultMessage: 'Advanced', }), content: ( diff --git a/x-pack/plugins/file_upload/public/application/components/import_settings/simple.tsx b/x-pack/plugins/file_upload/public/application/components/import_settings/simple.tsx index daa360f0e1af0..1014820775e3c 100644 --- a/x-pack/plugins/file_upload/public/application/components/import_settings/simple.tsx +++ b/x-pack/plugins/file_upload/public/application/components/import_settings/simple.tsx @@ -36,7 +36,7 @@ export const SimpleSettings: FC = ({ } @@ -45,7 +45,7 @@ export const SimpleSettings: FC = ({ > = ({ disabled={initialized === true} onChange={onIndexChange} isInvalid={indexNameError !== ''} - aria-label={i18n.translate( - 'xpack.ml.fileDatavisualizer.simpleImportSettings.indexNameAriaLabel', - { - defaultMessage: 'Index name, required field', - } - )} + aria-label={i18n.translate('xpack.fileUpload.simpleImportSettings.indexNameAriaLabel', { + defaultMessage: 'Index name, required field', + })} data-test-subj="mlFileDataVisIndexNameInput" /> @@ -70,7 +67,7 @@ export const SimpleSettings: FC = ({ id="createIndexPattern" label={ } diff --git a/x-pack/plugins/file_upload/public/application/components/import_summary/failures.tsx b/x-pack/plugins/file_upload/public/application/components/import_summary/failures.tsx index 498320b1b792d..41c1afa89f711 100644 --- a/x-pack/plugins/file_upload/public/application/components/import_summary/failures.tsx +++ b/x-pack/plugins/file_upload/public/application/components/import_summary/failures.tsx @@ -51,7 +51,7 @@ export class Failures extends Component { id="failureList" buttonContent={ } diff --git a/x-pack/plugins/file_upload/public/application/components/import_summary/import_summary.tsx b/x-pack/plugins/file_upload/public/application/components/import_summary/import_summary.tsx index 7fa71193ee516..04dd657c833cd 100644 --- a/x-pack/plugins/file_upload/public/application/components/import_summary/import_summary.tsx +++ b/x-pack/plugins/file_upload/public/application/components/import_summary/import_summary.tsx @@ -45,7 +45,7 @@ export const ImportSummary: FC = ({ } @@ -62,7 +62,7 @@ export const ImportSummary: FC = ({ } @@ -71,7 +71,7 @@ export const ImportSummary: FC = ({ >

+ ), description: index, }, { title: ( ), @@ -123,7 +120,7 @@ function createDisplayItems( items.splice(1, 0, { title: ( ), @@ -135,7 +132,7 @@ function createDisplayItems( items.splice(1, 0, { title: ( ), @@ -147,7 +144,7 @@ function createDisplayItems( items.push({ title: ( ), diff --git a/x-pack/plugins/file_upload/public/application/components/import_view/import_view.js b/x-pack/plugins/file_upload/public/application/components/import_view/import_view.js index 22b7bfbdeab9f..012b455f4c1ce 100644 --- a/x-pack/plugins/file_upload/public/application/components/import_view/import_view.js +++ b/x-pack/plugins/file_upload/public/application/components/import_view/import_view.js @@ -130,7 +130,7 @@ export class ImportView extends Component { })) === false ) { errors.push( - i18n.translate('xpack.ml.fileDatavisualizer.importView.importPermissionError', { + i18n.translate('xpack.fileUpload.importView.importPermissionError', { defaultMessage: 'You do not have permission to create or import data into index {index}.', values: { @@ -170,7 +170,7 @@ export class ImportView extends Component { } catch (error) { success = false; const parseError = i18n.translate( - 'xpack.ml.fileDatavisualizer.importView.parseSettingsError', + 'xpack.fileUpload.importView.parseSettingsError', { defaultMessage: 'Error parsing settings:', } @@ -183,7 +183,7 @@ export class ImportView extends Component { } catch (error) { success = false; const parseError = i18n.translate( - 'xpack.ml.fileDatavisualizer.importView.parseMappingsError', + 'xpack.fileUpload.importView.parseMappingsError', { defaultMessage: 'Error parsing mappings:', } @@ -198,7 +198,7 @@ export class ImportView extends Component { } catch (error) { success = false; const parseError = i18n.translate( - 'xpack.ml.fileDatavisualizer.importView.parsePipelineError', + 'xpack.fileUpload.importView.parsePipelineError', { defaultMessage: 'Error parsing ingest pipeline:', } @@ -355,7 +355,7 @@ export class ImportView extends Component { const { exists } = await checkIndexExists(index); const indexNameError = exists ? ( ) : ( @@ -508,14 +508,14 @@ export class ImportView extends Component {

  } @@ -556,7 +556,7 @@ export class ImportView extends Component { data-test-subj="mlFileDataVisImportButton" > @@ -565,7 +565,7 @@ export class ImportView extends Component { {initialized === true && importing === false && ( @@ -697,7 +697,7 @@ function isIndexNameValid(name) { ) { return ( ); @@ -714,7 +714,7 @@ function isIndexPatternNameValid(name, indexPatternNames, index) { if (indexPatternNames.find((i) => i === name)) { return ( ); @@ -730,7 +730,7 @@ function isIndexPatternNameValid(name, indexPatternNames, index) { // name should match index return ( ); diff --git a/x-pack/plugins/file_upload/public/application/components/multi_select_picker/multi_select_picker.tsx b/x-pack/plugins/file_upload/public/application/components/multi_select_picker/multi_select_picker.tsx index 03db3127c85c0..7fe7fc88cd9d7 100644 --- a/x-pack/plugins/file_upload/public/application/components/multi_select_picker/multi_select_picker.tsx +++ b/x-pack/plugins/file_upload/public/application/components/multi_select_picker/multi_select_picker.tsx @@ -32,7 +32,7 @@ const NoFilterItems = () => {

diff --git a/x-pack/plugins/file_upload/public/application/components/results_links/results_links.tsx b/x-pack/plugins/file_upload/public/application/components/results_links/results_links.tsx index e3f58e7e5a564..b18ac3d7b0af2 100644 --- a/x-pack/plugins/file_upload/public/application/components/results_links/results_links.tsx +++ b/x-pack/plugins/file_upload/public/application/components/results_links/results_links.tsx @@ -175,7 +175,7 @@ export const ResultsLinks: FC = ({ icon={} title={ } @@ -191,7 +191,7 @@ export const ResultsLinks: FC = ({ icon={} title={ } @@ -207,7 +207,7 @@ export const ResultsLinks: FC = ({ icon={} title={ } @@ -221,7 +221,7 @@ export const ResultsLinks: FC = ({ icon={} title={ } diff --git a/x-pack/plugins/file_upload/public/application/components/results_view/results_view.tsx b/x-pack/plugins/file_upload/public/application/components/results_view/results_view.tsx index 3167cbba28bd7..40363b0225d90 100644 --- a/x-pack/plugins/file_upload/public/application/components/results_view/results_view.tsx +++ b/x-pack/plugins/file_upload/public/application/components/results_view/results_view.tsx @@ -72,7 +72,7 @@ export const ResultsView: FC = ({ showEditFlyout()} disabled={disableButtons}> @@ -80,7 +80,7 @@ export const ResultsView: FC = ({ showExplanationFlyout()} disabled={disableButtons}> @@ -94,7 +94,7 @@ export const ResultsView: FC = ({

diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/metric_fields_count.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/metric_fields_count.tsx index dae22cf6daab8..14b564b5272ca 100644 --- a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/metric_fields_count.tsx +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/metric_fields_count.tsx @@ -37,7 +37,7 @@ export const MetricFieldsCount: FC = ({ metricsStats })
@@ -55,7 +55,7 @@ export const MetricFieldsCount: FC = ({ metricsStats }) diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/total_fields_count.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/total_fields_count.tsx index aacd7172903f5..20e742e9a3c2f 100644 --- a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/total_fields_count.tsx +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/total_fields_count.tsx @@ -37,7 +37,7 @@ export const TotalFieldsCount: FC = ({ fieldsCountStats }
@@ -56,7 +56,7 @@ export const TotalFieldsCount: FC = ({ fieldsCountStats } diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/boolean_content.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/boolean_content.tsx index fbcd6b0793a66..2624d750ede6e 100644 --- a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/boolean_content.tsx +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/boolean_content.tsx @@ -49,7 +49,7 @@ export const BooleanContent: FC = ({ config }) => { function: 'true', display: ( ), @@ -59,7 +59,7 @@ export const BooleanContent: FC = ({ config }) => { function: 'false', display: ( ), @@ -80,7 +80,7 @@ export const BooleanContent: FC = ({ config }) => { ]; const summaryTableTitle = i18n.translate( - 'xpack.ml.fieldDataCardExpandedRow.booleanContent.summaryTableTitle', + 'xpack.fileUpload.fieldDataCardExpandedRow.booleanContent.summaryTableTitle', { defaultMessage: 'Summary', } @@ -104,7 +104,7 @@ export const BooleanContent: FC = ({ config }) => { diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/date_content.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/date_content.tsx index ad773ba5a3b16..2274d8189b1c0 100644 --- a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/date_content.tsx +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/date_content.tsx @@ -29,15 +29,18 @@ export const DateContent: FC = ({ config }) => { const { earliest, latest } = stats; - const summaryTableTitle = i18n.translate('xpack.ml.fieldDataCard.cardDate.summaryTableTitle', { - defaultMessage: 'Summary', - }); + const summaryTableTitle = i18n.translate( + 'xpack.fileUpload.fieldDataCard.cardDate.summaryTableTitle', + { + defaultMessage: 'Summary', + } + ); const summaryTableItems = [ { function: 'earliest', display: ( ), @@ -47,7 +50,7 @@ export const DateContent: FC = ({ config }) => { function: 'latest', display: ( ), diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/document_stats.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/document_stats.tsx index a22bb93319ac1..b8436eac79eb3 100644 --- a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/document_stats.tsx +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/document_stats.tsx @@ -27,7 +27,7 @@ const metaTableColumns = [ ]; const metaTableTitle = i18n.translate( - 'xpack.ml.fieldDataCardExpandedRow.documentStatsTable.metaTableTitle', + 'xpack.fileUpload.fieldDataCardExpandedRow.documentStatsTable.metaTableTitle', { defaultMessage: 'Documents stats', } @@ -47,7 +47,7 @@ export const DocumentStatsTable: FC = ({ config }) => { function: 'count', display: ( ), @@ -57,7 +57,7 @@ export const DocumentStatsTable: FC = ({ config }) => { function: 'percentage', display: ( ), @@ -67,7 +67,7 @@ export const DocumentStatsTable: FC = ({ config }) => { function: 'distinctValues', display: ( ), diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/number_content.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/number_content.tsx index aa11063b809c5..ec9ffa53a4769 100644 --- a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/number_content.tsx +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/number_content.tsx @@ -52,7 +52,7 @@ export const NumberContent: FC = ({ config }) => { function: 'min', display: ( ), @@ -62,7 +62,7 @@ export const NumberContent: FC = ({ config }) => { function: 'median', display: ( ), @@ -72,7 +72,7 @@ export const NumberContent: FC = ({ config }) => { function: 'max', display: ( ), @@ -93,7 +93,7 @@ export const NumberContent: FC = ({ config }) => { ]; const summaryTableTitle = i18n.translate( - 'xpack.ml.fieldDataCardExpandedRow.numberContent.summaryTableTitle', + 'xpack.fileUpload.fieldDataCardExpandedRow.numberContent.summaryTableTitle', { defaultMessage: 'Summary', } @@ -121,7 +121,7 @@ export const NumberContent: FC = ({ config }) => { @@ -138,7 +138,7 @@ export const NumberContent: FC = ({ config }) => { = ({ config }) => { _source, @@ -48,7 +51,7 @@ export const TextContent: FC = ({ config }) => { copy_to, diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx index 912f930a89e07..dd73fdb5ea4c9 100644 --- a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx @@ -81,13 +81,13 @@ export const getLegendText = ( maxChartColumns = MAX_CHART_COLUMNS ): LegendText => { if (chartData.type === 'unsupported') { - return i18n.translate('xpack.ml.dataGridChart.histogramNotAvailable', { + return i18n.translate('xpack.fileUpload.dataGridChart.histogramNotAvailable', { defaultMessage: 'Chart not supported.', }); } if (chartData.data.length === 0) { - return i18n.translate('xpack.ml.dataGridChart.notEnoughData', { + return i18n.translate('xpack.fileUpload.dataGridChart.notEnoughData', { defaultMessage: `0 documents contain field.`, }); } @@ -106,14 +106,14 @@ export const getLegendText = ( } if (isOrdinalChartData(chartData) && chartData.cardinality <= maxChartColumns) { - return i18n.translate('xpack.ml.dataGridChart.singleCategoryLegend', { + return i18n.translate('xpack.fileUpload.dataGridChart.singleCategoryLegend', { defaultMessage: `{cardinality, plural, one {# category} other {# categories}}`, values: { cardinality: chartData.cardinality }, }); } if (isOrdinalChartData(chartData) && chartData.cardinality > maxChartColumns) { - return i18n.translate('xpack.ml.dataGridChart.topCategoriesLegend', { + return i18n.translate('xpack.fileUpload.dataGridChart.topCategoriesLegend', { defaultMessage: `top {maxChartColumns} of {cardinality} categories`, values: { cardinality: chartData.cardinality, maxChartColumns }, }); diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart.tsx index 8b5e5ec65bae4..3394d7de95a63 100644 --- a/x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart.tsx +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart.tsx @@ -57,9 +57,12 @@ export const MetricDistributionChart: FC = ({ // This value is shown to label the y axis values in the tooltip. // Ideally we wouldn't show these values at all in the tooltip, // but this is not yet possible with Elastic charts. - const seriesName = i18n.translate('xpack.ml.fieldDataCard.metricDistributionChart.seriesName', { - defaultMessage: 'distribution', - }); + const seriesName = i18n.translate( + 'xpack.fileUpload.fieldDataCard.metricDistributionChart.seriesName', + { + defaultMessage: 'distribution', + } + ); const theme = useDataVizChartTheme(); diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart_tooltip_header.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart_tooltip_header.tsx index 5038978e9388c..2259e31f9e370 100644 --- a/x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart_tooltip_header.tsx +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart_tooltip_header.tsx @@ -31,7 +31,7 @@ export const MetricDistributionChartTooltipHeader: FC = ({
{chartPoint.dataMax > chartPoint.dataMin ? ( = ({ /> ) : ( ({ onClick={() => toggleExpandAll(!expandAll)} aria-label={ !expandAll - ? i18n.translate('xpack.ml.datavisualizer.dataGrid.expandDetailsForAllAriaLabel', { - defaultMessage: 'Expand details for all fields', - }) - : i18n.translate('xpack.ml.datavisualizer.dataGrid.collapseDetailsForAllAriaLabel', { - defaultMessage: 'Collapse details for all fields', - }) + ? i18n.translate( + 'xpack.fileUpload.datavisualizer.dataGrid.expandDetailsForAllAriaLabel', + { + defaultMessage: 'Expand details for all fields', + } + ) + : i18n.translate( + 'xpack.fileUpload.datavisualizer.dataGrid.collapseDetailsForAllAriaLabel', + { + defaultMessage: 'Collapse details for all fields', + } + ) } iconType={expandAll ? 'arrowUp' : 'arrowDown'} /> @@ -125,11 +131,11 @@ export const DataVisualizerTable = ({ onClick={() => toggleDetails(item)} aria-label={ expandedRowItemIds.includes(item.fieldName) - ? i18n.translate('xpack.ml.datavisualizer.dataGrid.rowCollapse', { + ? i18n.translate('xpack.fileUpload.datavisualizer.dataGrid.rowCollapse', { defaultMessage: 'Hide details for {fieldName}', values: { fieldName: item.fieldName }, }) - : i18n.translate('xpack.ml.datavisualizer.dataGrid.rowExpand', { + : i18n.translate('xpack.fileUpload.datavisualizer.dataGrid.rowExpand', { defaultMessage: 'Show details for {fieldName}', values: { fieldName: item.fieldName }, }) @@ -145,7 +151,7 @@ export const DataVisualizerTable = ({ expanderColumn, { field: 'type', - name: i18n.translate('xpack.ml.datavisualizer.dataGrid.typeColumnName', { + name: i18n.translate('xpack.fileUpload.datavisualizer.dataGrid.typeColumnName', { defaultMessage: 'Type', }), render: (fieldType: MlJobFieldType) => { @@ -158,7 +164,7 @@ export const DataVisualizerTable = ({ }, { field: 'fieldName', - name: i18n.translate('xpack.ml.datavisualizer.dataGrid.nameColumnName', { + name: i18n.translate('xpack.fileUpload.datavisualizer.dataGrid.nameColumnName', { defaultMessage: 'Name', }), sortable: true, @@ -173,7 +179,7 @@ export const DataVisualizerTable = ({ }, { field: 'docCount', - name: i18n.translate('xpack.ml.datavisualizer.dataGrid.documentsCountColumnName', { + name: i18n.translate('xpack.fileUpload.datavisualizer.dataGrid.documentsCountColumnName', { defaultMessage: 'Documents (%)', }), render: (value: number | undefined, item: DataVisualizerTableItem) => ( @@ -185,7 +191,7 @@ export const DataVisualizerTable = ({ }, { field: 'stats.cardinality', - name: i18n.translate('xpack.ml.datavisualizer.dataGrid.distinctValuesColumnName', { + name: i18n.translate('xpack.fileUpload.datavisualizer.dataGrid.distinctValuesColumnName', { defaultMessage: 'Distinct values', }), render: (cardinality?: number) => , @@ -197,7 +203,7 @@ export const DataVisualizerTable = ({ name: (
- {i18n.translate('xpack.ml.datavisualizer.dataGrid.distributionsColumnName', { + {i18n.translate('xpack.fileUpload.datavisualizer.dataGrid.distributionsColumnName', { defaultMessage: 'Distributions', })} ({ iconType={showDistributions ? 'eye' : 'eyeClosed'} onClick={() => toggleShowDistribution()} aria-label={i18n.translate( - 'xpack.ml.datavisualizer.dataGrid.showDistributionsAriaLabel', + 'xpack.fileUpload.datavisualizer.dataGrid.showDistributionsAriaLabel', { defaultMessage: 'Show distributions', } diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/hooks/use_color_range.ts b/x-pack/plugins/file_upload/public/application/components/stats_table/hooks/use_color_range.ts index 8376bb9281153..bcc4a95d72006 100644 --- a/x-pack/plugins/file_upload/public/application/components/stats_table/hooks/use_color_range.ts +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/hooks/use_color_range.ts @@ -51,19 +51,19 @@ export enum COLOR_RANGE_SCALE { export const colorRangeScaleOptions = [ { value: COLOR_RANGE_SCALE.LINEAR, - text: i18n.translate('xpack.ml.components.colorRangeLegend.linearScaleLabel', { + text: i18n.translate('xpack.fileUpload.components.colorRangeLegend.linearScaleLabel', { defaultMessage: 'Linear', }), }, { value: COLOR_RANGE_SCALE.INFLUENCER, - text: i18n.translate('xpack.ml.components.colorRangeLegend.influencerScaleLabel', { + text: i18n.translate('xpack.fileUpload.components.colorRangeLegend.influencerScaleLabel', { defaultMessage: 'Influencer custom scale', }), }, { value: COLOR_RANGE_SCALE.SQRT, - text: i18n.translate('xpack.ml.components.colorRangeLegend.sqrtScaleLabel', { + text: i18n.translate('xpack.fileUpload.components.colorRangeLegend.sqrtScaleLabel', { defaultMessage: 'Sqrt', }), }, @@ -83,33 +83,36 @@ export enum COLOR_RANGE { export const colorRangeOptions = [ { value: COLOR_RANGE.BLUE, - text: i18n.translate('xpack.ml.components.colorRangeLegend.blueColorRangeLabel', { + text: i18n.translate('xpack.fileUpload.components.colorRangeLegend.blueColorRangeLabel', { defaultMessage: 'Blue', }), }, { value: COLOR_RANGE.RED, - text: i18n.translate('xpack.ml.components.colorRangeLegend.redColorRangeLabel', { + text: i18n.translate('xpack.fileUpload.components.colorRangeLegend.redColorRangeLabel', { defaultMessage: 'Red', }), }, { value: COLOR_RANGE.RED_GREEN, - text: i18n.translate('xpack.ml.components.colorRangeLegend.redGreenColorRangeLabel', { + text: i18n.translate('xpack.fileUpload.components.colorRangeLegend.redGreenColorRangeLabel', { defaultMessage: 'Red - Green', }), }, { value: COLOR_RANGE.GREEN_RED, - text: i18n.translate('xpack.ml.components.colorRangeLegend.greenRedColorRangeLabel', { + text: i18n.translate('xpack.fileUpload.components.colorRangeLegend.greenRedColorRangeLabel', { defaultMessage: 'Green - Red', }), }, { value: COLOR_RANGE.YELLOW_GREEN_BLUE, - text: i18n.translate('xpack.ml.components.colorRangeLegend.yellowGreenBlueColorRangeLabel', { - defaultMessage: 'Yellow - Green - Blue', - }), + text: i18n.translate( + 'xpack.fileUpload.components.colorRangeLegend.yellowGreenBlueColorRangeLabel', + { + defaultMessage: 'Yellow - Green - Blue', + } + ), }, ]; diff --git a/x-pack/plugins/file_upload/public/application/components/top_values/top_values.tsx b/x-pack/plugins/file_upload/public/application/components/top_values/top_values.tsx index 8f179f60df7f6..8b98dc250e125 100644 --- a/x-pack/plugins/file_upload/public/application/components/top_values/top_values.tsx +++ b/x-pack/plugins/file_upload/public/application/components/top_values/top_values.tsx @@ -51,7 +51,10 @@ export const TopValues: FC = ({ stats, fieldFormat, barColor, compressed return ( - +
@@ -97,7 +100,7 @@ export const TopValues: FC = ({ stats, fieldFormat, barColor, compressed Date: Thu, 8 Apr 2021 15:47:58 +0100 Subject: [PATCH 07/37] fxing table controls --- x-pack/plugins/file_upload/common/types.ts | 26 ++++++++---- .../fields_stats_grid/fields_stats_grid.tsx | 13 +++--- .../data_visualizer_stats_table.tsx | 14 ++----- .../stats_table/use_table_settings.ts | 41 +++---------------- 4 files changed, 34 insertions(+), 60 deletions(-) diff --git a/x-pack/plugins/file_upload/common/types.ts b/x-pack/plugins/file_upload/common/types.ts index 7ecb2f5a5c732..08072ea45e048 100644 --- a/x-pack/plugins/file_upload/common/types.ts +++ b/x-pack/plugins/file_upload/common/types.ts @@ -131,16 +131,26 @@ export interface IngestPipeline { export type MlJobFieldType = typeof ML_JOB_FIELD_TYPES[keyof typeof ML_JOB_FIELD_TYPES]; -interface ListingPageUrlState { +// interface ListingPageUrlState { +// pageSize: number; +// pageIndex: number; +// sortField: string; +// sortDirection: string; +// queryText?: string; +// } + +// export interface DataVisualizerFileBasedAppState extends Omit { +// visibleFieldTypes?: string[]; +// visibleFieldNames?: string[]; +// showDistributions?: boolean; +// } + +export interface DataVisualizeTableState { pageSize: number; pageIndex: number; sortField: string; sortDirection: string; - queryText?: string; -} - -export interface DataVisualizerFileBasedAppState extends Omit { - visibleFieldTypes?: string[]; - visibleFieldNames?: string[]; - showDistributions?: boolean; + visibleFieldTypes: string[]; + visibleFieldNames: string[]; + showDistributions: boolean; } diff --git a/x-pack/plugins/file_upload/public/application/components/fields_stats_grid/fields_stats_grid.tsx b/x-pack/plugins/file_upload/public/application/components/fields_stats_grid/fields_stats_grid.tsx index 534f32bcf1fa5..01953debb8fe9 100644 --- a/x-pack/plugins/file_upload/public/application/components/fields_stats_grid/fields_stats_grid.tsx +++ b/x-pack/plugins/file_upload/public/application/components/fields_stats_grid/fields_stats_grid.tsx @@ -5,9 +5,9 @@ * 2.0. */ -import React, { useMemo, FC } from 'react'; +import React, { useMemo, FC, useState } from 'react'; import { EuiFlexGroup, EuiSpacer } from '@elastic/eui'; -import type { FindFileStructureResponse } from '../../../../common'; +import type { FindFileStructureResponse, DataVisualizeTableState } from '../../../../common'; import { DataVisualizerTable, ItemIdToExpandedRowMap } from '../stats_table'; import type { FileBasedFieldVisConfig } from '../stats_table/types/field_vis_config'; import { FileBasedDataVisualizerExpandedRow } from '../expanded_row'; @@ -21,7 +21,8 @@ import { MetricFieldsCount, TotalFieldsCount } from '../stats_table/components/f interface Props { results: FindFileStructureResponse; } -export const getDefaultDataVisualizerListState = () => ({ + +export const getDefaultDataVisualizerListState = (): DataVisualizeTableState => ({ pageIndex: 0, pageSize: 10, sortField: 'fieldName', @@ -47,8 +48,10 @@ function getItemIdToExpandedRowMap( export const FieldsStatsGrid: FC = ({ results }) => { const restorableDefaults = getDefaultDataVisualizerListState(); - const dataVisualizerListState = restorableDefaults; - const setDataVisualizerListState = (a: any) => {}; + const [dataVisualizerListState, setDataVisualizerListState] = useState( + restorableDefaults + ); + const visibleFieldTypes = dataVisualizerListState.visibleFieldTypes ?? restorableDefaults.visibleFieldTypes; const setVisibleFieldTypes = (values: string[]) => { diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/data_visualizer_stats_table.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/data_visualizer_stats_table.tsx index 8ee73ee5f4a23..39e83a659c1c1 100644 --- a/x-pack/plugins/file_upload/public/application/components/stats_table/data_visualizer_stats_table.tsx +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/data_visualizer_stats_table.tsx @@ -21,11 +21,7 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { EuiTableComputedColumnType } from '@elastic/eui/src/components/basic_table/table_types'; -import { - ML_JOB_FIELD_TYPES, - MlJobFieldType, - DataVisualizerFileBasedAppState, -} from '../../../../common'; +import { ML_JOB_FIELD_TYPES, MlJobFieldType, DataVisualizeTableState } from '../../../../common'; import { FieldTypeIcon } from '../field_type_icon'; import { DocumentStat } from './components/field_data_row/document_stats'; import { DistinctValues } from './components/field_data_row/distinct_values'; @@ -43,17 +39,13 @@ import { BooleanContentPreview } from './components/field_data_row'; const FIELD_NAME = 'fieldName'; -type DataVisualizerIndexBasedAppState = any; // REMOVE - export type ItemIdToExpandedRowMap = Record; type DataVisualizerTableItem = FieldVisConfig | FileBasedFieldVisConfig; interface DataVisualizerTableProps { items: T[]; - pageState: DataVisualizerIndexBasedAppState | DataVisualizerFileBasedAppState; - updatePageState: ( - update: Partial - ) => void; + pageState: DataVisualizeTableState; + updatePageState: (update: DataVisualizeTableState) => void; getItemIdToExpandedRowMap: (itemIds: string[], items: T[]) => ItemIdToExpandedRowMap; extendedColumns?: Array>; } diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/use_table_settings.ts b/x-pack/plugins/file_upload/public/application/components/stats_table/use_table_settings.ts index e29c5169394a0..9780cbe654b7f 100644 --- a/x-pack/plugins/file_upload/public/application/components/stats_table/use_table_settings.ts +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/use_table_settings.ts @@ -7,40 +7,11 @@ import { Direction, EuiBasicTableProps, Pagination, PropertySort } from '@elastic/eui'; import { useCallback, useMemo } from 'react'; -// import { ListingPageUrlState } from '../../../../../../../common/types/common'; -import { DataVisualizerFileBasedAppState } from '../../../../common'; -type DataVisualizerIndexBasedAppState = any; // REMOVE - -export interface ListingPageUrlState { - pageSize: number; - pageIndex: number; - sortField: string; - sortDirection: string; - queryText?: string; -} +import { DataVisualizeTableState } from '../../../../common'; const PAGE_SIZE_OPTIONS = [10, 25, 50]; -// Copying from EUI EuiBasicTable types as type is not correctly picked up for table's onChange -// Can be removed when https://github.com/elastic/eui/issues/4011 is addressed in EUI -export interface Criteria { - page?: { - index: number; - size: number; - }; - sort?: { - field: keyof T; - direction: Direction; - }; -} -export interface CriteriaWithPagination extends Criteria { - page: { - index: number; - size: number; - }; -} - interface UseTableSettingsReturnValue { onTableChange: EuiBasicTableProps['onChange']; pagination: Pagination; @@ -49,17 +20,15 @@ interface UseTableSettingsReturnValue { export function useTableSettings( items: TypeOfItem[], - pageState: - | ListingPageUrlState - | DataVisualizerIndexBasedAppState - | DataVisualizerFileBasedAppState, - updatePageState: (update: Partial) => void + pageState: DataVisualizeTableState, + updatePageState: (update: DataVisualizeTableState) => void ): UseTableSettingsReturnValue { const { pageIndex, pageSize, sortField, sortDirection } = pageState; const onTableChange: EuiBasicTableProps['onChange'] = useCallback( - ({ page, sort }: CriteriaWithPagination) => { + ({ page, sort }) => { const result = { + ...pageState, pageIndex: page?.index ?? pageState.pageIndex, pageSize: page?.size ?? pageState.pageSize, sortField: (sort?.field as string) ?? pageState.sortField, From 56e73f554b88cb38bcaeb894aaff4efaa85af70b Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Fri, 9 Apr 2021 09:56:48 +0100 Subject: [PATCH 08/37] fixing types and disabling geo point test --- x-pack/plugins/file_upload/common/types.ts | 26 ++++++++----------- .../fields_stats_grid/fields_stats_grid.tsx | 6 ++--- .../file_error_callouts.tsx | 17 +++--------- .../data_visualizer_stats_table.tsx | 10 +++---- .../stats_table/use_table_settings.ts | 6 ++--- 5 files changed, 25 insertions(+), 40 deletions(-) diff --git a/x-pack/plugins/file_upload/common/types.ts b/x-pack/plugins/file_upload/common/types.ts index 08072ea45e048..3e60eff839f0d 100644 --- a/x-pack/plugins/file_upload/common/types.ts +++ b/x-pack/plugins/file_upload/common/types.ts @@ -76,6 +76,16 @@ export interface FindFileStructureResponse { should_trim_fields?: boolean; } +export interface FindFileStructureErrorResponse { + body: { + statusCode: number; + error: string; + message: string; + attributes?: any; + }; + name: string; +} + export type InputData = any[]; export interface ImportResponse { @@ -131,21 +141,7 @@ export interface IngestPipeline { export type MlJobFieldType = typeof ML_JOB_FIELD_TYPES[keyof typeof ML_JOB_FIELD_TYPES]; -// interface ListingPageUrlState { -// pageSize: number; -// pageIndex: number; -// sortField: string; -// sortDirection: string; -// queryText?: string; -// } - -// export interface DataVisualizerFileBasedAppState extends Omit { -// visibleFieldTypes?: string[]; -// visibleFieldNames?: string[]; -// showDistributions?: boolean; -// } - -export interface DataVisualizeTableState { +export interface DataVisualizerTableState { pageSize: number; pageIndex: number; sortField: string; diff --git a/x-pack/plugins/file_upload/public/application/components/fields_stats_grid/fields_stats_grid.tsx b/x-pack/plugins/file_upload/public/application/components/fields_stats_grid/fields_stats_grid.tsx index 01953debb8fe9..533ec2d2d43cf 100644 --- a/x-pack/plugins/file_upload/public/application/components/fields_stats_grid/fields_stats_grid.tsx +++ b/x-pack/plugins/file_upload/public/application/components/fields_stats_grid/fields_stats_grid.tsx @@ -7,7 +7,7 @@ import React, { useMemo, FC, useState } from 'react'; import { EuiFlexGroup, EuiSpacer } from '@elastic/eui'; -import type { FindFileStructureResponse, DataVisualizeTableState } from '../../../../common'; +import type { FindFileStructureResponse, DataVisualizerTableState } from '../../../../common'; import { DataVisualizerTable, ItemIdToExpandedRowMap } from '../stats_table'; import type { FileBasedFieldVisConfig } from '../stats_table/types/field_vis_config'; import { FileBasedDataVisualizerExpandedRow } from '../expanded_row'; @@ -22,7 +22,7 @@ interface Props { results: FindFileStructureResponse; } -export const getDefaultDataVisualizerListState = (): DataVisualizeTableState => ({ +export const getDefaultDataVisualizerListState = (): DataVisualizerTableState => ({ pageIndex: 0, pageSize: 10, sortField: 'fieldName', @@ -48,7 +48,7 @@ function getItemIdToExpandedRowMap( export const FieldsStatsGrid: FC = ({ results }) => { const restorableDefaults = getDefaultDataVisualizerListState(); - const [dataVisualizerListState, setDataVisualizerListState] = useState( + const [dataVisualizerListState, setDataVisualizerListState] = useState( restorableDefaults ); diff --git a/x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/file_error_callouts.tsx b/x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/file_error_callouts.tsx index 21923a0b09980..c77805a3c0c60 100644 --- a/x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/file_error_callouts.tsx +++ b/x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/file_error_callouts.tsx @@ -11,18 +11,7 @@ import React, { FC } from 'react'; import { EuiCallOut, EuiSpacer, EuiButtonEmpty, EuiHorizontalRule } from '@elastic/eui'; import numeral from '@elastic/numeral'; -import { FILE_SIZE_DISPLAY_FORMAT } from '../../../../common'; - -export interface ErrorResponse { - // TODO MOVE THIS OR REPLACE WITH COMMON RESPONSE - body: { - statusCode: number; - error: string; - message: string; - attributes?: any; - }; - name: string; -} +import { FILE_SIZE_DISPLAY_FORMAT, FindFileStructureErrorResponse } from '../../../../common'; interface FileTooLargeProps { fileSize: number; @@ -86,7 +75,7 @@ export const FileTooLarge: FC = ({ fileSize, maxFileSize }) = }; interface FileCouldNotBeReadProps { - error: ErrorResponse; + error: FindFileStructureErrorResponse; loaded: boolean; showEditFlyout(): void; } @@ -142,7 +131,7 @@ export const FileCouldNotBeRead: FC = ({ ); }; -export const Explanation: FC<{ error: ErrorResponse }> = ({ error }) => { +export const Explanation: FC<{ error: FindFileStructureErrorResponse }> = ({ error }) => { if (!error?.body?.attributes?.body?.error?.suppressed?.length) { return null; } diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/data_visualizer_stats_table.tsx b/x-pack/plugins/file_upload/public/application/components/stats_table/data_visualizer_stats_table.tsx index 39e83a659c1c1..ef4c0fd5a3522 100644 --- a/x-pack/plugins/file_upload/public/application/components/stats_table/data_visualizer_stats_table.tsx +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/data_visualizer_stats_table.tsx @@ -21,7 +21,7 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { EuiTableComputedColumnType } from '@elastic/eui/src/components/basic_table/table_types'; -import { ML_JOB_FIELD_TYPES, MlJobFieldType, DataVisualizeTableState } from '../../../../common'; +import { ML_JOB_FIELD_TYPES, MlJobFieldType, DataVisualizerTableState } from '../../../../common'; import { FieldTypeIcon } from '../field_type_icon'; import { DocumentStat } from './components/field_data_row/document_stats'; import { DistinctValues } from './components/field_data_row/distinct_values'; @@ -44,8 +44,8 @@ export type ItemIdToExpandedRowMap = Record; type DataVisualizerTableItem = FieldVisConfig | FileBasedFieldVisConfig; interface DataVisualizerTableProps { items: T[]; - pageState: DataVisualizeTableState; - updatePageState: (update: DataVisualizeTableState) => void; + pageState: DataVisualizerTableState; + updatePageState: (update: DataVisualizerTableState) => void; getItemIdToExpandedRowMap: (itemIds: string[], items: T[]) => ItemIdToExpandedRowMap; extendedColumns?: Array>; } @@ -240,7 +240,7 @@ export const DataVisualizerTable = ({ }, ]; return extendedColumns ? [...baseColumns, ...extendedColumns] : baseColumns; - // eslint-disable-next-line + // eslint-disable-next-line react-hooks/exhaustive-deps }, [expandAll, showDistributions, updatePageState, extendedColumns]); const itemIdToExpandedRowMap = useMemo(() => { @@ -249,7 +249,7 @@ export const DataVisualizerTable = ({ itemIds = items.map((i) => i[FIELD_NAME]).filter((f) => f !== undefined) as string[]; } return getItemIdToExpandedRowMap(itemIds, items); - // eslint-disable-next-line + // eslint-disable-next-line react-hooks/exhaustive-deps }, [expandAll, items, expandedRowItemIds]); return ( diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/use_table_settings.ts b/x-pack/plugins/file_upload/public/application/components/stats_table/use_table_settings.ts index 9780cbe654b7f..e2ff18a8001aa 100644 --- a/x-pack/plugins/file_upload/public/application/components/stats_table/use_table_settings.ts +++ b/x-pack/plugins/file_upload/public/application/components/stats_table/use_table_settings.ts @@ -8,7 +8,7 @@ import { Direction, EuiBasicTableProps, Pagination, PropertySort } from '@elastic/eui'; import { useCallback, useMemo } from 'react'; -import { DataVisualizeTableState } from '../../../../common'; +import { DataVisualizerTableState } from '../../../../common'; const PAGE_SIZE_OPTIONS = [10, 25, 50]; @@ -20,8 +20,8 @@ interface UseTableSettingsReturnValue { export function useTableSettings( items: TypeOfItem[], - pageState: DataVisualizeTableState, - updatePageState: (update: DataVisualizeTableState) => void + pageState: DataVisualizerTableState, + updatePageState: (update: DataVisualizerTableState) => void ): UseTableSettingsReturnValue { const { pageIndex, pageSize, sortField, sortDirection } = pageState; From d874090dc0787a17caab14221c1d3670ffffb8fa Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Fri, 9 Apr 2021 15:15:30 +0100 Subject: [PATCH 09/37] actually disabling geo point test --- .../data_visualizer/file_data_visualizer.ts | 82 +++++++++---------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/x-pack/test/functional/apps/ml/data_visualizer/file_data_visualizer.ts b/x-pack/test/functional/apps/ml/data_visualizer/file_data_visualizer.ts index 65bc68db25aa1..7a489fa2e80c1 100644 --- a/x-pack/test/functional/apps/ml/data_visualizer/file_data_visualizer.ts +++ b/x-pack/test/functional/apps/ml/data_visualizer/file_data_visualizer.ts @@ -113,47 +113,47 @@ export default function ({ getService }: FtrProviderContext) { fieldNameFiltersResultCount: 1, }, }, - { - suiteSuffix: 'with a file containing geo field', - filePath: path.join(__dirname, 'files_to_import', 'geo_file.csv'), - indexName: 'user-import_2', - createIndexPattern: false, - fieldTypeFilters: [ML_JOB_FIELD_TYPES.GEO_POINT], - fieldNameFilters: ['Coordinates'], - expected: { - results: { - title: 'geo_file.csv', - numberOfFields: 3, - }, - metricFields: [], - nonMetricFields: [ - { - fieldName: 'Context', - type: ML_JOB_FIELD_TYPES.UNKNOWN, - docCountFormatted: '0 (0%)', - exampleCount: 0, - }, - { - fieldName: 'Coordinates', - type: ML_JOB_FIELD_TYPES.GEO_POINT, - docCountFormatted: '13 (100%)', - exampleCount: 7, - }, - { - fieldName: 'Location', - type: ML_JOB_FIELD_TYPES.KEYWORD, - docCountFormatted: '13 (100%)', - exampleCount: 7, - }, - ], - visibleMetricFieldsCount: 0, - totalMetricFieldsCount: 0, - populatedFieldsCount: 3, - totalFieldsCount: 3, - fieldTypeFiltersResultCount: 1, - fieldNameFiltersResultCount: 1, - }, - }, + // { + // suiteSuffix: 'with a file containing geo field', + // filePath: path.join(__dirname, 'files_to_import', 'geo_file.csv'), + // indexName: 'user-import_2', + // createIndexPattern: false, + // fieldTypeFilters: [ML_JOB_FIELD_TYPES.GEO_POINT], + // fieldNameFilters: ['Coordinates'], + // expected: { + // results: { + // title: 'geo_file.csv', + // numberOfFields: 3, + // }, + // metricFields: [], + // nonMetricFields: [ + // { + // fieldName: 'Context', + // type: ML_JOB_FIELD_TYPES.UNKNOWN, + // docCountFormatted: '0 (0%)', + // exampleCount: 0, + // }, + // { + // fieldName: 'Coordinates', + // type: ML_JOB_FIELD_TYPES.GEO_POINT, + // docCountFormatted: '13 (100%)', + // exampleCount: 7, + // }, + // { + // fieldName: 'Location', + // type: ML_JOB_FIELD_TYPES.KEYWORD, + // docCountFormatted: '13 (100%)', + // exampleCount: 7, + // }, + // ], + // visibleMetricFieldsCount: 0, + // totalMetricFieldsCount: 0, + // populatedFieldsCount: 3, + // totalFieldsCount: 3, + // fieldTypeFiltersResultCount: 1, + // fieldNameFiltersResultCount: 1, + // }, + // }, ]; const testDataListNegative = [ From 0aa4952e69a2b76e1b12d0c6eaef0c329e142a0e Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Mon, 12 Apr 2021 12:05:51 +0100 Subject: [PATCH 10/37] making endpoints internal --- x-pack/plugins/file_upload/public/api/index.ts | 6 +++--- .../file_upload/public/importer/importer.ts | 2 +- x-pack/plugins/file_upload/server/routes.ts | 16 ++++++++-------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/x-pack/plugins/file_upload/public/api/index.ts b/x-pack/plugins/file_upload/public/api/index.ts index 67e1cb97fd774..141e8372fc7d1 100644 --- a/x-pack/plugins/file_upload/public/api/index.ts +++ b/x-pack/plugins/file_upload/public/api/index.ts @@ -67,7 +67,7 @@ export async function analyzeFile( const body = JSON.stringify(file); const fileUploadModules = await lazyLoadFileUploadModules(); return await fileUploadModules.getHttp().fetch({ - path: `/api/file_upload/analyze_file`, + path: `/internal/file_upload/analyze_file`, method: 'POST', body, query: params, @@ -81,7 +81,7 @@ export async function checkIndexExists( const body = JSON.stringify({ index }); const fileUploadModules = await lazyLoadFileUploadModules(); return await fileUploadModules.getHttp().fetch({ - path: `/api/file_upload/index_exists`, + path: `/internal/file_upload/index_exists`, method: 'POST', body, query: params, @@ -101,7 +101,7 @@ export async function getTimeFieldRange({ const fileUploadModules = await lazyLoadFileUploadModules(); return await fileUploadModules.getHttp().fetch({ - path: `/api/file_upload/time_field_range`, + path: `/internal/file_upload/time_field_range`, method: 'POST', body, }); diff --git a/x-pack/plugins/file_upload/public/importer/importer.ts b/x-pack/plugins/file_upload/public/importer/importer.ts index 4a87d67d0616b..49324c8f360ef 100644 --- a/x-pack/plugins/file_upload/public/importer/importer.ts +++ b/x-pack/plugins/file_upload/public/importer/importer.ts @@ -260,7 +260,7 @@ export function callImportRoute({ }); return getHttp().fetch({ - path: `/api/file_upload/import`, + path: `/internal/file_upload/import`, method: 'POST', query, body, diff --git a/x-pack/plugins/file_upload/server/routes.ts b/x-pack/plugins/file_upload/server/routes.ts index 43ef741698298..d2e696123c0e1 100644 --- a/x-pack/plugins/file_upload/server/routes.ts +++ b/x-pack/plugins/file_upload/server/routes.ts @@ -93,7 +93,7 @@ export function fileUploadRoutes(coreSetup: CoreSetup, logge /** * @apiGroup FileDataVisualizer * - * @api {post} /api/file_upload/analyze_file Analyze file data + * @api {post} /internal/file_upload/analyze_file Analyze file data * @apiName AnalyzeFile * @apiDescription Performs analysis of the file data. * @@ -101,7 +101,7 @@ export function fileUploadRoutes(coreSetup: CoreSetup, logge */ router.post( { - path: '/api/file_upload/analyze_file', + path: '/internal/file_upload/analyze_file', validate: { body: schema.any(), query: analyzeFileQuerySchema, @@ -131,7 +131,7 @@ export function fileUploadRoutes(coreSetup: CoreSetup, logge /** * @apiGroup FileDataVisualizer * - * @api {post} /api/file_upload/import Import file data + * @api {post} /internal/file_upload/import Import file data * @apiName ImportFile * @apiDescription Imports file data into elasticsearch index. * @@ -140,7 +140,7 @@ export function fileUploadRoutes(coreSetup: CoreSetup, logge */ router.post( { - path: '/api/file_upload/import', + path: '/internal/file_upload/import', validate: { query: importFileQuerySchema, body: importFileBodySchema, @@ -185,12 +185,12 @@ export function fileUploadRoutes(coreSetup: CoreSetup, logge /** * @apiGroup FileDataVisualizer * - * @api {post} /api/file_upload/index_exists ES Field caps wrapper checks if index exists + * @api {post} /internal/file_upload/index_exists ES Field caps wrapper checks if index exists * @apiName IndexExists */ router.post( { - path: '/api/file_upload/index_exists', + path: '/internal/file_upload/index_exists', validate: { body: schema.object({ index: schema.string() }), }, @@ -223,7 +223,7 @@ export function fileUploadRoutes(coreSetup: CoreSetup, logge /** * @apiGroup FileDataVisualizer * - * @api {post} /api/file_upload/time_field_range Get time field range + * @api {post} /internal/file_upload/time_field_range Get time field range * @apiName GetTimeFieldRange * @apiDescription Returns the time range for the given index and query using the specified time range. * @@ -234,7 +234,7 @@ export function fileUploadRoutes(coreSetup: CoreSetup, logge */ router.post( { - path: '/api/file_upload/time_field_range', + path: '/internal/file_upload/time_field_range', validate: { body: schema.object({ /** Index or indexes for which to return the time range. */ From 6842e988b7926e019134595b5b08c7dd5d9c9b06 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Tue, 13 Apr 2021 13:36:33 +0100 Subject: [PATCH 11/37] moving UI code to separate plugin --- .../file_data_visualizer/common/constants.ts | 31 ++++ .../file_data_visualizer/common/index.ts | 9 ++ .../file_data_visualizer/common/types.ts | 152 ++++++++++++++++++ .../file_data_visualizer/jest.config.js | 12 ++ .../plugins/file_data_visualizer/kibana.json | 27 ++++ .../file_data_visualizer/public/api/index.ts | 30 ++++ .../public/application/_index.scss | 0 .../public/application/components/_index.scss | 0 .../components/about_panel/_about_panel.scss | 0 .../components/about_panel/_index.scss | 0 .../components/about_panel/about_panel.tsx | 0 .../components/about_panel/index.ts | 0 .../about_panel/welcome_content.tsx | 2 +- .../analysis_summary/_analysis_summary.scss | 0 .../components/analysis_summary/_index.scss | 0 .../analysis_summary/analysis_summary.tsx | 0 .../components/analysis_summary/index.ts | 0 .../components/bottom_bar/bottom_bar.tsx | 0 .../components/bottom_bar/index.ts | 0 .../combined_fields/combined_field_label.tsx | 0 .../combined_fields/combined_fields_form.tsx | 0 .../combined_fields_read_only_form.tsx | 0 .../components/combined_fields/geo_point.tsx | 0 .../components/combined_fields/index.ts | 0 .../components/combined_fields/types.ts | 0 .../components/combined_fields/utils.test.ts | 0 .../components/combined_fields/utils.ts | 0 .../__snapshots__/overrides.test.js.snap | 0 .../components/edit_flyout/_edit_flyout.scss | 0 .../components/edit_flyout/_index.scss | 0 .../components/edit_flyout/edit_flyout.js | 0 .../components/edit_flyout/index.js | 0 .../components/edit_flyout/options/index.js | 0 .../edit_flyout/options/option_lists.js | 0 .../components/edit_flyout/options/options.js | 0 .../components/edit_flyout/overrides.js | 0 .../components/edit_flyout/overrides.test.js | 0 .../edit_flyout/overrides_validation.js | 0 .../examples_list/examples_list.tsx | 0 .../components/examples_list/index.ts | 0 .../expanded_row/file_based_expanded_row.tsx | 0 .../geo_point_content/format_utils.ts | 0 .../geo_point_content/geo_point_content.tsx | 0 .../expanded_row/geo_point_content/index.ts | 0 .../components/expanded_row/index.ts | 0 .../_experimental_badge.scss | 0 .../components/experimental_badge/_index.scss | 0 .../experimental_badge/experimental_badge.tsx | 0 .../components/experimental_badge/index.ts | 0 .../explanation_flyout/explanation_flyout.tsx | 0 .../components/explanation_flyout/index.ts | 0 .../components/field_data_row/index.ts | 0 .../field_data_row/number_content_preview.tsx | 0 .../field_names_filter/field_names_filter.tsx | 0 .../components/field_names_filter/index.ts | 0 .../field_type_icon.test.tsx.snap | 0 .../field_type_icon/field_type_icon.test.tsx | 0 .../field_type_icon/field_type_icon.tsx | 0 .../components/field_type_icon/index.ts | 0 .../field_types_filter/field_types_filter.tsx | 0 .../components/field_types_filter/index.ts | 0 .../fields_stats/_field_stats_card.scss | 0 .../fields_stats/_fields_stats.scss | 0 .../fields_stats_grid/create_fields.ts | 0 .../fields_stats_grid/fields_stats_grid.tsx | 0 .../fields_stats_grid/filter_fields.ts | 0 .../fields_stats_grid/get_field_names.ts | 0 .../components/fields_stats_grid/index.ts | 0 .../file_contents/_file_contents.scss | 0 .../components/file_contents/_index.scss | 0 .../file_contents/file_contents.tsx | 0 .../components/file_contents/index.ts | 0 .../_file_datavisualizer_view.scss | 0 .../file_datavisualizer_view/_index.scss | 0 .../file_datavisualizer_view/constants.ts | 0 .../file_datavisualizer_view.js | 8 +- .../file_error_callouts.tsx | 0 .../file_datavisualizer_view/index.js | 0 .../filebeat_config_flyout/filebeat_config.ts | 0 .../filebeat_config_flyout.tsx | 0 .../filebeat_config_flyout/index.ts | 0 .../components/import_errors/errors.tsx | 0 .../components/import_errors/index.ts | 0 .../import_progress/import_progress.tsx | 0 .../components/import_progress/index.ts | 0 .../components/import_settings/advanced.tsx | 0 .../import_settings/import_settings.tsx | 0 .../components/import_settings/index.ts | 0 .../components/import_settings/simple.tsx | 0 .../import_summary/_import_sumary.scss | 0 .../components/import_summary/_index.scss | 0 .../components/import_summary/failures.tsx | 0 .../import_summary/import_summary.tsx | 0 .../components/import_summary/index.ts | 0 .../components/import_view/import_view.js | 9 +- .../components/import_view/index.js | 0 .../components/ml_embedded_map/_index.scss | 0 .../ml_embedded_map/_ml_embedded_map.scss | 0 .../components/ml_embedded_map/index.ts | 0 .../ml_embedded_map/ml_embedded_map.tsx | 2 - .../components/ml_job_editor/index.ts | 0 .../ml_job_editor/ml_job_editor.tsx | 0 .../components/multi_select_picker/index.ts | 0 .../multi_select_picker.tsx | 0 .../components/results_links/index.ts | 0 .../results_links/results_links.tsx | 8 +- .../components/results_view/_index.scss | 0 .../results_view/_results_view.scss | 0 .../components/results_view/index.ts | 0 .../components/results_view/results_view.tsx | 0 .../stats_table/_field_data_row.scss | 0 .../components/stats_table/_index.scss | 0 .../expanded_row_field_header.tsx | 0 .../expanded_row_field_header/index.ts | 0 .../components/field_count_stats/_index.scss | 0 .../components/field_count_stats/index.ts | 0 .../field_count_stats/metric_fields_count.tsx | 0 .../field_count_stats/total_fields_count.tsx | 0 .../field_data_expanded_row/_index.scss | 0 .../_number_content.scss | 0 .../boolean_content.tsx | 0 .../field_data_expanded_row/date_content.tsx | 0 .../document_stats.tsx | 0 .../expanded_row_content.tsx | 0 .../field_data_expanded_row/index.ts | 0 .../field_data_expanded_row/ip_content.tsx | 0 .../keyword_content.tsx | 0 .../number_content.tsx | 0 .../field_data_expanded_row/other_content.tsx | 0 .../field_data_expanded_row/text_content.tsx | 0 .../components/field_data_row/_index.scss | 0 .../boolean_content_preview.tsx | 0 .../field_data_row/column_chart.scss | 0 .../field_data_row/column_chart.tsx | 0 .../field_data_row/distinct_values.tsx | 0 .../field_data_row/document_stats.tsx | 0 .../field_data_row/field_histograms.ts | 0 .../components/field_data_row/index.ts | 0 .../field_data_row/number_content_preview.tsx | 0 .../field_data_row/top_values_preview.tsx | 0 .../field_data_row/use_column_chart.test.tsx | 0 .../field_data_row/use_column_chart.tsx | 0 .../metric_distribution_chart/index.ts | 0 .../metric_distribution_chart.tsx | 0 ...metric_distribution_chart_data_builder.tsx | 0 ...tric_distribution_chart_tooltip_header.tsx | 0 .../data_visualizer_stats_table.tsx | 0 .../stats_table/hooks/color_range_legend.tsx | 0 .../components/stats_table/hooks/index.ts | 0 .../stats_table/hooks/use_color_range.test.ts | 0 .../stats_table/hooks/use_color_range.ts | 0 .../hooks/use_data_viz_chart_theme.ts | 0 .../components/stats_table/index.ts | 0 .../stats_table/types/field_data_row.ts | 0 .../stats_table/types/field_vis_config.ts | 0 .../components/stats_table/types/index.ts | 0 .../stats_table/use_table_settings.ts | 0 .../components/stats_table/utils.ts | 0 .../components/top_values/_top_values.scss | 0 .../components/top_values/index.ts | 0 .../components/top_values/top_values.tsx | 0 .../components/utils/format_value.ts | 0 .../application/components/utils/index.ts | 0 .../components/utils/kibana_field_format.ts | 0 .../utils/number_as_ordinal.test.ts | 0 .../components/utils/number_as_ordinal.ts | 0 .../utils/round_to_decimal_place.test.ts | 0 .../utils/round_to_decimal_place.ts | 0 .../application/components/utils/utils.ts | 0 .../application/file_datavisualizer.tsx | 9 +- .../public/application/index.ts | 0 .../public/application/kibana_context.ts | 4 +- .../public/application/shared_imports.ts | 0 .../util/field_types_utils.test.ts | 0 .../application/util/field_types_utils.ts | 0 .../public/application/util/util.ts | 0 .../file_data_visualizer/public/index.ts | 19 +++ .../public/kibana_services.ts | 23 +++ .../file_data_visualizer/public/plugin.ts | 48 ++++++ .../file_data_visualizer/server/index.ts | 12 ++ .../file_data_visualizer/server/plugin.ts | 39 +++++ .../file_data_visualizer/server/types.ts | 12 ++ .../file_data_visualizer/tsconfig.json | 20 +++ x-pack/plugins/file_upload/kibana.json | 1 - .../plugins/file_upload/public/api/index.ts | 16 +- x-pack/plugins/file_upload/public/index.ts | 2 +- x-pack/plugins/file_upload/public/plugin.ts | 4 + x-pack/plugins/ml/kibana.json | 1 + .../file_based/file_datavisualizer.tsx | 8 +- x-pack/plugins/ml/tsconfig.json | 1 + 190 files changed, 472 insertions(+), 37 deletions(-) create mode 100644 x-pack/plugins/file_data_visualizer/common/constants.ts create mode 100644 x-pack/plugins/file_data_visualizer/common/index.ts create mode 100644 x-pack/plugins/file_data_visualizer/common/types.ts create mode 100644 x-pack/plugins/file_data_visualizer/jest.config.js create mode 100644 x-pack/plugins/file_data_visualizer/kibana.json create mode 100644 x-pack/plugins/file_data_visualizer/public/api/index.ts rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/_index.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/_index.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/about_panel/_about_panel.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/about_panel/_index.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/about_panel/about_panel.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/about_panel/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/about_panel/welcome_content.tsx (98%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/analysis_summary/_analysis_summary.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/analysis_summary/_index.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/analysis_summary/analysis_summary.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/analysis_summary/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/bottom_bar/bottom_bar.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/bottom_bar/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/combined_fields/combined_field_label.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/combined_fields/combined_fields_form.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/combined_fields/combined_fields_read_only_form.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/combined_fields/geo_point.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/combined_fields/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/combined_fields/types.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/combined_fields/utils.test.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/combined_fields/utils.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/edit_flyout/__snapshots__/overrides.test.js.snap (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/edit_flyout/_edit_flyout.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/edit_flyout/_index.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/edit_flyout/edit_flyout.js (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/edit_flyout/index.js (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/edit_flyout/options/index.js (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/edit_flyout/options/option_lists.js (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/edit_flyout/options/options.js (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/edit_flyout/overrides.js (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/edit_flyout/overrides.test.js (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/edit_flyout/overrides_validation.js (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/examples_list/examples_list.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/examples_list/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/expanded_row/file_based_expanded_row.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/expanded_row/geo_point_content/format_utils.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/expanded_row/geo_point_content/geo_point_content.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/expanded_row/geo_point_content/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/expanded_row/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/experimental_badge/_experimental_badge.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/experimental_badge/_index.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/experimental_badge/experimental_badge.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/experimental_badge/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/explanation_flyout/explanation_flyout.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/explanation_flyout/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/field_data_row/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/field_data_row/number_content_preview.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/field_names_filter/field_names_filter.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/field_names_filter/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/field_type_icon/__snapshots__/field_type_icon.test.tsx.snap (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/field_type_icon/field_type_icon.test.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/field_type_icon/field_type_icon.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/field_type_icon/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/field_types_filter/field_types_filter.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/field_types_filter/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/fields_stats/_field_stats_card.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/fields_stats/_fields_stats.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/fields_stats_grid/create_fields.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/fields_stats_grid/fields_stats_grid.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/fields_stats_grid/filter_fields.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/fields_stats_grid/get_field_names.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/fields_stats_grid/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/file_contents/_file_contents.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/file_contents/_index.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/file_contents/file_contents.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/file_contents/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/file_datavisualizer_view/_file_datavisualizer_view.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/file_datavisualizer_view/_index.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/file_datavisualizer_view/constants.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/file_datavisualizer_view/file_datavisualizer_view.js (97%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/file_datavisualizer_view/file_error_callouts.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/file_datavisualizer_view/index.js (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/filebeat_config_flyout/filebeat_config.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/filebeat_config_flyout/filebeat_config_flyout.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/filebeat_config_flyout/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/import_errors/errors.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/import_errors/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/import_progress/import_progress.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/import_progress/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/import_settings/advanced.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/import_settings/import_settings.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/import_settings/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/import_settings/simple.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/import_summary/_import_sumary.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/import_summary/_index.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/import_summary/failures.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/import_summary/import_summary.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/import_summary/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/import_view/import_view.js (98%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/import_view/index.js (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/ml_embedded_map/_index.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/ml_embedded_map/_ml_embedded_map.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/ml_embedded_map/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/ml_embedded_map/ml_embedded_map.tsx (99%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/ml_job_editor/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/ml_job_editor/ml_job_editor.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/multi_select_picker/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/multi_select_picker/multi_select_picker.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/results_links/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/results_links/results_links.tsx (97%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/results_view/_index.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/results_view/_results_view.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/results_view/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/results_view/results_view.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/_field_data_row.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/_index.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/expanded_row_field_header/expanded_row_field_header.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/expanded_row_field_header/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/field_count_stats/_index.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/field_count_stats/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/field_count_stats/metric_fields_count.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/field_count_stats/total_fields_count.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/field_data_expanded_row/_index.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/field_data_expanded_row/_number_content.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/field_data_expanded_row/boolean_content.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/field_data_expanded_row/date_content.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/field_data_expanded_row/document_stats.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/field_data_expanded_row/expanded_row_content.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/field_data_expanded_row/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/field_data_expanded_row/ip_content.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/field_data_expanded_row/keyword_content.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/field_data_expanded_row/number_content.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/field_data_expanded_row/other_content.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/field_data_expanded_row/text_content.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/field_data_row/_index.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/field_data_row/boolean_content_preview.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/field_data_row/column_chart.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/field_data_row/column_chart.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/field_data_row/distinct_values.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/field_data_row/document_stats.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/field_data_row/field_histograms.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/field_data_row/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/field_data_row/number_content_preview.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/field_data_row/top_values_preview.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/field_data_row/use_column_chart.test.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/metric_distribution_chart/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart_data_builder.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart_tooltip_header.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/data_visualizer_stats_table.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/hooks/color_range_legend.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/hooks/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/hooks/use_color_range.test.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/hooks/use_color_range.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/hooks/use_data_viz_chart_theme.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/types/field_data_row.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/types/field_vis_config.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/types/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/use_table_settings.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/stats_table/utils.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/top_values/_top_values.scss (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/top_values/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/top_values/top_values.tsx (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/utils/format_value.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/utils/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/utils/kibana_field_format.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/utils/number_as_ordinal.test.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/utils/number_as_ordinal.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/utils/round_to_decimal_place.test.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/utils/round_to_decimal_place.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/components/utils/utils.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/file_datavisualizer.tsx (87%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/index.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/kibana_context.ts (92%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/shared_imports.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/util/field_types_utils.test.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/util/field_types_utils.ts (100%) rename x-pack/plugins/{file_upload => file_data_visualizer}/public/application/util/util.ts (100%) create mode 100644 x-pack/plugins/file_data_visualizer/public/index.ts create mode 100644 x-pack/plugins/file_data_visualizer/public/kibana_services.ts create mode 100644 x-pack/plugins/file_data_visualizer/public/plugin.ts create mode 100644 x-pack/plugins/file_data_visualizer/server/index.ts create mode 100644 x-pack/plugins/file_data_visualizer/server/plugin.ts create mode 100644 x-pack/plugins/file_data_visualizer/server/types.ts create mode 100644 x-pack/plugins/file_data_visualizer/tsconfig.json diff --git a/x-pack/plugins/file_data_visualizer/common/constants.ts b/x-pack/plugins/file_data_visualizer/common/constants.ts new file mode 100644 index 0000000000000..6c4e62698e8af --- /dev/null +++ b/x-pack/plugins/file_data_visualizer/common/constants.ts @@ -0,0 +1,31 @@ +/* + * 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. + */ + +export const UI_SETTING_MAX_FILE_SIZE = 'fileUpload:maxFileSize'; + +export const MB = Math.pow(2, 20); +export const MAX_FILE_SIZE = '100MB'; +export const MAX_FILE_SIZE_BYTES = 104857600; // 100MB + +export const ABSOLUTE_MAX_FILE_SIZE_BYTES = 1073741274; // 1GB +export const FILE_SIZE_DISPLAY_FORMAT = '0,0.[0] b'; + +// Value to use in the Elasticsearch index mapping meta data to identify the +// index as having been created by the ML File Data Visualizer. +export const INDEX_META_DATA_CREATED_BY = 'ml-file-data-visualizer'; + +export const ML_JOB_FIELD_TYPES = { + BOOLEAN: 'boolean', + DATE: 'date', + GEO_POINT: 'geo_point', + GEO_SHAPE: 'geo_shape', + IP: 'ip', + KEYWORD: 'keyword', + NUMBER: 'number', + TEXT: 'text', + UNKNOWN: 'unknown', +} as const; diff --git a/x-pack/plugins/file_data_visualizer/common/index.ts b/x-pack/plugins/file_data_visualizer/common/index.ts new file mode 100644 index 0000000000000..f4d74984a7d78 --- /dev/null +++ b/x-pack/plugins/file_data_visualizer/common/index.ts @@ -0,0 +1,9 @@ +/* + * 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. + */ + +export * from './constants'; +export * from './types'; diff --git a/x-pack/plugins/file_data_visualizer/common/types.ts b/x-pack/plugins/file_data_visualizer/common/types.ts new file mode 100644 index 0000000000000..3e60eff839f0d --- /dev/null +++ b/x-pack/plugins/file_data_visualizer/common/types.ts @@ -0,0 +1,152 @@ +/* + * 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 type { estypes } from '@elastic/elasticsearch'; +import { ES_FIELD_TYPES } from '../../../../src/plugins/data/common'; +import { ML_JOB_FIELD_TYPES } from './constants'; + +export interface HasImportPermission { + hasImportPermission: boolean; +} + +export interface InputOverrides { + [key: string]: string | undefined; +} + +export type FormattedOverrides = InputOverrides & { + column_names: string[]; + has_header_row: boolean; + should_trim_fields: boolean; +}; + +export interface AnalysisResult { + results: FindFileStructureResponse; + overrides?: FormattedOverrides; +} + +export interface FindFileStructureResponse { + charset: string; + has_header_row: boolean; + has_byte_order_marker: boolean; + format: string; + field_stats: { + [fieldName: string]: { + count: number; + cardinality: number; + top_hits: Array<{ count: number; value: any }>; + mean_value?: number; + median_value?: number; + max_value?: number; + min_value?: number; + earliest?: string; + latest?: string; + }; + }; + sample_start: string; + num_messages_analyzed: number; + mappings: { + properties: { + [fieldName: string]: { + // including all possible Elasticsearch types + // since find_file_structure API can be enhanced to include new fields in the future + type: Exclude< + ES_FIELD_TYPES, + ES_FIELD_TYPES._ID | ES_FIELD_TYPES._INDEX | ES_FIELD_TYPES._SOURCE | ES_FIELD_TYPES._TYPE + >; + format?: string; + }; + }; + }; + quote: string; + delimiter: string; + need_client_timezone: boolean; + num_lines_analyzed: number; + column_names?: string[]; + explanation?: string[]; + grok_pattern?: string; + multiline_start_pattern?: string; + exclude_lines_pattern?: string; + java_timestamp_formats?: string[]; + joda_timestamp_formats?: string[]; + timestamp_field?: string; + should_trim_fields?: boolean; +} + +export interface FindFileStructureErrorResponse { + body: { + statusCode: number; + error: string; + message: string; + attributes?: any; + }; + name: string; +} + +export type InputData = any[]; + +export interface ImportResponse { + success: boolean; + id: string; + index?: string; + pipelineId?: string; + docCount: number; + failures: ImportFailure[]; + error?: { + error: estypes.ErrorCause; + }; + ingestError?: boolean; +} + +export interface ImportFailure { + item: number; + reason: string; + doc: ImportDoc; +} + +export interface Doc { + message: string; +} + +export type ImportDoc = Doc | string | object; + +export interface Settings { + pipeline?: string; + index: string; + body: any[]; + [key: string]: any; +} + +export interface Mappings { + _meta?: { + created_by: string; + }; + properties: { + [key: string]: any; + }; +} + +export interface IngestPipelineWrapper { + id: string; + pipeline: IngestPipeline; +} + +export interface IngestPipeline { + description: string; + processors: any[]; +} + +export type MlJobFieldType = typeof ML_JOB_FIELD_TYPES[keyof typeof ML_JOB_FIELD_TYPES]; + +export interface DataVisualizerTableState { + pageSize: number; + pageIndex: number; + sortField: string; + sortDirection: string; + visibleFieldTypes: string[]; + visibleFieldNames: string[]; + showDistributions: boolean; +} diff --git a/x-pack/plugins/file_data_visualizer/jest.config.js b/x-pack/plugins/file_data_visualizer/jest.config.js new file mode 100644 index 0000000000000..90d4cfb81f11f --- /dev/null +++ b/x-pack/plugins/file_data_visualizer/jest.config.js @@ -0,0 +1,12 @@ +/* + * 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. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../..', + roots: ['/x-pack/plugins/file_data_visualizer'], +}; diff --git a/x-pack/plugins/file_data_visualizer/kibana.json b/x-pack/plugins/file_data_visualizer/kibana.json new file mode 100644 index 0000000000000..dda2e41057572 --- /dev/null +++ b/x-pack/plugins/file_data_visualizer/kibana.json @@ -0,0 +1,27 @@ +{ + "id": "fileDataVisualizer", + "version": "8.0.0", + "kibanaVersion": "kibana", + "server": true, + "ui": true, + "requiredPlugins": [ + "data", + "usageCollection", + "embeddable", + "share", + "discover", + "fileUpload" + ], + "optionalPlugins": [ + "security", + "maps" + ], + "requiredBundles": [ + "esUiShared", + "kibanaReact", + "fileUpload" + ], + "extraPublicDirs": [ + "common" + ] +} diff --git a/x-pack/plugins/file_data_visualizer/public/api/index.ts b/x-pack/plugins/file_data_visualizer/public/api/index.ts new file mode 100644 index 0000000000000..ee9e50c98725d --- /dev/null +++ b/x-pack/plugins/file_data_visualizer/public/api/index.ts @@ -0,0 +1,30 @@ +/* + * 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 React from 'react'; +import { HttpStart } from 'src/core/public'; +// import { FileUploadComponentProps, lazyLoadFileUploadModules } from '../lazy_load_bundle'; +// import type { IImporter, ImportFactoryOptions } from '../importer'; +// import { HasImportPermission } from '../../common'; + +export interface FileDataVisualizerStartApi { + analyzeFile(file: string, params: Record): Promise; +} + +export function getApi(http: HttpStart) { + async function analyzeFile(file: string, params: Record = {}): Promise { + const body = JSON.stringify(file); + return await http.fetch({ + path: `/internal/file_upload/analyze_file`, + method: 'POST', + body, + query: params, + }); + } + + return { analyzeFile }; +} diff --git a/x-pack/plugins/file_upload/public/application/_index.scss b/x-pack/plugins/file_data_visualizer/public/application/_index.scss similarity index 100% rename from x-pack/plugins/file_upload/public/application/_index.scss rename to x-pack/plugins/file_data_visualizer/public/application/_index.scss diff --git a/x-pack/plugins/file_upload/public/application/components/_index.scss b/x-pack/plugins/file_data_visualizer/public/application/components/_index.scss similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/_index.scss rename to x-pack/plugins/file_data_visualizer/public/application/components/_index.scss diff --git a/x-pack/plugins/file_upload/public/application/components/about_panel/_about_panel.scss b/x-pack/plugins/file_data_visualizer/public/application/components/about_panel/_about_panel.scss similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/about_panel/_about_panel.scss rename to x-pack/plugins/file_data_visualizer/public/application/components/about_panel/_about_panel.scss diff --git a/x-pack/plugins/file_upload/public/application/components/about_panel/_index.scss b/x-pack/plugins/file_data_visualizer/public/application/components/about_panel/_index.scss similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/about_panel/_index.scss rename to x-pack/plugins/file_data_visualizer/public/application/components/about_panel/_index.scss diff --git a/x-pack/plugins/file_upload/public/application/components/about_panel/about_panel.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/about_panel/about_panel.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/about_panel/about_panel.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/about_panel/about_panel.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/about_panel/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/about_panel/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/about_panel/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/about_panel/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/about_panel/welcome_content.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/about_panel/welcome_content.tsx similarity index 98% rename from x-pack/plugins/file_upload/public/application/components/about_panel/welcome_content.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/about_panel/welcome_content.tsx index c753b224ab200..94e27caa20fe0 100644 --- a/x-pack/plugins/file_upload/public/application/components/about_panel/welcome_content.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/about_panel/welcome_content.tsx @@ -21,7 +21,7 @@ import { import { ExperimentalBadge } from '../experimental_badge'; -import { getMaxBytesFormatted } from '../../../get_max_bytes'; +import { getMaxBytesFormatted } from '../../../../../file_upload/public'; export const WelcomeContent: FC = () => { const toolTipContent = i18n.translate( diff --git a/x-pack/plugins/file_upload/public/application/components/analysis_summary/_analysis_summary.scss b/x-pack/plugins/file_data_visualizer/public/application/components/analysis_summary/_analysis_summary.scss similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/analysis_summary/_analysis_summary.scss rename to x-pack/plugins/file_data_visualizer/public/application/components/analysis_summary/_analysis_summary.scss diff --git a/x-pack/plugins/file_upload/public/application/components/analysis_summary/_index.scss b/x-pack/plugins/file_data_visualizer/public/application/components/analysis_summary/_index.scss similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/analysis_summary/_index.scss rename to x-pack/plugins/file_data_visualizer/public/application/components/analysis_summary/_index.scss diff --git a/x-pack/plugins/file_upload/public/application/components/analysis_summary/analysis_summary.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/analysis_summary/analysis_summary.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/analysis_summary/analysis_summary.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/analysis_summary/analysis_summary.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/analysis_summary/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/analysis_summary/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/analysis_summary/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/analysis_summary/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/bottom_bar/bottom_bar.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/bottom_bar/bottom_bar.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/bottom_bar/bottom_bar.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/bottom_bar/bottom_bar.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/bottom_bar/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/bottom_bar/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/bottom_bar/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/bottom_bar/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/combined_fields/combined_field_label.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/combined_field_label.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/combined_fields/combined_field_label.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/combined_field_label.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/combined_fields/combined_fields_form.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/combined_fields_form.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/combined_fields/combined_fields_form.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/combined_fields_form.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/combined_fields/combined_fields_read_only_form.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/combined_fields_read_only_form.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/combined_fields/combined_fields_read_only_form.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/combined_fields_read_only_form.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/combined_fields/geo_point.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/geo_point.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/combined_fields/geo_point.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/geo_point.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/combined_fields/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/combined_fields/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/combined_fields/types.ts b/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/types.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/combined_fields/types.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/types.ts diff --git a/x-pack/plugins/file_upload/public/application/components/combined_fields/utils.test.ts b/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/utils.test.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/combined_fields/utils.test.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/utils.test.ts diff --git a/x-pack/plugins/file_upload/public/application/components/combined_fields/utils.ts b/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/utils.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/combined_fields/utils.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/utils.ts diff --git a/x-pack/plugins/file_upload/public/application/components/edit_flyout/__snapshots__/overrides.test.js.snap b/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/__snapshots__/overrides.test.js.snap similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/edit_flyout/__snapshots__/overrides.test.js.snap rename to x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/__snapshots__/overrides.test.js.snap diff --git a/x-pack/plugins/file_upload/public/application/components/edit_flyout/_edit_flyout.scss b/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/_edit_flyout.scss similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/edit_flyout/_edit_flyout.scss rename to x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/_edit_flyout.scss diff --git a/x-pack/plugins/file_upload/public/application/components/edit_flyout/_index.scss b/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/_index.scss similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/edit_flyout/_index.scss rename to x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/_index.scss diff --git a/x-pack/plugins/file_upload/public/application/components/edit_flyout/edit_flyout.js b/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/edit_flyout.js similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/edit_flyout/edit_flyout.js rename to x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/edit_flyout.js diff --git a/x-pack/plugins/file_upload/public/application/components/edit_flyout/index.js b/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/index.js similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/edit_flyout/index.js rename to x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/index.js diff --git a/x-pack/plugins/file_upload/public/application/components/edit_flyout/options/index.js b/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/options/index.js similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/edit_flyout/options/index.js rename to x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/options/index.js diff --git a/x-pack/plugins/file_upload/public/application/components/edit_flyout/options/option_lists.js b/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/options/option_lists.js similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/edit_flyout/options/option_lists.js rename to x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/options/option_lists.js diff --git a/x-pack/plugins/file_upload/public/application/components/edit_flyout/options/options.js b/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/options/options.js similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/edit_flyout/options/options.js rename to x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/options/options.js diff --git a/x-pack/plugins/file_upload/public/application/components/edit_flyout/overrides.js b/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/overrides.js similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/edit_flyout/overrides.js rename to x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/overrides.js diff --git a/x-pack/plugins/file_upload/public/application/components/edit_flyout/overrides.test.js b/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/overrides.test.js similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/edit_flyout/overrides.test.js rename to x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/overrides.test.js diff --git a/x-pack/plugins/file_upload/public/application/components/edit_flyout/overrides_validation.js b/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/overrides_validation.js similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/edit_flyout/overrides_validation.js rename to x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/overrides_validation.js diff --git a/x-pack/plugins/file_upload/public/application/components/examples_list/examples_list.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/examples_list/examples_list.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/examples_list/examples_list.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/examples_list/examples_list.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/examples_list/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/examples_list/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/examples_list/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/examples_list/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/expanded_row/file_based_expanded_row.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/file_based_expanded_row.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/expanded_row/file_based_expanded_row.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/file_based_expanded_row.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/expanded_row/geo_point_content/format_utils.ts b/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/format_utils.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/expanded_row/geo_point_content/format_utils.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/format_utils.ts diff --git a/x-pack/plugins/file_upload/public/application/components/expanded_row/geo_point_content/geo_point_content.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/geo_point_content.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/expanded_row/geo_point_content/geo_point_content.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/geo_point_content.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/expanded_row/geo_point_content/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/expanded_row/geo_point_content/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/expanded_row/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/expanded_row/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/experimental_badge/_experimental_badge.scss b/x-pack/plugins/file_data_visualizer/public/application/components/experimental_badge/_experimental_badge.scss similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/experimental_badge/_experimental_badge.scss rename to x-pack/plugins/file_data_visualizer/public/application/components/experimental_badge/_experimental_badge.scss diff --git a/x-pack/plugins/file_upload/public/application/components/experimental_badge/_index.scss b/x-pack/plugins/file_data_visualizer/public/application/components/experimental_badge/_index.scss similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/experimental_badge/_index.scss rename to x-pack/plugins/file_data_visualizer/public/application/components/experimental_badge/_index.scss diff --git a/x-pack/plugins/file_upload/public/application/components/experimental_badge/experimental_badge.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/experimental_badge/experimental_badge.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/experimental_badge/experimental_badge.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/experimental_badge/experimental_badge.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/experimental_badge/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/experimental_badge/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/experimental_badge/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/experimental_badge/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/explanation_flyout/explanation_flyout.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/explanation_flyout/explanation_flyout.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/explanation_flyout/explanation_flyout.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/explanation_flyout/explanation_flyout.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/explanation_flyout/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/explanation_flyout/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/explanation_flyout/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/explanation_flyout/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/field_data_row/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/field_data_row/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/field_data_row/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/field_data_row/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/field_data_row/number_content_preview.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/field_data_row/number_content_preview.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/field_data_row/number_content_preview.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/field_data_row/number_content_preview.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/field_names_filter/field_names_filter.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/field_names_filter/field_names_filter.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/field_names_filter/field_names_filter.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/field_names_filter/field_names_filter.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/field_names_filter/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/field_names_filter/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/field_names_filter/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/field_names_filter/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/field_type_icon/__snapshots__/field_type_icon.test.tsx.snap b/x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/__snapshots__/field_type_icon.test.tsx.snap similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/field_type_icon/__snapshots__/field_type_icon.test.tsx.snap rename to x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/__snapshots__/field_type_icon.test.tsx.snap diff --git a/x-pack/plugins/file_upload/public/application/components/field_type_icon/field_type_icon.test.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/field_type_icon.test.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/field_type_icon/field_type_icon.test.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/field_type_icon.test.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/field_type_icon/field_type_icon.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/field_type_icon.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/field_type_icon/field_type_icon.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/field_type_icon.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/field_type_icon/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/field_type_icon/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/field_types_filter/field_types_filter.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/field_types_filter/field_types_filter.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/field_types_filter/field_types_filter.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/field_types_filter/field_types_filter.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/field_types_filter/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/field_types_filter/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/field_types_filter/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/field_types_filter/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/fields_stats/_field_stats_card.scss b/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats/_field_stats_card.scss similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/fields_stats/_field_stats_card.scss rename to x-pack/plugins/file_data_visualizer/public/application/components/fields_stats/_field_stats_card.scss diff --git a/x-pack/plugins/file_upload/public/application/components/fields_stats/_fields_stats.scss b/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats/_fields_stats.scss similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/fields_stats/_fields_stats.scss rename to x-pack/plugins/file_data_visualizer/public/application/components/fields_stats/_fields_stats.scss diff --git a/x-pack/plugins/file_upload/public/application/components/fields_stats_grid/create_fields.ts b/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/create_fields.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/fields_stats_grid/create_fields.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/create_fields.ts diff --git a/x-pack/plugins/file_upload/public/application/components/fields_stats_grid/fields_stats_grid.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/fields_stats_grid.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/fields_stats_grid/fields_stats_grid.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/fields_stats_grid.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/fields_stats_grid/filter_fields.ts b/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/filter_fields.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/fields_stats_grid/filter_fields.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/filter_fields.ts diff --git a/x-pack/plugins/file_upload/public/application/components/fields_stats_grid/get_field_names.ts b/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/get_field_names.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/fields_stats_grid/get_field_names.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/get_field_names.ts diff --git a/x-pack/plugins/file_upload/public/application/components/fields_stats_grid/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/fields_stats_grid/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/file_contents/_file_contents.scss b/x-pack/plugins/file_data_visualizer/public/application/components/file_contents/_file_contents.scss similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/file_contents/_file_contents.scss rename to x-pack/plugins/file_data_visualizer/public/application/components/file_contents/_file_contents.scss diff --git a/x-pack/plugins/file_upload/public/application/components/file_contents/_index.scss b/x-pack/plugins/file_data_visualizer/public/application/components/file_contents/_index.scss similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/file_contents/_index.scss rename to x-pack/plugins/file_data_visualizer/public/application/components/file_contents/_index.scss diff --git a/x-pack/plugins/file_upload/public/application/components/file_contents/file_contents.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/file_contents/file_contents.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/file_contents/file_contents.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/file_contents/file_contents.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/file_contents/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/file_contents/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/file_contents/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/file_contents/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/_file_datavisualizer_view.scss b/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/_file_datavisualizer_view.scss similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/_file_datavisualizer_view.scss rename to x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/_file_datavisualizer_view.scss diff --git a/x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/_index.scss b/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/_index.scss similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/_index.scss rename to x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/_index.scss diff --git a/x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/constants.ts b/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/constants.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/constants.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/constants.ts diff --git a/x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/file_datavisualizer_view.js b/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_datavisualizer_view.js similarity index 97% rename from x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/file_datavisualizer_view.js rename to x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_datavisualizer_view.js index c9032f58bb030..0663b5fc4bce4 100644 --- a/x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/file_datavisualizer_view.js +++ b/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_datavisualizer_view.js @@ -20,8 +20,9 @@ import { EditFlyout } from '../edit_flyout'; import { ExplanationFlyout } from '../explanation_flyout'; import { ImportView } from '../import_view'; import { DEFAULT_LINES_TO_SAMPLE, readFile, createUrlOverrides, processResults } from '../utils'; -import { getMaxBytes } from '../../../get_max_bytes'; -import { hasImportPermission, analyzeFile } from '../../../api'; +import { getMaxBytes } from '../../../../../file_upload/public'; +import { getApi } from '../../../api'; +import { getFileUpload } from '../../../kibana_services'; import { MODE } from './constants'; @@ -63,7 +64,7 @@ export class FileDataVisualizerView extends Component { // check the user has the correct permission to import data. // note, calling hasImportPermission with no arguments just checks the // cluster privileges, the user will still need index privileges to create and ingest - const hasPermissionToImport = await hasImportPermission({ + const hasPermissionToImport = await getFileUpload().hasImportPermission({ checkCreateIndexPattern: false, checkHasManagePipeline: true, }); @@ -128,6 +129,7 @@ export class FileDataVisualizerView extends Component { async analyzeFile(fileContents, overrides, isRetry = false) { try { + const { analyzeFile } = getApi(this.props.http); const resp = await analyzeFile(fileContents, overrides); const serverSettings = processResults(resp); const serverOverrides = resp.overrides; diff --git a/x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/file_error_callouts.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_error_callouts.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/file_error_callouts.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_error_callouts.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/index.js b/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/index.js similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/file_datavisualizer_view/index.js rename to x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/index.js diff --git a/x-pack/plugins/file_upload/public/application/components/filebeat_config_flyout/filebeat_config.ts b/x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/filebeat_config.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/filebeat_config_flyout/filebeat_config.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/filebeat_config.ts diff --git a/x-pack/plugins/file_upload/public/application/components/filebeat_config_flyout/filebeat_config_flyout.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/filebeat_config_flyout.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/filebeat_config_flyout/filebeat_config_flyout.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/filebeat_config_flyout.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/filebeat_config_flyout/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/filebeat_config_flyout/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/import_errors/errors.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/import_errors/errors.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/import_errors/errors.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/import_errors/errors.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/import_errors/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/import_errors/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/import_errors/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/import_errors/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/import_progress/import_progress.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/import_progress/import_progress.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/import_progress/import_progress.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/import_progress/import_progress.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/import_progress/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/import_progress/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/import_progress/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/import_progress/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/import_settings/advanced.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/advanced.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/import_settings/advanced.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/import_settings/advanced.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/import_settings/import_settings.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/import_settings.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/import_settings/import_settings.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/import_settings/import_settings.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/import_settings/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/import_settings/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/import_settings/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/import_settings/simple.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/simple.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/import_settings/simple.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/import_settings/simple.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/import_summary/_import_sumary.scss b/x-pack/plugins/file_data_visualizer/public/application/components/import_summary/_import_sumary.scss similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/import_summary/_import_sumary.scss rename to x-pack/plugins/file_data_visualizer/public/application/components/import_summary/_import_sumary.scss diff --git a/x-pack/plugins/file_upload/public/application/components/import_summary/_index.scss b/x-pack/plugins/file_data_visualizer/public/application/components/import_summary/_index.scss similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/import_summary/_index.scss rename to x-pack/plugins/file_data_visualizer/public/application/components/import_summary/_index.scss diff --git a/x-pack/plugins/file_upload/public/application/components/import_summary/failures.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/import_summary/failures.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/import_summary/failures.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/import_summary/failures.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/import_summary/import_summary.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/import_summary/import_summary.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/import_summary/import_summary.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/import_summary/import_summary.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/import_summary/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/import_summary/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/import_summary/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/import_summary/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/import_view/import_view.js b/x-pack/plugins/file_data_visualizer/public/application/components/import_view/import_view.js similarity index 98% rename from x-pack/plugins/file_upload/public/application/components/import_view/import_view.js rename to x-pack/plugins/file_data_visualizer/public/application/components/import_view/import_view.js index 012b455f4c1ce..005f363b2a8f1 100644 --- a/x-pack/plugins/file_upload/public/application/components/import_view/import_view.js +++ b/x-pack/plugins/file_data_visualizer/public/application/components/import_view/import_view.js @@ -32,7 +32,8 @@ import { getDefaultCombinedFields, } from '../combined_fields'; import { ExperimentalBadge } from '../experimental_badge'; -import { hasImportPermission, importerFactory, checkIndexExists } from '../../../api'; +// import { hasImportPermission, importerFactory, checkIndexExists } from '../../../api'; +import { getFileUpload } from '../../../kibana_services'; const DEFAULT_TIME_FIELD = '@timestamp'; const DEFAULT_INDEX_SETTINGS = { number_of_shards: 1 }; @@ -123,7 +124,7 @@ export class ImportView extends Component { async () => { // check to see if the user has permission to create and ingest data into the specified index if ( - (await hasImportPermission({ + (await getFileUpload().hasImportPermission({ checkCreateIndexPattern: createIndexPattern, checkHasManagePipeline: true, indexName: index, @@ -220,7 +221,7 @@ export class ImportView extends Component { } if (success) { - const importer = await importerFactory(format, { + const importer = await getFileUpload().importerFactory(format, { excludeLinesPattern: results.exclude_lines_pattern, multilineStartPattern: results.multiline_start_pattern, }); @@ -352,7 +353,7 @@ export class ImportView extends Component { return; } - const { exists } = await checkIndexExists(index); + const { exists } = await getFileUpload().checkIndexExists(index); const indexNameError = exists ? ( ); } -*/ diff --git a/x-pack/plugins/file_upload/public/application/components/ml_job_editor/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/ml_job_editor/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/ml_job_editor/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/ml_job_editor/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/ml_job_editor/ml_job_editor.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/ml_job_editor/ml_job_editor.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/ml_job_editor/ml_job_editor.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/ml_job_editor/ml_job_editor.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/multi_select_picker/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/multi_select_picker/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/multi_select_picker/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/multi_select_picker/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/multi_select_picker/multi_select_picker.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/multi_select_picker/multi_select_picker.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/multi_select_picker/multi_select_picker.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/multi_select_picker/multi_select_picker.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/results_links/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/results_links/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/results_links/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/results_links/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/results_links/results_links.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/results_links/results_links.tsx similarity index 97% rename from x-pack/plugins/file_upload/public/application/components/results_links/results_links.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/results_links/results_links.tsx index b18ac3d7b0af2..b8c048589fa47 100644 --- a/x-pack/plugins/file_upload/public/application/components/results_links/results_links.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/results_links/results_links.tsx @@ -15,7 +15,7 @@ import { } from '../../../../../../../src/plugins/discover/public'; import { FindFileStructureResponse } from '../../../../common'; import { useFileUploadKibana } from '../../kibana_context'; -import { getTimeFieldRange } from '../../../api'; +import { getFileUpload } from '../../../kibana_services'; interface Props { fieldStats: FindFileStructureResponse['field_stats']; @@ -235,11 +235,7 @@ export const ResultsLinks: FC = ({ async function getFullTimeRange(index: string, timeFieldName: string) { const query = { bool: { must: [{ query_string: { analyze_wildcard: true, query: '*' } }] } }; - const resp = await getTimeFieldRange({ - index, - timeFieldName, - query, - }); + const resp = await getFileUpload().getTimeFieldRange(index, query, timeFieldName); return { from: moment(resp.start.epoch).toISOString(), diff --git a/x-pack/plugins/file_upload/public/application/components/results_view/_index.scss b/x-pack/plugins/file_data_visualizer/public/application/components/results_view/_index.scss similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/results_view/_index.scss rename to x-pack/plugins/file_data_visualizer/public/application/components/results_view/_index.scss diff --git a/x-pack/plugins/file_upload/public/application/components/results_view/_results_view.scss b/x-pack/plugins/file_data_visualizer/public/application/components/results_view/_results_view.scss similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/results_view/_results_view.scss rename to x-pack/plugins/file_data_visualizer/public/application/components/results_view/_results_view.scss diff --git a/x-pack/plugins/file_upload/public/application/components/results_view/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/results_view/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/results_view/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/results_view/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/results_view/results_view.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/results_view/results_view.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/results_view/results_view.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/results_view/results_view.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/_field_data_row.scss b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/_field_data_row.scss similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/_field_data_row.scss rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/_field_data_row.scss diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/_index.scss b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/_index.scss similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/_index.scss rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/_index.scss diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/expanded_row_field_header/expanded_row_field_header.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/expanded_row_field_header/expanded_row_field_header.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/expanded_row_field_header/expanded_row_field_header.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/expanded_row_field_header/expanded_row_field_header.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/expanded_row_field_header/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/expanded_row_field_header/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/expanded_row_field_header/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/expanded_row_field_header/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/_index.scss b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/_index.scss similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/_index.scss rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/_index.scss diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/metric_fields_count.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/metric_fields_count.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/metric_fields_count.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/metric_fields_count.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/total_fields_count.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/total_fields_count.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/field_count_stats/total_fields_count.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/total_fields_count.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/_index.scss b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/_index.scss similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/_index.scss rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/_index.scss diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/_number_content.scss b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/_number_content.scss similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/_number_content.scss rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/_number_content.scss diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/boolean_content.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/boolean_content.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/boolean_content.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/boolean_content.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/date_content.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/date_content.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/date_content.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/date_content.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/document_stats.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/document_stats.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/document_stats.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/document_stats.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/expanded_row_content.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/expanded_row_content.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/expanded_row_content.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/expanded_row_content.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/ip_content.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/ip_content.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/ip_content.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/ip_content.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/keyword_content.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/keyword_content.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/keyword_content.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/keyword_content.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/number_content.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/number_content.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/number_content.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/number_content.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/other_content.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/other_content.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/other_content.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/other_content.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/text_content.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/text_content.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_expanded_row/text_content.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/text_content.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/_index.scss b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/_index.scss similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/_index.scss rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/_index.scss diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/boolean_content_preview.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/boolean_content_preview.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/boolean_content_preview.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/boolean_content_preview.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/column_chart.scss b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/column_chart.scss similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/column_chart.scss rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/column_chart.scss diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/column_chart.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/column_chart.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/column_chart.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/column_chart.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/distinct_values.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/distinct_values.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/distinct_values.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/distinct_values.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/document_stats.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/document_stats.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/document_stats.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/document_stats.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/field_histograms.ts b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/field_histograms.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/field_histograms.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/field_histograms.ts diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/number_content_preview.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/number_content_preview.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/number_content_preview.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/number_content_preview.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/top_values_preview.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/top_values_preview.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/top_values_preview.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/top_values_preview.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/use_column_chart.test.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/use_column_chart.test.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/use_column_chart.test.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/use_column_chart.test.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/metric_distribution_chart/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/metric_distribution_chart/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart_data_builder.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart_data_builder.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart_data_builder.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart_data_builder.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart_tooltip_header.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart_tooltip_header.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart_tooltip_header.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart_tooltip_header.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/data_visualizer_stats_table.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/data_visualizer_stats_table.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/data_visualizer_stats_table.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/data_visualizer_stats_table.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/hooks/color_range_legend.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/color_range_legend.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/hooks/color_range_legend.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/color_range_legend.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/hooks/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/hooks/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/hooks/use_color_range.test.ts b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/use_color_range.test.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/hooks/use_color_range.test.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/use_color_range.test.ts diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/hooks/use_color_range.ts b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/use_color_range.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/hooks/use_color_range.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/use_color_range.ts diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/hooks/use_data_viz_chart_theme.ts b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/use_data_viz_chart_theme.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/hooks/use_data_viz_chart_theme.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/use_data_viz_chart_theme.ts diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/types/field_data_row.ts b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/types/field_data_row.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/types/field_data_row.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/types/field_data_row.ts diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/types/field_vis_config.ts b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/types/field_vis_config.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/types/field_vis_config.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/types/field_vis_config.ts diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/types/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/types/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/types/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/types/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/use_table_settings.ts b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/use_table_settings.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/use_table_settings.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/use_table_settings.ts diff --git a/x-pack/plugins/file_upload/public/application/components/stats_table/utils.ts b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/utils.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/stats_table/utils.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/stats_table/utils.ts diff --git a/x-pack/plugins/file_upload/public/application/components/top_values/_top_values.scss b/x-pack/plugins/file_data_visualizer/public/application/components/top_values/_top_values.scss similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/top_values/_top_values.scss rename to x-pack/plugins/file_data_visualizer/public/application/components/top_values/_top_values.scss diff --git a/x-pack/plugins/file_upload/public/application/components/top_values/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/top_values/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/top_values/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/top_values/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/top_values/top_values.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/top_values/top_values.tsx similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/top_values/top_values.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/top_values/top_values.tsx diff --git a/x-pack/plugins/file_upload/public/application/components/utils/format_value.ts b/x-pack/plugins/file_data_visualizer/public/application/components/utils/format_value.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/utils/format_value.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/utils/format_value.ts diff --git a/x-pack/plugins/file_upload/public/application/components/utils/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/utils/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/utils/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/utils/index.ts diff --git a/x-pack/plugins/file_upload/public/application/components/utils/kibana_field_format.ts b/x-pack/plugins/file_data_visualizer/public/application/components/utils/kibana_field_format.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/utils/kibana_field_format.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/utils/kibana_field_format.ts diff --git a/x-pack/plugins/file_upload/public/application/components/utils/number_as_ordinal.test.ts b/x-pack/plugins/file_data_visualizer/public/application/components/utils/number_as_ordinal.test.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/utils/number_as_ordinal.test.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/utils/number_as_ordinal.test.ts diff --git a/x-pack/plugins/file_upload/public/application/components/utils/number_as_ordinal.ts b/x-pack/plugins/file_data_visualizer/public/application/components/utils/number_as_ordinal.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/utils/number_as_ordinal.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/utils/number_as_ordinal.ts diff --git a/x-pack/plugins/file_upload/public/application/components/utils/round_to_decimal_place.test.ts b/x-pack/plugins/file_data_visualizer/public/application/components/utils/round_to_decimal_place.test.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/utils/round_to_decimal_place.test.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/utils/round_to_decimal_place.test.ts diff --git a/x-pack/plugins/file_upload/public/application/components/utils/round_to_decimal_place.ts b/x-pack/plugins/file_data_visualizer/public/application/components/utils/round_to_decimal_place.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/utils/round_to_decimal_place.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/utils/round_to_decimal_place.ts diff --git a/x-pack/plugins/file_upload/public/application/components/utils/utils.ts b/x-pack/plugins/file_data_visualizer/public/application/components/utils/utils.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/components/utils/utils.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/utils/utils.ts diff --git a/x-pack/plugins/file_upload/public/application/file_datavisualizer.tsx b/x-pack/plugins/file_data_visualizer/public/application/file_datavisualizer.tsx similarity index 87% rename from x-pack/plugins/file_upload/public/application/file_datavisualizer.tsx rename to x-pack/plugins/file_data_visualizer/public/application/file_datavisualizer.tsx index ed157249106c0..48e30e99d91aa 100644 --- a/x-pack/plugins/file_upload/public/application/file_datavisualizer.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/file_datavisualizer.tsx @@ -11,7 +11,7 @@ import { CoreStart } from 'kibana/public'; import type { SharePluginStart } from 'src/plugins/share/public'; import { KibanaContextProvider } from '../../../../../src/plugins/kibana_react/public'; import type { EmbeddableStart } from '../../../../../src/plugins/embeddable/public'; -// import type { MapsStartApi } from '../../../maps/public'; +import type { MapsStartApi } from '../../../maps/public'; import { SecurityPluginSetup } from '../../../security/public'; // @ts-ignore @@ -20,7 +20,7 @@ import { FileDataVisualizerView } from './components/file_datavisualizer_view/in export interface FileDataVisualizerProps { data: DataPublicPluginStart; embeddable?: EmbeddableStart; - // maps?: MapsStartApi; + maps?: MapsStartApi; security?: SecurityPluginSetup; coreStart: CoreStart; share: SharePluginStart; @@ -29,18 +29,19 @@ export interface FileDataVisualizerProps { export const FileDataVisualizer: FC = ({ data, embeddable, - // maps, + maps, security, share, coreStart, }) => { - const services = { data, embeddable, share, /* maps,*/ security, ...coreStart }; + const services = { data, embeddable, share, maps, security, ...coreStart }; return ( ); diff --git a/x-pack/plugins/file_upload/public/application/index.ts b/x-pack/plugins/file_data_visualizer/public/application/index.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/index.ts diff --git a/x-pack/plugins/file_upload/public/application/kibana_context.ts b/x-pack/plugins/file_data_visualizer/public/application/kibana_context.ts similarity index 92% rename from x-pack/plugins/file_upload/public/application/kibana_context.ts rename to x-pack/plugins/file_data_visualizer/public/application/kibana_context.ts index 5ec378d7c6566..7426ca87009e6 100644 --- a/x-pack/plugins/file_upload/public/application/kibana_context.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/kibana_context.ts @@ -11,14 +11,14 @@ import type { SharePluginStart } from 'src/plugins/share/public'; import { useKibana, KibanaReactContextValue } from '../../../../../src/plugins/kibana_react/public'; import { SecurityPluginSetup } from '../../../security/public'; import type { EmbeddableStart } from '../../../../../src/plugins/embeddable/public'; -// import type { MapsStartApi } from '../../../maps/public'; +import type { MapsStartApi } from '../../../maps/public'; interface StartPlugins { data: DataPublicPluginStart; security?: SecurityPluginSetup; embeddable: EmbeddableStart; share: SharePluginStart; - // maps?: MapsStartApi; + maps?: MapsStartApi; } export type StartServices = CoreStart & StartPlugins; export const useFileUploadKibana = () => useKibana(); diff --git a/x-pack/plugins/file_upload/public/application/shared_imports.ts b/x-pack/plugins/file_data_visualizer/public/application/shared_imports.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/shared_imports.ts rename to x-pack/plugins/file_data_visualizer/public/application/shared_imports.ts diff --git a/x-pack/plugins/file_upload/public/application/util/field_types_utils.test.ts b/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.test.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/util/field_types_utils.test.ts rename to x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.test.ts diff --git a/x-pack/plugins/file_upload/public/application/util/field_types_utils.ts b/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/util/field_types_utils.ts rename to x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.ts diff --git a/x-pack/plugins/file_upload/public/application/util/util.ts b/x-pack/plugins/file_data_visualizer/public/application/util/util.ts similarity index 100% rename from x-pack/plugins/file_upload/public/application/util/util.ts rename to x-pack/plugins/file_data_visualizer/public/application/util/util.ts diff --git a/x-pack/plugins/file_data_visualizer/public/index.ts b/x-pack/plugins/file_data_visualizer/public/index.ts new file mode 100644 index 0000000000000..f56e02f1a6d0b --- /dev/null +++ b/x-pack/plugins/file_data_visualizer/public/index.ts @@ -0,0 +1,19 @@ +/* + * 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 { FileDataVisualizerPlugin } from './plugin'; + +export function plugin() { + return new FileDataVisualizerPlugin(); +} + +// export * from './importer/types'; + +// export { FileUploadPluginStart } from './plugin'; +// export { FileUploadComponentProps } from './lazy_load_bundle'; + +export { FileDataVisualizer } from './application'; diff --git a/x-pack/plugins/file_data_visualizer/public/kibana_services.ts b/x-pack/plugins/file_data_visualizer/public/kibana_services.ts new file mode 100644 index 0000000000000..368f58116931c --- /dev/null +++ b/x-pack/plugins/file_data_visualizer/public/kibana_services.ts @@ -0,0 +1,23 @@ +/* + * 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 { CoreStart } from 'kibana/public'; +import { FileDataVisualizerStartDependencies } from './plugin'; + +let coreStart: CoreStart; +let pluginsStart: FileDataVisualizerStartDependencies; +export function setStartServices(core: CoreStart, plugins: FileDataVisualizerStartDependencies) { + coreStart = core; + pluginsStart = plugins; +} + +export const getDocLinks = () => coreStart.docLinks; +export const getIndexPatternService = () => pluginsStart.data.indexPatterns; +export const getHttp = () => coreStart.http; +export const getSavedObjectsClient = () => coreStart.savedObjects.client; +export const getUiSettings = () => coreStart.uiSettings; +export const getFileUpload = () => pluginsStart.fileUpload; diff --git a/x-pack/plugins/file_data_visualizer/public/plugin.ts b/x-pack/plugins/file_data_visualizer/public/plugin.ts new file mode 100644 index 0000000000000..915123a26c925 --- /dev/null +++ b/x-pack/plugins/file_data_visualizer/public/plugin.ts @@ -0,0 +1,48 @@ +/* + * 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 { CoreStart } from 'kibana/public'; +import { Plugin } from '../../../../src/core/public'; +// import { +// FileDataVisualizerStartApi, +// getFileDataVisualizerComponent, +// importerFactory, +// hasImportPermission, +// analyzeFile, +// } from './api'; +import { setStartServices } from './kibana_services'; +import { DataPublicPluginStart } from '../../../../src/plugins/data/public'; +import type { FileUploadPluginStart } from '../../file_upload/public'; +// import { getMaxBytes, getMaxBytesFormatted } from './get_max_bytes'; + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface FileDataVisualizerSetupDependencies {} +// export interface FileDataVisualizerStartDependencies {} +export interface FileDataVisualizerStartDependencies { + data: DataPublicPluginStart; + fileUpload: FileUploadPluginStart; +} + +export type FileDataVisualizerPluginSetup = ReturnType; +export type FileDataVisualizerPluginStart = ReturnType; + +export class FileDataVisualizerPlugin + implements + Plugin< + FileDataVisualizerPluginSetup, + FileDataVisualizerPluginStart, + FileDataVisualizerSetupDependencies, + FileDataVisualizerStartDependencies + > { + public setup() {} + // public start() {} + + public start(core: CoreStart, plugins: FileDataVisualizerStartDependencies) { + setStartServices(core, plugins); + return {}; + } +} diff --git a/x-pack/plugins/file_data_visualizer/server/index.ts b/x-pack/plugins/file_data_visualizer/server/index.ts new file mode 100644 index 0000000000000..4d38bff8fa26f --- /dev/null +++ b/x-pack/plugins/file_data_visualizer/server/index.ts @@ -0,0 +1,12 @@ +/* + * 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 { PluginInitializerContext } from '../../../../src/core/server'; +import { FileUploadPlugin } from './plugin'; + +export const plugin = (initializerContext: PluginInitializerContext) => + new FileUploadPlugin(initializerContext); diff --git a/x-pack/plugins/file_data_visualizer/server/plugin.ts b/x-pack/plugins/file_data_visualizer/server/plugin.ts new file mode 100644 index 0000000000000..cfaa14c679ae5 --- /dev/null +++ b/x-pack/plugins/file_data_visualizer/server/plugin.ts @@ -0,0 +1,39 @@ +/* + * 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 { i18n } from '@kbn/i18n'; +import { + CoreSetup, + CoreStart, + /* Logger,*/ Plugin, + PluginInitializerContext, +} from 'src/core/server'; +// import { schema } from '@kbn/config-schema'; +// import { fileUploadRoutes } from './routes'; +// import { initFileUploadTelemetry } from './telemetry'; +import { UsageCollectionSetup } from '../../../../src/plugins/usage_collection/server'; +// import { UI_SETTING_MAX_FILE_SIZE, MAX_FILE_SIZE } from '../common'; +import { StartDeps } from './types'; + +interface SetupDeps { + usageCollection: UsageCollectionSetup; +} + +export class FileUploadPlugin implements Plugin { + // private readonly _logger: Logger; + + constructor(initializerContext: PluginInitializerContext) { + // this._logger = initializerContext.logger.get(); + } + + async setup(coreSetup: CoreSetup, plugins: SetupDeps) { + // fileUploadRoutes(coreSetup, this._logger); + // initFileUploadTelemetry(coreSetup, plugins.usageCollection); + } + + start(core: CoreStart) {} +} diff --git a/x-pack/plugins/file_data_visualizer/server/types.ts b/x-pack/plugins/file_data_visualizer/server/types.ts new file mode 100644 index 0000000000000..d23661ebae711 --- /dev/null +++ b/x-pack/plugins/file_data_visualizer/server/types.ts @@ -0,0 +1,12 @@ +/* + * 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 { SecurityPluginStart } from '../..//security/server'; + +export interface StartDeps { + security?: SecurityPluginStart; +} diff --git a/x-pack/plugins/file_data_visualizer/tsconfig.json b/x-pack/plugins/file_data_visualizer/tsconfig.json new file mode 100644 index 0000000000000..2d668bcaa2045 --- /dev/null +++ b/x-pack/plugins/file_data_visualizer/tsconfig.json @@ -0,0 +1,20 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outDir": "./target/types", + "emitDeclarationOnly": true, + "declaration": true, + "declarationMap": true + }, + "include": ["common/**/*", "public/**/*", "server/**/*"], + "references": [ + { "path": "../../../src/core/tsconfig.json" }, + { "path": "../../../src/plugins/data/tsconfig.json" }, + { "path": "../../../src/plugins/usage_collection/tsconfig.json" }, + { "path": "../security/tsconfig.json" }, + { "path": "../file_upload/tsconfig.json" }, + { "path": "../maps/tsconfig.json" }, + { "path": "../../../src/plugins/embeddable/tsconfig.json" }, + ] +} diff --git a/x-pack/plugins/file_upload/kibana.json b/x-pack/plugins/file_upload/kibana.json index 296fc36850ef0..d21f5ad5562a9 100644 --- a/x-pack/plugins/file_upload/kibana.json +++ b/x-pack/plugins/file_upload/kibana.json @@ -15,7 +15,6 @@ "security" ], "requiredBundles": [ - "esUiShared", "kibanaReact" ], "extraPublicDirs": [ diff --git a/x-pack/plugins/file_upload/public/api/index.ts b/x-pack/plugins/file_upload/public/api/index.ts index 141e8372fc7d1..9abc11eec096d 100644 --- a/x-pack/plugins/file_upload/public/api/index.ts +++ b/x-pack/plugins/file_upload/public/api/index.ts @@ -17,6 +17,12 @@ export interface FileUploadStartApi { getMaxBytesFormatted(): string; hasImportPermission(params: HasImportPermissionParams): Promise; analyzeFile(file: string, params: Record): Promise; + checkIndexExists(index: string, params: Record): Promise; + getTimeFieldRange( + index: string, + query: any, + timeFieldName?: string + ): Promise; } export interface GetTimeFieldRangeResponse { @@ -88,15 +94,7 @@ export async function checkIndexExists( }); } -export async function getTimeFieldRange({ - index, - timeFieldName, - query, -}: { - index: string; - timeFieldName?: string; - query: any; -}) { +export async function getTimeFieldRange(index: string, query: any, timeFieldName?: string) { const body = JSON.stringify({ index, timeFieldName, query }); const fileUploadModules = await lazyLoadFileUploadModules(); diff --git a/x-pack/plugins/file_upload/public/index.ts b/x-pack/plugins/file_upload/public/index.ts index c90c2975b6937..f1f1d00957d25 100644 --- a/x-pack/plugins/file_upload/public/index.ts +++ b/x-pack/plugins/file_upload/public/index.ts @@ -16,4 +16,4 @@ export * from './importer/types'; export { FileUploadPluginStart } from './plugin'; export { FileUploadComponentProps } from './lazy_load_bundle'; -export { FileDataVisualizer } from './application'; +export { getMaxBytes, getMaxBytesFormatted } from './get_max_bytes'; diff --git a/x-pack/plugins/file_upload/public/plugin.ts b/x-pack/plugins/file_upload/public/plugin.ts index 19fe78ad318fa..fefb0a05a46d3 100644 --- a/x-pack/plugins/file_upload/public/plugin.ts +++ b/x-pack/plugins/file_upload/public/plugin.ts @@ -12,6 +12,8 @@ import { importerFactory, hasImportPermission, analyzeFile, + checkIndexExists, + getTimeFieldRange, } from './api'; import { setStartServices } from './kibana_services'; import { DataPublicPluginStart } from '../../../../src/plugins/data/public'; @@ -45,6 +47,8 @@ export class FileUploadPlugin getMaxBytesFormatted, hasImportPermission, analyzeFile, + checkIndexExists, + getTimeFieldRange, }; } } diff --git a/x-pack/plugins/ml/kibana.json b/x-pack/plugins/ml/kibana.json index 4955c1af5674d..0334638bd9293 100644 --- a/x-pack/plugins/ml/kibana.json +++ b/x-pack/plugins/ml/kibana.json @@ -11,6 +11,7 @@ "cloud", "features", "fileUpload", + "fileDataVisualizer", "licensing", "share", "embeddable", diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx b/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx index c3adb6d357108..449ddbd3cd602 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx +++ b/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx @@ -12,14 +12,14 @@ import { useTimefilter } from '../../contexts/kibana'; import { NavigationMenu } from '../../components/navigation_menu'; import { HelpMenu } from '../../components/help_menu'; import { useMlKibana } from '../../contexts/kibana'; -import { FileDataVisualizer } from '../../../../../file_upload/public'; +import { FileDataVisualizer } from '../../../../../file_data_visualizer/public'; export const FileDataVisualizerPage: FC = () => { useTimefilter({ timeRangeSelector: false, autoRefreshSelector: false }); const { - services: { docLinks, data, embeddable, share, /* maps,*/ security, savedObjects }, + services: { docLinks, data, embeddable, share, maps, security, savedObjects, http }, } = useMlKibana(); - const coreStart = { savedObjects } as CoreStart; + const coreStart = { savedObjects, http } as CoreStart; const helpLink = docLinks.links.ml.guide; return ( @@ -29,7 +29,7 @@ export const FileDataVisualizerPage: FC = () => { data={data} embeddable={embeddable} share={share} - // maps={maps} + maps={maps} security={security} /> diff --git a/x-pack/plugins/ml/tsconfig.json b/x-pack/plugins/ml/tsconfig.json index 6b396b1c59642..b30e232ca5c59 100644 --- a/x-pack/plugins/ml/tsconfig.json +++ b/x-pack/plugins/ml/tsconfig.json @@ -25,6 +25,7 @@ { "path": "../cloud/tsconfig.json" }, { "path": "../features/tsconfig.json" }, { "path": "../file_upload/tsconfig.json" }, + { "path": "../file_data_visualizer/tsconfig.json" }, { "path": "../license_management/tsconfig.json" }, { "path": "../licensing/tsconfig.json" }, { "path": "../maps/tsconfig.json" }, From dee153b7a64d83808a689849fd386beb65f67a53 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Tue, 13 Apr 2021 13:43:53 +0100 Subject: [PATCH 12/37] enabling maps integration --- x-pack/plugins/file_data_visualizer/kibana.json | 3 ++- .../expanded_row/geo_point_content/geo_point_content.tsx | 4 ++-- .../public/application/components/ml_embedded_map/index.ts | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/file_data_visualizer/kibana.json b/x-pack/plugins/file_data_visualizer/kibana.json index dda2e41057572..c2ae95ab21b16 100644 --- a/x-pack/plugins/file_data_visualizer/kibana.json +++ b/x-pack/plugins/file_data_visualizer/kibana.json @@ -19,7 +19,8 @@ "requiredBundles": [ "esUiShared", "kibanaReact", - "fileUpload" + "fileUpload", + "maps" ], "extraPublicDirs": [ "common" diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/geo_point_content.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/geo_point_content.tsx index eb708db7c2ab5..499844bdee6da 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/geo_point_content.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/geo_point_content.tsx @@ -11,7 +11,7 @@ import { EuiFlexItem } from '@elastic/eui'; import { Feature, Point } from 'geojson'; import type { FieldDataRowProps } from '../../stats_table/types/field_data_row'; import { DocumentStatsTable } from '../../stats_table/components/field_data_expanded_row/document_stats'; -// import { MlEmbeddedMapComponent } from '../../ml_embedded_map'; +import { MlEmbeddedMapComponent } from '../../ml_embedded_map'; import { convertWKTGeoToLonLat, getGeoPointsLayer } from './format_utils'; import { ExpandedRowContent } from '../../stats_table/components/field_data_expanded_row/expanded_row_content'; import { ExamplesList } from '../../examples_list'; @@ -72,7 +72,7 @@ export const GeoPointContent: FC = ({ config }) => { className={'mlDataVisualizerMapWrapper'} data-test-subj={'mlDataVisualizerEmbeddedMap'} > - {/* */} + )} diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/index.ts index 6871cd6cce62a..3829e98450d73 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/index.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/index.ts @@ -5,4 +5,4 @@ * 2.0. */ -// export { MlEmbeddedMapComponent } from './ml_embedded_map'; +export { MlEmbeddedMapComponent } from './ml_embedded_map'; From 66c68406c4eaa6f49cea2b23adc91f24ceb4ed41 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Tue, 13 Apr 2021 16:14:18 +0100 Subject: [PATCH 13/37] cleaning up dependencies --- .../file_datavisualizer_view.js | 4 +-- .../filebeat_config_flyout.tsx | 4 +-- .../components/import_view/import_view.js | 10 +++---- .../ml_embedded_map/ml_embedded_map.tsx | 4 +-- .../results_links/results_links.tsx | 20 +++++++++---- .../stats_table/hooks/use_color_range.ts | 4 +-- .../application/file_datavisualizer.tsx | 30 ++++--------------- .../public/application/kibana_context.ts | 17 ++--------- .../file_data_visualizer/public/index.ts | 5 ---- .../public/kibana_services.ts | 8 ++--- .../file_data_visualizer/public/plugin.ts | 19 ++++++------ .../file_based/file_datavisualizer.tsx | 13 ++------ 12 files changed, 48 insertions(+), 90 deletions(-) diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_datavisualizer_view.js b/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_datavisualizer_view.js index 0663b5fc4bce4..8ff5e82ca384f 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_datavisualizer_view.js +++ b/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_datavisualizer_view.js @@ -22,7 +22,6 @@ import { ImportView } from '../import_view'; import { DEFAULT_LINES_TO_SAMPLE, readFile, createUrlOverrides, processResults } from '../utils'; import { getMaxBytes } from '../../../../../file_upload/public'; import { getApi } from '../../../api'; -import { getFileUpload } from '../../../kibana_services'; import { MODE } from './constants'; @@ -64,7 +63,7 @@ export class FileDataVisualizerView extends Component { // check the user has the correct permission to import data. // note, calling hasImportPermission with no arguments just checks the // cluster privileges, the user will still need index privileges to create and ingest - const hasPermissionToImport = await getFileUpload().hasImportPermission({ + const hasPermissionToImport = await this.props.fileUpload.hasImportPermission({ checkCreateIndexPattern: false, checkHasManagePipeline: true, }); @@ -352,6 +351,7 @@ export class FileDataVisualizerView extends Component { showBottomBar={this.showBottomBar} hideBottomBar={this.hideBottomBar} savedObjectsClient={this.savedObjectsClient} + fileUpload={this.props.fileUpload} /> {bottomBarVisible && ( diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/filebeat_config_flyout.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/filebeat_config_flyout.tsx index b106d527f24f9..41e5667b025ea 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/filebeat_config_flyout.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/filebeat_config_flyout.tsx @@ -22,7 +22,7 @@ import { EuiCopy, } from '@elastic/eui'; import { createFilebeatConfig } from './filebeat_config'; -import { useFileUploadKibana } from '../../kibana_context'; // copy context? +import { useFileDataVisualizerKibana } from '../../kibana_context'; // copy context? import { FindFileStructureResponse } from '../../../../common'; export enum EDITOR_MODE { @@ -48,7 +48,7 @@ export const FilebeatConfigFlyout: FC = ({ const [username, setUsername] = useState(null); const { services: { security }, - } = useFileUploadKibana(); + } = useFileDataVisualizerKibana(); useEffect(() => { if (security !== undefined) { diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/import_view/import_view.js b/x-pack/plugins/file_data_visualizer/public/application/components/import_view/import_view.js index 005f363b2a8f1..41fd054298c0e 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/import_view/import_view.js +++ b/x-pack/plugins/file_data_visualizer/public/application/components/import_view/import_view.js @@ -32,8 +32,6 @@ import { getDefaultCombinedFields, } from '../combined_fields'; import { ExperimentalBadge } from '../experimental_badge'; -// import { hasImportPermission, importerFactory, checkIndexExists } from '../../../api'; -import { getFileUpload } from '../../../kibana_services'; const DEFAULT_TIME_FIELD = '@timestamp'; const DEFAULT_INDEX_SETTINGS = { number_of_shards: 1 }; @@ -100,7 +98,7 @@ export class ImportView extends Component { // TODO - sort this function out. it's a mess async import() { - const { data, results, indexPatterns, showBottomBar } = this.props; + const { data, results, indexPatterns, showBottomBar, fileUpload } = this.props; const { format } = results; let { timeFieldName } = this.state; @@ -124,7 +122,7 @@ export class ImportView extends Component { async () => { // check to see if the user has permission to create and ingest data into the specified index if ( - (await getFileUpload().hasImportPermission({ + (await fileUpload.hasImportPermission({ checkCreateIndexPattern: createIndexPattern, checkHasManagePipeline: true, indexName: index, @@ -221,7 +219,7 @@ export class ImportView extends Component { } if (success) { - const importer = await getFileUpload().importerFactory(format, { + const importer = await fileUpload.importerFactory(format, { excludeLinesPattern: results.exclude_lines_pattern, multilineStartPattern: results.multiline_start_pattern, }); @@ -353,7 +351,7 @@ export class ImportView extends Component { return; } - const { exists } = await getFileUpload().checkIndexExists(index); + const { exists } = await this.props.fileUpload.checkIndexExists(index); const indexNameError = exists ? ( diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/results_links/results_links.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/results_links/results_links.tsx index b8c048589fa47..ba0173b0e5063 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/results_links/results_links.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/results_links/results_links.tsx @@ -14,8 +14,8 @@ import { DiscoverUrlGeneratorState, } from '../../../../../../../src/plugins/discover/public'; import { FindFileStructureResponse } from '../../../../common'; -import { useFileUploadKibana } from '../../kibana_context'; -import { getFileUpload } from '../../../kibana_services'; +import { useFileDataVisualizerKibana } from '../../kibana_context'; +import type { FileUploadPluginStart } from '../../../../../file_upload/public'; interface Props { fieldStats: FindFileStructureResponse['field_stats']; @@ -45,6 +45,10 @@ export const ResultsLinks: FC = ({ createIndexPattern, showFilebeatFlyout, }) => { + const { + services: { fileUpload }, + } = useFileDataVisualizerKibana(); + const [duration, setDuration] = useState({ from: 'now-30m', to: 'now', @@ -62,7 +66,7 @@ export const ResultsLinks: FC = ({ urlGenerators: { getUrlGenerator }, }, }, - } = useFileUploadKibana(); + } = useFileDataVisualizerKibana(); useEffect(() => { let unmounted = false; @@ -149,7 +153,7 @@ export const ResultsLinks: FC = ({ async function updateTimeValues(recheck = true) { if (timeFieldName !== undefined) { - const { from, to } = await getFullTimeRange(index, timeFieldName); + const { from, to } = await getFullTimeRange(index, timeFieldName, fileUpload); setDuration({ from: from === null ? duration.from : from, to: to === null ? duration.to : to, @@ -233,9 +237,13 @@ export const ResultsLinks: FC = ({ ); }; -async function getFullTimeRange(index: string, timeFieldName: string) { +async function getFullTimeRange( + index: string, + timeFieldName: string, + { getTimeFieldRange }: FileUploadPluginStart +) { const query = { bool: { must: [{ query_string: { analyze_wildcard: true, query: '*' } }] } }; - const resp = await getFileUpload().getTimeFieldRange(index, query, timeFieldName); + const resp = await getTimeFieldRange(index, query, timeFieldName); return { from: moment(resp.start.epoch).toISOString(), diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/use_color_range.ts b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/use_color_range.ts index bcc4a95d72006..e1ada072b00b3 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/use_color_range.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/use_color_range.ts @@ -12,7 +12,7 @@ import euiThemeDark from '@elastic/eui/dist/eui_theme_dark.json'; import { i18n } from '@kbn/i18n'; -import { useFileUploadKibana } from '../../../kibana_context'; +import { useFileDataVisualizerKibana } from '../../../kibana_context'; /** * Custom color scale factory that takes the amount of feature influencers @@ -196,7 +196,7 @@ export type EuiThemeType = typeof euiThemeLight | typeof euiThemeDark; export function useCurrentEuiTheme() { const { services: { uiSettings }, - } = useFileUploadKibana(); + } = useFileDataVisualizerKibana(); return useMemo( () => ({ euiTheme: uiSettings.get('theme:darkMode') ? euiThemeDark : euiThemeLight }), [uiSettings] diff --git a/x-pack/plugins/file_data_visualizer/public/application/file_datavisualizer.tsx b/x-pack/plugins/file_data_visualizer/public/application/file_datavisualizer.tsx index 48e30e99d91aa..ed26cc1376449 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/file_datavisualizer.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/file_datavisualizer.tsx @@ -6,35 +6,16 @@ */ import './_index.scss'; import React, { FC } from 'react'; -import { DataPublicPluginStart } from 'src/plugins/data/public'; -import { CoreStart } from 'kibana/public'; -import type { SharePluginStart } from 'src/plugins/share/public'; import { KibanaContextProvider } from '../../../../../src/plugins/kibana_react/public'; -import type { EmbeddableStart } from '../../../../../src/plugins/embeddable/public'; -import type { MapsStartApi } from '../../../maps/public'; -import { SecurityPluginSetup } from '../../../security/public'; +import { getCoreStart, getPluginsStart } from '../kibana_services'; // @ts-ignore import { FileDataVisualizerView } from './components/file_datavisualizer_view/index'; -export interface FileDataVisualizerProps { - data: DataPublicPluginStart; - embeddable?: EmbeddableStart; - maps?: MapsStartApi; - security?: SecurityPluginSetup; - coreStart: CoreStart; - share: SharePluginStart; -} - -export const FileDataVisualizer: FC = ({ - data, - embeddable, - maps, - security, - share, - coreStart, -}) => { - const services = { data, embeddable, share, maps, security, ...coreStart }; +export const FileDataVisualizer: FC = () => { + const coreStart = getCoreStart(); + const { data, maps, embeddable, share, security, fileUpload } = getPluginsStart(); + const services = { data, maps, embeddable, share, security, ...coreStart }; return ( @@ -42,6 +23,7 @@ export const FileDataVisualizer: FC = ({ indexPatterns={data.indexPatterns} savedObjectsClient={coreStart.savedObjects.client} http={coreStart.http} + fileUpload={fileUpload} /> ); diff --git a/x-pack/plugins/file_data_visualizer/public/application/kibana_context.ts b/x-pack/plugins/file_data_visualizer/public/application/kibana_context.ts index 7426ca87009e6..29c7cfe9bb553 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/kibana_context.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/kibana_context.ts @@ -5,21 +5,10 @@ * 2.0. */ -import { DataPublicPluginStart } from 'src/plugins/data/public'; import { CoreStart } from 'kibana/public'; -import type { SharePluginStart } from 'src/plugins/share/public'; import { useKibana, KibanaReactContextValue } from '../../../../../src/plugins/kibana_react/public'; -import { SecurityPluginSetup } from '../../../security/public'; -import type { EmbeddableStart } from '../../../../../src/plugins/embeddable/public'; -import type { MapsStartApi } from '../../../maps/public'; +import type { FileDataVisualizerStartDependencies } from '../plugin'; -interface StartPlugins { - data: DataPublicPluginStart; - security?: SecurityPluginSetup; - embeddable: EmbeddableStart; - share: SharePluginStart; - maps?: MapsStartApi; -} -export type StartServices = CoreStart & StartPlugins; -export const useFileUploadKibana = () => useKibana(); +export type StartServices = CoreStart & FileDataVisualizerStartDependencies; +export const useFileDataVisualizerKibana = () => useKibana(); export type MlKibanaReactContextValue = KibanaReactContextValue; diff --git a/x-pack/plugins/file_data_visualizer/public/index.ts b/x-pack/plugins/file_data_visualizer/public/index.ts index f56e02f1a6d0b..cca82e8e6702a 100644 --- a/x-pack/plugins/file_data_visualizer/public/index.ts +++ b/x-pack/plugins/file_data_visualizer/public/index.ts @@ -11,9 +11,4 @@ export function plugin() { return new FileDataVisualizerPlugin(); } -// export * from './importer/types'; - -// export { FileUploadPluginStart } from './plugin'; -// export { FileUploadComponentProps } from './lazy_load_bundle'; - export { FileDataVisualizer } from './application'; diff --git a/x-pack/plugins/file_data_visualizer/public/kibana_services.ts b/x-pack/plugins/file_data_visualizer/public/kibana_services.ts index 368f58116931c..6a5fe85c72477 100644 --- a/x-pack/plugins/file_data_visualizer/public/kibana_services.ts +++ b/x-pack/plugins/file_data_visualizer/public/kibana_services.ts @@ -15,9 +15,5 @@ export function setStartServices(core: CoreStart, plugins: FileDataVisualizerSta pluginsStart = plugins; } -export const getDocLinks = () => coreStart.docLinks; -export const getIndexPatternService = () => pluginsStart.data.indexPatterns; -export const getHttp = () => coreStart.http; -export const getSavedObjectsClient = () => coreStart.savedObjects.client; -export const getUiSettings = () => coreStart.uiSettings; -export const getFileUpload = () => pluginsStart.fileUpload; +export const getCoreStart = () => coreStart; +export const getPluginsStart = () => pluginsStart; diff --git a/x-pack/plugins/file_data_visualizer/public/plugin.ts b/x-pack/plugins/file_data_visualizer/public/plugin.ts index 915123a26c925..ff1dd03c9f99f 100644 --- a/x-pack/plugins/file_data_visualizer/public/plugin.ts +++ b/x-pack/plugins/file_data_visualizer/public/plugin.ts @@ -6,25 +6,25 @@ */ import { CoreStart } from 'kibana/public'; +import type { EmbeddableStart } from 'src/plugins/embeddable/public'; +import type { SharePluginStart } from 'src/plugins/share/public'; import { Plugin } from '../../../../src/core/public'; -// import { -// FileDataVisualizerStartApi, -// getFileDataVisualizerComponent, -// importerFactory, -// hasImportPermission, -// analyzeFile, -// } from './api'; + import { setStartServices } from './kibana_services'; import { DataPublicPluginStart } from '../../../../src/plugins/data/public'; import type { FileUploadPluginStart } from '../../file_upload/public'; -// import { getMaxBytes, getMaxBytesFormatted } from './get_max_bytes'; +import type { MapsStartApi } from '../../maps/public'; +import type { SecurityPluginSetup } from '../../security/public'; // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface FileDataVisualizerSetupDependencies {} -// export interface FileDataVisualizerStartDependencies {} export interface FileDataVisualizerStartDependencies { data: DataPublicPluginStart; fileUpload: FileUploadPluginStart; + maps: MapsStartApi; + embeddable: EmbeddableStart; + security?: SecurityPluginSetup; + share: SharePluginStart; } export type FileDataVisualizerPluginSetup = ReturnType; @@ -39,7 +39,6 @@ export class FileDataVisualizerPlugin FileDataVisualizerStartDependencies > { public setup() {} - // public start() {} public start(core: CoreStart, plugins: FileDataVisualizerStartDependencies) { setStartServices(core, plugins); diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx b/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx index 449ddbd3cd602..74a19961f7941 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx +++ b/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx @@ -6,7 +6,6 @@ */ import React, { FC, Fragment } from 'react'; -import type { CoreStart } from 'kibana/public'; import { useTimefilter } from '../../contexts/kibana'; import { NavigationMenu } from '../../components/navigation_menu'; @@ -17,21 +16,13 @@ import { FileDataVisualizer } from '../../../../../file_data_visualizer/public'; export const FileDataVisualizerPage: FC = () => { useTimefilter({ timeRangeSelector: false, autoRefreshSelector: false }); const { - services: { docLinks, data, embeddable, share, maps, security, savedObjects, http }, + services: { docLinks }, } = useMlKibana(); - const coreStart = { savedObjects, http } as CoreStart; const helpLink = docLinks.links.ml.guide; return ( - + ); From 21f6ce60f12b605498525647ed43a29c41e325c1 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Tue, 13 Apr 2021 16:47:29 +0100 Subject: [PATCH 14/37] fixing translation ids --- .../components/about_panel/about_panel.tsx | 4 +- .../about_panel/welcome_content.tsx | 18 ++-- .../analysis_summary/analysis_summary.tsx | 16 ++-- .../components/bottom_bar/bottom_bar.tsx | 10 +- .../combined_fields/combined_fields_form.tsx | 21 ++-- .../combined_fields_read_only_form.tsx | 4 +- .../components/combined_fields/geo_point.tsx | 17 ++-- .../components/combined_fields/utils.ts | 2 +- .../__snapshots__/overrides.test.js.snap | 8 +- .../components/edit_flyout/edit_flyout.js | 6 +- .../components/edit_flyout/overrides.js | 30 +++--- .../edit_flyout/overrides_validation.js | 8 +- .../examples_list/examples_list.tsx | 4 +- .../experimental_badge/experimental_badge.tsx | 2 +- .../explanation_flyout/explanation_flyout.tsx | 6 +- .../field_data_row/number_content_preview.tsx | 12 ++- .../field_names_filter/field_names_filter.tsx | 2 +- .../field_type_icon/field_type_icon.tsx | 2 +- .../field_types_filter/field_types_filter.tsx | 2 +- .../file_contents/file_contents.tsx | 4 +- .../file_datavisualizer_view.js | 2 +- .../file_error_callouts.tsx | 14 +-- .../filebeat_config_flyout/filebeat_config.ts | 2 +- .../filebeat_config_flyout.tsx | 14 +-- .../components/import_errors/errors.tsx | 20 ++-- .../import_progress/import_progress.tsx | 96 ++++++++++++------- .../components/import_settings/advanced.tsx | 23 +++-- .../import_settings/import_settings.tsx | 4 +- .../components/import_settings/simple.tsx | 15 +-- .../components/import_summary/failures.tsx | 2 +- .../import_summary/import_summary.tsx | 19 ++-- .../components/import_view/import_view.js | 24 ++--- .../multi_select_picker.tsx | 2 +- .../results_links/results_links.tsx | 8 +- .../components/results_view/results_view.tsx | 6 +- .../field_count_stats/metric_fields_count.tsx | 4 +- .../field_count_stats/total_fields_count.tsx | 4 +- .../boolean_content.tsx | 8 +- .../field_data_expanded_row/date_content.tsx | 6 +- .../document_stats.tsx | 8 +- .../number_content.tsx | 12 +-- .../field_data_expanded_row/text_content.tsx | 6 +- .../field_data_row/use_column_chart.tsx | 8 +- .../metric_distribution_chart.tsx | 2 +- ...tric_distribution_chart_tooltip_header.tsx | 4 +- .../data_visualizer_stats_table.tsx | 41 ++++---- .../stats_table/hooks/use_color_range.ts | 51 ++++++---- .../components/top_values/top_values.tsx | 4 +- .../application/util/field_types_utils.ts | 16 ++-- 49 files changed, 336 insertions(+), 267 deletions(-) diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/about_panel/about_panel.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/about_panel/about_panel.tsx index c8592179e18e3..e4f59c492fa1c 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/about_panel/about_panel.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/about_panel/about_panel.tsx @@ -43,7 +43,7 @@ export const AboutPanel: FC = ({ onFilePickerChange }) => { {

diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/about_panel/welcome_content.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/about_panel/welcome_content.tsx index 94e27caa20fe0..8df5557fa1c2f 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/about_panel/welcome_content.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/about_panel/welcome_content.tsx @@ -25,7 +25,7 @@ import { getMaxBytesFormatted } from '../../../../../file_upload/public'; export const WelcomeContent: FC = () => { const toolTipContent = i18n.translate( - 'xpack.fileUpload.welcomeContent.experimentalFeatureTooltip', + 'xpack.fileDataVisualizer.welcomeContent.experimentalFeatureTooltip', { defaultMessage: "Experimental feature. We'd love to hear your feedback.", } @@ -42,7 +42,7 @@ export const WelcomeContent: FC = () => {

, @@ -54,7 +54,7 @@ export const WelcomeContent: FC = () => {

@@ -64,7 +64,7 @@ export const WelcomeContent: FC = () => {

@@ -78,7 +78,7 @@ export const WelcomeContent: FC = () => {

@@ -94,7 +94,7 @@ export const WelcomeContent: FC = () => {

@@ -110,7 +110,7 @@ export const WelcomeContent: FC = () => {

@@ -121,7 +121,7 @@ export const WelcomeContent: FC = () => {

@@ -131,7 +131,7 @@ export const WelcomeContent: FC = () => {

= ({ re

@@ -37,7 +37,7 @@ function createDisplayItems(results: FindFileStructureResponse) { { title: ( ), @@ -53,7 +53,7 @@ function createDisplayItems(results: FindFileStructureResponse) { items.push({ title: ( ), @@ -64,7 +64,7 @@ function createDisplayItems(results: FindFileStructureResponse) { items.push({ title: ( ), @@ -74,7 +74,7 @@ function createDisplayItems(results: FindFileStructureResponse) { items.push({ title: ( ), @@ -87,7 +87,7 @@ function createDisplayItems(results: FindFileStructureResponse) { items.push({ title: ( ), @@ -99,7 +99,7 @@ function createDisplayItems(results: FindFileStructureResponse) { items.push({ title: ( ), @@ -111,7 +111,7 @@ function createDisplayItems(results: FindFileStructureResponse) { items.push({ title: ( = ({ mode, onChangeMode, onCancel, di content={ disableImport ? ( ) : null @@ -52,7 +52,7 @@ export const BottomBar: FC = ({ mode, onChangeMode, onCancel, di data-test-subj="mlFileDataVisOpenImportPageButton" > @@ -61,7 +61,7 @@ export const BottomBar: FC = ({ mode, onChangeMode, onCancel, di onCancel()}> @@ -76,7 +76,7 @@ export const BottomBar: FC = ({ mode, onChangeMode, onCancel, di onChangeMode(DATAVISUALIZER_MODE.READ)}> @@ -84,7 +84,7 @@ export const BottomBar: FC = ({ mode, onChangeMode, onCancel, di onCancel()}> diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/combined_fields_form.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/combined_fields_form.tsx index b16f3ec79323a..aef6bcfced3ff 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/combined_fields_form.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/combined_fields_form.tsx @@ -114,7 +114,7 @@ export class CombinedFieldsForm extends Component { return JSON.parse(this.props.mappingsString); } catch (error) { throw new Error( - i18n.translate('xpack.fileUpload.combinedFieldsForm.mappingsParseError', { + i18n.translate('xpack.fileDataVisualizer.combinedFieldsForm.mappingsParseError', { defaultMessage: 'Error parsing mappings: {error}', values: { error: error.message }, }) @@ -127,7 +127,7 @@ export class CombinedFieldsForm extends Component { return JSON.parse(this.props.pipelineString); } catch (error) { throw new Error( - i18n.translate('xpack.fileUpload.combinedFieldsForm.pipelineParseError', { + i18n.translate('xpack.fileDataVisualizer.combinedFieldsForm.pipelineParseError', { defaultMessage: 'Error parsing pipeline: {error}', values: { error: error.message }, }) @@ -153,7 +153,7 @@ export class CombinedFieldsForm extends Component { }; render() { - const geoPointLabel = i18n.translate('xpack.fileUpload.geoPointCombinedFieldLabel', { + const geoPointLabel = i18n.translate('xpack.fileDataVisualizer.geoPointCombinedFieldLabel', { defaultMessage: 'Add geo point field', }); const panels = [ @@ -180,7 +180,7 @@ export class CombinedFieldsForm extends Component { ]; return ( @@ -196,12 +196,15 @@ export class CombinedFieldsForm extends Component { iconType="trash" color="danger" onClick={this.removeCombinedField.bind(null, idx)} - title={i18n.translate('xpack.fileUpload.removeCombinedFieldsLabel', { - defaultMessage: 'Remove combined field', - })} - aria-label={i18n.translate('xpack.fileUpload.removeCombinedFieldsLabel', { + title={i18n.translate('xpack.fileDataVisualizer.removeCombinedFieldsLabel', { defaultMessage: 'Remove combined field', })} + aria-label={i18n.translate( + 'xpack.fileDataVisualizer.removeCombinedFieldsLabel', + { + defaultMessage: 'Remove combined field', + } + )} /> )} @@ -217,7 +220,7 @@ export class CombinedFieldsForm extends Component { isDisabled={this.props.isDisabled} > diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/combined_fields_read_only_form.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/combined_fields_read_only_form.tsx index 630ad746720fc..978383f8e5e10 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/combined_fields_read_only_form.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/combined_fields_read_only_form.tsx @@ -20,10 +20,10 @@ export function CombinedFieldsReadOnlyForm({ }) { return combinedFields.length ? ( diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/geo_point.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/geo_point.tsx index 1b8f2de644d5f..e2cf9916d6665 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/geo_point.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/geo_point.tsx @@ -119,7 +119,7 @@ export class GeoPointForm extends Component { return ( @@ -131,7 +131,7 @@ export class GeoPointForm extends Component { @@ -143,7 +143,7 @@ export class GeoPointForm extends Component { { value={this.state.geoPointField} onChange={this.onGeoPointFieldChange} isInvalid={this.state.geoPointFieldError !== ''} - aria-label={i18n.translate('xpack.fileUpload.geoPointForm.geoPointFieldAriaLabel', { - defaultMessage: 'Geo point field, required field', - })} + aria-label={i18n.translate( + 'xpack.fileDataVisualizer.geoPointForm.geoPointFieldAriaLabel', + { + defaultMessage: 'Geo point field, required field', + } + )} /> @@ -176,7 +179,7 @@ export class GeoPointForm extends Component { onClick={this.onSubmit} > diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/utils.ts b/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/utils.ts index 0527af9a8b225..1537521bb84a6 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/utils.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/utils.ts @@ -123,7 +123,7 @@ export function createGeoPointCombinedField( } export function getNameCollisionMsg(name: string) { - return i18n.translate('xpack.fileUpload.nameCollisionMsg', { + return i18n.translate('xpack.fileDataVisualizer.nameCollisionMsg', { defaultMessage: '"{name}" already exists, please provide a unique name', values: { name }, }); diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/__snapshots__/overrides.test.js.snap b/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/__snapshots__/overrides.test.js.snap index 18e63c7d6af05..00dd652457daf 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/__snapshots__/overrides.test.js.snap +++ b/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/__snapshots__/overrides.test.js.snap @@ -13,7 +13,7 @@ exports[`Overrides render overrides 1`] = ` label={ } @@ -33,7 +33,7 @@ exports[`Overrides render overrides 1`] = ` label={ } @@ -94,7 +94,7 @@ exports[`Overrides render overrides 1`] = ` label={ } @@ -335,7 +335,7 @@ exports[`Overrides render overrides 1`] = ` label={ } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/edit_flyout.js b/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/edit_flyout.js index 41a784c91a261..7cdee6f823bd6 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/edit_flyout.js +++ b/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/edit_flyout.js @@ -69,7 +69,7 @@ export class EditFlyout extends Component {

@@ -96,7 +96,7 @@ export class EditFlyout extends Component { @@ -108,7 +108,7 @@ export class EditFlyout extends Component { fill > diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/overrides.js b/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/overrides.js index 3a820bf5b9778..cb0839b335a97 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/overrides.js +++ b/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/overrides.js @@ -52,7 +52,7 @@ class OverridesUI extends Component { } linesToSampleErrors = i18n.translate( - 'xpack.fileUpload.editFlyout.overrides.linesToSampleErrorMessage', + 'xpack.fileDataVisualizer.editFlyout.overrides.linesToSampleErrorMessage', { defaultMessage: 'Value must be greater than {min} and less than or equal to {max}', values: { @@ -63,7 +63,7 @@ class OverridesUI extends Component { ); customTimestampFormatErrors = i18n.translate( - 'xpack.fileUpload.editFlyout.overrides.customTimestampFormatErrorMessage', + 'xpack.fileDataVisualizer.editFlyout.overrides.customTimestampFormatErrorMessage', { defaultMessage: `Timestamp format must be a combination of these Java date/time formats: yy, yyyy, M, MM, MMM, MMMM, d, dd, EEE, EEEE, H, HH, h, mm, ss, S through SSSSSSSSS, a, XX, XXX, zzz`, @@ -274,7 +274,7 @@ class OverridesUI extends Component { const timestampFormatHelp = ( - {i18n.translate('xpack.fileUpload.editFlyout.overrides.timestampFormatHelpText', { + {i18n.translate('xpack.fileDataVisualizer.editFlyout.overrides.timestampFormatHelpText', { defaultMessage: 'See more on accepted formats', })} @@ -288,7 +288,7 @@ class OverridesUI extends Component { isInvalid={linesToSampleValid === false} label={ } @@ -303,7 +303,7 @@ class OverridesUI extends Component { } @@ -321,7 +321,7 @@ class OverridesUI extends Component { } @@ -338,7 +338,7 @@ class OverridesUI extends Component { } @@ -350,7 +350,7 @@ class OverridesUI extends Component { } @@ -369,7 +369,7 @@ class OverridesUI extends Component { id={'hasHeaderRow'} label={ } @@ -383,7 +383,7 @@ class OverridesUI extends Component { id={'shouldTrimFields'} label={ } @@ -398,7 +398,7 @@ class OverridesUI extends Component { } @@ -415,7 +415,7 @@ class OverridesUI extends Component { helpText={timestampFormatHelp} label={ } @@ -434,7 +434,7 @@ class OverridesUI extends Component { isInvalid={timestampFormatValid === false} label={ } @@ -450,7 +450,7 @@ class OverridesUI extends Component { } @@ -480,7 +480,7 @@ class OverridesUI extends Component {

diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/overrides_validation.js b/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/overrides_validation.js index 1356f7dccf6a9..c833d55351b6d 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/overrides_validation.js +++ b/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/overrides_validation.js @@ -41,7 +41,7 @@ export function isTimestampFormatValid(timestampFormat) { if (timestampFormat.indexOf('?') >= 0) { result.isValid = false; result.errorMessage = i18n.translate( - 'xpack.fileUpload.editFlyout.overrides.timestampQuestionMarkValidationErrorMessage', + 'xpack.fileDataVisualizer.editFlyout.overrides.timestampQuestionMarkValidationErrorMessage', { defaultMessage: 'Timestamp format {timestampFormat} not supported because it contains a question mark character ({fieldPlaceholder})', @@ -86,7 +86,7 @@ export function isTimestampFormatValid(timestampFormat) { result.isValid = false; result.errorMessage = i18n.translate( - 'xpack.fileUpload.editFlyout.overrides.timestampLetterValidationErrorMessage', + 'xpack.fileDataVisualizer.editFlyout.overrides.timestampLetterValidationErrorMessage', { defaultMessage: 'Letter { length, plural, one { {lg} } other { group {lg} } } in {format} is not supported', @@ -101,7 +101,7 @@ export function isTimestampFormatValid(timestampFormat) { if (curChar === 'S') { // disable exceeds maximum line length error so i18n check passes result.errorMessage = i18n.translate( - 'xpack.fileUpload.editFlyout.overrides.timestampLetterSValidationErrorMessage', + 'xpack.fileDataVisualizer.editFlyout.overrides.timestampLetterSValidationErrorMessage', { defaultMessage: 'Letter { length, plural, one { {lg} } other { group {lg} } } in {format} is not supported because it is not preceded by ss and a separator from {sep}', // eslint-disable-line @@ -128,7 +128,7 @@ export function isTimestampFormatValid(timestampFormat) { if (prevLetterGroup == null) { result.isValid = false; result.errorMessage = i18n.translate( - 'xpack.fileUpload.editFlyout.overrides.timestampEmptyValidationErrorMessage', + 'xpack.fileDataVisualizer.editFlyout.overrides.timestampEmptyValidationErrorMessage', { defaultMessage: 'No time format letter groups in timestamp format {timestampFormat}', values: { diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/examples_list/examples_list.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/examples_list/examples_list.tsx index f02e853779b29..202562a3fa80d 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/examples_list/examples_list.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/examples_list/examples_list.tsx @@ -23,7 +23,7 @@ export const ExamplesList: FC = ({ examples }) => { if (examples.length === 0) { examplesContent = ( ); @@ -44,7 +44,7 @@ export const ExamplesList: FC = ({ examples }) => {
= ({ tooltipConte className="ml-experimental-badge" label={ } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/explanation_flyout/explanation_flyout.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/explanation_flyout/explanation_flyout.tsx index 4c89307d286d1..a7f6e86293966 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/explanation_flyout/explanation_flyout.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/explanation_flyout/explanation_flyout.tsx @@ -34,7 +34,7 @@ export const ExplanationFlyout: FC = ({ results, closeFlyout }) => {

@@ -48,7 +48,7 @@ export const ExplanationFlyout: FC = ({ results, closeFlyout }) => { @@ -63,7 +63,7 @@ const Content: FC<{ explanation: string[] }> = ({ explanation }) => ( <> diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/field_data_row/number_content_preview.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/field_data_row/number_content_preview.tsx index fb097de7c2f1d..c02976cdb3853 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/field_data_row/number_content_preview.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/field_data_row/number_content_preview.tsx @@ -24,20 +24,26 @@ export const FileBasedNumberContentPreview = ({ config }: { config: FileBasedFie - + - + diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/field_names_filter/field_names_filter.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/field_names_filter/field_names_filter.tsx index eb5b0fa48fe90..466722adc7179 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/field_names_filter/field_names_filter.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/field_names_filter/field_names_filter.tsx @@ -26,7 +26,7 @@ export const DataVisualizerFieldNamesFilter: FC = ({ }) => { const fieldNameTitle = useMemo( () => - i18n.translate('xpack.fileUpload.fieldNameSelect', { + i18n.translate('xpack.fileDataVisualizer.fieldNameSelect', { defaultMessage: 'Field name', }), [] diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/field_type_icon.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/field_type_icon.tsx index 3d066a121c693..9c7d32ccf45e6 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/field_type_icon.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/field_type_icon.tsx @@ -91,7 +91,7 @@ export const FieldTypeIcon: FC = ({ return ( = ({ }) => { const fieldNameTitle = useMemo( () => - i18n.translate('xpack.fileUpload.fieldTypeSelect', { + i18n.translate('xpack.fileDataVisualizer.fieldTypeSelect', { defaultMessage: 'Field type', }), [] diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/file_contents/file_contents.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/file_contents/file_contents.tsx index 46bab8c44df46..4b9ade182aa67 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/file_contents/file_contents.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/file_contents/file_contents.tsx @@ -31,7 +31,7 @@ export const FileContents: FC = ({ data, format, numberOfLines }) => {

@@ -39,7 +39,7 @@ export const FileContents: FC = ({ data, format, numberOfLines }) => {
), diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_error_callouts.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_error_callouts.tsx index c77805a3c0c60..732a8fa91b52c 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_error_callouts.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_error_callouts.tsx @@ -30,7 +30,7 @@ export const FileTooLarge: FC = ({ fileSize, maxFileSize }) = errorText = (

= ({ fileSize, maxFileSize }) = errorText = (

= ({ fileSize, maxFileSize }) = } @@ -91,7 +91,7 @@ export const FileCouldNotBeRead: FC = ({ } @@ -102,13 +102,13 @@ export const FileCouldNotBeRead: FC = ({ {loaded === false && ( <>
@@ -121,7 +121,7 @@ export const FileCouldNotBeRead: FC = ({ <> diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/filebeat_config.ts b/x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/filebeat_config.ts index f21138df10ac7..035ea592f7f7f 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/filebeat_config.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/filebeat_config.ts @@ -36,7 +36,7 @@ export function createFilebeatConfig( } function getPaths() { - const txt = i18n.translate('xpack.fileUpload.fileBeatConfig.paths', { + const txt = i18n.translate('xpack.fileDataVisualizer.fileBeatConfig.paths', { defaultMessage: 'add path to your files here', }); return [' paths:', ` - '<${txt}>'`]; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/filebeat_config_flyout.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/filebeat_config_flyout.tsx index 41e5667b025ea..d7c0c160d7bd9 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/filebeat_config_flyout.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/filebeat_config_flyout.tsx @@ -75,7 +75,7 @@ export const FilebeatConfigFlyout: FC = ({ @@ -85,7 +85,7 @@ export const FilebeatConfigFlyout: FC = ({ {(copy) => ( @@ -108,7 +108,7 @@ const Contents: FC<{

@@ -116,14 +116,14 @@ const Contents: FC<{

{index} }} />

filebeat.yml }} /> @@ -137,7 +137,7 @@ const Contents: FC<{

{username === null ? ( {''}, @@ -145,7 +145,7 @@ const Contents: FC<{ /> ) : ( {username}, diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/import_errors/errors.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/import_errors/errors.tsx index 719fcc8ba8001..5a6f78a1a3068 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/import_errors/errors.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/import_errors/errors.tsx @@ -38,56 +38,56 @@ function title(statuses: Statuses) { case statuses.readStatus: return ( ); case statuses.parseJSONStatus: return ( ); case statuses.indexCreatedStatus: return ( ); case statuses.ingestPipelineCreatedStatus: return ( ); case statuses.uploadStatus: return ( ); case statuses.indexPatternCreatedStatus: return ( ); case statuses.permissionCheckStatus: return ( ); default: return ( ); @@ -105,7 +105,7 @@ const ImportError: FC<{ error: any }> = ({ error }) => { id="more" buttonContent={ } @@ -151,7 +151,7 @@ function toString(error: any): ImportError { } return { - msg: i18n.translate('xpack.fileUpload.importErrors.unknownErrorMessage', { + msg: i18n.translate('xpack.fileDataVisualizer.importErrors.unknownErrorMessage', { defaultMessage: 'Unknown error', }), }; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/import_progress/import_progress.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/import_progress/import_progress.tsx index 44d3584e1262d..8296a4885bf2c 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/import_progress/import_progress.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/import_progress/import_progress.tsx @@ -79,23 +79,32 @@ export const ImportProgress: FC<{ statuses: Statuses }> = ({ statuses }) => { completedStep = 5; } - let processFileTitle = i18n.translate('xpack.fileUpload.importProgress.processFileTitle', { - defaultMessage: 'Process file', - }); - let createIndexTitle = i18n.translate('xpack.fileUpload.importProgress.createIndexTitle', { - defaultMessage: 'Create index', - }); + let processFileTitle = i18n.translate( + 'xpack.fileDataVisualizer.importProgress.processFileTitle', + { + defaultMessage: 'Process file', + } + ); + let createIndexTitle = i18n.translate( + 'xpack.fileDataVisualizer.importProgress.createIndexTitle', + { + defaultMessage: 'Create index', + } + ); let createIngestPipelineTitle = i18n.translate( - 'xpack.fileUpload.importProgress.createIngestPipelineTitle', + 'xpack.fileDataVisualizer.importProgress.createIngestPipelineTitle', { defaultMessage: 'Create ingest pipeline', } ); - let uploadingDataTitle = i18n.translate('xpack.fileUpload.importProgress.uploadDataTitle', { - defaultMessage: 'Upload data', - }); + let uploadingDataTitle = i18n.translate( + 'xpack.fileDataVisualizer.importProgress.uploadDataTitle', + { + defaultMessage: 'Upload data', + } + ); let createIndexPatternTitle = i18n.translate( - 'xpack.fileUpload.importProgress.createIndexPatternTitle', + 'xpack.fileDataVisualizer.importProgress.createIndexPatternTitle', { defaultMessage: 'Create index pattern', } @@ -104,7 +113,7 @@ export const ImportProgress: FC<{ statuses: Statuses }> = ({ statuses }) => { const creatingIndexStatus = (

@@ -113,41 +122,50 @@ export const ImportProgress: FC<{ statuses: Statuses }> = ({ statuses }) => { const creatingIndexAndIngestPipelineStatus = (

); if (completedStep >= 0) { - processFileTitle = i18n.translate('xpack.fileUpload.importProgress.processingFileTitle', { - defaultMessage: 'Processing file', - }); + processFileTitle = i18n.translate( + 'xpack.fileDataVisualizer.importProgress.processingFileTitle', + { + defaultMessage: 'Processing file', + } + ); statusInfo = (

); } if (completedStep >= 1) { - processFileTitle = i18n.translate('xpack.fileUpload.importProgress.fileProcessedTitle', { - defaultMessage: 'File processed', - }); - createIndexTitle = i18n.translate('xpack.fileUpload.importProgress.creatingIndexTitle', { - defaultMessage: 'Creating index', - }); + processFileTitle = i18n.translate( + 'xpack.fileDataVisualizer.importProgress.fileProcessedTitle', + { + defaultMessage: 'File processed', + } + ); + createIndexTitle = i18n.translate( + 'xpack.fileDataVisualizer.importProgress.creatingIndexTitle', + { + defaultMessage: 'Creating index', + } + ); statusInfo = createPipeline === true ? creatingIndexAndIngestPipelineStatus : creatingIndexStatus; } if (completedStep >= 2) { - createIndexTitle = i18n.translate('xpack.fileUpload.importProgress.indexCreatedTitle', { + createIndexTitle = i18n.translate('xpack.fileDataVisualizer.importProgress.indexCreatedTitle', { defaultMessage: 'Index created', }); createIngestPipelineTitle = i18n.translate( - 'xpack.fileUpload.importProgress.creatingIngestPipelineTitle', + 'xpack.fileDataVisualizer.importProgress.creatingIngestPipelineTitle', { defaultMessage: 'Creating ingest pipeline', } @@ -157,23 +175,29 @@ export const ImportProgress: FC<{ statuses: Statuses }> = ({ statuses }) => { } if (completedStep >= 3) { createIngestPipelineTitle = i18n.translate( - 'xpack.fileUpload.importProgress.ingestPipelineCreatedTitle', + 'xpack.fileDataVisualizer.importProgress.ingestPipelineCreatedTitle', { defaultMessage: 'Ingest pipeline created', } ); - uploadingDataTitle = i18n.translate('xpack.fileUpload.importProgress.uploadingDataTitle', { - defaultMessage: 'Uploading data', - }); + uploadingDataTitle = i18n.translate( + 'xpack.fileDataVisualizer.importProgress.uploadingDataTitle', + { + defaultMessage: 'Uploading data', + } + ); statusInfo = ; } if (completedStep >= 4) { - uploadingDataTitle = i18n.translate('xpack.fileUpload.importProgress.dataUploadedTitle', { - defaultMessage: 'Data uploaded', - }); + uploadingDataTitle = i18n.translate( + 'xpack.fileDataVisualizer.importProgress.dataUploadedTitle', + { + defaultMessage: 'Data uploaded', + } + ); if (createIndexPattern === true) { createIndexPatternTitle = i18n.translate( - 'xpack.fileUpload.importProgress.creatingIndexPatternTitle', + 'xpack.fileDataVisualizer.importProgress.creatingIndexPatternTitle', { defaultMessage: 'Creating index pattern', } @@ -181,7 +205,7 @@ export const ImportProgress: FC<{ statuses: Statuses }> = ({ statuses }) => { statusInfo = (

@@ -192,7 +216,7 @@ export const ImportProgress: FC<{ statuses: Statuses }> = ({ statuses }) => { } if (completedStep >= 5) { createIndexPatternTitle = i18n.translate( - 'xpack.fileUpload.importProgress.indexPatternCreatedTitle', + 'xpack.fileDataVisualizer.importProgress.indexPatternCreatedTitle', { defaultMessage: 'Index pattern created', } @@ -266,7 +290,7 @@ const UploadFunctionProgress: FC<{ progress: number }> = ({ progress }) => {

diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/advanced.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/advanced.tsx index b3671f8856095..fe0ce9e5fe9b9 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/advanced.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/advanced.tsx @@ -69,7 +69,7 @@ export const AdvancedSettings: FC = ({ } @@ -78,7 +78,7 @@ export const AdvancedSettings: FC = ({ > = ({ disabled={initialized === true} onChange={onIndexChange} isInvalid={indexNameError !== ''} - aria-label={i18n.translate('xpack.fileUpload.advancedImportSettings.indexNameAriaLabel', { - defaultMessage: 'Index name, required field', - })} + aria-label={i18n.translate( + 'xpack.fileDataVisualizer.advancedImportSettings.indexNameAriaLabel', + { + defaultMessage: 'Index name, required field', + } + )} /> @@ -99,7 +102,7 @@ export const AdvancedSettings: FC = ({ id="createIndexPattern" label={ } @@ -113,7 +116,7 @@ export const AdvancedSettings: FC = ({ } @@ -181,7 +184,7 @@ const IndexSettings: FC = ({ initialized, data, onChange }) => } @@ -206,7 +209,7 @@ const Mappings: FC = ({ initialized, data, onChange }) => { } @@ -231,7 +234,7 @@ const IngestPipeline: FC = ({ initialized, data, onChange }) => } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/import_settings.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/import_settings.tsx index 7544ed962d02e..6e1398de20407 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/import_settings.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/import_settings.tsx @@ -59,7 +59,7 @@ export const ImportSettings: FC = ({ const tabs = [ { id: 'simple-settings', - name: i18n.translate('xpack.fileUpload.importSettings.simpleTabName', { + name: i18n.translate('xpack.fileDataVisualizer.importSettings.simpleTabName', { defaultMessage: 'Simple', }), content: ( @@ -80,7 +80,7 @@ export const ImportSettings: FC = ({ }, { id: 'advanced-settings', - name: i18n.translate('xpack.fileUpload.importSettings.advancedTabName', { + name: i18n.translate('xpack.fileDataVisualizer.importSettings.advancedTabName', { defaultMessage: 'Advanced', }), content: ( diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/simple.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/simple.tsx index 1014820775e3c..2751b37cd3256 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/simple.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/simple.tsx @@ -36,7 +36,7 @@ export const SimpleSettings: FC = ({ } @@ -45,7 +45,7 @@ export const SimpleSettings: FC = ({ > = ({ disabled={initialized === true} onChange={onIndexChange} isInvalid={indexNameError !== ''} - aria-label={i18n.translate('xpack.fileUpload.simpleImportSettings.indexNameAriaLabel', { - defaultMessage: 'Index name, required field', - })} + aria-label={i18n.translate( + 'xpack.fileDataVisualizer.simpleImportSettings.indexNameAriaLabel', + { + defaultMessage: 'Index name, required field', + } + )} data-test-subj="mlFileDataVisIndexNameInput" /> @@ -67,7 +70,7 @@ export const SimpleSettings: FC = ({ id="createIndexPattern" label={ } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/import_summary/failures.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/import_summary/failures.tsx index 41c1afa89f711..c8f62021b7bae 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/import_summary/failures.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/import_summary/failures.tsx @@ -51,7 +51,7 @@ export class Failures extends Component { id="failureList" buttonContent={ } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/import_summary/import_summary.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/import_summary/import_summary.tsx index 04dd657c833cd..f981b1fdf9f23 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/import_summary/import_summary.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/import_summary/import_summary.tsx @@ -45,7 +45,7 @@ export const ImportSummary: FC = ({ } @@ -62,7 +62,7 @@ export const ImportSummary: FC = ({ } @@ -71,7 +71,7 @@ export const ImportSummary: FC = ({ >

+ ), description: index, }, { title: ( ), @@ -120,7 +123,7 @@ function createDisplayItems( items.splice(1, 0, { title: ( ), @@ -132,7 +135,7 @@ function createDisplayItems( items.splice(1, 0, { title: ( ), @@ -144,7 +147,7 @@ function createDisplayItems( items.push({ title: ( ), diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/import_view/import_view.js b/x-pack/plugins/file_data_visualizer/public/application/components/import_view/import_view.js index 41fd054298c0e..d93756e6d03c4 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/import_view/import_view.js +++ b/x-pack/plugins/file_data_visualizer/public/application/components/import_view/import_view.js @@ -129,7 +129,7 @@ export class ImportView extends Component { })) === false ) { errors.push( - i18n.translate('xpack.fileUpload.importView.importPermissionError', { + i18n.translate('xpack.fileDataVisualizer.importView.importPermissionError', { defaultMessage: 'You do not have permission to create or import data into index {index}.', values: { @@ -169,7 +169,7 @@ export class ImportView extends Component { } catch (error) { success = false; const parseError = i18n.translate( - 'xpack.fileUpload.importView.parseSettingsError', + 'xpack.fileDataVisualizer.importView.parseSettingsError', { defaultMessage: 'Error parsing settings:', } @@ -182,7 +182,7 @@ export class ImportView extends Component { } catch (error) { success = false; const parseError = i18n.translate( - 'xpack.fileUpload.importView.parseMappingsError', + 'xpack.fileDataVisualizer.importView.parseMappingsError', { defaultMessage: 'Error parsing mappings:', } @@ -197,7 +197,7 @@ export class ImportView extends Component { } catch (error) { success = false; const parseError = i18n.translate( - 'xpack.fileUpload.importView.parsePipelineError', + 'xpack.fileDataVisualizer.importView.parsePipelineError', { defaultMessage: 'Error parsing ingest pipeline:', } @@ -354,7 +354,7 @@ export class ImportView extends Component { const { exists } = await this.props.fileUpload.checkIndexExists(index); const indexNameError = exists ? ( ) : ( @@ -507,14 +507,14 @@ export class ImportView extends Component {

  } @@ -555,7 +555,7 @@ export class ImportView extends Component { data-test-subj="mlFileDataVisImportButton" > @@ -564,7 +564,7 @@ export class ImportView extends Component { {initialized === true && importing === false && ( @@ -696,7 +696,7 @@ function isIndexNameValid(name) { ) { return ( ); @@ -713,7 +713,7 @@ function isIndexPatternNameValid(name, indexPatternNames, index) { if (indexPatternNames.find((i) => i === name)) { return ( ); @@ -729,7 +729,7 @@ function isIndexPatternNameValid(name, indexPatternNames, index) { // name should match index return ( ); diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/multi_select_picker/multi_select_picker.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/multi_select_picker/multi_select_picker.tsx index 7fe7fc88cd9d7..2093b61a7ef4d 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/multi_select_picker/multi_select_picker.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/multi_select_picker/multi_select_picker.tsx @@ -32,7 +32,7 @@ const NoFilterItems = () => {

diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/results_links/results_links.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/results_links/results_links.tsx index ba0173b0e5063..57932cafec061 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/results_links/results_links.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/results_links/results_links.tsx @@ -179,7 +179,7 @@ export const ResultsLinks: FC = ({ icon={} title={ } @@ -195,7 +195,7 @@ export const ResultsLinks: FC = ({ icon={} title={ } @@ -211,7 +211,7 @@ export const ResultsLinks: FC = ({ icon={} title={ } @@ -225,7 +225,7 @@ export const ResultsLinks: FC = ({ icon={} title={ } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/results_view/results_view.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/results_view/results_view.tsx index 40363b0225d90..907f9ae638a84 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/results_view/results_view.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/results_view/results_view.tsx @@ -72,7 +72,7 @@ export const ResultsView: FC = ({ showEditFlyout()} disabled={disableButtons}> @@ -80,7 +80,7 @@ export const ResultsView: FC = ({ showExplanationFlyout()} disabled={disableButtons}> @@ -94,7 +94,7 @@ export const ResultsView: FC = ({

diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/metric_fields_count.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/metric_fields_count.tsx index 14b564b5272ca..436063ce3007c 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/metric_fields_count.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/metric_fields_count.tsx @@ -37,7 +37,7 @@ export const MetricFieldsCount: FC = ({ metricsStats })
@@ -55,7 +55,7 @@ export const MetricFieldsCount: FC = ({ metricsStats }) diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/total_fields_count.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/total_fields_count.tsx index 20e742e9a3c2f..cc27cda69eda7 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/total_fields_count.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/total_fields_count.tsx @@ -37,7 +37,7 @@ export const TotalFieldsCount: FC = ({ fieldsCountStats }
@@ -56,7 +56,7 @@ export const TotalFieldsCount: FC = ({ fieldsCountStats } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/boolean_content.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/boolean_content.tsx index 2624d750ede6e..3f7ebb9d55849 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/boolean_content.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/boolean_content.tsx @@ -49,7 +49,7 @@ export const BooleanContent: FC = ({ config }) => { function: 'true', display: ( ), @@ -59,7 +59,7 @@ export const BooleanContent: FC = ({ config }) => { function: 'false', display: ( ), @@ -80,7 +80,7 @@ export const BooleanContent: FC = ({ config }) => { ]; const summaryTableTitle = i18n.translate( - 'xpack.fileUpload.fieldDataCardExpandedRow.booleanContent.summaryTableTitle', + 'xpack.fileDataVisualizer.fieldDataCardExpandedRow.booleanContent.summaryTableTitle', { defaultMessage: 'Summary', } @@ -104,7 +104,7 @@ export const BooleanContent: FC = ({ config }) => { diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/date_content.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/date_content.tsx index 2274d8189b1c0..b0e5af05cd95d 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/date_content.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/date_content.tsx @@ -30,7 +30,7 @@ export const DateContent: FC = ({ config }) => { const { earliest, latest } = stats; const summaryTableTitle = i18n.translate( - 'xpack.fileUpload.fieldDataCard.cardDate.summaryTableTitle', + 'xpack.fileDataVisualizer.fieldDataCard.cardDate.summaryTableTitle', { defaultMessage: 'Summary', } @@ -40,7 +40,7 @@ export const DateContent: FC = ({ config }) => { function: 'earliest', display: ( ), @@ -50,7 +50,7 @@ export const DateContent: FC = ({ config }) => { function: 'latest', display: ( ), diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/document_stats.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/document_stats.tsx index b8436eac79eb3..f0ebe741df6f7 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/document_stats.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/document_stats.tsx @@ -27,7 +27,7 @@ const metaTableColumns = [ ]; const metaTableTitle = i18n.translate( - 'xpack.fileUpload.fieldDataCardExpandedRow.documentStatsTable.metaTableTitle', + 'xpack.fileDataVisualizer.fieldDataCardExpandedRow.documentStatsTable.metaTableTitle', { defaultMessage: 'Documents stats', } @@ -47,7 +47,7 @@ export const DocumentStatsTable: FC = ({ config }) => { function: 'count', display: ( ), @@ -57,7 +57,7 @@ export const DocumentStatsTable: FC = ({ config }) => { function: 'percentage', display: ( ), @@ -67,7 +67,7 @@ export const DocumentStatsTable: FC = ({ config }) => { function: 'distinctValues', display: ( ), diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/number_content.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/number_content.tsx index ec9ffa53a4769..facba323a844e 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/number_content.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/number_content.tsx @@ -52,7 +52,7 @@ export const NumberContent: FC = ({ config }) => { function: 'min', display: ( ), @@ -62,7 +62,7 @@ export const NumberContent: FC = ({ config }) => { function: 'median', display: ( ), @@ -72,7 +72,7 @@ export const NumberContent: FC = ({ config }) => { function: 'max', display: ( ), @@ -93,7 +93,7 @@ export const NumberContent: FC = ({ config }) => { ]; const summaryTableTitle = i18n.translate( - 'xpack.fileUpload.fieldDataCardExpandedRow.numberContent.summaryTableTitle', + 'xpack.fileDataVisualizer.fieldDataCardExpandedRow.numberContent.summaryTableTitle', { defaultMessage: 'Summary', } @@ -121,7 +121,7 @@ export const NumberContent: FC = ({ config }) => { @@ -138,7 +138,7 @@ export const NumberContent: FC = ({ config }) => { = ({ config }) => { = ({ config }) => { iconType="alert" > _source, @@ -51,7 +51,7 @@ export const TextContent: FC = ({ config }) => { copy_to, diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx index dd73fdb5ea4c9..436f740bee41f 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx @@ -81,13 +81,13 @@ export const getLegendText = ( maxChartColumns = MAX_CHART_COLUMNS ): LegendText => { if (chartData.type === 'unsupported') { - return i18n.translate('xpack.fileUpload.dataGridChart.histogramNotAvailable', { + return i18n.translate('xpack.fileDataVisualizer.dataGridChart.histogramNotAvailable', { defaultMessage: 'Chart not supported.', }); } if (chartData.data.length === 0) { - return i18n.translate('xpack.fileUpload.dataGridChart.notEnoughData', { + return i18n.translate('xpack.fileDataVisualizer.dataGridChart.notEnoughData', { defaultMessage: `0 documents contain field.`, }); } @@ -106,14 +106,14 @@ export const getLegendText = ( } if (isOrdinalChartData(chartData) && chartData.cardinality <= maxChartColumns) { - return i18n.translate('xpack.fileUpload.dataGridChart.singleCategoryLegend', { + return i18n.translate('xpack.fileDataVisualizer.dataGridChart.singleCategoryLegend', { defaultMessage: `{cardinality, plural, one {# category} other {# categories}}`, values: { cardinality: chartData.cardinality }, }); } if (isOrdinalChartData(chartData) && chartData.cardinality > maxChartColumns) { - return i18n.translate('xpack.fileUpload.dataGridChart.topCategoriesLegend', { + return i18n.translate('xpack.fileDataVisualizer.dataGridChart.topCategoriesLegend', { defaultMessage: `top {maxChartColumns} of {cardinality} categories`, values: { cardinality: chartData.cardinality, maxChartColumns }, }); diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart.tsx index 3394d7de95a63..caa560488d499 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart.tsx @@ -58,7 +58,7 @@ export const MetricDistributionChart: FC = ({ // Ideally we wouldn't show these values at all in the tooltip, // but this is not yet possible with Elastic charts. const seriesName = i18n.translate( - 'xpack.fileUpload.fieldDataCard.metricDistributionChart.seriesName', + 'xpack.fileDataVisualizer.fieldDataCard.metricDistributionChart.seriesName', { defaultMessage: 'distribution', } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart_tooltip_header.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart_tooltip_header.tsx index 2259e31f9e370..9fd613ac96b8e 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart_tooltip_header.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart_tooltip_header.tsx @@ -31,7 +31,7 @@ export const MetricDistributionChartTooltipHeader: FC = ({
{chartPoint.dataMax > chartPoint.dataMin ? ( = ({ /> ) : ( ({ aria-label={ !expandAll ? i18n.translate( - 'xpack.fileUpload.datavisualizer.dataGrid.expandDetailsForAllAriaLabel', + 'xpack.fileDataVisualizer.datavisualizer.dataGrid.expandDetailsForAllAriaLabel', { defaultMessage: 'Expand details for all fields', } ) : i18n.translate( - 'xpack.fileUpload.datavisualizer.dataGrid.collapseDetailsForAllAriaLabel', + 'xpack.fileDataVisualizer.datavisualizer.dataGrid.collapseDetailsForAllAriaLabel', { defaultMessage: 'Collapse details for all fields', } @@ -123,11 +123,11 @@ export const DataVisualizerTable = ({ onClick={() => toggleDetails(item)} aria-label={ expandedRowItemIds.includes(item.fieldName) - ? i18n.translate('xpack.fileUpload.datavisualizer.dataGrid.rowCollapse', { + ? i18n.translate('xpack.fileDataVisualizer.datavisualizer.dataGrid.rowCollapse', { defaultMessage: 'Hide details for {fieldName}', values: { fieldName: item.fieldName }, }) - : i18n.translate('xpack.fileUpload.datavisualizer.dataGrid.rowExpand', { + : i18n.translate('xpack.fileDataVisualizer.datavisualizer.dataGrid.rowExpand', { defaultMessage: 'Show details for {fieldName}', values: { fieldName: item.fieldName }, }) @@ -143,7 +143,7 @@ export const DataVisualizerTable = ({ expanderColumn, { field: 'type', - name: i18n.translate('xpack.fileUpload.datavisualizer.dataGrid.typeColumnName', { + name: i18n.translate('xpack.fileDataVisualizer.datavisualizer.dataGrid.typeColumnName', { defaultMessage: 'Type', }), render: (fieldType: MlJobFieldType) => { @@ -156,7 +156,7 @@ export const DataVisualizerTable = ({ }, { field: 'fieldName', - name: i18n.translate('xpack.fileUpload.datavisualizer.dataGrid.nameColumnName', { + name: i18n.translate('xpack.fileDataVisualizer.datavisualizer.dataGrid.nameColumnName', { defaultMessage: 'Name', }), sortable: true, @@ -171,9 +171,12 @@ export const DataVisualizerTable = ({ }, { field: 'docCount', - name: i18n.translate('xpack.fileUpload.datavisualizer.dataGrid.documentsCountColumnName', { - defaultMessage: 'Documents (%)', - }), + name: i18n.translate( + 'xpack.fileDataVisualizer.datavisualizer.dataGrid.documentsCountColumnName', + { + defaultMessage: 'Documents (%)', + } + ), render: (value: number | undefined, item: DataVisualizerTableItem) => ( ), @@ -183,9 +186,12 @@ export const DataVisualizerTable = ({ }, { field: 'stats.cardinality', - name: i18n.translate('xpack.fileUpload.datavisualizer.dataGrid.distinctValuesColumnName', { - defaultMessage: 'Distinct values', - }), + name: i18n.translate( + 'xpack.fileDataVisualizer.datavisualizer.dataGrid.distinctValuesColumnName', + { + defaultMessage: 'Distinct values', + } + ), render: (cardinality?: number) => , sortable: true, align: LEFT_ALIGNMENT as HorizontalAlignment, @@ -195,16 +201,19 @@ export const DataVisualizerTable = ({ name: (
- {i18n.translate('xpack.fileUpload.datavisualizer.dataGrid.distributionsColumnName', { - defaultMessage: 'Distributions', - })} + {i18n.translate( + 'xpack.fileDataVisualizer.datavisualizer.dataGrid.distributionsColumnName', + { + defaultMessage: 'Distributions', + } + )} toggleShowDistribution()} aria-label={i18n.translate( - 'xpack.fileUpload.datavisualizer.dataGrid.showDistributionsAriaLabel', + 'xpack.fileDataVisualizer.datavisualizer.dataGrid.showDistributionsAriaLabel', { defaultMessage: 'Show distributions', } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/use_color_range.ts b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/use_color_range.ts index e1ada072b00b3..e24134507e3a9 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/use_color_range.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/use_color_range.ts @@ -51,19 +51,22 @@ export enum COLOR_RANGE_SCALE { export const colorRangeScaleOptions = [ { value: COLOR_RANGE_SCALE.LINEAR, - text: i18n.translate('xpack.fileUpload.components.colorRangeLegend.linearScaleLabel', { + text: i18n.translate('xpack.fileDataVisualizer.components.colorRangeLegend.linearScaleLabel', { defaultMessage: 'Linear', }), }, { value: COLOR_RANGE_SCALE.INFLUENCER, - text: i18n.translate('xpack.fileUpload.components.colorRangeLegend.influencerScaleLabel', { - defaultMessage: 'Influencer custom scale', - }), + text: i18n.translate( + 'xpack.fileDataVisualizer.components.colorRangeLegend.influencerScaleLabel', + { + defaultMessage: 'Influencer custom scale', + } + ), }, { value: COLOR_RANGE_SCALE.SQRT, - text: i18n.translate('xpack.fileUpload.components.colorRangeLegend.sqrtScaleLabel', { + text: i18n.translate('xpack.fileDataVisualizer.components.colorRangeLegend.sqrtScaleLabel', { defaultMessage: 'Sqrt', }), }, @@ -83,32 +86,44 @@ export enum COLOR_RANGE { export const colorRangeOptions = [ { value: COLOR_RANGE.BLUE, - text: i18n.translate('xpack.fileUpload.components.colorRangeLegend.blueColorRangeLabel', { - defaultMessage: 'Blue', - }), + text: i18n.translate( + 'xpack.fileDataVisualizer.components.colorRangeLegend.blueColorRangeLabel', + { + defaultMessage: 'Blue', + } + ), }, { value: COLOR_RANGE.RED, - text: i18n.translate('xpack.fileUpload.components.colorRangeLegend.redColorRangeLabel', { - defaultMessage: 'Red', - }), + text: i18n.translate( + 'xpack.fileDataVisualizer.components.colorRangeLegend.redColorRangeLabel', + { + defaultMessage: 'Red', + } + ), }, { value: COLOR_RANGE.RED_GREEN, - text: i18n.translate('xpack.fileUpload.components.colorRangeLegend.redGreenColorRangeLabel', { - defaultMessage: 'Red - Green', - }), + text: i18n.translate( + 'xpack.fileDataVisualizer.components.colorRangeLegend.redGreenColorRangeLabel', + { + defaultMessage: 'Red - Green', + } + ), }, { value: COLOR_RANGE.GREEN_RED, - text: i18n.translate('xpack.fileUpload.components.colorRangeLegend.greenRedColorRangeLabel', { - defaultMessage: 'Green - Red', - }), + text: i18n.translate( + 'xpack.fileDataVisualizer.components.colorRangeLegend.greenRedColorRangeLabel', + { + defaultMessage: 'Green - Red', + } + ), }, { value: COLOR_RANGE.YELLOW_GREEN_BLUE, text: i18n.translate( - 'xpack.fileUpload.components.colorRangeLegend.yellowGreenBlueColorRangeLabel', + 'xpack.fileDataVisualizer.components.colorRangeLegend.yellowGreenBlueColorRangeLabel', { defaultMessage: 'Yellow - Green - Blue', } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/top_values/top_values.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/top_values/top_values.tsx index 8b98dc250e125..6b7323146f479 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/top_values/top_values.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/top_values/top_values.tsx @@ -52,7 +52,7 @@ export const TopValues: FC = ({ stats, fieldFormat, barColor, compressed @@ -100,7 +100,7 @@ export const TopValues: FC = ({ stats, fieldFormat, barColor, compressed Date: Tue, 13 Apr 2021 17:41:06 +0100 Subject: [PATCH 15/37] moving analyze file endpoint out of file upload plugin --- .../file_data_visualizer/public/api/index.ts | 2 +- .../server/analyze_file.tsx | 0 .../server/error_wrapper.ts | 24 ++++++++ .../file_data_visualizer/server/index.ts | 4 +- .../file_data_visualizer/server/plugin.ts | 6 +- .../file_data_visualizer/server/routes.ts | 60 +++++++++++++++++++ .../file_data_visualizer/server/schemas.ts | 25 ++++++++ .../plugins/file_upload/public/api/index.ts | 15 ----- x-pack/plugins/file_upload/public/plugin.ts | 2 - x-pack/plugins/file_upload/server/routes.ts | 41 +------------ x-pack/plugins/file_upload/server/schemas.ts | 17 ------ 11 files changed, 116 insertions(+), 80 deletions(-) rename x-pack/plugins/{file_upload => file_data_visualizer}/server/analyze_file.tsx (100%) create mode 100644 x-pack/plugins/file_data_visualizer/server/error_wrapper.ts create mode 100644 x-pack/plugins/file_data_visualizer/server/routes.ts create mode 100644 x-pack/plugins/file_data_visualizer/server/schemas.ts diff --git a/x-pack/plugins/file_data_visualizer/public/api/index.ts b/x-pack/plugins/file_data_visualizer/public/api/index.ts index ee9e50c98725d..6b890a1cc5919 100644 --- a/x-pack/plugins/file_data_visualizer/public/api/index.ts +++ b/x-pack/plugins/file_data_visualizer/public/api/index.ts @@ -19,7 +19,7 @@ export function getApi(http: HttpStart) { async function analyzeFile(file: string, params: Record = {}): Promise { const body = JSON.stringify(file); return await http.fetch({ - path: `/internal/file_upload/analyze_file`, + path: `/internal/file_data_visualizer/analyze_file`, method: 'POST', body, query: params, diff --git a/x-pack/plugins/file_upload/server/analyze_file.tsx b/x-pack/plugins/file_data_visualizer/server/analyze_file.tsx similarity index 100% rename from x-pack/plugins/file_upload/server/analyze_file.tsx rename to x-pack/plugins/file_data_visualizer/server/analyze_file.tsx diff --git a/x-pack/plugins/file_data_visualizer/server/error_wrapper.ts b/x-pack/plugins/file_data_visualizer/server/error_wrapper.ts new file mode 100644 index 0000000000000..64395f601f9ac --- /dev/null +++ b/x-pack/plugins/file_data_visualizer/server/error_wrapper.ts @@ -0,0 +1,24 @@ +/* + * 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 { boomify, isBoom } from '@hapi/boom'; +import { ResponseError, CustomHttpResponseOptions } from 'kibana/server'; + +export function wrapError(error: any): CustomHttpResponseOptions { + const boom = isBoom(error) + ? error + : boomify(error, { statusCode: error.status ?? error.statusCode }); + const statusCode = boom.output.statusCode; + return { + body: { + message: boom, + ...(statusCode !== 500 && error.body ? { attributes: { body: error.body } } : {}), + }, + headers: boom.output.headers as { [key: string]: string }, + statusCode, + }; +} diff --git a/x-pack/plugins/file_data_visualizer/server/index.ts b/x-pack/plugins/file_data_visualizer/server/index.ts index 4d38bff8fa26f..a943773117c09 100644 --- a/x-pack/plugins/file_data_visualizer/server/index.ts +++ b/x-pack/plugins/file_data_visualizer/server/index.ts @@ -6,7 +6,7 @@ */ import { PluginInitializerContext } from '../../../../src/core/server'; -import { FileUploadPlugin } from './plugin'; +import { FileDataVisualizerPlugin } from './plugin'; export const plugin = (initializerContext: PluginInitializerContext) => - new FileUploadPlugin(initializerContext); + new FileDataVisualizerPlugin(initializerContext); diff --git a/x-pack/plugins/file_data_visualizer/server/plugin.ts b/x-pack/plugins/file_data_visualizer/server/plugin.ts index cfaa14c679ae5..bb8bc13bdabb2 100644 --- a/x-pack/plugins/file_data_visualizer/server/plugin.ts +++ b/x-pack/plugins/file_data_visualizer/server/plugin.ts @@ -13,7 +13,7 @@ import { PluginInitializerContext, } from 'src/core/server'; // import { schema } from '@kbn/config-schema'; -// import { fileUploadRoutes } from './routes'; +import { fileDataVisualizerRoutes } from './routes'; // import { initFileUploadTelemetry } from './telemetry'; import { UsageCollectionSetup } from '../../../../src/plugins/usage_collection/server'; // import { UI_SETTING_MAX_FILE_SIZE, MAX_FILE_SIZE } from '../common'; @@ -23,7 +23,7 @@ interface SetupDeps { usageCollection: UsageCollectionSetup; } -export class FileUploadPlugin implements Plugin { +export class FileDataVisualizerPlugin implements Plugin { // private readonly _logger: Logger; constructor(initializerContext: PluginInitializerContext) { @@ -31,7 +31,7 @@ export class FileUploadPlugin implements Plugin { } async setup(coreSetup: CoreSetup, plugins: SetupDeps) { - // fileUploadRoutes(coreSetup, this._logger); + fileDataVisualizerRoutes(coreSetup); // initFileUploadTelemetry(coreSetup, plugins.usageCollection); } diff --git a/x-pack/plugins/file_data_visualizer/server/routes.ts b/x-pack/plugins/file_data_visualizer/server/routes.ts new file mode 100644 index 0000000000000..4a92ba6abc84b --- /dev/null +++ b/x-pack/plugins/file_data_visualizer/server/routes.ts @@ -0,0 +1,60 @@ +/* + * 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 { schema } from '@kbn/config-schema'; +import { CoreSetup } from 'src/core/server'; +import { MAX_FILE_SIZE_BYTES } from '../common'; +import { wrapError } from './error_wrapper'; +import { analyzeFile } from './analyze_file'; + +import { analyzeFileQuerySchema } from './schemas'; +import { StartDeps } from './types'; + +/** + * Routes for the file upload. + */ +export function fileDataVisualizerRoutes(coreSetup: CoreSetup) { + const router = coreSetup.http.createRouter(); + + /** + * @apiGroup FileDataVisualizer + * + * @api {post} /internal/file_upload/analyze_file Analyze file data + * @apiName AnalyzeFile + * @apiDescription Performs analysis of the file data. + * + * @apiSchema (query) analyzeFileQuerySchema + */ + router.post( + { + path: '/internal/file_data_visualizer/analyze_file', + validate: { + body: schema.any(), + query: analyzeFileQuerySchema, + }, + options: { + body: { + accepts: ['text/*', 'application/json'], + maxBytes: MAX_FILE_SIZE_BYTES, + }, + tags: ['access:fileUpload:analyzeFile'], + }, + }, + async (context, request, response) => { + try { + const result = await analyzeFile( + context.core.elasticsearch.client, + request.body, + request.query + ); + return response.ok({ body: result }); + } catch (e) { + return response.customError(wrapError(e)); + } + } + ); +} diff --git a/x-pack/plugins/file_data_visualizer/server/schemas.ts b/x-pack/plugins/file_data_visualizer/server/schemas.ts new file mode 100644 index 0000000000000..276aa46e42385 --- /dev/null +++ b/x-pack/plugins/file_data_visualizer/server/schemas.ts @@ -0,0 +1,25 @@ +/* + * 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 { schema } from '@kbn/config-schema'; + +export const analyzeFileQuerySchema = schema.object({ + charset: schema.maybe(schema.string()), + column_names: schema.maybe(schema.string()), + delimiter: schema.maybe(schema.string()), + explain: schema.maybe(schema.string()), + format: schema.maybe(schema.string()), + grok_pattern: schema.maybe(schema.string()), + has_header_row: schema.maybe(schema.string()), + line_merge_size_limit: schema.maybe(schema.string()), + lines_to_sample: schema.maybe(schema.string()), + quote: schema.maybe(schema.string()), + should_trim_fields: schema.maybe(schema.string()), + timeout: schema.maybe(schema.string()), + timestamp_field: schema.maybe(schema.string()), + timestamp_format: schema.maybe(schema.string()), +}); diff --git a/x-pack/plugins/file_upload/public/api/index.ts b/x-pack/plugins/file_upload/public/api/index.ts index 9abc11eec096d..10444970a91a1 100644 --- a/x-pack/plugins/file_upload/public/api/index.ts +++ b/x-pack/plugins/file_upload/public/api/index.ts @@ -16,7 +16,6 @@ export interface FileUploadStartApi { getMaxBytes(): number; getMaxBytesFormatted(): string; hasImportPermission(params: HasImportPermissionParams): Promise; - analyzeFile(file: string, params: Record): Promise; checkIndexExists(index: string, params: Record): Promise; getTimeFieldRange( index: string, @@ -66,20 +65,6 @@ export async function hasImportPermission(params: HasImportPermissionParams): Pr } } -export async function analyzeFile( - file: string, - params: Record = {} -): Promise { - const body = JSON.stringify(file); - const fileUploadModules = await lazyLoadFileUploadModules(); - return await fileUploadModules.getHttp().fetch({ - path: `/internal/file_upload/analyze_file`, - method: 'POST', - body, - query: params, - }); -} - export async function checkIndexExists( index: string, params: Record = {} diff --git a/x-pack/plugins/file_upload/public/plugin.ts b/x-pack/plugins/file_upload/public/plugin.ts index fefb0a05a46d3..f7fe5fde54262 100644 --- a/x-pack/plugins/file_upload/public/plugin.ts +++ b/x-pack/plugins/file_upload/public/plugin.ts @@ -11,7 +11,6 @@ import { getFileUploadComponent, importerFactory, hasImportPermission, - analyzeFile, checkIndexExists, getTimeFieldRange, } from './api'; @@ -46,7 +45,6 @@ export class FileUploadPlugin getMaxBytes, getMaxBytesFormatted, hasImportPermission, - analyzeFile, checkIndexExists, getTimeFieldRange, }; diff --git a/x-pack/plugins/file_upload/server/routes.ts b/x-pack/plugins/file_upload/server/routes.ts index d2e696123c0e1..6078312c07bb4 100644 --- a/x-pack/plugins/file_upload/server/routes.ts +++ b/x-pack/plugins/file_upload/server/routes.ts @@ -16,12 +16,11 @@ import { Settings, } from '../common'; import { wrapError } from './error_wrapper'; -import { analyzeFile } from './analyze_file'; import { importDataProvider } from './import_data'; import { getTimeFieldRange } from './get_time_field_range'; import { updateTelemetry } from './telemetry'; -import { analyzeFileQuerySchema, importFileBodySchema, importFileQuerySchema } from './schemas'; +import { importFileBodySchema, importFileQuerySchema } from './schemas'; import { CheckPrivilegesPayload } from '../../security/server'; import { StartDeps } from './types'; @@ -90,44 +89,6 @@ export function fileUploadRoutes(coreSetup: CoreSetup, logge } ); - /** - * @apiGroup FileDataVisualizer - * - * @api {post} /internal/file_upload/analyze_file Analyze file data - * @apiName AnalyzeFile - * @apiDescription Performs analysis of the file data. - * - * @apiSchema (query) analyzeFileQuerySchema - */ - router.post( - { - path: '/internal/file_upload/analyze_file', - validate: { - body: schema.any(), - query: analyzeFileQuerySchema, - }, - options: { - body: { - accepts: ['text/*', 'application/json'], - maxBytes: MAX_FILE_SIZE_BYTES, - }, - tags: ['access:fileUpload:analyzeFile'], - }, - }, - async (context, request, response) => { - try { - const result = await analyzeFile( - context.core.elasticsearch.client, - request.body, - request.query - ); - return response.ok({ body: result }); - } catch (e) { - return response.customError(wrapError(e)); - } - } - ); - /** * @apiGroup FileDataVisualizer * diff --git a/x-pack/plugins/file_upload/server/schemas.ts b/x-pack/plugins/file_upload/server/schemas.ts index a0d54cf9ec553..bfef9885b3216 100644 --- a/x-pack/plugins/file_upload/server/schemas.ts +++ b/x-pack/plugins/file_upload/server/schemas.ts @@ -7,23 +7,6 @@ import { schema } from '@kbn/config-schema'; -export const analyzeFileQuerySchema = schema.object({ - charset: schema.maybe(schema.string()), - column_names: schema.maybe(schema.string()), - delimiter: schema.maybe(schema.string()), - explain: schema.maybe(schema.string()), - format: schema.maybe(schema.string()), - grok_pattern: schema.maybe(schema.string()), - has_header_row: schema.maybe(schema.string()), - line_merge_size_limit: schema.maybe(schema.string()), - lines_to_sample: schema.maybe(schema.string()), - quote: schema.maybe(schema.string()), - should_trim_fields: schema.maybe(schema.string()), - timeout: schema.maybe(schema.string()), - timestamp_field: schema.maybe(schema.string()), - timestamp_format: schema.maybe(schema.string()), -}); - export const importFileQuerySchema = schema.object({ id: schema.maybe(schema.string()), }); From 6dcf2622a8cfeb8da8b1084bc741a47dacee5e86 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Wed, 14 Apr 2021 08:54:43 +0100 Subject: [PATCH 16/37] fixing transtations issues --- x-pack/.i18nrc.json | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/.i18nrc.json b/x-pack/.i18nrc.json index 6bbbf6cd6b82d..d7f0162edf47b 100644 --- a/x-pack/.i18nrc.json +++ b/x-pack/.i18nrc.json @@ -20,6 +20,7 @@ "xpack.endpoint": "plugins/endpoint", "xpack.enterpriseSearch": "plugins/enterprise_search", "xpack.features": "plugins/features", + "xpack.fileDataVisualizer": "plugins/file_data_visualizer", "xpack.fileUpload": "plugins/file_upload", "xpack.globalSearch": ["plugins/global_search"], "xpack.globalSearchBar": ["plugins/global_search_bar"], From 8c79c8b02ba466bc28cd2815937893d69a098146 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Wed, 14 Apr 2021 13:55:06 +0100 Subject: [PATCH 17/37] refactor for lazy loading of component --- .../file_data_visualizer/public/api/index.ts | 32 ++++++++++------- .../file_datavisualizer_view.js | 3 +- .../file_data_visualizer/public/index.ts | 3 +- .../public/lazy_load_bundle/index.ts | 35 +++++++++++++++++++ .../public/lazy_load_bundle/lazy/index.ts | 9 +++++ .../file_data_visualizer/public/plugin.ts | 3 +- .../file_data_visualizer/server/index.ts | 4 +-- .../file_data_visualizer/server/plugin.ts | 18 +--------- x-pack/plugins/ml/public/application/app.tsx | 2 ++ .../contexts/kibana/kibana_context.ts | 2 ++ .../file_based/file_datavisualizer.tsx | 22 ++++++++---- .../application/util/dependency_cache.ts | 11 ++++++ x-pack/plugins/ml/public/plugin.ts | 3 ++ 13 files changed, 105 insertions(+), 42 deletions(-) create mode 100644 x-pack/plugins/file_data_visualizer/public/lazy_load_bundle/index.ts create mode 100644 x-pack/plugins/file_data_visualizer/public/lazy_load_bundle/lazy/index.ts diff --git a/x-pack/plugins/file_data_visualizer/public/api/index.ts b/x-pack/plugins/file_data_visualizer/public/api/index.ts index 6b890a1cc5919..bcc5eafdc959a 100644 --- a/x-pack/plugins/file_data_visualizer/public/api/index.ts +++ b/x-pack/plugins/file_data_visualizer/public/api/index.ts @@ -6,25 +6,33 @@ */ // import React from 'react'; -import { HttpStart } from 'src/core/public'; +// import { HttpStart } from 'src/core/public'; // import { FileUploadComponentProps, lazyLoadFileUploadModules } from '../lazy_load_bundle'; // import type { IImporter, ImportFactoryOptions } from '../importer'; // import { HasImportPermission } from '../../common'; +// import { getCoreStart } from '../kibana_services'; +import { lazyLoadFileUploadModules } from '../lazy_load_bundle'; +import { FileDataVisualizer } from '../application'; export interface FileDataVisualizerStartApi { analyzeFile(file: string, params: Record): Promise; } -export function getApi(http: HttpStart) { - async function analyzeFile(file: string, params: Record = {}): Promise { - const body = JSON.stringify(file); - return await http.fetch({ - path: `/internal/file_data_visualizer/analyze_file`, - method: 'POST', - body, - query: params, - }); - } +export async function analyzeFile( + file: string, + params: Record = {} +): Promise { + const { getHttp } = await lazyLoadFileUploadModules(); + const body = JSON.stringify(file); + return await getHttp().fetch({ + path: `/internal/file_data_visualizer/analyze_file`, + method: 'POST', + body, + query: params, + }); +} - return { analyzeFile }; +export async function getFileDatavisualizerComponent(): Promise { + const fileUploadModules = await lazyLoadFileUploadModules(); + return fileUploadModules.FileDataVisualizer; } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_datavisualizer_view.js b/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_datavisualizer_view.js index 6514372b3849f..d239017a97617 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_datavisualizer_view.js +++ b/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_datavisualizer_view.js @@ -21,7 +21,7 @@ import { ExplanationFlyout } from '../explanation_flyout'; import { ImportView } from '../import_view'; import { DEFAULT_LINES_TO_SAMPLE, readFile, createUrlOverrides, processResults } from '../utils'; import { getMaxBytes } from '../../../../../file_upload/public'; -import { getApi } from '../../../api'; +import { analyzeFile } from '../../../api'; import { MODE } from './constants'; @@ -128,7 +128,6 @@ export class FileDataVisualizerView extends Component { async analyzeFile(fileContents, overrides, isRetry = false) { try { - const { analyzeFile } = getApi(this.props.http); const resp = await analyzeFile(fileContents, overrides); const serverSettings = processResults(resp); const serverOverrides = resp.overrides; diff --git a/x-pack/plugins/file_data_visualizer/public/index.ts b/x-pack/plugins/file_data_visualizer/public/index.ts index cca82e8e6702a..2e6809528aa27 100644 --- a/x-pack/plugins/file_data_visualizer/public/index.ts +++ b/x-pack/plugins/file_data_visualizer/public/index.ts @@ -11,4 +11,5 @@ export function plugin() { return new FileDataVisualizerPlugin(); } -export { FileDataVisualizer } from './application'; +export { FileDataVisualizerPluginStart } from './plugin'; +export type { FileDataVisualizer } from './application'; diff --git a/x-pack/plugins/file_data_visualizer/public/lazy_load_bundle/index.ts b/x-pack/plugins/file_data_visualizer/public/lazy_load_bundle/index.ts new file mode 100644 index 0000000000000..005bf9a040520 --- /dev/null +++ b/x-pack/plugins/file_data_visualizer/public/lazy_load_bundle/index.ts @@ -0,0 +1,35 @@ +/* + * 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 { HttpSetup } from 'src/core/public'; +import { FileDataVisualizer } from '../application'; +import { analyzeFile } from '../api'; +import { getCoreStart } from '../kibana_services'; + +let loadModulesPromise: Promise; + +interface LazyLoadedFileUploadModules { + analyzeFile: typeof analyzeFile; + FileDataVisualizer: typeof FileDataVisualizer; + getHttp: () => HttpSetup; +} + +export async function lazyLoadFileUploadModules(): Promise { + if (typeof loadModulesPromise !== 'undefined') { + return loadModulesPromise; + } + + loadModulesPromise = new Promise(async (resolve) => { + const lazyImports = await import('./lazy'); + + resolve({ + ...lazyImports, + getHttp: () => getCoreStart().http, + }); + }); + return loadModulesPromise; +} diff --git a/x-pack/plugins/file_data_visualizer/public/lazy_load_bundle/lazy/index.ts b/x-pack/plugins/file_data_visualizer/public/lazy_load_bundle/lazy/index.ts new file mode 100644 index 0000000000000..2c63cb0742414 --- /dev/null +++ b/x-pack/plugins/file_data_visualizer/public/lazy_load_bundle/lazy/index.ts @@ -0,0 +1,9 @@ +/* + * 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. + */ + +export { FileDataVisualizer } from '../../application'; +export { analyzeFile } from '../../api'; diff --git a/x-pack/plugins/file_data_visualizer/public/plugin.ts b/x-pack/plugins/file_data_visualizer/public/plugin.ts index ff1dd03c9f99f..6d3244153cdc9 100644 --- a/x-pack/plugins/file_data_visualizer/public/plugin.ts +++ b/x-pack/plugins/file_data_visualizer/public/plugin.ts @@ -15,6 +15,7 @@ import { DataPublicPluginStart } from '../../../../src/plugins/data/public'; import type { FileUploadPluginStart } from '../../file_upload/public'; import type { MapsStartApi } from '../../maps/public'; import type { SecurityPluginSetup } from '../../security/public'; +import { getFileDatavisualizerComponent } from './api'; // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface FileDataVisualizerSetupDependencies {} @@ -42,6 +43,6 @@ export class FileDataVisualizerPlugin public start(core: CoreStart, plugins: FileDataVisualizerStartDependencies) { setStartServices(core, plugins); - return {}; + return { getFileDatavisualizerComponent }; } } diff --git a/x-pack/plugins/file_data_visualizer/server/index.ts b/x-pack/plugins/file_data_visualizer/server/index.ts index a943773117c09..43067dbe99d0d 100644 --- a/x-pack/plugins/file_data_visualizer/server/index.ts +++ b/x-pack/plugins/file_data_visualizer/server/index.ts @@ -5,8 +5,6 @@ * 2.0. */ -import { PluginInitializerContext } from '../../../../src/core/server'; import { FileDataVisualizerPlugin } from './plugin'; -export const plugin = (initializerContext: PluginInitializerContext) => - new FileDataVisualizerPlugin(initializerContext); +export const plugin = () => new FileDataVisualizerPlugin(); diff --git a/x-pack/plugins/file_data_visualizer/server/plugin.ts b/x-pack/plugins/file_data_visualizer/server/plugin.ts index bb8bc13bdabb2..9ecef2e45d16c 100644 --- a/x-pack/plugins/file_data_visualizer/server/plugin.ts +++ b/x-pack/plugins/file_data_visualizer/server/plugin.ts @@ -5,18 +5,9 @@ * 2.0. */ -// import { i18n } from '@kbn/i18n'; -import { - CoreSetup, - CoreStart, - /* Logger,*/ Plugin, - PluginInitializerContext, -} from 'src/core/server'; -// import { schema } from '@kbn/config-schema'; +import { CoreSetup, CoreStart, Plugin } from 'src/core/server'; import { fileDataVisualizerRoutes } from './routes'; -// import { initFileUploadTelemetry } from './telemetry'; import { UsageCollectionSetup } from '../../../../src/plugins/usage_collection/server'; -// import { UI_SETTING_MAX_FILE_SIZE, MAX_FILE_SIZE } from '../common'; import { StartDeps } from './types'; interface SetupDeps { @@ -24,15 +15,8 @@ interface SetupDeps { } export class FileDataVisualizerPlugin implements Plugin { - // private readonly _logger: Logger; - - constructor(initializerContext: PluginInitializerContext) { - // this._logger = initializerContext.logger.get(); - } - async setup(coreSetup: CoreSetup, plugins: SetupDeps) { fileDataVisualizerRoutes(coreSetup); - // initFileUploadTelemetry(coreSetup, plugins.usageCollection); } start(core: CoreStart) {} diff --git a/x-pack/plugins/ml/public/application/app.tsx b/x-pack/plugins/ml/public/application/app.tsx index 5f72d49e4672e..22dbaecb19c4c 100644 --- a/x-pack/plugins/ml/public/application/app.tsx +++ b/x-pack/plugins/ml/public/application/app.tsx @@ -83,6 +83,7 @@ const App: FC = ({ coreStart, deps, appMountParams }) => { maps: deps.maps, triggersActionsUi: deps.triggersActionsUi, fileUpload: deps.fileUpload, + fileDataVisualizer: deps.fileDataVisualizer, ...coreStart, }; @@ -126,6 +127,7 @@ export const renderApp = ( urlGenerators: deps.share.urlGenerators, maps: deps.maps, fileUpload: deps.fileUpload, + fileDataVisualizer: deps.fileDataVisualizer, }); appMountParams.onAppLeave((actions) => actions.default()); diff --git a/x-pack/plugins/ml/public/application/contexts/kibana/kibana_context.ts b/x-pack/plugins/ml/public/application/contexts/kibana/kibana_context.ts index 3c86bb520600f..11b21348172c0 100644 --- a/x-pack/plugins/ml/public/application/contexts/kibana/kibana_context.ts +++ b/x-pack/plugins/ml/public/application/contexts/kibana/kibana_context.ts @@ -19,6 +19,7 @@ import { IStorageWrapper } from '../../../../../../../src/plugins/kibana_utils/p import type { EmbeddableStart } from '../../../../../../../src/plugins/embeddable/public'; import type { MapsStartApi } from '../../../../../maps/public'; import type { FileUploadPluginStart } from '../../../../../file_upload/public'; +import type { FileDataVisualizerPluginStart } from '../../../../../file_data_visualizer/public'; import type { LensPublicStart } from '../../../../../lens/public'; import { TriggersAndActionsUIPublicPluginStart } from '../../../../../triggers_actions_ui/public'; @@ -32,6 +33,7 @@ interface StartPlugins { lens?: LensPublicStart; triggersActionsUi?: TriggersAndActionsUIPublicPluginStart; fileUpload?: FileUploadPluginStart; + fileDataVisualizer?: FileDataVisualizerPluginStart; } export type StartServices = CoreStart & StartPlugins & { diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx b/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx index 74a19961f7941..e9ddacdf8acf2 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx +++ b/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx @@ -5,25 +5,35 @@ * 2.0. */ -import React, { FC, Fragment } from 'react'; +import React, { FC, Fragment, useState, useEffect } from 'react'; import { useTimefilter } from '../../contexts/kibana'; import { NavigationMenu } from '../../components/navigation_menu'; import { HelpMenu } from '../../components/help_menu'; import { useMlKibana } from '../../contexts/kibana'; -import { FileDataVisualizer } from '../../../../../file_data_visualizer/public'; +import type { FileDataVisualizer as FileDataVisualizerType } from '../../../../../file_data_visualizer/public'; export const FileDataVisualizerPage: FC = () => { useTimefilter({ timeRangeSelector: false, autoRefreshSelector: false }); const { - services: { docLinks }, + services: { docLinks, fileDataVisualizer }, } = useMlKibana(); - const helpLink = docLinks.links.ml.guide; + const [FileDataVisualizer, setFileDataVisualizer] = useState< + typeof FileDataVisualizerType | null + >(null); + + useEffect(() => { + if (fileDataVisualizer !== undefined) { + const { getFileDatavisualizerComponent } = fileDataVisualizer; + getFileDatavisualizerComponent().then(setFileDataVisualizer); + } + }, []); + return ( - - + {FileDataVisualizer} + ); }; diff --git a/x-pack/plugins/ml/public/application/util/dependency_cache.ts b/x-pack/plugins/ml/public/application/util/dependency_cache.ts index 215f087020d6f..4f5045a78f074 100644 --- a/x-pack/plugins/ml/public/application/util/dependency_cache.ts +++ b/x-pack/plugins/ml/public/application/util/dependency_cache.ts @@ -24,6 +24,7 @@ import type { SharePluginStart } from 'src/plugins/share/public'; import type { SecurityPluginSetup } from '../../../../security/public'; import type { MapsStartApi } from '../../../../maps/public'; import type { FileUploadPluginStart } from '../../../../file_upload/public'; +import type { FileDataVisualizerPluginStart } from '../../../../file_data_visualizer/public'; export interface DependencyCache { timefilter: DataPublicPluginSetup['query']['timefilter'] | null; @@ -45,6 +46,7 @@ export interface DependencyCache { urlGenerators: SharePluginStart['urlGenerators'] | null; maps: MapsStartApi | null; fileUpload: FileUploadPluginStart | null; + fileDataVisualizer: FileDataVisualizerPluginStart | null; } const cache: DependencyCache = { @@ -67,6 +69,7 @@ const cache: DependencyCache = { urlGenerators: null, maps: null, fileUpload: null, + fileDataVisualizer: null, }; export function setDependencyCache(deps: Partial) { @@ -88,6 +91,7 @@ export function setDependencyCache(deps: Partial) { cache.i18n = deps.i18n || null; cache.urlGenerators = deps.urlGenerators || null; cache.fileUpload = deps.fileUpload || null; + cache.fileDataVisualizer = deps.fileDataVisualizer || null; } export function getTimefilter() { @@ -220,3 +224,10 @@ export function getFileUpload() { } return cache.fileUpload; } + +export function getFileDataVisualizer() { + if (cache.fileDataVisualizer === null) { + throw new Error("fileDataVisualizer hasn't been initialized"); + } + return cache.fileDataVisualizer; +} diff --git a/x-pack/plugins/ml/public/plugin.ts b/x-pack/plugins/ml/public/plugin.ts index f6d5da92f5e71..b1214fc98bc49 100644 --- a/x-pack/plugins/ml/public/plugin.ts +++ b/x-pack/plugins/ml/public/plugin.ts @@ -53,6 +53,7 @@ import { } from '../../triggers_actions_ui/public'; import { registerMlAlerts } from './alerting/register_ml_alerts'; import { FileUploadPluginStart } from '../../file_upload/public'; +import { FileDataVisualizerPluginStart } from '../../file_data_visualizer/public'; export interface MlStartDependencies { data: DataPublicPluginStart; @@ -65,6 +66,7 @@ export interface MlStartDependencies { lens?: LensPublicStart; triggersActionsUi?: TriggersAndActionsUIPublicPluginStart; fileUpload: FileUploadPluginStart; + fileDataVisualizer: FileDataVisualizerPluginStart; } export interface MlSetupDependencies { @@ -122,6 +124,7 @@ export class MlPlugin implements Plugin { kibanaVersion, triggersActionsUi: pluginsStart.triggersActionsUi, fileUpload: pluginsStart.fileUpload, + fileDataVisualizer: pluginsStart.fileDataVisualizer, }, params ); From 33590f339fbecd5d77804a453fe631422798da0b Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Wed, 14 Apr 2021 14:49:44 +0100 Subject: [PATCH 18/37] updating limits --- packages/kbn-optimizer/limits.yml | 1 + x-pack/plugins/file_data_visualizer/public/index.ts | 1 - .../datavisualizer/file_based/file_datavisualizer.tsx | 5 +---- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/kbn-optimizer/limits.yml b/packages/kbn-optimizer/limits.yml index 249183d4b1e31..e68a3d1ebeab9 100644 --- a/packages/kbn-optimizer/limits.yml +++ b/packages/kbn-optimizer/limits.yml @@ -105,6 +105,7 @@ pageLoadAssetSize: indexPatternFieldEditor: 90489 osquery: 107090 fileUpload: 25664 + fileDataVisualizer: 27530 banners: 17946 mapsEms: 26072 timelines: 28613 diff --git a/x-pack/plugins/file_data_visualizer/public/index.ts b/x-pack/plugins/file_data_visualizer/public/index.ts index 2e6809528aa27..64a81936dbbde 100644 --- a/x-pack/plugins/file_data_visualizer/public/index.ts +++ b/x-pack/plugins/file_data_visualizer/public/index.ts @@ -12,4 +12,3 @@ export function plugin() { } export { FileDataVisualizerPluginStart } from './plugin'; -export type { FileDataVisualizer } from './application'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx b/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx index e9ddacdf8acf2..dcc0ea9bd5579 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx +++ b/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx @@ -11,16 +11,13 @@ import { useTimefilter } from '../../contexts/kibana'; import { NavigationMenu } from '../../components/navigation_menu'; import { HelpMenu } from '../../components/help_menu'; import { useMlKibana } from '../../contexts/kibana'; -import type { FileDataVisualizer as FileDataVisualizerType } from '../../../../../file_data_visualizer/public'; export const FileDataVisualizerPage: FC = () => { useTimefilter({ timeRangeSelector: false, autoRefreshSelector: false }); const { services: { docLinks, fileDataVisualizer }, } = useMlKibana(); - const [FileDataVisualizer, setFileDataVisualizer] = useState< - typeof FileDataVisualizerType | null - >(null); + const [FileDataVisualizer, setFileDataVisualizer] = useState | null>(null); useEffect(() => { if (fileDataVisualizer !== undefined) { From 15a5416c074981c3ef2a4235f011a7c2d1f1742e Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Wed, 14 Apr 2021 14:53:59 +0100 Subject: [PATCH 19/37] updating plugin asciidoc --- docs/developer/plugin-list.asciidoc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/developer/plugin-list.asciidoc b/docs/developer/plugin-list.asciidoc index 0c40c2a8c4db9..06bf9fde86fbc 100644 --- a/docs/developer/plugin-list.asciidoc +++ b/docs/developer/plugin-list.asciidoc @@ -79,7 +79,7 @@ by the user. The final output of the expression pipeline can be rendered using one of the *renderers* registered in `expressions` plugin. All the arguments to expression functions need to be serializable, as well as input and output. -Expression functions should try to stay 'pure'. This makes functions easy to reuse and also +Expression functions should try to stay 'pure'. This makes functions easy to reuse and also make it possible to serialize the whole chain as well as output at every step of execution. Expressions power visualizations in Dashboard and Lens, as well as, every @@ -383,6 +383,10 @@ actitivies. |WARNING: Missing README. +|{kib-repo}blob/{branch}/x-pack/plugins/file_data_visualizer[fileDataVisualizer] +|WARNING: Missing README. + + |{kib-repo}blob/{branch}/x-pack/plugins/fleet/README.md[fleet] |Fleet needs to have Elasticsearch API keys enabled, and also to have TLS enabled on kibana, (if you want to run Kibana without TLS you can provide the following config flag --xpack.fleet.agents.tlsCheckDisabled=false) From 37bb0509bd4ef957774e1bf5f1b4ebcc8fe1cd4d Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Wed, 14 Apr 2021 16:05:59 +0100 Subject: [PATCH 20/37] code clean up --- .../file_data_visualizer/common/types.ts | 56 ------------ .../file_data_visualizer/public/api/index.ts | 11 +-- .../file_datavisualizer_view.js | 3 +- .../plugins/file_upload/common/constants.ts | 12 --- x-pack/plugins/file_upload/common/types.ts | 87 ------------------- x-pack/plugins/file_upload/kibana.json | 5 +- .../public/{ => importer}/get_max_bytes.ts | 4 +- x-pack/plugins/file_upload/public/index.ts | 2 - x-pack/plugins/file_upload/public/plugin.ts | 2 +- x-pack/plugins/file_upload/tsconfig.json | 1 - 10 files changed, 8 insertions(+), 175 deletions(-) rename x-pack/plugins/file_upload/public/{ => importer}/get_max_bytes.ts (92%) diff --git a/x-pack/plugins/file_data_visualizer/common/types.ts b/x-pack/plugins/file_data_visualizer/common/types.ts index 3e60eff839f0d..6dda231a93629 100644 --- a/x-pack/plugins/file_data_visualizer/common/types.ts +++ b/x-pack/plugins/file_data_visualizer/common/types.ts @@ -5,14 +5,9 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; import { ES_FIELD_TYPES } from '../../../../src/plugins/data/common'; import { ML_JOB_FIELD_TYPES } from './constants'; -export interface HasImportPermission { - hasImportPermission: boolean; -} - export interface InputOverrides { [key: string]: string | undefined; } @@ -88,57 +83,6 @@ export interface FindFileStructureErrorResponse { export type InputData = any[]; -export interface ImportResponse { - success: boolean; - id: string; - index?: string; - pipelineId?: string; - docCount: number; - failures: ImportFailure[]; - error?: { - error: estypes.ErrorCause; - }; - ingestError?: boolean; -} - -export interface ImportFailure { - item: number; - reason: string; - doc: ImportDoc; -} - -export interface Doc { - message: string; -} - -export type ImportDoc = Doc | string | object; - -export interface Settings { - pipeline?: string; - index: string; - body: any[]; - [key: string]: any; -} - -export interface Mappings { - _meta?: { - created_by: string; - }; - properties: { - [key: string]: any; - }; -} - -export interface IngestPipelineWrapper { - id: string; - pipeline: IngestPipeline; -} - -export interface IngestPipeline { - description: string; - processors: any[]; -} - export type MlJobFieldType = typeof ML_JOB_FIELD_TYPES[keyof typeof ML_JOB_FIELD_TYPES]; export interface DataVisualizerTableState { diff --git a/x-pack/plugins/file_data_visualizer/public/api/index.ts b/x-pack/plugins/file_data_visualizer/public/api/index.ts index bcc5eafdc959a..0fb5eced44733 100644 --- a/x-pack/plugins/file_data_visualizer/public/api/index.ts +++ b/x-pack/plugins/file_data_visualizer/public/api/index.ts @@ -5,14 +5,9 @@ * 2.0. */ -// import React from 'react'; -// import { HttpStart } from 'src/core/public'; -// import { FileUploadComponentProps, lazyLoadFileUploadModules } from '../lazy_load_bundle'; -// import type { IImporter, ImportFactoryOptions } from '../importer'; -// import { HasImportPermission } from '../../common'; -// import { getCoreStart } from '../kibana_services'; import { lazyLoadFileUploadModules } from '../lazy_load_bundle'; import { FileDataVisualizer } from '../application'; +import { FindFileStructureResponse } from '../../common'; export interface FileDataVisualizerStartApi { analyzeFile(file: string, params: Record): Promise; @@ -21,10 +16,10 @@ export interface FileDataVisualizerStartApi { export async function analyzeFile( file: string, params: Record = {} -): Promise { +): Promise { const { getHttp } = await lazyLoadFileUploadModules(); const body = JSON.stringify(file); - return await getHttp().fetch({ + return await getHttp().fetch({ path: `/internal/file_data_visualizer/analyze_file`, method: 'POST', body, diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_datavisualizer_view.js b/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_datavisualizer_view.js index d239017a97617..18e3188f71abf 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_datavisualizer_view.js +++ b/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_datavisualizer_view.js @@ -20,7 +20,6 @@ import { EditFlyout } from '../edit_flyout'; import { ExplanationFlyout } from '../explanation_flyout'; import { ImportView } from '../import_view'; import { DEFAULT_LINES_TO_SAMPLE, readFile, createUrlOverrides, processResults } from '../utils'; -import { getMaxBytes } from '../../../../../file_upload/public'; import { analyzeFile } from '../../../api'; import { MODE } from './constants'; @@ -56,7 +55,7 @@ export class FileDataVisualizerView extends Component { }; this.savedObjectsClient = props.savedObjectsClient; - this.maxFileUploadBytes = getMaxBytes(); + this.maxFileUploadBytes = this.props.fileUpload.getMaxBytes(); } async componentDidMount() { diff --git a/x-pack/plugins/file_upload/common/constants.ts b/x-pack/plugins/file_upload/common/constants.ts index 6c4e62698e8af..ea36e51466703 100644 --- a/x-pack/plugins/file_upload/common/constants.ts +++ b/x-pack/plugins/file_upload/common/constants.ts @@ -17,15 +17,3 @@ export const FILE_SIZE_DISPLAY_FORMAT = '0,0.[0] b'; // Value to use in the Elasticsearch index mapping meta data to identify the // index as having been created by the ML File Data Visualizer. export const INDEX_META_DATA_CREATED_BY = 'ml-file-data-visualizer'; - -export const ML_JOB_FIELD_TYPES = { - BOOLEAN: 'boolean', - DATE: 'date', - GEO_POINT: 'geo_point', - GEO_SHAPE: 'geo_shape', - IP: 'ip', - KEYWORD: 'keyword', - NUMBER: 'number', - TEXT: 'text', - UNKNOWN: 'unknown', -} as const; diff --git a/x-pack/plugins/file_upload/common/types.ts b/x-pack/plugins/file_upload/common/types.ts index 3e60eff839f0d..1ccd8b91cc4c2 100644 --- a/x-pack/plugins/file_upload/common/types.ts +++ b/x-pack/plugins/file_upload/common/types.ts @@ -6,86 +6,11 @@ */ import type { estypes } from '@elastic/elasticsearch'; -import { ES_FIELD_TYPES } from '../../../../src/plugins/data/common'; -import { ML_JOB_FIELD_TYPES } from './constants'; export interface HasImportPermission { hasImportPermission: boolean; } -export interface InputOverrides { - [key: string]: string | undefined; -} - -export type FormattedOverrides = InputOverrides & { - column_names: string[]; - has_header_row: boolean; - should_trim_fields: boolean; -}; - -export interface AnalysisResult { - results: FindFileStructureResponse; - overrides?: FormattedOverrides; -} - -export interface FindFileStructureResponse { - charset: string; - has_header_row: boolean; - has_byte_order_marker: boolean; - format: string; - field_stats: { - [fieldName: string]: { - count: number; - cardinality: number; - top_hits: Array<{ count: number; value: any }>; - mean_value?: number; - median_value?: number; - max_value?: number; - min_value?: number; - earliest?: string; - latest?: string; - }; - }; - sample_start: string; - num_messages_analyzed: number; - mappings: { - properties: { - [fieldName: string]: { - // including all possible Elasticsearch types - // since find_file_structure API can be enhanced to include new fields in the future - type: Exclude< - ES_FIELD_TYPES, - ES_FIELD_TYPES._ID | ES_FIELD_TYPES._INDEX | ES_FIELD_TYPES._SOURCE | ES_FIELD_TYPES._TYPE - >; - format?: string; - }; - }; - }; - quote: string; - delimiter: string; - need_client_timezone: boolean; - num_lines_analyzed: number; - column_names?: string[]; - explanation?: string[]; - grok_pattern?: string; - multiline_start_pattern?: string; - exclude_lines_pattern?: string; - java_timestamp_formats?: string[]; - joda_timestamp_formats?: string[]; - timestamp_field?: string; - should_trim_fields?: boolean; -} - -export interface FindFileStructureErrorResponse { - body: { - statusCode: number; - error: string; - message: string; - attributes?: any; - }; - name: string; -} - export type InputData = any[]; export interface ImportResponse { @@ -138,15 +63,3 @@ export interface IngestPipeline { description: string; processors: any[]; } - -export type MlJobFieldType = typeof ML_JOB_FIELD_TYPES[keyof typeof ML_JOB_FIELD_TYPES]; - -export interface DataVisualizerTableState { - pageSize: number; - pageIndex: number; - sortField: string; - sortDirection: string; - visibleFieldTypes: string[]; - visibleFieldNames: string[]; - showDistributions: boolean; -} diff --git a/x-pack/plugins/file_upload/kibana.json b/x-pack/plugins/file_upload/kibana.json index d21f5ad5562a9..6f93874cdbcaa 100644 --- a/x-pack/plugins/file_upload/kibana.json +++ b/x-pack/plugins/file_upload/kibana.json @@ -6,10 +6,7 @@ "ui": true, "requiredPlugins": [ "data", - "usageCollection", - "embeddable", - "share", - "discover" + "usageCollection" ], "optionalPlugins": [ "security" diff --git a/x-pack/plugins/file_upload/public/get_max_bytes.ts b/x-pack/plugins/file_upload/public/importer/get_max_bytes.ts similarity index 92% rename from x-pack/plugins/file_upload/public/get_max_bytes.ts rename to x-pack/plugins/file_upload/public/importer/get_max_bytes.ts index 2e002e65248c9..792cd2d01ff6d 100644 --- a/x-pack/plugins/file_upload/public/get_max_bytes.ts +++ b/x-pack/plugins/file_upload/public/importer/get_max_bytes.ts @@ -13,8 +13,8 @@ import { ABSOLUTE_MAX_FILE_SIZE_BYTES, FILE_SIZE_DISPLAY_FORMAT, UI_SETTING_MAX_FILE_SIZE, -} from '../common'; -import { getUiSettings } from './kibana_services'; +} from '../../common'; +import { getUiSettings } from '../kibana_services'; export function getMaxBytes() { const maxFileSize = getUiSettings().get(UI_SETTING_MAX_FILE_SIZE, MAX_FILE_SIZE); diff --git a/x-pack/plugins/file_upload/public/index.ts b/x-pack/plugins/file_upload/public/index.ts index f1f1d00957d25..7c6d6656b87d6 100644 --- a/x-pack/plugins/file_upload/public/index.ts +++ b/x-pack/plugins/file_upload/public/index.ts @@ -15,5 +15,3 @@ export * from './importer/types'; export { FileUploadPluginStart } from './plugin'; export { FileUploadComponentProps } from './lazy_load_bundle'; - -export { getMaxBytes, getMaxBytesFormatted } from './get_max_bytes'; diff --git a/x-pack/plugins/file_upload/public/plugin.ts b/x-pack/plugins/file_upload/public/plugin.ts index f7fe5fde54262..9bbbd1cd774e4 100644 --- a/x-pack/plugins/file_upload/public/plugin.ts +++ b/x-pack/plugins/file_upload/public/plugin.ts @@ -16,7 +16,7 @@ import { } from './api'; import { setStartServices } from './kibana_services'; import { DataPublicPluginStart } from '../../../../src/plugins/data/public'; -import { getMaxBytes, getMaxBytesFormatted } from './get_max_bytes'; +import { getMaxBytes, getMaxBytesFormatted } from './importer/get_max_bytes'; // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface FileUploadSetupDependencies {} diff --git a/x-pack/plugins/file_upload/tsconfig.json b/x-pack/plugins/file_upload/tsconfig.json index 0f37b0bcf2a65..3e146d76fbb90 100644 --- a/x-pack/plugins/file_upload/tsconfig.json +++ b/x-pack/plugins/file_upload/tsconfig.json @@ -13,7 +13,6 @@ { "path": "../../../src/plugins/data/tsconfig.json" }, { "path": "../../../src/plugins/usage_collection/tsconfig.json" }, { "path": "../security/tsconfig.json" }, - // { "path": "../maps/tsconfig.json" }, { "path": "../../../src/plugins/embeddable/tsconfig.json" }, ] } From 3ea16e7f10ce5177562c6cf39a9d6a25b1c26ce2 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Wed, 14 Apr 2021 17:41:41 +0100 Subject: [PATCH 21/37] further clean up --- .../file_data_visualizer/common/types.ts | 26 +++++++++++++++++++ .../plugins/file_data_visualizer/kibana.json | 1 - .../about_panel/welcome_content.tsx | 7 ++++- .../application/file_datavisualizer.tsx | 2 +- .../public/application/util/get_max_bytes.ts | 12 +++++++++ .../file_data_visualizer/public/plugin.ts | 3 ++- .../file_data_visualizer/server/plugin.ts | 11 +++----- .../geojson_file_picker.tsx | 2 +- .../public/importer/get_max_bytes.ts | 1 - .../public/importer/validate_file.ts | 2 +- x-pack/plugins/ml/kibana.json | 1 - .../ml/public/__mocks__/ml_start_deps.ts | 2 +- x-pack/plugins/ml/public/application/app.tsx | 2 -- .../contexts/kibana/kibana_context.ts | 2 -- .../datavisualizer_selector.tsx | 8 +++--- .../application/util/dependency_cache.ts | 11 -------- x-pack/plugins/ml/public/plugin.ts | 3 --- x-pack/plugins/ml/tsconfig.json | 1 - 18 files changed, 57 insertions(+), 40 deletions(-) create mode 100644 x-pack/plugins/file_data_visualizer/public/application/util/get_max_bytes.ts diff --git a/x-pack/plugins/file_data_visualizer/common/types.ts b/x-pack/plugins/file_data_visualizer/common/types.ts index 6dda231a93629..28dbd6a0acbfb 100644 --- a/x-pack/plugins/file_data_visualizer/common/types.ts +++ b/x-pack/plugins/file_data_visualizer/common/types.ts @@ -94,3 +94,29 @@ export interface DataVisualizerTableState { visibleFieldNames: string[]; showDistributions: boolean; } + +export interface Settings { + pipeline?: string; + index: string; + body: any[]; + [key: string]: any; +} + +export interface Mappings { + _meta?: { + created_by: string; + }; + properties: { + [key: string]: any; + }; +} + +export interface IngestPipelineWrapper { + id: string; + pipeline: IngestPipeline; +} + +export interface IngestPipeline { + description: string; + processors: any[]; +} diff --git a/x-pack/plugins/file_data_visualizer/kibana.json b/x-pack/plugins/file_data_visualizer/kibana.json index c2ae95ab21b16..8a3d977b47e5e 100644 --- a/x-pack/plugins/file_data_visualizer/kibana.json +++ b/x-pack/plugins/file_data_visualizer/kibana.json @@ -19,7 +19,6 @@ "requiredBundles": [ "esUiShared", "kibanaReact", - "fileUpload", "maps" ], "extraPublicDirs": [ diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/about_panel/welcome_content.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/about_panel/welcome_content.tsx index 8df5557fa1c2f..684b6dadcb290 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/about_panel/welcome_content.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/about_panel/welcome_content.tsx @@ -21,7 +21,7 @@ import { import { ExperimentalBadge } from '../experimental_badge'; -import { getMaxBytesFormatted } from '../../../../../file_upload/public'; +import { useFileDataVisualizerKibana } from '../../kibana_context'; export const WelcomeContent: FC = () => { const toolTipContent = i18n.translate( @@ -31,6 +31,11 @@ export const WelcomeContent: FC = () => { } ); + const { + services: { + fileUpload: { getMaxBytesFormatted }, + }, + } = useFileDataVisualizerKibana(); const maxFileSize = getMaxBytesFormatted(); return ( diff --git a/x-pack/plugins/file_data_visualizer/public/application/file_datavisualizer.tsx b/x-pack/plugins/file_data_visualizer/public/application/file_datavisualizer.tsx index ed26cc1376449..f291076557bb8 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/file_datavisualizer.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/file_datavisualizer.tsx @@ -15,7 +15,7 @@ import { FileDataVisualizerView } from './components/file_datavisualizer_view/in export const FileDataVisualizer: FC = () => { const coreStart = getCoreStart(); const { data, maps, embeddable, share, security, fileUpload } = getPluginsStart(); - const services = { data, maps, embeddable, share, security, ...coreStart }; + const services = { data, maps, embeddable, share, security, fileUpload, ...coreStart }; return ( diff --git a/x-pack/plugins/file_data_visualizer/public/application/util/get_max_bytes.ts b/x-pack/plugins/file_data_visualizer/public/application/util/get_max_bytes.ts new file mode 100644 index 0000000000000..f85a6fd2f2dfe --- /dev/null +++ b/x-pack/plugins/file_data_visualizer/public/application/util/get_max_bytes.ts @@ -0,0 +1,12 @@ +/* + * 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 { getPluginsStart } from '../../kibana_services'; + +export function getMaxBytesFormatted() { + return getPluginsStart().fileUpload.getMaxBytesFormatted(); +} diff --git a/x-pack/plugins/file_data_visualizer/public/plugin.ts b/x-pack/plugins/file_data_visualizer/public/plugin.ts index 6d3244153cdc9..16fecf81141db 100644 --- a/x-pack/plugins/file_data_visualizer/public/plugin.ts +++ b/x-pack/plugins/file_data_visualizer/public/plugin.ts @@ -16,6 +16,7 @@ import type { FileUploadPluginStart } from '../../file_upload/public'; import type { MapsStartApi } from '../../maps/public'; import type { SecurityPluginSetup } from '../../security/public'; import { getFileDatavisualizerComponent } from './api'; +import { getMaxBytesFormatted } from './application/util/get_max_bytes'; // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface FileDataVisualizerSetupDependencies {} @@ -43,6 +44,6 @@ export class FileDataVisualizerPlugin public start(core: CoreStart, plugins: FileDataVisualizerStartDependencies) { setStartServices(core, plugins); - return { getFileDatavisualizerComponent }; + return { getFileDatavisualizerComponent, getMaxBytesFormatted }; } } diff --git a/x-pack/plugins/file_data_visualizer/server/plugin.ts b/x-pack/plugins/file_data_visualizer/server/plugin.ts index 9ecef2e45d16c..344a484ebdfaa 100644 --- a/x-pack/plugins/file_data_visualizer/server/plugin.ts +++ b/x-pack/plugins/file_data_visualizer/server/plugin.ts @@ -5,19 +5,14 @@ * 2.0. */ -import { CoreSetup, CoreStart, Plugin } from 'src/core/server'; +import { CoreSetup, Plugin } from 'src/core/server'; import { fileDataVisualizerRoutes } from './routes'; -import { UsageCollectionSetup } from '../../../../src/plugins/usage_collection/server'; import { StartDeps } from './types'; -interface SetupDeps { - usageCollection: UsageCollectionSetup; -} - export class FileDataVisualizerPlugin implements Plugin { - async setup(coreSetup: CoreSetup, plugins: SetupDeps) { + async setup(coreSetup: CoreSetup) { fileDataVisualizerRoutes(coreSetup); } - start(core: CoreStart) {} + start() {} } diff --git a/x-pack/plugins/file_upload/public/components/geojson_upload_form/geojson_file_picker.tsx b/x-pack/plugins/file_upload/public/components/geojson_upload_form/geojson_file_picker.tsx index 2f31bc47b899c..6cd55e3a0a74a 100644 --- a/x-pack/plugins/file_upload/public/components/geojson_upload_form/geojson_file_picker.tsx +++ b/x-pack/plugins/file_upload/public/components/geojson_upload_form/geojson_file_picker.tsx @@ -9,7 +9,7 @@ import React, { Component } from 'react'; import { EuiFilePicker, EuiFormRow } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { MB } from '../../../common'; -import { getMaxBytesFormatted } from '../../get_max_bytes'; +import { getMaxBytesFormatted } from '../../importer/get_max_bytes'; import { validateFile } from '../../importer'; import { GeoJsonImporter, diff --git a/x-pack/plugins/file_upload/public/importer/get_max_bytes.ts b/x-pack/plugins/file_upload/public/importer/get_max_bytes.ts index 792cd2d01ff6d..f1ca532692e77 100644 --- a/x-pack/plugins/file_upload/public/importer/get_max_bytes.ts +++ b/x-pack/plugins/file_upload/public/importer/get_max_bytes.ts @@ -5,7 +5,6 @@ * 2.0. */ -// @ts-ignore import numeral from '@elastic/numeral'; import { MAX_FILE_SIZE, diff --git a/x-pack/plugins/file_upload/public/importer/validate_file.ts b/x-pack/plugins/file_upload/public/importer/validate_file.ts index 4c7fe704d8afa..60d93ad552d0d 100644 --- a/x-pack/plugins/file_upload/public/importer/validate_file.ts +++ b/x-pack/plugins/file_upload/public/importer/validate_file.ts @@ -6,7 +6,7 @@ */ import { i18n } from '@kbn/i18n'; -import { getMaxBytes, getMaxBytesFormatted } from '../get_max_bytes'; +import { getMaxBytes, getMaxBytesFormatted } from './get_max_bytes'; export function validateFile(file: File, types: string[]) { if (file.size > getMaxBytes()) { diff --git a/x-pack/plugins/ml/kibana.json b/x-pack/plugins/ml/kibana.json index 0334638bd9293..f61ab17646b65 100644 --- a/x-pack/plugins/ml/kibana.json +++ b/x-pack/plugins/ml/kibana.json @@ -10,7 +10,6 @@ "data", "cloud", "features", - "fileUpload", "fileDataVisualizer", "licensing", "share", diff --git a/x-pack/plugins/ml/public/__mocks__/ml_start_deps.ts b/x-pack/plugins/ml/public/__mocks__/ml_start_deps.ts index 77381c8728a48..ad47e84319e4a 100644 --- a/x-pack/plugins/ml/public/__mocks__/ml_start_deps.ts +++ b/x-pack/plugins/ml/public/__mocks__/ml_start_deps.ts @@ -24,5 +24,5 @@ export const createMlStartDepsMock = () => ({ maps: jest.fn(), lens: lensPluginMock.createStartContract(), triggersActionsUi: triggersActionsUiMock.createStart(), - fileUpload: jest.fn(), + fileDataVisualizer: jest.fn(), }); diff --git a/x-pack/plugins/ml/public/application/app.tsx b/x-pack/plugins/ml/public/application/app.tsx index 22dbaecb19c4c..e2fbcc77f2767 100644 --- a/x-pack/plugins/ml/public/application/app.tsx +++ b/x-pack/plugins/ml/public/application/app.tsx @@ -82,7 +82,6 @@ const App: FC = ({ coreStart, deps, appMountParams }) => { embeddable: deps.embeddable, maps: deps.maps, triggersActionsUi: deps.triggersActionsUi, - fileUpload: deps.fileUpload, fileDataVisualizer: deps.fileDataVisualizer, ...coreStart, }; @@ -126,7 +125,6 @@ export const renderApp = ( security: deps.security, urlGenerators: deps.share.urlGenerators, maps: deps.maps, - fileUpload: deps.fileUpload, fileDataVisualizer: deps.fileDataVisualizer, }); diff --git a/x-pack/plugins/ml/public/application/contexts/kibana/kibana_context.ts b/x-pack/plugins/ml/public/application/contexts/kibana/kibana_context.ts index 11b21348172c0..b69a8a9b7867a 100644 --- a/x-pack/plugins/ml/public/application/contexts/kibana/kibana_context.ts +++ b/x-pack/plugins/ml/public/application/contexts/kibana/kibana_context.ts @@ -18,7 +18,6 @@ import { MlServicesContext } from '../../app'; import { IStorageWrapper } from '../../../../../../../src/plugins/kibana_utils/public'; import type { EmbeddableStart } from '../../../../../../../src/plugins/embeddable/public'; import type { MapsStartApi } from '../../../../../maps/public'; -import type { FileUploadPluginStart } from '../../../../../file_upload/public'; import type { FileDataVisualizerPluginStart } from '../../../../../file_data_visualizer/public'; import type { LensPublicStart } from '../../../../../lens/public'; import { TriggersAndActionsUIPublicPluginStart } from '../../../../../triggers_actions_ui/public'; @@ -32,7 +31,6 @@ interface StartPlugins { maps?: MapsStartApi; lens?: LensPublicStart; triggersActionsUi?: TriggersAndActionsUIPublicPluginStart; - fileUpload?: FileUploadPluginStart; fileDataVisualizer?: FileDataVisualizerPluginStart; } export type StartServices = CoreStart & diff --git a/x-pack/plugins/ml/public/application/datavisualizer/datavisualizer_selector.tsx b/x-pack/plugins/ml/public/application/datavisualizer/datavisualizer_selector.tsx index fc03ff475e05a..5f9127740709f 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/datavisualizer_selector.tsx +++ b/x-pack/plugins/ml/public/application/datavisualizer/datavisualizer_selector.tsx @@ -56,7 +56,7 @@ export const DatavisualizerSelector: FC = () => { licenseManagement, http: { basePath }, docLinks, - fileUpload, + fileDataVisualizer, }, } = useMlKibana(); @@ -68,12 +68,12 @@ export const DatavisualizerSelector: FC = () => { licenseManagement.enabled === true && isFullLicense() === false; - if (fileUpload === undefined) { + if (fileDataVisualizer === undefined) { // eslint-disable-next-line no-console - console.error('File upload plugin not available'); + console.error('File data visualizer plugin not available'); return null; } - const maxFileSize = fileUpload.getMaxBytesFormatted(); + const maxFileSize = fileDataVisualizer.getMaxBytesFormatted(); return ( diff --git a/x-pack/plugins/ml/public/application/util/dependency_cache.ts b/x-pack/plugins/ml/public/application/util/dependency_cache.ts index 4f5045a78f074..759d0dcc68741 100644 --- a/x-pack/plugins/ml/public/application/util/dependency_cache.ts +++ b/x-pack/plugins/ml/public/application/util/dependency_cache.ts @@ -23,7 +23,6 @@ import type { IndexPatternsContract, DataPublicPluginStart } from 'src/plugins/d import type { SharePluginStart } from 'src/plugins/share/public'; import type { SecurityPluginSetup } from '../../../../security/public'; import type { MapsStartApi } from '../../../../maps/public'; -import type { FileUploadPluginStart } from '../../../../file_upload/public'; import type { FileDataVisualizerPluginStart } from '../../../../file_data_visualizer/public'; export interface DependencyCache { @@ -45,7 +44,6 @@ export interface DependencyCache { i18n: I18nStart | null; urlGenerators: SharePluginStart['urlGenerators'] | null; maps: MapsStartApi | null; - fileUpload: FileUploadPluginStart | null; fileDataVisualizer: FileDataVisualizerPluginStart | null; } @@ -68,7 +66,6 @@ const cache: DependencyCache = { i18n: null, urlGenerators: null, maps: null, - fileUpload: null, fileDataVisualizer: null, }; @@ -90,7 +87,6 @@ export function setDependencyCache(deps: Partial) { cache.security = deps.security || null; cache.i18n = deps.i18n || null; cache.urlGenerators = deps.urlGenerators || null; - cache.fileUpload = deps.fileUpload || null; cache.fileDataVisualizer = deps.fileDataVisualizer || null; } @@ -218,13 +214,6 @@ export function clearCache() { }); } -export function getFileUpload() { - if (cache.fileUpload === null) { - throw new Error("fileUpload hasn't been initialized"); - } - return cache.fileUpload; -} - export function getFileDataVisualizer() { if (cache.fileDataVisualizer === null) { throw new Error("fileDataVisualizer hasn't been initialized"); diff --git a/x-pack/plugins/ml/public/plugin.ts b/x-pack/plugins/ml/public/plugin.ts index b1214fc98bc49..1ab47256b2c2a 100644 --- a/x-pack/plugins/ml/public/plugin.ts +++ b/x-pack/plugins/ml/public/plugin.ts @@ -52,7 +52,6 @@ import { TriggersAndActionsUIPublicPluginStart, } from '../../triggers_actions_ui/public'; import { registerMlAlerts } from './alerting/register_ml_alerts'; -import { FileUploadPluginStart } from '../../file_upload/public'; import { FileDataVisualizerPluginStart } from '../../file_data_visualizer/public'; export interface MlStartDependencies { @@ -65,7 +64,6 @@ export interface MlStartDependencies { maps?: MapsStartApi; lens?: LensPublicStart; triggersActionsUi?: TriggersAndActionsUIPublicPluginStart; - fileUpload: FileUploadPluginStart; fileDataVisualizer: FileDataVisualizerPluginStart; } @@ -123,7 +121,6 @@ export class MlPlugin implements Plugin { lens: pluginsStart.lens, kibanaVersion, triggersActionsUi: pluginsStart.triggersActionsUi, - fileUpload: pluginsStart.fileUpload, fileDataVisualizer: pluginsStart.fileDataVisualizer, }, params diff --git a/x-pack/plugins/ml/tsconfig.json b/x-pack/plugins/ml/tsconfig.json index b30e232ca5c59..d887cfc885253 100644 --- a/x-pack/plugins/ml/tsconfig.json +++ b/x-pack/plugins/ml/tsconfig.json @@ -24,7 +24,6 @@ { "path": "../../../src/plugins/index_pattern_management/tsconfig.json" }, { "path": "../cloud/tsconfig.json" }, { "path": "../features/tsconfig.json" }, - { "path": "../file_upload/tsconfig.json" }, { "path": "../file_data_visualizer/tsconfig.json" }, { "path": "../license_management/tsconfig.json" }, { "path": "../licensing/tsconfig.json" }, From 3a10c997ab1ffc930884d4ffd35e3b4fa6d31838 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Thu, 15 Apr 2021 10:15:57 +0100 Subject: [PATCH 22/37] adding comment --- .../public/application/util/get_max_bytes.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x-pack/plugins/file_data_visualizer/public/application/util/get_max_bytes.ts b/x-pack/plugins/file_data_visualizer/public/application/util/get_max_bytes.ts index f85a6fd2f2dfe..821a94bf5166d 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/util/get_max_bytes.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/util/get_max_bytes.ts @@ -7,6 +7,8 @@ import { getPluginsStart } from '../../kibana_services'; +// expose the fileUpload plugin's getMaxBytesFormatted for use in ML +// so ML doesn't need to depend on the fileUpload plugin for this one function export function getMaxBytesFormatted() { return getPluginsStart().fileUpload.getMaxBytesFormatted(); } From c558cfea024872b092f5c11823697a51ac705856 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Thu, 15 Apr 2021 14:17:19 +0100 Subject: [PATCH 23/37] fixing really obvious CI error --- docs/developer/plugin-list.asciidoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/developer/plugin-list.asciidoc b/docs/developer/plugin-list.asciidoc index a8e2c8f9f7872..0926f0d226818 100644 --- a/docs/developer/plugin-list.asciidoc +++ b/docs/developer/plugin-list.asciidoc @@ -79,7 +79,7 @@ by the user. The final output of the expression pipeline can be rendered using one of the *renderers* registered in `expressions` plugin. All the arguments to expression functions need to be serializable, as well as input and output. -Expression functions should try to stay 'pure'. This makes functions easy to reuse and also +Expression functions should try to stay 'pure'. This makes functions easy to reuse and also make it possible to serialize the whole chain as well as output at every step of execution. Expressions power visualizations in Dashboard and Lens, as well as, every @@ -392,11 +392,11 @@ actitivies. |The features plugin enhance Kibana with a per-feature privilege system. -|{kib-repo}blob/{branch}/x-pack/plugins/file_upload[fileUpload] +|{kib-repo}blob/{branch}/x-pack/plugins/file_data_visualizer[fileDataVisualizer] |WARNING: Missing README. -|{kib-repo}blob/{branch}/x-pack/plugins/file_data_visualizer[fileDataVisualizer] +|{kib-repo}blob/{branch}/x-pack/plugins/file_upload[fileUpload] |WARNING: Missing README. From 8854d2d79f832c334e7711d363193706ee8fe8ac Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Thu, 15 Apr 2021 14:46:03 +0100 Subject: [PATCH 24/37] removing commented out include --- .../components/expanded_row/geo_point_content/format_utils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/format_utils.ts b/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/format_utils.ts index 61b05278c0a4a..c8ee1236524d9 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/format_utils.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/format_utils.ts @@ -8,7 +8,6 @@ import { Feature, Point } from 'geojson'; import { euiPaletteColorBlind } from '@elastic/eui'; import { DEFAULT_GEO_REGEX } from './geo_point_content'; -// import { SOURCE_TYPES } from '../../../../../../maps/common/constants'; // TODO - copied from maps, fix import link, resolve circular dependency export enum SOURCE_TYPES { From b55b95c443138dcf7bdd874da28cecd4354f72b0 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Thu, 15 Apr 2021 15:05:40 +0100 Subject: [PATCH 25/37] reenabling geo point test --- .../data_visualizer/file_data_visualizer.ts | 82 +++++++++---------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/x-pack/test/functional/apps/ml/data_visualizer/file_data_visualizer.ts b/x-pack/test/functional/apps/ml/data_visualizer/file_data_visualizer.ts index 7a489fa2e80c1..65bc68db25aa1 100644 --- a/x-pack/test/functional/apps/ml/data_visualizer/file_data_visualizer.ts +++ b/x-pack/test/functional/apps/ml/data_visualizer/file_data_visualizer.ts @@ -113,47 +113,47 @@ export default function ({ getService }: FtrProviderContext) { fieldNameFiltersResultCount: 1, }, }, - // { - // suiteSuffix: 'with a file containing geo field', - // filePath: path.join(__dirname, 'files_to_import', 'geo_file.csv'), - // indexName: 'user-import_2', - // createIndexPattern: false, - // fieldTypeFilters: [ML_JOB_FIELD_TYPES.GEO_POINT], - // fieldNameFilters: ['Coordinates'], - // expected: { - // results: { - // title: 'geo_file.csv', - // numberOfFields: 3, - // }, - // metricFields: [], - // nonMetricFields: [ - // { - // fieldName: 'Context', - // type: ML_JOB_FIELD_TYPES.UNKNOWN, - // docCountFormatted: '0 (0%)', - // exampleCount: 0, - // }, - // { - // fieldName: 'Coordinates', - // type: ML_JOB_FIELD_TYPES.GEO_POINT, - // docCountFormatted: '13 (100%)', - // exampleCount: 7, - // }, - // { - // fieldName: 'Location', - // type: ML_JOB_FIELD_TYPES.KEYWORD, - // docCountFormatted: '13 (100%)', - // exampleCount: 7, - // }, - // ], - // visibleMetricFieldsCount: 0, - // totalMetricFieldsCount: 0, - // populatedFieldsCount: 3, - // totalFieldsCount: 3, - // fieldTypeFiltersResultCount: 1, - // fieldNameFiltersResultCount: 1, - // }, - // }, + { + suiteSuffix: 'with a file containing geo field', + filePath: path.join(__dirname, 'files_to_import', 'geo_file.csv'), + indexName: 'user-import_2', + createIndexPattern: false, + fieldTypeFilters: [ML_JOB_FIELD_TYPES.GEO_POINT], + fieldNameFilters: ['Coordinates'], + expected: { + results: { + title: 'geo_file.csv', + numberOfFields: 3, + }, + metricFields: [], + nonMetricFields: [ + { + fieldName: 'Context', + type: ML_JOB_FIELD_TYPES.UNKNOWN, + docCountFormatted: '0 (0%)', + exampleCount: 0, + }, + { + fieldName: 'Coordinates', + type: ML_JOB_FIELD_TYPES.GEO_POINT, + docCountFormatted: '13 (100%)', + exampleCount: 7, + }, + { + fieldName: 'Location', + type: ML_JOB_FIELD_TYPES.KEYWORD, + docCountFormatted: '13 (100%)', + exampleCount: 7, + }, + ], + visibleMetricFieldsCount: 0, + totalMetricFieldsCount: 0, + populatedFieldsCount: 3, + totalFieldsCount: 3, + fieldTypeFiltersResultCount: 1, + fieldNameFiltersResultCount: 1, + }, + }, ]; const testDataListNegative = [ From 6921ee3ad49ea2ffaaee31b06455ea570285ced6 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Thu, 15 Apr 2021 15:28:33 +0100 Subject: [PATCH 26/37] fixing incorrectly changed import --- .../components/analytics_list/use_table_settings.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/use_table_settings.ts b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/use_table_settings.ts index b16ef72c0b660..5ac7b00e8af67 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/use_table_settings.ts +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/use_table_settings.ts @@ -7,7 +7,7 @@ import { Direction, EuiBasicTableProps, Pagination, PropertySort } from '@elastic/eui'; import { useCallback, useMemo } from 'react'; -// import { ListingPageUrlState } from '../../../../../../../common/types/common'; +import { ListingPageUrlState } from '../../../../../../../common/types/common'; import { DataVisualizerFileBasedAppState, DataVisualizerIndexBasedAppState, @@ -15,14 +15,6 @@ import { const PAGE_SIZE_OPTIONS = [10, 25, 50]; -interface ListingPageUrlState { - pageSize: number; - pageIndex: number; - sortField: string; - sortDirection: string; - queryText?: string; -} - // Copying from EUI EuiBasicTable types as type is not correctly picked up for table's onChange // Can be removed when https://github.com/elastic/eui/issues/4011 is addressed in EUI export interface Criteria { From 92c211ed976e41f0d06499567191b901badb5479 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Thu, 15 Apr 2021 16:07:23 +0100 Subject: [PATCH 27/37] removing ml from labels and identifiers --- .../file_data_visualizer/common/constants.ts | 4 +- .../file_data_visualizer/common/types.ts | 4 +- .../file_data_visualizer/public/api/index.ts | 2 +- .../examples_list/examples_list.tsx | 2 +- .../expanded_row/file_based_expanded_row.tsx | 16 +++--- .../geo_point_content/format_utils.ts | 19 +------ .../field_type_icon/field_type_icon.test.tsx | 8 +-- .../field_type_icon/field_type_icon.tsx | 26 +++++----- .../field_types_filter/field_types_filter.tsx | 20 ++++---- .../fields_stats_grid/create_fields.ts | 20 ++++---- .../fields_stats_grid/filter_fields.ts | 4 +- .../fields_stats_grid/get_field_names.ts | 12 ++--- .../data_visualizer_stats_table.tsx | 10 ++-- .../stats_table/types/field_vis_config.ts | 6 +-- .../util/field_types_utils.test.ts | 32 ++++++------ .../application/util/field_types_utils.ts | 20 ++++---- .../public/application/util/util.ts | 51 ------------------- .../file_data_visualizer/public/plugin.ts | 4 +- .../plugins/file_upload/common/constants.ts | 2 +- .../services/ml/data_visualizer_table.ts | 2 +- 20 files changed, 98 insertions(+), 166 deletions(-) delete mode 100644 x-pack/plugins/file_data_visualizer/public/application/util/util.ts diff --git a/x-pack/plugins/file_data_visualizer/common/constants.ts b/x-pack/plugins/file_data_visualizer/common/constants.ts index 6c4e62698e8af..f2a2e52a2267f 100644 --- a/x-pack/plugins/file_data_visualizer/common/constants.ts +++ b/x-pack/plugins/file_data_visualizer/common/constants.ts @@ -16,9 +16,9 @@ export const FILE_SIZE_DISPLAY_FORMAT = '0,0.[0] b'; // Value to use in the Elasticsearch index mapping meta data to identify the // index as having been created by the ML File Data Visualizer. -export const INDEX_META_DATA_CREATED_BY = 'ml-file-data-visualizer'; +export const INDEX_META_DATA_CREATED_BY = 'file-data-visualizer'; -export const ML_JOB_FIELD_TYPES = { +export const JOB_FIELD_TYPES = { BOOLEAN: 'boolean', DATE: 'date', GEO_POINT: 'geo_point', diff --git a/x-pack/plugins/file_data_visualizer/common/types.ts b/x-pack/plugins/file_data_visualizer/common/types.ts index 28dbd6a0acbfb..f7f3d5bef7de6 100644 --- a/x-pack/plugins/file_data_visualizer/common/types.ts +++ b/x-pack/plugins/file_data_visualizer/common/types.ts @@ -6,7 +6,7 @@ */ import { ES_FIELD_TYPES } from '../../../../src/plugins/data/common'; -import { ML_JOB_FIELD_TYPES } from './constants'; +import { JOB_FIELD_TYPES } from './constants'; export interface InputOverrides { [key: string]: string | undefined; @@ -83,7 +83,7 @@ export interface FindFileStructureErrorResponse { export type InputData = any[]; -export type MlJobFieldType = typeof ML_JOB_FIELD_TYPES[keyof typeof ML_JOB_FIELD_TYPES]; +export type JobFieldType = typeof JOB_FIELD_TYPES[keyof typeof JOB_FIELD_TYPES]; export interface DataVisualizerTableState { pageSize: number; diff --git a/x-pack/plugins/file_data_visualizer/public/api/index.ts b/x-pack/plugins/file_data_visualizer/public/api/index.ts index 0fb5eced44733..af35c2d64dbc9 100644 --- a/x-pack/plugins/file_data_visualizer/public/api/index.ts +++ b/x-pack/plugins/file_data_visualizer/public/api/index.ts @@ -27,7 +27,7 @@ export async function analyzeFile( }); } -export async function getFileDatavisualizerComponent(): Promise { +export async function getFileDataVisualizerComponent(): Promise { const fileUploadModules = await lazyLoadFileUploadModules(); return fileUploadModules.FileDataVisualizer; } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/examples_list/examples_list.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/examples_list/examples_list.tsx index 202562a3fa80d..dbf2230181a43 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/examples_list/examples_list.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/examples_list/examples_list.tsx @@ -41,7 +41,7 @@ export const ExamplesList: FC = ({ examples }) => { } return ( -
+
{ @@ -25,25 +25,25 @@ export const FileBasedDataVisualizerExpandedRow = ({ item }: { item: FileBasedFi function getCardContent() { switch (type) { - case ML_JOB_FIELD_TYPES.NUMBER: + case JOB_FIELD_TYPES.NUMBER: return ; - case ML_JOB_FIELD_TYPES.BOOLEAN: + case JOB_FIELD_TYPES.BOOLEAN: return ; - case ML_JOB_FIELD_TYPES.DATE: + case JOB_FIELD_TYPES.DATE: return ; - case ML_JOB_FIELD_TYPES.GEO_POINT: + case JOB_FIELD_TYPES.GEO_POINT: return ; - case ML_JOB_FIELD_TYPES.IP: + case JOB_FIELD_TYPES.IP: return ; - case ML_JOB_FIELD_TYPES.KEYWORD: + case JOB_FIELD_TYPES.KEYWORD: return ; - case ML_JOB_FIELD_TYPES.TEXT: + case JOB_FIELD_TYPES.TEXT: return ; default: diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/format_utils.ts b/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/format_utils.ts index c8ee1236524d9..69e361aba9bca 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/format_utils.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/format_utils.ts @@ -8,24 +8,7 @@ import { Feature, Point } from 'geojson'; import { euiPaletteColorBlind } from '@elastic/eui'; import { DEFAULT_GEO_REGEX } from './geo_point_content'; - -// TODO - copied from maps, fix import link, resolve circular dependency -export enum SOURCE_TYPES { - EMS_TMS = 'EMS_TMS', - EMS_FILE = 'EMS_FILE', - ES_GEO_GRID = 'ES_GEO_GRID', - ES_GEO_LINE = 'ES_GEO_LINE', - ES_SEARCH = 'ES_SEARCH', - ES_PEW_PEW = 'ES_PEW_PEW', - ES_TERM_SOURCE = 'ES_TERM_SOURCE', - EMS_XYZ = 'EMS_XYZ', // identifies a custom TMS source. Name is a little unfortunate. - WMS = 'WMS', - KIBANA_TILEMAP = 'KIBANA_TILEMAP', - REGIONMAP_FILE = 'REGIONMAP_FILE', - GEOJSON_FILE = 'GEOJSON_FILE', - MVT_SINGLE_LAYER = 'MVT_SINGLE_LAYER', - TABLE_SOURCE = 'TABLE_SOURCE', -} +import { SOURCE_TYPES } from '../../../../../../maps/common/constants'; export const convertWKTGeoToLonLat = ( value: string | number diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/field_type_icon.test.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/field_type_icon.test.tsx index e054b2b868caf..d1321ad8f9f4d 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/field_type_icon.test.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/field_type_icon.test.tsx @@ -9,12 +9,12 @@ import React from 'react'; import { mount, shallow } from 'enzyme'; import { FieldTypeIcon } from './field_type_icon'; -import { ML_JOB_FIELD_TYPES } from '../../../../common'; +import { JOB_FIELD_TYPES } from '../../../../common'; describe('FieldTypeIcon', () => { test(`render component when type matches a field type`, () => { const typeIconComponent = shallow( - + ); expect(typeIconComponent).toMatchSnapshot(); }); @@ -24,9 +24,9 @@ describe('FieldTypeIcon', () => { jest.useFakeTimers(); const typeIconComponent = mount( - + ); - const container = typeIconComponent.find({ 'data-test-subj': 'mlFieldTypeIcon' }); + const container = typeIconComponent.find({ 'data-test-subj': 'fieldTypeIcon' }); expect(typeIconComponent.find('EuiToolTip').children()).toHaveLength(1); diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/field_type_icon.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/field_type_icon.tsx index 9c7d32ccf45e6..9a346d5542318 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/field_type_icon.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/field_type_icon.tsx @@ -12,12 +12,12 @@ import { EuiToken, EuiToolTip } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { getMLJobTypeAriaLabel } from '../../util/field_types_utils'; -import { ML_JOB_FIELD_TYPES } from '../../../../common'; -import type { MlJobFieldType } from '../../../../common'; +import { JOB_FIELD_TYPES } from '../../../../common'; +import type { JobFieldType } from '../../../../common'; interface FieldTypeIconProps { tooltipEnabled: boolean; - type: MlJobFieldType; + type: JobFieldType; fieldName?: string; needsAria: boolean; } @@ -43,36 +43,36 @@ export const FieldTypeIcon: FC = ({ switch (type) { // Set icon types and colors - case ML_JOB_FIELD_TYPES.BOOLEAN: + case JOB_FIELD_TYPES.BOOLEAN: iconType = 'tokenBoolean'; color = 'euiColorVis5'; break; - case ML_JOB_FIELD_TYPES.DATE: + case JOB_FIELD_TYPES.DATE: iconType = 'tokenDate'; color = 'euiColorVis7'; break; - case ML_JOB_FIELD_TYPES.GEO_POINT: - case ML_JOB_FIELD_TYPES.GEO_SHAPE: + case JOB_FIELD_TYPES.GEO_POINT: + case JOB_FIELD_TYPES.GEO_SHAPE: iconType = 'tokenGeo'; color = 'euiColorVis8'; break; - case ML_JOB_FIELD_TYPES.TEXT: + case JOB_FIELD_TYPES.TEXT: iconType = 'document'; color = 'euiColorVis9'; break; - case ML_JOB_FIELD_TYPES.IP: + case JOB_FIELD_TYPES.IP: iconType = 'tokenIP'; color = 'euiColorVis3'; break; - case ML_JOB_FIELD_TYPES.KEYWORD: + case JOB_FIELD_TYPES.KEYWORD: iconType = 'tokenText'; color = 'euiColorVis0'; break; - case ML_JOB_FIELD_TYPES.NUMBER: + case JOB_FIELD_TYPES.NUMBER: iconType = 'tokenNumber'; color = fieldName !== undefined ? 'euiColorVis1' : 'euiColorVis2'; break; - case ML_JOB_FIELD_TYPES.UNKNOWN: + case JOB_FIELD_TYPES.UNKNOWN: // Use defaults break; } @@ -121,7 +121,7 @@ const FieldTypeIconContainer: FC = ({ } return ( - + diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/field_types_filter/field_types_filter.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/field_types_filter/field_types_filter.tsx index 49695fc930e91..821a688a0bf52 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/field_types_filter/field_types_filter.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/field_types_filter/field_types_filter.tsx @@ -14,18 +14,18 @@ import type { FileBasedUnknownFieldVisConfig, } from '../stats_table/types/field_vis_config'; import { FieldTypeIcon } from '../field_type_icon'; -import { ML_JOB_FIELD_TYPES } from '../../../../common'; +import { JOB_FIELD_TYPES } from '../../../../common'; const ML_JOB_FIELD_TYPES_OPTIONS = { - [ML_JOB_FIELD_TYPES.BOOLEAN]: { name: 'Boolean', icon: 'tokenBoolean' }, - [ML_JOB_FIELD_TYPES.DATE]: { name: 'Date', icon: 'tokenDate' }, - [ML_JOB_FIELD_TYPES.GEO_POINT]: { name: 'Geo point', icon: 'tokenGeo' }, - [ML_JOB_FIELD_TYPES.GEO_SHAPE]: { name: 'Geo shape', icon: 'tokenGeo' }, - [ML_JOB_FIELD_TYPES.IP]: { name: 'IP address', icon: 'tokenIP' }, - [ML_JOB_FIELD_TYPES.KEYWORD]: { name: 'Keyword', icon: 'tokenKeyword' }, - [ML_JOB_FIELD_TYPES.NUMBER]: { name: 'Number', icon: 'tokenNumber' }, - [ML_JOB_FIELD_TYPES.TEXT]: { name: 'Text', icon: 'tokenString' }, - [ML_JOB_FIELD_TYPES.UNKNOWN]: { name: 'Unknown' }, + [JOB_FIELD_TYPES.BOOLEAN]: { name: 'Boolean', icon: 'tokenBoolean' }, + [JOB_FIELD_TYPES.DATE]: { name: 'Date', icon: 'tokenDate' }, + [JOB_FIELD_TYPES.GEO_POINT]: { name: 'Geo point', icon: 'tokenGeo' }, + [JOB_FIELD_TYPES.GEO_SHAPE]: { name: 'Geo shape', icon: 'tokenGeo' }, + [JOB_FIELD_TYPES.IP]: { name: 'IP address', icon: 'tokenIP' }, + [JOB_FIELD_TYPES.KEYWORD]: { name: 'Keyword', icon: 'tokenKeyword' }, + [JOB_FIELD_TYPES.NUMBER]: { name: 'Number', icon: 'tokenNumber' }, + [JOB_FIELD_TYPES.TEXT]: { name: 'Text', icon: 'tokenString' }, + [JOB_FIELD_TYPES.UNKNOWN]: { name: 'Unknown' }, }; interface Props { diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/create_fields.ts b/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/create_fields.ts index 995a28c20d0db..c53e495af8eb7 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/create_fields.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/create_fields.ts @@ -8,7 +8,7 @@ import { FindFileStructureResponse } from '../../../../common'; import { getFieldNames, getSupportedFieldType } from './get_field_names'; import { FileBasedFieldVisConfig } from '../stats_table/types'; -import { ML_JOB_FIELD_TYPES } from '../../../../common'; +import { JOB_FIELD_TYPES } from '../../../../common'; import { roundToDecimalPlace } from '../utils'; export function createFields(results: FindFileStructureResponse) { @@ -28,20 +28,20 @@ export function createFields(results: FindFileStructureResponse) { if (fieldStats[name] !== undefined) { const field: FileBasedFieldVisConfig = { fieldName: name, - type: ML_JOB_FIELD_TYPES.UNKNOWN, + type: JOB_FIELD_TYPES.UNKNOWN, }; const f = fieldStats[name]; const m = mappings.properties[name]; // sometimes the timestamp field is not in the mappings, and so our // collection of fields will be missing a time field with a type of date - if (name === timestampField && field.type === ML_JOB_FIELD_TYPES.UNKNOWN) { - field.type = ML_JOB_FIELD_TYPES.DATE; + if (name === timestampField && field.type === JOB_FIELD_TYPES.UNKNOWN) { + field.type = JOB_FIELD_TYPES.DATE; } if (m !== undefined) { field.type = getSupportedFieldType(m.type); - if (field.type === ML_JOB_FIELD_TYPES.NUMBER) { + if (field.type === JOB_FIELD_TYPES.NUMBER) { numericFieldsCount += 1; } if (m.format !== undefined) { @@ -71,7 +71,7 @@ export function createFields(results: FindFileStructureResponse) { } if (f.top_hits !== undefined) { - if (field.type === ML_JOB_FIELD_TYPES.TEXT) { + if (field.type === JOB_FIELD_TYPES.TEXT) { _stats = { ..._stats, examples: f.top_hits.map((hit) => hit.value), @@ -84,7 +84,7 @@ export function createFields(results: FindFileStructureResponse) { } } - if (field.type === ML_JOB_FIELD_TYPES.DATE) { + if (field.type === JOB_FIELD_TYPES.DATE) { _stats = { ..._stats, earliest: f.earliest, @@ -99,9 +99,9 @@ export function createFields(results: FindFileStructureResponse) { // this could be the message field for a semi-structured log file or a // field which the endpoint has not been able to work out any information for const type = - mappings.properties[name] && mappings.properties[name].type === ML_JOB_FIELD_TYPES.TEXT - ? ML_JOB_FIELD_TYPES.TEXT - : ML_JOB_FIELD_TYPES.UNKNOWN; + mappings.properties[name] && mappings.properties[name].type === JOB_FIELD_TYPES.TEXT + ? JOB_FIELD_TYPES.TEXT + : JOB_FIELD_TYPES.UNKNOWN; return { fieldName: name, diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/filter_fields.ts b/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/filter_fields.ts index 8cccdf73b4625..0120b17452558 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/filter_fields.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/filter_fields.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ML_JOB_FIELD_TYPES } from '../../../../common'; +import { JOB_FIELD_TYPES } from '../../../../common'; import type { FileBasedFieldVisConfig, FileBasedUnknownFieldVisConfig, @@ -32,6 +32,6 @@ export function filterFields( return { filteredFields: items, visibleFieldsCount: items.length, - visibleMetricsCount: items.filter((d) => d.type === ML_JOB_FIELD_TYPES.NUMBER).length, + visibleMetricsCount: items.filter((d) => d.type === JOB_FIELD_TYPES.NUMBER).length, }; } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/get_field_names.ts b/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/get_field_names.ts index 4b9f65b0ff93f..06a17cbd95706 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/get_field_names.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/get_field_names.ts @@ -6,9 +6,9 @@ */ import { difference } from 'lodash'; -import type { FindFileStructureResponse, MlJobFieldType } from '../../../../common'; +import type { FindFileStructureResponse, JobFieldType } from '../../../../common'; import { ES_FIELD_TYPES } from '../../../../../../../src/plugins/data/common'; -import { ML_JOB_FIELD_TYPES } from '../../../../common'; +import { JOB_FIELD_TYPES } from '../../../../common'; export function getFieldNames(results: FindFileStructureResponse) { const { mappings, field_stats: fieldStats, column_names: columnNames } = results; @@ -33,7 +33,7 @@ export function getFieldNames(results: FindFileStructureResponse) { return tempFields; } -export function getSupportedFieldType(type: string): MlJobFieldType { +export function getSupportedFieldType(type: string): JobFieldType { switch (type) { case ES_FIELD_TYPES.FLOAT: case ES_FIELD_TYPES.HALF_FLOAT: @@ -43,13 +43,13 @@ export function getSupportedFieldType(type: string): MlJobFieldType { case ES_FIELD_TYPES.LONG: case ES_FIELD_TYPES.SHORT: case ES_FIELD_TYPES.UNSIGNED_LONG: - return ML_JOB_FIELD_TYPES.NUMBER; + return JOB_FIELD_TYPES.NUMBER; case ES_FIELD_TYPES.DATE: case ES_FIELD_TYPES.DATE_NANOS: - return ML_JOB_FIELD_TYPES.DATE; + return JOB_FIELD_TYPES.DATE; default: - return type as MlJobFieldType; + return type as JobFieldType; } } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/data_visualizer_stats_table.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/data_visualizer_stats_table.tsx index b5d8ef5cbb501..97c44f49b733e 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/data_visualizer_stats_table.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/data_visualizer_stats_table.tsx @@ -21,7 +21,7 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { EuiTableComputedColumnType } from '@elastic/eui/src/components/basic_table/table_types'; -import { ML_JOB_FIELD_TYPES, MlJobFieldType, DataVisualizerTableState } from '../../../../common'; +import { JOB_FIELD_TYPES, JobFieldType, DataVisualizerTableState } from '../../../../common'; import { FieldTypeIcon } from '../field_type_icon'; import { DocumentStat } from './components/field_data_row/document_stats'; import { DistinctValues } from './components/field_data_row/distinct_values'; @@ -146,7 +146,7 @@ export const DataVisualizerTable = ({ name: i18n.translate('xpack.fileDataVisualizer.datavisualizer.dataGrid.typeColumnName', { defaultMessage: 'Type', }), - render: (fieldType: MlJobFieldType) => { + render: (fieldType: JobFieldType) => { return ; }, width: '75px', @@ -224,13 +224,13 @@ export const DataVisualizerTable = ({ render: (item: DataVisualizerTableItem) => { if (item === undefined || showDistributions === false) return null; if ( - (item.type === ML_JOB_FIELD_TYPES.KEYWORD || item.type === ML_JOB_FIELD_TYPES.IP) && + (item.type === JOB_FIELD_TYPES.KEYWORD || item.type === JOB_FIELD_TYPES.IP) && item.stats?.topValues !== undefined ) { return ; } - if (item.type === ML_JOB_FIELD_TYPES.NUMBER) { + if (item.type === JOB_FIELD_TYPES.NUMBER) { if (isIndexBasedFieldVisConfig(item) && item.stats?.distribution !== undefined) { return ; } else { @@ -238,7 +238,7 @@ export const DataVisualizerTable = ({ } } - if (item.type === ML_JOB_FIELD_TYPES.BOOLEAN) { + if (item.type === JOB_FIELD_TYPES.BOOLEAN) { return ; } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/types/field_vis_config.ts b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/types/field_vis_config.ts index 7bf80dfcfb745..e9ef0cd75e286 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/types/field_vis_config.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/types/field_vis_config.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { MlJobFieldType } from '../../../../../common'; +import { JobFieldType } from '../../../../../common'; export interface Percentile { percent: number; @@ -62,7 +62,7 @@ export interface FieldVisStats { // The internal representation of the configuration used to build the visuals // which display the field information. export interface FieldVisConfig { - type: MlJobFieldType; + type: JobFieldType; fieldName?: string; existsInDocs: boolean; aggregatable: boolean; @@ -73,7 +73,7 @@ export interface FieldVisConfig { } export interface FileBasedFieldVisConfig { - type: MlJobFieldType; + type: JobFieldType; fieldName?: string; stats?: FieldVisStats; format?: string; diff --git a/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.test.ts b/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.test.ts index 4f2cc74391427..a50457ca57a55 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.test.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.test.ts @@ -6,7 +6,7 @@ */ import { IFieldType, KBN_FIELD_TYPES } from '../../../../../../src/plugins/data/public'; -import { ML_JOB_FIELD_TYPES } from '../../../common'; +import { JOB_FIELD_TYPES } from '../../../common'; import { kbnTypeToMLJobType, getMLJobTypeAriaLabel, @@ -15,43 +15,43 @@ import { describe('ML - field type utils', () => { describe('kbnTypeToMLJobType', () => { - test('returns correct ML_JOB_FIELD_TYPES for KBN_FIELD_TYPES', () => { + test('returns correct JOB_FIELD_TYPES for KBN_FIELD_TYPES', () => { const field: IFieldType = { type: KBN_FIELD_TYPES.NUMBER, name: KBN_FIELD_TYPES.NUMBER, aggregatable: true, }; - expect(kbnTypeToMLJobType(field)).toBe(ML_JOB_FIELD_TYPES.NUMBER); + expect(kbnTypeToMLJobType(field)).toBe(JOB_FIELD_TYPES.NUMBER); field.type = KBN_FIELD_TYPES.DATE; - expect(kbnTypeToMLJobType(field)).toBe(ML_JOB_FIELD_TYPES.DATE); + expect(kbnTypeToMLJobType(field)).toBe(JOB_FIELD_TYPES.DATE); field.type = KBN_FIELD_TYPES.IP; - expect(kbnTypeToMLJobType(field)).toBe(ML_JOB_FIELD_TYPES.IP); + expect(kbnTypeToMLJobType(field)).toBe(JOB_FIELD_TYPES.IP); field.type = KBN_FIELD_TYPES.BOOLEAN; - expect(kbnTypeToMLJobType(field)).toBe(ML_JOB_FIELD_TYPES.BOOLEAN); + expect(kbnTypeToMLJobType(field)).toBe(JOB_FIELD_TYPES.BOOLEAN); field.type = KBN_FIELD_TYPES.GEO_POINT; - expect(kbnTypeToMLJobType(field)).toBe(ML_JOB_FIELD_TYPES.GEO_POINT); + expect(kbnTypeToMLJobType(field)).toBe(JOB_FIELD_TYPES.GEO_POINT); }); - test('returns ML_JOB_FIELD_TYPES.KEYWORD for aggregatable KBN_FIELD_TYPES.STRING', () => { + test('returns JOB_FIELD_TYPES.KEYWORD for aggregatable KBN_FIELD_TYPES.STRING', () => { const field: IFieldType = { type: KBN_FIELD_TYPES.STRING, name: KBN_FIELD_TYPES.STRING, aggregatable: true, }; - expect(kbnTypeToMLJobType(field)).toBe(ML_JOB_FIELD_TYPES.KEYWORD); + expect(kbnTypeToMLJobType(field)).toBe(JOB_FIELD_TYPES.KEYWORD); }); - test('returns ML_JOB_FIELD_TYPES.TEXT for non-aggregatable KBN_FIELD_TYPES.STRING', () => { + test('returns JOB_FIELD_TYPES.TEXT for non-aggregatable KBN_FIELD_TYPES.STRING', () => { const field: IFieldType = { type: KBN_FIELD_TYPES.STRING, name: KBN_FIELD_TYPES.STRING, aggregatable: false, }; - expect(kbnTypeToMLJobType(field)).toBe(ML_JOB_FIELD_TYPES.TEXT); + expect(kbnTypeToMLJobType(field)).toBe(JOB_FIELD_TYPES.TEXT); }); test('returns undefined for non-aggregatable "foo"', () => { @@ -65,20 +65,20 @@ describe('ML - field type utils', () => { }); describe('getMLJobTypeAriaLabel: Getting a field type aria label by passing what it is stored in constants', () => { - test('should returns all ML_JOB_FIELD_TYPES labels exactly as it is for each correct value', () => { - const mlKeys = Object.keys(ML_JOB_FIELD_TYPES); + test('should returns all JOB_FIELD_TYPES labels exactly as it is for each correct value', () => { + const mlKeys = Object.keys(JOB_FIELD_TYPES); const receivedMlLabels: Record = {}; const testStorage = mlJobTypeAriaLabels; mlKeys.forEach((constant) => { receivedMlLabels[constant] = getMLJobTypeAriaLabel( - ML_JOB_FIELD_TYPES[constant as keyof typeof ML_JOB_FIELD_TYPES] + JOB_FIELD_TYPES[constant as keyof typeof JOB_FIELD_TYPES] ); }); expect(receivedMlLabels).toEqual(testStorage); }); - test('should returns NULL as ML_JOB_FIELD_TYPES does not contain such a keyword', () => { - expect(getMLJobTypeAriaLabel('ML_JOB_FIELD_TYPES')).toBe(null); + test('should returns NULL as JOB_FIELD_TYPES does not contain such a keyword', () => { + expect(getMLJobTypeAriaLabel('JOB_FIELD_TYPES')).toBe(null); }); }); }); diff --git a/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.ts b/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.ts index dd72e0da949ce..6f46ac518ffd7 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.ts @@ -6,7 +6,7 @@ */ import { i18n } from '@kbn/i18n'; -import { ML_JOB_FIELD_TYPES } from '../../../common'; +import { JOB_FIELD_TYPES } from '../../../common'; import { IFieldType, KBN_FIELD_TYPES } from '../../../../../../src/plugins/data/public'; @@ -18,25 +18,25 @@ export function kbnTypeToMLJobType(field: IFieldType) { let type; switch (field.type) { case KBN_FIELD_TYPES.STRING: - type = field.aggregatable ? ML_JOB_FIELD_TYPES.KEYWORD : ML_JOB_FIELD_TYPES.TEXT; + type = field.aggregatable ? JOB_FIELD_TYPES.KEYWORD : JOB_FIELD_TYPES.TEXT; break; case KBN_FIELD_TYPES.NUMBER: - type = ML_JOB_FIELD_TYPES.NUMBER; + type = JOB_FIELD_TYPES.NUMBER; break; case KBN_FIELD_TYPES.DATE: - type = ML_JOB_FIELD_TYPES.DATE; + type = JOB_FIELD_TYPES.DATE; break; case KBN_FIELD_TYPES.IP: - type = ML_JOB_FIELD_TYPES.IP; + type = JOB_FIELD_TYPES.IP; break; case KBN_FIELD_TYPES.BOOLEAN: - type = ML_JOB_FIELD_TYPES.BOOLEAN; + type = JOB_FIELD_TYPES.BOOLEAN; break; case KBN_FIELD_TYPES.GEO_POINT: - type = ML_JOB_FIELD_TYPES.GEO_POINT; + type = JOB_FIELD_TYPES.GEO_POINT; break; case KBN_FIELD_TYPES.GEO_SHAPE: - type = ML_JOB_FIELD_TYPES.GEO_SHAPE; + type = JOB_FIELD_TYPES.GEO_SHAPE; break; default: @@ -77,8 +77,8 @@ export const mlJobTypeAriaLabels = { }; export const getMLJobTypeAriaLabel = (type: string) => { - const requestedFieldType = Object.keys(ML_JOB_FIELD_TYPES).find( - (k) => ML_JOB_FIELD_TYPES[k as keyof typeof ML_JOB_FIELD_TYPES] === type + const requestedFieldType = Object.keys(JOB_FIELD_TYPES).find( + (k) => JOB_FIELD_TYPES[k as keyof typeof JOB_FIELD_TYPES] === type ); if (requestedFieldType === undefined) { return null; diff --git a/x-pack/plugins/file_data_visualizer/public/application/util/util.ts b/x-pack/plugins/file_data_visualizer/public/application/util/util.ts deleted file mode 100644 index ed703d6b2e7e3..0000000000000 --- a/x-pack/plugins/file_data_visualizer/public/application/util/util.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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. - */ - -// type LegacyUrlKeys = 'mlExplorerSwimlane'; - -// export type AppStateKey = -// | 'mlSelectSeverity' -// | 'mlSelectInterval' -// | 'mlAnomaliesTable' -// | MlPages -// | LegacyUrlKeys; - -// /** -// * Hook for managing the URL state of the page. -// */ -// export const usePageUrlState = ( -// pageKey: AppStateKey, -// defaultState?: PageUrlState -// ): [PageUrlState, (update: Partial, replaceState?: boolean) => void] => { -// const [appState, setAppState] = useUrlState('_a'); -// const pageState = appState?.[pageKey]; - -// const resultPageState: PageUrlState = useMemo(() => { -// return { -// ...(defaultState ?? {}), -// ...(pageState ?? {}), -// }; -// }, [pageState]); - -// const onStateUpdate = useCallback( -// (update: Partial, replaceState?: boolean) => { -// setAppState( -// pageKey, -// { -// ...resultPageState, -// ...update, -// }, -// replaceState -// ); -// }, -// [pageKey, resultPageState, setAppState] -// ); - -// return useMemo(() => { -// return [resultPageState, onStateUpdate]; -// }, [resultPageState, onStateUpdate]); -// }; diff --git a/x-pack/plugins/file_data_visualizer/public/plugin.ts b/x-pack/plugins/file_data_visualizer/public/plugin.ts index 16fecf81141db..c1a74f7a2a568 100644 --- a/x-pack/plugins/file_data_visualizer/public/plugin.ts +++ b/x-pack/plugins/file_data_visualizer/public/plugin.ts @@ -15,7 +15,7 @@ import { DataPublicPluginStart } from '../../../../src/plugins/data/public'; import type { FileUploadPluginStart } from '../../file_upload/public'; import type { MapsStartApi } from '../../maps/public'; import type { SecurityPluginSetup } from '../../security/public'; -import { getFileDatavisualizerComponent } from './api'; +import { getFileDataVisualizerComponent } from './api'; import { getMaxBytesFormatted } from './application/util/get_max_bytes'; // eslint-disable-next-line @typescript-eslint/no-empty-interface @@ -44,6 +44,6 @@ export class FileDataVisualizerPlugin public start(core: CoreStart, plugins: FileDataVisualizerStartDependencies) { setStartServices(core, plugins); - return { getFileDatavisualizerComponent, getMaxBytesFormatted }; + return { getFileDataVisualizerComponent, getMaxBytesFormatted }; } } diff --git a/x-pack/plugins/file_upload/common/constants.ts b/x-pack/plugins/file_upload/common/constants.ts index ea36e51466703..977f969647658 100644 --- a/x-pack/plugins/file_upload/common/constants.ts +++ b/x-pack/plugins/file_upload/common/constants.ts @@ -16,4 +16,4 @@ export const FILE_SIZE_DISPLAY_FORMAT = '0,0.[0] b'; // Value to use in the Elasticsearch index mapping meta data to identify the // index as having been created by the ML File Data Visualizer. -export const INDEX_META_DATA_CREATED_BY = 'ml-file-data-visualizer'; +export const INDEX_META_DATA_CREATED_BY = 'file-data-visualizer'; diff --git a/x-pack/test/functional/services/ml/data_visualizer_table.ts b/x-pack/test/functional/services/ml/data_visualizer_table.ts index 3bd3b7e2e783a..e2b9508b15a6b 100644 --- a/x-pack/test/functional/services/ml/data_visualizer_table.ts +++ b/x-pack/test/functional/services/ml/data_visualizer_table.ts @@ -309,7 +309,7 @@ export function MachineLearningDataVisualizerTableProvider( public async assertExamplesList(fieldName: string, expectedExamplesCount: number) { const examplesList = await testSubjects.find( - this.detailsSelector(fieldName, 'mlFieldDataExamplesList') + this.detailsSelector(fieldName, 'fieldDataExamplesList') ); const examplesListItems = await examplesList.findAllByTagName('li'); expect(examplesListItems).to.have.length( From 1c8123a4f7d375a1ef1b0f3ca08ca68f1ca8e2fa Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Thu, 15 Apr 2021 16:12:08 +0100 Subject: [PATCH 28/37] renaming function --- x-pack/plugins/file_data_visualizer/public/api/index.ts | 8 ++++---- .../file_data_visualizer/public/lazy_load_bundle/index.ts | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/x-pack/plugins/file_data_visualizer/public/api/index.ts b/x-pack/plugins/file_data_visualizer/public/api/index.ts index af35c2d64dbc9..df147ac441534 100644 --- a/x-pack/plugins/file_data_visualizer/public/api/index.ts +++ b/x-pack/plugins/file_data_visualizer/public/api/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { lazyLoadFileUploadModules } from '../lazy_load_bundle'; +import { lazyLoadModules } from '../lazy_load_bundle'; import { FileDataVisualizer } from '../application'; import { FindFileStructureResponse } from '../../common'; @@ -17,7 +17,7 @@ export async function analyzeFile( file: string, params: Record = {} ): Promise { - const { getHttp } = await lazyLoadFileUploadModules(); + const { getHttp } = await lazyLoadModules(); const body = JSON.stringify(file); return await getHttp().fetch({ path: `/internal/file_data_visualizer/analyze_file`, @@ -28,6 +28,6 @@ export async function analyzeFile( } export async function getFileDataVisualizerComponent(): Promise { - const fileUploadModules = await lazyLoadFileUploadModules(); - return fileUploadModules.FileDataVisualizer; + const modules = await lazyLoadModules(); + return modules.FileDataVisualizer; } diff --git a/x-pack/plugins/file_data_visualizer/public/lazy_load_bundle/index.ts b/x-pack/plugins/file_data_visualizer/public/lazy_load_bundle/index.ts index 005bf9a040520..5430fe52bb0dc 100644 --- a/x-pack/plugins/file_data_visualizer/public/lazy_load_bundle/index.ts +++ b/x-pack/plugins/file_data_visualizer/public/lazy_load_bundle/index.ts @@ -10,15 +10,15 @@ import { FileDataVisualizer } from '../application'; import { analyzeFile } from '../api'; import { getCoreStart } from '../kibana_services'; -let loadModulesPromise: Promise; +let loadModulesPromise: Promise; -interface LazyLoadedFileUploadModules { +interface LazyLoadedModules { analyzeFile: typeof analyzeFile; FileDataVisualizer: typeof FileDataVisualizer; getHttp: () => HttpSetup; } -export async function lazyLoadFileUploadModules(): Promise { +export async function lazyLoadModules(): Promise { if (typeof loadModulesPromise !== 'undefined') { return loadModulesPromise; } From 97480fe4354f23249ef7ab70bb48182cdb6c1f52 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Thu, 15 Apr 2021 16:56:32 +0100 Subject: [PATCH 29/37] moving analyse file endpoint to file upload plugin --- .../file_data_visualizer/common/types.ts | 100 ------------------ .../file_data_visualizer/public/api/index.ts | 19 ---- .../analysis_summary/analysis_summary.tsx | 2 +- .../combined_fields/combined_fields_form.tsx | 2 +- .../components/combined_fields/geo_point.tsx | 2 +- .../components/combined_fields/utils.ts | 6 +- .../explanation_flyout/explanation_flyout.tsx | 2 +- .../fields_stats_grid/create_fields.ts | 2 +- .../fields_stats_grid/fields_stats_grid.tsx | 3 +- .../fields_stats_grid/get_field_names.ts | 5 +- .../file_datavisualizer_view.js | 3 +- .../file_error_callouts.tsx | 3 +- .../filebeat_config_flyout/filebeat_config.ts | 2 +- .../filebeat_config_flyout.tsx | 2 +- .../components/import_settings/advanced.tsx | 2 +- .../import_settings/import_settings.tsx | 2 +- .../ml_embedded_map/ml_embedded_map.tsx | 12 +-- .../results_links/results_links.tsx | 9 +- .../components/results_view/results_view.tsx | 2 +- .../field_data_row/use_column_chart.tsx | 2 +- .../application/components/utils/utils.ts | 2 +- .../application/file_datavisualizer.tsx | 2 +- .../public/application/kibana_context.ts | 2 +- .../public/application/shared_imports.ts | 2 +- .../application/util/field_types_utils.ts | 3 +- .../public/lazy_load_bundle/index.ts | 2 - .../public/lazy_load_bundle/lazy/index.ts | 1 - .../file_data_visualizer/public/plugin.ts | 2 +- .../server/error_wrapper.ts | 24 ----- .../file_data_visualizer/server/plugin.ts | 9 +- .../file_data_visualizer/server/routes.ts | 60 ----------- .../file_data_visualizer/server/schemas.ts | 25 ----- .../file_data_visualizer/server/types.ts | 12 --- x-pack/plugins/file_upload/common/types.ts | 74 +++++++++++++ .../plugins/file_upload/public/api/index.ts | 48 +++++---- .../public/lazy_load_bundle/index.ts | 2 +- x-pack/plugins/file_upload/public/plugin.ts | 2 + .../server/analyze_file.tsx | 0 x-pack/plugins/file_upload/server/routes.ts | 41 ++++++- x-pack/plugins/file_upload/server/schemas.ts | 17 +++ .../file_based/file_datavisualizer.tsx | 4 +- 41 files changed, 207 insertions(+), 309 deletions(-) delete mode 100644 x-pack/plugins/file_data_visualizer/server/error_wrapper.ts delete mode 100644 x-pack/plugins/file_data_visualizer/server/routes.ts delete mode 100644 x-pack/plugins/file_data_visualizer/server/schemas.ts delete mode 100644 x-pack/plugins/file_data_visualizer/server/types.ts rename x-pack/plugins/{file_data_visualizer => file_upload}/server/analyze_file.tsx (100%) diff --git a/x-pack/plugins/file_data_visualizer/common/types.ts b/x-pack/plugins/file_data_visualizer/common/types.ts index f7f3d5bef7de6..edfe8b3575c8d 100644 --- a/x-pack/plugins/file_data_visualizer/common/types.ts +++ b/x-pack/plugins/file_data_visualizer/common/types.ts @@ -5,82 +5,8 @@ * 2.0. */ -import { ES_FIELD_TYPES } from '../../../../src/plugins/data/common'; import { JOB_FIELD_TYPES } from './constants'; -export interface InputOverrides { - [key: string]: string | undefined; -} - -export type FormattedOverrides = InputOverrides & { - column_names: string[]; - has_header_row: boolean; - should_trim_fields: boolean; -}; - -export interface AnalysisResult { - results: FindFileStructureResponse; - overrides?: FormattedOverrides; -} - -export interface FindFileStructureResponse { - charset: string; - has_header_row: boolean; - has_byte_order_marker: boolean; - format: string; - field_stats: { - [fieldName: string]: { - count: number; - cardinality: number; - top_hits: Array<{ count: number; value: any }>; - mean_value?: number; - median_value?: number; - max_value?: number; - min_value?: number; - earliest?: string; - latest?: string; - }; - }; - sample_start: string; - num_messages_analyzed: number; - mappings: { - properties: { - [fieldName: string]: { - // including all possible Elasticsearch types - // since find_file_structure API can be enhanced to include new fields in the future - type: Exclude< - ES_FIELD_TYPES, - ES_FIELD_TYPES._ID | ES_FIELD_TYPES._INDEX | ES_FIELD_TYPES._SOURCE | ES_FIELD_TYPES._TYPE - >; - format?: string; - }; - }; - }; - quote: string; - delimiter: string; - need_client_timezone: boolean; - num_lines_analyzed: number; - column_names?: string[]; - explanation?: string[]; - grok_pattern?: string; - multiline_start_pattern?: string; - exclude_lines_pattern?: string; - java_timestamp_formats?: string[]; - joda_timestamp_formats?: string[]; - timestamp_field?: string; - should_trim_fields?: boolean; -} - -export interface FindFileStructureErrorResponse { - body: { - statusCode: number; - error: string; - message: string; - attributes?: any; - }; - name: string; -} - export type InputData = any[]; export type JobFieldType = typeof JOB_FIELD_TYPES[keyof typeof JOB_FIELD_TYPES]; @@ -94,29 +20,3 @@ export interface DataVisualizerTableState { visibleFieldNames: string[]; showDistributions: boolean; } - -export interface Settings { - pipeline?: string; - index: string; - body: any[]; - [key: string]: any; -} - -export interface Mappings { - _meta?: { - created_by: string; - }; - properties: { - [key: string]: any; - }; -} - -export interface IngestPipelineWrapper { - id: string; - pipeline: IngestPipeline; -} - -export interface IngestPipeline { - description: string; - processors: any[]; -} diff --git a/x-pack/plugins/file_data_visualizer/public/api/index.ts b/x-pack/plugins/file_data_visualizer/public/api/index.ts index df147ac441534..13efd80133349 100644 --- a/x-pack/plugins/file_data_visualizer/public/api/index.ts +++ b/x-pack/plugins/file_data_visualizer/public/api/index.ts @@ -7,25 +7,6 @@ import { lazyLoadModules } from '../lazy_load_bundle'; import { FileDataVisualizer } from '../application'; -import { FindFileStructureResponse } from '../../common'; - -export interface FileDataVisualizerStartApi { - analyzeFile(file: string, params: Record): Promise; -} - -export async function analyzeFile( - file: string, - params: Record = {} -): Promise { - const { getHttp } = await lazyLoadModules(); - const body = JSON.stringify(file); - return await getHttp().fetch({ - path: `/internal/file_data_visualizer/analyze_file`, - method: 'POST', - body, - query: params, - }); -} export async function getFileDataVisualizerComponent(): Promise { const modules = await lazyLoadModules(); diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/analysis_summary/analysis_summary.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/analysis_summary/analysis_summary.tsx index 45cb542c63eb7..58177ea34286c 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/analysis_summary/analysis_summary.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/analysis_summary/analysis_summary.tsx @@ -9,7 +9,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import React, { FC } from 'react'; import { EuiTitle, EuiSpacer, EuiDescriptionList } from '@elastic/eui'; -import { FindFileStructureResponse } from '../../../../common'; +import { FindFileStructureResponse } from '../../../../../file_upload/common'; export const AnalysisSummary: FC<{ results: FindFileStructureResponse }> = ({ results }) => { const items = createDisplayItems(results); diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/combined_fields_form.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/combined_fields_form.tsx index aef6bcfced3ff..5472760182bb0 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/combined_fields_form.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/combined_fields_form.tsx @@ -29,7 +29,7 @@ import { removeCombinedFieldsFromMappings, removeCombinedFieldsFromPipeline, } from './utils'; -import { FindFileStructureResponse } from '../../../../common'; +import { FindFileStructureResponse } from '../../../../../file_upload/common'; interface Props { mappingsString: string; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/geo_point.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/geo_point.tsx index e2cf9916d6665..578d22384be33 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/geo_point.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/geo_point.tsx @@ -29,7 +29,7 @@ import { getFieldNames, getNameCollisionMsg, } from './utils'; -import { FindFileStructureResponse } from '../../../../common'; +import { FindFileStructureResponse } from '../../../../../file_upload/common'; interface Props { addCombinedField: (combinedField: CombinedField) => void; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/utils.ts b/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/utils.ts index 1537521bb84a6..efd166d4821c5 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/utils.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/utils.ts @@ -9,7 +9,11 @@ import { i18n } from '@kbn/i18n'; import { cloneDeep } from 'lodash'; import uuid from 'uuid/v4'; import { CombinedField } from './types'; -import { FindFileStructureResponse, IngestPipeline, Mappings } from '../../../../common'; +import { + FindFileStructureResponse, + IngestPipeline, + Mappings, +} from '../../../../../file_upload/common'; const COMMON_LAT_NAMES = ['latitude', 'lat']; const COMMON_LON_NAMES = ['longitude', 'long', 'lon']; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/explanation_flyout/explanation_flyout.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/explanation_flyout/explanation_flyout.tsx index a7f6e86293966..606bab514ac9f 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/explanation_flyout/explanation_flyout.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/explanation_flyout/explanation_flyout.tsx @@ -20,7 +20,7 @@ import { EuiText, EuiSubSteps, } from '@elastic/eui'; -import { FindFileStructureResponse } from '../../../../common'; +import { FindFileStructureResponse } from '../../../../../file_upload/common'; interface Props { results: FindFileStructureResponse; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/create_fields.ts b/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/create_fields.ts index c53e495af8eb7..f45071d6e96b5 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/create_fields.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/create_fields.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { FindFileStructureResponse } from '../../../../common'; +import { FindFileStructureResponse } from '../../../../../file_upload/common'; import { getFieldNames, getSupportedFieldType } from './get_field_names'; import { FileBasedFieldVisConfig } from '../stats_table/types'; import { JOB_FIELD_TYPES } from '../../../../common'; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/fields_stats_grid.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/fields_stats_grid.tsx index 533ec2d2d43cf..3b5b1bbf81dba 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/fields_stats_grid.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/fields_stats_grid.tsx @@ -7,7 +7,8 @@ import React, { useMemo, FC, useState } from 'react'; import { EuiFlexGroup, EuiSpacer } from '@elastic/eui'; -import type { FindFileStructureResponse, DataVisualizerTableState } from '../../../../common'; +import type { FindFileStructureResponse } from '../../../../../file_upload/common'; +import type { DataVisualizerTableState } from '../../../../common'; import { DataVisualizerTable, ItemIdToExpandedRowMap } from '../stats_table'; import type { FileBasedFieldVisConfig } from '../stats_table/types/field_vis_config'; import { FileBasedDataVisualizerExpandedRow } from '../expanded_row'; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/get_field_names.ts b/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/get_field_names.ts index 06a17cbd95706..a62a43a5071c1 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/get_field_names.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/get_field_names.ts @@ -6,8 +6,9 @@ */ import { difference } from 'lodash'; -import type { FindFileStructureResponse, JobFieldType } from '../../../../common'; -import { ES_FIELD_TYPES } from '../../../../../../../src/plugins/data/common'; +import { ES_FIELD_TYPES } from 'src/plugins/data/common'; +import type { FindFileStructureResponse } from '../../../../../file_upload/common'; +import type { JobFieldType } from '../../../../common'; import { JOB_FIELD_TYPES } from '../../../../common'; export function getFieldNames(results: FindFileStructureResponse) { const { mappings, field_stats: fieldStats, column_names: columnNames } = results; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_datavisualizer_view.js b/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_datavisualizer_view.js index 18e3188f71abf..6a1b2e5fa43f9 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_datavisualizer_view.js +++ b/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_datavisualizer_view.js @@ -20,7 +20,6 @@ import { EditFlyout } from '../edit_flyout'; import { ExplanationFlyout } from '../explanation_flyout'; import { ImportView } from '../import_view'; import { DEFAULT_LINES_TO_SAMPLE, readFile, createUrlOverrides, processResults } from '../utils'; -import { analyzeFile } from '../../../api'; import { MODE } from './constants'; @@ -127,7 +126,7 @@ export class FileDataVisualizerView extends Component { async analyzeFile(fileContents, overrides, isRetry = false) { try { - const resp = await analyzeFile(fileContents, overrides); + const resp = await this.props.fileUpload.analyzeFile(fileContents, overrides); const serverSettings = processResults(resp); const serverOverrides = resp.overrides; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_error_callouts.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_error_callouts.tsx index 732a8fa91b52c..35654b78c020f 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_error_callouts.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_error_callouts.tsx @@ -11,7 +11,8 @@ import React, { FC } from 'react'; import { EuiCallOut, EuiSpacer, EuiButtonEmpty, EuiHorizontalRule } from '@elastic/eui'; import numeral from '@elastic/numeral'; -import { FILE_SIZE_DISPLAY_FORMAT, FindFileStructureErrorResponse } from '../../../../common'; +import { FILE_SIZE_DISPLAY_FORMAT } from '../../../../common'; +import { FindFileStructureErrorResponse } from '../../../../../file_upload/common'; interface FileTooLargeProps { fileSize: number; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/filebeat_config.ts b/x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/filebeat_config.ts index 035ea592f7f7f..1cbb177c86442 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/filebeat_config.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/filebeat_config.ts @@ -6,7 +6,7 @@ */ import { i18n } from '@kbn/i18n'; -import { FindFileStructureResponse } from '../../../../common'; +import { FindFileStructureResponse } from '../../../../../file_upload/common'; export function createFilebeatConfig( index: string, diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/filebeat_config_flyout.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/filebeat_config_flyout.tsx index d7c0c160d7bd9..a5d05bb06f78e 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/filebeat_config_flyout.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/filebeat_config_flyout.tsx @@ -23,7 +23,7 @@ import { } from '@elastic/eui'; import { createFilebeatConfig } from './filebeat_config'; import { useFileDataVisualizerKibana } from '../../kibana_context'; // copy context? -import { FindFileStructureResponse } from '../../../../common'; +import { FindFileStructureResponse } from '../../../../../file_upload/common'; export enum EDITOR_MODE { HIDDEN, diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/advanced.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/advanced.tsx index fe0ce9e5fe9b9..e7723f96d5af0 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/advanced.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/advanced.tsx @@ -20,7 +20,7 @@ import { import { CombinedField, CombinedFieldsForm } from '../combined_fields'; import { MLJobEditor, ML_EDITOR_MODE } from '../ml_job_editor'; -import { FindFileStructureResponse } from '../../../../common'; +import { FindFileStructureResponse } from '../../../../../file_upload/common'; const EDITOR_HEIGHT = '300px'; interface Props { diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/import_settings.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/import_settings.tsx index 6e1398de20407..f68453f9a0ee9 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/import_settings.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/import_settings.tsx @@ -13,7 +13,7 @@ import { EuiTabbedContent, EuiSpacer } from '@elastic/eui'; import { SimpleSettings } from './simple'; import { AdvancedSettings } from './advanced'; import { CombinedField } from '../combined_fields'; -import { FindFileStructureResponse } from '../../../../common'; +import { FindFileStructureResponse } from '../../../../../file_upload/common'; interface Props { index: string; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/ml_embedded_map.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/ml_embedded_map.tsx index 5cc260a9dc194..738ec28f7bc8b 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/ml_embedded_map.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/ml_embedded_map.tsx @@ -8,6 +8,12 @@ import React, { useEffect, useRef, useState } from 'react'; import { htmlIdGenerator } from '@elastic/eui'; +import { + EmbeddableFactory, + ErrorEmbeddable, + isErrorEmbeddable, + ViewMode, +} from 'src/plugins/embeddable/public'; import { LayerDescriptor } from '../../../../../maps/common/descriptor_types'; import { INITIAL_LOCATION } from '../../../../../maps/common/constants'; import { @@ -17,12 +23,6 @@ import { // eslint-disable-next-line @kbn/eslint/no-restricted-paths } from '../../../../../maps/public/embeddable'; import { MAP_SAVED_OBJECT_TYPE, RenderTooltipContentParams } from '../../../../../maps/public'; -import { - EmbeddableFactory, - ErrorEmbeddable, - isErrorEmbeddable, - ViewMode, -} from '../../../../../../../src/plugins/embeddable/public'; import { useFileDataVisualizerKibana } from '../../kibana_context'; export function MlEmbeddedMapComponent({ diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/results_links/results_links.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/results_links/results_links.tsx index 57932cafec061..8b19b84043a70 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/results_links/results_links.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/results_links/results_links.tsx @@ -9,13 +9,10 @@ import React, { FC, useState, useEffect } from 'react'; import moment from 'moment'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiFlexGroup, EuiFlexItem, EuiCard, EuiIcon } from '@elastic/eui'; -import { - DISCOVER_APP_URL_GENERATOR, - DiscoverUrlGeneratorState, -} from '../../../../../../../src/plugins/discover/public'; -import { FindFileStructureResponse } from '../../../../common'; -import { useFileDataVisualizerKibana } from '../../kibana_context'; +import { DISCOVER_APP_URL_GENERATOR, DiscoverUrlGeneratorState } from 'src/plugins/discover/public'; +import { FindFileStructureResponse } from '../../../../../file_upload/common'; import type { FileUploadPluginStart } from '../../../../../file_upload/public'; +import { useFileDataVisualizerKibana } from '../../kibana_context'; interface Props { fieldStats: FindFileStructureResponse['field_stats']; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/results_view/results_view.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/results_view/results_view.tsx index 907f9ae638a84..e2d21f242e4ef 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/results_view/results_view.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/results_view/results_view.tsx @@ -20,7 +20,7 @@ import { EuiFlexGroup, EuiFlexItem, } from '@elastic/eui'; -import { FindFileStructureResponse } from '../../../../common'; +import { FindFileStructureResponse } from '../../../../../file_upload/common'; import { FileContents } from '../file_contents'; import { AnalysisSummary } from '../analysis_summary'; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx index 436f740bee41f..ed7e3e6ea4d0e 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx @@ -15,7 +15,7 @@ import { euiPaletteColorBlind, EuiDataGridColumn } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { KBN_FIELD_TYPES } from '../../../../../../../../../src/plugins/data/public'; +import { KBN_FIELD_TYPES } from 'src/plugins/data/public'; import { isNumericChartData, diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/utils/utils.ts b/x-pack/plugins/file_data_visualizer/public/application/components/utils/utils.ts index 6899d8476322f..1d47e633188c5 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/utils/utils.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/components/utils/utils.ts @@ -6,7 +6,7 @@ */ import { isEqual } from 'lodash'; -import { AnalysisResult, InputOverrides, MB } from '../../../../common'; +import { AnalysisResult, InputOverrides, MB } from '../../../../../file_upload/common'; export const DEFAULT_LINES_TO_SAMPLE = 1000; const UPLOAD_SIZE_MB = 5; diff --git a/x-pack/plugins/file_data_visualizer/public/application/file_datavisualizer.tsx b/x-pack/plugins/file_data_visualizer/public/application/file_datavisualizer.tsx index f291076557bb8..42a927abbf9e4 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/file_datavisualizer.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/file_datavisualizer.tsx @@ -6,7 +6,7 @@ */ import './_index.scss'; import React, { FC } from 'react'; -import { KibanaContextProvider } from '../../../../../src/plugins/kibana_react/public'; +import { KibanaContextProvider } from 'src/plugins/kibana_react/public'; import { getCoreStart, getPluginsStart } from '../kibana_services'; // @ts-ignore diff --git a/x-pack/plugins/file_data_visualizer/public/application/kibana_context.ts b/x-pack/plugins/file_data_visualizer/public/application/kibana_context.ts index 29c7cfe9bb553..cb83e45b916b5 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/kibana_context.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/kibana_context.ts @@ -6,7 +6,7 @@ */ import { CoreStart } from 'kibana/public'; -import { useKibana, KibanaReactContextValue } from '../../../../../src/plugins/kibana_react/public'; +import { useKibana, KibanaReactContextValue } from 'src/plugins/kibana_react/public'; import type { FileDataVisualizerStartDependencies } from '../plugin'; export type StartServices = CoreStart & FileDataVisualizerStartDependencies; diff --git a/x-pack/plugins/file_data_visualizer/public/application/shared_imports.ts b/x-pack/plugins/file_data_visualizer/public/application/shared_imports.ts index 20481d2fde9be..807458ca87cd0 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/shared_imports.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/shared_imports.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { XJson } from '../../../../../src/plugins/es_ui_shared/public'; +import { XJson } from 'src/plugins/es_ui_shared/public'; const { collapseLiteralStrings, expandLiteralStrings } = XJson; export { XJsonMode } from '@kbn/ace'; diff --git a/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.ts b/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.ts index 6f46ac518ffd7..e0465be44e71e 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.ts @@ -6,10 +6,9 @@ */ import { i18n } from '@kbn/i18n'; +import { IFieldType, KBN_FIELD_TYPES } from 'src/plugins/data/public'; import { JOB_FIELD_TYPES } from '../../../common'; -import { IFieldType, KBN_FIELD_TYPES } from '../../../../../../src/plugins/data/public'; - // convert kibana types to ML Job types // this is needed because kibana types only have string and not text and keyword. // and we can't use ES_FIELD_TYPES because it has no NUMBER type diff --git a/x-pack/plugins/file_data_visualizer/public/lazy_load_bundle/index.ts b/x-pack/plugins/file_data_visualizer/public/lazy_load_bundle/index.ts index 5430fe52bb0dc..99dbb6d3746ce 100644 --- a/x-pack/plugins/file_data_visualizer/public/lazy_load_bundle/index.ts +++ b/x-pack/plugins/file_data_visualizer/public/lazy_load_bundle/index.ts @@ -7,13 +7,11 @@ import { HttpSetup } from 'src/core/public'; import { FileDataVisualizer } from '../application'; -import { analyzeFile } from '../api'; import { getCoreStart } from '../kibana_services'; let loadModulesPromise: Promise; interface LazyLoadedModules { - analyzeFile: typeof analyzeFile; FileDataVisualizer: typeof FileDataVisualizer; getHttp: () => HttpSetup; } diff --git a/x-pack/plugins/file_data_visualizer/public/lazy_load_bundle/lazy/index.ts b/x-pack/plugins/file_data_visualizer/public/lazy_load_bundle/lazy/index.ts index 2c63cb0742414..4229b95f3aaad 100644 --- a/x-pack/plugins/file_data_visualizer/public/lazy_load_bundle/lazy/index.ts +++ b/x-pack/plugins/file_data_visualizer/public/lazy_load_bundle/lazy/index.ts @@ -6,4 +6,3 @@ */ export { FileDataVisualizer } from '../../application'; -export { analyzeFile } from '../../api'; diff --git a/x-pack/plugins/file_data_visualizer/public/plugin.ts b/x-pack/plugins/file_data_visualizer/public/plugin.ts index c1a74f7a2a568..c0e52259ec0d4 100644 --- a/x-pack/plugins/file_data_visualizer/public/plugin.ts +++ b/x-pack/plugins/file_data_visualizer/public/plugin.ts @@ -8,10 +8,10 @@ import { CoreStart } from 'kibana/public'; import type { EmbeddableStart } from 'src/plugins/embeddable/public'; import type { SharePluginStart } from 'src/plugins/share/public'; +import { DataPublicPluginStart } from 'src/plugins/data/public'; import { Plugin } from '../../../../src/core/public'; import { setStartServices } from './kibana_services'; -import { DataPublicPluginStart } from '../../../../src/plugins/data/public'; import type { FileUploadPluginStart } from '../../file_upload/public'; import type { MapsStartApi } from '../../maps/public'; import type { SecurityPluginSetup } from '../../security/public'; diff --git a/x-pack/plugins/file_data_visualizer/server/error_wrapper.ts b/x-pack/plugins/file_data_visualizer/server/error_wrapper.ts deleted file mode 100644 index 64395f601f9ac..0000000000000 --- a/x-pack/plugins/file_data_visualizer/server/error_wrapper.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 { boomify, isBoom } from '@hapi/boom'; -import { ResponseError, CustomHttpResponseOptions } from 'kibana/server'; - -export function wrapError(error: any): CustomHttpResponseOptions { - const boom = isBoom(error) - ? error - : boomify(error, { statusCode: error.status ?? error.statusCode }); - const statusCode = boom.output.statusCode; - return { - body: { - message: boom, - ...(statusCode !== 500 && error.body ? { attributes: { body: error.body } } : {}), - }, - headers: boom.output.headers as { [key: string]: string }, - statusCode, - }; -} diff --git a/x-pack/plugins/file_data_visualizer/server/plugin.ts b/x-pack/plugins/file_data_visualizer/server/plugin.ts index 344a484ebdfaa..f6893b7edaa53 100644 --- a/x-pack/plugins/file_data_visualizer/server/plugin.ts +++ b/x-pack/plugins/file_data_visualizer/server/plugin.ts @@ -5,14 +5,9 @@ * 2.0. */ -import { CoreSetup, Plugin } from 'src/core/server'; -import { fileDataVisualizerRoutes } from './routes'; -import { StartDeps } from './types'; +import { Plugin } from 'src/core/server'; export class FileDataVisualizerPlugin implements Plugin { - async setup(coreSetup: CoreSetup) { - fileDataVisualizerRoutes(coreSetup); - } - + setup() {} start() {} } diff --git a/x-pack/plugins/file_data_visualizer/server/routes.ts b/x-pack/plugins/file_data_visualizer/server/routes.ts deleted file mode 100644 index 4a92ba6abc84b..0000000000000 --- a/x-pack/plugins/file_data_visualizer/server/routes.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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 { schema } from '@kbn/config-schema'; -import { CoreSetup } from 'src/core/server'; -import { MAX_FILE_SIZE_BYTES } from '../common'; -import { wrapError } from './error_wrapper'; -import { analyzeFile } from './analyze_file'; - -import { analyzeFileQuerySchema } from './schemas'; -import { StartDeps } from './types'; - -/** - * Routes for the file upload. - */ -export function fileDataVisualizerRoutes(coreSetup: CoreSetup) { - const router = coreSetup.http.createRouter(); - - /** - * @apiGroup FileDataVisualizer - * - * @api {post} /internal/file_upload/analyze_file Analyze file data - * @apiName AnalyzeFile - * @apiDescription Performs analysis of the file data. - * - * @apiSchema (query) analyzeFileQuerySchema - */ - router.post( - { - path: '/internal/file_data_visualizer/analyze_file', - validate: { - body: schema.any(), - query: analyzeFileQuerySchema, - }, - options: { - body: { - accepts: ['text/*', 'application/json'], - maxBytes: MAX_FILE_SIZE_BYTES, - }, - tags: ['access:fileUpload:analyzeFile'], - }, - }, - async (context, request, response) => { - try { - const result = await analyzeFile( - context.core.elasticsearch.client, - request.body, - request.query - ); - return response.ok({ body: result }); - } catch (e) { - return response.customError(wrapError(e)); - } - } - ); -} diff --git a/x-pack/plugins/file_data_visualizer/server/schemas.ts b/x-pack/plugins/file_data_visualizer/server/schemas.ts deleted file mode 100644 index 276aa46e42385..0000000000000 --- a/x-pack/plugins/file_data_visualizer/server/schemas.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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 { schema } from '@kbn/config-schema'; - -export const analyzeFileQuerySchema = schema.object({ - charset: schema.maybe(schema.string()), - column_names: schema.maybe(schema.string()), - delimiter: schema.maybe(schema.string()), - explain: schema.maybe(schema.string()), - format: schema.maybe(schema.string()), - grok_pattern: schema.maybe(schema.string()), - has_header_row: schema.maybe(schema.string()), - line_merge_size_limit: schema.maybe(schema.string()), - lines_to_sample: schema.maybe(schema.string()), - quote: schema.maybe(schema.string()), - should_trim_fields: schema.maybe(schema.string()), - timeout: schema.maybe(schema.string()), - timestamp_field: schema.maybe(schema.string()), - timestamp_format: schema.maybe(schema.string()), -}); diff --git a/x-pack/plugins/file_data_visualizer/server/types.ts b/x-pack/plugins/file_data_visualizer/server/types.ts deleted file mode 100644 index d23661ebae711..0000000000000 --- a/x-pack/plugins/file_data_visualizer/server/types.ts +++ /dev/null @@ -1,12 +0,0 @@ -/* - * 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 { SecurityPluginStart } from '../..//security/server'; - -export interface StartDeps { - security?: SecurityPluginStart; -} diff --git a/x-pack/plugins/file_upload/common/types.ts b/x-pack/plugins/file_upload/common/types.ts index 1ccd8b91cc4c2..d0e03de9b4ccc 100644 --- a/x-pack/plugins/file_upload/common/types.ts +++ b/x-pack/plugins/file_upload/common/types.ts @@ -6,6 +6,80 @@ */ import type { estypes } from '@elastic/elasticsearch'; +import { ES_FIELD_TYPES } from 'src/plugins/data/common'; + +export interface InputOverrides { + [key: string]: string | undefined; +} + +export type FormattedOverrides = InputOverrides & { + column_names: string[]; + has_header_row: boolean; + should_trim_fields: boolean; +}; + +export interface AnalysisResult { + results: FindFileStructureResponse; + overrides?: FormattedOverrides; +} + +export interface FindFileStructureResponse { + charset: string; + has_header_row: boolean; + has_byte_order_marker: boolean; + format: string; + field_stats: { + [fieldName: string]: { + count: number; + cardinality: number; + top_hits: Array<{ count: number; value: any }>; + mean_value?: number; + median_value?: number; + max_value?: number; + min_value?: number; + earliest?: string; + latest?: string; + }; + }; + sample_start: string; + num_messages_analyzed: number; + mappings: { + properties: { + [fieldName: string]: { + // including all possible Elasticsearch types + // since find_file_structure API can be enhanced to include new fields in the future + type: Exclude< + ES_FIELD_TYPES, + ES_FIELD_TYPES._ID | ES_FIELD_TYPES._INDEX | ES_FIELD_TYPES._SOURCE | ES_FIELD_TYPES._TYPE + >; + format?: string; + }; + }; + }; + quote: string; + delimiter: string; + need_client_timezone: boolean; + num_lines_analyzed: number; + column_names?: string[]; + explanation?: string[]; + grok_pattern?: string; + multiline_start_pattern?: string; + exclude_lines_pattern?: string; + java_timestamp_formats?: string[]; + joda_timestamp_formats?: string[]; + timestamp_field?: string; + should_trim_fields?: boolean; +} + +export interface FindFileStructureErrorResponse { + body: { + statusCode: number; + error: string; + message: string; + attributes?: any; + }; + name: string; +} export interface HasImportPermission { hasImportPermission: boolean; diff --git a/x-pack/plugins/file_upload/public/api/index.ts b/x-pack/plugins/file_upload/public/api/index.ts index 10444970a91a1..909dca76242ba 100644 --- a/x-pack/plugins/file_upload/public/api/index.ts +++ b/x-pack/plugins/file_upload/public/api/index.ts @@ -6,22 +6,20 @@ */ import React from 'react'; -import { FileUploadComponentProps, lazyLoadFileUploadModules } from '../lazy_load_bundle'; +import { FileUploadComponentProps, lazyLoadModules } from '../lazy_load_bundle'; import type { IImporter, ImportFactoryOptions } from '../importer'; -import { HasImportPermission } from '../../common'; +import type { HasImportPermission, FindFileStructureResponse } from '../../common'; +import type { getMaxBytes, getMaxBytesFormatted } from '../importer/get_max_bytes'; export interface FileUploadStartApi { - getFileUploadComponent(): Promise>; - importerFactory(format: string, options: ImportFactoryOptions): Promise; - getMaxBytes(): number; - getMaxBytesFormatted(): string; - hasImportPermission(params: HasImportPermissionParams): Promise; - checkIndexExists(index: string, params: Record): Promise; - getTimeFieldRange( - index: string, - query: any, - timeFieldName?: string - ): Promise; + getFileUploadComponent(): ReturnType; + importerFactory: typeof importerFactory; + getMaxBytes: typeof getMaxBytes; + getMaxBytesFormatted: typeof getMaxBytesFormatted; + hasImportPermission: typeof hasImportPermission; + checkIndexExists: typeof checkIndexExists; + getTimeFieldRange: typeof getTimeFieldRange; + analyzeFile: typeof analyzeFile; } export interface GetTimeFieldRangeResponse { @@ -33,7 +31,7 @@ export interface GetTimeFieldRangeResponse { export async function getFileUploadComponent(): Promise< React.ComponentType > { - const fileUploadModules = await lazyLoadFileUploadModules(); + const fileUploadModules = await lazyLoadModules(); return fileUploadModules.JsonUploadAndParse; } @@ -41,7 +39,7 @@ export async function importerFactory( format: string, options: ImportFactoryOptions ): Promise { - const fileUploadModules = await lazyLoadFileUploadModules(); + const fileUploadModules = await lazyLoadModules(); return fileUploadModules.importerFactory(format, options); } @@ -51,8 +49,22 @@ interface HasImportPermissionParams { indexName?: string; } +export async function analyzeFile( + file: string, + params: Record = {} +): Promise { + const { getHttp } = await lazyLoadModules(); + const body = JSON.stringify(file); + return await getHttp().fetch({ + path: `/internal/file_data_visualizer/analyze_file`, + method: 'POST', + body, + query: params, + }); +} + export async function hasImportPermission(params: HasImportPermissionParams): Promise { - const fileUploadModules = await lazyLoadFileUploadModules(); + const fileUploadModules = await lazyLoadModules(); try { const resp = await fileUploadModules.getHttp().fetch({ path: `/internal/file_upload/has_import_permission`, @@ -70,7 +82,7 @@ export async function checkIndexExists( params: Record = {} ): Promise { const body = JSON.stringify({ index }); - const fileUploadModules = await lazyLoadFileUploadModules(); + const fileUploadModules = await lazyLoadModules(); return await fileUploadModules.getHttp().fetch({ path: `/internal/file_upload/index_exists`, method: 'POST', @@ -82,7 +94,7 @@ export async function checkIndexExists( export async function getTimeFieldRange(index: string, query: any, timeFieldName?: string) { const body = JSON.stringify({ index, timeFieldName, query }); - const fileUploadModules = await lazyLoadFileUploadModules(); + const fileUploadModules = await lazyLoadModules(); return await fileUploadModules.getHttp().fetch({ path: `/internal/file_upload/time_field_range`, method: 'POST', diff --git a/x-pack/plugins/file_upload/public/lazy_load_bundle/index.ts b/x-pack/plugins/file_upload/public/lazy_load_bundle/index.ts index 807d2fae52bf8..15a2453eb044e 100644 --- a/x-pack/plugins/file_upload/public/lazy_load_bundle/index.ts +++ b/x-pack/plugins/file_upload/public/lazy_load_bundle/index.ts @@ -32,7 +32,7 @@ interface LazyLoadedFileUploadModules { getHttp: () => HttpStart; } -export async function lazyLoadFileUploadModules(): Promise { +export async function lazyLoadModules(): Promise { if (typeof loadModulesPromise !== 'undefined') { return loadModulesPromise; } diff --git a/x-pack/plugins/file_upload/public/plugin.ts b/x-pack/plugins/file_upload/public/plugin.ts index 9bbbd1cd774e4..19306fadfd61c 100644 --- a/x-pack/plugins/file_upload/public/plugin.ts +++ b/x-pack/plugins/file_upload/public/plugin.ts @@ -13,6 +13,7 @@ import { hasImportPermission, checkIndexExists, getTimeFieldRange, + analyzeFile, } from './api'; import { setStartServices } from './kibana_services'; import { DataPublicPluginStart } from '../../../../src/plugins/data/public'; @@ -47,6 +48,7 @@ export class FileUploadPlugin hasImportPermission, checkIndexExists, getTimeFieldRange, + analyzeFile, }; } } diff --git a/x-pack/plugins/file_data_visualizer/server/analyze_file.tsx b/x-pack/plugins/file_upload/server/analyze_file.tsx similarity index 100% rename from x-pack/plugins/file_data_visualizer/server/analyze_file.tsx rename to x-pack/plugins/file_upload/server/analyze_file.tsx diff --git a/x-pack/plugins/file_upload/server/routes.ts b/x-pack/plugins/file_upload/server/routes.ts index 6078312c07bb4..f2e796ec53ce0 100644 --- a/x-pack/plugins/file_upload/server/routes.ts +++ b/x-pack/plugins/file_upload/server/routes.ts @@ -18,9 +18,10 @@ import { import { wrapError } from './error_wrapper'; import { importDataProvider } from './import_data'; import { getTimeFieldRange } from './get_time_field_range'; +import { analyzeFile } from './analyze_file'; import { updateTelemetry } from './telemetry'; -import { importFileBodySchema, importFileQuerySchema } from './schemas'; +import { importFileBodySchema, importFileQuerySchema, analyzeFileQuerySchema } from './schemas'; import { CheckPrivilegesPayload } from '../../security/server'; import { StartDeps } from './types'; @@ -89,6 +90,44 @@ export function fileUploadRoutes(coreSetup: CoreSetup, logge } ); + /** + * @apiGroup FileDataVisualizer + * + * @api {post} /internal/file_upload/analyze_file Analyze file data + * @apiName AnalyzeFile + * @apiDescription Performs analysis of the file data. + * + * @apiSchema (query) analyzeFileQuerySchema + */ + router.post( + { + path: '/internal/file_data_visualizer/analyze_file', + validate: { + body: schema.any(), + query: analyzeFileQuerySchema, + }, + options: { + body: { + accepts: ['text/*', 'application/json'], + maxBytes: MAX_FILE_SIZE_BYTES, + }, + tags: ['access:fileUpload:analyzeFile'], + }, + }, + async (context, request, response) => { + try { + const result = await analyzeFile( + context.core.elasticsearch.client, + request.body, + request.query + ); + return response.ok({ body: result }); + } catch (e) { + return response.customError(wrapError(e)); + } + } + ); + /** * @apiGroup FileDataVisualizer * diff --git a/x-pack/plugins/file_upload/server/schemas.ts b/x-pack/plugins/file_upload/server/schemas.ts index bfef9885b3216..a0d54cf9ec553 100644 --- a/x-pack/plugins/file_upload/server/schemas.ts +++ b/x-pack/plugins/file_upload/server/schemas.ts @@ -7,6 +7,23 @@ import { schema } from '@kbn/config-schema'; +export const analyzeFileQuerySchema = schema.object({ + charset: schema.maybe(schema.string()), + column_names: schema.maybe(schema.string()), + delimiter: schema.maybe(schema.string()), + explain: schema.maybe(schema.string()), + format: schema.maybe(schema.string()), + grok_pattern: schema.maybe(schema.string()), + has_header_row: schema.maybe(schema.string()), + line_merge_size_limit: schema.maybe(schema.string()), + lines_to_sample: schema.maybe(schema.string()), + quote: schema.maybe(schema.string()), + should_trim_fields: schema.maybe(schema.string()), + timeout: schema.maybe(schema.string()), + timestamp_field: schema.maybe(schema.string()), + timestamp_format: schema.maybe(schema.string()), +}); + export const importFileQuerySchema = schema.object({ id: schema.maybe(schema.string()), }); diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx b/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx index dcc0ea9bd5579..3b4cfbf33fbfc 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx +++ b/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx @@ -21,8 +21,8 @@ export const FileDataVisualizerPage: FC = () => { useEffect(() => { if (fileDataVisualizer !== undefined) { - const { getFileDatavisualizerComponent } = fileDataVisualizer; - getFileDatavisualizerComponent().then(setFileDataVisualizer); + const { getFileDataVisualizerComponent } = fileDataVisualizer; + getFileDataVisualizerComponent().then(setFileDataVisualizer); } }, []); From ed6c91928e052d45b63c6519e7960f6248d14d44 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Thu, 15 Apr 2021 18:32:13 +0100 Subject: [PATCH 30/37] reverting import path changes --- x-pack/plugins/file_data_visualizer/kibana.json | 1 - .../components/fields_stats_grid/get_field_names.ts | 2 +- .../components/ml_embedded_map/ml_embedded_map.tsx | 12 ++++++------ .../components/results_links/results_links.tsx | 5 ++++- .../components/field_data_row/use_column_chart.tsx | 2 +- .../public/application/file_datavisualizer.tsx | 2 +- .../public/application/kibana_context.ts | 2 +- .../public/application/shared_imports.ts | 2 +- .../public/application/util/field_types_utils.ts | 3 ++- x-pack/plugins/file_data_visualizer/public/plugin.ts | 6 +++--- 10 files changed, 20 insertions(+), 17 deletions(-) diff --git a/x-pack/plugins/file_data_visualizer/kibana.json b/x-pack/plugins/file_data_visualizer/kibana.json index 8a3d977b47e5e..325b000275d6e 100644 --- a/x-pack/plugins/file_data_visualizer/kibana.json +++ b/x-pack/plugins/file_data_visualizer/kibana.json @@ -17,7 +17,6 @@ "maps" ], "requiredBundles": [ - "esUiShared", "kibanaReact", "maps" ], diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/get_field_names.ts b/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/get_field_names.ts index a62a43a5071c1..83c517dfe965e 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/get_field_names.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/get_field_names.ts @@ -6,7 +6,7 @@ */ import { difference } from 'lodash'; -import { ES_FIELD_TYPES } from 'src/plugins/data/common'; +import { ES_FIELD_TYPES } from '../../../../../../../src/plugins/data/common'; import type { FindFileStructureResponse } from '../../../../../file_upload/common'; import type { JobFieldType } from '../../../../common'; import { JOB_FIELD_TYPES } from '../../../../common'; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/ml_embedded_map.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/ml_embedded_map.tsx index 738ec28f7bc8b..5cc260a9dc194 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/ml_embedded_map.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/ml_embedded_map.tsx @@ -8,12 +8,6 @@ import React, { useEffect, useRef, useState } from 'react'; import { htmlIdGenerator } from '@elastic/eui'; -import { - EmbeddableFactory, - ErrorEmbeddable, - isErrorEmbeddable, - ViewMode, -} from 'src/plugins/embeddable/public'; import { LayerDescriptor } from '../../../../../maps/common/descriptor_types'; import { INITIAL_LOCATION } from '../../../../../maps/common/constants'; import { @@ -23,6 +17,12 @@ import { // eslint-disable-next-line @kbn/eslint/no-restricted-paths } from '../../../../../maps/public/embeddable'; import { MAP_SAVED_OBJECT_TYPE, RenderTooltipContentParams } from '../../../../../maps/public'; +import { + EmbeddableFactory, + ErrorEmbeddable, + isErrorEmbeddable, + ViewMode, +} from '../../../../../../../src/plugins/embeddable/public'; import { useFileDataVisualizerKibana } from '../../kibana_context'; export function MlEmbeddedMapComponent({ diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/results_links/results_links.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/results_links/results_links.tsx index 8b19b84043a70..c38e4f5b2e983 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/results_links/results_links.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/results_links/results_links.tsx @@ -9,7 +9,10 @@ import React, { FC, useState, useEffect } from 'react'; import moment from 'moment'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiFlexGroup, EuiFlexItem, EuiCard, EuiIcon } from '@elastic/eui'; -import { DISCOVER_APP_URL_GENERATOR, DiscoverUrlGeneratorState } from 'src/plugins/discover/public'; +import { + DISCOVER_APP_URL_GENERATOR, + DiscoverUrlGeneratorState, +} from '../../../../../../../src/plugins/discover/public'; import { FindFileStructureResponse } from '../../../../../file_upload/common'; import type { FileUploadPluginStart } from '../../../../../file_upload/public'; import { useFileDataVisualizerKibana } from '../../kibana_context'; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx index ed7e3e6ea4d0e..436f740bee41f 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx @@ -15,7 +15,7 @@ import { euiPaletteColorBlind, EuiDataGridColumn } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { KBN_FIELD_TYPES } from 'src/plugins/data/public'; +import { KBN_FIELD_TYPES } from '../../../../../../../../../src/plugins/data/public'; import { isNumericChartData, diff --git a/x-pack/plugins/file_data_visualizer/public/application/file_datavisualizer.tsx b/x-pack/plugins/file_data_visualizer/public/application/file_datavisualizer.tsx index 42a927abbf9e4..f291076557bb8 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/file_datavisualizer.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/file_datavisualizer.tsx @@ -6,7 +6,7 @@ */ import './_index.scss'; import React, { FC } from 'react'; -import { KibanaContextProvider } from 'src/plugins/kibana_react/public'; +import { KibanaContextProvider } from '../../../../../src/plugins/kibana_react/public'; import { getCoreStart, getPluginsStart } from '../kibana_services'; // @ts-ignore diff --git a/x-pack/plugins/file_data_visualizer/public/application/kibana_context.ts b/x-pack/plugins/file_data_visualizer/public/application/kibana_context.ts index cb83e45b916b5..29c7cfe9bb553 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/kibana_context.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/kibana_context.ts @@ -6,7 +6,7 @@ */ import { CoreStart } from 'kibana/public'; -import { useKibana, KibanaReactContextValue } from 'src/plugins/kibana_react/public'; +import { useKibana, KibanaReactContextValue } from '../../../../../src/plugins/kibana_react/public'; import type { FileDataVisualizerStartDependencies } from '../plugin'; export type StartServices = CoreStart & FileDataVisualizerStartDependencies; diff --git a/x-pack/plugins/file_data_visualizer/public/application/shared_imports.ts b/x-pack/plugins/file_data_visualizer/public/application/shared_imports.ts index 807458ca87cd0..20481d2fde9be 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/shared_imports.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/shared_imports.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { XJson } from 'src/plugins/es_ui_shared/public'; +import { XJson } from '../../../../../src/plugins/es_ui_shared/public'; const { collapseLiteralStrings, expandLiteralStrings } = XJson; export { XJsonMode } from '@kbn/ace'; diff --git a/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.ts b/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.ts index e0465be44e71e..6f46ac518ffd7 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.ts @@ -6,9 +6,10 @@ */ import { i18n } from '@kbn/i18n'; -import { IFieldType, KBN_FIELD_TYPES } from 'src/plugins/data/public'; import { JOB_FIELD_TYPES } from '../../../common'; +import { IFieldType, KBN_FIELD_TYPES } from '../../../../../../src/plugins/data/public'; + // convert kibana types to ML Job types // this is needed because kibana types only have string and not text and keyword. // and we can't use ES_FIELD_TYPES because it has no NUMBER type diff --git a/x-pack/plugins/file_data_visualizer/public/plugin.ts b/x-pack/plugins/file_data_visualizer/public/plugin.ts index c0e52259ec0d4..a94c0fce45cd4 100644 --- a/x-pack/plugins/file_data_visualizer/public/plugin.ts +++ b/x-pack/plugins/file_data_visualizer/public/plugin.ts @@ -6,12 +6,12 @@ */ import { CoreStart } from 'kibana/public'; -import type { EmbeddableStart } from 'src/plugins/embeddable/public'; -import type { SharePluginStart } from 'src/plugins/share/public'; -import { DataPublicPluginStart } from 'src/plugins/data/public'; +import type { EmbeddableStart } from '../../../../src/plugins/embeddable/public'; +import type { SharePluginStart } from '../../../../src/plugins/share/public'; import { Plugin } from '../../../../src/core/public'; import { setStartServices } from './kibana_services'; +import { DataPublicPluginStart } from '../../../../src/plugins/data/public'; import type { FileUploadPluginStart } from '../../file_upload/public'; import type { MapsStartApi } from '../../maps/public'; import type { SecurityPluginSetup } from '../../security/public'; From 33906dc5c611079ca7814a8c0d534c49c5925980 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Fri, 16 Apr 2021 11:36:26 +0100 Subject: [PATCH 31/37] adding esUiShared back in --- x-pack/plugins/file_data_visualizer/kibana.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/file_data_visualizer/kibana.json b/x-pack/plugins/file_data_visualizer/kibana.json index 325b000275d6e..721352cff7c95 100644 --- a/x-pack/plugins/file_data_visualizer/kibana.json +++ b/x-pack/plugins/file_data_visualizer/kibana.json @@ -18,7 +18,8 @@ ], "requiredBundles": [ "kibanaReact", - "maps" + "maps", + "esUiShared" ], "extraPublicDirs": [ "common" From fbf1215d39eb95faf15905b496619f31074eab95 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Fri, 16 Apr 2021 11:45:00 +0100 Subject: [PATCH 32/37] fixing navigation tabs alignment in basic license --- .../components/navigation_menu/main_tabs.tsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/x-pack/plugins/ml/public/application/components/navigation_menu/main_tabs.tsx b/x-pack/plugins/ml/public/application/components/navigation_menu/main_tabs.tsx index 3a6979d021c8b..fdbf7b4b386c0 100644 --- a/x-pack/plugins/ml/public/application/components/navigation_menu/main_tabs.tsx +++ b/x-pack/plugins/ml/public/application/components/navigation_menu/main_tabs.tsx @@ -161,14 +161,16 @@ export const MainTabs: FC = ({ tabId, disableLinks }) => { const defaultPathId = (TAB_DATA[id].pathId || id) as MlUrlGeneratorState['page']; return disabled ? ( - - {tab.name} - +
+ + {tab.name} + +
) : (
Date: Fri, 16 Apr 2021 11:47:16 +0100 Subject: [PATCH 33/37] adding key to tab wrapper --- .../public/application/components/navigation_menu/main_tabs.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/ml/public/application/components/navigation_menu/main_tabs.tsx b/x-pack/plugins/ml/public/application/components/navigation_menu/main_tabs.tsx index fdbf7b4b386c0..0f381fb7acee9 100644 --- a/x-pack/plugins/ml/public/application/components/navigation_menu/main_tabs.tsx +++ b/x-pack/plugins/ml/public/application/components/navigation_menu/main_tabs.tsx @@ -161,7 +161,7 @@ export const MainTabs: FC = ({ tabId, disableLinks }) => { const defaultPathId = (TAB_DATA[id].pathId || id) as MlUrlGeneratorState['page']; return disabled ? ( -
+
Date: Sat, 17 Apr 2021 11:14:12 +0100 Subject: [PATCH 34/37] reverting test label --- .../application/components/examples_list/examples_list.tsx | 2 +- x-pack/test/functional/services/ml/data_visualizer_table.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/examples_list/examples_list.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/examples_list/examples_list.tsx index dbf2230181a43..202562a3fa80d 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/examples_list/examples_list.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/examples_list/examples_list.tsx @@ -41,7 +41,7 @@ export const ExamplesList: FC = ({ examples }) => { } return ( -
+
Date: Tue, 20 Apr 2021 14:45:01 +0100 Subject: [PATCH 35/37] further removal of ml references --- .../examples_list/examples_list.tsx | 2 +- .../expanded_row/file_based_expanded_row.tsx | 4 +- .../geo_point_content/geo_point_content.tsx | 4 +- .../field_type_icon/field_type_icon.tsx | 4 +- .../file_contents/file_contents.tsx | 10 +-- .../file_datavisualizer_view.js | 2 +- .../file_error_callouts.tsx | 2 +- .../components/import_settings/advanced.tsx | 14 ++-- .../components/import_view/import_view.js | 2 +- .../{ml_job_editor => json_editor}/index.ts | 2 +- .../json_editor.tsx} | 10 +-- .../ml_embedded_map/_ml_embedded_map.scss | 2 +- .../components/ml_embedded_map/index.ts | 2 +- .../ml_embedded_map/ml_embedded_map.tsx | 8 +-- .../results_links/results_links.tsx | 9 +-- .../stats_table/_field_data_row.scss | 12 ++-- .../components/stats_table/_index.scss | 6 +- .../expanded_row_field_header.tsx | 2 +- .../components/field_count_stats/_index.scss | 2 +- .../field_count_stats/metric_fields_count.tsx | 2 +- .../field_count_stats/total_fields_count.tsx | 2 +- .../field_data_expanded_row/_index.scss | 2 +- .../_number_content.scss | 2 +- .../expanded_row_content.tsx | 2 +- .../number_content.tsx | 2 +- .../field_data_expanded_row/text_content.tsx | 10 +-- .../components/field_data_row/_index.scss | 2 +- .../field_data_row/column_chart.scss | 10 +-- .../field_data_row/column_chart.tsx | 6 +- .../field_data_row/distinct_values.tsx | 2 +- .../field_data_row/document_stats.tsx | 2 +- .../field_data_row/number_content_preview.tsx | 11 ++-- .../field_data_row/use_column_chart.tsx | 2 +- .../util/field_types_utils.test.ts | 65 ++----------------- .../application/util/field_types_utils.ts | 44 +------------ x-pack/plugins/file_upload/common/types.ts | 10 ++- .../plugins/file_upload/public/api/index.ts | 5 +- 37 files changed, 93 insertions(+), 187 deletions(-) rename x-pack/plugins/file_data_visualizer/public/application/components/{ml_job_editor => json_editor}/index.ts (80%) rename x-pack/plugins/file_data_visualizer/public/application/components/{ml_job_editor/ml_job_editor.tsx => json_editor/json_editor.tsx} (82%) diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/examples_list/examples_list.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/examples_list/examples_list.tsx index 202562a3fa80d..1c533075af27b 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/examples_list/examples_list.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/examples_list/examples_list.tsx @@ -31,7 +31,7 @@ export const ExamplesList: FC = ({ examples }) => { examplesContent = examples.map((example, i) => { return ( {getCardContent()}
diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/geo_point_content.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/geo_point_content.tsx index 499844bdee6da..b33a084e410ef 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/geo_point_content.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/geo_point_content.tsx @@ -11,7 +11,7 @@ import { EuiFlexItem } from '@elastic/eui'; import { Feature, Point } from 'geojson'; import type { FieldDataRowProps } from '../../stats_table/types/field_data_row'; import { DocumentStatsTable } from '../../stats_table/components/field_data_expanded_row/document_stats'; -import { MlEmbeddedMapComponent } from '../../ml_embedded_map'; +import { EmbeddedMapComponent } from '../../ml_embedded_map'; import { convertWKTGeoToLonLat, getGeoPointsLayer } from './format_utils'; import { ExpandedRowContent } from '../../stats_table/components/field_data_expanded_row/expanded_row_content'; import { ExamplesList } from '../../examples_list'; @@ -72,7 +72,7 @@ export const GeoPointContent: FC = ({ config }) => { className={'mlDataVisualizerMapWrapper'} data-test-subj={'mlDataVisualizerEmbeddedMap'} > - + )} diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/field_type_icon.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/field_type_icon.tsx index 9a346d5542318..2dd7ff635bacd 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/field_type_icon.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/field_type_icon.tsx @@ -11,7 +11,7 @@ import { EuiToken, EuiToolTip } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { getMLJobTypeAriaLabel } from '../../util/field_types_utils'; +import { getJobTypeAriaLabel } from '../../util/field_types_utils'; import { JOB_FIELD_TYPES } from '../../../../common'; import type { JobFieldType } from '../../../../common'; @@ -36,7 +36,7 @@ export const FieldTypeIcon: FC = ({ fieldName, needsAria = true, }) => { - const ariaLabel = getMLJobTypeAriaLabel(type); + const ariaLabel = getJobTypeAriaLabel(type); let iconType = 'questionInCircle'; let color = 'euiColorVis6'; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/file_contents/file_contents.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/file_contents/file_contents.tsx index 4b9ade182aa67..fa54cf9cbc05c 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/file_contents/file_contents.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/file_contents/file_contents.tsx @@ -10,7 +10,7 @@ import React, { FC } from 'react'; import { EuiTitle, EuiSpacer } from '@elastic/eui'; -import { MLJobEditor, ML_EDITOR_MODE } from '../ml_job_editor'; +import { JsonEditor, EDITOR_MODE } from '../json_editor'; interface Props { data: string; @@ -19,9 +19,9 @@ interface Props { } export const FileContents: FC = ({ data, format, numberOfLines }) => { - let mode = ML_EDITOR_MODE.TEXT; - if (format === ML_EDITOR_MODE.JSON) { - mode = ML_EDITOR_MODE.JSON; + let mode = EDITOR_MODE.TEXT; + if (format === EDITOR_MODE.JSON) { + mode = EDITOR_MODE.JSON; } const formattedData = limitByNumberOfLines(data, numberOfLines); @@ -49,7 +49,7 @@ export const FileContents: FC = ({ data, format, numberOfLines }) => { - = ({ err if (!error?.body?.attributes?.body?.error?.suppressed?.length) { return null; } - const reason: string = error.body.attributes.body.error.suppressed[0].reason; + const reason = error.body.attributes.body.error.suppressed[0].reason; return ( <> diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/advanced.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/advanced.tsx index e7723f96d5af0..4b3ce9bcf4596 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/advanced.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/advanced.tsx @@ -19,7 +19,7 @@ import { } from '@elastic/eui'; import { CombinedField, CombinedFieldsForm } from '../combined_fields'; -import { MLJobEditor, ML_EDITOR_MODE } from '../ml_job_editor'; +import { JsonEditor, EDITOR_MODE } from '../json_editor'; import { FindFileStructureResponse } from '../../../../../file_upload/common'; const EDITOR_HEIGHT = '300px'; @@ -190,8 +190,8 @@ const IndexSettings: FC = ({ initialized, data, onChange }) => } fullWidth > - = ({ initialized, data, onChange }) => { } fullWidth > - = ({ initialized, data, onChange }) => } fullWidth > - = ({ +export const JsonEditor: FC = ({ value, height = '500px', width = '100%', - mode = ML_EDITOR_MODE.JSON, + mode = EDITOR_MODE.JSON, readOnly = false, syntaxChecking = true, theme = 'textmate', onChange = () => {}, }) => { - if (mode === ML_EDITOR_MODE.XJSON) { + if (mode === EDITOR_MODE.XJSON) { value = expandLiteralStrings(value); } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/_ml_embedded_map.scss b/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/_ml_embedded_map.scss index 495fc40ddb27c..99ee60f62bb21 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/_ml_embedded_map.scss +++ b/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/_ml_embedded_map.scss @@ -1,4 +1,4 @@ -.mlEmbeddedMapContent { +.embeddedMapContent { width: 100%; height: 100%; display: flex; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/index.ts index 3829e98450d73..eda8ec6604eb2 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/index.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/index.ts @@ -5,4 +5,4 @@ * 2.0. */ -export { MlEmbeddedMapComponent } from './ml_embedded_map'; +export { EmbeddedMapComponent } from './ml_embedded_map'; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/ml_embedded_map.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/ml_embedded_map.tsx index 5cc260a9dc194..3c2e0f6e44396 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/ml_embedded_map.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/ml_embedded_map.tsx @@ -25,7 +25,7 @@ import { } from '../../../../../../../src/plugins/embeddable/public'; import { useFileDataVisualizerKibana } from '../../kibana_context'; -export function MlEmbeddedMapComponent({ +export function EmbeddedMapComponent({ layerList, mapEmbeddableInput, renderTooltipContent, @@ -146,10 +146,6 @@ export function MlEmbeddedMapComponent({ } return ( -
+
); } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/results_links/results_links.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/results_links/results_links.tsx index c38e4f5b2e983..03dc06d836bbc 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/results_links/results_links.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/results_links/results_links.tsx @@ -13,6 +13,7 @@ import { DISCOVER_APP_URL_GENERATOR, DiscoverUrlGeneratorState, } from '../../../../../../../src/plugins/discover/public'; +import { TimeRange, RefreshInterval } from '../../../../../../../src/plugins/data/public'; import { FindFileStructureResponse } from '../../../../../file_upload/common'; import type { FileUploadPluginStart } from '../../../../../file_upload/public'; import { useFileDataVisualizerKibana } from '../../kibana_context'; @@ -27,12 +28,8 @@ interface Props { } interface GlobalState { - time?: { - from: string; - to: string; - mode?: 'absolute' | 'relative'; - }; - refreshInterval?: { pause: boolean; value: number }; + time?: TimeRange; + refreshInterval?: RefreshInterval; } const RECHECK_DELAY_MS = 3000; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/_field_data_row.scss b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/_field_data_row.scss index 1832b0f78b895..944c31da8cab7 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/_field_data_row.scss +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/_field_data_row.scss @@ -1,4 +1,4 @@ -.mlFieldDataCard { +.fieldDataCard { height: 420px; box-shadow: none; border-color: $euiBorderColor; @@ -50,17 +50,17 @@ border-color: $euiColorVis6; } - .mlFieldDataCard__content { + .fieldDataCard__content { @include euiFontSizeS; height: 385px; overflow: hidden; } - .mlFieldDataCard__codeContent { + .fieldDataCard__codeContent { @include euiCodeFont; } - .mlFieldDataCard__geoContent { + .fieldDataCard__geoContent { z-index: auto; flex: 1; display: flex; @@ -75,12 +75,12 @@ } } - .mlFieldDataCard__stats { + .fieldDataCard__stats { padding: $euiSizeS $euiSizeS 0 $euiSizeS; text-align: center; } - .mlFieldDataCard__valuesTitle { + .fieldDataCard__valuesTitle { text-transform: uppercase; } } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/_index.scss b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/_index.scss index 9e838c180713f..70ad81600692b 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/_index.scss +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/_index.scss @@ -2,11 +2,11 @@ @import 'components/field_count_stats/index'; @import 'components/field_data_row/index'; -.mlDataVisualizerFieldExpandedRow { +.dataVisualizerFieldExpandedRow { padding-left: $euiSize * 4; width: 100%; - .mlFieldDataCard__valuesTitle { + .fieldDataCard__valuesTitle { text-transform: uppercase; text-align: left; color: $euiColorDarkShade; @@ -14,7 +14,7 @@ padding-bottom: $euiSizeS; } - .mlFieldDataCard__codeContent { + .fieldDataCard__codeContent { @include euiCodeFont; } } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/expanded_row_field_header/expanded_row_field_header.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/expanded_row_field_header/expanded_row_field_header.tsx index 6c82e103a831f..7279bceb8be93 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/expanded_row_field_header/expanded_row_field_header.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/expanded_row_field_header/expanded_row_field_header.tsx @@ -9,7 +9,7 @@ import { EuiText } from '@elastic/eui'; import React from 'react'; export const ExpandedRowFieldHeader = ({ children }: { children: React.ReactNode }) => ( - + {children} ); diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/_index.scss b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/_index.scss index 7154d0da2c09c..e44082c90ba32 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/_index.scss +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/_index.scss @@ -1,3 +1,3 @@ -.mlDataVisualizerFieldCountContainer { +.dataVisualizerFieldCountContainer { max-width: 300px; } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/metric_fields_count.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/metric_fields_count.tsx index 436063ce3007c..93582a7cef9ed 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/metric_fields_count.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/metric_fields_count.tsx @@ -30,7 +30,7 @@ export const MetricFieldsCount: FC = ({ metricsStats }) diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/total_fields_count.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/total_fields_count.tsx index cc27cda69eda7..9d554c7025d80 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/total_fields_count.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/total_fields_count.tsx @@ -30,7 +30,7 @@ export const TotalFieldsCount: FC = ({ fieldsCountStats } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/_index.scss b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/_index.scss index 799beec093cca..b878bf0dcc0f6 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/_index.scss +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/_index.scss @@ -1,6 +1,6 @@ @import 'number_content'; -.mlDataVisualizerExpandedRow { +.dataVisualizerExpandedRow { @include euiBreakpoint('xs', 's', 'm') { flex-direction: column; } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/_number_content.scss b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/_number_content.scss index 066f405b39cd6..1f52b0763cdd3 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/_number_content.scss +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/_number_content.scss @@ -1,4 +1,4 @@ -.mlMetricDistributionChartContainer { +.metricDistributionChartContainer { padding-top: $euiSizeXS; width: 100%; } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/expanded_row_content.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/expanded_row_content.tsx index 8e14945b32a7f..a9f5dc6eaab1d 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/expanded_row_content.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/expanded_row_content.tsx @@ -17,7 +17,7 @@ export const ExpandedRowContent: FC = ({ children, dataTestSubj }) => { {children} diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/number_content.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/number_content.tsx index facba323a844e..4b377d0855966 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/number_content.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/number_content.tsx @@ -127,7 +127,7 @@ export const NumberContent: FC = ({ config }) => { - + = ({ config }) => { id="xpack.fileDataVisualizer.fieldDataCard.cardText.fieldNotPresentDescription" defaultMessage="This field was not present in the {sourceParam} field of documents queried." values={{ - sourceParam: _source, + sourceParam: _source, }} /> @@ -54,10 +54,10 @@ export const TextContent: FC = ({ config }) => { id="xpack.fileDataVisualizer.fieldDataCard.cardText.fieldMayBePopulatedDescription" defaultMessage="It may be populated, for example, using a {copyToParam} parameter in the document mapping, or be pruned from the {sourceParam} field after indexing through the use of {includesParam} and {excludesParam} parameters." values={{ - copyToParam: copy_to, - sourceParam: _source, - includesParam: includes, - excludesParam: excludes, + copyToParam: copy_to, + sourceParam: _source, + includesParam: includes, + excludesParam: excludes, }} /> diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/_index.scss b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/_index.scss index 27483feb573b8..3afa182560e1e 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/_index.scss +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/_index.scss @@ -1,3 +1,3 @@ -.mlDataVisualizerColumnHeaderIcon { +.dataVisualizerColumnHeaderIcon { max-width: $euiSizeM; } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/column_chart.scss b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/column_chart.scss index 756804a0e6aa0..63603ee9bd2ec 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/column_chart.scss +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/column_chart.scss @@ -1,9 +1,9 @@ -.mlDataGridChart__histogram { +.dataGridChart__histogram { width: 100%; height: $euiSizeXL + $euiSizeXXL; } -.mlDataGridChart__legend { +.dataGridChart__legend { @include euiTextTruncate; @include euiFontSizeXS; @@ -16,17 +16,17 @@ text-align: left; } -.mlDataGridChart__legend--numeric { +.dataGridChart__legend--numeric { text-align: right; } -.mlDataGridChart__legendBoolean { +.dataGridChart__legendBoolean { width: 100%; min-width: $euiButtonMinWidth; td { text-align: center } } /* Override to align column header to bottom of cell when no chart is available */ -.mlDataGrid .euiDataGridHeaderCell__content { +.dataGrid .euiDataGridHeaderCell__content { margin-top: auto; } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/column_chart.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/column_chart.tsx index c074d105bedc1..ed4b82005db29 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/column_chart.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/column_chart.tsx @@ -53,7 +53,7 @@ export const ColumnChart: FC = ({ return (
{!isUnsupportedChartData(chartData) && data.length > 0 && ( -
+
= ({
)}
diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/distinct_values.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/distinct_values.tsx index acbe081599c62..92e0d1a16229f 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/distinct_values.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/distinct_values.tsx @@ -13,7 +13,7 @@ export const DistinctValues = ({ cardinality }: { cardinality?: number }) => { if (cardinality === undefined) return null; return ( - + diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/document_stats.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/document_stats.tsx index 903b60c4a3082..7d0bda6ac47ea 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/document_stats.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/document_stats.tsx @@ -22,7 +22,7 @@ export const DocumentStat = ({ config }: FieldDataRowProps) => { return ( - + diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/number_content_preview.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/number_content_preview.tsx index 59ffc59caf5ab..00150bdfe8b7a 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/number_content_preview.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/number_content_preview.tsx @@ -47,7 +47,7 @@ export const IndexBasedNumberContentPreview: FC = ({ return (
-
+
= ({ hideXAxis={true} />
-
+
{legendText && ( <> - + {kibanaFieldFormat(legendText.min, fieldFormat)} {kibanaFieldFormat(legendText.max, fieldFormat)} diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx index 436f740bee41f..bd1df7f32c375 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx @@ -94,7 +94,7 @@ export const getLegendText = ( if (chartData.type === 'boolean') { return ( - +
{chartData.data[0] !== undefined && } diff --git a/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.test.ts b/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.test.ts index a50457ca57a55..aa909fb579b98 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.test.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.test.ts @@ -5,72 +5,17 @@ * 2.0. */ -import { IFieldType, KBN_FIELD_TYPES } from '../../../../../../src/plugins/data/public'; import { JOB_FIELD_TYPES } from '../../../common'; -import { - kbnTypeToMLJobType, - getMLJobTypeAriaLabel, - mlJobTypeAriaLabels, -} from './field_types_utils'; +import { getJobTypeAriaLabel, jobTypeAriaLabels } from './field_types_utils'; describe('ML - field type utils', () => { - describe('kbnTypeToMLJobType', () => { - test('returns correct JOB_FIELD_TYPES for KBN_FIELD_TYPES', () => { - const field: IFieldType = { - type: KBN_FIELD_TYPES.NUMBER, - name: KBN_FIELD_TYPES.NUMBER, - aggregatable: true, - }; - expect(kbnTypeToMLJobType(field)).toBe(JOB_FIELD_TYPES.NUMBER); - - field.type = KBN_FIELD_TYPES.DATE; - expect(kbnTypeToMLJobType(field)).toBe(JOB_FIELD_TYPES.DATE); - - field.type = KBN_FIELD_TYPES.IP; - expect(kbnTypeToMLJobType(field)).toBe(JOB_FIELD_TYPES.IP); - - field.type = KBN_FIELD_TYPES.BOOLEAN; - expect(kbnTypeToMLJobType(field)).toBe(JOB_FIELD_TYPES.BOOLEAN); - - field.type = KBN_FIELD_TYPES.GEO_POINT; - expect(kbnTypeToMLJobType(field)).toBe(JOB_FIELD_TYPES.GEO_POINT); - }); - - test('returns JOB_FIELD_TYPES.KEYWORD for aggregatable KBN_FIELD_TYPES.STRING', () => { - const field: IFieldType = { - type: KBN_FIELD_TYPES.STRING, - name: KBN_FIELD_TYPES.STRING, - aggregatable: true, - }; - expect(kbnTypeToMLJobType(field)).toBe(JOB_FIELD_TYPES.KEYWORD); - }); - - test('returns JOB_FIELD_TYPES.TEXT for non-aggregatable KBN_FIELD_TYPES.STRING', () => { - const field: IFieldType = { - type: KBN_FIELD_TYPES.STRING, - name: KBN_FIELD_TYPES.STRING, - aggregatable: false, - }; - expect(kbnTypeToMLJobType(field)).toBe(JOB_FIELD_TYPES.TEXT); - }); - - test('returns undefined for non-aggregatable "foo"', () => { - const field: IFieldType = { - type: 'foo', - name: 'foo', - aggregatable: false, - }; - expect(kbnTypeToMLJobType(field)).toBe(undefined); - }); - }); - - describe('getMLJobTypeAriaLabel: Getting a field type aria label by passing what it is stored in constants', () => { + describe('getJobTypeAriaLabel: Getting a field type aria label by passing what it is stored in constants', () => { test('should returns all JOB_FIELD_TYPES labels exactly as it is for each correct value', () => { const mlKeys = Object.keys(JOB_FIELD_TYPES); const receivedMlLabels: Record = {}; - const testStorage = mlJobTypeAriaLabels; + const testStorage = jobTypeAriaLabels; mlKeys.forEach((constant) => { - receivedMlLabels[constant] = getMLJobTypeAriaLabel( + receivedMlLabels[constant] = getJobTypeAriaLabel( JOB_FIELD_TYPES[constant as keyof typeof JOB_FIELD_TYPES] ); }); @@ -78,7 +23,7 @@ describe('ML - field type utils', () => { expect(receivedMlLabels).toEqual(testStorage); }); test('should returns NULL as JOB_FIELD_TYPES does not contain such a keyword', () => { - expect(getMLJobTypeAriaLabel('JOB_FIELD_TYPES')).toBe(null); + expect(getJobTypeAriaLabel('JOB_FIELD_TYPES')).toBe(null); }); }); }); diff --git a/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.ts b/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.ts index 6f46ac518ffd7..76a5f6ac20117 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.ts @@ -8,45 +8,7 @@ import { i18n } from '@kbn/i18n'; import { JOB_FIELD_TYPES } from '../../../common'; -import { IFieldType, KBN_FIELD_TYPES } from '../../../../../../src/plugins/data/public'; - -// convert kibana types to ML Job types -// this is needed because kibana types only have string and not text and keyword. -// and we can't use ES_FIELD_TYPES because it has no NUMBER type -export function kbnTypeToMLJobType(field: IFieldType) { - // Return undefined if not one of the supported data visualizer field types. - let type; - switch (field.type) { - case KBN_FIELD_TYPES.STRING: - type = field.aggregatable ? JOB_FIELD_TYPES.KEYWORD : JOB_FIELD_TYPES.TEXT; - break; - case KBN_FIELD_TYPES.NUMBER: - type = JOB_FIELD_TYPES.NUMBER; - break; - case KBN_FIELD_TYPES.DATE: - type = JOB_FIELD_TYPES.DATE; - break; - case KBN_FIELD_TYPES.IP: - type = JOB_FIELD_TYPES.IP; - break; - case KBN_FIELD_TYPES.BOOLEAN: - type = JOB_FIELD_TYPES.BOOLEAN; - break; - case KBN_FIELD_TYPES.GEO_POINT: - type = JOB_FIELD_TYPES.GEO_POINT; - break; - case KBN_FIELD_TYPES.GEO_SHAPE: - type = JOB_FIELD_TYPES.GEO_SHAPE; - break; - - default: - break; - } - - return type; -} - -export const mlJobTypeAriaLabels = { +export const jobTypeAriaLabels = { BOOLEAN: i18n.translate('xpack.fileDataVisualizer.fieldTypeIcon.booleanTypeAriaLabel', { defaultMessage: 'boolean type', }), @@ -76,12 +38,12 @@ export const mlJobTypeAriaLabels = { }), }; -export const getMLJobTypeAriaLabel = (type: string) => { +export const getJobTypeAriaLabel = (type: string) => { const requestedFieldType = Object.keys(JOB_FIELD_TYPES).find( (k) => JOB_FIELD_TYPES[k as keyof typeof JOB_FIELD_TYPES] === type ); if (requestedFieldType === undefined) { return null; } - return mlJobTypeAriaLabels[requestedFieldType as keyof typeof mlJobTypeAriaLabels]; + return jobTypeAriaLabels[requestedFieldType as keyof typeof jobTypeAriaLabels]; }; diff --git a/x-pack/plugins/file_upload/common/types.ts b/x-pack/plugins/file_upload/common/types.ts index d0e03de9b4ccc..e10b9e90a71d8 100644 --- a/x-pack/plugins/file_upload/common/types.ts +++ b/x-pack/plugins/file_upload/common/types.ts @@ -76,11 +76,19 @@ export interface FindFileStructureErrorResponse { statusCode: number; error: string; message: string; - attributes?: any; + attributes?: ErrorAttribute; }; name: string; } +interface ErrorAttribute { + body: { + error: { + suppressed: Array<{ reason: string }>; + }; + }; +} + export interface HasImportPermission { hasImportPermission: boolean; } diff --git a/x-pack/plugins/file_upload/public/api/index.ts b/x-pack/plugins/file_upload/public/api/index.ts index 909dca76242ba..23eeb9abde324 100644 --- a/x-pack/plugins/file_upload/public/api/index.ts +++ b/x-pack/plugins/file_upload/public/api/index.ts @@ -83,15 +83,16 @@ export async function checkIndexExists( ): Promise { const body = JSON.stringify({ index }); const fileUploadModules = await lazyLoadModules(); - return await fileUploadModules.getHttp().fetch({ + const { exists } = await fileUploadModules.getHttp().fetch<{ exists: boolean }>({ path: `/internal/file_upload/index_exists`, method: 'POST', body, query: params, }); + return exists; } -export async function getTimeFieldRange(index: string, query: any, timeFieldName?: string) { +export async function getTimeFieldRange(index: string, query: unknown, timeFieldName?: string) { const body = JSON.stringify({ index, timeFieldName, query }); const fileUploadModules = await lazyLoadModules(); From f94eb1600228264031de93df1890e8e7be1b5074 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Tue, 20 Apr 2021 16:39:46 +0100 Subject: [PATCH 36/37] removing ml label from more identifiers --- .../file_data_visualizer/common/constants.ts | 2 +- .../_embedded_map.scss} | 0 .../components/embedded_map/_index.scss | 1 + .../embedded_map.tsx} | 0 .../index.ts | 2 +- .../geo_point_content/geo_point_content.tsx | 6 +- .../_experimental_badge.scss | 2 +- .../experimental_badge/experimental_badge.tsx | 2 +- .../field_types_filter/field_types_filter.tsx | 6 +- .../fields_stats/_field_stats_card.scss | 150 ------------------ .../fields_stats/_fields_stats.scss | 6 - .../components/json_editor/json_editor.tsx | 4 +- .../components/ml_embedded_map/_index.scss | 1 - .../components/stats_table/_index.scss | 8 +- .../boolean_content.tsx | 4 +- .../field_data_expanded_row/date_content.tsx | 4 +- .../document_stats.tsx | 4 +- .../number_content.tsx | 4 +- .../data_visualizer_stats_table.tsx | 2 +- .../stats_table/hooks/color_range_legend.tsx | 6 +- .../components/top_values/_top_values.scss | 10 +- .../components/top_values/top_values.tsx | 8 +- .../components/utils/format_value.ts | 6 +- .../utils/number_as_ordinal.test.ts | 2 +- .../utils/round_to_decimal_place.test.ts | 2 +- .../public/application/kibana_context.ts | 3 +- .../util/field_types_utils.test.ts | 12 +- 27 files changed, 50 insertions(+), 207 deletions(-) rename x-pack/plugins/file_data_visualizer/public/application/components/{ml_embedded_map/_ml_embedded_map.scss => embedded_map/_embedded_map.scss} (100%) create mode 100644 x-pack/plugins/file_data_visualizer/public/application/components/embedded_map/_index.scss rename x-pack/plugins/file_data_visualizer/public/application/components/{ml_embedded_map/ml_embedded_map.tsx => embedded_map/embedded_map.tsx} (100%) rename x-pack/plugins/file_data_visualizer/public/application/components/{ml_embedded_map => embedded_map}/index.ts (81%) delete mode 100644 x-pack/plugins/file_data_visualizer/public/application/components/fields_stats/_field_stats_card.scss delete mode 100644 x-pack/plugins/file_data_visualizer/public/application/components/fields_stats/_fields_stats.scss delete mode 100644 x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/_index.scss diff --git a/x-pack/plugins/file_data_visualizer/common/constants.ts b/x-pack/plugins/file_data_visualizer/common/constants.ts index f2a2e52a2267f..819549a7eb4e6 100644 --- a/x-pack/plugins/file_data_visualizer/common/constants.ts +++ b/x-pack/plugins/file_data_visualizer/common/constants.ts @@ -15,7 +15,7 @@ export const ABSOLUTE_MAX_FILE_SIZE_BYTES = 1073741274; // 1GB export const FILE_SIZE_DISPLAY_FORMAT = '0,0.[0] b'; // Value to use in the Elasticsearch index mapping meta data to identify the -// index as having been created by the ML File Data Visualizer. +// index as having been created by the File Data Visualizer. export const INDEX_META_DATA_CREATED_BY = 'file-data-visualizer'; export const JOB_FIELD_TYPES = { diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/_ml_embedded_map.scss b/x-pack/plugins/file_data_visualizer/public/application/components/embedded_map/_embedded_map.scss similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/_ml_embedded_map.scss rename to x-pack/plugins/file_data_visualizer/public/application/components/embedded_map/_embedded_map.scss diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/embedded_map/_index.scss b/x-pack/plugins/file_data_visualizer/public/application/components/embedded_map/_index.scss new file mode 100644 index 0000000000000..5b3c6b4990ff1 --- /dev/null +++ b/x-pack/plugins/file_data_visualizer/public/application/components/embedded_map/_index.scss @@ -0,0 +1 @@ +@import 'embedded_map'; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/ml_embedded_map.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/embedded_map/embedded_map.tsx similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/ml_embedded_map.tsx rename to x-pack/plugins/file_data_visualizer/public/application/components/embedded_map/embedded_map.tsx diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/index.ts b/x-pack/plugins/file_data_visualizer/public/application/components/embedded_map/index.ts similarity index 81% rename from x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/index.ts rename to x-pack/plugins/file_data_visualizer/public/application/components/embedded_map/index.ts index eda8ec6604eb2..ee11a18345f64 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/index.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/components/embedded_map/index.ts @@ -5,4 +5,4 @@ * 2.0. */ -export { EmbeddedMapComponent } from './ml_embedded_map'; +export { EmbeddedMapComponent } from './embedded_map'; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/geo_point_content.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/geo_point_content.tsx index b33a084e410ef..c395b06059e8f 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/geo_point_content.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/geo_point_content.tsx @@ -11,7 +11,7 @@ import { EuiFlexItem } from '@elastic/eui'; import { Feature, Point } from 'geojson'; import type { FieldDataRowProps } from '../../stats_table/types/field_data_row'; import { DocumentStatsTable } from '../../stats_table/components/field_data_expanded_row/document_stats'; -import { EmbeddedMapComponent } from '../../ml_embedded_map'; +import { EmbeddedMapComponent } from '../../embedded_map'; import { convertWKTGeoToLonLat, getGeoPointsLayer } from './format_utils'; import { ExpandedRowContent } from '../../stats_table/components/field_data_expanded_row/expanded_row_content'; import { ExamplesList } from '../../examples_list'; @@ -38,7 +38,7 @@ export const GeoPointContent: FC = ({ config }) => { geoPointsFeatures.push({ type: 'Feature', - id: `ml-${config.fieldName}-${i}`, + id: `fileDataVisualizer-${config.fieldName}-${i}`, geometry: { type: 'Point', coordinates: [coordinates.lat, coordinates.lon], @@ -69,7 +69,7 @@ export const GeoPointContent: FC = ({ config }) => { )} {formattedResults && Array.isArray(formattedResults.layerList) && ( diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/experimental_badge/_experimental_badge.scss b/x-pack/plugins/file_data_visualizer/public/application/components/experimental_badge/_experimental_badge.scss index 016d5cd579e3f..8b21620542ff7 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/experimental_badge/_experimental_badge.scss +++ b/x-pack/plugins/file_data_visualizer/public/application/components/experimental_badge/_experimental_badge.scss @@ -1,4 +1,4 @@ -.ml-experimental-badge.euiBetaBadge { +.experimental-badge.euiBetaBadge { font-size: 10px; vertical-align: middle; margin-bottom: 5px; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/experimental_badge/experimental_badge.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/experimental_badge/experimental_badge.tsx index 819c3b04b1ef9..a067cb198914e 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/experimental_badge/experimental_badge.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/experimental_badge/experimental_badge.tsx @@ -14,7 +14,7 @@ export const ExperimentalBadge: FC<{ tooltipContent: string }> = ({ tooltipConte return ( = ({ if ( type !== undefined && !fieldTypesTracker.has(type) && - ML_JOB_FIELD_TYPES_OPTIONS[type] !== undefined + JOB_FIELD_TYPES_OPTIONS[type] !== undefined ) { - const item = ML_JOB_FIELD_TYPES_OPTIONS[type]; + const item = JOB_FIELD_TYPES_OPTIONS[type]; fieldTypesTracker.add(type); fieldTypes.push({ diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats/_field_stats_card.scss b/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats/_field_stats_card.scss deleted file mode 100644 index d0af6d3f01d2f..0000000000000 --- a/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats/_field_stats_card.scss +++ /dev/null @@ -1,150 +0,0 @@ -.card-container { - display: inline-grid; - display: -ms-inline-grid; - padding: 0 10px 10px 0; -} - -.ml-field-data-card { - // These styles should all be removed once the file data visualizer is using - // the same field_data_card component as the index based data visualizer. - height: 408px; - box-shadow: none; - border-color: $euiBorderColor; - - // Note the names of these styles need to match the type of the field they are displaying. - .boolean { - color: $euiColorVis5; - border-color: $euiColorVis5; - } - - .date { - color: $euiColorVis7; - border-color: $euiColorVis7; - } - - .document_count { - color: $euiColorVis2; - border-color: $euiColorVis2; - } - - .geo_point { - color: $euiColorVis8; - border-color: $euiColorVis8; - } - - .ip { - color: $euiColorVis3; - border-color: $euiColorVis3; - } - - .keyword { - color: $euiColorVis0; - border-color: $euiColorVis0; - } - - .number { - color: $euiColorVis1; - border-color: $euiColorVis1; - } - - .text { - color: $euiColorVis9; - border-color: $euiColorVis9; - } - - .type-other, - .unknown { - color: $euiColorVis6; - border-color: $euiColorVis6; - } - - // Use euiPanel styling - @include euiPanel($selector: '.card-contents'); - - .stats { - text-align: center; - } - - .stat { - padding-bottom: 6px; - } - - .stat.heading { - padding-bottom: 0; - } - - .stat.min, - .stat.max, - .stat.median { - width: 30%; - display: inline-block; - } - - .stat.min.value, - .stat.max.value, - .stat.median.value { - font-size: $euiFontSizeS; - @include euiTextTruncate; - } - - .valueWrapper { - display: inline; - } - - .not-exist-message { - padding: 50px 30px 0 30px; - text-align: center; - } - - .sampled-message { - font-size: 11px; - color: #555555; - text-align: center; - padding-top: 3px; - } - - .text-code { - font-family: $euiCodeFontFamily; - } - - .details-select { - text-align: center; - margin-top: 5px; - margin-bottom: 5px; - } - - .details-container { - padding-top: 5px; - } - - .top-value { - height: 21px; - font-size: 13px; - - .field-label { - @include euiTextTruncate; - - display: inline-block; - width: 100px; - text-align: right; - } - - .count-label { - display: inline-block; - width: 70px; - text-align: left; - overflow: hidden; - text-overflow: ellipsis; - } - - .top-value-bar-holder { - display: inline-block; - width: 160px; - } - - .top-value-bar { - height: 15px; - min-width: 3px; - } - } -} diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats/_fields_stats.scss b/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats/_fields_stats.scss deleted file mode 100644 index 5decacfe1b7b8..0000000000000 --- a/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats/_fields_stats.scss +++ /dev/null @@ -1,6 +0,0 @@ -.fields-stats { - padding: 10px; -} -.field { - margin-bottom: 10px; -} diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/json_editor/json_editor.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/json_editor/json_editor.tsx index 9c3f9b4ac886c..d429f8dada6ec 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/json_editor/json_editor.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/json_editor/json_editor.tsx @@ -12,7 +12,7 @@ import { expandLiteralStrings, XJsonMode } from '../../shared_imports'; export const EDITOR_MODE = { TEXT: 'text', JSON: 'json', XJSON: new XJsonMode() }; -interface MlJobEditorProps { +interface JobEditorProps { value: string; height?: string; width?: string; @@ -22,7 +22,7 @@ interface MlJobEditorProps { theme?: string; onChange?: EuiCodeEditorProps['onChange']; } -export const JsonEditor: FC = ({ +export const JsonEditor: FC = ({ value, height = '500px', width = '100%', diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/_index.scss b/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/_index.scss deleted file mode 100644 index 6d0d30dae670e..0000000000000 --- a/x-pack/plugins/file_data_visualizer/public/application/components/ml_embedded_map/_index.scss +++ /dev/null @@ -1 +0,0 @@ -@import 'ml_embedded_map'; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/_index.scss b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/_index.scss index 70ad81600692b..d317d324bae90 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/_index.scss +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/_index.scss @@ -19,7 +19,7 @@ } } -.mlDataVisualizer { +.dataVisualizer { .euiTableRow > .euiTableRowCell { border-bottom: 0; border-top: $euiBorderThin; @@ -36,7 +36,7 @@ } } } - .mlDataVisualizerSummaryTable { + .dataVisualizerSummaryTable { max-width: 350px; min-width: 250px; .euiTableRow > .euiTableRowCell { @@ -46,10 +46,10 @@ display: none; } } - .mlDataVisualizerSummaryTableWrapper { + .dataVisualizerSummaryTableWrapper { max-width: 300px; } - .mlDataVisualizerMapWrapper { + .dataVisualizerMapWrapper { min-height: 300px; min-width: 600px; } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/boolean_content.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/boolean_content.tsx index 3f7ebb9d55849..7c9ddcdab29c8 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/boolean_content.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/boolean_content.tsx @@ -90,10 +90,10 @@ export const BooleanContent: FC = ({ config }) => { - + {summaryTableTitle} = ({ config }) => { return ( - + {summaryTableTitle} - className={'mlDataVisualizerSummaryTable'} + className={'dataVisualizerSummaryTable'} data-test-subj={'mlDateSummaryTable'} compressed items={summaryTableItems} diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/document_stats.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/document_stats.tsx index f0ebe741df6f7..f3ac0d94aa255 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/document_stats.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/document_stats.tsx @@ -78,11 +78,11 @@ export const DocumentStatsTable: FC = ({ config }) => { return ( {metaTableTitle} = ({ config }) => { return ( - + {summaryTableTitle} - className={'mlDataVisualizerSummaryTable'} + className={'dataVisualizerSummaryTable'} compressed items={summaryTableItems} columns={summaryTableColumns} diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/data_visualizer_stats_table.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/data_visualizer_stats_table.tsx index 97c44f49b733e..bfa40c487a2ac 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/data_visualizer_stats_table.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/data_visualizer_stats_table.tsx @@ -264,7 +264,7 @@ export const DataVisualizerTable = ({ return ( - className={'mlDataVisualizer'} + className={'dataVisualizer'} items={items} itemId={FIELD_NAME} columns={columns} diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/color_range_legend.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/color_range_legend.tsx index 5f0c0a401bedd..58be31a53e9c5 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/color_range_legend.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/color_range_legend.tsx @@ -64,7 +64,7 @@ export const ColorRangeLegend: FC = ({ const wrapper = d3 .select(d3Container.current) - .classed('mlColorRangeLegend', true) + .classed('colorRangeLegend', true) .attr('width', wrapperWidth) .attr('height', wrapperHeight) .append('g') @@ -74,7 +74,7 @@ export const ColorRangeLegend: FC = ({ const gradient = wrapper .append('defs') .append('linearGradient') - .attr('id', 'mlColorRangeGradient') + .attr('id', 'colorRangeGradient') .attr('x1', '0%') .attr('y1', '0%') .attr('x2', '100%') @@ -95,7 +95,7 @@ export const ColorRangeLegend: FC = ({ .attr('y1', 0) .attr('width', legendWidth) .attr('height', legendHeight) - .style('fill', 'url(#mlColorRangeGradient)'); + .style('fill', 'url(#colorRangeGradient)'); const axisScale = d3.scale.linear().domain([0, 1]).range([0, legendWidth]); diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/top_values/_top_values.scss b/x-pack/plugins/file_data_visualizer/public/application/components/top_values/_top_values.scss index 75ee6aef1b7eb..05fa1bfa94b2d 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/top_values/_top_values.scss +++ b/x-pack/plugins/file_data_visualizer/public/application/components/top_values/_top_values.scss @@ -1,19 +1,19 @@ -.mlFieldDataTopValuesContainer { +.fieldDataTopValuesContainer { padding-top: $euiSizeXS; } -.mlTopValuesValueLabelContainer { +.topValuesValueLabelContainer { margin-right: $euiSizeM; - &.mlTopValuesValueLabelContainer--small { + &.topValuesValueLabelContainer--small { width:70px; } - &.mlTopValuesValueLabelContainer--large { + &.topValuesValueLabelContainer--large { width: 200px; } } -.mlTopValuesPercentLabelContainer { +.topValuesPercentLabelContainer { margin-left: $euiSizeM; width:70px; } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/top_values/top_values.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/top_values/top_values.tsx index 6b7323146f479..c1815fad41de8 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/top_values/top_values.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/top_values/top_values.tsx @@ -57,7 +57,7 @@ export const TopValues: FC = ({ stats, fieldFormat, barColor, compressed /> -
+
{Array.isArray(topValues) && topValues.map((value) => ( @@ -65,8 +65,8 @@ export const TopValues: FC = ({ stats, fieldFormat, barColor, compressed grow={false} className={classNames( 'eui-textTruncate', - 'mlTopValuesValueLabelContainer', - `mlTopValuesValueLabelContainer--${compressed === true ? 'small' : 'large'}` + 'topValuesValueLabelContainer', + `topValuesValueLabelContainer--${compressed === true ? 'small' : 'large'}` )} > @@ -86,7 +86,7 @@ export const TopValues: FC = ({ stats, fieldFormat, barColor, compressed {progressBarMax !== undefined && ( {getPercentLabel(value.doc_count, progressBarMax)} diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/utils/format_value.ts b/x-pack/plugins/file_data_visualizer/public/application/components/utils/format_value.ts index c62725b58b1e7..5e12302a598ff 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/utils/format_value.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/components/utils/format_value.ts @@ -23,7 +23,7 @@ const SIGFIGS_IF_ROUNDING = 3; // Number of sigfigs to use for values < 10 // order to correctly format the day or week offset to the time of the anomaly. export function formatSingleValue( value: number, - mlFunction?: string, + func?: string, fieldFormat?: any, record?: any // TODO remove record, not needed for file upload ) { @@ -36,14 +36,14 @@ export function formatSingleValue( // start of the week / day, so need to manipulate to UTC moment of the start of the week / day // that the anomaly occurred using record timestamp if supplied, add on the offset, and finally // revert back to configured timezone for formatting. - if (mlFunction === 'time_of_week') { + if (func === 'time_of_week') { const d = record !== undefined && record.timestamp !== undefined ? new Date(record.timestamp) : new Date(); const utcMoment = moment.utc(d).startOf('week').add(value, 's'); return moment(utcMoment.valueOf()).format('ddd HH:mm'); - } else if (mlFunction === 'time_of_day') { + } else if (func === 'time_of_day') { const d = record !== undefined && record.timestamp !== undefined ? new Date(record.timestamp) diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/utils/number_as_ordinal.test.ts b/x-pack/plugins/file_data_visualizer/public/application/components/utils/number_as_ordinal.test.ts index 99dbd58d14624..6990bf0923ac3 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/utils/number_as_ordinal.test.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/components/utils/number_as_ordinal.test.ts @@ -7,7 +7,7 @@ import { numberAsOrdinal } from './number_as_ordinal'; -describe('ML - numberAsOrdinal formatter', () => { +describe('numberAsOrdinal formatter', () => { const tests = [ { number: 0, asOrdinal: '0th' }, { number: 1, asOrdinal: '1st' }, diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/utils/round_to_decimal_place.test.ts b/x-pack/plugins/file_data_visualizer/public/application/components/utils/round_to_decimal_place.test.ts index dc4cee37ec67e..151ae93a93815 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/utils/round_to_decimal_place.test.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/components/utils/round_to_decimal_place.test.ts @@ -7,7 +7,7 @@ import { roundToDecimalPlace } from './round_to_decimal_place'; -describe('ML - roundToDecimalPlace formatter', () => { +describe('roundToDecimalPlace formatter', () => { it('returns the correct format using default decimal place', () => { expect(roundToDecimalPlace(12)).toBe(12); expect(roundToDecimalPlace(12.3)).toBe(12.3); diff --git a/x-pack/plugins/file_data_visualizer/public/application/kibana_context.ts b/x-pack/plugins/file_data_visualizer/public/application/kibana_context.ts index 29c7cfe9bb553..6752c322d42e3 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/kibana_context.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/kibana_context.ts @@ -6,9 +6,8 @@ */ import { CoreStart } from 'kibana/public'; -import { useKibana, KibanaReactContextValue } from '../../../../../src/plugins/kibana_react/public'; +import { useKibana } from '../../../../../src/plugins/kibana_react/public'; import type { FileDataVisualizerStartDependencies } from '../plugin'; export type StartServices = CoreStart & FileDataVisualizerStartDependencies; export const useFileDataVisualizerKibana = () => useKibana(); -export type MlKibanaReactContextValue = KibanaReactContextValue; diff --git a/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.test.ts b/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.test.ts index aa909fb579b98..6f81c0bf4e7d3 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.test.ts +++ b/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.test.ts @@ -8,19 +8,19 @@ import { JOB_FIELD_TYPES } from '../../../common'; import { getJobTypeAriaLabel, jobTypeAriaLabels } from './field_types_utils'; -describe('ML - field type utils', () => { +describe('field type utils', () => { describe('getJobTypeAriaLabel: Getting a field type aria label by passing what it is stored in constants', () => { test('should returns all JOB_FIELD_TYPES labels exactly as it is for each correct value', () => { - const mlKeys = Object.keys(JOB_FIELD_TYPES); - const receivedMlLabels: Record = {}; + const keys = Object.keys(JOB_FIELD_TYPES); + const receivedLabels: Record = {}; const testStorage = jobTypeAriaLabels; - mlKeys.forEach((constant) => { - receivedMlLabels[constant] = getJobTypeAriaLabel( + keys.forEach((constant) => { + receivedLabels[constant] = getJobTypeAriaLabel( JOB_FIELD_TYPES[constant as keyof typeof JOB_FIELD_TYPES] ); }); - expect(receivedMlLabels).toEqual(testStorage); + expect(receivedLabels).toEqual(testStorage); }); test('should returns NULL as JOB_FIELD_TYPES does not contain such a keyword', () => { expect(getJobTypeAriaLabel('JOB_FIELD_TYPES')).toBe(null); From e36a7333d144399cb31b00c05e65950175e80500 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Tue, 20 Apr 2021 20:04:42 +0100 Subject: [PATCH 37/37] fixing tests --- .../application/components/embedded_map/embedded_map.tsx | 6 +++++- .../components/expanded_row/file_based_expanded_row.tsx | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/embedded_map/embedded_map.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/embedded_map/embedded_map.tsx index 3c2e0f6e44396..42bc5ebf61227 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/embedded_map/embedded_map.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/embedded_map/embedded_map.tsx @@ -146,6 +146,10 @@ export function EmbeddedMapComponent({ } return ( -
+
); } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/file_based_expanded_row.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/file_based_expanded_row.tsx index c5504b66a50f2..620bcfef8ff6c 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/file_based_expanded_row.tsx +++ b/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/file_based_expanded_row.tsx @@ -54,7 +54,7 @@ export const FileBasedDataVisualizerExpandedRow = ({ item }: { item: FileBasedFi return (
{getCardContent()}
{chartData.data[0].key_as_string}