From 34ae77dd66edbde11a6fb22c928be8decfd81be8 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 15 Aug 2019 12:16:54 +0200 Subject: [PATCH 01/35] =?UTF-8?q?=20General=20structure=20of=20Public=20w/?= =?UTF-8?q?=20legacy=20brace=20+=20autocomplete=20=F0=9F=A4=94=20=20Refact?= =?UTF-8?q?or=20Resizer=20functionality=20(panel=20component)=20=20Refacto?= =?UTF-8?q?r=20Play=20Button=20=20Refactor=20Auto-completion=20=20Refactor?= =?UTF-8?q?=20Docs=20opener=20=20Refactor=20Storage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../text/0004_application_service_mounting.md | 4 +- .../console/{index.js => index.ts} | 153 ++++++++++-------- .../core_plugins/console/public/README.md | 20 +++ .../core_plugins/console/public/index.html | 42 ----- .../console/public/np_ready/kibana.json | 6 + .../np_ready/public/app/components/index.ts | 20 +++ .../split_panel/components/resizer.tsx | 37 +++++ .../split_panel/containers/panel.tsx | 51 ++++++ .../containers/panel_container.tsx | 105 ++++++++++++ .../app/components/split_panel/context.tsx | 34 ++++ .../app/components/split_panel/index.ts | 21 +++ .../app/components/split_panel/registry.ts | 40 +++++ .../public/app/containers/editor/index.ts | 20 +++ .../editor/legacy/console_menu_actions.ts | 49 ++++++ .../app/containers/editor/legacy/index.tsx | 152 +++++++++++++++++ .../np_ready/public/app/containers/index.ts | 20 +++ .../np_ready/public/app/containers/main.tsx | 55 +++++++ .../public/app/context/app_context.tsx | 39 +++++ .../np_ready/public/app/context/index.ts | 20 +++ .../public/np_ready/public/app/index.tsx | 38 +++++ .../public/{ => np_ready/public/app}/logo.svg | 0 .../np_ready/public/app/storage/index.ts | 86 ++++++++++ .../{console.js => np_ready/public/index.ts} | 21 +-- .../console/public/np_ready/public/legacy.ts | 86 ++++++++++ .../console/public/np_ready/public/plugin.ts | 41 +++++ .../public/{ => quarantined}/_app.scss | 14 +- .../{ => quarantined}/hacks/register.js | 4 +- .../console/public/quarantined/index.html | 44 +++++ .../public/{ => quarantined}/index.scss | 0 .../{ => quarantined}/src/__tests__/app.js | 0 .../{ => quarantined}/src/__tests__/utils.js | 0 .../public/{ => quarantined}/src/app.js | 0 .../{ => quarantined}/src/autocomplete.js | 0 .../src/autocomplete/body_completer.js | 0 .../components/accept_endpoint_component.js | 0 .../components/autocomplete_component.js | 0 .../components/conditional_proxy.js | 0 .../components/constant_component.js | 0 .../field_autocomplete_component.js | 0 .../components/global_only_component.js | 0 .../components/id_autocomplete_component.js | 0 .../src/autocomplete/components/index.js | 0 .../index_autocomplete_component.js | 0 .../autocomplete/components/list_component.js | 0 .../components/object_component.js | 0 .../components/shared_component.js | 0 .../components/simple_param_component.js | 0 .../template_autocomplete_component.js | 0 .../components/type_autocomplete_component.js | 0 .../components/url_pattern_matcher.js | 0 .../username_autocomplete_component.js | 0 .../src/autocomplete/engine.js | 0 .../src/autocomplete/url_params.js | 0 .../src/components/console_menu.js | 98 ++++++----- .../src/components/dev_tools_settings.ts | 0 .../src/components/editor_example.tsx | 0 .../src/components/help_example.txt | 0 .../src/components/help_panel.tsx | 0 .../src/components/settings_modal.tsx | 0 .../src/components/welcome_panel.tsx | 0 .../src/controllers/sense_controller.js | 0 .../public/{ => quarantined}/src/curl.js | 0 .../src/directives/_help.scss | 0 .../src/directives/_history.scss | 0 .../src/directives/_index.scss | 0 .../src/directives/console_menu_directive.js | 0 .../src/directives/history.html | 0 .../src/directives/sense_history.js | 0 .../src/directives/sense_history_viewer.js | 0 .../public/{ => quarantined}/src/es.js | 0 .../src/helpers/get_top_nav.ts | 0 .../src/helpers/help_show_panel.tsx | 0 .../src/helpers/settings_show_modal.tsx | 0 .../src/helpers/welcome_show_panel.tsx | 0 .../public/{ => quarantined}/src/history.js | 0 .../public/{ => quarantined}/src/input.js | 50 +++--- .../{ => quarantined}/src/input_resize.js | 53 +++--- .../public/{ => quarantined}/src/kb.js | 0 .../public/{ => quarantined}/src/kb/api.js | 0 .../public/{ => quarantined}/src/mappings.js | 0 .../public/{ => quarantined}/src/output.js | 0 .../src/sense_editor/editor.js | 0 .../src/sense_editor/mode/input.js | 0 .../mode/input_highlight_rules.js | 0 .../src/sense_editor/mode/output.js | 0 .../mode/output_highlight_rules.js | 0 .../src/sense_editor/mode/script.js | 0 .../mode/script_highlight_rules.js | 0 .../src/sense_editor/mode/worker/index.js | 0 .../src/sense_editor/mode/worker/worker.js | 0 .../mode/x_json_highlight_rules.js | 0 .../src/sense_editor/row_parser.js | 0 .../src/sense_editor/theme_sense_dark.js} | 0 .../src/sense_editor_resize.js | 0 .../public/{ => quarantined}/src/settings.js | 0 .../{ => quarantined}/src/smart_resize.js | 2 +- .../public/{ => quarantined}/src/storage.js | 0 .../public/{ => quarantined}/src/utils.js | 0 .../tests/src/content_type.test.js | 0 .../tests/src/curl_parsing.test.js | 0 .../tests/src/curl_parsing.txt | 0 .../tests/src/editor.test.js | 0 .../tests/src/editor_input1.txt | 0 .../tests/src/input_tokenization.test.js | 0 .../tests/src/integration.test.js | 0 .../{ => quarantined}/tests/src/kb.test.js | 0 .../tests/src/mapping.test.js | 0 .../tests/src/output_tokenization.test.js | 0 .../tests/src/setup_mocks.js | 0 .../tests/src/url_autocomplete.test.js | 0 .../tests/src/url_params.test.js | 0 .../{ => quarantined}/tests/src/utils.test.js | 0 .../tests/src/utils_string_collapsing.txt | 0 .../tests/src/utils_string_expanding.txt | 0 .../console/{ => server}/api_server/api.js | 0 .../console/{ => server}/api_server/es_6_0.js | 0 .../api_server/es_6_0/aggregations.js | 0 .../{ => server}/api_server/es_6_0/aliases.js | 0 .../api_server/es_6_0/document.js | 0 .../{ => server}/api_server/es_6_0/filter.js | 0 .../{ => server}/api_server/es_6_0/globals.js | 0 .../{ => server}/api_server/es_6_0/ingest.js | 0 .../api_server/es_6_0/mappings.js | 0 .../api_server/es_6_0/query/dsl.js | 0 .../api_server/es_6_0/query/index.js | 0 .../api_server/es_6_0/query/templates.js | 0 .../{ => server}/api_server/es_6_0/reindex.js | 0 .../{ => server}/api_server/es_6_0/search.js | 0 .../console/{ => server}/api_server/server.js | 0 .../{ => server}/api_server/server.test.js | 0 .../{ => server}/api_server/spec/.eslintrc | 2 +- .../api_server/spec/generated/_common.json | 0 .../api_server/spec/generated/bulk.json | 0 .../spec/generated/cat.aliases.json | 0 .../spec/generated/cat.allocation.json | 0 .../api_server/spec/generated/cat.count.json | 0 .../spec/generated/cat.fielddata.json | 0 .../api_server/spec/generated/cat.health.json | 0 .../api_server/spec/generated/cat.help.json | 0 .../spec/generated/cat.indices.json | 0 .../api_server/spec/generated/cat.master.json | 0 .../spec/generated/cat.nodeattrs.json | 0 .../api_server/spec/generated/cat.nodes.json | 0 .../spec/generated/cat.pending_tasks.json | 0 .../spec/generated/cat.plugins.json | 0 .../spec/generated/cat.recovery.json | 0 .../spec/generated/cat.repositories.json | 0 .../spec/generated/cat.segments.json | 0 .../api_server/spec/generated/cat.shards.json | 0 .../spec/generated/cat.snapshots.json | 0 .../api_server/spec/generated/cat.tasks.json | 0 .../spec/generated/cat.templates.json | 0 .../spec/generated/cat.thread_pool.json | 0 .../spec/generated/clear_scroll.json | 0 .../generated/cluster.allocation_explain.json | 0 .../spec/generated/cluster.get_settings.json | 0 .../spec/generated/cluster.health.json | 0 .../spec/generated/cluster.pending_tasks.json | 0 .../spec/generated/cluster.put_settings.json | 0 .../spec/generated/cluster.remote_info.json | 0 .../spec/generated/cluster.reroute.json | 0 .../spec/generated/cluster.state.json | 0 .../spec/generated/cluster.stats.json | 0 .../api_server/spec/generated/count.json | 0 .../api_server/spec/generated/create.json | 0 .../api_server/spec/generated/delete.json | 0 .../spec/generated/delete_by_query.json | 0 .../generated/delete_by_query_rethrottle.json | 0 .../spec/generated/delete_script.json | 0 .../api_server/spec/generated/exists.json | 0 .../spec/generated/exists_source.json | 0 .../api_server/spec/generated/explain.json | 0 .../api_server/spec/generated/field_caps.json | 0 .../api_server/spec/generated/get.json | 0 .../api_server/spec/generated/get_script.json | 0 .../api_server/spec/generated/get_source.json | 0 .../api_server/spec/generated/index.json | 0 .../spec/generated/indices.analyze.json | 0 .../spec/generated/indices.clear_cache.json | 0 .../spec/generated/indices.close.json | 0 .../spec/generated/indices.create.json | 0 .../spec/generated/indices.delete.json | 0 .../spec/generated/indices.delete_alias.json | 0 .../generated/indices.delete_template.json | 0 .../spec/generated/indices.exists.json | 0 .../spec/generated/indices.exists_alias.json | 0 .../generated/indices.exists_template.json | 0 .../spec/generated/indices.exists_type.json | 0 .../spec/generated/indices.flush.json | 0 .../spec/generated/indices.flush_synced.json | 0 .../spec/generated/indices.forcemerge.json | 0 .../spec/generated/indices.get.json | 0 .../spec/generated/indices.get_alias.json | 0 .../generated/indices.get_field_mapping.json | 0 .../spec/generated/indices.get_mapping.json | 0 .../spec/generated/indices.get_settings.json | 0 .../spec/generated/indices.get_template.json | 0 .../spec/generated/indices.get_upgrade.json | 0 .../spec/generated/indices.open.json | 0 .../spec/generated/indices.put_alias.json | 0 .../spec/generated/indices.put_mapping.json | 0 .../spec/generated/indices.put_settings.json | 0 .../spec/generated/indices.put_template.json | 0 .../spec/generated/indices.recovery.json | 0 .../spec/generated/indices.refresh.json | 0 .../spec/generated/indices.rollover.json | 0 .../spec/generated/indices.segments.json | 0 .../spec/generated/indices.shard_stores.json | 0 .../spec/generated/indices.shrink.json | 0 .../spec/generated/indices.split.json | 0 .../spec/generated/indices.stats.json | 0 .../generated/indices.update_aliases.json | 0 .../spec/generated/indices.upgrade.json | 0 .../generated/indices.validate_query.json | 0 .../api_server/spec/generated/info.json | 0 .../generated/ingest.delete_pipeline.json | 0 .../spec/generated/ingest.get_pipeline.json | 0 .../spec/generated/ingest.processor_grok.json | 0 .../spec/generated/ingest.put_pipeline.json | 0 .../spec/generated/ingest.simulate.json | 0 .../api_server/spec/generated/mget.json | 0 .../api_server/spec/generated/msearch.json | 0 .../spec/generated/msearch_template.json | 0 .../spec/generated/mtermvectors.json | 0 .../spec/generated/nodes.hot_threads.json | 0 .../api_server/spec/generated/nodes.info.json | 0 .../nodes.reload_secure_settings.json | 0 .../spec/generated/nodes.stats.json | 0 .../spec/generated/nodes.usage.json | 0 .../api_server/spec/generated/ping.json | 0 .../api_server/spec/generated/put_script.json | 0 .../api_server/spec/generated/rank_eval.json | 0 .../api_server/spec/generated/reindex.json | 0 .../spec/generated/reindex_rethrottle.json | 0 .../generated/render_search_template.json | 0 .../generated/scripts_painless_execute.json | 0 .../api_server/spec/generated/scroll.json | 0 .../api_server/spec/generated/search.json | 0 .../spec/generated/search_shards.json | 0 .../spec/generated/search_template.json | 0 .../spec/generated/snapshot.create.json | 0 .../generated/snapshot.create_repository.json | 0 .../spec/generated/snapshot.delete.json | 0 .../generated/snapshot.delete_repository.json | 0 .../spec/generated/snapshot.get.json | 0 .../generated/snapshot.get_repository.json | 0 .../spec/generated/snapshot.restore.json | 0 .../spec/generated/snapshot.status.json | 0 .../generated/snapshot.verify_repository.json | 0 .../spec/generated/tasks.cancel.json | 0 .../api_server/spec/generated/tasks.get.json | 0 .../api_server/spec/generated/tasks.list.json | 0 .../spec/generated/termvectors.json | 0 .../api_server/spec/generated/update.json | 0 .../spec/generated/update_by_query.json | 0 .../generated/update_by_query_rethrottle.json | 0 .../{ => server}/api_server/spec/index.js | 0 .../spec/overrides/cluster.health.json | 0 .../spec/overrides/cluster.put_settings.json | 0 .../spec/overrides/cluster.reroute.json | 0 .../api_server/spec/overrides/count.json | 0 .../api_server/spec/overrides/create.json | 0 .../spec/overrides/indices.analyze.json | 0 .../spec/overrides/indices.create.json | 0 .../overrides/indices.delete_template.json | 0 .../overrides/indices.exists_template.json | 0 .../overrides/indices.get_field_mapping.json | 0 .../spec/overrides/indices.get_mapping.json | 0 .../spec/overrides/indices.get_template.json | 0 .../spec/overrides/indices.put_alias.json | 0 .../spec/overrides/indices.put_settings.json | 0 .../spec/overrides/indices.put_template.json | 0 .../spec/overrides/indices.rollover.json | 0 .../overrides/indices.update_aliases.json | 0 .../overrides/indices.validate_query.json | 0 .../spec/overrides/snapshot.create.json | 0 .../overrides/snapshot.create_repository.json | 0 .../spec/overrides/snapshot.restore.json | 0 278 files changed, 1186 insertions(+), 241 deletions(-) rename src/legacy/core_plugins/console/{index.js => index.ts} (50%) create mode 100644 src/legacy/core_plugins/console/public/README.md delete mode 100644 src/legacy/core_plugins/console/public/index.html create mode 100644 src/legacy/core_plugins/console/public/np_ready/kibana.json create mode 100644 src/legacy/core_plugins/console/public/np_ready/public/app/components/index.ts create mode 100644 src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/components/resizer.tsx create mode 100644 src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/containers/panel.tsx create mode 100644 src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/containers/panel_container.tsx create mode 100644 src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/context.tsx create mode 100644 src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/index.ts create mode 100644 src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/registry.ts create mode 100644 src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/index.ts create mode 100644 src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_menu_actions.ts create mode 100644 src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.tsx create mode 100644 src/legacy/core_plugins/console/public/np_ready/public/app/containers/index.ts create mode 100644 src/legacy/core_plugins/console/public/np_ready/public/app/containers/main.tsx create mode 100644 src/legacy/core_plugins/console/public/np_ready/public/app/context/app_context.tsx create mode 100644 src/legacy/core_plugins/console/public/np_ready/public/app/context/index.ts create mode 100644 src/legacy/core_plugins/console/public/np_ready/public/app/index.tsx rename src/legacy/core_plugins/console/public/{ => np_ready/public/app}/logo.svg (100%) create mode 100644 src/legacy/core_plugins/console/public/np_ready/public/app/storage/index.ts rename src/legacy/core_plugins/console/public/{console.js => np_ready/public/index.ts} (65%) create mode 100644 src/legacy/core_plugins/console/public/np_ready/public/legacy.ts create mode 100644 src/legacy/core_plugins/console/public/np_ready/public/plugin.ts rename src/legacy/core_plugins/console/public/{ => quarantined}/_app.scss (85%) rename src/legacy/core_plugins/console/public/{ => quarantined}/hacks/register.js (94%) create mode 100644 src/legacy/core_plugins/console/public/quarantined/index.html rename src/legacy/core_plugins/console/public/{ => quarantined}/index.scss (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/__tests__/app.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/__tests__/utils.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/app.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/autocomplete.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/autocomplete/body_completer.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/autocomplete/components/accept_endpoint_component.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/autocomplete/components/autocomplete_component.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/autocomplete/components/conditional_proxy.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/autocomplete/components/constant_component.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/autocomplete/components/field_autocomplete_component.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/autocomplete/components/global_only_component.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/autocomplete/components/id_autocomplete_component.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/autocomplete/components/index.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/autocomplete/components/index_autocomplete_component.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/autocomplete/components/list_component.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/autocomplete/components/object_component.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/autocomplete/components/shared_component.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/autocomplete/components/simple_param_component.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/autocomplete/components/template_autocomplete_component.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/autocomplete/components/type_autocomplete_component.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/autocomplete/components/url_pattern_matcher.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/autocomplete/components/username_autocomplete_component.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/autocomplete/engine.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/autocomplete/url_params.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/components/console_menu.js (64%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/components/dev_tools_settings.ts (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/components/editor_example.tsx (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/components/help_example.txt (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/components/help_panel.tsx (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/components/settings_modal.tsx (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/components/welcome_panel.tsx (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/controllers/sense_controller.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/curl.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/directives/_help.scss (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/directives/_history.scss (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/directives/_index.scss (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/directives/console_menu_directive.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/directives/history.html (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/directives/sense_history.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/directives/sense_history_viewer.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/es.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/helpers/get_top_nav.ts (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/helpers/help_show_panel.tsx (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/helpers/settings_show_modal.tsx (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/helpers/welcome_show_panel.tsx (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/history.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/input.js (89%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/input_resize.js (58%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/kb.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/kb/api.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/mappings.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/output.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/sense_editor/editor.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/sense_editor/mode/input.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/sense_editor/mode/input_highlight_rules.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/sense_editor/mode/output.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/sense_editor/mode/output_highlight_rules.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/sense_editor/mode/script.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/sense_editor/mode/script_highlight_rules.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/sense_editor/mode/worker/index.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/sense_editor/mode/worker/worker.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/sense_editor/mode/x_json_highlight_rules.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/sense_editor/row_parser.js (100%) rename src/legacy/core_plugins/console/public/{src/sense_editor/theme-sense-dark.js => quarantined/src/sense_editor/theme_sense_dark.js} (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/sense_editor_resize.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/settings.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/smart_resize.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/storage.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/src/utils.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/tests/src/content_type.test.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/tests/src/curl_parsing.test.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/tests/src/curl_parsing.txt (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/tests/src/editor.test.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/tests/src/editor_input1.txt (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/tests/src/input_tokenization.test.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/tests/src/integration.test.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/tests/src/kb.test.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/tests/src/mapping.test.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/tests/src/output_tokenization.test.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/tests/src/setup_mocks.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/tests/src/url_autocomplete.test.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/tests/src/url_params.test.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/tests/src/utils.test.js (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/tests/src/utils_string_collapsing.txt (100%) rename src/legacy/core_plugins/console/public/{ => quarantined}/tests/src/utils_string_expanding.txt (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/api.js (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/es_6_0.js (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/es_6_0/aggregations.js (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/es_6_0/aliases.js (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/es_6_0/document.js (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/es_6_0/filter.js (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/es_6_0/globals.js (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/es_6_0/ingest.js (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/es_6_0/mappings.js (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/es_6_0/query/dsl.js (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/es_6_0/query/index.js (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/es_6_0/query/templates.js (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/es_6_0/reindex.js (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/es_6_0/search.js (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/server.js (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/server.test.js (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/.eslintrc (92%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/_common.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/bulk.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/cat.aliases.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/cat.allocation.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/cat.count.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/cat.fielddata.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/cat.health.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/cat.help.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/cat.indices.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/cat.master.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/cat.nodeattrs.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/cat.nodes.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/cat.pending_tasks.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/cat.plugins.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/cat.recovery.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/cat.repositories.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/cat.segments.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/cat.shards.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/cat.snapshots.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/cat.tasks.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/cat.templates.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/cat.thread_pool.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/clear_scroll.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/cluster.allocation_explain.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/cluster.get_settings.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/cluster.health.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/cluster.pending_tasks.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/cluster.put_settings.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/cluster.remote_info.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/cluster.reroute.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/cluster.state.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/cluster.stats.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/count.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/create.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/delete.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/delete_by_query.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/delete_by_query_rethrottle.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/delete_script.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/exists.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/exists_source.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/explain.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/field_caps.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/get.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/get_script.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/get_source.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/index.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.analyze.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.clear_cache.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.close.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.create.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.delete.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.delete_alias.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.delete_template.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.exists.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.exists_alias.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.exists_template.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.exists_type.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.flush.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.flush_synced.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.forcemerge.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.get.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.get_alias.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.get_field_mapping.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.get_mapping.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.get_settings.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.get_template.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.get_upgrade.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.open.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.put_alias.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.put_mapping.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.put_settings.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.put_template.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.recovery.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.refresh.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.rollover.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.segments.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.shard_stores.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.shrink.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.split.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.stats.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.update_aliases.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.upgrade.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.validate_query.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/info.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/ingest.delete_pipeline.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/ingest.get_pipeline.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/ingest.processor_grok.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/ingest.put_pipeline.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/ingest.simulate.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/mget.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/msearch.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/msearch_template.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/mtermvectors.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/nodes.hot_threads.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/nodes.info.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/nodes.reload_secure_settings.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/nodes.stats.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/nodes.usage.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/ping.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/put_script.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/rank_eval.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/reindex.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/reindex_rethrottle.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/render_search_template.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/scripts_painless_execute.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/scroll.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/search.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/search_shards.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/search_template.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/snapshot.create.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/snapshot.create_repository.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/snapshot.delete.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/snapshot.delete_repository.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/snapshot.get.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/snapshot.get_repository.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/snapshot.restore.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/snapshot.status.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/snapshot.verify_repository.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/tasks.cancel.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/tasks.get.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/tasks.list.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/termvectors.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/update.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/update_by_query.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/update_by_query_rethrottle.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/index.js (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/overrides/cluster.health.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/overrides/cluster.put_settings.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/overrides/cluster.reroute.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/overrides/count.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/overrides/create.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/overrides/indices.analyze.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/overrides/indices.create.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/overrides/indices.delete_template.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/overrides/indices.exists_template.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/overrides/indices.get_field_mapping.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/overrides/indices.get_mapping.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/overrides/indices.get_template.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/overrides/indices.put_alias.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/overrides/indices.put_settings.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/overrides/indices.put_template.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/overrides/indices.rollover.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/overrides/indices.update_aliases.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/overrides/indices.validate_query.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/overrides/snapshot.create.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/overrides/snapshot.create_repository.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/overrides/snapshot.restore.json (100%) diff --git a/rfcs/text/0004_application_service_mounting.md b/rfcs/text/0004_application_service_mounting.md index 30e8d9a05b8b4..9a06e2c3d7f76 100644 --- a/rfcs/text/0004_application_service_mounting.md +++ b/rfcs/text/0004_application_service_mounting.md @@ -39,7 +39,7 @@ class MyPlugin { id: 'my-app', title: 'My Application', async mount(context, targetDomElement) { - const { renderApp } = await import('./applcation'); + const { renderApp } = await import('./application'); return renderApp(context, targetDomElement); } }); @@ -260,7 +260,7 @@ export class MyPlugin { application.register({ id: 'my-app', async mount(context, targetDomElem) { - const { renderApp } = await import('./applcation'); + const { renderApp } = await import('./application'); return renderApp(context, targetDomElement); } }); diff --git a/src/legacy/core_plugins/console/index.js b/src/legacy/core_plugins/console/index.ts similarity index 50% rename from src/legacy/core_plugins/console/index.js rename to src/legacy/core_plugins/console/index.ts index 8c5da496afc21..8eeb2a8f58985 100644 --- a/src/legacy/core_plugins/console/index.js +++ b/src/legacy/core_plugins/console/index.ts @@ -23,18 +23,17 @@ import { resolve, join, sep } from 'path'; import url from 'url'; import { has, isEmpty, head, pick } from 'lodash'; -import { resolveApi } from './api_server/server'; -import { addExtensionSpecFilePath } from './api_server/spec'; +// @ts-ignore +import { resolveApi } from './server/api_server/server'; +// @ts-ignore +import { addExtensionSpecFilePath } from './server/api_server/spec'; +// @ts-ignore import { setHeaders } from './server/set_headers'; +// @ts-ignore +import { ProxyConfigCollection, getElasticsearchProxyConfig, createProxyRoute } from './server'; -import { - ProxyConfigCollection, - getElasticsearchProxyConfig, - createProxyRoute -} from './server'; - -function filterHeaders(originalHeaders, headersToKeep) { - const normalizeHeader = function (header) { +function filterHeaders(originalHeaders: any, headersToKeep: any) { + const normalizeHeader = function(header: any) { if (!header) { return ''; } @@ -48,51 +47,64 @@ function filterHeaders(originalHeaders, headersToKeep) { return pick(originalHeaders, headersToKeepNormalized); } -export default function (kibana) { +// eslint-disable-next-line +export default function(kibana: any) { const modules = resolve(__dirname, 'public/webpackShims/'); - const src = resolve(__dirname, 'public/src/'); + const quarantinedSrc = resolve(__dirname, 'public/quarantined/src/'); + const src = resolve(__dirname, 'public/np_ready/public'); - let defaultVars; - const apps = []; + let defaultVars: any; + const apps: any[] = []; return new kibana.Plugin({ id: 'console', require: ['elasticsearch'], - config: function (Joi) { + config(Joi: any) { return Joi.object({ enabled: Joi.boolean().default(true), - proxyFilter: Joi.array().items(Joi.string()).single().default(['.*']), + proxyFilter: Joi.array() + .items(Joi.string()) + .single() + .default(['.*']), ssl: Joi.object({ verify: Joi.boolean(), }).default(), - proxyConfig: Joi.array().items( - Joi.object().keys({ - match: Joi.object().keys({ - protocol: Joi.string().default('*'), - host: Joi.string().default('*'), - port: Joi.string().default('*'), - path: Joi.string().default('*') - }), - - timeout: Joi.number(), - ssl: Joi.object().keys({ - verify: Joi.boolean(), - ca: Joi.array().single().items(Joi.string()), - cert: Joi.string(), - key: Joi.string() - }).default() - }) - ).default() + proxyConfig: Joi.array() + .items( + Joi.object().keys({ + match: Joi.object().keys({ + protocol: Joi.string().default('*'), + host: Joi.string().default('*'), + port: Joi.string().default('*'), + path: Joi.string().default('*'), + }), + + timeout: Joi.number(), + ssl: Joi.object() + .keys({ + verify: Joi.boolean(), + ca: Joi.array() + .single() + .items(Joi.string()), + cert: Joi.string(), + key: Joi.string(), + }) + .default(), + }) + ) + .default(), }).default(); }, - deprecations: function () { + deprecations() { return [ - (settings, log) => { + (settings: any, log: any) => { if (has(settings, 'proxyConfig')) { - log('Config key "proxyConfig" is deprecated. Configuration can be inferred from the "elasticsearch" settings'); + log( + 'Config key "proxyConfig" is deprecated. Configuration can be inferred from the "elasticsearch" settings' + ); } - } + }, ]; }, @@ -105,16 +117,18 @@ export default function (kibana) { }; }, - async init(server, options) { + async init(server: any, options: any) { server.expose('addExtensionSpecFilePath', addExtensionSpecFilePath); if (options.ssl && options.ssl.verify) { throw new Error('sense.ssl.verify is no longer supported.'); } const config = server.config(); - const legacyEsConfig = await server.newPlatform.setup.core.elasticsearch.legacy.config$.pipe(first()).toPromise(); + const legacyEsConfig = await server.newPlatform.setup.core.elasticsearch.legacy.config$ + .pipe(first()) + .toPromise(); const proxyConfigCollection = new ProxyConfigCollection(options.proxyConfig); - const proxyPathFilters = options.proxyFilter.map(str => new RegExp(str)); + const proxyPathFilters = options.proxyFilter.map((str: string) => new RegExp(str)); defaultVars = { elasticsearchUrl: url.format( @@ -122,54 +136,59 @@ export default function (kibana) { ), }; - server.route(createProxyRoute({ - baseUrl: head(legacyEsConfig.hosts), - pathFilters: proxyPathFilters, - getConfigForReq(req, uri) { - const filteredHeaders = filterHeaders(req.headers, legacyEsConfig.requestHeadersWhitelist); - const headers = setHeaders(filteredHeaders, legacyEsConfig.customHeaders); + server.route( + createProxyRoute({ + baseUrl: head(legacyEsConfig.hosts), + pathFilters: proxyPathFilters, + getConfigForReq(req: any, uri: any) { + const filteredHeaders = filterHeaders( + req.headers, + legacyEsConfig.requestHeadersWhitelist + ); + const headers = setHeaders(filteredHeaders, legacyEsConfig.customHeaders); + + if (!isEmpty(config.get('console.proxyConfig'))) { + return { + ...proxyConfigCollection.configForUri(uri), + headers, + }; + } - if (!isEmpty(config.get('console.proxyConfig'))) { return { - ...proxyConfigCollection.configForUri(uri), + ...getElasticsearchProxyConfig(legacyEsConfig), headers, }; - } - - return { - ...getElasticsearchProxyConfig(legacyEsConfig), - headers, - }; - } - })); + }, + }) + ); server.route({ path: '/api/console/api_server', method: ['GET', 'POST'], - handler: function (req, h) { + handler(req: any, h: any) { const { sense_version: version, apis } = req.query; if (!apis) { throw Boom.badRequest('"apis" is a required param.'); } return resolveApi(version, apis.split(','), h); - } + }, }); }, uiExports: { - apps: apps, - hacks: ['plugins/console/hacks/register'], - devTools: ['plugins/console/console'], - styleSheetPaths: resolve(__dirname, 'public/index.scss'), + apps, + hacks: ['plugins/console/quarantined/hacks/register'], + devTools: [`${src}/legacy`], + styleSheetPaths: resolve(__dirname, 'public/quarantined/index.scss'), injectDefaultVars: () => defaultVars, noParse: [ join(modules, 'ace' + sep), join(modules, 'moment_src/moment' + sep), - join(src, 'sense_editor/mode/worker.js') - ] - } - }); + join(quarantinedSrc, 'sense_editor/mode/worker.js'), + ], + }, + } as any); } diff --git a/src/legacy/core_plugins/console/public/README.md b/src/legacy/core_plugins/console/public/README.md new file mode 100644 index 0000000000000..2633a82084c80 --- /dev/null +++ b/src/legacy/core_plugins/console/public/README.md @@ -0,0 +1,20 @@ +## New Platform (NP) Ready vs Quarantined + +We want to move toward more modularised code in the Console app. +Part of the effort means separating out different console compoonents +like: + +- The language parser +- The editor rendering component +- Autocomplete +- The UI container components + +In addition to this effort we want to bring Console in line with NP +requirements and ensure that we are not using NG in this app anymore. + +The quarantined folder contains all of the code that has been cleared +for living in the new platform as it has not been properly refactored +or has dependencies on, for example, UI public. + +Over time, the quarantined part of the code should shrink to nothing +and we should only have NP ready code. diff --git a/src/legacy/core_plugins/console/public/index.html b/src/legacy/core_plugins/console/public/index.html deleted file mode 100644 index 91bcb05bf64cc..0000000000000 --- a/src/legacy/core_plugins/console/public/index.html +++ /dev/null @@ -1,42 +0,0 @@ - - - -
-
-
    -
    - - - - - -
    - -
    GET _search - { - "query": { "match_all": {} } - }
    - -
    -
    -
    -
    {}
    -
    -
    -
    -
    -
    -
    diff --git a/src/legacy/core_plugins/console/public/np_ready/kibana.json b/src/legacy/core_plugins/console/public/np_ready/kibana.json new file mode 100644 index 0000000000000..ed8e4d8f15830 --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/kibana.json @@ -0,0 +1,6 @@ +{ + "id": "console", + "version": "kibana", + "server": true, + "ui": true +} diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/components/index.ts b/src/legacy/core_plugins/console/public/np_ready/public/app/components/index.ts new file mode 100644 index 0000000000000..378264c1f3b91 --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/components/index.ts @@ -0,0 +1,20 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export * from './split_panel'; diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/components/resizer.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/components/resizer.tsx new file mode 100644 index 0000000000000..605f90a7fc606 --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/components/resizer.tsx @@ -0,0 +1,37 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React from 'react'; + +type ResizerMouseEvent = React.MouseEvent; + +export interface Props { + onMouseDown: (eve: ResizerMouseEvent) => void; +} + +/** + * TODO: This component uses styling constants from public UI - should be removed, next iteration should incl. horizontal and vertical resizers. + */ +export function Resizer(props: Props) { + return ( +
    + ︙ +
    + ); +} diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/containers/panel.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/containers/panel.tsx new file mode 100644 index 0000000000000..747c21433f8ed --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/containers/panel.tsx @@ -0,0 +1,51 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React, { CSSProperties, ReactNode, useEffect, useRef, useState } from 'react'; +import { usePanelContext } from '../context'; + +export interface Props { + children: ReactNode[] | ReactNode; + initialWidth?: string; + style?: CSSProperties; +} + +export function Panel({ children, initialWidth = '100%', style = {} }: Props) { + const [width, setWidth] = useState(initialWidth); + const { registry } = usePanelContext(); + const divRef = useRef(null); + + useEffect(() => { + registry.registerPanel({ + initialWidth, + setWidth(value) { + setWidth(value + '%'); + }, + getWidth() { + return divRef.current!.getBoundingClientRect().width; + }, + }); + }, []); + + return ( +
    + {children} +
    + ); +} diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/containers/panel_container.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/containers/panel_container.tsx new file mode 100644 index 0000000000000..d5c5882a2e227 --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/containers/panel_container.tsx @@ -0,0 +1,105 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React, { Children, ReactNode, useRef, useState } from 'react'; + +import { PanelContextProvider } from '../context'; +import { Resizer } from '../components/resizer'; +import { PanelRegistry } from '../registry'; + +export interface Props { + children: ReactNode; + onPanelWidthChange?: (arrayOfPanelWidths: number[]) => any; +} + +const initialState = { currentPanel: -1, isDragging: false, currentResizerPos: -1 }; + +const pxToPercent = (proportion: number, whole: number) => (proportion / whole) * 100; + +// TODO: Write tests for this +export function PanelContainer({ children, onPanelWidthChange }: Props) { + const [head, ...rest] = Children.toArray(children); + + const registryRef = useRef(new PanelRegistry()); + const containerRef = useRef(null); + const [state, setState] = useState(initialState); + + const getContainerWidth = () => { + return containerRef.current!.getBoundingClientRect().width; + }; + + const resizableChildren = rest.reduce( + (acc: ReactNode[], child, idx) => { + // The target idx is offset by one, we want to target the panel to the left of the resizer + // for resizing. + return acc.concat([ + { + eve.preventDefault(); + setState({ + ...state, + currentPanel: idx, + isDragging: true, + currentResizerPos: eve.clientX, + }); + }} + />, + child, + ]); + }, + [head] + ); + + return ( + +
    { + if (state.isDragging) { + const { clientX: x } = eve; + const { current: registry } = registryRef; + const [left, right] = registry.getResizerNeighbours(state.currentPanel); + const delta = x - state.currentResizerPos; + const containerWidth = getContainerWidth(); + const leftPercent = pxToPercent(left.getWidth() + delta, containerWidth); + const rightPercent = pxToPercent(right.getWidth() - delta, containerWidth); + + left.setWidth(leftPercent); + right.setWidth(rightPercent); + + if (onPanelWidthChange) { + onPanelWidthChange( + registry.getPanels().map(panel => pxToPercent(panel.getWidth(), containerWidth)) + ); + } + + setState({ ...state, currentResizerPos: x }); + } + }} + onMouseUp={() => { + setState(initialState); + }} + > + {resizableChildren} +
    +
    + ); +} diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/context.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/context.tsx new file mode 100644 index 0000000000000..0c3aee794b39b --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/context.tsx @@ -0,0 +1,34 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React, { createContext, useContext } from 'react'; +import { PanelRegistry } from './registry'; + +const PanelContext = createContext({ registry: new PanelRegistry() }); + +interface ContextProps { + children: any; + registry: PanelRegistry; +} + +export function PanelContextProvider({ children, registry }: ContextProps) { + return {children}; +} + +export const usePanelContext = () => useContext(PanelContext); diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/index.ts b/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/index.ts new file mode 100644 index 0000000000000..2db2ee7ff2ca2 --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/index.ts @@ -0,0 +1,21 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { Panel } from './containers/panel'; +export { PanelContainer } from './containers/panel_container'; diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/registry.ts b/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/registry.ts new file mode 100644 index 0000000000000..5f06ab8915270 --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/registry.ts @@ -0,0 +1,40 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export interface PanelController { + setWidth: (percent: number) => void; + getWidth: () => number; + initialWidth: string; +} + +export class PanelRegistry { + private panels: PanelController[] = []; + + registerPanel(panel: PanelController) { + this.panels.push(panel); + } + + getResizerNeighbours(idx: number) { + return [this.panels[idx], this.panels[idx + 1]]; + } + + getPanels() { + return this.panels.map(panel => ({ ...panel })); + } +} diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/index.ts b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/index.ts new file mode 100644 index 0000000000000..443a80be80620 --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/index.ts @@ -0,0 +1,20 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { ConsoleEditor } from './legacy'; diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_menu_actions.ts b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_menu_actions.ts new file mode 100644 index 0000000000000..574e351178143 --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_menu_actions.ts @@ -0,0 +1,49 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +// @ts-ignore +import { getEndpointFromPosition } from '../../../../../../quarantined/src/autocomplete'; + +export function autoIndent(editor: any, event: any) { + editor.autoIndent(); + event.preventDefault(); + editor.focus(); +} + +export function getDocumentation(editor: any, docLinkVersion: string): Promise { + return new Promise(resolve => { + editor.getRequestsInRange((requests: any) => { + if (!requests || requests.length === 0) { + resolve(null); + return; + } + const position = requests[0].range.end; + position.column = position.column - 1; + const endpoint = getEndpointFromPosition(editor, position); + if (endpoint && endpoint.documentation && endpoint.documentation.indexOf('http') !== -1) { + const nextDocumentation = endpoint.documentation + .replace('/master/', `/${docLinkVersion}/`) + .replace('/current/', `/${docLinkVersion}/`); + resolve(nextDocumentation); + } else { + resolve(null); + } + }); + }); +} diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.tsx new file mode 100644 index 0000000000000..414eecd6edc5f --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.tsx @@ -0,0 +1,152 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React, { CSSProperties, useEffect, useRef, useState } from 'react'; +import $ from 'jquery'; +import { EuiToolTip } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; + +// @ts-ignore +import { initializeInput } from '../../../../../../quarantined/src/input'; +// @ts-ignore +import { initializeOutput } from '../../../../../../quarantined/src/output'; +// @ts-ignore +import { ConsoleMenu } from '../../../../../../quarantined/src/components/console_menu'; +// @ts-ignore +import init from '../../../../../../quarantined/src/app'; + +import { autoIndent, getDocumentation } from './console_menu_actions'; +import { Panel, PanelContainer } from '../../../components/split_panel'; + +const PANEL_MIN_WIDTH = '100px'; + +const abs: CSSProperties = { + position: 'absolute', + top: '0', + left: '0', + bottom: '0', + right: '0', +}; + +export interface EditorProps { + docLinkVersion: string; + onPanelWidthChange: (widths: number[]) => void; + initialInputPanelWidth: number; + initialOutputPanelWidth: number; +} + +export function ConsoleEditor({ + onPanelWidthChange, + docLinkVersion, + initialInputPanelWidth, + initialOutputPanelWidth, +}: EditorProps) { + const editorRef = useRef(null); + const outputRef = useRef(null); + const actionsRef = useRef(null); + + const [, setLastRequestTimestamp] = useState(null as any); + const [editor, setEditor] = useState(null as any); + const [, setOutput] = useState(null as any); + + const sendCurrentRequest = () => { + editor.focus(); + editor.sendCurrentRequestToES(() => { + // History watches this value and will re-render itself when it changes, so that + // the list of requests stays up-to-date as new requests are sent. + setLastRequestTimestamp(new Date().getTime()); + }); + return false; + }; + + useEffect(() => { + const editor$ = $(editorRef.current!); + const output$ = $(outputRef.current!); + const actions$ = $(actionsRef.current!); + + const outputEditor = initializeOutput(output$); + const inputEditor = initializeInput(editor$, actions$, outputEditor); + init(inputEditor, outputEditor); + + const session = inputEditor.getSession(); + session.getSelection().on('changeCursor', () => { + // Fire and forget + getDocumentation(inputEditor, docLinkVersion); + }); + + setOutput(outputEditor); + setEditor(inputEditor); + }, []); + + return ( + + +
    +
    +
      +
      + + + + { + editor.getRequestsAsCURL(cb); + }} + openDocumentation={() => {}} + getDocumentation={() => { + return getDocumentation(editor, docLinkVersion); + }} + autoIndent={(event: any) => { + autoIndent(editor, event); + }} + /> +
      +
      + {`GET _search + { + "query": { "match_all": { } } + }`} +
      +
    +
    +
    + +
    +
    {`{}`}
    +
    +
    +
    + ); +} diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/index.ts b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/index.ts new file mode 100644 index 0000000000000..44e8355611f48 --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/index.ts @@ -0,0 +1,20 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { Main } from './main'; diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main.tsx new file mode 100644 index 0000000000000..81565570251c6 --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main.tsx @@ -0,0 +1,55 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React, { useCallback } from 'react'; +import { debounce } from 'lodash'; + +import { ConsoleEditor } from './editor'; + +import { useAppContext } from '../context'; +import { StorageKeys } from '../storage'; + +const INITIAL_PANEL_WIDTH = 50; + +export function Main() { + const { storage, docLinkVersion } = useAppContext(); + const [firstPanelWidth, secondPanelWidth] = storage.get(StorageKeys.WIDTH, [ + INITIAL_PANEL_WIDTH, + INITIAL_PANEL_WIDTH, + ]); + + const onPanelWidthChange = useCallback( + debounce( + (widths: number[]) => { + storage.set(StorageKeys.WIDTH, widths); + }, + 300, + { trailing: true } + ), + [] + ); + return ( + + ); +} diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/context/app_context.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/context/app_context.tsx new file mode 100644 index 0000000000000..a3702563021d4 --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/context/app_context.tsx @@ -0,0 +1,39 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React, { createContext, useContext } from 'react'; +import { Storage } from '../storage'; + +interface ContextValue { + storage: Storage; + docLinkVersion: string; +} + +interface ContextProps { + value: ContextValue; + children: any; +} + +const AppContext = createContext(null as any); + +export function AppContextProvider({ children, value }: ContextProps) { + return {children}; +} + +export const useAppContext = () => useContext(AppContext); diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/context/index.ts b/src/legacy/core_plugins/console/public/np_ready/public/app/context/index.ts new file mode 100644 index 0000000000000..27d69f5736ffe --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/context/index.ts @@ -0,0 +1,20 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { useAppContext, AppContextProvider } from './app_context'; diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/index.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/index.tsx new file mode 100644 index 0000000000000..7d94535dab81f --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/index.tsx @@ -0,0 +1,38 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React from 'react'; +import { AppContextProvider } from './context'; +import { Main } from './containers'; +import { create as createStorage } from './storage'; + +export function boot(I18nContext: any, deps: { docLinkVersion: string }) { + const storage = createStorage({ + engine: window.localStorage, + prefix: 'console_editor:', + }); + + return ( + + +
    + + + ); +} diff --git a/src/legacy/core_plugins/console/public/logo.svg b/src/legacy/core_plugins/console/public/np_ready/public/app/logo.svg similarity index 100% rename from src/legacy/core_plugins/console/public/logo.svg rename to src/legacy/core_plugins/console/public/np_ready/public/app/logo.svg diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/storage/index.ts b/src/legacy/core_plugins/console/public/np_ready/public/app/storage/index.ts new file mode 100644 index 0000000000000..f65f087b47e8a --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/storage/index.ts @@ -0,0 +1,86 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { transform, keys, startsWith } from 'lodash'; + +interface GenericObject { + [key: string]: any; +} + +type IStorageEngine = typeof window.localStorage; + +export enum StorageKeys { + WIDTH = 'widths', +} + +export class Storage { + constructor(private readonly engine: IStorageEngine, private readonly prefix: string) {} + + encode(val: GenericObject) { + return JSON.stringify(val); + } + + decode(val: any) { + if (typeof val === 'string') { + return JSON.parse(val); + } + } + + encodeKey(key: string) { + return `${this.prefix}${key}`; + } + + decodeKey(key: string) { + if (startsWith(key, this.prefix)) { + return `${key.slice(this.prefix.length)}`; + } + } + + set(key: string, val: GenericObject) { + this.engine.setItem(this.encodeKey(key), this.encode(val)); + return val; + } + + has(key: string) { + return this.engine.getItem(this.encodeKey(key)) != null; + } + + get(key: string, _default: T) { + if (this.has(key)) { + return this.decode(this.engine.getItem(this.encodeKey(key))); + } else { + return _default; + } + } + + delete(key: string) { + return this.engine.removeItem(this.encodeKey(key)); + } + + keys() { + return transform(keys(this.engine), (ours, key) => { + const ourKey = this.decodeKey(key); + if (ourKey != null) ours.push(ourKey); + }); + } +} + +export function create({ engine, prefix }: { engine: IStorageEngine; prefix: string }) { + return new Storage(engine, prefix); +} diff --git a/src/legacy/core_plugins/console/public/console.js b/src/legacy/core_plugins/console/public/np_ready/public/index.ts similarity index 65% rename from src/legacy/core_plugins/console/public/console.js rename to src/legacy/core_plugins/console/public/np_ready/public/index.ts index 2cb8d299d993f..c3cb4d35e4d86 100644 --- a/src/legacy/core_plugins/console/public/console.js +++ b/src/legacy/core_plugins/console/public/np_ready/public/index.ts @@ -17,21 +17,12 @@ * under the License. */ -import uiRoutes from 'ui/routes'; -import template from './index.html'; +import { PluginInitializerContext } from '../../../../../../core/public'; -require('brace'); +import { ConsoleUIPlugin } from './plugin'; -require('ui/autoload/styles'); -require('ui/capabilities/route_setup'); +export { ConsoleUIPlugin as Plugin }; -require('./src/controllers/sense_controller'); -require('./src/directives/sense_history'); -require('./src/directives/console_menu_directive'); - - -uiRoutes.when('/dev_tools/console', { - requireUICapability: 'dev_tools.show', - controller: 'SenseController', - template, -}); +export function plugin(ctx: PluginInitializerContext) { + return new ConsoleUIPlugin(ctx); +} diff --git a/src/legacy/core_plugins/console/public/np_ready/public/legacy.ts b/src/legacy/core_plugins/console/public/np_ready/public/legacy.ts new file mode 100644 index 0000000000000..7e1573b04af8b --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/public/legacy.ts @@ -0,0 +1,86 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import 'brace'; + +/* eslint-disable @kbn/eslint/no-restricted-paths */ +import { npSetup, npStart } from 'ui/new_platform'; +import uiRoutes from 'ui/routes'; +import { DOC_LINK_VERSION } from 'ui/documentation_links'; +import { I18nContext } from 'ui/i18n'; +import 'ui/autoload/styles'; +import 'ui/capabilities/route_setup'; +/* eslint-enable @kbn/eslint/no-restricted-paths */ + +// require('./src/directives/sense_history'); +// require('./src/directives/console_menu_directive'); + +import template from '../../quarantined/index.html'; +import { CoreSetup } from '../../../../../../core/public'; + +interface SetupRegisterAppArgs { + id: string; + mount: (ctx: any, targetElement: HTMLDivElement) => Promise; +} + +export interface XCoreSetup extends CoreSetup { + docLinkVersion: string; + I18nContext: any; + application: { + register(args: SetupRegisterAppArgs): void; + }; +} + +import { plugin } from '.'; + +const pluginInstance = plugin({} as any); + +uiRoutes.when('/dev_tools/console', { + requireUICapability: 'dev_tools.show', + controller: function RootController($scope) { + // Stub out this config for now... + $scope.topNavMenu = []; + + $scope.initReactApp = () => { + const targetElement = document.querySelector('#consoleRoot'); + if (!targetElement) { + const message = `Could not mount Console App!`; + npSetup.core.fatalErrors.add(message); + throw new Error(message); + } + + const xNpSetupCore: XCoreSetup = { + ...npSetup.core, + I18nContext, + docLinkVersion: DOC_LINK_VERSION, + application: { + register(args: SetupRegisterAppArgs): void { + args.mount({}, targetElement).catch(err => { + npSetup.core.fatalErrors.add(err); + }); + }, + }, + }; + + pluginInstance.setup(xNpSetupCore); + pluginInstance.start(npStart.core); + }; + }, + template, +}); diff --git a/src/legacy/core_plugins/console/public/np_ready/public/plugin.ts b/src/legacy/core_plugins/console/public/np_ready/public/plugin.ts new file mode 100644 index 0000000000000..17cc0749fa76c --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/public/plugin.ts @@ -0,0 +1,41 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { render, unmountComponentAtNode } from 'react-dom'; + +import { PluginInitializerContext, Plugin, CoreStart } from '../../../../../../core/public'; +import { boot } from './app'; +import { XCoreSetup } from './legacy'; + +export class ConsoleUIPlugin implements Plugin { + // @ts-ignore + constructor(private readonly ctx: PluginInitializerContext) {} + + async setup({ application, docLinkVersion, I18nContext }: XCoreSetup) { + application.register({ + id: 'console', + async mount(ctx, targetElement) { + render(boot(I18nContext, { docLinkVersion }), targetElement); + return () => unmountComponentAtNode(targetElement); + }, + }); + } + + async start(core: CoreStart) {} +} diff --git a/src/legacy/core_plugins/console/public/_app.scss b/src/legacy/core_plugins/console/public/quarantined/_app.scss similarity index 85% rename from src/legacy/core_plugins/console/public/_app.scss rename to src/legacy/core_plugins/console/public/quarantined/_app.scss index f3de2a9ee9e5b..a5b6ed1979d1f 100644 --- a/src/legacy/core_plugins/console/public/_app.scss +++ b/src/legacy/core_plugins/console/public/quarantined/_app.scss @@ -1,20 +1,22 @@ +// TODO: Move all of the styles here (should be modularised by, e.g., CSS-in-JS or CSS modules). +#consoleRoot { + height: 100%; + padding: $euiSizeS; +} + .conApp { display: flex; flex: 1 1 auto; - position: relative; - padding: $euiSizeS; // Make sure the editor actions don't create scrollbars on this container // SASSTODO: Uncomment when tooltips are EUI-ified (inside portals) // overflow: hidden; } .conApp__editor { - // Default size of left side is half the large breakpoint - // but this is inline overridden by the resizer - width: map-get($euiBreakpoints, "l") / 2; + width: 100%; display: flex; flex: 0 0 auto; - position: relative; + //position: relative; } .conApp__output { diff --git a/src/legacy/core_plugins/console/public/hacks/register.js b/src/legacy/core_plugins/console/public/quarantined/hacks/register.js similarity index 94% rename from src/legacy/core_plugins/console/public/hacks/register.js rename to src/legacy/core_plugins/console/public/quarantined/hacks/register.js index 4869ae4b0ed00..b5df1c1af99c5 100644 --- a/src/legacy/core_plugins/console/public/hacks/register.js +++ b/src/legacy/core_plugins/console/public/quarantined/hacks/register.js @@ -24,7 +24,7 @@ DevToolsRegistryProvider.register(() => ({ order: 1, name: 'console', display: i18n.translate('console.consoleDisplayName', { - defaultMessage: 'Console' + defaultMessage: 'Console', }), - url: '#/dev_tools/console' + url: '#/dev_tools/console', })); diff --git a/src/legacy/core_plugins/console/public/quarantined/index.html b/src/legacy/core_plugins/console/public/quarantined/index.html new file mode 100644 index 0000000000000..b099d08ce6c45 --- /dev/null +++ b/src/legacy/core_plugins/console/public/quarantined/index.html @@ -0,0 +1,44 @@ + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + diff --git a/src/legacy/core_plugins/console/public/index.scss b/src/legacy/core_plugins/console/public/quarantined/index.scss similarity index 100% rename from src/legacy/core_plugins/console/public/index.scss rename to src/legacy/core_plugins/console/public/quarantined/index.scss diff --git a/src/legacy/core_plugins/console/public/src/__tests__/app.js b/src/legacy/core_plugins/console/public/quarantined/src/__tests__/app.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/__tests__/app.js rename to src/legacy/core_plugins/console/public/quarantined/src/__tests__/app.js diff --git a/src/legacy/core_plugins/console/public/src/__tests__/utils.js b/src/legacy/core_plugins/console/public/quarantined/src/__tests__/utils.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/__tests__/utils.js rename to src/legacy/core_plugins/console/public/quarantined/src/__tests__/utils.js diff --git a/src/legacy/core_plugins/console/public/src/app.js b/src/legacy/core_plugins/console/public/quarantined/src/app.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/app.js rename to src/legacy/core_plugins/console/public/quarantined/src/app.js diff --git a/src/legacy/core_plugins/console/public/src/autocomplete.js b/src/legacy/core_plugins/console/public/quarantined/src/autocomplete.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/autocomplete.js rename to src/legacy/core_plugins/console/public/quarantined/src/autocomplete.js diff --git a/src/legacy/core_plugins/console/public/src/autocomplete/body_completer.js b/src/legacy/core_plugins/console/public/quarantined/src/autocomplete/body_completer.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/autocomplete/body_completer.js rename to src/legacy/core_plugins/console/public/quarantined/src/autocomplete/body_completer.js diff --git a/src/legacy/core_plugins/console/public/src/autocomplete/components/accept_endpoint_component.js b/src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/accept_endpoint_component.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/autocomplete/components/accept_endpoint_component.js rename to src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/accept_endpoint_component.js diff --git a/src/legacy/core_plugins/console/public/src/autocomplete/components/autocomplete_component.js b/src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/autocomplete_component.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/autocomplete/components/autocomplete_component.js rename to src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/autocomplete_component.js diff --git a/src/legacy/core_plugins/console/public/src/autocomplete/components/conditional_proxy.js b/src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/conditional_proxy.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/autocomplete/components/conditional_proxy.js rename to src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/conditional_proxy.js diff --git a/src/legacy/core_plugins/console/public/src/autocomplete/components/constant_component.js b/src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/constant_component.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/autocomplete/components/constant_component.js rename to src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/constant_component.js diff --git a/src/legacy/core_plugins/console/public/src/autocomplete/components/field_autocomplete_component.js b/src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/field_autocomplete_component.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/autocomplete/components/field_autocomplete_component.js rename to src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/field_autocomplete_component.js diff --git a/src/legacy/core_plugins/console/public/src/autocomplete/components/global_only_component.js b/src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/global_only_component.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/autocomplete/components/global_only_component.js rename to src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/global_only_component.js diff --git a/src/legacy/core_plugins/console/public/src/autocomplete/components/id_autocomplete_component.js b/src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/id_autocomplete_component.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/autocomplete/components/id_autocomplete_component.js rename to src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/id_autocomplete_component.js diff --git a/src/legacy/core_plugins/console/public/src/autocomplete/components/index.js b/src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/index.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/autocomplete/components/index.js rename to src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/index.js diff --git a/src/legacy/core_plugins/console/public/src/autocomplete/components/index_autocomplete_component.js b/src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/index_autocomplete_component.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/autocomplete/components/index_autocomplete_component.js rename to src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/index_autocomplete_component.js diff --git a/src/legacy/core_plugins/console/public/src/autocomplete/components/list_component.js b/src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/list_component.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/autocomplete/components/list_component.js rename to src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/list_component.js diff --git a/src/legacy/core_plugins/console/public/src/autocomplete/components/object_component.js b/src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/object_component.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/autocomplete/components/object_component.js rename to src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/object_component.js diff --git a/src/legacy/core_plugins/console/public/src/autocomplete/components/shared_component.js b/src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/shared_component.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/autocomplete/components/shared_component.js rename to src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/shared_component.js diff --git a/src/legacy/core_plugins/console/public/src/autocomplete/components/simple_param_component.js b/src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/simple_param_component.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/autocomplete/components/simple_param_component.js rename to src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/simple_param_component.js diff --git a/src/legacy/core_plugins/console/public/src/autocomplete/components/template_autocomplete_component.js b/src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/template_autocomplete_component.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/autocomplete/components/template_autocomplete_component.js rename to src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/template_autocomplete_component.js diff --git a/src/legacy/core_plugins/console/public/src/autocomplete/components/type_autocomplete_component.js b/src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/type_autocomplete_component.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/autocomplete/components/type_autocomplete_component.js rename to src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/type_autocomplete_component.js diff --git a/src/legacy/core_plugins/console/public/src/autocomplete/components/url_pattern_matcher.js b/src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/url_pattern_matcher.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/autocomplete/components/url_pattern_matcher.js rename to src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/url_pattern_matcher.js diff --git a/src/legacy/core_plugins/console/public/src/autocomplete/components/username_autocomplete_component.js b/src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/username_autocomplete_component.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/autocomplete/components/username_autocomplete_component.js rename to src/legacy/core_plugins/console/public/quarantined/src/autocomplete/components/username_autocomplete_component.js diff --git a/src/legacy/core_plugins/console/public/src/autocomplete/engine.js b/src/legacy/core_plugins/console/public/quarantined/src/autocomplete/engine.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/autocomplete/engine.js rename to src/legacy/core_plugins/console/public/quarantined/src/autocomplete/engine.js diff --git a/src/legacy/core_plugins/console/public/src/autocomplete/url_params.js b/src/legacy/core_plugins/console/public/quarantined/src/autocomplete/url_params.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/autocomplete/url_params.js rename to src/legacy/core_plugins/console/public/quarantined/src/autocomplete/url_params.js diff --git a/src/legacy/core_plugins/console/public/src/components/console_menu.js b/src/legacy/core_plugins/console/public/quarantined/src/components/console_menu.js similarity index 64% rename from src/legacy/core_plugins/console/public/src/components/console_menu.js rename to src/legacy/core_plugins/console/public/quarantined/src/components/console_menu.js index 3ab05556f643e..07a3e57dd7ee7 100644 --- a/src/legacy/core_plugins/console/public/src/components/console_menu.js +++ b/src/legacy/core_plugins/console/public/quarantined/src/components/console_menu.js @@ -19,16 +19,9 @@ import PropTypes from 'prop-types'; -import React, { - Component, -} from 'react'; +import React, { Component } from 'react'; -import { - EuiButtonIcon, - EuiContextMenuPanel, - EuiContextMenuItem, - EuiPopover, -} from '@elastic/eui'; +import { EuiButtonIcon, EuiContextMenuPanel, EuiContextMenuItem, EuiPopover } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; @@ -47,7 +40,7 @@ export class ConsoleMenu extends Component { this.props.getCurl(text => { this.setState({ curlCode: text }); }); - } + }; copyAsCurl() { this.copyText(this.state.curlCode); @@ -74,11 +67,14 @@ export class ConsoleMenu extends Component { }); }; - openDocs = () => { + openDocs = async () => { this.closePopover(); - this.props.getDocumentation(); - this.props.openDocumentation(); - } + const documentation = await this.props.getDocumentation(); + if (!documentation) { + return; + } + window.open(documentation, '_blank'); + }; render() { const button = ( @@ -95,39 +91,43 @@ export class ConsoleMenu extends Component { ); const items = [ - ( - { this.closePopover(); this.copyAsCurl(); }} - > - - - ), ( - { this.openDocs(); }} - > - - - ), ( - { this.closePopover(); this.props.autoIndent(event); }} - > - - - ) + { + this.closePopover(); + this.copyAsCurl(); + }} + > + + , + { + this.openDocs(); + }} + > + + , + { + this.closePopover(); + this.props.autoIndent(event); + }} + > + + , ]; return ( @@ -140,9 +140,7 @@ export class ConsoleMenu extends Component { panelPaddingSize="none" anchorPosition="downLeft" > - + ); diff --git a/src/legacy/core_plugins/console/public/src/components/dev_tools_settings.ts b/src/legacy/core_plugins/console/public/quarantined/src/components/dev_tools_settings.ts similarity index 100% rename from src/legacy/core_plugins/console/public/src/components/dev_tools_settings.ts rename to src/legacy/core_plugins/console/public/quarantined/src/components/dev_tools_settings.ts diff --git a/src/legacy/core_plugins/console/public/src/components/editor_example.tsx b/src/legacy/core_plugins/console/public/quarantined/src/components/editor_example.tsx similarity index 100% rename from src/legacy/core_plugins/console/public/src/components/editor_example.tsx rename to src/legacy/core_plugins/console/public/quarantined/src/components/editor_example.tsx diff --git a/src/legacy/core_plugins/console/public/src/components/help_example.txt b/src/legacy/core_plugins/console/public/quarantined/src/components/help_example.txt similarity index 100% rename from src/legacy/core_plugins/console/public/src/components/help_example.txt rename to src/legacy/core_plugins/console/public/quarantined/src/components/help_example.txt diff --git a/src/legacy/core_plugins/console/public/src/components/help_panel.tsx b/src/legacy/core_plugins/console/public/quarantined/src/components/help_panel.tsx similarity index 100% rename from src/legacy/core_plugins/console/public/src/components/help_panel.tsx rename to src/legacy/core_plugins/console/public/quarantined/src/components/help_panel.tsx diff --git a/src/legacy/core_plugins/console/public/src/components/settings_modal.tsx b/src/legacy/core_plugins/console/public/quarantined/src/components/settings_modal.tsx similarity index 100% rename from src/legacy/core_plugins/console/public/src/components/settings_modal.tsx rename to src/legacy/core_plugins/console/public/quarantined/src/components/settings_modal.tsx diff --git a/src/legacy/core_plugins/console/public/src/components/welcome_panel.tsx b/src/legacy/core_plugins/console/public/quarantined/src/components/welcome_panel.tsx similarity index 100% rename from src/legacy/core_plugins/console/public/src/components/welcome_panel.tsx rename to src/legacy/core_plugins/console/public/quarantined/src/components/welcome_panel.tsx diff --git a/src/legacy/core_plugins/console/public/src/controllers/sense_controller.js b/src/legacy/core_plugins/console/public/quarantined/src/controllers/sense_controller.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/controllers/sense_controller.js rename to src/legacy/core_plugins/console/public/quarantined/src/controllers/sense_controller.js diff --git a/src/legacy/core_plugins/console/public/src/curl.js b/src/legacy/core_plugins/console/public/quarantined/src/curl.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/curl.js rename to src/legacy/core_plugins/console/public/quarantined/src/curl.js diff --git a/src/legacy/core_plugins/console/public/src/directives/_help.scss b/src/legacy/core_plugins/console/public/quarantined/src/directives/_help.scss similarity index 100% rename from src/legacy/core_plugins/console/public/src/directives/_help.scss rename to src/legacy/core_plugins/console/public/quarantined/src/directives/_help.scss diff --git a/src/legacy/core_plugins/console/public/src/directives/_history.scss b/src/legacy/core_plugins/console/public/quarantined/src/directives/_history.scss similarity index 100% rename from src/legacy/core_plugins/console/public/src/directives/_history.scss rename to src/legacy/core_plugins/console/public/quarantined/src/directives/_history.scss diff --git a/src/legacy/core_plugins/console/public/src/directives/_index.scss b/src/legacy/core_plugins/console/public/quarantined/src/directives/_index.scss similarity index 100% rename from src/legacy/core_plugins/console/public/src/directives/_index.scss rename to src/legacy/core_plugins/console/public/quarantined/src/directives/_index.scss diff --git a/src/legacy/core_plugins/console/public/src/directives/console_menu_directive.js b/src/legacy/core_plugins/console/public/quarantined/src/directives/console_menu_directive.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/directives/console_menu_directive.js rename to src/legacy/core_plugins/console/public/quarantined/src/directives/console_menu_directive.js diff --git a/src/legacy/core_plugins/console/public/src/directives/history.html b/src/legacy/core_plugins/console/public/quarantined/src/directives/history.html similarity index 100% rename from src/legacy/core_plugins/console/public/src/directives/history.html rename to src/legacy/core_plugins/console/public/quarantined/src/directives/history.html diff --git a/src/legacy/core_plugins/console/public/src/directives/sense_history.js b/src/legacy/core_plugins/console/public/quarantined/src/directives/sense_history.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/directives/sense_history.js rename to src/legacy/core_plugins/console/public/quarantined/src/directives/sense_history.js diff --git a/src/legacy/core_plugins/console/public/src/directives/sense_history_viewer.js b/src/legacy/core_plugins/console/public/quarantined/src/directives/sense_history_viewer.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/directives/sense_history_viewer.js rename to src/legacy/core_plugins/console/public/quarantined/src/directives/sense_history_viewer.js diff --git a/src/legacy/core_plugins/console/public/src/es.js b/src/legacy/core_plugins/console/public/quarantined/src/es.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/es.js rename to src/legacy/core_plugins/console/public/quarantined/src/es.js diff --git a/src/legacy/core_plugins/console/public/src/helpers/get_top_nav.ts b/src/legacy/core_plugins/console/public/quarantined/src/helpers/get_top_nav.ts similarity index 100% rename from src/legacy/core_plugins/console/public/src/helpers/get_top_nav.ts rename to src/legacy/core_plugins/console/public/quarantined/src/helpers/get_top_nav.ts diff --git a/src/legacy/core_plugins/console/public/src/helpers/help_show_panel.tsx b/src/legacy/core_plugins/console/public/quarantined/src/helpers/help_show_panel.tsx similarity index 100% rename from src/legacy/core_plugins/console/public/src/helpers/help_show_panel.tsx rename to src/legacy/core_plugins/console/public/quarantined/src/helpers/help_show_panel.tsx diff --git a/src/legacy/core_plugins/console/public/src/helpers/settings_show_modal.tsx b/src/legacy/core_plugins/console/public/quarantined/src/helpers/settings_show_modal.tsx similarity index 100% rename from src/legacy/core_plugins/console/public/src/helpers/settings_show_modal.tsx rename to src/legacy/core_plugins/console/public/quarantined/src/helpers/settings_show_modal.tsx diff --git a/src/legacy/core_plugins/console/public/src/helpers/welcome_show_panel.tsx b/src/legacy/core_plugins/console/public/quarantined/src/helpers/welcome_show_panel.tsx similarity index 100% rename from src/legacy/core_plugins/console/public/src/helpers/welcome_show_panel.tsx rename to src/legacy/core_plugins/console/public/quarantined/src/helpers/welcome_show_panel.tsx diff --git a/src/legacy/core_plugins/console/public/src/history.js b/src/legacy/core_plugins/console/public/quarantined/src/history.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/history.js rename to src/legacy/core_plugins/console/public/quarantined/src/history.js diff --git a/src/legacy/core_plugins/console/public/src/input.js b/src/legacy/core_plugins/console/public/quarantined/src/input.js similarity index 89% rename from src/legacy/core_plugins/console/public/src/input.js rename to src/legacy/core_plugins/console/public/quarantined/src/input.js index 86c2efe3a70bd..9c5400e873bf5 100644 --- a/src/legacy/core_plugins/console/public/src/input.js +++ b/src/legacy/core_plugins/console/public/quarantined/src/input.js @@ -19,7 +19,7 @@ require('brace'); require('brace/ext/searchbox'); -import Autocomplete from './autocomplete'; +import Autocomplete from './autocomplete'; import mappings from './mappings'; const SenseEditor = require('./sense_editor/editor'); const settings = require('./settings'); @@ -29,7 +29,7 @@ const history = require('./history'); import { uiModules } from 'ui/modules'; let input; -export function initializeInput($el, $actionsEl, $copyAsCurlEl, output, openDocumentation = () => {}) { +export function initializeInput($el, $actionsEl, output, openDocumentation = () => {}) { input = new SenseEditor($el); // this may not exist if running from tests @@ -47,23 +47,23 @@ export function initializeInput($el, $actionsEl, $copyAsCurlEl, output, openDocu input.commands.addCommand({ name: 'auto indent request', bindKey: { win: 'Ctrl-I', mac: 'Command-I' }, - exec: function () { + exec: () => { input.autoIndent(); - } + }, }); input.commands.addCommand({ name: 'move to previous request start or end', bindKey: { win: 'Ctrl-Up', mac: 'Command-Up' }, - exec: function () { + exec: () => { input.moveToPreviousRequestEdge(); - } + }, }); input.commands.addCommand({ name: 'move to next request start or end', bindKey: { win: 'Ctrl-Down', mac: 'Command-Down' }, - exec: function () { + exec: () => { input.moveToNextRequestEdge(); - } + }, }); /** @@ -73,10 +73,9 @@ export function initializeInput($el, $actionsEl, $copyAsCurlEl, output, openDocu let CURRENT_REQ_ID = 0; function sendCurrentRequestToES(addedToHistoryCb) { - const reqId = ++CURRENT_REQ_ID; - input.getRequestsInRange(function (requests) { + input.getRequestsInRange(requests => { if (reqId !== CURRENT_REQ_ID) { return; } @@ -87,11 +86,13 @@ export function initializeInput($el, $actionsEl, $copyAsCurlEl, output, openDocu } const isMultiRequest = requests.length > 1; - const finishChain = function () { /* noop */ }; + const finishChain = () => { + /* noop */ + }; let isFirstRequest = true; - const sendNextRequest = function () { + const sendNextRequest = () => { if (reqId !== CURRENT_REQ_ID) { return; } @@ -107,7 +108,7 @@ export function initializeInput($el, $actionsEl, $copyAsCurlEl, output, openDocu esData += '\n'; } //append a new line for bulk requests. - es.send(esMethod, esPath, esData).always(function (dataOrjqXHR, textStatus, jqXhrORerrorThrown) { + es.send(esMethod, esPath, esData).always((dataOrjqXHR, textStatus, jqXhrORerrorThrown) => { if (reqId !== CURRENT_REQ_ID) { return; } @@ -117,14 +118,14 @@ export function initializeInput($el, $actionsEl, $copyAsCurlEl, output, openDocu function modeForContentType(contentType) { if (contentType.indexOf('text/plain') >= 0) { return 'ace/mode/text'; - } - else if (contentType.indexOf('application/yaml') >= 0) { + } else if (contentType.indexOf('application/yaml') >= 0) { return 'ace/mode/yaml'; } return null; } - const isSuccess = typeof xhr.status === 'number' && + const isSuccess = + typeof xhr.status === 'number' && // Things like DELETE index where the index is not there are OK. ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 404); @@ -151,8 +152,7 @@ export function initializeInput($el, $actionsEl, $copyAsCurlEl, output, openDocu // assume json - auto pretty try { value = utils.expandLiteralStrings(value); - } - catch (e) { + } catch (e) { // nothing to do here } } @@ -168,8 +168,7 @@ export function initializeInput($el, $actionsEl, $copyAsCurlEl, output, openDocu } if (isFirstRequest) { output.update(value, mode); - } - else { + } else { output.append('\n' + value); } isFirstRequest = false; @@ -184,8 +183,7 @@ export function initializeInput($el, $actionsEl, $copyAsCurlEl, output, openDocu if (value[0] === '{') { try { value = JSON.stringify(JSON.parse(value), null, 2); - } - catch (e) { + } catch (e) { // nothing to do here } } @@ -198,8 +196,7 @@ export function initializeInput($el, $actionsEl, $copyAsCurlEl, output, openDocu } if (isFirstRequest) { output.update(value, mode); - } - else { + } else { output.append('\n' + value); } finishChain(); @@ -211,18 +208,17 @@ export function initializeInput($el, $actionsEl, $copyAsCurlEl, output, openDocu }); } - input.commands.addCommand({ name: 'send to elasticsearch', bindKey: { win: 'Ctrl-Enter', mac: 'Command-Enter' }, - exec: () => sendCurrentRequestToES() + exec: () => sendCurrentRequestToES(), }); input.commands.addCommand({ name: 'open documentation', bindKey: { win: 'Ctrl-/', mac: 'Command-/' }, exec: () => { openDocumentation(); - } + }, }); /** diff --git a/src/legacy/core_plugins/console/public/src/input_resize.js b/src/legacy/core_plugins/console/public/quarantined/src/input_resize.js similarity index 58% rename from src/legacy/core_plugins/console/public/src/input_resize.js rename to src/legacy/core_plugins/console/public/quarantined/src/input_resize.js index 1afc952f699f4..c75c5555ba068 100644 --- a/src/legacy/core_plugins/console/public/src/input_resize.js +++ b/src/legacy/core_plugins/console/public/quarantined/src/input_resize.js @@ -21,12 +21,11 @@ const $ = require('jquery'); const storage = require('./storage'); export default function (input, output) { - const $left = input.$el.parent(); - function readStoredEditorWidth() { - return storage.get('editorWidth'); - } + // function readStoredEditorWidth() { + // return storage.get('editorWidth'); + // } function storeEditorWidth(editorWidth) { storage.set('editorWidth', editorWidth); @@ -38,31 +37,29 @@ export default function (input, output) { } const $resizer = $('#ConAppResizer'); - $resizer - .on('mousedown', function (event) { - $resizer.addClass('active'); - const startWidth = $left.width(); - const startX = event.pageX; - input.resize.topRow = input.renderer.layerConfig.firstRow; - output.resize.topRow = output.renderer.layerConfig.firstRow; + $resizer.on('mousedown', function (event) { + $resizer.addClass('active'); + const startWidth = $left.width(); + const startX = event.pageX; + input.resize.topRow = input.renderer.layerConfig.firstRow; + output.resize.topRow = output.renderer.layerConfig.firstRow; - function onMove(event) { - setEditorWidth(startWidth + event.pageX - startX); - } + function onMove(event) { + setEditorWidth(startWidth + event.pageX - startX); + } - $(document.body) - .on('mousemove', onMove) - .one('mouseup', function () { - $resizer.removeClass('active'); - $(this).off('mousemove', onMove); - input.resize(); - output.resize(); - }); - }); - - const initialEditorWidth = readStoredEditorWidth(); - if (initialEditorWidth != null) { - setEditorWidth(initialEditorWidth); - } + $(document.body) + .on('mousemove', onMove) + .one('mouseup', function () { + $resizer.removeClass('active'); + $(this).off('mousemove', onMove); + input.resize(); + output.resize(); + }); + }); + // const initialEditorWidth = readStoredEditorWidth(); + // if (initialEditorWidth != null) { + // setEditorWidth(initialEditorWidth); + // } } diff --git a/src/legacy/core_plugins/console/public/src/kb.js b/src/legacy/core_plugins/console/public/quarantined/src/kb.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/kb.js rename to src/legacy/core_plugins/console/public/quarantined/src/kb.js diff --git a/src/legacy/core_plugins/console/public/src/kb/api.js b/src/legacy/core_plugins/console/public/quarantined/src/kb/api.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/kb/api.js rename to src/legacy/core_plugins/console/public/quarantined/src/kb/api.js diff --git a/src/legacy/core_plugins/console/public/src/mappings.js b/src/legacy/core_plugins/console/public/quarantined/src/mappings.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/mappings.js rename to src/legacy/core_plugins/console/public/quarantined/src/mappings.js diff --git a/src/legacy/core_plugins/console/public/src/output.js b/src/legacy/core_plugins/console/public/quarantined/src/output.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/output.js rename to src/legacy/core_plugins/console/public/quarantined/src/output.js diff --git a/src/legacy/core_plugins/console/public/src/sense_editor/editor.js b/src/legacy/core_plugins/console/public/quarantined/src/sense_editor/editor.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/sense_editor/editor.js rename to src/legacy/core_plugins/console/public/quarantined/src/sense_editor/editor.js diff --git a/src/legacy/core_plugins/console/public/src/sense_editor/mode/input.js b/src/legacy/core_plugins/console/public/quarantined/src/sense_editor/mode/input.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/sense_editor/mode/input.js rename to src/legacy/core_plugins/console/public/quarantined/src/sense_editor/mode/input.js diff --git a/src/legacy/core_plugins/console/public/src/sense_editor/mode/input_highlight_rules.js b/src/legacy/core_plugins/console/public/quarantined/src/sense_editor/mode/input_highlight_rules.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/sense_editor/mode/input_highlight_rules.js rename to src/legacy/core_plugins/console/public/quarantined/src/sense_editor/mode/input_highlight_rules.js diff --git a/src/legacy/core_plugins/console/public/src/sense_editor/mode/output.js b/src/legacy/core_plugins/console/public/quarantined/src/sense_editor/mode/output.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/sense_editor/mode/output.js rename to src/legacy/core_plugins/console/public/quarantined/src/sense_editor/mode/output.js diff --git a/src/legacy/core_plugins/console/public/src/sense_editor/mode/output_highlight_rules.js b/src/legacy/core_plugins/console/public/quarantined/src/sense_editor/mode/output_highlight_rules.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/sense_editor/mode/output_highlight_rules.js rename to src/legacy/core_plugins/console/public/quarantined/src/sense_editor/mode/output_highlight_rules.js diff --git a/src/legacy/core_plugins/console/public/src/sense_editor/mode/script.js b/src/legacy/core_plugins/console/public/quarantined/src/sense_editor/mode/script.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/sense_editor/mode/script.js rename to src/legacy/core_plugins/console/public/quarantined/src/sense_editor/mode/script.js diff --git a/src/legacy/core_plugins/console/public/src/sense_editor/mode/script_highlight_rules.js b/src/legacy/core_plugins/console/public/quarantined/src/sense_editor/mode/script_highlight_rules.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/sense_editor/mode/script_highlight_rules.js rename to src/legacy/core_plugins/console/public/quarantined/src/sense_editor/mode/script_highlight_rules.js diff --git a/src/legacy/core_plugins/console/public/src/sense_editor/mode/worker/index.js b/src/legacy/core_plugins/console/public/quarantined/src/sense_editor/mode/worker/index.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/sense_editor/mode/worker/index.js rename to src/legacy/core_plugins/console/public/quarantined/src/sense_editor/mode/worker/index.js diff --git a/src/legacy/core_plugins/console/public/src/sense_editor/mode/worker/worker.js b/src/legacy/core_plugins/console/public/quarantined/src/sense_editor/mode/worker/worker.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/sense_editor/mode/worker/worker.js rename to src/legacy/core_plugins/console/public/quarantined/src/sense_editor/mode/worker/worker.js diff --git a/src/legacy/core_plugins/console/public/src/sense_editor/mode/x_json_highlight_rules.js b/src/legacy/core_plugins/console/public/quarantined/src/sense_editor/mode/x_json_highlight_rules.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/sense_editor/mode/x_json_highlight_rules.js rename to src/legacy/core_plugins/console/public/quarantined/src/sense_editor/mode/x_json_highlight_rules.js diff --git a/src/legacy/core_plugins/console/public/src/sense_editor/row_parser.js b/src/legacy/core_plugins/console/public/quarantined/src/sense_editor/row_parser.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/sense_editor/row_parser.js rename to src/legacy/core_plugins/console/public/quarantined/src/sense_editor/row_parser.js diff --git a/src/legacy/core_plugins/console/public/src/sense_editor/theme-sense-dark.js b/src/legacy/core_plugins/console/public/quarantined/src/sense_editor/theme_sense_dark.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/sense_editor/theme-sense-dark.js rename to src/legacy/core_plugins/console/public/quarantined/src/sense_editor/theme_sense_dark.js diff --git a/src/legacy/core_plugins/console/public/src/sense_editor_resize.js b/src/legacy/core_plugins/console/public/quarantined/src/sense_editor_resize.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/sense_editor_resize.js rename to src/legacy/core_plugins/console/public/quarantined/src/sense_editor_resize.js diff --git a/src/legacy/core_plugins/console/public/src/settings.js b/src/legacy/core_plugins/console/public/quarantined/src/settings.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/settings.js rename to src/legacy/core_plugins/console/public/quarantined/src/settings.js diff --git a/src/legacy/core_plugins/console/public/src/smart_resize.js b/src/legacy/core_plugins/console/public/quarantined/src/smart_resize.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/smart_resize.js rename to src/legacy/core_plugins/console/public/quarantined/src/smart_resize.js index 2cae2d7f17615..8ac5eda345c23 100644 --- a/src/legacy/core_plugins/console/public/src/smart_resize.js +++ b/src/legacy/core_plugins/console/public/quarantined/src/smart_resize.js @@ -21,8 +21,8 @@ import { get, throttle } from 'lodash'; export default function (editor) { const resize = editor.resize; - const throttledResize = throttle(() => { + const throttledResize = throttle(() => { resize.call(editor); // Keep current top line in view when resizing to avoid losing user context diff --git a/src/legacy/core_plugins/console/public/src/storage.js b/src/legacy/core_plugins/console/public/quarantined/src/storage.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/storage.js rename to src/legacy/core_plugins/console/public/quarantined/src/storage.js diff --git a/src/legacy/core_plugins/console/public/src/utils.js b/src/legacy/core_plugins/console/public/quarantined/src/utils.js similarity index 100% rename from src/legacy/core_plugins/console/public/src/utils.js rename to src/legacy/core_plugins/console/public/quarantined/src/utils.js diff --git a/src/legacy/core_plugins/console/public/tests/src/content_type.test.js b/src/legacy/core_plugins/console/public/quarantined/tests/src/content_type.test.js similarity index 100% rename from src/legacy/core_plugins/console/public/tests/src/content_type.test.js rename to src/legacy/core_plugins/console/public/quarantined/tests/src/content_type.test.js diff --git a/src/legacy/core_plugins/console/public/tests/src/curl_parsing.test.js b/src/legacy/core_plugins/console/public/quarantined/tests/src/curl_parsing.test.js similarity index 100% rename from src/legacy/core_plugins/console/public/tests/src/curl_parsing.test.js rename to src/legacy/core_plugins/console/public/quarantined/tests/src/curl_parsing.test.js diff --git a/src/legacy/core_plugins/console/public/tests/src/curl_parsing.txt b/src/legacy/core_plugins/console/public/quarantined/tests/src/curl_parsing.txt similarity index 100% rename from src/legacy/core_plugins/console/public/tests/src/curl_parsing.txt rename to src/legacy/core_plugins/console/public/quarantined/tests/src/curl_parsing.txt diff --git a/src/legacy/core_plugins/console/public/tests/src/editor.test.js b/src/legacy/core_plugins/console/public/quarantined/tests/src/editor.test.js similarity index 100% rename from src/legacy/core_plugins/console/public/tests/src/editor.test.js rename to src/legacy/core_plugins/console/public/quarantined/tests/src/editor.test.js diff --git a/src/legacy/core_plugins/console/public/tests/src/editor_input1.txt b/src/legacy/core_plugins/console/public/quarantined/tests/src/editor_input1.txt similarity index 100% rename from src/legacy/core_plugins/console/public/tests/src/editor_input1.txt rename to src/legacy/core_plugins/console/public/quarantined/tests/src/editor_input1.txt diff --git a/src/legacy/core_plugins/console/public/tests/src/input_tokenization.test.js b/src/legacy/core_plugins/console/public/quarantined/tests/src/input_tokenization.test.js similarity index 100% rename from src/legacy/core_plugins/console/public/tests/src/input_tokenization.test.js rename to src/legacy/core_plugins/console/public/quarantined/tests/src/input_tokenization.test.js diff --git a/src/legacy/core_plugins/console/public/tests/src/integration.test.js b/src/legacy/core_plugins/console/public/quarantined/tests/src/integration.test.js similarity index 100% rename from src/legacy/core_plugins/console/public/tests/src/integration.test.js rename to src/legacy/core_plugins/console/public/quarantined/tests/src/integration.test.js diff --git a/src/legacy/core_plugins/console/public/tests/src/kb.test.js b/src/legacy/core_plugins/console/public/quarantined/tests/src/kb.test.js similarity index 100% rename from src/legacy/core_plugins/console/public/tests/src/kb.test.js rename to src/legacy/core_plugins/console/public/quarantined/tests/src/kb.test.js diff --git a/src/legacy/core_plugins/console/public/tests/src/mapping.test.js b/src/legacy/core_plugins/console/public/quarantined/tests/src/mapping.test.js similarity index 100% rename from src/legacy/core_plugins/console/public/tests/src/mapping.test.js rename to src/legacy/core_plugins/console/public/quarantined/tests/src/mapping.test.js diff --git a/src/legacy/core_plugins/console/public/tests/src/output_tokenization.test.js b/src/legacy/core_plugins/console/public/quarantined/tests/src/output_tokenization.test.js similarity index 100% rename from src/legacy/core_plugins/console/public/tests/src/output_tokenization.test.js rename to src/legacy/core_plugins/console/public/quarantined/tests/src/output_tokenization.test.js diff --git a/src/legacy/core_plugins/console/public/tests/src/setup_mocks.js b/src/legacy/core_plugins/console/public/quarantined/tests/src/setup_mocks.js similarity index 100% rename from src/legacy/core_plugins/console/public/tests/src/setup_mocks.js rename to src/legacy/core_plugins/console/public/quarantined/tests/src/setup_mocks.js diff --git a/src/legacy/core_plugins/console/public/tests/src/url_autocomplete.test.js b/src/legacy/core_plugins/console/public/quarantined/tests/src/url_autocomplete.test.js similarity index 100% rename from src/legacy/core_plugins/console/public/tests/src/url_autocomplete.test.js rename to src/legacy/core_plugins/console/public/quarantined/tests/src/url_autocomplete.test.js diff --git a/src/legacy/core_plugins/console/public/tests/src/url_params.test.js b/src/legacy/core_plugins/console/public/quarantined/tests/src/url_params.test.js similarity index 100% rename from src/legacy/core_plugins/console/public/tests/src/url_params.test.js rename to src/legacy/core_plugins/console/public/quarantined/tests/src/url_params.test.js diff --git a/src/legacy/core_plugins/console/public/tests/src/utils.test.js b/src/legacy/core_plugins/console/public/quarantined/tests/src/utils.test.js similarity index 100% rename from src/legacy/core_plugins/console/public/tests/src/utils.test.js rename to src/legacy/core_plugins/console/public/quarantined/tests/src/utils.test.js diff --git a/src/legacy/core_plugins/console/public/tests/src/utils_string_collapsing.txt b/src/legacy/core_plugins/console/public/quarantined/tests/src/utils_string_collapsing.txt similarity index 100% rename from src/legacy/core_plugins/console/public/tests/src/utils_string_collapsing.txt rename to src/legacy/core_plugins/console/public/quarantined/tests/src/utils_string_collapsing.txt diff --git a/src/legacy/core_plugins/console/public/tests/src/utils_string_expanding.txt b/src/legacy/core_plugins/console/public/quarantined/tests/src/utils_string_expanding.txt similarity index 100% rename from src/legacy/core_plugins/console/public/tests/src/utils_string_expanding.txt rename to src/legacy/core_plugins/console/public/quarantined/tests/src/utils_string_expanding.txt diff --git a/src/legacy/core_plugins/console/api_server/api.js b/src/legacy/core_plugins/console/server/api_server/api.js similarity index 100% rename from src/legacy/core_plugins/console/api_server/api.js rename to src/legacy/core_plugins/console/server/api_server/api.js diff --git a/src/legacy/core_plugins/console/api_server/es_6_0.js b/src/legacy/core_plugins/console/server/api_server/es_6_0.js similarity index 100% rename from src/legacy/core_plugins/console/api_server/es_6_0.js rename to src/legacy/core_plugins/console/server/api_server/es_6_0.js diff --git a/src/legacy/core_plugins/console/api_server/es_6_0/aggregations.js b/src/legacy/core_plugins/console/server/api_server/es_6_0/aggregations.js similarity index 100% rename from src/legacy/core_plugins/console/api_server/es_6_0/aggregations.js rename to src/legacy/core_plugins/console/server/api_server/es_6_0/aggregations.js diff --git a/src/legacy/core_plugins/console/api_server/es_6_0/aliases.js b/src/legacy/core_plugins/console/server/api_server/es_6_0/aliases.js similarity index 100% rename from src/legacy/core_plugins/console/api_server/es_6_0/aliases.js rename to src/legacy/core_plugins/console/server/api_server/es_6_0/aliases.js diff --git a/src/legacy/core_plugins/console/api_server/es_6_0/document.js b/src/legacy/core_plugins/console/server/api_server/es_6_0/document.js similarity index 100% rename from src/legacy/core_plugins/console/api_server/es_6_0/document.js rename to src/legacy/core_plugins/console/server/api_server/es_6_0/document.js diff --git a/src/legacy/core_plugins/console/api_server/es_6_0/filter.js b/src/legacy/core_plugins/console/server/api_server/es_6_0/filter.js similarity index 100% rename from src/legacy/core_plugins/console/api_server/es_6_0/filter.js rename to src/legacy/core_plugins/console/server/api_server/es_6_0/filter.js diff --git a/src/legacy/core_plugins/console/api_server/es_6_0/globals.js b/src/legacy/core_plugins/console/server/api_server/es_6_0/globals.js similarity index 100% rename from src/legacy/core_plugins/console/api_server/es_6_0/globals.js rename to src/legacy/core_plugins/console/server/api_server/es_6_0/globals.js diff --git a/src/legacy/core_plugins/console/api_server/es_6_0/ingest.js b/src/legacy/core_plugins/console/server/api_server/es_6_0/ingest.js similarity index 100% rename from src/legacy/core_plugins/console/api_server/es_6_0/ingest.js rename to src/legacy/core_plugins/console/server/api_server/es_6_0/ingest.js diff --git a/src/legacy/core_plugins/console/api_server/es_6_0/mappings.js b/src/legacy/core_plugins/console/server/api_server/es_6_0/mappings.js similarity index 100% rename from src/legacy/core_plugins/console/api_server/es_6_0/mappings.js rename to src/legacy/core_plugins/console/server/api_server/es_6_0/mappings.js diff --git a/src/legacy/core_plugins/console/api_server/es_6_0/query/dsl.js b/src/legacy/core_plugins/console/server/api_server/es_6_0/query/dsl.js similarity index 100% rename from src/legacy/core_plugins/console/api_server/es_6_0/query/dsl.js rename to src/legacy/core_plugins/console/server/api_server/es_6_0/query/dsl.js diff --git a/src/legacy/core_plugins/console/api_server/es_6_0/query/index.js b/src/legacy/core_plugins/console/server/api_server/es_6_0/query/index.js similarity index 100% rename from src/legacy/core_plugins/console/api_server/es_6_0/query/index.js rename to src/legacy/core_plugins/console/server/api_server/es_6_0/query/index.js diff --git a/src/legacy/core_plugins/console/api_server/es_6_0/query/templates.js b/src/legacy/core_plugins/console/server/api_server/es_6_0/query/templates.js similarity index 100% rename from src/legacy/core_plugins/console/api_server/es_6_0/query/templates.js rename to src/legacy/core_plugins/console/server/api_server/es_6_0/query/templates.js diff --git a/src/legacy/core_plugins/console/api_server/es_6_0/reindex.js b/src/legacy/core_plugins/console/server/api_server/es_6_0/reindex.js similarity index 100% rename from src/legacy/core_plugins/console/api_server/es_6_0/reindex.js rename to src/legacy/core_plugins/console/server/api_server/es_6_0/reindex.js diff --git a/src/legacy/core_plugins/console/api_server/es_6_0/search.js b/src/legacy/core_plugins/console/server/api_server/es_6_0/search.js similarity index 100% rename from src/legacy/core_plugins/console/api_server/es_6_0/search.js rename to src/legacy/core_plugins/console/server/api_server/es_6_0/search.js diff --git a/src/legacy/core_plugins/console/api_server/server.js b/src/legacy/core_plugins/console/server/api_server/server.js similarity index 100% rename from src/legacy/core_plugins/console/api_server/server.js rename to src/legacy/core_plugins/console/server/api_server/server.js diff --git a/src/legacy/core_plugins/console/api_server/server.test.js b/src/legacy/core_plugins/console/server/api_server/server.test.js similarity index 100% rename from src/legacy/core_plugins/console/api_server/server.test.js rename to src/legacy/core_plugins/console/server/api_server/server.test.js diff --git a/src/legacy/core_plugins/console/api_server/spec/.eslintrc b/src/legacy/core_plugins/console/server/api_server/spec/.eslintrc similarity index 92% rename from src/legacy/core_plugins/console/api_server/spec/.eslintrc rename to src/legacy/core_plugins/console/server/api_server/spec/.eslintrc index b302d39e1dfd1..46052f0e19a0d 100644 --- a/src/legacy/core_plugins/console/api_server/spec/.eslintrc +++ b/src/legacy/core_plugins/console/server/api_server/spec/.eslintrc @@ -1,7 +1,7 @@ --- root: true -extends: '../../../../../../.eslintrc.js' +extends: '../../../../../../../.eslintrc.js' rules: block-scoped-var: off diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/_common.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/_common.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/_common.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/_common.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/bulk.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/bulk.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/bulk.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/bulk.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/cat.aliases.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/cat.aliases.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/cat.aliases.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/cat.aliases.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/cat.allocation.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/cat.allocation.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/cat.allocation.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/cat.allocation.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/cat.count.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/cat.count.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/cat.count.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/cat.count.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/cat.fielddata.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/cat.fielddata.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/cat.fielddata.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/cat.fielddata.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/cat.health.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/cat.health.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/cat.health.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/cat.health.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/cat.help.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/cat.help.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/cat.help.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/cat.help.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/cat.indices.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/cat.indices.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/cat.indices.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/cat.indices.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/cat.master.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/cat.master.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/cat.master.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/cat.master.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/cat.nodeattrs.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/cat.nodeattrs.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/cat.nodeattrs.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/cat.nodeattrs.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/cat.nodes.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/cat.nodes.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/cat.nodes.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/cat.nodes.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/cat.pending_tasks.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/cat.pending_tasks.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/cat.pending_tasks.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/cat.pending_tasks.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/cat.plugins.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/cat.plugins.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/cat.plugins.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/cat.plugins.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/cat.recovery.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/cat.recovery.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/cat.recovery.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/cat.recovery.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/cat.repositories.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/cat.repositories.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/cat.repositories.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/cat.repositories.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/cat.segments.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/cat.segments.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/cat.segments.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/cat.segments.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/cat.shards.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/cat.shards.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/cat.shards.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/cat.shards.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/cat.snapshots.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/cat.snapshots.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/cat.snapshots.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/cat.snapshots.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/cat.tasks.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/cat.tasks.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/cat.tasks.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/cat.tasks.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/cat.templates.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/cat.templates.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/cat.templates.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/cat.templates.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/cat.thread_pool.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/cat.thread_pool.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/cat.thread_pool.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/cat.thread_pool.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/clear_scroll.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/clear_scroll.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/clear_scroll.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/clear_scroll.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/cluster.allocation_explain.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/cluster.allocation_explain.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/cluster.allocation_explain.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/cluster.allocation_explain.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/cluster.get_settings.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/cluster.get_settings.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/cluster.get_settings.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/cluster.get_settings.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/cluster.health.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/cluster.health.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/cluster.health.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/cluster.health.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/cluster.pending_tasks.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/cluster.pending_tasks.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/cluster.pending_tasks.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/cluster.pending_tasks.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/cluster.put_settings.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/cluster.put_settings.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/cluster.put_settings.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/cluster.put_settings.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/cluster.remote_info.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/cluster.remote_info.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/cluster.remote_info.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/cluster.remote_info.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/cluster.reroute.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/cluster.reroute.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/cluster.reroute.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/cluster.reroute.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/cluster.state.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/cluster.state.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/cluster.state.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/cluster.state.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/cluster.stats.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/cluster.stats.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/cluster.stats.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/cluster.stats.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/count.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/count.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/count.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/count.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/create.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/create.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/create.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/create.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/delete.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/delete.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/delete.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/delete.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/delete_by_query.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/delete_by_query.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/delete_by_query.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/delete_by_query.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/delete_by_query_rethrottle.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/delete_by_query_rethrottle.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/delete_by_query_rethrottle.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/delete_by_query_rethrottle.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/delete_script.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/delete_script.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/delete_script.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/delete_script.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/exists.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/exists.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/exists.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/exists.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/exists_source.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/exists_source.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/exists_source.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/exists_source.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/explain.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/explain.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/explain.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/explain.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/field_caps.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/field_caps.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/field_caps.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/field_caps.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/get.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/get.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/get.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/get.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/get_script.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/get_script.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/get_script.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/get_script.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/get_source.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/get_source.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/get_source.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/get_source.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/index.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/index.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/index.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/index.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.analyze.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.analyze.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.analyze.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.analyze.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.clear_cache.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.clear_cache.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.clear_cache.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.clear_cache.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.close.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.close.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.close.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.close.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.create.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.create.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.create.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.create.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.delete.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.delete.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.delete.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.delete.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.delete_alias.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.delete_alias.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.delete_alias.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.delete_alias.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.delete_template.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.delete_template.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.delete_template.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.delete_template.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.exists.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.exists.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.exists.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.exists.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.exists_alias.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.exists_alias.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.exists_alias.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.exists_alias.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.exists_template.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.exists_template.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.exists_template.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.exists_template.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.exists_type.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.exists_type.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.exists_type.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.exists_type.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.flush.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.flush.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.flush.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.flush.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.flush_synced.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.flush_synced.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.flush_synced.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.flush_synced.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.forcemerge.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.forcemerge.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.forcemerge.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.forcemerge.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.get.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.get.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.get.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.get.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.get_alias.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.get_alias.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.get_alias.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.get_alias.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.get_field_mapping.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.get_field_mapping.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.get_field_mapping.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.get_field_mapping.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.get_mapping.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.get_mapping.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.get_mapping.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.get_mapping.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.get_settings.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.get_settings.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.get_settings.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.get_settings.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.get_template.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.get_template.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.get_template.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.get_template.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.get_upgrade.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.get_upgrade.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.get_upgrade.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.get_upgrade.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.open.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.open.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.open.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.open.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.put_alias.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.put_alias.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.put_alias.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.put_alias.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.put_mapping.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.put_mapping.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.put_mapping.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.put_mapping.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.put_settings.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.put_settings.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.put_settings.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.put_settings.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.put_template.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.put_template.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.put_template.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.put_template.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.recovery.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.recovery.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.recovery.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.recovery.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.refresh.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.refresh.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.refresh.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.refresh.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.rollover.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.rollover.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.rollover.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.rollover.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.segments.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.segments.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.segments.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.segments.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.shard_stores.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.shard_stores.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.shard_stores.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.shard_stores.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.shrink.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.shrink.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.shrink.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.shrink.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.split.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.split.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.split.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.split.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.stats.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.stats.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.stats.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.stats.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.update_aliases.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.update_aliases.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.update_aliases.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.update_aliases.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.upgrade.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.upgrade.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.upgrade.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.upgrade.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.validate_query.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.validate_query.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.validate_query.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.validate_query.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/info.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/info.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/info.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/info.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/ingest.delete_pipeline.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/ingest.delete_pipeline.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/ingest.delete_pipeline.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/ingest.delete_pipeline.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/ingest.get_pipeline.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/ingest.get_pipeline.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/ingest.get_pipeline.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/ingest.get_pipeline.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/ingest.processor_grok.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/ingest.processor_grok.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/ingest.processor_grok.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/ingest.processor_grok.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/ingest.put_pipeline.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/ingest.put_pipeline.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/ingest.put_pipeline.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/ingest.put_pipeline.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/ingest.simulate.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/ingest.simulate.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/ingest.simulate.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/ingest.simulate.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/mget.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/mget.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/mget.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/mget.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/msearch.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/msearch.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/msearch.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/msearch.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/msearch_template.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/msearch_template.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/msearch_template.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/msearch_template.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/mtermvectors.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/mtermvectors.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/mtermvectors.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/mtermvectors.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/nodes.hot_threads.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/nodes.hot_threads.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/nodes.hot_threads.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/nodes.hot_threads.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/nodes.info.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/nodes.info.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/nodes.info.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/nodes.info.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/nodes.reload_secure_settings.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/nodes.reload_secure_settings.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/nodes.reload_secure_settings.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/nodes.reload_secure_settings.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/nodes.stats.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/nodes.stats.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/nodes.stats.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/nodes.stats.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/nodes.usage.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/nodes.usage.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/nodes.usage.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/nodes.usage.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/ping.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/ping.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/ping.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/ping.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/put_script.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/put_script.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/put_script.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/put_script.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/rank_eval.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/rank_eval.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/rank_eval.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/rank_eval.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/reindex.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/reindex.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/reindex.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/reindex.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/reindex_rethrottle.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/reindex_rethrottle.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/reindex_rethrottle.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/reindex_rethrottle.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/render_search_template.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/render_search_template.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/render_search_template.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/render_search_template.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/scripts_painless_execute.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/scripts_painless_execute.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/scripts_painless_execute.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/scripts_painless_execute.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/scroll.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/scroll.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/scroll.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/scroll.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/search.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/search.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/search.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/search.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/search_shards.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/search_shards.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/search_shards.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/search_shards.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/search_template.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/search_template.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/search_template.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/search_template.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/snapshot.create.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/snapshot.create.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/snapshot.create.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/snapshot.create.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/snapshot.create_repository.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/snapshot.create_repository.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/snapshot.create_repository.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/snapshot.create_repository.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/snapshot.delete.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/snapshot.delete.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/snapshot.delete.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/snapshot.delete.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/snapshot.delete_repository.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/snapshot.delete_repository.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/snapshot.delete_repository.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/snapshot.delete_repository.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/snapshot.get.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/snapshot.get.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/snapshot.get.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/snapshot.get.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/snapshot.get_repository.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/snapshot.get_repository.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/snapshot.get_repository.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/snapshot.get_repository.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/snapshot.restore.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/snapshot.restore.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/snapshot.restore.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/snapshot.restore.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/snapshot.status.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/snapshot.status.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/snapshot.status.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/snapshot.status.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/snapshot.verify_repository.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/snapshot.verify_repository.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/snapshot.verify_repository.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/snapshot.verify_repository.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/tasks.cancel.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/tasks.cancel.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/tasks.cancel.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/tasks.cancel.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/tasks.get.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/tasks.get.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/tasks.get.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/tasks.get.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/tasks.list.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/tasks.list.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/tasks.list.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/tasks.list.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/termvectors.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/termvectors.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/termvectors.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/termvectors.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/update.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/update.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/update.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/update.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/update_by_query.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/update_by_query.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/update_by_query.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/update_by_query.json diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/update_by_query_rethrottle.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/update_by_query_rethrottle.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/update_by_query_rethrottle.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/update_by_query_rethrottle.json diff --git a/src/legacy/core_plugins/console/api_server/spec/index.js b/src/legacy/core_plugins/console/server/api_server/spec/index.js similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/index.js rename to src/legacy/core_plugins/console/server/api_server/spec/index.js diff --git a/src/legacy/core_plugins/console/api_server/spec/overrides/cluster.health.json b/src/legacy/core_plugins/console/server/api_server/spec/overrides/cluster.health.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/overrides/cluster.health.json rename to src/legacy/core_plugins/console/server/api_server/spec/overrides/cluster.health.json diff --git a/src/legacy/core_plugins/console/api_server/spec/overrides/cluster.put_settings.json b/src/legacy/core_plugins/console/server/api_server/spec/overrides/cluster.put_settings.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/overrides/cluster.put_settings.json rename to src/legacy/core_plugins/console/server/api_server/spec/overrides/cluster.put_settings.json diff --git a/src/legacy/core_plugins/console/api_server/spec/overrides/cluster.reroute.json b/src/legacy/core_plugins/console/server/api_server/spec/overrides/cluster.reroute.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/overrides/cluster.reroute.json rename to src/legacy/core_plugins/console/server/api_server/spec/overrides/cluster.reroute.json diff --git a/src/legacy/core_plugins/console/api_server/spec/overrides/count.json b/src/legacy/core_plugins/console/server/api_server/spec/overrides/count.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/overrides/count.json rename to src/legacy/core_plugins/console/server/api_server/spec/overrides/count.json diff --git a/src/legacy/core_plugins/console/api_server/spec/overrides/create.json b/src/legacy/core_plugins/console/server/api_server/spec/overrides/create.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/overrides/create.json rename to src/legacy/core_plugins/console/server/api_server/spec/overrides/create.json diff --git a/src/legacy/core_plugins/console/api_server/spec/overrides/indices.analyze.json b/src/legacy/core_plugins/console/server/api_server/spec/overrides/indices.analyze.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/overrides/indices.analyze.json rename to src/legacy/core_plugins/console/server/api_server/spec/overrides/indices.analyze.json diff --git a/src/legacy/core_plugins/console/api_server/spec/overrides/indices.create.json b/src/legacy/core_plugins/console/server/api_server/spec/overrides/indices.create.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/overrides/indices.create.json rename to src/legacy/core_plugins/console/server/api_server/spec/overrides/indices.create.json diff --git a/src/legacy/core_plugins/console/api_server/spec/overrides/indices.delete_template.json b/src/legacy/core_plugins/console/server/api_server/spec/overrides/indices.delete_template.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/overrides/indices.delete_template.json rename to src/legacy/core_plugins/console/server/api_server/spec/overrides/indices.delete_template.json diff --git a/src/legacy/core_plugins/console/api_server/spec/overrides/indices.exists_template.json b/src/legacy/core_plugins/console/server/api_server/spec/overrides/indices.exists_template.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/overrides/indices.exists_template.json rename to src/legacy/core_plugins/console/server/api_server/spec/overrides/indices.exists_template.json diff --git a/src/legacy/core_plugins/console/api_server/spec/overrides/indices.get_field_mapping.json b/src/legacy/core_plugins/console/server/api_server/spec/overrides/indices.get_field_mapping.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/overrides/indices.get_field_mapping.json rename to src/legacy/core_plugins/console/server/api_server/spec/overrides/indices.get_field_mapping.json diff --git a/src/legacy/core_plugins/console/api_server/spec/overrides/indices.get_mapping.json b/src/legacy/core_plugins/console/server/api_server/spec/overrides/indices.get_mapping.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/overrides/indices.get_mapping.json rename to src/legacy/core_plugins/console/server/api_server/spec/overrides/indices.get_mapping.json diff --git a/src/legacy/core_plugins/console/api_server/spec/overrides/indices.get_template.json b/src/legacy/core_plugins/console/server/api_server/spec/overrides/indices.get_template.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/overrides/indices.get_template.json rename to src/legacy/core_plugins/console/server/api_server/spec/overrides/indices.get_template.json diff --git a/src/legacy/core_plugins/console/api_server/spec/overrides/indices.put_alias.json b/src/legacy/core_plugins/console/server/api_server/spec/overrides/indices.put_alias.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/overrides/indices.put_alias.json rename to src/legacy/core_plugins/console/server/api_server/spec/overrides/indices.put_alias.json diff --git a/src/legacy/core_plugins/console/api_server/spec/overrides/indices.put_settings.json b/src/legacy/core_plugins/console/server/api_server/spec/overrides/indices.put_settings.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/overrides/indices.put_settings.json rename to src/legacy/core_plugins/console/server/api_server/spec/overrides/indices.put_settings.json diff --git a/src/legacy/core_plugins/console/api_server/spec/overrides/indices.put_template.json b/src/legacy/core_plugins/console/server/api_server/spec/overrides/indices.put_template.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/overrides/indices.put_template.json rename to src/legacy/core_plugins/console/server/api_server/spec/overrides/indices.put_template.json diff --git a/src/legacy/core_plugins/console/api_server/spec/overrides/indices.rollover.json b/src/legacy/core_plugins/console/server/api_server/spec/overrides/indices.rollover.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/overrides/indices.rollover.json rename to src/legacy/core_plugins/console/server/api_server/spec/overrides/indices.rollover.json diff --git a/src/legacy/core_plugins/console/api_server/spec/overrides/indices.update_aliases.json b/src/legacy/core_plugins/console/server/api_server/spec/overrides/indices.update_aliases.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/overrides/indices.update_aliases.json rename to src/legacy/core_plugins/console/server/api_server/spec/overrides/indices.update_aliases.json diff --git a/src/legacy/core_plugins/console/api_server/spec/overrides/indices.validate_query.json b/src/legacy/core_plugins/console/server/api_server/spec/overrides/indices.validate_query.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/overrides/indices.validate_query.json rename to src/legacy/core_plugins/console/server/api_server/spec/overrides/indices.validate_query.json diff --git a/src/legacy/core_plugins/console/api_server/spec/overrides/snapshot.create.json b/src/legacy/core_plugins/console/server/api_server/spec/overrides/snapshot.create.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/overrides/snapshot.create.json rename to src/legacy/core_plugins/console/server/api_server/spec/overrides/snapshot.create.json diff --git a/src/legacy/core_plugins/console/api_server/spec/overrides/snapshot.create_repository.json b/src/legacy/core_plugins/console/server/api_server/spec/overrides/snapshot.create_repository.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/overrides/snapshot.create_repository.json rename to src/legacy/core_plugins/console/server/api_server/spec/overrides/snapshot.create_repository.json diff --git a/src/legacy/core_plugins/console/api_server/spec/overrides/snapshot.restore.json b/src/legacy/core_plugins/console/server/api_server/spec/overrides/snapshot.restore.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/overrides/snapshot.restore.json rename to src/legacy/core_plugins/console/server/api_server/spec/overrides/snapshot.restore.json From a6c404559813350c240381dcc4332aaa4d3da542 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Wed, 28 Aug 2019 11:49:39 +0200 Subject: [PATCH 02/35] First refactor of kbn ace keyboard mode to TS+React --- .../app/containers/editor/legacy/index.tsx | 6 + .../legacy/use_ui_ace_keyboard_mode.tsx | 111 ++++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.tsx index 414eecd6edc5f..a580ce235df30 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.tsx +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.tsx @@ -34,6 +34,8 @@ import init from '../../../../../../quarantined/src/app'; import { autoIndent, getDocumentation } from './console_menu_actions'; import { Panel, PanelContainer } from '../../../components/split_panel'; +import { useUIAceKeyboardMode } from './use_ui_ace_keyboard_mode'; + const PANEL_MIN_WIDTH = '100px'; const abs: CSSProperties = { @@ -64,6 +66,7 @@ export function ConsoleEditor({ const [, setLastRequestTimestamp] = useState(null as any); const [editor, setEditor] = useState(null as any); const [, setOutput] = useState(null as any); + const [maybeTextArea, setTextArea] = useState(null); const sendCurrentRequest = () => { editor.focus(); @@ -90,10 +93,13 @@ export function ConsoleEditor({ getDocumentation(inputEditor, docLinkVersion); }); + setTextArea(editorRef.current!.querySelector('textarea')); setOutput(outputEditor); setEditor(inputEditor); }, []); + useUIAceKeyboardMode(maybeTextArea); + return ( void; + onKeyDown: (ev: React.KeyboardEvent) => void; +}) => ( + // The point of this element is for accessibility purposes, so ignore eslint error + // in this case + // + // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions +
    +

    Press Enter to start editing.

    +

    + When you’re done, press Escape to stop editing. +

    +
    +); + +export function useUIAceKeyboardMode(aceTextAreaElement: HTMLTextAreaElement | null) { + const textArea = useRef(null); + const mountNode = useRef(null); + const [isAutoCompleteOpen, setAutoCompleteOpen] = useState(false); + + function onDismissOverlay(ev: React.KeyboardEvent) { + if (ev.keyCode === keyCodes.ENTER) { + ev.preventDefault(); + unmountComponentAtNode(mountNode.current!); + textArea.current!.focus(); + } + } + + function enableOverlay() { + render( + ref && ref.focus()} />, + mountNode.current! + ); + } + + const autoCompleteOpenListener = () => { + const autoCompleter = document.querySelector('.ace_autocomplete'); + + if (!autoCompleter) { + setAutoCompleteOpen(false); + return; + } + + // The autoComplete is just hidden when it's closed, not removed from the DOM. + setAutoCompleteOpen(autoCompleter.style.display !== 'none'); + }; + + const aceTextBoxListener = (ev: KeyboardEvent) => { + if (ev.keyCode === keyCodes.ESCAPE) { + // If the autocompletion context menu is open then we want to let ESC close it but + // **not** exit out of editing mode. + if (!isAutoCompleteOpen) { + ev.preventDefault(); + ev.stopPropagation(); + enableOverlay(); + } + } + }; + + useEffect(() => { + if (aceTextAreaElement) { + const container = document.createElement('div'); + aceTextAreaElement.parentElement!.insertBefore(container, aceTextAreaElement); + + mountNode.current = container; + textArea.current = aceTextAreaElement; + + document.addEventListener('keydown', autoCompleteOpenListener, { capture: true }); + textArea.current.addEventListener('keydown', aceTextBoxListener); + } + return () => { + if (aceTextAreaElement) { + aceTextAreaElement.removeEventListener('keydown', aceTextBoxListener); + document.removeEventListener('keydown', autoCompleteOpenListener); + document.removeChild(mountNode.current!); + } + }; + }, [aceTextAreaElement]); +} From bc36ca00a7055afe4630c94ff1558e7eba8c1daa Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Wed, 28 Aug 2019 11:55:36 +0200 Subject: [PATCH 03/35] clean up unused props --- .../np_ready/public/app/containers/editor/legacy/index.tsx | 1 - .../console/public/quarantined/src/components/console_menu.js | 1 - 2 files changed, 2 deletions(-) diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.tsx index a580ce235df30..424b7234438eb 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.tsx +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.tsx @@ -127,7 +127,6 @@ export function ConsoleEditor({ getCurl={(cb: any) => { editor.getRequestsAsCURL(cb); }} - openDocumentation={() => {}} getDocumentation={() => { return getDocumentation(editor, docLinkVersion); }} diff --git a/src/legacy/core_plugins/console/public/quarantined/src/components/console_menu.js b/src/legacy/core_plugins/console/public/quarantined/src/components/console_menu.js index 07a3e57dd7ee7..8d58d50ba2d0b 100644 --- a/src/legacy/core_plugins/console/public/quarantined/src/components/console_menu.js +++ b/src/legacy/core_plugins/console/public/quarantined/src/components/console_menu.js @@ -149,7 +149,6 @@ export class ConsoleMenu extends Component { ConsoleMenu.propTypes = { getCurl: PropTypes.func.isRequired, - openDocumentation: PropTypes.func.isRequired, getDocumentation: PropTypes.func.isRequired, autoIndent: PropTypes.func.isRequired, }; From 8983ae81d9849f73e2bf72d153b0d6433aff8f57 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Wed, 28 Aug 2019 13:38:49 +0200 Subject: [PATCH 04/35] console_menu.js -> console_menu.tsx --- .../public/app/components/console_menu.tsx} | 40 ++++++++++--------- .../app/containers/editor/legacy/index.tsx | 4 +- 2 files changed, 24 insertions(+), 20 deletions(-) rename src/legacy/core_plugins/console/public/{quarantined/src/components/console_menu.js => np_ready/public/app/components/console_menu.tsx} (84%) diff --git a/src/legacy/core_plugins/console/public/quarantined/src/components/console_menu.js b/src/legacy/core_plugins/console/public/np_ready/public/app/components/console_menu.tsx similarity index 84% rename from src/legacy/core_plugins/console/public/quarantined/src/components/console_menu.js rename to src/legacy/core_plugins/console/public/np_ready/public/app/components/console_menu.tsx index 8d58d50ba2d0b..1fb23ffbc8897 100644 --- a/src/legacy/core_plugins/console/public/quarantined/src/components/console_menu.js +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/components/console_menu.tsx @@ -17,16 +17,25 @@ * under the License. */ -import PropTypes from 'prop-types'; - import React, { Component } from 'react'; import { EuiButtonIcon, EuiContextMenuPanel, EuiContextMenuItem, EuiPopover } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; -export class ConsoleMenu extends Component { - constructor(props) { +interface Props { + getCurl: (cb: (text: string) => void) => void; + getDocumentation: () => Promise; + autoIndent: (ev: React.MouseEvent) => void; +} + +interface State { + isPopoverOpen: boolean; + curlCode: string; +} + +export class ConsoleMenu extends Component { + constructor(props: Props) { super(props); this.state = { @@ -46,7 +55,7 @@ export class ConsoleMenu extends Component { this.copyText(this.state.curlCode); } - copyText(text) { + copyText(text: string) { const textField = document.createElement('textarea'); textField.innerText = text; document.body.appendChild(textField); @@ -76,11 +85,18 @@ export class ConsoleMenu extends Component { window.open(documentation, '_blank'); }; + // Using `any` here per this issue: https://github.com/elastic/eui/issues/2265 + autoIndent: any = (event: React.MouseEvent) => { + this.closePopover(); + this.props.autoIndent(event); + }; + render() { const button = ( , - { - this.closePopover(); - this.props.autoIndent(event); - }} - > + Date: Wed, 28 Aug 2019 17:30:58 +0200 Subject: [PATCH 05/35] Remove unused file from quarantine and added fixed ui ace keyboard mode react hook --- .../legacy/use_ui_ace_keyboard_mode.tsx | 42 +++++++++---------- .../src/directives/console_menu_directive.js | 30 ------------- 2 files changed, 20 insertions(+), 52 deletions(-) delete mode 100644 src/legacy/core_plugins/console/public/quarantined/src/directives/console_menu_directive.js diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx index 1974fb22d8c2e..7fe5820d94f97 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import React, { useEffect, useState, useRef } from 'react'; +import React, { useEffect, useRef } from 'react'; import { render, unmountComponentAtNode } from 'react-dom'; import { keyCodes } from '@elastic/eui'; @@ -48,7 +48,7 @@ const Overlay = ({ export function useUIAceKeyboardMode(aceTextAreaElement: HTMLTextAreaElement | null) { const textArea = useRef(null); const mountNode = useRef(null); - const [isAutoCompleteOpen, setAutoCompleteOpen] = useState(false); + const autoCompleteVisibleRef = useRef(false); function onDismissOverlay(ev: React.KeyboardEvent) { if (ev.keyCode === keyCodes.ENTER) { @@ -65,27 +65,24 @@ export function useUIAceKeyboardMode(aceTextAreaElement: HTMLTextAreaElement | n ); } - const autoCompleteOpenListener = () => { + const isAutoCompleteVisible = () => { const autoCompleter = document.querySelector('.ace_autocomplete'); - if (!autoCompleter) { - setAutoCompleteOpen(false); - return; + return false; } - // The autoComplete is just hidden when it's closed, not removed from the DOM. - setAutoCompleteOpen(autoCompleter.style.display !== 'none'); + return autoCompleter.style.display !== 'none'; }; - const aceTextBoxListener = (ev: KeyboardEvent) => { - if (ev.keyCode === keyCodes.ESCAPE) { - // If the autocompletion context menu is open then we want to let ESC close it but - // **not** exit out of editing mode. - if (!isAutoCompleteOpen) { - ev.preventDefault(); - ev.stopPropagation(); - enableOverlay(); - } + const documentKeyDownListener = () => { + autoCompleteVisibleRef.current = isAutoCompleteVisible(); + }; + + const aceKeydownListener = (ev: KeyboardEvent) => { + if (ev.keyCode === keyCodes.ESCAPE && !autoCompleteVisibleRef.current) { + ev.preventDefault(); + ev.stopPropagation(); + enableOverlay(); } }; @@ -97,13 +94,14 @@ export function useUIAceKeyboardMode(aceTextAreaElement: HTMLTextAreaElement | n mountNode.current = container; textArea.current = aceTextAreaElement; - document.addEventListener('keydown', autoCompleteOpenListener, { capture: true }); - textArea.current.addEventListener('keydown', aceTextBoxListener); + // This listener fires on capture phase so that we get a look at the world before ace changes it. + document.addEventListener('keydown', documentKeyDownListener, { capture: true }); + textArea.current.addEventListener('keydown', aceKeydownListener); } return () => { - if (aceTextAreaElement) { - aceTextAreaElement.removeEventListener('keydown', aceTextBoxListener); - document.removeEventListener('keydown', autoCompleteOpenListener); + if (textArea.current) { + document.removeEventListener('keydown', documentKeyDownListener); + textArea.current.removeEventListener('keydown', aceKeydownListener); document.removeChild(mountNode.current!); } }; diff --git a/src/legacy/core_plugins/console/public/quarantined/src/directives/console_menu_directive.js b/src/legacy/core_plugins/console/public/quarantined/src/directives/console_menu_directive.js deleted file mode 100644 index be04e6bcc17fe..0000000000000 --- a/src/legacy/core_plugins/console/public/quarantined/src/directives/console_menu_directive.js +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import 'ngreact'; - -import { wrapInI18nContext } from 'ui/i18n'; -import { uiModules } from 'ui/modules'; -const module = uiModules.get('apps/sense', ['react']); - -import { ConsoleMenu } from '../components/console_menu'; - -module.directive('consoleMenu', function (reactDirective) { - return reactDirective(wrapInI18nContext(ConsoleMenu)); -}); From 7cf1417b9e89acfd15807c42ee4fa5af57c3dae7 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Wed, 28 Aug 2019 19:07:36 +0200 Subject: [PATCH 06/35] - Refactored history and storage to app-wide services - Pre-emptive changes to tests - sense-history -> HistoryList - removed unused kbn top nav v2 component --- .../app/containers/editor/legacy/index.tsx | 7 +- .../app/containers/history_viewer/index.tsx | 172 ++++++++++++++++++ .../np_ready/public/app/containers/main.tsx | 21 ++- .../public/app/context/app_context.tsx | 3 +- .../public/np_ready/public/app/index.tsx | 6 +- .../np_ready/public/app/services/history.ts | 117 ++++++++++++ .../np_ready/public/app/services/index.ts | 21 +++ .../{storage/index.ts => services/storage.ts} | 8 +- .../console/public/quarantined/index.html | 8 +- .../public/quarantined/src/__tests__/app.js | 15 +- .../console/public/quarantined/src/app.js | 58 +----- .../console/public/quarantined/src/history.js | 83 --------- .../console/public/quarantined/src/input.js | 3 +- .../quarantined/tests/src/editor.test.js | 1 + .../tests/src/input_tokenization.test.js | 10 +- .../quarantined/tests/src/integration.test.js | 3 +- 16 files changed, 370 insertions(+), 166 deletions(-) create mode 100644 src/legacy/core_plugins/console/public/np_ready/public/app/containers/history_viewer/index.tsx create mode 100644 src/legacy/core_plugins/console/public/np_ready/public/app/services/history.ts create mode 100644 src/legacy/core_plugins/console/public/np_ready/public/app/services/index.ts rename src/legacy/core_plugins/console/public/np_ready/public/app/{storage/index.ts => services/storage.ts} (91%) delete mode 100644 src/legacy/core_plugins/console/public/quarantined/src/history.js diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.tsx index 03bffc4f03498..8ae239f75bb9a 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.tsx +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.tsx @@ -35,6 +35,7 @@ import { autoIndent, getDocumentation } from './console_menu_actions'; import { Panel, PanelContainer } from '../../../components/split_panel'; import { useUIAceKeyboardMode } from './use_ui_ace_keyboard_mode'; +import { useAppContext } from '../../../context'; const PANEL_MIN_WIDTH = '100px'; @@ -59,6 +60,8 @@ export function ConsoleEditor({ initialInputPanelWidth, initialOutputPanelWidth, }: EditorProps) { + const { history } = useAppContext(); + const editorRef = useRef(null); const outputRef = useRef(null); const actionsRef = useRef(null); @@ -84,8 +87,8 @@ export function ConsoleEditor({ const actions$ = $(actionsRef.current!); const outputEditor = initializeOutput(output$); - const inputEditor = initializeInput(editor$, actions$, outputEditor); - init(inputEditor, outputEditor); + const inputEditor = initializeInput(editor$, actions$, outputEditor, history); + init(inputEditor, outputEditor, history); const session = inputEditor.getSession(); session.getSelection().on('changeCursor', () => { diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/history_viewer/index.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/history_viewer/index.tsx new file mode 100644 index 0000000000000..a3d6b8c966823 --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/history_viewer/index.tsx @@ -0,0 +1,172 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React, { useEffect, useRef, useState } from 'react'; +import { i18n } from '@kbn/i18n'; +import { memoize } from 'lodash'; +import moment from 'moment'; +import { keyCodes } from '@elastic/eui'; + +import { useAppContext } from '../../context'; + +interface Props { + close: () => void; +} + +export function HistoryList({ close }: Props) { + const { history } = useAppContext(); + const [reqs, setReqs] = useState([]); + const [selectedIndex, setSelectedIndex] = useState(0); + + const selectedReq = useRef(null); + const viewingReq = useRef(null); + + const describeReq = memoize((req: any) => { + const endpoint = req.endpoint; + const date = moment(req.time); + + let formattedDate = date.format('MMM D'); + if (date.diff(moment(), 'days') > -7) { + formattedDate = date.fromNow(); + } + + return `${endpoint} (${formattedDate})`; + }); + + const initialize = () => { + const nextReqs = history.getHistory(); + const nextSelectedIndex = 0; + selectedReq.current = viewingReq.current = nextReqs[nextSelectedIndex]; + (describeReq as any).cache = new WeakMap(); + setSelectedIndex(nextSelectedIndex); + setReqs(nextReqs); + }; + + const clear = () => { + history.clearHistory(); + initialize(); + }; + + const restore = (req: any = selectedReq.current) => { + history.restoreFromHistory(req); + }; + + useEffect(() => { + initialize(); + }, []); + + return ( +
    +

    + {i18n.translate('console.historyPage.pageTitle', { defaultMessage: 'History' })} +

    +
    + {/* eslint-disable-next-line */} +
      { + if (ev.keyCode === keyCodes.ENTER) { + restore(); + return; + } + + if (ev.keyCode === keyCodes.UP) { + ev.preventDefault(); + setSelectedIndex(selectedIndex - 1); + } else if (ev.keyCode === keyCodes.DOWN) { + ev.preventDefault(); + setSelectedIndex(selectedIndex + 1); + } + + const nextSelectedIndex = Math.min(Math.max(0, selectedIndex), reqs.length - 1); + + selectedReq.current = reqs[nextSelectedIndex]; + viewingReq.current = reqs[nextSelectedIndex]; + setSelectedIndex(nextSelectedIndex); + }} + className="list-group conHistory__reqs" + tabIndex={0} + aria-activedescendant="historyReq{{ history.selectedIndex }}" + scrollto-activedescendant + ng-keydown="history.onKeyDown($event)" + aria-label="{{:: 'console.historyPage.requestListAriaLabel' | i18n: { defaultMessage: 'History of sent requests' } }}" + > + {reqs.map((req, idx) => { + const isSelected = viewingReq === req; + return ( + // Ignore a11y issues on li's + // eslint-disable-next-line +
    • { + selectedReq.current = req; + viewingReq.current = req; + setSelectedIndex(idx); + }} + onMouseEnter={() => (viewingReq.current = req)} + onMouseLeave={() => (viewingReq.current = selectedReq.current)} + onDoubleClick={() => restore(req)} + aria-label={i18n.translate('console.historyPage.itemOfRequestListAriaLabel', { + defaultMessage: 'Request: {historyItem}', + values: { historyItem: describeReq(req) }, + })} + aria-selected={selectedReq === req} + > + {describeReq(req)} + + + +
    • + ); + })} +
    + + {/* */} +
    + +
    + + +
    + + + +
    +
    +
    + ); +} diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main.tsx index 81565570251c6..55fcd3d0e8eac 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main.tsx +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main.tsx @@ -17,18 +17,20 @@ * under the License. */ -import React, { useCallback } from 'react'; +import React, { useCallback, useState } from 'react'; import { debounce } from 'lodash'; import { ConsoleEditor } from './editor'; +import { HistoryList } from './history_viewer'; import { useAppContext } from '../context'; -import { StorageKeys } from '../storage'; +import { StorageKeys } from '../services/storage'; const INITIAL_PANEL_WIDTH = 50; export function Main() { const { storage, docLinkVersion } = useAppContext(); + const [, setShowingHistory] = useState(false); const [firstPanelWidth, secondPanelWidth] = storage.get(StorageKeys.WIDTH, [ INITIAL_PANEL_WIDTH, INITIAL_PANEL_WIDTH, @@ -45,11 +47,14 @@ export function Main() { [] ); return ( - + <> + setShowingHistory(false)} /> + + ); } diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/context/app_context.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/context/app_context.tsx index a3702563021d4..ef4baacfc2e47 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/context/app_context.tsx +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/context/app_context.tsx @@ -18,9 +18,10 @@ */ import React, { createContext, useContext } from 'react'; -import { Storage } from '../storage'; +import { History, Storage } from '../services'; interface ContextValue { + history: History; storage: Storage; docLinkVersion: string; } diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/index.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/index.tsx index 7d94535dab81f..a2df870efdd7e 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/index.tsx +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/index.tsx @@ -20,7 +20,7 @@ import React from 'react'; import { AppContextProvider } from './context'; import { Main } from './containers'; -import { create as createStorage } from './storage'; +import { createStorage, createHistory } from './services'; export function boot(I18nContext: any, deps: { docLinkVersion: string }) { const storage = createStorage({ @@ -28,9 +28,11 @@ export function boot(I18nContext: any, deps: { docLinkVersion: string }) { prefix: 'console_editor:', }); + const history = createHistory({ storage }); + return ( - +
    diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/services/history.ts b/src/legacy/core_plugins/console/public/np_ready/public/app/services/history.ts new file mode 100644 index 0000000000000..cef605dc11952 --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/services/history.ts @@ -0,0 +1,117 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { Storage } from '.'; + +export class History { + private editor: any; + + constructor(private readonly storage: Storage) {} + + setEditor(editor: any) { + this.editor = editor; + } + + // stupid simple restore function, called when the user + // chooses to restore a request from the history + // PREVENTS history from needing to know about the input + restoreFromHistory(req: any) { + const session = this.editor.getSession(); + let pos = this.editor.getCursorPosition(); + let prefix = ''; + let suffix = '\n'; + if (this.editor.parser.isStartRequestRow(pos.row)) { + pos.column = 0; + suffix += '\n'; + } else if (this.editor.parser.isEndRequestRow(pos.row)) { + const line = session.getLine(pos.row); + pos.column = line.length; + prefix = '\n\n'; + } else if (this.editor.parser.isInBetweenRequestsRow(pos.row)) { + pos.column = 0; + } else { + pos = this.editor.nextRequestEnd(pos); + prefix = '\n\n'; + } + + let s = prefix + req.method + ' ' + req.endpoint; + if (req.data) { + s += '\n' + req.data; + } + + s += suffix; + + session.insert(pos, s); + this.editor.clearSelection(); + this.editor.moveCursorTo(pos.row + prefix.length, 0); + this.editor.focus(); + } + + getHistoryKeys() { + return this.storage + .keys() + .filter((key: string) => key.indexOf('hist_elem') === 0) + .sort() + .reverse(); + } + + getHistory() { + return this.getHistoryKeys().map(key => this.storage.get(key)); + } + + addToHistory(endpoint: string, method: string, data: any) { + const keys = this.getHistoryKeys(); + keys.splice(0, 500); // only maintain most recent X; + $.each(keys, (i, k) => { + this.storage.delete(k); + }); + + const timestamp = new Date().getTime(); + const k = 'hist_elem_' + timestamp; + this.storage.set(k, { + time: timestamp, + endpoint, + method, + data, + }); + } + + updateCurrentState(content: any) { + const timestamp = new Date().getTime(); + this.storage.set('editor_state', { + time: timestamp, + content, + }); + } + + getSavedEditorState() { + const saved = this.storage.get('editor_state'); + if (!saved) return; + const { time, content } = saved; + return { time, content }; + } + + clearHistory() { + this.getHistoryKeys().forEach(key => this.storage.delete(key)); + } +} + +export function createHistory(deps: { storage: Storage }) { + return new History(deps.storage); +} diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/services/index.ts b/src/legacy/core_plugins/console/public/np_ready/public/app/services/index.ts new file mode 100644 index 0000000000000..ce6f37010f7e3 --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/services/index.ts @@ -0,0 +1,21 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { createHistory, History } from './history'; +export { createStorage, Storage } from './storage'; diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/storage/index.ts b/src/legacy/core_plugins/console/public/np_ready/public/app/services/storage.ts similarity index 91% rename from src/legacy/core_plugins/console/public/np_ready/public/app/storage/index.ts rename to src/legacy/core_plugins/console/public/np_ready/public/app/services/storage.ts index f65f087b47e8a..fcbe3947fbd54 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/storage/index.ts +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/services/storage.ts @@ -61,7 +61,7 @@ export class Storage { return this.engine.getItem(this.encodeKey(key)) != null; } - get(key: string, _default: T) { + get(key: string, _default?: T) { if (this.has(key)) { return this.decode(this.engine.getItem(this.encodeKey(key))); } else { @@ -73,7 +73,7 @@ export class Storage { return this.engine.removeItem(this.encodeKey(key)); } - keys() { + keys(): string[] { return transform(keys(this.engine), (ours, key) => { const ourKey = this.decodeKey(key); if (ourKey != null) ours.push(ourKey); @@ -81,6 +81,6 @@ export class Storage { } } -export function create({ engine, prefix }: { engine: IStorageEngine; prefix: string }) { - return new Storage(engine, prefix); +export function createStorage(deps: { engine: IStorageEngine; prefix: string }) { + return new Storage(deps.engine, deps.prefix); } diff --git a/src/legacy/core_plugins/console/public/quarantined/index.html b/src/legacy/core_plugins/console/public/quarantined/index.html index b099d08ce6c45..744b498d6f269 100644 --- a/src/legacy/core_plugins/console/public/quarantined/index.html +++ b/src/legacy/core_plugins/console/public/quarantined/index.html @@ -1,7 +1,7 @@ - + + + +
    diff --git a/src/legacy/core_plugins/console/public/quarantined/src/__tests__/app.js b/src/legacy/core_plugins/console/public/quarantined/src/__tests__/app.js index 60c6f7a8ebb54..9f3779b02e9f3 100644 --- a/src/legacy/core_plugins/console/public/quarantined/src/__tests__/app.js +++ b/src/legacy/core_plugins/console/public/quarantined/src/__tests__/app.js @@ -20,10 +20,11 @@ import sinon from 'sinon'; import $ from 'jquery'; -import history from '../history'; import mappings from '../mappings'; import init from '../app'; +const history = {}; + describe('console app initialization', () => { const sandbox = sinon.createSandbox(); @@ -41,11 +42,11 @@ describe('console app initialization', () => { moveToNextRequestEdge: sinon.stub(), highlightCurrentRequestsAndUpdateActionBar: sinon.stub(), updateActionsBar: sinon.stub(), - getSession: sinon.stub().returns({ on() {} }) + getSession: sinon.stub().returns({ on() {} }), }; outputMock = { - update: sinon.stub() + update: sinon.stub(), }; }); @@ -57,13 +58,13 @@ describe('console app initialization', () => { const mockContent = {}; ajaxDoneStub.yields(mockContent); - init(inputMock, outputMock, 'https://state.link.com/content'); + init(inputMock, outputMock, history, 'https://state.link.com/content'); sinon.assert.calledOnce($.ajax); sinon.assert.calledWithExactly($.ajax, { url: 'https://state.link.com/content', dataType: 'text', - kbnXsrfToken: false + kbnXsrfToken: false, }); sinon.assert.calledTwice(inputMock.moveToNextRequestEdge); @@ -81,14 +82,14 @@ describe('console app initialization', () => { const mockContent = {}; ajaxDoneStub.yields(mockContent); - init(inputMock, outputMock, 'https://api.github.com/content'); + init(inputMock, outputMock, history, 'https://api.github.com/content'); sinon.assert.calledOnce($.ajax); sinon.assert.calledWithExactly($.ajax, { url: 'https://api.github.com/content', dataType: 'text', kbnXsrfToken: false, - headers: { Accept: 'application/vnd.github.v3.raw' } + headers: { Accept: 'application/vnd.github.v3.raw' }, }); sinon.assert.calledTwice(inputMock.moveToNextRequestEdge); diff --git a/src/legacy/core_plugins/console/public/quarantined/src/app.js b/src/legacy/core_plugins/console/public/quarantined/src/app.js index c591de73d0056..54264950c2183 100644 --- a/src/legacy/core_plugins/console/public/quarantined/src/app.js +++ b/src/legacy/core_plugins/console/public/quarantined/src/app.js @@ -18,11 +18,9 @@ */ const $ = require('jquery'); - -const history = require('./history'); const mappings = require('./mappings'); -export default function init(input, output, sourceLocation = 'stored') { +export default function init(input, output, history, sourceLocation = 'stored') { $(document.body).removeClass('fouc'); // set the value of the input and clear the output @@ -49,8 +47,7 @@ export default function init(input, output, sourceLocation = 'stored') { try { const content = input.getValue(); history.updateCurrentState(content); - } - catch (e) { + } catch (e) { console.log('Ignoring saving error: ' + e); } } @@ -60,76 +57,35 @@ export default function init(input, output, sourceLocation = 'stored') { if (sourceLocation === 'stored') { if (previousSaveState) { resetToValues(previousSaveState.content); - } - else { + } else { resetToValues(); input.autoIndent(); } - } - else if (/^https?:\/\//.test(sourceLocation)) { + } else if (/^https?:\/\//.test(sourceLocation)) { const loadFrom = { url: sourceLocation, // Having dataType here is required as it doesn't allow jQuery to `eval` content // coming from the external source thereby preventing XSS attack. dataType: 'text', - kbnXsrfToken: false + kbnXsrfToken: false, }; if (/https?:\/\/api.github.com/.test(sourceLocation)) { loadFrom.headers = { Accept: 'application/vnd.github.v3.raw' }; } - $.ajax(loadFrom).done((data) => { + $.ajax(loadFrom).done(data => { resetToValues(data); input.moveToNextRequestEdge(true); input.highlightCurrentRequestsAndUpdateActionBar(); input.updateActionsBar(); }); - } - else { + } else { resetToValues(); } input.moveToNextRequestEdge(true); } - // stupid simple restore function, called when the user - // chooses to restore a request from the history - // PREVENTS history from needing to know about the input - history.restoreFromHistory = function applyHistoryElem(req) { - const session = input.getSession(); - let pos = input.getCursorPosition(); - let prefix = ''; - let suffix = '\n'; - if (input.parser.isStartRequestRow(pos.row)) { - pos.column = 0; - suffix += '\n'; - } - else if (input.parser.isEndRequestRow(pos.row)) { - const line = session.getLine(pos.row); - pos.column = line.length; - prefix = '\n\n'; - } - else if (input.parser.isInBetweenRequestsRow(pos.row)) { - pos.column = 0; - } - else { - pos = input.nextRequestEnd(pos); - prefix = '\n\n'; - } - - let s = prefix + req.method + ' ' + req.endpoint; - if (req.data) { - s += '\n' + req.data; - } - - s += suffix; - - session.insert(pos, s); - input.clearSelection(); - input.moveCursorTo(pos.row + prefix.length, 0); - input.focus(); - }; - setupAutosave(); loadSavedState(); mappings.retrieveAutoCompleteInfo(); diff --git a/src/legacy/core_plugins/console/public/quarantined/src/history.js b/src/legacy/core_plugins/console/public/quarantined/src/history.js deleted file mode 100644 index 14d6ef5fcff04..0000000000000 --- a/src/legacy/core_plugins/console/public/quarantined/src/history.js +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -const $ = require('jquery'); -const storage = require('./storage'); - -const history = { - restoreFromHistory() { - // default method for history.restoreFromHistory - // replace externally to do something when the user chooses - // to relive a bit of history - throw new Error('not implemented'); - }, - - getHistoryKeys() { - return storage.keys() - .filter(key => key.indexOf('hist_elem') === 0) - .sort() - .reverse(); - }, - - getHistory() { - return history - .getHistoryKeys() - .map(key => storage.get(key)); - }, - - addToHistory(endpoint, method, data) { - const keys = history.getHistoryKeys(); - keys.splice(0, 500); // only maintain most recent X; - $.each(keys, function (i, k) { - storage.delete(k); - }); - - const timestamp = new Date().getTime(); - const k = 'hist_elem_' + timestamp; - storage.set(k, { - time: timestamp, - endpoint: endpoint, - method: method, - data: data - }); - }, - - updateCurrentState(content) { - const timestamp = new Date().getTime(); - storage.set('editor_state', { - time: timestamp, - content: content - }); - }, - - getSavedEditorState() { - const saved = storage.get('editor_state'); - if (!saved) return; - const { time, content } = saved; - return { time, content }; - }, - - clearHistory() { - history - .getHistoryKeys() - .forEach(key => storage.delete(key)); - } -}; - -export default history; diff --git a/src/legacy/core_plugins/console/public/quarantined/src/input.js b/src/legacy/core_plugins/console/public/quarantined/src/input.js index 9c5400e873bf5..8785f65386d7a 100644 --- a/src/legacy/core_plugins/console/public/quarantined/src/input.js +++ b/src/legacy/core_plugins/console/public/quarantined/src/input.js @@ -25,11 +25,10 @@ const SenseEditor = require('./sense_editor/editor'); const settings = require('./settings'); const utils = require('./utils'); const es = require('./es'); -const history = require('./history'); import { uiModules } from 'ui/modules'; let input; -export function initializeInput($el, $actionsEl, output, openDocumentation = () => {}) { +export function initializeInput($el, $actionsEl, output, history, openDocumentation = () => {}) { input = new SenseEditor($el); // this may not exist if running from tests diff --git a/src/legacy/core_plugins/console/public/quarantined/tests/src/editor.test.js b/src/legacy/core_plugins/console/public/quarantined/tests/src/editor.test.js index ef1b1fb2dd65c..41e3decf33e0d 100644 --- a/src/legacy/core_plugins/console/public/quarantined/tests/src/editor.test.js +++ b/src/legacy/core_plugins/console/public/quarantined/tests/src/editor.test.js @@ -46,6 +46,7 @@ describe('Editor', () => { $('#ConAppEditor'), $('#ConAppEditorActions'), $('#ConCopyAsCurl'), + {}, null ); input.$el.show(); diff --git a/src/legacy/core_plugins/console/public/quarantined/tests/src/input_tokenization.test.js b/src/legacy/core_plugins/console/public/quarantined/tests/src/input_tokenization.test.js index 3c249a0c86bc5..c6005f5b86a77 100644 --- a/src/legacy/core_plugins/console/public/quarantined/tests/src/input_tokenization.test.js +++ b/src/legacy/core_plugins/console/public/quarantined/tests/src/input_tokenization.test.js @@ -40,9 +40,17 @@ describe('Input Tokenization', () => { $('#ConAppEditor'), $('#ConAppEditorActions'), $('#ConCopyAsCurl'), + {}, + null + ); + + input = initializeInput( + $('#ConAppEditor'), + $('#ConAppEditorActions'), + $('#ConCopyAsCurl'), + {}, null ); - input = initializeInput($('#ConAppEditor'), $('#ConAppEditorActions'), $('#ConCopyAsCurl'), null); input.$el.show(); input.autocomplete._test.removeChangeListener(); }); diff --git a/src/legacy/core_plugins/console/public/quarantined/tests/src/integration.test.js b/src/legacy/core_plugins/console/public/quarantined/tests/src/integration.test.js index 0164f291594f3..2ecad41f1d2c7 100644 --- a/src/legacy/core_plugins/console/public/quarantined/tests/src/integration.test.js +++ b/src/legacy/core_plugins/console/public/quarantined/tests/src/integration.test.js @@ -39,7 +39,8 @@ describe('Integration', () => { $('#ConAppEditor'), $('#ConAppEditorActions'), $('#ConCopyAsCurl'), - null + {}, + null, ); input.$el.show(); input.autocomplete._test.removeChangeListener(); From 8ff783af45404b0286bda16a847c9abe23489cb8 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 29 Aug 2019 13:05:38 +0200 Subject: [PATCH 07/35] A lot of cleanup, re-introduced editor resize checker, re-introduced history viewer as TS+React. `history` still needs refactoring. --- .../containers/panel_container.tsx | 2 +- .../app/components/split_panel/index.ts | 2 +- .../public/app/containers/editor/index.ts | 2 +- .../editor/legacy/console_editor.tsx | 187 ++++++++++++++++++ .../console_history/console_history.tsx} | 31 +-- .../legacy/console_history/history_viewer.tsx | 66 +++++++ .../editor/legacy/console_history/index.ts | 20 ++ .../app/containers/editor/legacy/index.ts | 21 ++ .../app/containers/editor/legacy/index.tsx | 160 --------------- .../legacy/install_console_resize_checker.ts} | 6 +- .../app/containers/editor/legacy/settings.ts | 130 ++++++++++++ .../np_ready/public/app/containers/main.tsx | 23 ++- .../public/app/context/app_context.tsx | 1 + .../public/np_ready/public/app/index.tsx | 5 +- .../np_ready/public/app/services/storage.ts | 8 +- .../console/public/np_ready/public/legacy.ts | 3 + .../console/public/np_ready/public/plugin.ts | 4 +- .../console/public/quarantined/src/app.js | 11 +- .../console/public/quarantined/src/input.js | 10 - 19 files changed, 487 insertions(+), 205 deletions(-) create mode 100644 src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_editor.tsx rename src/legacy/core_plugins/console/public/np_ready/public/app/containers/{history_viewer/index.tsx => editor/legacy/console_history/console_history.tsx} (87%) create mode 100644 src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_history/history_viewer.tsx create mode 100644 src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_history/index.ts create mode 100644 src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.ts delete mode 100644 src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.tsx rename src/legacy/core_plugins/console/public/{quarantined/src/sense_editor_resize.js => np_ready/public/app/containers/editor/legacy/install_console_resize_checker.ts} (83%) create mode 100644 src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/settings.ts diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/containers/panel_container.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/containers/panel_container.tsx index d5c5882a2e227..dcec12ddefee7 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/containers/panel_container.tsx +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/containers/panel_container.tsx @@ -33,7 +33,7 @@ const initialState = { currentPanel: -1, isDragging: false, currentResizerPos: - const pxToPercent = (proportion: number, whole: number) => (proportion / whole) * 100; // TODO: Write tests for this -export function PanelContainer({ children, onPanelWidthChange }: Props) { +export function PanelsContainer({ children, onPanelWidthChange }: Props) { const [head, ...rest] = Children.toArray(children); const registryRef = useRef(new PanelRegistry()); diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/index.ts b/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/index.ts index 2db2ee7ff2ca2..ed66cb958ea77 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/index.ts +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/index.ts @@ -18,4 +18,4 @@ */ export { Panel } from './containers/panel'; -export { PanelContainer } from './containers/panel_container'; +export { PanelsContainer } from './containers/panel_container'; diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/index.ts b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/index.ts index 443a80be80620..72565bde33f3c 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/index.ts +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/index.ts @@ -17,4 +17,4 @@ * under the License. */ -export { ConsoleEditor } from './legacy'; +export { ConsoleEditor, ConsoleHistory } from './legacy'; diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_editor.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_editor.tsx new file mode 100644 index 0000000000000..1d3f506f2a579 --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_editor.tsx @@ -0,0 +1,187 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React, { CSSProperties, useEffect, useRef, useState } from 'react'; +import $ from 'jquery'; +import { EuiToolTip } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; + +// @ts-ignore +import { initializeInput } from '../../../../../../quarantined/src/input'; +// @ts-ignore +import { initializeOutput } from '../../../../../../quarantined/src/output'; +// @ts-ignore +import init from '../../../../../../quarantined/src/app'; + +import { ConsoleMenu } from '../../../components/console_menu'; + +import { autoIndent, getDocumentation } from './console_menu_actions'; +import { Panel, PanelsContainer } from '../../../components/split_panel'; + +import { useUIAceKeyboardMode } from './use_ui_ace_keyboard_mode'; +import { useAppContext } from '../../../context'; +import { installEditorsResizeChecker } from './install_console_resize_checker'; +import { Settings } from './settings'; + +const PANEL_MIN_WIDTH = '100px'; + +const abs: CSSProperties = { + position: 'absolute', + top: '0', + left: '0', + bottom: '0', + right: '0', +}; + +export interface ConsoleEditorProps { + docLinkVersion: string; + onPanelWidthChange: (widths: number[]) => void; + onEditorsReady: () => void; + settings: Settings; + initialInputPanelWidth: number; + initialOutputPanelWidth: number; +} + +export const ConsoleEditor = React.memo( + ({ + onPanelWidthChange, + docLinkVersion, + initialInputPanelWidth, + initialOutputPanelWidth, + onEditorsReady, + settings, + }: ConsoleEditorProps) => { + const { history, ResizeChecker } = useAppContext(); + + const containerRef = useRef(null); + const editorRef = useRef(null); + const outputRef = useRef(null); + const actionsRef = useRef(null); + + const [, setLastRequestTimestamp] = useState(null as any); + const [editor, setEditor] = useState(null as any); + const [, setOutput] = useState(null as any); + const [maybeTextArea, setTextArea] = useState(null); + + const sendCurrentRequest = () => { + editor.focus(); + editor.sendCurrentRequestToES(() => { + // History watches this value and will re-render itself when it changes, so that + // the list of requests stays up-to-date as new requests are sent. + setLastRequestTimestamp(new Date().getTime()); + }); + return false; + }; + + useEffect(() => { + const editor$ = $(editorRef.current!); + const output$ = $(outputRef.current!); + const actions$ = $(actionsRef.current!); + + const outputEditor = initializeOutput(output$); + const inputEditor = initializeInput(editor$, actions$, outputEditor, history); + + settings.registerOutput(outputEditor); + settings.registerInput(inputEditor); + history.setEditor(inputEditor); + + init(inputEditor, outputEditor, history); + + const subscriptions = [ + installEditorsResizeChecker( + ResizeChecker, + containerRef.current!, + inputEditor, + outputEditor + ), + installEditorsResizeChecker(ResizeChecker, editorRef.current!, inputEditor), + installEditorsResizeChecker(ResizeChecker, outputRef.current!, outputEditor), + ]; + + const session = inputEditor.getSession(); + session.getSelection().on('changeCursor', () => { + // Fire and forget + getDocumentation(inputEditor, docLinkVersion); + }); + + setTextArea(editorRef.current!.querySelector('textarea')); + setOutput(outputEditor); + setEditor(inputEditor); + onEditorsReady(); + + return () => { + subscriptions.map(unsubscribe => unsubscribe()); + }; + }, []); + + useUIAceKeyboardMode(maybeTextArea); + + return ( +
    + + +
    +
    +
      +
      + + + + { + editor.getRequestsAsCURL(cb); + }} + getDocumentation={() => { + return getDocumentation(editor, docLinkVersion); + }} + autoIndent={(event: any) => { + autoIndent(editor, event); + }} + /> +
      +
      +
      +
    + + +
    +
    +
    + + +
    + ); + } +); diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/history_viewer/index.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_history/console_history.tsx similarity index 87% rename from src/legacy/core_plugins/console/public/np_ready/public/app/containers/history_viewer/index.tsx rename to src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_history/console_history.tsx index a3d6b8c966823..1145598392c0e 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/history_viewer/index.tsx +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_history/console_history.tsx @@ -23,14 +23,17 @@ import { memoize } from 'lodash'; import moment from 'moment'; import { keyCodes } from '@elastic/eui'; -import { useAppContext } from '../../context'; +import { useAppContext } from '../../../../context'; +import { HistoryViewer } from './history_viewer'; +import { Settings } from '../settings'; interface Props { + settings: Settings; close: () => void; } -export function HistoryList({ close }: Props) { - const { history } = useAppContext(); +export function ConsoleHistory({ close, settings }: Props) { + const { history, ResizeChecker } = useAppContext(); const [reqs, setReqs] = useState([]); const [selectedIndex, setSelectedIndex] = useState(0); @@ -71,14 +74,14 @@ export function HistoryList({ close }: Props) { initialize(); }, []); + /* eslint-disable */ return (

    {i18n.translate('console.historyPage.pageTitle', { defaultMessage: 'History' })}

    - {/* eslint-disable-next-line */} -
      { if (ev.keyCode === keyCodes.ENTER) { restore(); @@ -99,20 +102,21 @@ export function HistoryList({ close }: Props) { viewingReq.current = reqs[nextSelectedIndex]; setSelectedIndex(nextSelectedIndex); }} + role="listbox" className="list-group conHistory__reqs" tabIndex={0} - aria-activedescendant="historyReq{{ history.selectedIndex }}" - scrollto-activedescendant - ng-keydown="history.onKeyDown($event)" + // aria-activedescendant={`historyReq${selectedIndex}`} + // scrollto-activedescendant="true" aria-label="{{:: 'console.historyPage.requestListAriaLabel' | i18n: { defaultMessage: 'History of sent requests' } }}" > {reqs.map((req, idx) => { - const isSelected = viewingReq === req; + const isSelected = viewingReq.current === req; return ( // Ignore a11y issues on li's // eslint-disable-next-line
    • (viewingReq.current = req)} onMouseLeave={() => (viewingReq.current = selectedReq.current)} onDoubleClick={() => restore(req)} @@ -128,7 +133,7 @@ export function HistoryList({ close }: Props) { defaultMessage: 'Request: {historyItem}', values: { historyItem: describeReq(req) }, })} - aria-selected={selectedReq === req} + aria-selected={isSelected} > {describeReq(req)} @@ -139,7 +144,11 @@ export function HistoryList({ close }: Props) { })}
    - {/* */} +
    diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_history/history_viewer.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_history/history_viewer.tsx new file mode 100644 index 0000000000000..e60df257a436f --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_history/history_viewer.tsx @@ -0,0 +1,66 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React, { useEffect, useRef } from 'react'; +import { i18n } from '@kbn/i18n'; +import $ from 'jquery'; + +import { Settings } from '../settings'; +import { installEditorsResizeChecker } from '../install_console_resize_checker'; + +// @ts-ignore +import SenseEditor from '../../../../../../../quarantined/src/sense_editor/editor'; + +interface Props { + settings: Settings; + req: any | null; + ResizeChecker: any; +} + +export function HistoryViewer({ settings, ResizeChecker, req }: Props) { + const divRef = useRef(null); + const viewerRef = useRef(null); + + useEffect(() => { + const viewer = new SenseEditor($(divRef.current!)); + viewerRef.current = viewer; + viewer.renderer.setShowPrintMargin(false); + viewer.$blockScrolling = Infinity; + const unsubscribe = installEditorsResizeChecker(ResizeChecker, divRef.current!, viewer); + settings.applyCurrentSettings(viewer); + return () => unsubscribe(); + }, []); + + if (viewerRef.current) { + const { current: viewer } = viewerRef; + if (req) { + const s = req.method + ' ' + req.endpoint + '\n' + (req.data || ''); + viewer.setValue(s); + viewer.clearSelection(); + } else { + viewer.getSession().setValue( + i18n.translate('console.historyPage.noHistoryTextMessage', { + defaultMessage: 'No history available', + }) + ); + } + } + + return
    ; +} diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_history/index.ts b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_history/index.ts new file mode 100644 index 0000000000000..ba5b52f8ea4ad --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_history/index.ts @@ -0,0 +1,20 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { ConsoleHistory } from './console_history'; diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.ts b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.ts new file mode 100644 index 0000000000000..d7ed410f4bf8d --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.ts @@ -0,0 +1,21 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { ConsoleEditor } from './console_editor'; +export { ConsoleHistory } from './console_history'; diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.tsx deleted file mode 100644 index 8ae239f75bb9a..0000000000000 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.tsx +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import React, { CSSProperties, useEffect, useRef, useState } from 'react'; -import $ from 'jquery'; -import { EuiToolTip } from '@elastic/eui'; -import { i18n } from '@kbn/i18n'; - -// @ts-ignore -import { initializeInput } from '../../../../../../quarantined/src/input'; -// @ts-ignore -import { initializeOutput } from '../../../../../../quarantined/src/output'; -// @ts-ignore -import init from '../../../../../../quarantined/src/app'; - -import { ConsoleMenu } from '../../../components/console_menu'; - -import { autoIndent, getDocumentation } from './console_menu_actions'; -import { Panel, PanelContainer } from '../../../components/split_panel'; - -import { useUIAceKeyboardMode } from './use_ui_ace_keyboard_mode'; -import { useAppContext } from '../../../context'; - -const PANEL_MIN_WIDTH = '100px'; - -const abs: CSSProperties = { - position: 'absolute', - top: '0', - left: '0', - bottom: '0', - right: '0', -}; - -export interface EditorProps { - docLinkVersion: string; - onPanelWidthChange: (widths: number[]) => void; - initialInputPanelWidth: number; - initialOutputPanelWidth: number; -} - -export function ConsoleEditor({ - onPanelWidthChange, - docLinkVersion, - initialInputPanelWidth, - initialOutputPanelWidth, -}: EditorProps) { - const { history } = useAppContext(); - - const editorRef = useRef(null); - const outputRef = useRef(null); - const actionsRef = useRef(null); - - const [, setLastRequestTimestamp] = useState(null as any); - const [editor, setEditor] = useState(null as any); - const [, setOutput] = useState(null as any); - const [maybeTextArea, setTextArea] = useState(null); - - const sendCurrentRequest = () => { - editor.focus(); - editor.sendCurrentRequestToES(() => { - // History watches this value and will re-render itself when it changes, so that - // the list of requests stays up-to-date as new requests are sent. - setLastRequestTimestamp(new Date().getTime()); - }); - return false; - }; - - useEffect(() => { - const editor$ = $(editorRef.current!); - const output$ = $(outputRef.current!); - const actions$ = $(actionsRef.current!); - - const outputEditor = initializeOutput(output$); - const inputEditor = initializeInput(editor$, actions$, outputEditor, history); - init(inputEditor, outputEditor, history); - - const session = inputEditor.getSession(); - session.getSelection().on('changeCursor', () => { - // Fire and forget - getDocumentation(inputEditor, docLinkVersion); - }); - - setTextArea(editorRef.current!.querySelector('textarea')); - setOutput(outputEditor); - setEditor(inputEditor); - }, []); - - useUIAceKeyboardMode(maybeTextArea); - - return ( - - -
    -
    -
      -
      - - - - { - editor.getRequestsAsCURL(cb); - }} - getDocumentation={() => { - return getDocumentation(editor, docLinkVersion); - }} - autoIndent={(event: any) => { - autoIndent(editor, event); - }} - /> -
      -
      - {`GET _search - { - "query": { "match_all": { } } - }`} -
      -
    -
    -
    - -
    -
    {`{}`}
    -
    -
    -
    - ); -} diff --git a/src/legacy/core_plugins/console/public/quarantined/src/sense_editor_resize.js b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/install_console_resize_checker.ts similarity index 83% rename from src/legacy/core_plugins/console/public/quarantined/src/sense_editor_resize.js rename to src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/install_console_resize_checker.ts index 6b950a394db1b..e3c0cf7b6619b 100644 --- a/src/legacy/core_plugins/console/public/quarantined/src/sense_editor_resize.js +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/install_console_resize_checker.ts @@ -17,10 +17,8 @@ * under the License. */ -import { ResizeChecker } from 'ui/resize_checker'; - -export function applyResizeCheckerToEditors($scope, $el, ...editors) { +export function installEditorsResizeChecker(ResizeChecker: any, $el: any, ...editors: any[]) { const checker = new ResizeChecker($el); checker.on('resize', () => editors.forEach(e => e.resize())); - $scope.$on('$destroy', () => checker.destroy()); + return () => checker.destroy(); } diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/settings.ts b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/settings.ts new file mode 100644 index 0000000000000..efd2134878a6c --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/settings.ts @@ -0,0 +1,130 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { Storage } from '../../../services'; + +export class Settings { + private input: any | null = null; + private output: any | null = null; + + constructor(private readonly storage: Storage) {} + + /** + * TODO: Slight hackiness going on here - late registration of dependencies should be refactored + */ + registerInput(input: any) { + this.input = input; + } + /** + * TODO: Slight hackiness going on here - late registration of dependencies should be refactored + */ + registerOutput(output: any) { + this.output = output; + } + + getFontSize() { + return this.storage.get('font_size', 14); + } + + setFontSize(size: any) { + this.storage.set('font_size', size); + this.applyCurrentSettings(); + return true; + } + + getWrapMode() { + return this.storage.get('wrap_mode', true); + } + + setWrapMode(mode: any) { + this.storage.set('wrap_mode', mode); + this.applyCurrentSettings(); + return true; + } + + setTripleQuotes(tripleQuotes: any) { + this.storage.set('triple_quotes', tripleQuotes); + return true; + } + + getTripleQuotes() { + return this.storage.get('triple_quotes', true); + } + + getAutocomplete() { + return this.storage.get('autocomplete_settings', { + fields: true, + indices: true, + templates: true, + }); + } + + setAutocomplete(settings: any) { + this.storage.set('autocomplete_settings', settings); + return true; + } + + getPolling() { + return this.storage.get('console_polling', true); + } + + setPolling(polling: any) { + this.storage.set('console_polling', polling); + this.applyCurrentSettings(); + return true; + } + + applyCurrentSettings(editor?: any) { + if (typeof editor === 'undefined') { + if (this.input) this.applyCurrentSettings(this.input); + if (this.output) this.applyCurrentSettings(this.output); + } else if (editor) { + editor.getSession().setUseWrapMode(this.getWrapMode()); + editor.$el.css('font-size', this.getFontSize() + 'px'); + } + } + + getCurrentSettings() { + return { + autocomplete: this.getAutocomplete(), + wrapMode: this.getWrapMode(), + tripleQuotes: this.getTripleQuotes(), + fontSize: parseFloat(this.getFontSize()), + polling: Boolean(this.getPolling()), + }; + } + + updateSettings({ fontSize, wrapMode, tripleQuotes, autocomplete, polling }: any) { + this.setFontSize(fontSize); + this.setWrapMode(wrapMode); + this.setTripleQuotes(tripleQuotes); + this.setAutocomplete(autocomplete); + this.setPolling(polling); + this.input.focus(); + return this.getCurrentSettings(); + } +} + +interface Deps { + storage: Storage; +} + +export function createSettings({ storage }: Deps) { + return new Settings(storage); +} diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main.tsx index 55fcd3d0e8eac..7c9649688bfc9 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main.tsx +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main.tsx @@ -17,19 +17,23 @@ * under the License. */ -import React, { useCallback, useState } from 'react'; +import React, { useCallback, useRef, useState } from 'react'; import { debounce } from 'lodash'; -import { ConsoleEditor } from './editor'; -import { HistoryList } from './history_viewer'; +import { ConsoleEditor, ConsoleHistory } from './editor'; import { useAppContext } from '../context'; import { StorageKeys } from '../services/storage'; +import { createSettings } from './editor/legacy/settings'; + const INITIAL_PANEL_WIDTH = 50; export function Main() { const { storage, docLinkVersion } = useAppContext(); + + const settingsRef = useRef(createSettings({ storage })); + const [editorReady, setEditorReady] = useState(false); const [, setShowingHistory] = useState(false); const [firstPanelWidth, secondPanelWidth] = storage.get(StorageKeys.WIDTH, [ INITIAL_PANEL_WIDTH, @@ -46,10 +50,21 @@ export function Main() { ), [] ); + + const onEditorReady = useCallback(() => setEditorReady(true), []); + + const renderConsoleHistory = () => { + return editorReady ? ( + setShowingHistory(false)} /> + ) : null; + }; + return ( <> - setShowingHistory(false)} /> + {renderConsoleHistory()} - +
    diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/services/storage.ts b/src/legacy/core_plugins/console/public/np_ready/public/app/services/storage.ts index fcbe3947fbd54..2ac6fc5861ad2 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/services/storage.ts +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/services/storage.ts @@ -19,10 +19,6 @@ import { transform, keys, startsWith } from 'lodash'; -interface GenericObject { - [key: string]: any; -} - type IStorageEngine = typeof window.localStorage; export enum StorageKeys { @@ -32,7 +28,7 @@ export enum StorageKeys { export class Storage { constructor(private readonly engine: IStorageEngine, private readonly prefix: string) {} - encode(val: GenericObject) { + encode(val: any) { return JSON.stringify(val); } @@ -52,7 +48,7 @@ export class Storage { } } - set(key: string, val: GenericObject) { + set(key: string, val: any) { this.engine.setItem(this.encodeKey(key), this.encode(val)); return val; } diff --git a/src/legacy/core_plugins/console/public/np_ready/public/legacy.ts b/src/legacy/core_plugins/console/public/np_ready/public/legacy.ts index 7e1573b04af8b..30f8f5f5ddac0 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/legacy.ts +++ b/src/legacy/core_plugins/console/public/np_ready/public/legacy.ts @@ -24,6 +24,7 @@ import { npSetup, npStart } from 'ui/new_platform'; import uiRoutes from 'ui/routes'; import { DOC_LINK_VERSION } from 'ui/documentation_links'; import { I18nContext } from 'ui/i18n'; +import { ResizeChecker } from 'ui/resize_checker'; import 'ui/autoload/styles'; import 'ui/capabilities/route_setup'; /* eslint-enable @kbn/eslint/no-restricted-paths */ @@ -41,6 +42,7 @@ interface SetupRegisterAppArgs { export interface XCoreSetup extends CoreSetup { docLinkVersion: string; + ResizeChecker: any; I18nContext: any; application: { register(args: SetupRegisterAppArgs): void; @@ -68,6 +70,7 @@ uiRoutes.when('/dev_tools/console', { const xNpSetupCore: XCoreSetup = { ...npSetup.core, I18nContext, + ResizeChecker, docLinkVersion: DOC_LINK_VERSION, application: { register(args: SetupRegisterAppArgs): void { diff --git a/src/legacy/core_plugins/console/public/np_ready/public/plugin.ts b/src/legacy/core_plugins/console/public/np_ready/public/plugin.ts index 17cc0749fa76c..2f05ace7f5027 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/plugin.ts +++ b/src/legacy/core_plugins/console/public/np_ready/public/plugin.ts @@ -27,11 +27,11 @@ export class ConsoleUIPlugin implements Plugin { // @ts-ignore constructor(private readonly ctx: PluginInitializerContext) {} - async setup({ application, docLinkVersion, I18nContext }: XCoreSetup) { + async setup({ application, docLinkVersion, I18nContext, ResizeChecker }: XCoreSetup) { application.register({ id: 'console', async mount(ctx, targetElement) { - render(boot(I18nContext, { docLinkVersion }), targetElement); + render(boot({ docLinkVersion, I18nContext, ResizeChecker }), targetElement); return () => unmountComponentAtNode(targetElement); }, }); diff --git a/src/legacy/core_plugins/console/public/quarantined/src/app.js b/src/legacy/core_plugins/console/public/quarantined/src/app.js index 54264950c2183..4ceb6808e8b20 100644 --- a/src/legacy/core_plugins/console/public/quarantined/src/app.js +++ b/src/legacy/core_plugins/console/public/quarantined/src/app.js @@ -20,14 +20,19 @@ const $ = require('jquery'); const mappings = require('./mappings'); +const DEFAULT_INPUT_VALUE = `GET _search +{ + "query": { + "match_all": { } + } +}`; + export default function init(input, output, history, sourceLocation = 'stored') { $(document.body).removeClass('fouc'); // set the value of the input and clear the output function resetToValues(content) { - if (content != null) { - input.update(content); - } + input.update(content != null ? content : DEFAULT_INPUT_VALUE); output.update(''); } diff --git a/src/legacy/core_plugins/console/public/quarantined/src/input.js b/src/legacy/core_plugins/console/public/quarantined/src/input.js index 8785f65386d7a..a6de0b994b77c 100644 --- a/src/legacy/core_plugins/console/public/quarantined/src/input.js +++ b/src/legacy/core_plugins/console/public/quarantined/src/input.js @@ -25,20 +25,11 @@ const SenseEditor = require('./sense_editor/editor'); const settings = require('./settings'); const utils = require('./utils'); const es = require('./es'); -import { uiModules } from 'ui/modules'; let input; export function initializeInput($el, $actionsEl, output, history, openDocumentation = () => {}) { input = new SenseEditor($el); - // this may not exist if running from tests - if (uiModules) { - const appSense = uiModules.get('app/sense'); - if (appSense && appSense.setupResizeCheckerForRootEditors) { - appSense.setupResizeCheckerForRootEditors($el, input, output); - } - } - input.autocomplete = new Autocomplete(input); input.$actions = $actionsEl; @@ -230,7 +221,6 @@ export function initializeInput($el, $actionsEl, output, history, openDocumentat input.highlightCurrentRequestsAndUpdateActionBar(); input.sendCurrentRequestToES = sendCurrentRequestToES; - require('./input_resize')(input, output); return input; } From 32c463398bc2f2331f5b45af420f305df914365d Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 29 Aug 2019 13:44:57 +0200 Subject: [PATCH 08/35] First iteration of tap nav menu, with history toggle working --- .../np_ready/public/app/components/index.ts | 2 + .../public/app/components/top_nav_menu.tsx | 47 ++++++++ .../editor/legacy/console_editor.tsx | 8 +- .../app/containers/main}/get_top_nav.ts | 23 ++-- .../public/app/containers/main/index.ts | 20 ++++ .../public/app/containers/{ => main}/main.tsx | 18 ++- .../public/np_ready/public/app/index.tsx | 2 +- .../console/public/quarantined/_app.scss | 3 + .../quarantined/src/directives/history.html | 64 ----------- .../src/directives/sense_history.js | 105 ------------------ .../src/directives/sense_history_viewer.js | 58 ---------- 11 files changed, 104 insertions(+), 246 deletions(-) create mode 100644 src/legacy/core_plugins/console/public/np_ready/public/app/components/top_nav_menu.tsx rename src/legacy/core_plugins/console/public/{quarantined/src/helpers => np_ready/public/app/containers/main}/get_top_nav.ts (81%) create mode 100644 src/legacy/core_plugins/console/public/np_ready/public/app/containers/main/index.ts rename src/legacy/core_plugins/console/public/np_ready/public/app/containers/{ => main}/main.tsx (78%) delete mode 100644 src/legacy/core_plugins/console/public/quarantined/src/directives/history.html delete mode 100644 src/legacy/core_plugins/console/public/quarantined/src/directives/sense_history.js delete mode 100644 src/legacy/core_plugins/console/public/quarantined/src/directives/sense_history_viewer.js diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/components/index.ts b/src/legacy/core_plugins/console/public/np_ready/public/app/components/index.ts index 378264c1f3b91..28b8716a03c15 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/components/index.ts +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/components/index.ts @@ -18,3 +18,5 @@ */ export * from './split_panel'; +export { TopNavMenuItem, TopNavMenu } from './top_nav_menu'; +export { ConsoleMenu } from './console_menu'; diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/components/top_nav_menu.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/components/top_nav_menu.tsx new file mode 100644 index 0000000000000..df45d87ab94a1 --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/components/top_nav_menu.tsx @@ -0,0 +1,47 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React from 'react'; +import { EuiTabs, EuiTab } from '@elastic/eui'; + +export interface TopNavMenuItem { + id: string; + label: string; + description: string; + run: () => void; + testId: string; +} + +interface Props { + items: TopNavMenuItem[]; +} + +export function TopNavMenu({ items }: Props) { + return ( + + {items.map((item, idx) => { + return ( + + {item.label} + + ); + })} + + ); +} diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_editor.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_editor.tsx index 1d3f506f2a579..f79ec75d8391a 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_editor.tsx +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_editor.tsx @@ -29,7 +29,7 @@ import { initializeOutput } from '../../../../../../quarantined/src/output'; // @ts-ignore import init from '../../../../../../quarantined/src/app'; -import { ConsoleMenu } from '../../../components/console_menu'; +import { ConsoleMenu } from '../../../components'; import { autoIndent, getDocumentation } from './console_menu_actions'; import { Panel, PanelsContainer } from '../../../components/split_panel'; @@ -133,7 +133,11 @@ export const ConsoleEditor = React.memo( useUIAceKeyboardMode(maybeTextArea); return ( -
    +
    {}) { +interface Props { + toggleHistory: () => void; +} + +export function getTopNavConfig({ toggleHistory }: Props) { return [ { id: 'history', @@ -36,7 +39,7 @@ export function getTopNavConfig($scope: IScope, toggleHistory: () => {}) { defaultMessage: 'History', }), run: () => { - $scope.$evalAsync(toggleHistory); + toggleHistory(); }, testId: 'consoleHistoryButton', }, @@ -49,7 +52,7 @@ export function getTopNavConfig($scope: IScope, toggleHistory: () => {}) { defaultMessage: 'Settings', }), run: () => { - showSettingsModal(); + // showSettingsModal(); }, testId: 'consoleSettingsButton', }, @@ -62,10 +65,10 @@ export function getTopNavConfig($scope: IScope, toggleHistory: () => {}) { defaultMessage: 'Help', }), run: () => { - const hideHelpPanel = showHelpPanel(); - $scope.$on('$destroy', () => { - hideHelpPanel(); - }); + // const hideHelpPanel = showHelpPanel(); + // $scope.$on('$destroy', () => { + // hideHelpPanel(); + // }); }, testId: 'consoleHelpButton', }, diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main/index.ts b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main/index.ts new file mode 100644 index 0000000000000..44e8355611f48 --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main/index.ts @@ -0,0 +1,20 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { Main } from './main'; diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main/main.tsx similarity index 78% rename from src/legacy/core_plugins/console/public/np_ready/public/app/containers/main.tsx rename to src/legacy/core_plugins/console/public/np_ready/public/app/containers/main/main.tsx index 7c9649688bfc9..a41955f7c7949 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main.tsx +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main/main.tsx @@ -20,12 +20,14 @@ import React, { useCallback, useRef, useState } from 'react'; import { debounce } from 'lodash'; -import { ConsoleEditor, ConsoleHistory } from './editor'; +import { TopNavMenu } from '../../components'; +import { ConsoleEditor, ConsoleHistory } from '../editor'; -import { useAppContext } from '../context'; -import { StorageKeys } from '../services/storage'; +import { useAppContext } from '../../context'; +import { StorageKeys } from '../../services/storage'; -import { createSettings } from './editor/legacy/settings'; +import { createSettings } from '../editor/legacy/settings'; +import { getTopNavConfig } from './get_top_nav'; const INITIAL_PANEL_WIDTH = 50; @@ -34,7 +36,7 @@ export function Main() { const settingsRef = useRef(createSettings({ storage })); const [editorReady, setEditorReady] = useState(false); - const [, setShowingHistory] = useState(false); + const [showingHistory, setShowingHistory] = useState(false); const [firstPanelWidth, secondPanelWidth] = storage.get(StorageKeys.WIDTH, [ INITIAL_PANEL_WIDTH, INITIAL_PANEL_WIDTH, @@ -61,7 +63,11 @@ export function Main() { return ( <> - {renderConsoleHistory()} + {showingHistory ? ( + renderConsoleHistory() + ) : ( + setShowingHistory(true) })} /> + )} -

    - -
    -
      -
    • - {{ history.describeReq(req) }} - -
    • -
    - - -
    - - -
    diff --git a/src/legacy/core_plugins/console/public/quarantined/src/directives/sense_history.js b/src/legacy/core_plugins/console/public/quarantined/src/directives/sense_history.js deleted file mode 100644 index 29ad60a84e740..0000000000000 --- a/src/legacy/core_plugins/console/public/quarantined/src/directives/sense_history.js +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { keyCodes } from '@elastic/eui'; -import template from './history.html'; - -const { memoize } = require('lodash'); -const moment = require('moment'); - -const history = require('../history'); -require('./sense_history_viewer'); - -require('ui/modules') - .get('app/sense') - .directive('senseHistory', function () { - return { - restrict: 'E', - template, - controllerAs: 'history', - scope: { - isShown: '=', - historyDirty: '=', - close: '&', - }, - controller: function ($scope, $element) { - $scope.$watch('historyDirty', () => { - this.init(); - }); - - $scope.$watch('isShown', () => { - if ($scope.isShown) this.init(); - }); - - this.init = () => { - this.reqs = history.getHistory(); - this.selectedIndex = 0; - this.selectedReq = this.reqs[this.selectedIndex]; - this.viewingReq = this.selectedReq; - - // calculate the text description of a request - this.describeReq = memoize((req) => { - const endpoint = req.endpoint; - const date = moment(req.time); - - let formattedDate = date.format('MMM D'); - if (date.diff(moment(), 'days') > -7) { - formattedDate = date.fromNow(); - } - - return `${endpoint} (${formattedDate})`; - }); - this.describeReq.cache = new WeakMap(); - }; - - // main actions - this.clear = () => { - history.clearHistory($element); - this.init(); - }; - - this.close = () => { - $scope.close(); - }; - - this.restore = (req = this.selectedReq) => { - history.restoreFromHistory(req); - }; - - this.onKeyDown = (ev) => { - if (ev.keyCode === keyCodes.ENTER) { - this.restore(); - return; - } - - if (ev.keyCode === keyCodes.UP) { - ev.preventDefault(); - this.selectedIndex--; - } else if (ev.keyCode === keyCodes.DOWN) { - ev.preventDefault(); - this.selectedIndex++; - } - - this.selectedIndex = Math.min(Math.max(0, this.selectedIndex), this.reqs.length - 1); - this.selectedReq = this.reqs[this.selectedIndex]; - this.viewingReq = this.reqs[this.selectedIndex]; - }; - } - }; - }); diff --git a/src/legacy/core_plugins/console/public/quarantined/src/directives/sense_history_viewer.js b/src/legacy/core_plugins/console/public/quarantined/src/directives/sense_history_viewer.js deleted file mode 100644 index e066605a2ca83..0000000000000 --- a/src/legacy/core_plugins/console/public/quarantined/src/directives/sense_history_viewer.js +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -const SenseEditor = require('../sense_editor/editor'); - -import { i18n } from '@kbn/i18n'; - -import { applyResizeCheckerToEditors } from '../sense_editor_resize'; - -require('ui/modules') - .get('app/sense') - .directive('senseHistoryViewer', function () { - return { - restrict: 'E', - scope: { - req: '=', - }, - link: function ($scope, $el) { - const viewer = new SenseEditor($el); - viewer.setReadOnly(true); - viewer.renderer.setShowPrintMargin(false); - applyResizeCheckerToEditors($scope, $el, viewer); - require('../settings').applyCurrentSettings(viewer); - - $scope.$watch('req', function (req) { - if (req) { - const s = req.method + ' ' + req.endpoint + '\n' + (req.data || ''); - viewer.setValue(s); - viewer.clearSelection(); - } else { - viewer.getSession().setValue( - i18n.translate('console.historyPage.noHistoryTextMessage', { defaultMessage: 'No history available' }) - ); - } - }); - - $scope.$on('$destroy', function () { - viewer.destroy(); - }); - } - }; - }); From 1969e6696828ce6cba7f29778abcd5702f2193fc Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 29 Aug 2019 20:13:59 +0200 Subject: [PATCH 09/35] Lots of fixes Also moved over and integrated remaining three react components --- .../public/app}/components/editor_example.tsx | 4 +- .../public/app}/components/help_panel.tsx | 0 .../np_ready/public/app/components/index.ts | 3 + .../public/app}/components/settings_modal.tsx | 11 +- .../public/app}/components/welcome_panel.tsx | 0 .../public/app/constants}/help_example.txt | 0 .../public/app/containers/editor/index.ts | 2 +- .../editor/legacy/console_editor.tsx | 249 +++++++++--------- .../console_history/console_history.tsx | 47 ++-- .../legacy/console_history/history_viewer.tsx | 2 +- .../app/containers/editor/legacy/index.ts | 2 +- .../public/app/containers/main/get_top_nav.ts | 15 +- .../public/app/containers/main/main.tsx | 117 ++++++-- .../public/app/context/app_context.tsx | 9 +- .../public/np_ready/public/app/index.tsx | 15 +- .../np_ready/public/app/services/index.ts | 3 +- .../editor/legacy => services}/settings.ts | 16 +- .../src/components/dev_tools_settings.ts | 30 --- .../src/helpers/help_show_panel.tsx | 47 ---- .../src/helpers/settings_show_modal.tsx | 103 -------- .../src/helpers/welcome_show_panel.tsx | 53 ---- .../console/public/quarantined/src/input.js | 10 +- .../public/quarantined/src/mappings.js | 9 +- .../console/public/quarantined/src/output.js | 14 +- 24 files changed, 322 insertions(+), 439 deletions(-) rename src/legacy/core_plugins/console/public/{quarantined/src => np_ready/public/app}/components/editor_example.tsx (90%) rename src/legacy/core_plugins/console/public/{quarantined/src => np_ready/public/app}/components/help_panel.tsx (100%) rename src/legacy/core_plugins/console/public/{quarantined/src => np_ready/public/app}/components/settings_modal.tsx (97%) rename src/legacy/core_plugins/console/public/{quarantined/src => np_ready/public/app}/components/welcome_panel.tsx (100%) rename src/legacy/core_plugins/console/public/{quarantined/src/components => np_ready/public/app/constants}/help_example.txt (100%) rename src/legacy/core_plugins/console/public/np_ready/public/app/{containers/editor/legacy => services}/settings.ts (92%) delete mode 100644 src/legacy/core_plugins/console/public/quarantined/src/components/dev_tools_settings.ts delete mode 100644 src/legacy/core_plugins/console/public/quarantined/src/helpers/help_show_panel.tsx delete mode 100644 src/legacy/core_plugins/console/public/quarantined/src/helpers/settings_show_modal.tsx delete mode 100644 src/legacy/core_plugins/console/public/quarantined/src/helpers/welcome_show_panel.tsx diff --git a/src/legacy/core_plugins/console/public/quarantined/src/components/editor_example.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/components/editor_example.tsx similarity index 90% rename from src/legacy/core_plugins/console/public/quarantined/src/components/editor_example.tsx rename to src/legacy/core_plugins/console/public/np_ready/public/app/components/editor_example.tsx index 99309d7b8549c..6f0acd4ecc0ba 100644 --- a/src/legacy/core_plugins/console/public/quarantined/src/components/editor_example.tsx +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/components/editor_example.tsx @@ -19,10 +19,10 @@ import React, { useEffect } from 'react'; // @ts-ignore -import exampleText from 'raw-loader!./help_example.txt'; +import exampleText from 'raw-loader!../constants/help_example.txt'; import $ from 'jquery'; // @ts-ignore -import SenseEditor from '../sense_editor/editor'; +import SenseEditor from '../../../../quarantined/src/sense_editor/editor'; interface EditorExampleProps { panel: string; diff --git a/src/legacy/core_plugins/console/public/quarantined/src/components/help_panel.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/components/help_panel.tsx similarity index 100% rename from src/legacy/core_plugins/console/public/quarantined/src/components/help_panel.tsx rename to src/legacy/core_plugins/console/public/np_ready/public/app/components/help_panel.tsx diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/components/index.ts b/src/legacy/core_plugins/console/public/np_ready/public/app/components/index.ts index 28b8716a03c15..0f109e99b0b39 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/components/index.ts +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/components/index.ts @@ -20,3 +20,6 @@ export * from './split_panel'; export { TopNavMenuItem, TopNavMenu } from './top_nav_menu'; export { ConsoleMenu } from './console_menu'; +export { WelcomePanel } from './welcome_panel'; +export { AutocompleteOptions, DevToolsSettingsModal } from './settings_modal'; +export { HelpPanel } from './help_panel'; diff --git a/src/legacy/core_plugins/console/public/quarantined/src/components/settings_modal.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/components/settings_modal.tsx similarity index 97% rename from src/legacy/core_plugins/console/public/quarantined/src/components/settings_modal.tsx rename to src/legacy/core_plugins/console/public/np_ready/public/app/components/settings_modal.tsx index f3ec577e43b71..d4e2ffdfe2022 100644 --- a/src/legacy/core_plugins/console/public/quarantined/src/components/settings_modal.tsx +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/components/settings_modal.tsx @@ -35,7 +35,8 @@ import { EuiOverlayMask, EuiSwitch, } from '@elastic/eui'; -import { DevToolsSettings } from './dev_tools_settings'; + +import { DevToolsSettings } from '../services'; export type AutocompleteOptions = 'fields' | 'indices' | 'templates'; @@ -145,11 +146,9 @@ export function DevToolsSettingsModal(props: Props) { onClick={() => { // Only refresh the currently selected settings. props.refreshAutocompleteSettings({ - autocomplete: { - fields, - indices, - templates, - }, + fields, + indices, + templates, }); }} > diff --git a/src/legacy/core_plugins/console/public/quarantined/src/components/welcome_panel.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/components/welcome_panel.tsx similarity index 100% rename from src/legacy/core_plugins/console/public/quarantined/src/components/welcome_panel.tsx rename to src/legacy/core_plugins/console/public/np_ready/public/app/components/welcome_panel.tsx diff --git a/src/legacy/core_plugins/console/public/quarantined/src/components/help_example.txt b/src/legacy/core_plugins/console/public/np_ready/public/app/constants/help_example.txt similarity index 100% rename from src/legacy/core_plugins/console/public/quarantined/src/components/help_example.txt rename to src/legacy/core_plugins/console/public/np_ready/public/app/constants/help_example.txt diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/index.ts b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/index.ts index 72565bde33f3c..4a6d1b6b53c9f 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/index.ts +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/index.ts @@ -17,4 +17,4 @@ * under the License. */ -export { ConsoleEditor, ConsoleHistory } from './legacy'; +export { ConsoleEditor, ConsoleHistory, MemoConsoleEditor } from './legacy'; diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_editor.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_editor.tsx index f79ec75d8391a..721c8e45be2a4 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_editor.tsx +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_editor.tsx @@ -37,7 +37,6 @@ import { Panel, PanelsContainer } from '../../../components/split_panel'; import { useUIAceKeyboardMode } from './use_ui_ace_keyboard_mode'; import { useAppContext } from '../../../context'; import { installEditorsResizeChecker } from './install_console_resize_checker'; -import { Settings } from './settings'; const PANEL_MIN_WIDTH = '100px'; @@ -53,139 +52,131 @@ export interface ConsoleEditorProps { docLinkVersion: string; onPanelWidthChange: (widths: number[]) => void; onEditorsReady: () => void; - settings: Settings; initialInputPanelWidth: number; initialOutputPanelWidth: number; } -export const ConsoleEditor = React.memo( - ({ - onPanelWidthChange, - docLinkVersion, - initialInputPanelWidth, - initialOutputPanelWidth, - onEditorsReady, - settings, - }: ConsoleEditorProps) => { - const { history, ResizeChecker } = useAppContext(); - - const containerRef = useRef(null); - const editorRef = useRef(null); - const outputRef = useRef(null); - const actionsRef = useRef(null); - - const [, setLastRequestTimestamp] = useState(null as any); - const [editor, setEditor] = useState(null as any); - const [, setOutput] = useState(null as any); - const [maybeTextArea, setTextArea] = useState(null); - - const sendCurrentRequest = () => { - editor.focus(); - editor.sendCurrentRequestToES(() => { - // History watches this value and will re-render itself when it changes, so that - // the list of requests stays up-to-date as new requests are sent. - setLastRequestTimestamp(new Date().getTime()); - }); - return false; +export function ConsoleEditor({ + onPanelWidthChange, + docLinkVersion, + initialInputPanelWidth, + initialOutputPanelWidth, + onEditorsReady, +}: ConsoleEditorProps) { + const { + services: { history, settings }, + ResizeChecker, + } = useAppContext(); + + const containerRef = useRef(null); + const editorRef = useRef(null); + const outputRef = useRef(null); + const actionsRef = useRef(null); + + const [, setLastRequestTimestamp] = useState(null as any); + const [editor, setEditor] = useState(null as any); + const [, setOutput] = useState(null as any); + const [maybeTextArea, setTextArea] = useState(null); + + const sendCurrentRequest = () => { + editor.focus(); + editor.sendCurrentRequestToES(() => { + // History watches this value and will re-render itself when it changes, so that + // the list of requests stays up-to-date as new requests are sent. + setLastRequestTimestamp(new Date().getTime()); + }); + return false; + }; + + useEffect(() => { + const editor$ = $(editorRef.current!); + const output$ = $(outputRef.current!); + const actions$ = $(actionsRef.current!); + + const outputEditor = initializeOutput(output$, settings); + const inputEditor = initializeInput(editor$, actions$, outputEditor, history, settings); + + settings.registerOutput(outputEditor); + settings.registerInput(inputEditor); + history.setEditor(inputEditor); + + init(inputEditor, outputEditor, history); + + const subscriptions = [ + installEditorsResizeChecker(ResizeChecker, containerRef.current!, inputEditor, outputEditor), + installEditorsResizeChecker(ResizeChecker, editorRef.current!, inputEditor), + installEditorsResizeChecker(ResizeChecker, outputRef.current!, outputEditor), + ]; + + const session = inputEditor.getSession(); + session.getSelection().on('changeCursor', () => { + // Fire and forget + getDocumentation(inputEditor, docLinkVersion); + }); + + setTextArea(editorRef.current!.querySelector('textarea')); + setOutput(outputEditor); + setEditor(inputEditor); + onEditorsReady(); + + return () => { + subscriptions.map(unsubscribe => unsubscribe()); }; - - useEffect(() => { - const editor$ = $(editorRef.current!); - const output$ = $(outputRef.current!); - const actions$ = $(actionsRef.current!); - - const outputEditor = initializeOutput(output$); - const inputEditor = initializeInput(editor$, actions$, outputEditor, history); - - settings.registerOutput(outputEditor); - settings.registerInput(inputEditor); - history.setEditor(inputEditor); - - init(inputEditor, outputEditor, history); - - const subscriptions = [ - installEditorsResizeChecker( - ResizeChecker, - containerRef.current!, - inputEditor, - outputEditor - ), - installEditorsResizeChecker(ResizeChecker, editorRef.current!, inputEditor), - installEditorsResizeChecker(ResizeChecker, outputRef.current!, outputEditor), - ]; - - const session = inputEditor.getSession(); - session.getSelection().on('changeCursor', () => { - // Fire and forget - getDocumentation(inputEditor, docLinkVersion); - }); - - setTextArea(editorRef.current!.querySelector('textarea')); - setOutput(outputEditor); - setEditor(inputEditor); - onEditorsReady(); - - return () => { - subscriptions.map(unsubscribe => unsubscribe()); - }; - }, []); - - useUIAceKeyboardMode(maybeTextArea); - - return ( -
    - - -
    -
    -
      -
      - + + +
      +
      +
        +
        + + - - { - editor.getRequestsAsCURL(cb); - }} - getDocumentation={() => { - return getDocumentation(editor, docLinkVersion); - }} - autoIndent={(event: any) => { - autoIndent(editor, event); - }} - /> -
        -
        + + + + { + editor.getRequestsAsCURL(cb); + }} + getDocumentation={() => { + return getDocumentation(editor, docLinkVersion); + }} + autoIndent={(event: any) => { + autoIndent(editor, event); + }} + />
        +
        - - -
        -
        -
        - - -
        - ); - } -); +
      + + +
      +
      +
      + + +
      + ); +} + +export const MemoConsoleEditor = React.memo(ConsoleEditor); diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_history/console_history.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_history/console_history.tsx index 1145598392c0e..d7d847457fb8f 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_history/console_history.tsx +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_history/console_history.tsx @@ -25,31 +25,39 @@ import { keyCodes } from '@elastic/eui'; import { useAppContext } from '../../../../context'; import { HistoryViewer } from './history_viewer'; -import { Settings } from '../settings'; interface Props { - settings: Settings; close: () => void; } -export function ConsoleHistory({ close, settings }: Props) { - const { history, ResizeChecker } = useAppContext(); +export function ConsoleHistory({ close }: Props) { + const { + services: { history, settings }, + ResizeChecker, + } = useAppContext(); + const [reqs, setReqs] = useState([]); const [selectedIndex, setSelectedIndex] = useState(0); const selectedReq = useRef(null); const viewingReq = useRef(null); - const describeReq = memoize((req: any) => { - const endpoint = req.endpoint; - const date = moment(req.time); + const [describeReq] = useState(() => { + const _describeReq = (req: any) => { + const endpoint = req.endpoint; + const date = moment(req.time); + + let formattedDate = date.format('MMM D'); + if (date.diff(moment(), 'days') > -7) { + formattedDate = date.fromNow(); + } - let formattedDate = date.format('MMM D'); - if (date.diff(moment(), 'days') > -7) { - formattedDate = date.fromNow(); - } + return `${endpoint} (${formattedDate})`; + }; - return `${endpoint} (${formattedDate})`; + (_describeReq as any).cache = new WeakMap(); + + return memoize(_describeReq); }); const initialize = () => { @@ -81,22 +89,24 @@ export function ConsoleHistory({ close, settings }: Props) { {i18n.translate('console.historyPage.pageTitle', { defaultMessage: 'History' })}
      -
        { if (ev.keyCode === keyCodes.ENTER) { restore(); return; } + let currentIdx = selectedIndex; + if (ev.keyCode === keyCodes.UP) { ev.preventDefault(); - setSelectedIndex(selectedIndex - 1); + --currentIdx; } else if (ev.keyCode === keyCodes.DOWN) { ev.preventDefault(); - setSelectedIndex(selectedIndex + 1); + ++currentIdx; } - const nextSelectedIndex = Math.min(Math.max(0, selectedIndex), reqs.length - 1); + const nextSelectedIndex = Math.min(Math.max(0, currentIdx), reqs.length - 1); selectedReq.current = reqs[nextSelectedIndex]; viewingReq.current = reqs[nextSelectedIndex]; @@ -110,6 +120,7 @@ export function ConsoleHistory({ close, settings }: Props) { aria-label="{{:: 'console.historyPage.requestListAriaLabel' | i18n: { defaultMessage: 'History of sent requests' } }}" > {reqs.map((req, idx) => { + const reqDescription = describeReq(req); const isSelected = viewingReq.current === req; return ( // Ignore a11y issues on li's @@ -131,11 +142,11 @@ export function ConsoleHistory({ close, settings }: Props) { onDoubleClick={() => restore(req)} aria-label={i18n.translate('console.historyPage.itemOfRequestListAriaLabel', { defaultMessage: 'Request: {historyItem}', - values: { historyItem: describeReq(req) }, + values: { historyItem: reqDescription }, })} aria-selected={isSelected} > - {describeReq(req)} + {reqDescription} diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_history/history_viewer.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_history/history_viewer.tsx index e60df257a436f..58ddccc377574 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_history/history_viewer.tsx +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_history/history_viewer.tsx @@ -21,7 +21,7 @@ import React, { useEffect, useRef } from 'react'; import { i18n } from '@kbn/i18n'; import $ from 'jquery'; -import { Settings } from '../settings'; +import { Settings } from '../../../../services'; import { installEditorsResizeChecker } from '../install_console_resize_checker'; // @ts-ignore diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.ts b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.ts index d7ed410f4bf8d..9b348ceb384bd 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.ts +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.ts @@ -17,5 +17,5 @@ * under the License. */ -export { ConsoleEditor } from './console_editor'; +export { ConsoleEditor, MemoConsoleEditor } from './console_editor'; export { ConsoleHistory } from './console_history'; diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main/get_top_nav.ts b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main/get_top_nav.ts index ba96e321f81db..476cb47e6b9b2 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main/get_top_nav.ts +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main/get_top_nav.ts @@ -25,10 +25,12 @@ import { i18n } from '@kbn/i18n'; // import { showHelpPanel } from './help_show_panel'; interface Props { - toggleHistory: () => void; + onClickHistory: () => void; + onClickSettings: () => void; + onClickHelp: () => void; } -export function getTopNavConfig({ toggleHistory }: Props) { +export function getTopNavConfig({ onClickHistory, onClickSettings, onClickHelp }: Props) { return [ { id: 'history', @@ -39,7 +41,7 @@ export function getTopNavConfig({ toggleHistory }: Props) { defaultMessage: 'History', }), run: () => { - toggleHistory(); + onClickHistory(); }, testId: 'consoleHistoryButton', }, @@ -52,7 +54,7 @@ export function getTopNavConfig({ toggleHistory }: Props) { defaultMessage: 'Settings', }), run: () => { - // showSettingsModal(); + onClickSettings(); }, testId: 'consoleSettingsButton', }, @@ -65,10 +67,7 @@ export function getTopNavConfig({ toggleHistory }: Props) { defaultMessage: 'Help', }), run: () => { - // const hideHelpPanel = showHelpPanel(); - // $scope.$on('$destroy', () => { - // hideHelpPanel(); - // }); + onClickHelp(); }, testId: 'consoleHelpButton', }, diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main/main.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main/main.tsx index a41955f7c7949..0eb8743c4c380 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main/main.tsx +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main/main.tsx @@ -17,26 +17,43 @@ * under the License. */ -import React, { useCallback, useRef, useState } from 'react'; +import React, { useCallback, useState } from 'react'; import { debounce } from 'lodash'; -import { TopNavMenu } from '../../components'; -import { ConsoleEditor, ConsoleHistory } from '../editor'; +import { + AutocompleteOptions, + TopNavMenu, + WelcomePanel, + DevToolsSettingsModal, + HelpPanel, +} from '../../components'; +import { MemoConsoleEditor, ConsoleHistory } from '../editor'; import { useAppContext } from '../../context'; -import { StorageKeys } from '../../services/storage'; +import { StorageKeys, DevToolsSettings } from '../../services'; + +// @ts-ignore +import mappings from '../../../../../quarantined/src/mappings'; -import { createSettings } from '../editor/legacy/settings'; import { getTopNavConfig } from './get_top_nav'; const INITIAL_PANEL_WIDTH = 50; export function Main() { - const { storage, docLinkVersion } = useAppContext(); + const { + services: { storage, settings }, + docLinkVersion, + } = useAppContext(); - const settingsRef = useRef(createSettings({ storage })); const [editorReady, setEditorReady] = useState(false); - const [showingHistory, setShowingHistory] = useState(false); + const [showWelcome, setShowWelcomePanel] = useState( + () => storage.get('version_welcome_shown') !== '@@SENSE_REVISION' + ); + + const [showingHistory, setShowHistory] = useState(false); + const [showSettings, setShowSettings] = useState(false); + const [showHelp, setShowHelp] = useState(false); + const [firstPanelWidth, secondPanelWidth] = storage.get(StorageKeys.WIDTH, [ INITIAL_PANEL_WIDTH, INITIAL_PANEL_WIDTH, @@ -56,26 +73,90 @@ export function Main() { const onEditorReady = useCallback(() => setEditorReady(true), []); const renderConsoleHistory = () => { - return editorReady ? ( - setShowingHistory(false)} /> - ) : null; + return editorReady ? setShowHistory(false)} /> : null; + }; + + const refreshAutocompleteSettings = (selectedSettings: any) => { + mappings.retrieveAutoCompleteInfo(selectedSettings); + }; + + const getAutocompleteDiff = (newSettings: DevToolsSettings, prevSettings: DevToolsSettings) => { + return Object.keys(newSettings.autocomplete).filter(key => { + // @ts-ignore + return prevSettings.autocomplete[key] !== newSettings.autocomplete[key]; + }); + }; + + const fetchAutocompleteSettingsIfNeeded = ( + newSettings: DevToolsSettings, + prevSettings: DevToolsSettings + ) => { + // We'll only retrieve settings if polling is on. The expectation here is that if the user + // disables polling it's because they want manual control over the fetch request (possibly + // because it's a very expensive request given their cluster and bandwidth). In that case, + // they would be unhappy with any request that's sent automatically. + if (newSettings.polling) { + const autocompleteDiff = getAutocompleteDiff(newSettings, prevSettings); + + const isSettingsChanged = autocompleteDiff.length > 0; + const isPollingChanged = prevSettings.polling !== newSettings.polling; + + if (isSettingsChanged) { + // If the user has changed one of the autocomplete settings, then we'll fetch just the + // ones which have changed. + const changedSettings: any = autocompleteDiff.reduce( + (changedSettingsAccum: any, setting: string): any => { + changedSettingsAccum[setting] = + newSettings.autocomplete[setting as AutocompleteOptions]; + return changedSettingsAccum; + }, + {} + ); + mappings.retrieveAutoCompleteInfo(changedSettings.autocomplete); + } else if (isPollingChanged) { + // If the user has turned polling on, then we'll fetch all selected autocomplete settings. + mappings.retrieveAutoCompleteInfo(); + } + } + }; + + const onSaveSettings = async (newSettings: DevToolsSettings) => { + const prevSettings = settings.getCurrentSettings(); + settings.updateSettings(newSettings); + fetchAutocompleteSettingsIfNeeded(newSettings, prevSettings); + setShowSettings(false); }; return ( <> - {showingHistory ? ( - renderConsoleHistory() - ) : ( - setShowingHistory(true) })} /> - )} - setShowHistory(!showingHistory), + onClickSettings: () => setShowSettings(true), + onClickHelp: () => setShowHelp(!showHelp), + })} + /> + {showingHistory ? renderConsoleHistory() : null} + + + {showWelcome ? setShowWelcomePanel(false)} /> : null} + + {showSettings ? ( + setShowSettings(false)} + refreshAutocompleteSettings={refreshAutocompleteSettings} + settings={settings.getCurrentSettings()} + /> + ) : null} + + {showHelp ? setShowHelp(false)} /> : null} ); } diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/context/app_context.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/context/app_context.tsx index 35c88f7681fdf..f7040fcc3234e 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/context/app_context.tsx +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/context/app_context.tsx @@ -18,11 +18,14 @@ */ import React, { createContext, useContext } from 'react'; -import { History, Storage } from '../services'; +import { History, Storage, Settings } from '../services'; interface ContextValue { - history: History; - storage: Storage; + services: { + history: History; + storage: Storage; + settings: Settings; + }; docLinkVersion: string; ResizeChecker: any; } diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/index.tsx b/src/legacy/core_plugins/console/public/np_ready/public/app/index.tsx index af13dd3900015..8b80bd439f775 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/index.tsx +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/index.tsx @@ -20,20 +20,29 @@ import React from 'react'; import { AppContextProvider } from './context'; import { Main } from './containers'; -import { createStorage, createHistory } from './services'; +import { createStorage, createHistory, createSettings, Settings } from './services'; + +let settingsRef: Settings; +export function legacyBackDoorToSettings() { + return settingsRef; +} export function boot(deps: { docLinkVersion: string; I18nContext: any; ResizeChecker: any }) { const { I18nContext, ResizeChecker } = deps; + const storage = createStorage({ engine: window.localStorage, prefix: 'sense:', }); - const history = createHistory({ storage }); + const settings = createSettings({ storage }); + settingsRef = settings; return ( - +
        diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/services/index.ts b/src/legacy/core_plugins/console/public/np_ready/public/app/services/index.ts index ce6f37010f7e3..c54cafab7f6bc 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/services/index.ts +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/services/index.ts @@ -18,4 +18,5 @@ */ export { createHistory, History } from './history'; -export { createStorage, Storage } from './storage'; +export { createStorage, Storage, StorageKeys } from './storage'; +export { createSettings, Settings, DevToolsSettings } from './settings'; diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/settings.ts b/src/legacy/core_plugins/console/public/np_ready/public/app/services/settings.ts similarity index 92% rename from src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/settings.ts rename to src/legacy/core_plugins/console/public/np_ready/public/app/services/settings.ts index efd2134878a6c..c5cd19b32bfdc 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/settings.ts +++ b/src/legacy/core_plugins/console/public/np_ready/public/app/services/settings.ts @@ -17,7 +17,19 @@ * under the License. */ -import { Storage } from '../../../services'; +import { Storage } from '.'; + +export interface DevToolsSettings { + fontSize: number; + wrapMode: boolean; + autocomplete: { + fields: boolean; + indices: boolean; + templates: boolean; + }; + polling: boolean; + tripleQuotes: boolean; +} export class Settings { private input: any | null = null; @@ -100,7 +112,7 @@ export class Settings { } } - getCurrentSettings() { + getCurrentSettings(): DevToolsSettings { return { autocomplete: this.getAutocomplete(), wrapMode: this.getWrapMode(), diff --git a/src/legacy/core_plugins/console/public/quarantined/src/components/dev_tools_settings.ts b/src/legacy/core_plugins/console/public/quarantined/src/components/dev_tools_settings.ts deleted file mode 100644 index f3fd1442ca90f..0000000000000 --- a/src/legacy/core_plugins/console/public/quarantined/src/components/dev_tools_settings.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -export interface DevToolsSettings { - fontSize: number; - wrapMode: boolean; - autocomplete: { - fields: boolean; - indices: boolean; - templates: boolean; - }; - polling: boolean; - tripleQuotes: boolean; -} diff --git a/src/legacy/core_plugins/console/public/quarantined/src/helpers/help_show_panel.tsx b/src/legacy/core_plugins/console/public/quarantined/src/helpers/help_show_panel.tsx deleted file mode 100644 index a57fc92e17141..0000000000000 --- a/src/legacy/core_plugins/console/public/quarantined/src/helpers/help_show_panel.tsx +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import React from 'react'; -import ReactDOM from 'react-dom'; -import { I18nContext } from 'ui/i18n'; -import { HelpPanel } from '../components/help_panel'; - -let isOpen = false; - -export function showHelpPanel(): () => void { - const onClose = () => { - if (!container) return; - ReactDOM.unmountComponentAtNode(container); - isOpen = false; - }; - - const container = document.getElementById('consoleHelpPanel'); - - if (container && !isOpen) { - isOpen = true; - const element = ( - - - - ); - ReactDOM.render(element, container); - } - - return onClose; -} diff --git a/src/legacy/core_plugins/console/public/quarantined/src/helpers/settings_show_modal.tsx b/src/legacy/core_plugins/console/public/quarantined/src/helpers/settings_show_modal.tsx deleted file mode 100644 index c4f36d836dfda..0000000000000 --- a/src/legacy/core_plugins/console/public/quarantined/src/helpers/settings_show_modal.tsx +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { I18nContext } from 'ui/i18n'; -import React from 'react'; -import ReactDOM from 'react-dom'; -import { DevToolsSettingsModal, AutocompleteOptions } from '../components/settings_modal'; -import { DevToolsSettings } from '../components/dev_tools_settings'; - -// @ts-ignore -import mappings from '../mappings'; -// @ts-ignore -import { getCurrentSettings, updateSettings } from '../settings'; - -export function showSettingsModal() { - const container = document.getElementById('consoleSettingsModal'); - const curSettings = getCurrentSettings(); - - const refreshAutocompleteSettings = (selectedSettings: any) => { - mappings.retrieveAutoCompleteInfo(selectedSettings); - }; - - const closeModal = () => { - if (!container) return; - ReactDOM.unmountComponentAtNode(container); - container.innerHTML = ''; - }; - - const getAutocompleteDiff = (newSettings: DevToolsSettings, prevSettings: DevToolsSettings) => { - return Object.keys(newSettings.autocomplete).filter(key => { - // @ts-ignore - return prevSettings.autocomplete[key] !== newSettings.autocomplete[key]; - }); - }; - - const fetchAutocompleteSettingsIfNeeded = ( - newSettings: DevToolsSettings, - prevSettings: DevToolsSettings - ) => { - // We'll only retrieve settings if polling is on. The expectation here is that if the user - // disables polling it's because they want manual control over the fetch request (possibly - // because it's a very expensive request given their cluster and bandwidth). In that case, - // they would be unhappy with any request that's sent automatically. - if (newSettings.polling) { - const autocompleteDiff = getAutocompleteDiff(newSettings, prevSettings); - - const isSettingsChanged = autocompleteDiff.length > 0; - const isPollingChanged = prevSettings.polling !== newSettings.polling; - - if (isSettingsChanged) { - // If the user has changed one of the autocomplete settings, then we'll fetch just the - // ones which have changed. - const changedSettings: any = autocompleteDiff.reduce( - (changedSettingsAccum: any, setting: string): any => { - changedSettingsAccum[setting] = - newSettings.autocomplete[setting as AutocompleteOptions]; - return changedSettingsAccum; - }, - {} - ); - mappings.retrieveAutoCompleteInfo(changedSettings); - } else if (isPollingChanged) { - // If the user has turned polling on, then we'll fetch all selected autocomplete settings. - mappings.retrieveAutoCompleteInfo(); - } - } - }; - - const onSave = async (newSettings: DevToolsSettings) => { - const prevSettings = getCurrentSettings(); - updateSettings(newSettings); - fetchAutocompleteSettingsIfNeeded(newSettings, prevSettings); - closeModal(); - }; - - const element = ( - - - - ); - ReactDOM.render(element, container); -} diff --git a/src/legacy/core_plugins/console/public/quarantined/src/helpers/welcome_show_panel.tsx b/src/legacy/core_plugins/console/public/quarantined/src/helpers/welcome_show_panel.tsx deleted file mode 100644 index 60a66babef6e6..0000000000000 --- a/src/legacy/core_plugins/console/public/quarantined/src/helpers/welcome_show_panel.tsx +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import React from 'react'; -import ReactDOM from 'react-dom'; -import { I18nContext } from 'ui/i18n'; -import { WelcomePanel } from '../components/welcome_panel'; -// @ts-ignore -import storage from '../storage'; - -let isOpen = false; - -export function showWelcomePanel(): () => void { - const onClose = () => { - if (!container) return; - ReactDOM.unmountComponentAtNode(container); - isOpen = false; - }; - - const onDismiss = () => { - storage.set('version_welcome_shown', '@@SENSE_REVISION'); - onClose(); - }; - - const container = document.getElementById('consoleWelcomePanel'); - if (container && !isOpen) { - isOpen = true; - const element = ( - - - - ); - ReactDOM.render(element, container); - } - - return onClose; -} diff --git a/src/legacy/core_plugins/console/public/quarantined/src/input.js b/src/legacy/core_plugins/console/public/quarantined/src/input.js index a6de0b994b77c..93bab05f3e9b9 100644 --- a/src/legacy/core_plugins/console/public/quarantined/src/input.js +++ b/src/legacy/core_plugins/console/public/quarantined/src/input.js @@ -22,12 +22,18 @@ require('brace/ext/searchbox'); import Autocomplete from './autocomplete'; import mappings from './mappings'; const SenseEditor = require('./sense_editor/editor'); -const settings = require('./settings'); const utils = require('./utils'); const es = require('./es'); let input; -export function initializeInput($el, $actionsEl, output, history, openDocumentation = () => {}) { +export function initializeInput( + $el, + $actionsEl, + output, + history, + settings, + openDocumentation = () => {} +) { input = new SenseEditor($el); input.autocomplete = new Autocomplete(input); diff --git a/src/legacy/core_plugins/console/public/quarantined/src/mappings.js b/src/legacy/core_plugins/console/public/quarantined/src/mappings.js index 51864333ef1fe..dacdc79562064 100644 --- a/src/legacy/core_plugins/console/public/quarantined/src/mappings.js +++ b/src/legacy/core_plugins/console/public/quarantined/src/mappings.js @@ -17,10 +17,11 @@ * under the License. */ +import { legacyBackDoorToSettings } from '../../np_ready/public/app'; + const $ = require('jquery'); const _ = require('lodash'); const es = require('./es'); -const settings = require('./settings'); // NOTE: If this value ever changes to be a few seconds or less, it might introduce flakiness // due to timing issues in our app.js tests. @@ -257,7 +258,7 @@ function clear() { } function retrieveSettings(settingsKey, settingsToRetrieve) { - const currentSettings = settings.getAutocomplete(); + const currentSettings = legacyBackDoorToSettings().getAutocomplete(); const settingKeyToPathMap = { fields: '_mapping', indices: '_aliases', @@ -289,7 +290,7 @@ function retrieveSettings(settingsKey, settingsToRetrieve) { // unchanged alone (both selected and unselected). // 3. Poll: Use saved. Fetch selected. Ignore unselected. -function retrieveAutoCompleteInfo(settingsToRetrieve = settings.getAutocomplete()) { +function retrieveAutoCompleteInfo(settingsToRetrieve = legacyBackDoorToSettings().getAutocomplete()) { if (pollTimeoutId) { clearTimeout(pollTimeoutId); } @@ -329,7 +330,7 @@ function retrieveAutoCompleteInfo(settingsToRetrieve = settings.getAutocomplete( pollTimeoutId = setTimeout(() => { // This looks strange/inefficient, but it ensures correct behavior because we don't want to send // a scheduled request if the user turns off polling. - if (settings.getPolling()) { + if (legacyBackDoorToSettings().getPolling()) { retrieveAutoCompleteInfo(); } }, POLL_INTERVAL); diff --git a/src/legacy/core_plugins/console/public/quarantined/src/output.js b/src/legacy/core_plugins/console/public/quarantined/src/output.js index 1c2781e13333e..d5ffe736e2dbe 100644 --- a/src/legacy/core_plugins/console/public/quarantined/src/output.js +++ b/src/legacy/core_plugins/console/public/quarantined/src/output.js @@ -19,19 +19,18 @@ import _ from 'lodash'; const ace = require('brace'); -const settings = require('./settings'); const OutputMode = require('./sense_editor/mode/output'); const smartResize = require('./smart_resize'); let output; -export function initializeOutput($el) { +export function initializeOutput($el, settings) { output = ace.acequire('ace/ace').edit($el[0]); const outputMode = new OutputMode.Mode(); output.$blockScrolling = Infinity; output.resize = smartResize(output); - output.update = function (val, mode, cb) { + output.update = (val, mode, cb) => { if (typeof mode === 'function') { cb = mode; mode = void 0; @@ -39,14 +38,14 @@ export function initializeOutput($el) { const session = output.getSession(); - session.setMode(val ? (mode || outputMode) : 'ace/mode/text'); + session.setMode(val ? mode || outputMode : 'ace/mode/text'); session.setValue(val); if (typeof cb === 'function') { setTimeout(cb); } }; - output.append = function (val, foldPrevious, cb) { + output.append = (val, foldPrevious, cb) => { if (typeof foldPrevious === 'function') { cb = foldPrevious; foldPrevious = true; @@ -68,12 +67,13 @@ export function initializeOutput($el) { output.$el = $el; - (function (session) { + // eslint-disable-next-line + (function setupSession(session) { session.setMode('ace/mode/text'); session.setFoldStyle('markbeginend'); session.setTabSize(2); session.setUseWrapMode(true); - }(output.getSession())); + })(output.getSession()); output.setShowPrintMargin(false); output.setReadOnly(true); From d819528646a89a3d5446d95b23aee219a73b0994 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Fri, 30 Aug 2019 13:22:14 +0200 Subject: [PATCH 10/35] Moved a lot of files around again, tidied up NP set up --- src/legacy/core_plugins/console/index.ts | 4 +- .../console/{public => }/np_ready/kibana.json | 0 .../public/app/components/console_menu.tsx | 0 .../public/app/components/editor_example.tsx | 2 +- .../public/app/components/help_panel.tsx | 0 .../np_ready/public/app/components/index.ts | 0 .../public/app/components/settings_modal.tsx | 0 .../split_panel/components/resizer.tsx | 0 .../split_panel/containers/panel.tsx | 0 .../containers/panel_container.tsx | 0 .../app/components/split_panel/context.tsx | 0 .../app/components/split_panel/index.ts | 0 .../app/components/split_panel/registry.ts | 0 .../public/app/components/top_nav_menu.tsx | 0 .../public/app/components/welcome_panel.tsx | 0 .../public/app/constants/help_example.txt | 0 .../public/app/containers/editor/index.ts | 0 .../editor/legacy/console_editor.tsx | 6 +-- .../console_history/console_history.tsx | 0 .../legacy/console_history/history_viewer.tsx | 2 +- .../editor/legacy/console_history/index.ts | 0 .../editor/legacy/console_menu_actions.ts | 2 +- .../app/containers/editor/legacy/index.ts | 0 .../legacy/install_console_resize_checker.ts | 0 .../legacy/use_ui_ace_keyboard_mode.tsx | 0 .../np_ready/public/app/containers/index.ts | 0 .../public/app/containers/main/get_top_nav.ts | 0 .../public/app/containers/main/index.ts | 0 .../public/app/containers/main/main.tsx | 2 +- .../public/app/context/app_context.tsx | 0 .../np_ready/public/app/context/index.ts | 0 .../np_ready/public/app/index.tsx | 0 .../{public => }/np_ready/public/app/logo.svg | 0 .../np_ready/public/app/services/history.ts | 0 .../np_ready/public/app/services/index.ts | 0 .../np_ready/public/app/services/settings.ts | 0 .../np_ready/public/app/services/storage.ts | 0 .../{public => }/np_ready/public/index.ts | 2 +- .../{public => }/np_ready/public/legacy.ts | 30 ++++++++------ .../{public => }/np_ready/public/plugin.ts | 10 +++-- .../console/np_ready/server/.gitkeep | 0 .../core_plugins/console/public/README.md | 7 ++-- .../console/public/quarantined/index.html | 41 ------------------- .../public/quarantined/src/mappings.js | 2 +- 44 files changed, 40 insertions(+), 70 deletions(-) rename src/legacy/core_plugins/console/{public => }/np_ready/kibana.json (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/components/console_menu.tsx (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/components/editor_example.tsx (94%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/components/help_panel.tsx (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/components/index.ts (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/components/settings_modal.tsx (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/components/split_panel/components/resizer.tsx (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/components/split_panel/containers/panel.tsx (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/components/split_panel/containers/panel_container.tsx (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/components/split_panel/context.tsx (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/components/split_panel/index.ts (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/components/split_panel/registry.ts (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/components/top_nav_menu.tsx (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/components/welcome_panel.tsx (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/constants/help_example.txt (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/containers/editor/index.ts (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/containers/editor/legacy/console_editor.tsx (96%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/containers/editor/legacy/console_history/console_history.tsx (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/containers/editor/legacy/console_history/history_viewer.tsx (95%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/containers/editor/legacy/console_history/index.ts (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/containers/editor/legacy/console_menu_actions.ts (94%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/containers/editor/legacy/index.ts (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/containers/editor/legacy/install_console_resize_checker.ts (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/containers/index.ts (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/containers/main/get_top_nav.ts (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/containers/main/index.ts (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/containers/main/main.tsx (98%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/context/app_context.tsx (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/context/index.ts (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/index.tsx (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/logo.svg (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/services/history.ts (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/services/index.ts (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/services/settings.ts (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/app/services/storage.ts (100%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/index.ts (92%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/legacy.ts (84%) rename src/legacy/core_plugins/console/{public => }/np_ready/public/plugin.ts (85%) create mode 100644 src/legacy/core_plugins/console/np_ready/server/.gitkeep diff --git a/src/legacy/core_plugins/console/index.ts b/src/legacy/core_plugins/console/index.ts index 8eeb2a8f58985..2d0ba9bc14383 100644 --- a/src/legacy/core_plugins/console/index.ts +++ b/src/legacy/core_plugins/console/index.ts @@ -51,7 +51,7 @@ function filterHeaders(originalHeaders: any, headersToKeep: any) { export default function(kibana: any) { const modules = resolve(__dirname, 'public/webpackShims/'); const quarantinedSrc = resolve(__dirname, 'public/quarantined/src/'); - const src = resolve(__dirname, 'public/np_ready/public'); + const npSrc = resolve(__dirname, 'np_ready/public'); let defaultVars: any; const apps: any[] = []; @@ -179,7 +179,7 @@ export default function(kibana: any) { uiExports: { apps, hacks: ['plugins/console/quarantined/hacks/register'], - devTools: [`${src}/legacy`], + devTools: [`${npSrc}/legacy`], styleSheetPaths: resolve(__dirname, 'public/quarantined/index.scss'), injectDefaultVars: () => defaultVars, diff --git a/src/legacy/core_plugins/console/public/np_ready/kibana.json b/src/legacy/core_plugins/console/np_ready/kibana.json similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/kibana.json rename to src/legacy/core_plugins/console/np_ready/kibana.json diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/components/console_menu.tsx b/src/legacy/core_plugins/console/np_ready/public/app/components/console_menu.tsx similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/components/console_menu.tsx rename to src/legacy/core_plugins/console/np_ready/public/app/components/console_menu.tsx diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/components/editor_example.tsx b/src/legacy/core_plugins/console/np_ready/public/app/components/editor_example.tsx similarity index 94% rename from src/legacy/core_plugins/console/public/np_ready/public/app/components/editor_example.tsx rename to src/legacy/core_plugins/console/np_ready/public/app/components/editor_example.tsx index 6f0acd4ecc0ba..33cefd9b20968 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/components/editor_example.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/app/components/editor_example.tsx @@ -22,7 +22,7 @@ import React, { useEffect } from 'react'; import exampleText from 'raw-loader!../constants/help_example.txt'; import $ from 'jquery'; // @ts-ignore -import SenseEditor from '../../../../quarantined/src/sense_editor/editor'; +import SenseEditor from '../../../../public/quarantined/src/sense_editor/editor'; interface EditorExampleProps { panel: string; diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/components/help_panel.tsx b/src/legacy/core_plugins/console/np_ready/public/app/components/help_panel.tsx similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/components/help_panel.tsx rename to src/legacy/core_plugins/console/np_ready/public/app/components/help_panel.tsx diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/components/index.ts b/src/legacy/core_plugins/console/np_ready/public/app/components/index.ts similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/components/index.ts rename to src/legacy/core_plugins/console/np_ready/public/app/components/index.ts diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/components/settings_modal.tsx b/src/legacy/core_plugins/console/np_ready/public/app/components/settings_modal.tsx similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/components/settings_modal.tsx rename to src/legacy/core_plugins/console/np_ready/public/app/components/settings_modal.tsx diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/components/resizer.tsx b/src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/components/resizer.tsx similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/components/resizer.tsx rename to src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/components/resizer.tsx diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/containers/panel.tsx b/src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/containers/panel.tsx similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/containers/panel.tsx rename to src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/containers/panel.tsx diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/containers/panel_container.tsx b/src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/containers/panel_container.tsx similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/containers/panel_container.tsx rename to src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/containers/panel_container.tsx diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/context.tsx b/src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/context.tsx similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/context.tsx rename to src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/context.tsx diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/index.ts b/src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/index.ts similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/index.ts rename to src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/index.ts diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/registry.ts b/src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/registry.ts similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/components/split_panel/registry.ts rename to src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/registry.ts diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/components/top_nav_menu.tsx b/src/legacy/core_plugins/console/np_ready/public/app/components/top_nav_menu.tsx similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/components/top_nav_menu.tsx rename to src/legacy/core_plugins/console/np_ready/public/app/components/top_nav_menu.tsx diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/components/welcome_panel.tsx b/src/legacy/core_plugins/console/np_ready/public/app/components/welcome_panel.tsx similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/components/welcome_panel.tsx rename to src/legacy/core_plugins/console/np_ready/public/app/components/welcome_panel.tsx diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/constants/help_example.txt b/src/legacy/core_plugins/console/np_ready/public/app/constants/help_example.txt similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/constants/help_example.txt rename to src/legacy/core_plugins/console/np_ready/public/app/constants/help_example.txt diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/index.ts b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/index.ts similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/index.ts rename to src/legacy/core_plugins/console/np_ready/public/app/containers/editor/index.ts diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_editor.tsx b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor.tsx similarity index 96% rename from src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_editor.tsx rename to src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor.tsx index 721c8e45be2a4..27ce6f7c0d318 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_editor.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor.tsx @@ -23,11 +23,11 @@ import { EuiToolTip } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; // @ts-ignore -import { initializeInput } from '../../../../../../quarantined/src/input'; +import { initializeInput } from '../../../../../../public/quarantined/src/input'; // @ts-ignore -import { initializeOutput } from '../../../../../../quarantined/src/output'; +import { initializeOutput } from '../../../../../../public/quarantined/src/output'; // @ts-ignore -import init from '../../../../../../quarantined/src/app'; +import init from '../../../../../../public/quarantined/src/app'; import { ConsoleMenu } from '../../../components'; diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_history/console_history.tsx b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_history/console_history.tsx similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_history/console_history.tsx rename to src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_history/console_history.tsx diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_history/history_viewer.tsx b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_history/history_viewer.tsx similarity index 95% rename from src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_history/history_viewer.tsx rename to src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_history/history_viewer.tsx index 58ddccc377574..68087b19b3c25 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_history/history_viewer.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_history/history_viewer.tsx @@ -25,7 +25,7 @@ import { Settings } from '../../../../services'; import { installEditorsResizeChecker } from '../install_console_resize_checker'; // @ts-ignore -import SenseEditor from '../../../../../../../quarantined/src/sense_editor/editor'; +import SenseEditor from '../../../../../../../public/quarantined/src/sense_editor/editor'; interface Props { settings: Settings; diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_history/index.ts b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_history/index.ts similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_history/index.ts rename to src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_history/index.ts diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_menu_actions.ts b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_menu_actions.ts similarity index 94% rename from src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_menu_actions.ts rename to src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_menu_actions.ts index 574e351178143..e4fdb43e68e50 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/console_menu_actions.ts +++ b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_menu_actions.ts @@ -18,7 +18,7 @@ */ // @ts-ignore -import { getEndpointFromPosition } from '../../../../../../quarantined/src/autocomplete'; +import { getEndpointFromPosition } from '../../../../../../public/quarantined/src/autocomplete'; export function autoIndent(editor: any, event: any) { editor.autoIndent(); diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.ts b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/index.ts similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/index.ts rename to src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/index.ts diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/install_console_resize_checker.ts b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/install_console_resize_checker.ts similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/install_console_resize_checker.ts rename to src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/install_console_resize_checker.ts diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx rename to src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/index.ts b/src/legacy/core_plugins/console/np_ready/public/app/containers/index.ts similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/containers/index.ts rename to src/legacy/core_plugins/console/np_ready/public/app/containers/index.ts diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main/get_top_nav.ts b/src/legacy/core_plugins/console/np_ready/public/app/containers/main/get_top_nav.ts similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/containers/main/get_top_nav.ts rename to src/legacy/core_plugins/console/np_ready/public/app/containers/main/get_top_nav.ts diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main/index.ts b/src/legacy/core_plugins/console/np_ready/public/app/containers/main/index.ts similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/containers/main/index.ts rename to src/legacy/core_plugins/console/np_ready/public/app/containers/main/index.ts diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main/main.tsx b/src/legacy/core_plugins/console/np_ready/public/app/containers/main/main.tsx similarity index 98% rename from src/legacy/core_plugins/console/public/np_ready/public/app/containers/main/main.tsx rename to src/legacy/core_plugins/console/np_ready/public/app/containers/main/main.tsx index 0eb8743c4c380..d3d29c0f3681a 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/app/containers/main/main.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/app/containers/main/main.tsx @@ -33,7 +33,7 @@ import { useAppContext } from '../../context'; import { StorageKeys, DevToolsSettings } from '../../services'; // @ts-ignore -import mappings from '../../../../../quarantined/src/mappings'; +import mappings from '../../../../../public/quarantined/src/mappings'; import { getTopNavConfig } from './get_top_nav'; diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/context/app_context.tsx b/src/legacy/core_plugins/console/np_ready/public/app/context/app_context.tsx similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/context/app_context.tsx rename to src/legacy/core_plugins/console/np_ready/public/app/context/app_context.tsx diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/context/index.ts b/src/legacy/core_plugins/console/np_ready/public/app/context/index.ts similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/context/index.ts rename to src/legacy/core_plugins/console/np_ready/public/app/context/index.ts diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/index.tsx b/src/legacy/core_plugins/console/np_ready/public/app/index.tsx similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/index.tsx rename to src/legacy/core_plugins/console/np_ready/public/app/index.tsx diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/logo.svg b/src/legacy/core_plugins/console/np_ready/public/app/logo.svg similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/logo.svg rename to src/legacy/core_plugins/console/np_ready/public/app/logo.svg diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/services/history.ts b/src/legacy/core_plugins/console/np_ready/public/app/services/history.ts similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/services/history.ts rename to src/legacy/core_plugins/console/np_ready/public/app/services/history.ts diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/services/index.ts b/src/legacy/core_plugins/console/np_ready/public/app/services/index.ts similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/services/index.ts rename to src/legacy/core_plugins/console/np_ready/public/app/services/index.ts diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/services/settings.ts b/src/legacy/core_plugins/console/np_ready/public/app/services/settings.ts similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/services/settings.ts rename to src/legacy/core_plugins/console/np_ready/public/app/services/settings.ts diff --git a/src/legacy/core_plugins/console/public/np_ready/public/app/services/storage.ts b/src/legacy/core_plugins/console/np_ready/public/app/services/storage.ts similarity index 100% rename from src/legacy/core_plugins/console/public/np_ready/public/app/services/storage.ts rename to src/legacy/core_plugins/console/np_ready/public/app/services/storage.ts diff --git a/src/legacy/core_plugins/console/public/np_ready/public/index.ts b/src/legacy/core_plugins/console/np_ready/public/index.ts similarity index 92% rename from src/legacy/core_plugins/console/public/np_ready/public/index.ts rename to src/legacy/core_plugins/console/np_ready/public/index.ts index c3cb4d35e4d86..3f8d162f62d44 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/index.ts +++ b/src/legacy/core_plugins/console/np_ready/public/index.ts @@ -17,7 +17,7 @@ * under the License. */ -import { PluginInitializerContext } from '../../../../../../core/public'; +import { PluginInitializerContext } from '../../../../../core/public'; import { ConsoleUIPlugin } from './plugin'; diff --git a/src/legacy/core_plugins/console/public/np_ready/public/legacy.ts b/src/legacy/core_plugins/console/np_ready/public/legacy.ts similarity index 84% rename from src/legacy/core_plugins/console/public/np_ready/public/legacy.ts rename to src/legacy/core_plugins/console/np_ready/public/legacy.ts index 30f8f5f5ddac0..a6bdf2615e9aa 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/legacy.ts +++ b/src/legacy/core_plugins/console/np_ready/public/legacy.ts @@ -29,11 +29,8 @@ import 'ui/autoload/styles'; import 'ui/capabilities/route_setup'; /* eslint-enable @kbn/eslint/no-restricted-paths */ -// require('./src/directives/sense_history'); -// require('./src/directives/console_menu_directive'); - -import template from '../../quarantined/index.html'; -import { CoreSetup } from '../../../../../../core/public'; +import template from '../../public/quarantined/index.html'; +import { CoreSetup } from '../../../../../core/public'; interface SetupRegisterAppArgs { id: string; @@ -41,14 +38,19 @@ interface SetupRegisterAppArgs { } export interface XCoreSetup extends CoreSetup { - docLinkVersion: string; - ResizeChecker: any; - I18nContext: any; application: { register(args: SetupRegisterAppArgs): void; }; } +export interface XPluginSet { + __LEGACY: { + I18nContext: any; + ResizeChecker: any; + docLinkVersion: string; + }; +} + import { plugin } from '.'; const pluginInstance = plugin({} as any); @@ -69,9 +71,6 @@ uiRoutes.when('/dev_tools/console', { const xNpSetupCore: XCoreSetup = { ...npSetup.core, - I18nContext, - ResizeChecker, - docLinkVersion: DOC_LINK_VERSION, application: { register(args: SetupRegisterAppArgs): void { args.mount({}, targetElement).catch(err => { @@ -81,7 +80,14 @@ uiRoutes.when('/dev_tools/console', { }, }; - pluginInstance.setup(xNpSetupCore); + pluginInstance.setup(xNpSetupCore, { + ...npSetup.plugins, + __LEGACY: { + I18nContext, + ResizeChecker, + docLinkVersion: DOC_LINK_VERSION, + }, + }); pluginInstance.start(npStart.core); }; }, diff --git a/src/legacy/core_plugins/console/public/np_ready/public/plugin.ts b/src/legacy/core_plugins/console/np_ready/public/plugin.ts similarity index 85% rename from src/legacy/core_plugins/console/public/np_ready/public/plugin.ts rename to src/legacy/core_plugins/console/np_ready/public/plugin.ts index 2f05ace7f5027..2cb74ebb7b7cc 100644 --- a/src/legacy/core_plugins/console/public/np_ready/public/plugin.ts +++ b/src/legacy/core_plugins/console/np_ready/public/plugin.ts @@ -19,15 +19,19 @@ import { render, unmountComponentAtNode } from 'react-dom'; -import { PluginInitializerContext, Plugin, CoreStart } from '../../../../../../core/public'; +import { PluginInitializerContext, Plugin, CoreStart } from '../../../../../core/public'; import { boot } from './app'; -import { XCoreSetup } from './legacy'; +import { XCoreSetup, XPluginSet } from './legacy'; export class ConsoleUIPlugin implements Plugin { // @ts-ignore constructor(private readonly ctx: PluginInitializerContext) {} - async setup({ application, docLinkVersion, I18nContext, ResizeChecker }: XCoreSetup) { + async setup({ application }: XCoreSetup, pluginSet: XPluginSet) { + const { + __LEGACY: { docLinkVersion, I18nContext, ResizeChecker }, + } = pluginSet; + application.register({ id: 'console', async mount(ctx, targetElement) { diff --git a/src/legacy/core_plugins/console/np_ready/server/.gitkeep b/src/legacy/core_plugins/console/np_ready/server/.gitkeep new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/legacy/core_plugins/console/public/README.md b/src/legacy/core_plugins/console/public/README.md index 2633a82084c80..3a53c46143793 100644 --- a/src/legacy/core_plugins/console/public/README.md +++ b/src/legacy/core_plugins/console/public/README.md @@ -1,7 +1,7 @@ ## New Platform (NP) Ready vs Quarantined We want to move toward more modularised code in the Console app. -Part of the effort means separating out different console compoonents +Part of the effort means separating out different console components like: - The language parser @@ -10,9 +10,10 @@ like: - The UI container components In addition to this effort we want to bring Console in line with NP -requirements and ensure that we are not using NG in this app anymore. +requirements and ensure that we are not using angular and public ui +in this app anymore. -The quarantined folder contains all of the code that has been cleared +The quarantined folder contains all of the code that has not been cleared for living in the new platform as it has not been properly refactored or has dependencies on, for example, UI public. diff --git a/src/legacy/core_plugins/console/public/quarantined/index.html b/src/legacy/core_plugins/console/public/quarantined/index.html index 744b498d6f269..66a693d4b2af7 100644 --- a/src/legacy/core_plugins/console/public/quarantined/index.html +++ b/src/legacy/core_plugins/console/public/quarantined/index.html @@ -1,44 +1,3 @@ - - - -
        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        - - - diff --git a/src/legacy/core_plugins/console/public/quarantined/src/mappings.js b/src/legacy/core_plugins/console/public/quarantined/src/mappings.js index dacdc79562064..90c7068e34344 100644 --- a/src/legacy/core_plugins/console/public/quarantined/src/mappings.js +++ b/src/legacy/core_plugins/console/public/quarantined/src/mappings.js @@ -17,7 +17,7 @@ * under the License. */ -import { legacyBackDoorToSettings } from '../../np_ready/public/app'; +import { legacyBackDoorToSettings } from '../../../np_ready/public/app'; const $ = require('jquery'); const _ = require('lodash'); From 45382c3748cc695309b1fcc6ca3064fa58efe229 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Fri, 30 Aug 2019 15:03:11 +0200 Subject: [PATCH 11/35] Replace angular directive --- .../editor/legacy/console_history/console_history.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_history/console_history.tsx b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_history/console_history.tsx index d7d847457fb8f..a0b48fcd5ea77 100644 --- a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_history/console_history.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_history/console_history.tsx @@ -115,9 +115,11 @@ export function ConsoleHistory({ close }: Props) { role="listbox" className="list-group conHistory__reqs" tabIndex={0} - // aria-activedescendant={`historyReq${selectedIndex}`} - // scrollto-activedescendant="true" - aria-label="{{:: 'console.historyPage.requestListAriaLabel' | i18n: { defaultMessage: 'History of sent requests' } }}" + aria-activedescendant={`historyReq${selectedIndex}`} + scrollto-activedescendant="true" + aria-label={i18n.translate('console.historyPage.requestListAriaLabel', { + defaultMessage: 'History of sent requests', + })} > {reqs.map((req, idx) => { const reqDescription = describeReq(req); From 18f84a29b447679469b0b4d9e8bb20b4d28995d1 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Fri, 30 Aug 2019 17:09:42 +0200 Subject: [PATCH 12/35] Remove used code --- .../public/app/containers/main/get_top_nav.ts | 5 - .../console/np_ready/public/legacy.ts | 2 + .../console/np_ready/public/plugin.ts | 2 +- .../public/quarantined/src/autocomplete.js | 1 - .../console/public/quarantined/src/input.js | 2 - .../public/quarantined/src/input_resize.js | 65 ----------- .../src/sense_editor/mode/output.js | 2 +- .../public/quarantined/src/settings.js | 102 ------------------ .../console/public/quarantined/src/storage.js | 79 -------------- 9 files changed, 4 insertions(+), 256 deletions(-) delete mode 100644 src/legacy/core_plugins/console/public/quarantined/src/input_resize.js delete mode 100644 src/legacy/core_plugins/console/public/quarantined/src/settings.js delete mode 100644 src/legacy/core_plugins/console/public/quarantined/src/storage.js diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/main/get_top_nav.ts b/src/legacy/core_plugins/console/np_ready/public/app/containers/main/get_top_nav.ts index 476cb47e6b9b2..e4437ea6c2f16 100644 --- a/src/legacy/core_plugins/console/np_ready/public/app/containers/main/get_top_nav.ts +++ b/src/legacy/core_plugins/console/np_ready/public/app/containers/main/get_top_nav.ts @@ -19,11 +19,6 @@ import { i18n } from '@kbn/i18n'; -// import { showSettingsModal } from './settings_show_modal'; - -// help -// import { showHelpPanel } from './help_show_panel'; - interface Props { onClickHistory: () => void; onClickSettings: () => void; diff --git a/src/legacy/core_plugins/console/np_ready/public/legacy.ts b/src/legacy/core_plugins/console/np_ready/public/legacy.ts index a6bdf2615e9aa..e5bb41fcea301 100644 --- a/src/legacy/core_plugins/console/np_ready/public/legacy.ts +++ b/src/legacy/core_plugins/console/np_ready/public/legacy.ts @@ -18,6 +18,8 @@ */ import 'brace'; +import 'brace/ext/language_tools'; +import 'brace/ext/searchbox'; /* eslint-disable @kbn/eslint/no-restricted-paths */ import { npSetup, npStart } from 'ui/new_platform'; diff --git a/src/legacy/core_plugins/console/np_ready/public/plugin.ts b/src/legacy/core_plugins/console/np_ready/public/plugin.ts index 2cb74ebb7b7cc..6c4d957bb5a6c 100644 --- a/src/legacy/core_plugins/console/np_ready/public/plugin.ts +++ b/src/legacy/core_plugins/console/np_ready/public/plugin.ts @@ -20,8 +20,8 @@ import { render, unmountComponentAtNode } from 'react-dom'; import { PluginInitializerContext, Plugin, CoreStart } from '../../../../../core/public'; -import { boot } from './app'; import { XCoreSetup, XPluginSet } from './legacy'; +import { boot } from './app'; export class ConsoleUIPlugin implements Plugin { // @ts-ignore diff --git a/src/legacy/core_plugins/console/public/quarantined/src/autocomplete.js b/src/legacy/core_plugins/console/public/quarantined/src/autocomplete.js index 8275813ea2b98..640cb5889d408 100644 --- a/src/legacy/core_plugins/console/public/quarantined/src/autocomplete.js +++ b/src/legacy/core_plugins/console/public/quarantined/src/autocomplete.js @@ -28,7 +28,6 @@ import { populateContext } from './autocomplete/engine'; import { URL_PATH_END_MARKER } from './autocomplete/components'; import _ from 'lodash'; import ace from 'brace'; -import 'brace/ext/language_tools'; import { i18n } from '@kbn/i18n'; const AceRange = ace.acequire('ace/range').Range; diff --git a/src/legacy/core_plugins/console/public/quarantined/src/input.js b/src/legacy/core_plugins/console/public/quarantined/src/input.js index 93bab05f3e9b9..d1daccc10bb88 100644 --- a/src/legacy/core_plugins/console/public/quarantined/src/input.js +++ b/src/legacy/core_plugins/console/public/quarantined/src/input.js @@ -17,8 +17,6 @@ * under the License. */ -require('brace'); -require('brace/ext/searchbox'); import Autocomplete from './autocomplete'; import mappings from './mappings'; const SenseEditor = require('./sense_editor/editor'); diff --git a/src/legacy/core_plugins/console/public/quarantined/src/input_resize.js b/src/legacy/core_plugins/console/public/quarantined/src/input_resize.js deleted file mode 100644 index c75c5555ba068..0000000000000 --- a/src/legacy/core_plugins/console/public/quarantined/src/input_resize.js +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -const $ = require('jquery'); -const storage = require('./storage'); - -export default function (input, output) { - const $left = input.$el.parent(); - - // function readStoredEditorWidth() { - // return storage.get('editorWidth'); - // } - - function storeEditorWidth(editorWidth) { - storage.set('editorWidth', editorWidth); - } - - function setEditorWidth(editorWidth) { - storeEditorWidth(editorWidth); - $left.width(editorWidth); - } - - const $resizer = $('#ConAppResizer'); - $resizer.on('mousedown', function (event) { - $resizer.addClass('active'); - const startWidth = $left.width(); - const startX = event.pageX; - input.resize.topRow = input.renderer.layerConfig.firstRow; - output.resize.topRow = output.renderer.layerConfig.firstRow; - - function onMove(event) { - setEditorWidth(startWidth + event.pageX - startX); - } - - $(document.body) - .on('mousemove', onMove) - .one('mouseup', function () { - $resizer.removeClass('active'); - $(this).off('mousemove', onMove); - input.resize(); - output.resize(); - }); - }); - - // const initialEditorWidth = readStoredEditorWidth(); - // if (initialEditorWidth != null) { - // setEditorWidth(initialEditorWidth); - // } -} diff --git a/src/legacy/core_plugins/console/public/quarantined/src/sense_editor/mode/output.js b/src/legacy/core_plugins/console/public/quarantined/src/sense_editor/mode/output.js index e9964fa759726..e2598f2a73d77 100644 --- a/src/legacy/core_plugins/console/public/quarantined/src/sense_editor/mode/output.js +++ b/src/legacy/core_plugins/console/public/quarantined/src/sense_editor/mode/output.js @@ -17,7 +17,7 @@ * under the License. */ -const ace = require('brace'); +import ace from 'brace'; require('./output_highlight_rules'); diff --git a/src/legacy/core_plugins/console/public/quarantined/src/settings.js b/src/legacy/core_plugins/console/public/quarantined/src/settings.js deleted file mode 100644 index 23e89d00563a3..0000000000000 --- a/src/legacy/core_plugins/console/public/quarantined/src/settings.js +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -const storage = require('./storage'); - -import getInput from './input'; -import getOutput from './output'; - -function getFontSize() { - return storage.get('font_size', 14); -} - -function setFontSize(size) { - storage.set('font_size', size); - applyCurrentSettings(); - return true; -} - -function getWrapMode() { - return storage.get('wrap_mode', true); -} - -function setWrapMode(mode) { - storage.set('wrap_mode', mode); - applyCurrentSettings(); - return true; -} - -function setTripleQuotes(tripleQuotes) { - storage.set('triple_quotes', tripleQuotes); - return true; -} - -export function getTripleQuotes() { - return storage.get('triple_quotes', true); -} - -export function getAutocomplete() { - return storage.get('autocomplete_settings', { fields: true, indices: true, templates: true }); -} - -function setAutocomplete(settings) { - storage.set('autocomplete_settings', settings); - return true; -} - -export function getPolling() { - return storage.get('console_polling', true); -} - -function setPolling(polling) { - storage.set('console_polling', polling); - applyCurrentSettings(); - return true; -} - -export function applyCurrentSettings(editor) { - if (typeof editor === 'undefined') { - applyCurrentSettings(getInput()); - applyCurrentSettings(getOutput()); - } - if (editor) { - editor.getSession().setUseWrapMode(getWrapMode()); - editor.$el.css('font-size', getFontSize() + 'px'); - } -} - -export function getCurrentSettings() { - return { - autocomplete: getAutocomplete(), - wrapMode: getWrapMode(), - tripleQuotes: getTripleQuotes(), - fontSize: parseFloat(getFontSize()), - polling: Boolean(getPolling()), - }; -} - -export function updateSettings({ fontSize, wrapMode, tripleQuotes, autocomplete, polling }) { - setFontSize(fontSize); - setWrapMode(wrapMode); - setTripleQuotes(tripleQuotes); - setAutocomplete(autocomplete); - setPolling(polling); - getInput().focus(); - return getCurrentSettings(); -} diff --git a/src/legacy/core_plugins/console/public/quarantined/src/storage.js b/src/legacy/core_plugins/console/public/quarantined/src/storage.js deleted file mode 100644 index fc8113287e971..0000000000000 --- a/src/legacy/core_plugins/console/public/quarantined/src/storage.js +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -const { transform, keys, startsWith } = require('lodash'); - -class Storage { - constructor(engine, prefix) { - this.engine = engine; - this.prefix = prefix; - } - - encode(val) { - return JSON.stringify(val); - } - - decode(val) { - if (typeof val === 'string') { - return JSON.parse(val); - } - } - - encodeKey(key) { - return `${this.prefix}${key}`; - } - - decodeKey(key) { - if (startsWith(key, this.prefix)) { - return `${key.slice(this.prefix.length)}`; - } - } - - set(key, val) { - this.engine.setItem(this.encodeKey(key), this.encode(val)); - return val; - } - - has(key) { - return this.engine.getItem(this.encodeKey(key)) != null; - } - - get(key, _default) { - if (this.has(key)) { - return this.decode(this.engine.getItem(this.encodeKey(key))); - } else { - return _default; - } - } - - delete(key) { - return this.engine.removeItem(this.encodeKey(key)); - } - - keys() { - return transform(keys(this.engine), (ours, key) => { - const ourKey = this.decodeKey(key); - if (ourKey != null) ours.push(ourKey); - }); - } -} - -const instance = new Storage(window.localStorage, 'sense:'); - -export default instance; From 51daf2838d4b59bab58ab913252954ff7991aeaa Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Fri, 30 Aug 2019 20:51:56 +0200 Subject: [PATCH 13/35] Re-order imports and move all ace dependencies to same location --- .../public/app/components/top_nav_menu.tsx | 2 +- .../editor/legacy/console_editor.tsx | 7 ++++++- .../public/app/containers/main/main.tsx | 18 +++++++++++++----- .../console/np_ready/public/legacy.ts | 2 ++ 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/legacy/core_plugins/console/np_ready/public/app/components/top_nav_menu.tsx b/src/legacy/core_plugins/console/np_ready/public/app/components/top_nav_menu.tsx index df45d87ab94a1..7da9d08036c0b 100644 --- a/src/legacy/core_plugins/console/np_ready/public/app/components/top_nav_menu.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/app/components/top_nav_menu.tsx @@ -37,7 +37,7 @@ export function TopNavMenu({ items }: Props) { {items.map((item, idx) => { return ( - + {item.label} ); diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor.tsx b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor.tsx index 27ce6f7c0d318..1eaf84a0448e0 100644 --- a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor.tsx @@ -162,7 +162,12 @@ export function ConsoleEditor({ }} />
      -
      +
      diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/main/main.tsx b/src/legacy/core_plugins/console/np_ready/public/app/containers/main/main.tsx index d3d29c0f3681a..8a7e2487438c9 100644 --- a/src/legacy/core_plugins/console/np_ready/public/app/containers/main/main.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/app/containers/main/main.tsx @@ -20,6 +20,11 @@ import React, { useCallback, useState } from 'react'; import { debounce } from 'lodash'; +// @ts-ignore +import mappings from '../../../../../public/quarantined/src/mappings'; + +import { MemoConsoleEditor, ConsoleHistory } from '../editor'; + import { AutocompleteOptions, TopNavMenu, @@ -28,13 +33,9 @@ import { HelpPanel, } from '../../components'; -import { MemoConsoleEditor, ConsoleHistory } from '../editor'; import { useAppContext } from '../../context'; import { StorageKeys, DevToolsSettings } from '../../services'; -// @ts-ignore -import mappings from '../../../../../public/quarantined/src/mappings'; - import { getTopNavConfig } from './get_top_nav'; const INITIAL_PANEL_WIDTH = 50; @@ -145,7 +146,14 @@ export function Main() { initialOutputPanelWidth={secondPanelWidth} /> - {showWelcome ? setShowWelcomePanel(false)} /> : null} + {showWelcome ? ( + { + storage.set('version_welcome_shown', '@@SENSE_REVISION'); + setShowWelcomePanel(false); + }} + /> + ) : null} {showSettings ? ( Date: Sat, 31 Aug 2019 00:35:22 +0200 Subject: [PATCH 14/35] Remove more unused code --- .../src/controllers/sense_controller.js | 137 ------------------ 1 file changed, 137 deletions(-) delete mode 100644 src/legacy/core_plugins/console/public/quarantined/src/controllers/sense_controller.js diff --git a/src/legacy/core_plugins/console/public/quarantined/src/controllers/sense_controller.js b/src/legacy/core_plugins/console/public/quarantined/src/controllers/sense_controller.js deleted file mode 100644 index 2011f23d11cc6..0000000000000 --- a/src/legacy/core_plugins/console/public/quarantined/src/controllers/sense_controller.js +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -import { docTitle } from 'ui/doc_title'; - -import { applyResizeCheckerToEditors } from '../sense_editor_resize'; -import $ from 'jquery'; -import { initializeInput } from '../input'; -import { initializeOutput } from '../output'; -import init from '../app'; -import { getEndpointFromPosition } from '../autocomplete'; -import { DOC_LINK_VERSION } from 'ui/documentation_links'; - -// welcome message -import { showWelcomePanel } from '../helpers/welcome_show_panel'; -import storage from '../storage'; - -import { getTopNavConfig } from '../helpers/get_top_nav'; - -const module = require('ui/modules').get('app/sense'); - -module.run(function ($rootScope) { - module.setupResizeCheckerForRootEditors = ($el, ...editors) => { - return applyResizeCheckerToEditors($rootScope, $el, ...editors); - }; -}); - -function showWelcomeMessageIfNeeded($scope) { - if (storage.get('version_welcome_shown') !== '@@SENSE_REVISION') { - const hideWelcomePanel = showWelcomePanel(); - $scope.$on('$destroy', () => { - hideWelcomePanel(); - }); - } -} - -module.controller('SenseController', function SenseController($scope, $timeout, $location, kbnUiAceKeyboardModeService) { - docTitle.change('Console'); - - showWelcomeMessageIfNeeded($scope); - - // Since we pass this callback via reactDirective into a react component, which has the function defined as required - // in it's prop types, we should set this initially (before it's set in the $timeout below). Without this line - // the component we pass this in will throw an propType validation error. - $scope.getRequestsAsCURL = () => ''; - - // We need to wait for these elements to be rendered before we can select them with jQuery - // and then initialize this app - let input; - let output; - $timeout(async () => { - output = initializeOutput($('#ConAppOutput')); - input = initializeInput($('#ConAppEditor'), $('#ConAppEditorActions'), $('#ConCopyAsCurl'), output, $scope.openDocumentation); - init(input, output, $location.search().load_from); - kbnUiAceKeyboardModeService.initialize($scope, $('#ConAppEditor')); - const session = input.getSession(); - session.getSelection().on('changeCursor', () => { - $scope.getDocumentation(); - }); - $scope.getDocumentation(); - - // expose method for React Consumption - $scope.getRequestsAsCURL = input.getRequestsAsCURL; - }); - $scope.getDocumentation = () => { - input.getRequestsInRange(function (requests) { - if (!requests || requests.length === 0) { - $scope.documentation = null; - $scope.$apply(); - return; - } - const position = requests[0].range.end; - position.column = position.column - 1; - const endpoint = getEndpointFromPosition(input, position); - if (endpoint - && endpoint.documentation - && endpoint.documentation.indexOf('http') !== -1) { - $scope.documentation = endpoint.documentation.replace('/master/', `/${DOC_LINK_VERSION}/`); - $scope.documentation = $scope.documentation.replace('/current/', `/${DOC_LINK_VERSION}/`); - $scope.$apply(); - } else { - $scope.documentation = null; - $scope.$apply(); - } - }); - }; - - $scope.showHistory = false; - $scope.historyDirty = undefined; - $scope.toggleHistory = () => { - $scope.showHistory = !$scope.showHistory; - }; - - $scope.closeHistory = () => { - $scope.showHistory = false; - }; - - $scope.topNavMenu = getTopNavConfig($scope, $scope.toggleHistory); - - $scope.openDocumentation = () => { - if (!$scope.documentation) { - return; - } - window.open($scope.documentation, '_blank'); - }; - - $scope.sendSelected = () => { - input.focus(); - input.sendCurrentRequestToES(() => { - // History watches this value and will re-render itself when it changes, so that - // the list of requests stays up-to-date as new requests are sent. - $scope.lastRequestTimestamp = new Date().getTime(); - }); - return false; - }; - - $scope.autoIndent = (event) => { - input.autoIndent(); - event.preventDefault(); - input.focus(); - }; -}); From 6a5f082557137f8d1c66a6a02fe4687102518d41 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Mon, 2 Sep 2019 12:08:18 +0200 Subject: [PATCH 15/35] Revise quarantined setup mocks --- .../quarantined/tests/src/setup_mocks.js | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/legacy/core_plugins/console/public/quarantined/tests/src/setup_mocks.js b/src/legacy/core_plugins/console/public/quarantined/tests/src/setup_mocks.js index 0bcf75e29f5f3..b151cf04cf135 100644 --- a/src/legacy/core_plugins/console/public/quarantined/tests/src/setup_mocks.js +++ b/src/legacy/core_plugins/console/public/quarantined/tests/src/setup_mocks.js @@ -17,16 +17,33 @@ * under the License. */ /* eslint no-undef: 0 */ -jest.mock('../../src/sense_editor/mode/worker', () => { return { workerModule: { id: 'sense_editor/mode/worker', src: '' } }; }); -window.Worker = function () { this.postMessage = () => {}; this.terminate = () => {}; }; +jest.mock('../../src/sense_editor/mode/worker', () => { + return { workerModule: { id: 'sense_editor/mode/worker', src: '' } }; +}); +window.Worker = function () { + this.postMessage = () => {}; + this.terminate = () => {}; +}; window.URL = { - createObjectURL: () => { return ''; } + createObjectURL: () => { + return ''; + }, }; -jest.mock('../../src/storage'); + +import 'brace'; +import 'brace/ext/language_tools'; +import 'brace/ext/searchbox'; +import 'brace/mode/json'; +import 'brace/mode/text'; + +jest.mock('../../../../np_ready/public/app', () => ({ legacyBackDoorToSettings: () => {} })); document.queryCommandSupported = () => true; import jQuery from 'jquery'; -jest.spyOn(jQuery, 'ajax').mockImplementation(() => new Promise(() => { - // never resolve -})); +jest.spyOn(jQuery, 'ajax').mockImplementation( + () => + new Promise(() => { + // never resolve + }) +); From c5b28415f21bba307ea29ae5cbfd275985a80fea Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Mon, 2 Sep 2019 12:38:53 +0200 Subject: [PATCH 16/35] Don't suggest 'undefined' or other null-like values in autocomplete --- .../public/quarantined/src/autocomplete.js | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/src/legacy/core_plugins/console/public/quarantined/src/autocomplete.js b/src/legacy/core_plugins/console/public/quarantined/src/autocomplete.js index 640cb5889d408..d8cd5d868e9ae 100644 --- a/src/legacy/core_plugins/console/public/quarantined/src/autocomplete.js +++ b/src/legacy/core_plugins/console/public/quarantined/src/autocomplete.js @@ -906,30 +906,34 @@ export default function (editor) { callback(null, []); } else { - const terms = _.map(context.autoCompleteSet, function (term) { - if (typeof term !== 'object') { - term = { - name: term + const terms = _.map( + context + .autoCompleteSet + .filter(term => Boolean(term) && term.name != null), + function (term) { + if (typeof term !== 'object') { + term = { + name: term + }; + } else { + term = _.clone(term); + } + const defaults = { + value: term.name, + meta: 'API', + score: 0, + context: context, }; - } else { - term = _.clone(term); - } - const defaults = { - value: term.name, - meta: 'API', - score: 0, - context: context, - }; - // we only need out custom insertMatch behavior for the body - if (context.autoCompleteType === 'body') { - defaults.completer = { - insertMatch: function () { - return applyTerm(term); - } - }; - } - return _.defaults(term, defaults); - }); + // we only need out custom insertMatch behavior for the body + if (context.autoCompleteType === 'body') { + defaults.completer = { + insertMatch: function () { + return applyTerm(term); + } + }; + } + return _.defaults(term, defaults); + }); terms.sort(function (t1, t2) { /* score sorts from high to low */ From 605f16a1b43943dc8289559d2b05f8062d532202 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Mon, 2 Sep 2019 12:55:43 +0200 Subject: [PATCH 17/35] Clean up api_server folder --- .../{ => server}/api_server/spec/generated/indices.clone.json | 0 .../{ => server}/api_server/spec/overrides/indices.clone.json | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/generated/indices.clone.json (100%) rename src/legacy/core_plugins/console/{ => server}/api_server/spec/overrides/indices.clone.json (100%) diff --git a/src/legacy/core_plugins/console/api_server/spec/generated/indices.clone.json b/src/legacy/core_plugins/console/server/api_server/spec/generated/indices.clone.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/generated/indices.clone.json rename to src/legacy/core_plugins/console/server/api_server/spec/generated/indices.clone.json diff --git a/src/legacy/core_plugins/console/api_server/spec/overrides/indices.clone.json b/src/legacy/core_plugins/console/server/api_server/spec/overrides/indices.clone.json similarity index 100% rename from src/legacy/core_plugins/console/api_server/spec/overrides/indices.clone.json rename to src/legacy/core_plugins/console/server/api_server/spec/overrides/indices.clone.json From 21c9168ee617b6a72a618f45a8807044d0e3c2a1 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Mon, 2 Sep 2019 13:27:11 +0200 Subject: [PATCH 18/35] Re-add missing style --- .../core_plugins/console/public/quarantined/_app.scss | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/legacy/core_plugins/console/public/quarantined/_app.scss b/src/legacy/core_plugins/console/public/quarantined/_app.scss index 1f23a0dff4a3d..a142f3d8bc135 100644 --- a/src/legacy/core_plugins/console/public/quarantined/_app.scss +++ b/src/legacy/core_plugins/console/public/quarantined/_app.scss @@ -1,6 +1,9 @@ // TODO: Move all of the styles here (should be modularised by, e.g., CSS-in-JS or CSS modules). #consoleRoot { height: 100%; + // Make sure the editor actions don't create scrollbars on this container + // SASSTODO: Uncomment when tooltips are EUI-ified (inside portals) + overflow: hidden; } .consoleContainer { @@ -10,9 +13,6 @@ .conApp { display: flex; flex: 1 1 auto; - // Make sure the editor actions don't create scrollbars on this container - // SASSTODO: Uncomment when tooltips are EUI-ified (inside portals) - // overflow: hidden; } .conApp__editor { From d5b27021efdf21339b1cf7f03998f9db8dddc85f Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Mon, 2 Sep 2019 13:56:08 +0200 Subject: [PATCH 19/35] Updated karma spec mock --- .../console/public/quarantined/src/__tests__/app.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/legacy/core_plugins/console/public/quarantined/src/__tests__/app.js b/src/legacy/core_plugins/console/public/quarantined/src/__tests__/app.js index 9f3779b02e9f3..a1984bca3ab02 100644 --- a/src/legacy/core_plugins/console/public/quarantined/src/__tests__/app.js +++ b/src/legacy/core_plugins/console/public/quarantined/src/__tests__/app.js @@ -23,7 +23,7 @@ import $ from 'jquery'; import mappings from '../mappings'; import init from '../app'; -const history = {}; +const history = { getSavedEditorState() {}, }; describe('console app initialization', () => { const sandbox = sinon.createSandbox(); @@ -34,7 +34,6 @@ describe('console app initialization', () => { beforeEach(() => { ajaxDoneStub = sinon.stub(); sandbox.stub($, 'ajax').returns({ done: ajaxDoneStub }); - sandbox.stub(history, 'getSavedEditorState'); sandbox.stub(mappings, 'retrieveAutoCompleteInfo'); inputMock = { From b59a2b2b28434ab59f5f17c01449851dcf4af0d3 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Mon, 2 Sep 2019 20:01:46 +0200 Subject: [PATCH 20/35] Fix editors cutting of at bottom of screen --- .../public/app/containers/main/main.tsx | 42 ++++++++++++------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/main/main.tsx b/src/legacy/core_plugins/console/np_ready/public/app/containers/main/main.tsx index 8a7e2487438c9..56bce96ab2e01 100644 --- a/src/legacy/core_plugins/console/np_ready/public/app/containers/main/main.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/app/containers/main/main.tsx @@ -19,6 +19,7 @@ import React, { useCallback, useState } from 'react'; import { debounce } from 'lodash'; +import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; // @ts-ignore import mappings from '../../../../../public/quarantined/src/mappings'; @@ -130,21 +131,32 @@ export function Main() { return ( <> - setShowHistory(!showingHistory), - onClickSettings: () => setShowSettings(true), - onClickHelp: () => setShowHelp(!showHelp), - })} - /> - {showingHistory ? renderConsoleHistory() : null} - + + + setShowHistory(!showingHistory), + onClickSettings: () => setShowSettings(true), + onClickHelp: () => setShowHelp(!showHelp), + })} + /> + + {showingHistory ? {renderConsoleHistory()} : null} + + + + {showWelcome ? ( Date: Tue, 3 Sep 2019 17:41:59 +0200 Subject: [PATCH 21/35] Refactor console editors into single components Refactor a lot of business logic to main.tsx container Minor renaming of variables for better readability --- .../containers/panel_container.tsx | 8 +- .../public/app/containers/editor/index.ts | 8 +- .../editor/legacy/console_editor.tsx | 187 ------------------ .../legacy/console_editor/console_editor.tsx | 33 ++++ .../editor/legacy/console_editor/editor.tsx | 118 +++++++++++ .../editor/legacy/console_editor/index.ts | 20 ++ .../legacy/console_editor/readonly_editor.tsx | 51 +++++ .../legacy/console_history/history_viewer.tsx | 4 +- .../app/containers/editor/legacy/index.ts | 3 +- ...ts => subscribe_console_resize_checker.ts} | 2 +- .../public/app/containers/main/main.tsx | 101 ++++++++-- .../console/public/quarantined/src/input.js | 37 ++-- .../quarantined/tests/src/editor.test.js | 2 +- .../tests/src/input_tokenization.test.js | 4 +- .../quarantined/tests/src/integration.test.js | 2 +- 15 files changed, 349 insertions(+), 231 deletions(-) delete mode 100644 src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor.tsx create mode 100644 src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/console_editor.tsx create mode 100644 src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/editor.tsx create mode 100644 src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/index.ts create mode 100644 src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/readonly_editor.tsx rename src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/{install_console_resize_checker.ts => subscribe_console_resize_checker.ts} (90%) diff --git a/src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/containers/panel_container.tsx b/src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/containers/panel_container.tsx index dcec12ddefee7..feb835f65d79c 100644 --- a/src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/containers/panel_container.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/containers/panel_container.tsx @@ -34,7 +34,7 @@ const pxToPercent = (proportion: number, whole: number) => (proportion / whole) // TODO: Write tests for this export function PanelsContainer({ children, onPanelWidthChange }: Props) { - const [head, ...rest] = Children.toArray(children); + const [firstChild, ...rest] = Children.toArray(children); const registryRef = useRef(new PanelRegistry()); const containerRef = useRef(null); @@ -44,7 +44,7 @@ export function PanelsContainer({ children, onPanelWidthChange }: Props) { return containerRef.current!.getBoundingClientRect().width; }; - const resizableChildren = rest.reduce( + const childrenWithResizer = rest.reduce( (acc: ReactNode[], child, idx) => { // The target idx is offset by one, we want to target the panel to the left of the resizer // for resizing. @@ -64,7 +64,7 @@ export function PanelsContainer({ children, onPanelWidthChange }: Props) { child, ]); }, - [head] + [firstChild] ); return ( @@ -98,7 +98,7 @@ export function PanelsContainer({ children, onPanelWidthChange }: Props) { setState(initialState); }} > - {resizableChildren} + {childrenWithResizer}
      ); diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/index.ts b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/index.ts index 4a6d1b6b53c9f..9b6940dd0c38c 100644 --- a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/index.ts +++ b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/index.ts @@ -17,4 +17,10 @@ * under the License. */ -export { ConsoleEditor, ConsoleHistory, MemoConsoleEditor } from './legacy'; +export { + ConsoleEditor, + ConsoleHistory, + MemoConsoleEditor, + autoIndent, + getDocumentation, +} from './legacy'; diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor.tsx b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor.tsx deleted file mode 100644 index 1eaf84a0448e0..0000000000000 --- a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor.tsx +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import React, { CSSProperties, useEffect, useRef, useState } from 'react'; -import $ from 'jquery'; -import { EuiToolTip } from '@elastic/eui'; -import { i18n } from '@kbn/i18n'; - -// @ts-ignore -import { initializeInput } from '../../../../../../public/quarantined/src/input'; -// @ts-ignore -import { initializeOutput } from '../../../../../../public/quarantined/src/output'; -// @ts-ignore -import init from '../../../../../../public/quarantined/src/app'; - -import { ConsoleMenu } from '../../../components'; - -import { autoIndent, getDocumentation } from './console_menu_actions'; -import { Panel, PanelsContainer } from '../../../components/split_panel'; - -import { useUIAceKeyboardMode } from './use_ui_ace_keyboard_mode'; -import { useAppContext } from '../../../context'; -import { installEditorsResizeChecker } from './install_console_resize_checker'; - -const PANEL_MIN_WIDTH = '100px'; - -const abs: CSSProperties = { - position: 'absolute', - top: '0', - left: '0', - bottom: '0', - right: '0', -}; - -export interface ConsoleEditorProps { - docLinkVersion: string; - onPanelWidthChange: (widths: number[]) => void; - onEditorsReady: () => void; - initialInputPanelWidth: number; - initialOutputPanelWidth: number; -} - -export function ConsoleEditor({ - onPanelWidthChange, - docLinkVersion, - initialInputPanelWidth, - initialOutputPanelWidth, - onEditorsReady, -}: ConsoleEditorProps) { - const { - services: { history, settings }, - ResizeChecker, - } = useAppContext(); - - const containerRef = useRef(null); - const editorRef = useRef(null); - const outputRef = useRef(null); - const actionsRef = useRef(null); - - const [, setLastRequestTimestamp] = useState(null as any); - const [editor, setEditor] = useState(null as any); - const [, setOutput] = useState(null as any); - const [maybeTextArea, setTextArea] = useState(null); - - const sendCurrentRequest = () => { - editor.focus(); - editor.sendCurrentRequestToES(() => { - // History watches this value and will re-render itself when it changes, so that - // the list of requests stays up-to-date as new requests are sent. - setLastRequestTimestamp(new Date().getTime()); - }); - return false; - }; - - useEffect(() => { - const editor$ = $(editorRef.current!); - const output$ = $(outputRef.current!); - const actions$ = $(actionsRef.current!); - - const outputEditor = initializeOutput(output$, settings); - const inputEditor = initializeInput(editor$, actions$, outputEditor, history, settings); - - settings.registerOutput(outputEditor); - settings.registerInput(inputEditor); - history.setEditor(inputEditor); - - init(inputEditor, outputEditor, history); - - const subscriptions = [ - installEditorsResizeChecker(ResizeChecker, containerRef.current!, inputEditor, outputEditor), - installEditorsResizeChecker(ResizeChecker, editorRef.current!, inputEditor), - installEditorsResizeChecker(ResizeChecker, outputRef.current!, outputEditor), - ]; - - const session = inputEditor.getSession(); - session.getSelection().on('changeCursor', () => { - // Fire and forget - getDocumentation(inputEditor, docLinkVersion); - }); - - setTextArea(editorRef.current!.querySelector('textarea')); - setOutput(outputEditor); - setEditor(inputEditor); - onEditorsReady(); - - return () => { - subscriptions.map(unsubscribe => unsubscribe()); - }; - }, []); - - useUIAceKeyboardMode(maybeTextArea); - - return ( -
      - - -
      -
      -
        -
        - - - - { - editor.getRequestsAsCURL(cb); - }} - getDocumentation={() => { - return getDocumentation(editor, docLinkVersion); - }} - autoIndent={(event: any) => { - autoIndent(editor, event); - }} - /> -
        -
        -
        -
      - - -
      -
      -
      - - -
      - ); -} - -export const MemoConsoleEditor = React.memo(ConsoleEditor); diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/console_editor.tsx b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/console_editor.tsx new file mode 100644 index 0000000000000..225a769ca19bd --- /dev/null +++ b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/console_editor.tsx @@ -0,0 +1,33 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React from 'react'; + +import { MemoReadOnlyEditor } from './readonly_editor'; +import { MemoEditor, EditorProps } from './editor'; + +export type ConsoleEditorProps = { readOnly?: boolean } & EditorProps; + +export function ConsoleEditor(props: ConsoleEditorProps) { + const { readOnly, ...editorProps } = props; + if (props.readOnly) { + return ; + } + return ; +} diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/editor.tsx b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/editor.tsx new file mode 100644 index 0000000000000..87d41c9fdc5b3 --- /dev/null +++ b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/editor.tsx @@ -0,0 +1,118 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React, { CSSProperties, useEffect, useRef, useState } from 'react'; +import { EuiToolTip } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; + +import $ from 'jquery'; + +import { useAppContext } from '../../../../context'; +import { useUIAceKeyboardMode } from '../use_ui_ace_keyboard_mode'; +import { ConsoleMenu } from '../../../../components'; +import { autoIndent, getDocumentation } from '../console_menu_actions'; + +// @ts-ignore +import { initializeInput } from '../../../../../../../public/quarantined/src/input'; + +export interface EditorProps { + onEditorReady?: (editor: any) => void; + sendCurrentRequest?: () => void; + docLinkVersion: string; +} + +const abs: CSSProperties = { + position: 'absolute', + top: '0', + left: '0', + bottom: '0', + right: '0', +}; + +function Editor({ onEditorReady, docLinkVersion, sendCurrentRequest = () => {} }: EditorProps) { + const { + services: { history, settings }, + } = useAppContext(); + + const editorRef = useRef(null); + const actionsRef = useRef(null); + const editorInstanceRef = useRef(null); + + const [textArea, setTextArea] = useState(null); + useUIAceKeyboardMode(textArea); + + useEffect(() => { + const editor$ = $(editorRef.current!); + const actions$ = $(actionsRef.current!); + editorInstanceRef.current = initializeInput(editor$, actions$, history, settings); + if (onEditorReady) { + onEditorReady({ editor: editorInstanceRef.current, element: editorRef.current! }); + } + + const session = editorInstanceRef.current.getSession(); + session.getSelection().on('changeCursor', () => { + // Fire and forget + getDocumentation(editorInstanceRef.current!, docLinkVersion); + }); + + setTextArea(editorRef.current!.querySelector('textarea')); + }, []); + + return ( +
      +
      +
        +
        + + + + { + editorInstanceRef.current!.getRequestsAsCURL(cb); + }} + getDocumentation={() => { + return getDocumentation(editorInstanceRef.current!, docLinkVersion); + }} + autoIndent={(event: any) => { + autoIndent(editorInstanceRef.current!, event); + }} + /> +
        +
        +
        +
      + ); +} + +export const MemoEditor = React.memo(Editor); diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/index.ts b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/index.ts new file mode 100644 index 0000000000000..f7152d818f096 --- /dev/null +++ b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/index.ts @@ -0,0 +1,20 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { ConsoleEditor } from './console_editor'; diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/readonly_editor.tsx b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/readonly_editor.tsx new file mode 100644 index 0000000000000..4c833261ff734 --- /dev/null +++ b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/readonly_editor.tsx @@ -0,0 +1,51 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import React, { useEffect, useRef } from 'react'; +import $ from 'jquery'; + +import { EditorProps } from './editor'; + +// @ts-ignore +import { initializeOutput } from '../../../../../../../public/quarantined/src/output'; +import { useAppContext } from '../../../../context'; + +export type ReadOnlyEditorProps = Pick; + +function ReadOnlyEditor({ onEditorReady }: ReadOnlyEditorProps) { + const editorRef = useRef(null); + const { + services: { settings }, + } = useAppContext(); + + useEffect(() => { + const editor$ = $(editorRef.current!); + const outputEditor = initializeOutput(editor$, settings); + if (onEditorReady) { + onEditorReady({ editor: outputEditor, element: editorRef.current! }); + } + }); + + return ( +
      +
      +
      + ); +} + +export const MemoReadOnlyEditor = React.memo(ReadOnlyEditor); diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_history/history_viewer.tsx b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_history/history_viewer.tsx index 68087b19b3c25..274a3c5783367 100644 --- a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_history/history_viewer.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_history/history_viewer.tsx @@ -22,7 +22,7 @@ import { i18n } from '@kbn/i18n'; import $ from 'jquery'; import { Settings } from '../../../../services'; -import { installEditorsResizeChecker } from '../install_console_resize_checker'; +import { subscribeResizeChecker } from '../subscribe_console_resize_checker'; // @ts-ignore import SenseEditor from '../../../../../../../public/quarantined/src/sense_editor/editor'; @@ -42,7 +42,7 @@ export function HistoryViewer({ settings, ResizeChecker, req }: Props) { viewerRef.current = viewer; viewer.renderer.setShowPrintMargin(false); viewer.$blockScrolling = Infinity; - const unsubscribe = installEditorsResizeChecker(ResizeChecker, divRef.current!, viewer); + const unsubscribe = subscribeResizeChecker(ResizeChecker, divRef.current!, viewer); settings.applyCurrentSettings(viewer); return () => unsubscribe(); }, []); diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/index.ts b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/index.ts index 9b348ceb384bd..e2a495642a1b7 100644 --- a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/index.ts +++ b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/index.ts @@ -17,5 +17,6 @@ * under the License. */ -export { ConsoleEditor, MemoConsoleEditor } from './console_editor'; +export { ConsoleEditor } from './console_editor'; export { ConsoleHistory } from './console_history'; +export { getDocumentation, autoIndent } from './console_menu_actions'; diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/install_console_resize_checker.ts b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/subscribe_console_resize_checker.ts similarity index 90% rename from src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/install_console_resize_checker.ts rename to src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/subscribe_console_resize_checker.ts index e3c0cf7b6619b..ae15a652d40c4 100644 --- a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/install_console_resize_checker.ts +++ b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/subscribe_console_resize_checker.ts @@ -17,7 +17,7 @@ * under the License. */ -export function installEditorsResizeChecker(ResizeChecker: any, $el: any, ...editors: any[]) { +export function subscribeResizeChecker(ResizeChecker: any, $el: any, ...editors: any[]) { const checker = new ResizeChecker($el); checker.on('resize', () => editors.forEach(e => e.resize())); return () => checker.destroy(); diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/main/main.tsx b/src/legacy/core_plugins/console/np_ready/public/app/containers/main/main.tsx index 56bce96ab2e01..1d5c5658037b4 100644 --- a/src/legacy/core_plugins/console/np_ready/public/app/containers/main/main.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/app/containers/main/main.tsx @@ -17,14 +17,18 @@ * under the License. */ -import React, { useCallback, useState } from 'react'; +import React, { useCallback, useEffect, useRef, useState } from 'react'; import { debounce } from 'lodash'; import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; +import { BehaviorSubject, combineLatest } from 'rxjs'; // @ts-ignore import mappings from '../../../../../public/quarantined/src/mappings'; +// @ts-ignore +import init from '../../../../../public/quarantined/src/app'; -import { MemoConsoleEditor, ConsoleHistory } from '../editor'; +import { ConsoleEditor, ConsoleHistory } from '../editor'; +import { subscribeResizeChecker } from '../editor/legacy/subscribe_console_resize_checker'; import { AutocompleteOptions, @@ -32,6 +36,8 @@ import { WelcomePanel, DevToolsSettingsModal, HelpPanel, + PanelsContainer, + Panel, } from '../../components'; import { useAppContext } from '../../context'; @@ -40,14 +46,19 @@ import { StorageKeys, DevToolsSettings } from '../../services'; import { getTopNavConfig } from './get_top_nav'; const INITIAL_PANEL_WIDTH = 50; +const PANEL_MIN_WIDTH = '100px'; export function Main() { const { - services: { storage, settings }, + services: { storage, settings, history }, docLinkVersion, + ResizeChecker, } = useAppContext(); + const [, forceUpdate] = useState(undefined); const [editorReady, setEditorReady] = useState(false); + const [inputEditor, setInputEditor] = useState(null); + const [outputEditor, setOutputEditor] = useState(null); const [showWelcome, setShowWelcomePanel] = useState( () => storage.get('version_welcome_shown') !== '@@SENSE_REVISION' ); @@ -56,6 +67,24 @@ export function Main() { const [showSettings, setShowSettings] = useState(false); const [showHelp, setShowHelp] = useState(false); + const containerRef = useRef(null); + + // We want to only run certain initialization after we now all our editors have + // been instantiated. + const inputReadySubject$ = useRef(new BehaviorSubject(null)); + const outputReadySubject$ = useRef(new BehaviorSubject(null)); + const editorsReady$ = useRef( + combineLatest(inputReadySubject$.current, outputReadySubject$.current) + ); + + const onInputEditorReady = useCallback((value: any) => { + inputReadySubject$.current.next(value); + }, []); + + const onOutputEditorReady = useCallback((value: any) => { + outputReadySubject$.current.next(value); + }, []); + const [firstPanelWidth, secondPanelWidth] = storage.get(StorageKeys.WIDTH, [ INITIAL_PANEL_WIDTH, INITIAL_PANEL_WIDTH, @@ -72,7 +101,12 @@ export function Main() { [] ); - const onEditorReady = useCallback(() => setEditorReady(true), []); + const sendCurrentRequest = () => { + inputEditor.focus(); + inputEditor.sendCurrentRequestToES(() => { + forceUpdate(undefined); + }, outputEditor); + }; const renderConsoleHistory = () => { return editorReady ? setShowHistory(false)} /> : null; @@ -129,8 +163,34 @@ export function Main() { setShowSettings(false); }; + useEffect(() => { + let resizerSubscriptions: Array<() => void> = []; + const subscription = editorsReady$.current.subscribe(([input, output]) => { + settings.registerOutput(output.editor); + settings.registerInput(input.editor); + history.setEditor(input.editor); + + init(input.editor, output.editor, history); + + resizerSubscriptions = resizerSubscriptions.concat([ + subscribeResizeChecker(ResizeChecker, containerRef.current!, input.editor, output.editor), + subscribeResizeChecker(ResizeChecker, input.element, input.editor), + subscribeResizeChecker(ResizeChecker, output.element, output.editor), + ]); + + setInputEditor(input.editor); + setOutputEditor(output.editor); + setEditorReady(true); + }); + + return () => { + resizerSubscriptions.map(done => done()); + subscription.unsubscribe(); + }; + }); + return ( - <> +
      {showingHistory ? {renderConsoleHistory()} : null} - + + + + + + + + @@ -177,6 +252,6 @@ export function Main() { ) : null} {showHelp ? setShowHelp(false)} /> : null} - +
      ); } diff --git a/src/legacy/core_plugins/console/public/quarantined/src/input.js b/src/legacy/core_plugins/console/public/quarantined/src/input.js index d1daccc10bb88..9ccdebed4154e 100644 --- a/src/legacy/core_plugins/console/public/quarantined/src/input.js +++ b/src/legacy/core_plugins/console/public/quarantined/src/input.js @@ -24,14 +24,7 @@ const utils = require('./utils'); const es = require('./es'); let input; -export function initializeInput( - $el, - $actionsEl, - output, - history, - settings, - openDocumentation = () => {} -) { +export function initializeInput($el, $actionsEl, history, settings, openDocumentation = () => {}) { input = new SenseEditor($el); input.autocomplete = new Autocomplete(input); @@ -66,14 +59,16 @@ export function initializeInput( let CURRENT_REQ_ID = 0; - function sendCurrentRequestToES(addedToHistoryCb) { + function sendCurrentRequestToES(addedToHistoryCb, output) { const reqId = ++CURRENT_REQ_ID; input.getRequestsInRange(requests => { if (reqId !== CURRENT_REQ_ID) { return; } - output.update(''); + if (output) { + output.update(''); + } if (requests.length === 0) { return; @@ -160,11 +155,15 @@ export function initializeInput( if (isMultiRequest) { value = '# ' + req.method + ' ' + req.url + '\n' + value; } - if (isFirstRequest) { - output.update(value, mode); - } else { - output.append('\n' + value); + + if (output) { + if (isFirstRequest) { + output.update(value, mode); + } else { + output.append('\n' + value); + } } + isFirstRequest = false; // single request terminate via sendNextRequest as well sendNextRequest(); @@ -188,10 +187,12 @@ export function initializeInput( if (isMultiRequest) { value = '# ' + req.method + ' ' + req.url + '\n' + value; } - if (isFirstRequest) { - output.update(value, mode); - } else { - output.append('\n' + value); + if (output) { + if (isFirstRequest) { + output.update(value, mode); + } else { + output.append('\n' + value); + } } finishChain(); } diff --git a/src/legacy/core_plugins/console/public/quarantined/tests/src/editor.test.js b/src/legacy/core_plugins/console/public/quarantined/tests/src/editor.test.js index 41e3decf33e0d..98879bda3d459 100644 --- a/src/legacy/core_plugins/console/public/quarantined/tests/src/editor.test.js +++ b/src/legacy/core_plugins/console/public/quarantined/tests/src/editor.test.js @@ -45,7 +45,7 @@ describe('Editor', () => { input = initializeInput( $('#ConAppEditor'), $('#ConAppEditorActions'), - $('#ConCopyAsCurl'), + {}, {}, null ); diff --git a/src/legacy/core_plugins/console/public/quarantined/tests/src/input_tokenization.test.js b/src/legacy/core_plugins/console/public/quarantined/tests/src/input_tokenization.test.js index c6005f5b86a77..57b914cf408ea 100644 --- a/src/legacy/core_plugins/console/public/quarantined/tests/src/input_tokenization.test.js +++ b/src/legacy/core_plugins/console/public/quarantined/tests/src/input_tokenization.test.js @@ -39,7 +39,7 @@ describe('Input Tokenization', () => { input = initializeInput( $('#ConAppEditor'), $('#ConAppEditorActions'), - $('#ConCopyAsCurl'), + {}, {}, null ); @@ -47,7 +47,7 @@ describe('Input Tokenization', () => { input = initializeInput( $('#ConAppEditor'), $('#ConAppEditorActions'), - $('#ConCopyAsCurl'), + {}, {}, null ); diff --git a/src/legacy/core_plugins/console/public/quarantined/tests/src/integration.test.js b/src/legacy/core_plugins/console/public/quarantined/tests/src/integration.test.js index 2ecad41f1d2c7..f34306d6339fa 100644 --- a/src/legacy/core_plugins/console/public/quarantined/tests/src/integration.test.js +++ b/src/legacy/core_plugins/console/public/quarantined/tests/src/integration.test.js @@ -38,7 +38,7 @@ describe('Integration', () => { input = initializeInput( $('#ConAppEditor'), $('#ConAppEditorActions'), - $('#ConCopyAsCurl'), + {}, {}, null, ); From 012d760373a35eb0e08bbab16f70de920be976e4 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Tue, 3 Sep 2019 19:04:07 +0200 Subject: [PATCH 22/35] Updated use of contexts with better error message Fixed broken render sync cycles (using useCallback) Fixed Main container render cycle (added missing deps to useEffect) Fixed default input and removed auto indent from being called on init for already formatted text --- .../containers/panel_container.tsx | 8 +++++- .../app/components/split_panel/context.tsx | 8 +++++- .../public/app/components/top_nav_menu.tsx | 4 +-- .../public/app/containers/editor/index.ts | 8 +----- .../legacy/console_editor/console_editor.tsx | 2 +- .../editor/legacy/console_editor/editor.tsx | 6 ++--- .../public/app/containers/main/get_top_nav.ts | 6 ++--- .../public/app/containers/main/main.tsx | 26 +++++++++---------- .../public/app/context/app_context.tsx | 8 +++++- .../console/public/quarantined/src/app.js | 3 +-- 10 files changed, 44 insertions(+), 35 deletions(-) diff --git a/src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/containers/panel_container.tsx b/src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/containers/panel_container.tsx index feb835f65d79c..594c10bf5b353 100644 --- a/src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/containers/panel_container.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/containers/panel_container.tsx @@ -28,6 +28,12 @@ export interface Props { onPanelWidthChange?: (arrayOfPanelWidths: number[]) => any; } +interface State { + currentPanel: number; + isDragging: boolean; + currentResizerPos: number; +} + const initialState = { currentPanel: -1, isDragging: false, currentResizerPos: -1 }; const pxToPercent = (proportion: number, whole: number) => (proportion / whole) * 100; @@ -38,7 +44,7 @@ export function PanelsContainer({ children, onPanelWidthChange }: Props) { const registryRef = useRef(new PanelRegistry()); const containerRef = useRef(null); - const [state, setState] = useState(initialState); + const [state, setState] = useState(initialState); const getContainerWidth = () => { return containerRef.current!.getBoundingClientRect().width; diff --git a/src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/context.tsx b/src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/context.tsx index 0c3aee794b39b..22cfee8720b9d 100644 --- a/src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/context.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/context.tsx @@ -31,4 +31,10 @@ export function PanelContextProvider({ children, registry }: ContextProps) { return {children}; } -export const usePanelContext = () => useContext(PanelContext); +export const usePanelContext = () => { + const context = useContext(PanelContext); + if (context === undefined) { + throw new Error('usePanelContext must be used within a '); + } + return context; +}; diff --git a/src/legacy/core_plugins/console/np_ready/public/app/components/top_nav_menu.tsx b/src/legacy/core_plugins/console/np_ready/public/app/components/top_nav_menu.tsx index 7da9d08036c0b..c83237c52febd 100644 --- a/src/legacy/core_plugins/console/np_ready/public/app/components/top_nav_menu.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/app/components/top_nav_menu.tsx @@ -24,7 +24,7 @@ export interface TopNavMenuItem { id: string; label: string; description: string; - run: () => void; + onClick: () => void; testId: string; } @@ -37,7 +37,7 @@ export function TopNavMenu({ items }: Props) { {items.map((item, idx) => { return ( - + {item.label} ); diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/index.ts b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/index.ts index 9b6940dd0c38c..46cf31d6892dd 100644 --- a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/index.ts +++ b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/index.ts @@ -17,10 +17,4 @@ * under the License. */ -export { - ConsoleEditor, - ConsoleHistory, - MemoConsoleEditor, - autoIndent, - getDocumentation, -} from './legacy'; +export { ConsoleEditor, ConsoleHistory, autoIndent, getDocumentation } from './legacy'; diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/console_editor.tsx b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/console_editor.tsx index 225a769ca19bd..f6b7eb1a780ab 100644 --- a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/console_editor.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/console_editor.tsx @@ -27,7 +27,7 @@ export type ConsoleEditorProps = { readOnly?: boolean } & EditorProps; export function ConsoleEditor(props: ConsoleEditorProps) { const { readOnly, ...editorProps } = props; if (props.readOnly) { - return ; + return ; } return ; } diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/editor.tsx b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/editor.tsx index 87d41c9fdc5b3..750f6bbff6e8f 100644 --- a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/editor.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/editor.tsx @@ -58,9 +58,9 @@ function Editor({ onEditorReady, docLinkVersion, sendCurrentRequest = () => {} } useUIAceKeyboardMode(textArea); useEffect(() => { - const editor$ = $(editorRef.current!); - const actions$ = $(actionsRef.current!); - editorInstanceRef.current = initializeInput(editor$, actions$, history, settings); + const $editor = $(editorRef.current!); + const $actions = $(actionsRef.current!); + editorInstanceRef.current = initializeInput($editor, $actions, history, settings); if (onEditorReady) { onEditorReady({ editor: editorInstanceRef.current, element: editorRef.current! }); } diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/main/get_top_nav.ts b/src/legacy/core_plugins/console/np_ready/public/app/containers/main/get_top_nav.ts index e4437ea6c2f16..330f0d1a6c1cf 100644 --- a/src/legacy/core_plugins/console/np_ready/public/app/containers/main/get_top_nav.ts +++ b/src/legacy/core_plugins/console/np_ready/public/app/containers/main/get_top_nav.ts @@ -35,7 +35,7 @@ export function getTopNavConfig({ onClickHistory, onClickSettings, onClickHelp } description: i18n.translate('console.topNav.historyTabDescription', { defaultMessage: 'History', }), - run: () => { + onClick: () => { onClickHistory(); }, testId: 'consoleHistoryButton', @@ -48,7 +48,7 @@ export function getTopNavConfig({ onClickHistory, onClickSettings, onClickHelp } description: i18n.translate('console.topNav.settingsTabDescription', { defaultMessage: 'Settings', }), - run: () => { + onClick: () => { onClickSettings(); }, testId: 'consoleSettingsButton', @@ -61,7 +61,7 @@ export function getTopNavConfig({ onClickHistory, onClickSettings, onClickHelp } description: i18n.translate('console.topNav.helpTabDescription', { defaultMessage: 'Help', }), - run: () => { + onClick: () => { onClickHelp(); }, testId: 'consoleHelpButton', diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/main/main.tsx b/src/legacy/core_plugins/console/np_ready/public/app/containers/main/main.tsx index 1d5c5658037b4..97cbd6169cd6c 100644 --- a/src/legacy/core_plugins/console/np_ready/public/app/containers/main/main.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/app/containers/main/main.tsx @@ -48,6 +48,12 @@ import { getTopNavConfig } from './get_top_nav'; const INITIAL_PANEL_WIDTH = 50; const PANEL_MIN_WIDTH = '100px'; +// We only run certain initialization after we know all our editors have +// been instantiated -- which is what we use the below streams for. +const inputReadySubject$ = new BehaviorSubject(null); +const outputReadySubject$ = new BehaviorSubject(null); +const editorsReady$ = combineLatest(inputReadySubject$, outputReadySubject$); + export function Main() { const { services: { storage, settings, history }, @@ -69,20 +75,12 @@ export function Main() { const containerRef = useRef(null); - // We want to only run certain initialization after we now all our editors have - // been instantiated. - const inputReadySubject$ = useRef(new BehaviorSubject(null)); - const outputReadySubject$ = useRef(new BehaviorSubject(null)); - const editorsReady$ = useRef( - combineLatest(inputReadySubject$.current, outputReadySubject$.current) - ); - const onInputEditorReady = useCallback((value: any) => { - inputReadySubject$.current.next(value); + inputReadySubject$.next(value); }, []); const onOutputEditorReady = useCallback((value: any) => { - outputReadySubject$.current.next(value); + outputReadySubject$.next(value); }, []); const [firstPanelWidth, secondPanelWidth] = storage.get(StorageKeys.WIDTH, [ @@ -101,12 +99,12 @@ export function Main() { [] ); - const sendCurrentRequest = () => { + const sendCurrentRequest = useCallback(() => { inputEditor.focus(); inputEditor.sendCurrentRequestToES(() => { forceUpdate(undefined); }, outputEditor); - }; + }, [inputEditor, outputEditor]); const renderConsoleHistory = () => { return editorReady ? setShowHistory(false)} /> : null; @@ -165,7 +163,7 @@ export function Main() { useEffect(() => { let resizerSubscriptions: Array<() => void> = []; - const subscription = editorsReady$.current.subscribe(([input, output]) => { + const subscription = editorsReady$.subscribe(([input, output]) => { settings.registerOutput(output.editor); settings.registerInput(input.editor); history.setEditor(input.editor); @@ -187,7 +185,7 @@ export function Main() { resizerSubscriptions.map(done => done()); subscription.unsubscribe(); }; - }); + }, []); return (
      diff --git a/src/legacy/core_plugins/console/np_ready/public/app/context/app_context.tsx b/src/legacy/core_plugins/console/np_ready/public/app/context/app_context.tsx index f7040fcc3234e..67139db9e56a9 100644 --- a/src/legacy/core_plugins/console/np_ready/public/app/context/app_context.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/app/context/app_context.tsx @@ -41,4 +41,10 @@ export function AppContextProvider({ children, value }: ContextProps) { return {children}; } -export const useAppContext = () => useContext(AppContext); +export const useAppContext = () => { + const context = useContext(AppContext); + if (context === undefined) { + throw new Error('useAppContext must be used inside the AppContextProvider.'); + } + return context; +}; diff --git a/src/legacy/core_plugins/console/public/quarantined/src/app.js b/src/legacy/core_plugins/console/public/quarantined/src/app.js index 4ceb6808e8b20..610e006f76e0f 100644 --- a/src/legacy/core_plugins/console/public/quarantined/src/app.js +++ b/src/legacy/core_plugins/console/public/quarantined/src/app.js @@ -23,7 +23,7 @@ const mappings = require('./mappings'); const DEFAULT_INPUT_VALUE = `GET _search { "query": { - "match_all": { } + "match_all": {} } }`; @@ -64,7 +64,6 @@ export default function init(input, output, history, sourceLocation = 'stored') resetToValues(previousSaveState.content); } else { resetToValues(); - input.autoIndent(); } } else if (/^https?:\/\//.test(sourceLocation)) { const loadFrom = { From 2b2509c14fe7d3ac5d51b10170561213987c4bf8 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Tue, 3 Sep 2019 22:42:32 +0200 Subject: [PATCH 23/35] Updated test mocks --- .../console/public/quarantined/tests/src/editor.test.js | 2 +- .../public/quarantined/tests/src/input_tokenization.test.js | 4 ++-- .../console/public/quarantined/tests/src/integration.test.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/legacy/core_plugins/console/public/quarantined/tests/src/editor.test.js b/src/legacy/core_plugins/console/public/quarantined/tests/src/editor.test.js index 98879bda3d459..a356f8ff29cdc 100644 --- a/src/legacy/core_plugins/console/public/quarantined/tests/src/editor.test.js +++ b/src/legacy/core_plugins/console/public/quarantined/tests/src/editor.test.js @@ -46,7 +46,7 @@ describe('Editor', () => { $('#ConAppEditor'), $('#ConAppEditorActions'), {}, - {}, + { applyCurrentSettings: () => {} }, null ); input.$el.show(); diff --git a/src/legacy/core_plugins/console/public/quarantined/tests/src/input_tokenization.test.js b/src/legacy/core_plugins/console/public/quarantined/tests/src/input_tokenization.test.js index 57b914cf408ea..7267956f57280 100644 --- a/src/legacy/core_plugins/console/public/quarantined/tests/src/input_tokenization.test.js +++ b/src/legacy/core_plugins/console/public/quarantined/tests/src/input_tokenization.test.js @@ -40,7 +40,7 @@ describe('Input Tokenization', () => { $('#ConAppEditor'), $('#ConAppEditorActions'), {}, - {}, + { applyCurrentSettings: () => {} }, null ); @@ -48,7 +48,7 @@ describe('Input Tokenization', () => { $('#ConAppEditor'), $('#ConAppEditorActions'), {}, - {}, + { applyCurrentSettings: () => {} }, null ); input.$el.show(); diff --git a/src/legacy/core_plugins/console/public/quarantined/tests/src/integration.test.js b/src/legacy/core_plugins/console/public/quarantined/tests/src/integration.test.js index f34306d6339fa..5bd8fd4a5b4f5 100644 --- a/src/legacy/core_plugins/console/public/quarantined/tests/src/integration.test.js +++ b/src/legacy/core_plugins/console/public/quarantined/tests/src/integration.test.js @@ -39,7 +39,7 @@ describe('Integration', () => { $('#ConAppEditor'), $('#ConAppEditorActions'), {}, - {}, + { applyCurrentSettings: () => {} }, null, ); input.$el.show(); From 758064d50167dc006f37e24830600ced2f0df829 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Wed, 4 Sep 2019 10:16:41 +0200 Subject: [PATCH 24/35] Update to be more in line with NP conventions https://github.com/elastic/kibana/blob/master/src/core/CONVENTIONS.md --- .../{app => application}/components/console_menu.tsx | 0 .../{app => application}/components/editor_example.tsx | 0 .../public/{app => application}/components/help_panel.tsx | 0 .../public/{app => application}/components/index.ts | 0 .../{app => application}/components/settings_modal.tsx | 2 +- .../components/split_panel/components/resizer.tsx | 0 .../components/split_panel/containers/panel.tsx | 0 .../components/split_panel/containers/panel_container.tsx | 0 .../components/split_panel/context.tsx | 0 .../{app => application}/components/split_panel/index.ts | 0 .../components/split_panel/registry.ts | 0 .../{app => application}/components/top_nav_menu.tsx | 0 .../{app => application}/components/welcome_panel.tsx | 0 .../{app => application}/constants/help_example.txt | 0 .../{app => application}/containers/editor/index.ts | 0 .../editor/legacy/console_editor/console_editor.tsx | 0 .../containers/editor/legacy/console_editor/editor.tsx | 0 .../containers/editor/legacy/console_editor/index.ts | 0 .../editor/legacy/console_editor/readonly_editor.tsx | 0 .../editor/legacy/console_history/console_history.tsx | 0 .../editor/legacy/console_history/history_viewer.tsx | 2 +- .../containers/editor/legacy/console_history/index.ts | 0 .../containers/editor/legacy/console_menu_actions.ts | 0 .../containers/editor/legacy/index.ts | 0 .../editor/legacy/subscribe_console_resize_checker.ts | 0 .../containers/editor/legacy/use_ui_ace_keyboard_mode.tsx | 0 .../public/{app => application}/containers/index.ts | 0 .../{app => application}/containers/main/get_top_nav.ts | 0 .../public/{app => application}/containers/main/index.ts | 0 .../public/{app => application}/containers/main/main.tsx | 2 +- .../public/{app => application}/context/app_context.tsx | 2 +- .../np_ready/public/{app => application}/context/index.ts | 0 .../np_ready/public/{app => application}/index.tsx | 2 +- .../console/np_ready/public/{app => application}/logo.svg | 0 src/legacy/core_plugins/console/np_ready/public/legacy.ts | 4 ++-- src/legacy/core_plugins/console/np_ready/public/plugin.ts | 8 ++++---- .../console/np_ready/public/{app => }/services/history.ts | 2 +- .../console/np_ready/public/{app => }/services/index.ts | 0 .../np_ready/public/{app => }/services/settings.ts | 2 +- .../console/np_ready/public/{app => }/services/storage.ts | 0 .../console/public/quarantined/src/mappings.js | 2 +- 41 files changed, 14 insertions(+), 14 deletions(-) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/components/console_menu.tsx (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/components/editor_example.tsx (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/components/help_panel.tsx (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/components/index.ts (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/components/settings_modal.tsx (99%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/components/split_panel/components/resizer.tsx (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/components/split_panel/containers/panel.tsx (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/components/split_panel/containers/panel_container.tsx (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/components/split_panel/context.tsx (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/components/split_panel/index.ts (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/components/split_panel/registry.ts (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/components/top_nav_menu.tsx (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/components/welcome_panel.tsx (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/constants/help_example.txt (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/containers/editor/index.ts (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/containers/editor/legacy/console_editor/console_editor.tsx (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/containers/editor/legacy/console_editor/editor.tsx (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/containers/editor/legacy/console_editor/index.ts (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/containers/editor/legacy/console_editor/readonly_editor.tsx (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/containers/editor/legacy/console_history/console_history.tsx (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/containers/editor/legacy/console_history/history_viewer.tsx (97%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/containers/editor/legacy/console_history/index.ts (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/containers/editor/legacy/console_menu_actions.ts (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/containers/editor/legacy/index.ts (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/containers/editor/legacy/subscribe_console_resize_checker.ts (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/containers/index.ts (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/containers/main/get_top_nav.ts (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/containers/main/index.ts (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/containers/main/main.tsx (99%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/context/app_context.tsx (96%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/context/index.ts (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/index.tsx (98%) rename src/legacy/core_plugins/console/np_ready/public/{app => application}/logo.svg (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => }/services/history.ts (98%) rename src/legacy/core_plugins/console/np_ready/public/{app => }/services/index.ts (100%) rename src/legacy/core_plugins/console/np_ready/public/{app => }/services/settings.ts (99%) rename src/legacy/core_plugins/console/np_ready/public/{app => }/services/storage.ts (100%) diff --git a/src/legacy/core_plugins/console/np_ready/public/app/components/console_menu.tsx b/src/legacy/core_plugins/console/np_ready/public/application/components/console_menu.tsx similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/components/console_menu.tsx rename to src/legacy/core_plugins/console/np_ready/public/application/components/console_menu.tsx diff --git a/src/legacy/core_plugins/console/np_ready/public/app/components/editor_example.tsx b/src/legacy/core_plugins/console/np_ready/public/application/components/editor_example.tsx similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/components/editor_example.tsx rename to src/legacy/core_plugins/console/np_ready/public/application/components/editor_example.tsx diff --git a/src/legacy/core_plugins/console/np_ready/public/app/components/help_panel.tsx b/src/legacy/core_plugins/console/np_ready/public/application/components/help_panel.tsx similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/components/help_panel.tsx rename to src/legacy/core_plugins/console/np_ready/public/application/components/help_panel.tsx diff --git a/src/legacy/core_plugins/console/np_ready/public/app/components/index.ts b/src/legacy/core_plugins/console/np_ready/public/application/components/index.ts similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/components/index.ts rename to src/legacy/core_plugins/console/np_ready/public/application/components/index.ts diff --git a/src/legacy/core_plugins/console/np_ready/public/app/components/settings_modal.tsx b/src/legacy/core_plugins/console/np_ready/public/application/components/settings_modal.tsx similarity index 99% rename from src/legacy/core_plugins/console/np_ready/public/app/components/settings_modal.tsx rename to src/legacy/core_plugins/console/np_ready/public/application/components/settings_modal.tsx index d4e2ffdfe2022..9ecfc1bc4d446 100644 --- a/src/legacy/core_plugins/console/np_ready/public/app/components/settings_modal.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/application/components/settings_modal.tsx @@ -36,7 +36,7 @@ import { EuiSwitch, } from '@elastic/eui'; -import { DevToolsSettings } from '../services'; +import { DevToolsSettings } from '../../services'; export type AutocompleteOptions = 'fields' | 'indices' | 'templates'; diff --git a/src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/components/resizer.tsx b/src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/components/resizer.tsx similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/components/resizer.tsx rename to src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/components/resizer.tsx diff --git a/src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/containers/panel.tsx b/src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/containers/panel.tsx similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/containers/panel.tsx rename to src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/containers/panel.tsx diff --git a/src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/containers/panel_container.tsx b/src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/containers/panel_container.tsx similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/containers/panel_container.tsx rename to src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/containers/panel_container.tsx diff --git a/src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/context.tsx b/src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/context.tsx similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/context.tsx rename to src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/context.tsx diff --git a/src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/index.ts b/src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/index.ts similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/index.ts rename to src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/index.ts diff --git a/src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/registry.ts b/src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/registry.ts similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/components/split_panel/registry.ts rename to src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/registry.ts diff --git a/src/legacy/core_plugins/console/np_ready/public/app/components/top_nav_menu.tsx b/src/legacy/core_plugins/console/np_ready/public/application/components/top_nav_menu.tsx similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/components/top_nav_menu.tsx rename to src/legacy/core_plugins/console/np_ready/public/application/components/top_nav_menu.tsx diff --git a/src/legacy/core_plugins/console/np_ready/public/app/components/welcome_panel.tsx b/src/legacy/core_plugins/console/np_ready/public/application/components/welcome_panel.tsx similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/components/welcome_panel.tsx rename to src/legacy/core_plugins/console/np_ready/public/application/components/welcome_panel.tsx diff --git a/src/legacy/core_plugins/console/np_ready/public/app/constants/help_example.txt b/src/legacy/core_plugins/console/np_ready/public/application/constants/help_example.txt similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/constants/help_example.txt rename to src/legacy/core_plugins/console/np_ready/public/application/constants/help_example.txt diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/index.ts b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/index.ts similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/containers/editor/index.ts rename to src/legacy/core_plugins/console/np_ready/public/application/containers/editor/index.ts diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/console_editor.tsx b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/console_editor.tsx similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/console_editor.tsx rename to src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/console_editor.tsx diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/editor.tsx b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/editor.tsx similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/editor.tsx rename to src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/editor.tsx diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/index.ts b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/index.ts similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/index.ts rename to src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/index.ts diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/readonly_editor.tsx b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/readonly_editor.tsx similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_editor/readonly_editor.tsx rename to src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/readonly_editor.tsx diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_history/console_history.tsx b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_history/console_history.tsx similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_history/console_history.tsx rename to src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_history/console_history.tsx diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_history/history_viewer.tsx b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_history/history_viewer.tsx similarity index 97% rename from src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_history/history_viewer.tsx rename to src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_history/history_viewer.tsx index 274a3c5783367..b8f857299a219 100644 --- a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_history/history_viewer.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_history/history_viewer.tsx @@ -21,7 +21,7 @@ import React, { useEffect, useRef } from 'react'; import { i18n } from '@kbn/i18n'; import $ from 'jquery'; -import { Settings } from '../../../../services'; +import { Settings } from '../../../../../services'; import { subscribeResizeChecker } from '../subscribe_console_resize_checker'; // @ts-ignore diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_history/index.ts b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_history/index.ts similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_history/index.ts rename to src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_history/index.ts diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_menu_actions.ts b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_menu_actions.ts similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/console_menu_actions.ts rename to src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_menu_actions.ts diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/index.ts b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/index.ts similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/index.ts rename to src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/index.ts diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/subscribe_console_resize_checker.ts b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/subscribe_console_resize_checker.ts similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/subscribe_console_resize_checker.ts rename to src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/subscribe_console_resize_checker.ts diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx rename to src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/index.ts b/src/legacy/core_plugins/console/np_ready/public/application/containers/index.ts similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/containers/index.ts rename to src/legacy/core_plugins/console/np_ready/public/application/containers/index.ts diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/main/get_top_nav.ts b/src/legacy/core_plugins/console/np_ready/public/application/containers/main/get_top_nav.ts similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/containers/main/get_top_nav.ts rename to src/legacy/core_plugins/console/np_ready/public/application/containers/main/get_top_nav.ts diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/main/index.ts b/src/legacy/core_plugins/console/np_ready/public/application/containers/main/index.ts similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/containers/main/index.ts rename to src/legacy/core_plugins/console/np_ready/public/application/containers/main/index.ts diff --git a/src/legacy/core_plugins/console/np_ready/public/app/containers/main/main.tsx b/src/legacy/core_plugins/console/np_ready/public/application/containers/main/main.tsx similarity index 99% rename from src/legacy/core_plugins/console/np_ready/public/app/containers/main/main.tsx rename to src/legacy/core_plugins/console/np_ready/public/application/containers/main/main.tsx index 97cbd6169cd6c..67ff05172793e 100644 --- a/src/legacy/core_plugins/console/np_ready/public/app/containers/main/main.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/application/containers/main/main.tsx @@ -41,7 +41,7 @@ import { } from '../../components'; import { useAppContext } from '../../context'; -import { StorageKeys, DevToolsSettings } from '../../services'; +import { StorageKeys, DevToolsSettings } from '../../../services'; import { getTopNavConfig } from './get_top_nav'; diff --git a/src/legacy/core_plugins/console/np_ready/public/app/context/app_context.tsx b/src/legacy/core_plugins/console/np_ready/public/application/context/app_context.tsx similarity index 96% rename from src/legacy/core_plugins/console/np_ready/public/app/context/app_context.tsx rename to src/legacy/core_plugins/console/np_ready/public/application/context/app_context.tsx index 67139db9e56a9..7811f27b94075 100644 --- a/src/legacy/core_plugins/console/np_ready/public/app/context/app_context.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/application/context/app_context.tsx @@ -18,7 +18,7 @@ */ import React, { createContext, useContext } from 'react'; -import { History, Storage, Settings } from '../services'; +import { History, Storage, Settings } from '../../services'; interface ContextValue { services: { diff --git a/src/legacy/core_plugins/console/np_ready/public/app/context/index.ts b/src/legacy/core_plugins/console/np_ready/public/application/context/index.ts similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/context/index.ts rename to src/legacy/core_plugins/console/np_ready/public/application/context/index.ts diff --git a/src/legacy/core_plugins/console/np_ready/public/app/index.tsx b/src/legacy/core_plugins/console/np_ready/public/application/index.tsx similarity index 98% rename from src/legacy/core_plugins/console/np_ready/public/app/index.tsx rename to src/legacy/core_plugins/console/np_ready/public/application/index.tsx index 8b80bd439f775..5fb6e05aa9234 100644 --- a/src/legacy/core_plugins/console/np_ready/public/app/index.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/application/index.tsx @@ -20,7 +20,7 @@ import React from 'react'; import { AppContextProvider } from './context'; import { Main } from './containers'; -import { createStorage, createHistory, createSettings, Settings } from './services'; +import { createStorage, createHistory, createSettings, Settings } from '../services'; let settingsRef: Settings; export function legacyBackDoorToSettings() { diff --git a/src/legacy/core_plugins/console/np_ready/public/app/logo.svg b/src/legacy/core_plugins/console/np_ready/public/application/logo.svg similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/logo.svg rename to src/legacy/core_plugins/console/np_ready/public/application/logo.svg diff --git a/src/legacy/core_plugins/console/np_ready/public/legacy.ts b/src/legacy/core_plugins/console/np_ready/public/legacy.ts index a7dfd9b8496f1..5535bc3c4b9ff 100644 --- a/src/legacy/core_plugins/console/np_ready/public/legacy.ts +++ b/src/legacy/core_plugins/console/np_ready/public/legacy.ts @@ -38,7 +38,7 @@ import { CoreSetup } from '../../../../../core/public'; interface SetupRegisterAppArgs { id: string; - mount: (ctx: any, targetElement: HTMLDivElement) => Promise; + mount: (ctx: any, opts: { element: HTMLDivElement }) => Promise; } export interface XCoreSetup extends CoreSetup { @@ -77,7 +77,7 @@ uiRoutes.when('/dev_tools/console', { ...npSetup.core, application: { register(args: SetupRegisterAppArgs): void { - args.mount({}, targetElement).catch(err => { + args.mount({}, { element: targetElement }).catch(err => { npSetup.core.fatalErrors.add(err); }); }, diff --git a/src/legacy/core_plugins/console/np_ready/public/plugin.ts b/src/legacy/core_plugins/console/np_ready/public/plugin.ts index 6c4d957bb5a6c..0028a78be0296 100644 --- a/src/legacy/core_plugins/console/np_ready/public/plugin.ts +++ b/src/legacy/core_plugins/console/np_ready/public/plugin.ts @@ -21,7 +21,7 @@ import { render, unmountComponentAtNode } from 'react-dom'; import { PluginInitializerContext, Plugin, CoreStart } from '../../../../../core/public'; import { XCoreSetup, XPluginSet } from './legacy'; -import { boot } from './app'; +import { boot } from './application'; export class ConsoleUIPlugin implements Plugin { // @ts-ignore @@ -34,9 +34,9 @@ export class ConsoleUIPlugin implements Plugin { application.register({ id: 'console', - async mount(ctx, targetElement) { - render(boot({ docLinkVersion, I18nContext, ResizeChecker }), targetElement); - return () => unmountComponentAtNode(targetElement); + async mount(ctx, { element }) { + render(boot({ docLinkVersion, I18nContext, ResizeChecker }), element); + return () => unmountComponentAtNode(element); }, }); } diff --git a/src/legacy/core_plugins/console/np_ready/public/app/services/history.ts b/src/legacy/core_plugins/console/np_ready/public/services/history.ts similarity index 98% rename from src/legacy/core_plugins/console/np_ready/public/app/services/history.ts rename to src/legacy/core_plugins/console/np_ready/public/services/history.ts index cef605dc11952..fba33feb101b1 100644 --- a/src/legacy/core_plugins/console/np_ready/public/app/services/history.ts +++ b/src/legacy/core_plugins/console/np_ready/public/services/history.ts @@ -17,7 +17,7 @@ * under the License. */ -import { Storage } from '.'; +import { Storage } from './index'; export class History { private editor: any; diff --git a/src/legacy/core_plugins/console/np_ready/public/app/services/index.ts b/src/legacy/core_plugins/console/np_ready/public/services/index.ts similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/services/index.ts rename to src/legacy/core_plugins/console/np_ready/public/services/index.ts diff --git a/src/legacy/core_plugins/console/np_ready/public/app/services/settings.ts b/src/legacy/core_plugins/console/np_ready/public/services/settings.ts similarity index 99% rename from src/legacy/core_plugins/console/np_ready/public/app/services/settings.ts rename to src/legacy/core_plugins/console/np_ready/public/services/settings.ts index c5cd19b32bfdc..5986a8e0eddde 100644 --- a/src/legacy/core_plugins/console/np_ready/public/app/services/settings.ts +++ b/src/legacy/core_plugins/console/np_ready/public/services/settings.ts @@ -17,7 +17,7 @@ * under the License. */ -import { Storage } from '.'; +import { Storage } from './index'; export interface DevToolsSettings { fontSize: number; diff --git a/src/legacy/core_plugins/console/np_ready/public/app/services/storage.ts b/src/legacy/core_plugins/console/np_ready/public/services/storage.ts similarity index 100% rename from src/legacy/core_plugins/console/np_ready/public/app/services/storage.ts rename to src/legacy/core_plugins/console/np_ready/public/services/storage.ts diff --git a/src/legacy/core_plugins/console/public/quarantined/src/mappings.js b/src/legacy/core_plugins/console/public/quarantined/src/mappings.js index 90c7068e34344..4538b058c2d8b 100644 --- a/src/legacy/core_plugins/console/public/quarantined/src/mappings.js +++ b/src/legacy/core_plugins/console/public/quarantined/src/mappings.js @@ -17,7 +17,7 @@ * under the License. */ -import { legacyBackDoorToSettings } from '../../../np_ready/public/app'; +import { legacyBackDoorToSettings } from '../../../np_ready/public/application'; const $ = require('jquery'); const _ = require('lodash'); From 313034388f4bd23e42a872f733b6bb77c64b9931 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Wed, 4 Sep 2019 13:48:23 +0200 Subject: [PATCH 25/35] Update console history when making new requests Fixed spacing between editor and console history Moved registration of keyboard commands to TS Fixed setup_mocks.js after renaming app to application --- .../editor/legacy/console_editor/editor.tsx | 17 ++ .../console_editor/keyboard_shortcuts.ts | 60 +++++ .../console_history/console_history.tsx | 231 +++++++++--------- .../application/containers/main/main.tsx | 8 +- .../quarantined/src/directives/_history.scss | 10 +- .../console/public/quarantined/src/input.js | 37 +-- .../quarantined/tests/src/setup_mocks.js | 2 +- 7 files changed, 214 insertions(+), 151 deletions(-) create mode 100644 src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/keyboard_shortcuts.ts diff --git a/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/editor.tsx b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/editor.tsx index 750f6bbff6e8f..588991c931077 100644 --- a/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/editor.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/editor.tsx @@ -27,6 +27,7 @@ import { useAppContext } from '../../../../context'; import { useUIAceKeyboardMode } from '../use_ui_ace_keyboard_mode'; import { ConsoleMenu } from '../../../../components'; import { autoIndent, getDocumentation } from '../console_menu_actions'; +import { registerCommands } from './keyboard_shortcuts'; // @ts-ignore import { initializeInput } from '../../../../../../../public/quarantined/src/input'; @@ -57,6 +58,14 @@ function Editor({ onEditorReady, docLinkVersion, sendCurrentRequest = () => {} } const [textArea, setTextArea] = useState(null); useUIAceKeyboardMode(textArea); + const openDocumentation = async () => { + const documentation = await getDocumentation(editorInstanceRef.current!, docLinkVersion); + if (!documentation) { + return; + } + window.open(documentation, '_blank'); + }; + useEffect(() => { const $editor = $(editorRef.current!); const $actions = $(actionsRef.current!); @@ -74,6 +83,14 @@ function Editor({ onEditorReady, docLinkVersion, sendCurrentRequest = () => {} } setTextArea(editorRef.current!.querySelector('textarea')); }, []); + useEffect(() => { + registerCommands({ + input: editorInstanceRef.current, + sendCurrentRequestToES: sendCurrentRequest, + openDocumentation, + }); + }, [sendCurrentRequest]); + return (
      diff --git a/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/keyboard_shortcuts.ts b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/keyboard_shortcuts.ts new file mode 100644 index 0000000000000..be1826afd7827 --- /dev/null +++ b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/keyboard_shortcuts.ts @@ -0,0 +1,60 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +interface Actions { + input: any; + sendCurrentRequestToES: () => void; + openDocumentation: () => void; +} + +export function registerCommands({ input, sendCurrentRequestToES, openDocumentation }: Actions) { + input.commands.addCommand({ + name: 'send to elasticsearch', + bindKey: { win: 'Ctrl-Enter', mac: 'Command-Enter' }, + exec: () => sendCurrentRequestToES(), + }); + input.commands.addCommand({ + name: 'open documentation', + bindKey: { win: 'Ctrl-/', mac: 'Command-/' }, + exec: () => { + openDocumentation(); + }, + }); + input.commands.addCommand({ + name: 'auto indent request', + bindKey: { win: 'Ctrl-I', mac: 'Command-I' }, + exec: () => { + input.autoIndent(); + }, + }); + input.commands.addCommand({ + name: 'move to previous request start or end', + bindKey: { win: 'Ctrl-Up', mac: 'Command-Up' }, + exec: () => { + input.moveToPreviousRequestEdge(); + }, + }); + input.commands.addCommand({ + name: 'move to next request start or end', + bindKey: { win: 'Ctrl-Down', mac: 'Command-Down' }, + exec: () => { + input.moveToNextRequestEdge(); + }, + }); +} diff --git a/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_history/console_history.tsx b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_history/console_history.tsx index a0b48fcd5ea77..8301474e5d3a1 100644 --- a/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_history/console_history.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_history/console_history.tsx @@ -21,26 +21,36 @@ import React, { useEffect, useRef, useState } from 'react'; import { i18n } from '@kbn/i18n'; import { memoize } from 'lodash'; import moment from 'moment'; -import { keyCodes } from '@elastic/eui'; +import { keyCodes, EuiSpacer } from '@elastic/eui'; import { useAppContext } from '../../../../context'; import { HistoryViewer } from './history_viewer'; interface Props { close: () => void; + reqs: any[]; } -export function ConsoleHistory({ close }: Props) { +const CHILD_ELEMENT_PREFIX = 'historyReq'; + +export function ConsoleHistory({ close, reqs }: Props) { const { services: { history, settings }, ResizeChecker, } = useAppContext(); - const [reqs, setReqs] = useState([]); - const [selectedIndex, setSelectedIndex] = useState(0); + const listRef = useRef(null); + const [viewingReq, setViewingReq] = useState(null); + const [selectedIndex, setSelectedIndex] = useState(0); const selectedReq = useRef(null); - const viewingReq = useRef(null); + + const scrollIntoView = (idx: number) => { + const activeDescendant = listRef.current!.querySelector(`#${CHILD_ELEMENT_PREFIX}${idx}`); + if (activeDescendant) { + activeDescendant.scrollIntoView(); + } + }; const [describeReq] = useState(() => { const _describeReq = (req: any) => { @@ -61,12 +71,12 @@ export function ConsoleHistory({ close }: Props) { }); const initialize = () => { - const nextReqs = history.getHistory(); const nextSelectedIndex = 0; - selectedReq.current = viewingReq.current = nextReqs[nextSelectedIndex]; (describeReq as any).cache = new WeakMap(); + setViewingReq(reqs[nextSelectedIndex]); + selectedReq.current = reqs[nextSelectedIndex]; setSelectedIndex(nextSelectedIndex); - setReqs(nextReqs); + scrollIntoView(nextSelectedIndex); }; const clear = () => { @@ -80,115 +90,118 @@ export function ConsoleHistory({ close }: Props) { useEffect(() => { initialize(); - }, []); + }, [reqs]); /* eslint-disable */ return ( -
      -

      - {i18n.translate('console.historyPage.pageTitle', { defaultMessage: 'History' })} -

      -
      -
        { - if (ev.keyCode === keyCodes.ENTER) { - restore(); - return; - } - - let currentIdx = selectedIndex; - - if (ev.keyCode === keyCodes.UP) { - ev.preventDefault(); - --currentIdx; - } else if (ev.keyCode === keyCodes.DOWN) { - ev.preventDefault(); - ++currentIdx; - } - - const nextSelectedIndex = Math.min(Math.max(0, currentIdx), reqs.length - 1); - - selectedReq.current = reqs[nextSelectedIndex]; - viewingReq.current = reqs[nextSelectedIndex]; - setSelectedIndex(nextSelectedIndex); - }} - role="listbox" - className="list-group conHistory__reqs" - tabIndex={0} - aria-activedescendant={`historyReq${selectedIndex}`} - scrollto-activedescendant="true" - aria-label={i18n.translate('console.historyPage.requestListAriaLabel', { - defaultMessage: 'History of sent requests', - })} - > - {reqs.map((req, idx) => { - const reqDescription = describeReq(req); - const isSelected = viewingReq.current === req; - return ( - // Ignore a11y issues on li's - // eslint-disable-next-line -
      • { - selectedReq.current = req; - viewingReq.current = req; - setSelectedIndex(idx); - }} - role="option" - onMouseEnter={() => (viewingReq.current = req)} - onMouseLeave={() => (viewingReq.current = selectedReq.current)} - onDoubleClick={() => restore(req)} - aria-label={i18n.translate('console.historyPage.itemOfRequestListAriaLabel', { - defaultMessage: 'Request: {historyItem}', - values: { historyItem: reqDescription }, - })} - aria-selected={isSelected} - > - {reqDescription} - - - -
      • - ); - })} -
      - - -
      - -
      - - -
      - - -
    + +
    + + +
    + +
    + + +
    + + + +
    -
    + + ); } diff --git a/src/legacy/core_plugins/console/np_ready/public/application/containers/main/main.tsx b/src/legacy/core_plugins/console/np_ready/public/application/containers/main/main.tsx index 67ff05172793e..83dbc290a87ef 100644 --- a/src/legacy/core_plugins/console/np_ready/public/application/containers/main/main.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/application/containers/main/main.tsx @@ -61,7 +61,7 @@ export function Main() { ResizeChecker, } = useAppContext(); - const [, forceUpdate] = useState(undefined); + const [pastRequests, setPastRequests] = useState(() => history.getHistory()); const [editorReady, setEditorReady] = useState(false); const [inputEditor, setInputEditor] = useState(null); const [outputEditor, setOutputEditor] = useState(null); @@ -102,12 +102,14 @@ export function Main() { const sendCurrentRequest = useCallback(() => { inputEditor.focus(); inputEditor.sendCurrentRequestToES(() => { - forceUpdate(undefined); + setPastRequests(history.getHistory()); }, outputEditor); }, [inputEditor, outputEditor]); const renderConsoleHistory = () => { - return editorReady ? setShowHistory(false)} /> : null; + return editorReady ? ( + setShowHistory(false)} /> + ) : null; }; const refreshAutocompleteSettings = (selectedSettings: any) => { diff --git a/src/legacy/core_plugins/console/public/quarantined/src/directives/_history.scss b/src/legacy/core_plugins/console/public/quarantined/src/directives/_history.scss index 1d13d366eec08..9104176bd384e 100644 --- a/src/legacy/core_plugins/console/public/quarantined/src/directives/_history.scss +++ b/src/legacy/core_plugins/console/public/quarantined/src/directives/_history.scss @@ -8,6 +8,9 @@ .conHistory__body { display: flex; height: $euiSizeXL * 10; + > ul { + margin-bottom: 0; + } } @@ -21,14 +24,17 @@ text-align: right; } +.conHistory__body__spacer { + flex: 0 0 1%; +} + .conHistory__reqs, .conHistory__viewer { - flex: 0 0 50%; + flex: 0 0 49.5%; } .conHistory__reqs { overflow: auto; - margin-right: $euiSizeL; } .conHistory__req { diff --git a/src/legacy/core_plugins/console/public/quarantined/src/input.js b/src/legacy/core_plugins/console/public/quarantined/src/input.js index 9ccdebed4154e..89672a5823ad5 100644 --- a/src/legacy/core_plugins/console/public/quarantined/src/input.js +++ b/src/legacy/core_plugins/console/public/quarantined/src/input.js @@ -24,35 +24,13 @@ const utils = require('./utils'); const es = require('./es'); let input; -export function initializeInput($el, $actionsEl, history, settings, openDocumentation = () => {}) { +export function initializeInput($el, $actionsEl, history, settings) { input = new SenseEditor($el); input.autocomplete = new Autocomplete(input); input.$actions = $actionsEl; - input.commands.addCommand({ - name: 'auto indent request', - bindKey: { win: 'Ctrl-I', mac: 'Command-I' }, - exec: () => { - input.autoIndent(); - }, - }); - input.commands.addCommand({ - name: 'move to previous request start or end', - bindKey: { win: 'Ctrl-Up', mac: 'Command-Up' }, - exec: () => { - input.moveToPreviousRequestEdge(); - }, - }); - input.commands.addCommand({ - name: 'move to next request start or end', - bindKey: { win: 'Ctrl-Down', mac: 'Command-Down' }, - exec: () => { - input.moveToNextRequestEdge(); - }, - }); - /** * Setup the "send" shortcut */ @@ -203,19 +181,6 @@ export function initializeInput($el, $actionsEl, history, settings, openDocument }); } - input.commands.addCommand({ - name: 'send to elasticsearch', - bindKey: { win: 'Ctrl-Enter', mac: 'Command-Enter' }, - exec: () => sendCurrentRequestToES(), - }); - input.commands.addCommand({ - name: 'open documentation', - bindKey: { win: 'Ctrl-/', mac: 'Command-/' }, - exec: () => { - openDocumentation(); - }, - }); - /** * Init the editor */ diff --git a/src/legacy/core_plugins/console/public/quarantined/tests/src/setup_mocks.js b/src/legacy/core_plugins/console/public/quarantined/tests/src/setup_mocks.js index b151cf04cf135..e0a4a04638178 100644 --- a/src/legacy/core_plugins/console/public/quarantined/tests/src/setup_mocks.js +++ b/src/legacy/core_plugins/console/public/quarantined/tests/src/setup_mocks.js @@ -36,7 +36,7 @@ import 'brace/ext/searchbox'; import 'brace/mode/json'; import 'brace/mode/text'; -jest.mock('../../../../np_ready/public/app', () => ({ legacyBackDoorToSettings: () => {} })); +jest.mock('../../../../np_ready/public/application', () => ({ legacyBackDoorToSettings: () => {}, })); document.queryCommandSupported = () => true; From 477e8f23473827434c5c5df7d7ba4bc9f6d42b3b Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Wed, 4 Sep 2019 13:58:17 +0200 Subject: [PATCH 26/35] Clean up git merge conflict artifact --- rfcs/text/0004_application_service_mounting.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/rfcs/text/0004_application_service_mounting.md b/rfcs/text/0004_application_service_mounting.md index b7c6f8a1ac655..f6d06129dd4c2 100644 --- a/rfcs/text/0004_application_service_mounting.md +++ b/rfcs/text/0004_application_service_mounting.md @@ -266,15 +266,9 @@ export class MyPlugin { setup({ application }) { application.register({ id: 'my-app', -<<<<<<< HEAD - async mount(context, targetDomElem) { - const { renderApp } = await import('./application'); - return renderApp(context, targetDomElement); -======= async mount(context, params) { - const { renderApp } = await import('./applcation'); + const { renderApp } = await import('./application'); return renderApp(context, params); ->>>>>>> 4f09de749afb2a6fd56e51bfa83db5549a55c675 } }); } From 60f23cbd05ba74d9d0f97f55e5d89b033376e395 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Wed, 4 Sep 2019 15:51:04 +0200 Subject: [PATCH 27/35] Use updated NP interfaces --- .../console/np_ready/public/legacy.ts | 27 +++++++------------ .../console/np_ready/public/plugin.ts | 16 ++++++----- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/src/legacy/core_plugins/console/np_ready/public/legacy.ts b/src/legacy/core_plugins/console/np_ready/public/legacy.ts index 5535bc3c4b9ff..27260c7631d31 100644 --- a/src/legacy/core_plugins/console/np_ready/public/legacy.ts +++ b/src/legacy/core_plugins/console/np_ready/public/legacy.ts @@ -34,18 +34,7 @@ import 'ui/capabilities/route_setup'; /* eslint-enable @kbn/eslint/no-restricted-paths */ import template from '../../public/quarantined/index.html'; -import { CoreSetup } from '../../../../../core/public'; - -interface SetupRegisterAppArgs { - id: string; - mount: (ctx: any, opts: { element: HTMLDivElement }) => Promise; -} - -export interface XCoreSetup extends CoreSetup { - application: { - register(args: SetupRegisterAppArgs): void; - }; -} +import { App } from '../../../../../core/public'; export interface XPluginSet { __LEGACY: { @@ -73,18 +62,20 @@ uiRoutes.when('/dev_tools/console', { throw new Error(message); } - const xNpSetupCore: XCoreSetup = { + const mockedSetupCore = { ...npSetup.core, application: { - register(args: SetupRegisterAppArgs): void { - args.mount({}, { element: targetElement }).catch(err => { - npSetup.core.fatalErrors.add(err); - }); + registerApp(app: App): void { + try { + app.mount(targetElement); + } catch (e) { + npSetup.core.fatalErrors.add(e); + } }, }, }; - pluginInstance.setup(xNpSetupCore, { + pluginInstance.setup(mockedSetupCore, { ...npSetup.plugins, __LEGACY: { I18nContext, diff --git a/src/legacy/core_plugins/console/np_ready/public/plugin.ts b/src/legacy/core_plugins/console/np_ready/public/plugin.ts index 0028a78be0296..85228a08fc118 100644 --- a/src/legacy/core_plugins/console/np_ready/public/plugin.ts +++ b/src/legacy/core_plugins/console/np_ready/public/plugin.ts @@ -19,24 +19,28 @@ import { render, unmountComponentAtNode } from 'react-dom'; -import { PluginInitializerContext, Plugin, CoreStart } from '../../../../../core/public'; -import { XCoreSetup, XPluginSet } from './legacy'; +import { PluginInitializerContext, Plugin, CoreStart, CoreSetup } from '../../../../../core/public'; +import { XPluginSet } from './legacy'; import { boot } from './application'; export class ConsoleUIPlugin implements Plugin { // @ts-ignore constructor(private readonly ctx: PluginInitializerContext) {} - async setup({ application }: XCoreSetup, pluginSet: XPluginSet) { + async setup({ application }: CoreSetup, pluginSet: XPluginSet) { const { __LEGACY: { docLinkVersion, I18nContext, ResizeChecker }, } = pluginSet; - application.register({ + application.registerApp({ id: 'console', - async mount(ctx, { element }) { + order: 1, + title: 'Console', + mount(element) { render(boot({ docLinkVersion, I18nContext, ResizeChecker }), element); - return () => unmountComponentAtNode(element); + return () => { + unmountComponentAtNode(element); + }; }, }); } From 322569fdd098e83af084ec8c0902993084d07dd5 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Wed, 4 Sep 2019 19:03:39 +0200 Subject: [PATCH 28/35] More typings fixed after updating local project dependencies --- src/legacy/core_plugins/console/np_ready/public/legacy.ts | 7 +++++-- src/legacy/core_plugins/console/np_ready/public/plugin.ts | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/legacy/core_plugins/console/np_ready/public/legacy.ts b/src/legacy/core_plugins/console/np_ready/public/legacy.ts index 27260c7631d31..7b8d27510d385 100644 --- a/src/legacy/core_plugins/console/np_ready/public/legacy.ts +++ b/src/legacy/core_plugins/console/np_ready/public/legacy.ts @@ -48,6 +48,8 @@ import { plugin } from '.'; const pluginInstance = plugin({} as any); +const anyObject = {} as any; + uiRoutes.when('/dev_tools/console', { requireUICapability: 'dev_tools.show', controller: function RootController($scope) { @@ -65,13 +67,14 @@ uiRoutes.when('/dev_tools/console', { const mockedSetupCore = { ...npSetup.core, application: { - registerApp(app: App): void { + register(app: App): void { try { - app.mount(targetElement); + app.mount(anyObject, { element: targetElement, appBasePath: '' }); } catch (e) { npSetup.core.fatalErrors.add(e); } }, + registerMountContext() {}, }, }; diff --git a/src/legacy/core_plugins/console/np_ready/public/plugin.ts b/src/legacy/core_plugins/console/np_ready/public/plugin.ts index 85228a08fc118..f24224ff97b3a 100644 --- a/src/legacy/core_plugins/console/np_ready/public/plugin.ts +++ b/src/legacy/core_plugins/console/np_ready/public/plugin.ts @@ -32,11 +32,11 @@ export class ConsoleUIPlugin implements Plugin { __LEGACY: { docLinkVersion, I18nContext, ResizeChecker }, } = pluginSet; - application.registerApp({ + application.register({ id: 'console', order: 1, title: 'Console', - mount(element) { + mount(ctx, { element }) { render(boot({ docLinkVersion, I18nContext, ResizeChecker }), element); return () => { unmountComponentAtNode(element); From 384f4de627fdc852fda298294871f8a455f40ddc Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 5 Sep 2019 12:12:57 +0200 Subject: [PATCH 29/35] Removing some dependencies on KUI and font awesome from legacy editor --- .../containers/panel_container.tsx | 10 +-- .../editor/legacy/console_editor/editor.tsx | 3 +- .../console_history/console_history.tsx | 72 +++++++++++-------- .../legacy/use_ui_ace_keyboard_mode.tsx | 8 +-- .../quarantined/src/directives/_history.scss | 11 --- 5 files changed, 54 insertions(+), 50 deletions(-) diff --git a/src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/containers/panel_container.tsx b/src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/containers/panel_container.tsx index 594c10bf5b353..045a5ca6f280f 100644 --- a/src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/containers/panel_container.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/containers/panel_container.tsx @@ -57,13 +57,13 @@ export function PanelsContainer({ children, onPanelWidthChange }: Props) { return acc.concat([ { - eve.preventDefault(); + onMouseDown={event => { + event.preventDefault(); setState({ ...state, currentPanel: idx, isDragging: true, - currentResizerPos: eve.clientX, + currentResizerPos: event.clientX, }); }} />, @@ -78,9 +78,9 @@ export function PanelsContainer({ children, onPanelWidthChange }: Props) {
    { + onMouseMove={event => { if (state.isDragging) { - const { clientX: x } = eve; + const { clientX: x } = event; const { current: registry } = registryRef; const [left, right] = registry.getResizerNeighbours(state.currentPanel); const delta = x - state.currentResizerPos; diff --git a/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/editor.tsx b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/editor.tsx index 588991c931077..e2d928fe63443 100644 --- a/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/editor.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/editor.tsx @@ -23,6 +23,7 @@ import { i18n } from '@kbn/i18n'; import $ from 'jquery'; +import { EuiIcon } from '@elastic/eui'; import { useAppContext } from '../../../../context'; import { useUIAceKeyboardMode } from '../use_ui_ace_keyboard_mode'; import { ConsoleMenu } from '../../../../components'; @@ -106,7 +107,7 @@ function Editor({ onEditorReady, docLinkVersion, sendCurrentRequest = () => {} } data-test-subj="send-request-button" className="conApp__editorActionButton conApp__editorActionButton--success" > - +
    -

    - {i18n.translate('console.historyPage.pageTitle', { defaultMessage: 'History' })} -

    + +

    {i18n.translate('console.historyPage.pageTitle', { defaultMessage: 'History' })}

    +
    +
      {reqDescription} - + ); @@ -175,31 +185,37 @@ export function ConsoleHistory({ close, reqs }: Props) {
    -
    - + -
    - - - -
    -
    + + + + + + + close()}> + {i18n.translate('console.historyPage.closehistoryButtonLabel', { + defaultMessage: 'Close', + })} + + + + + restore()}> + {i18n.translate('console.historyPage.applyHistoryButtonLabel', { + defaultMessage: 'Apply', + })} + + + + +
    diff --git a/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx index 7fe5820d94f97..4f47a1581973f 100644 --- a/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx @@ -18,7 +18,7 @@ */ import React, { useEffect, useRef } from 'react'; import { render, unmountComponentAtNode } from 'react-dom'; -import { keyCodes } from '@elastic/eui'; +import { keyCodes, EuiText } from '@elastic/eui'; const Overlay = ({ onMount, @@ -38,10 +38,8 @@ const Overlay = ({ tabIndex={0} role="application" > -

    Press Enter to start editing.

    -

    - When you’re done, press Escape to stop editing. -

    + Press Enter to start editing. + When you’re done, press Escape to stop editing.
    ); diff --git a/src/legacy/core_plugins/console/public/quarantined/src/directives/_history.scss b/src/legacy/core_plugins/console/public/quarantined/src/directives/_history.scss index 9104176bd384e..efd72245b3c48 100644 --- a/src/legacy/core_plugins/console/public/quarantined/src/directives/_history.scss +++ b/src/legacy/core_plugins/console/public/quarantined/src/directives/_history.scss @@ -13,17 +13,6 @@ } } - -.conHistory__footer { - display: flex; - justify-content: space-between; - padding-top: $euiSize; -} - -.conHistory__footerButtonsRight { - text-align: right; -} - .conHistory__body__spacer { flex: 0 0 1%; } From 683a04e1c5ee209e8e735efc6e682728da1d1a1f Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 5 Sep 2019 12:32:37 +0200 Subject: [PATCH 30/35] Fix clear history not re-rendering Refactor prop name to be more descriptive --- .../console_history/console_history.tsx | 26 ++++++++++--------- .../application/containers/main/main.tsx | 19 ++++++++++++-- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_history/console_history.tsx b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_history/console_history.tsx index 46980f202ae64..b23ec67422c98 100644 --- a/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_history/console_history.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_history/console_history.tsx @@ -37,14 +37,16 @@ import { HistoryViewer } from './history_viewer'; interface Props { close: () => void; - reqs: any[]; + clearHistory: () => void; + restoreFromHistory: (req: any) => void; + requests: any[]; } const CHILD_ELEMENT_PREFIX = 'historyReq'; -export function ConsoleHistory({ close, reqs }: Props) { +export function ConsoleHistory({ close, requests, clearHistory, restoreFromHistory }: Props) { const { - services: { history, settings }, + services: { settings }, ResizeChecker, } = useAppContext(); @@ -82,24 +84,24 @@ export function ConsoleHistory({ close, reqs }: Props) { const initialize = () => { const nextSelectedIndex = 0; (describeReq as any).cache = new WeakMap(); - setViewingReq(reqs[nextSelectedIndex]); - selectedReq.current = reqs[nextSelectedIndex]; + setViewingReq(requests[nextSelectedIndex]); + selectedReq.current = requests[nextSelectedIndex]; setSelectedIndex(nextSelectedIndex); scrollIntoView(nextSelectedIndex); }; const clear = () => { - history.clearHistory(); + clearHistory(); initialize(); }; const restore = (req: any = selectedReq.current) => { - history.restoreFromHistory(req); + restoreFromHistory(req); }; useEffect(() => { initialize(); - }, [reqs]); + }, [requests]); /* eslint-disable */ return ( @@ -128,10 +130,10 @@ export function ConsoleHistory({ close, reqs }: Props) { ++currentIdx; } - const nextSelectedIndex = Math.min(Math.max(0, currentIdx), reqs.length - 1); + const nextSelectedIndex = Math.min(Math.max(0, currentIdx), requests.length - 1); - setViewingReq(reqs[nextSelectedIndex]); - selectedReq.current = reqs[nextSelectedIndex]; + setViewingReq(requests[nextSelectedIndex]); + selectedReq.current = requests[nextSelectedIndex]; setSelectedIndex(nextSelectedIndex); scrollIntoView(nextSelectedIndex); }} @@ -143,7 +145,7 @@ export function ConsoleHistory({ close, reqs }: Props) { defaultMessage: 'History of sent requests', })} > - {reqs.map((req, idx) => { + {requests.map((req, idx) => { const reqDescription = describeReq(req); const isSelected = viewingReq === req; return ( diff --git a/src/legacy/core_plugins/console/np_ready/public/application/containers/main/main.tsx b/src/legacy/core_plugins/console/np_ready/public/application/containers/main/main.tsx index 83dbc290a87ef..ae2009c1cebb3 100644 --- a/src/legacy/core_plugins/console/np_ready/public/application/containers/main/main.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/application/containers/main/main.tsx @@ -61,7 +61,6 @@ export function Main() { ResizeChecker, } = useAppContext(); - const [pastRequests, setPastRequests] = useState(() => history.getHistory()); const [editorReady, setEditorReady] = useState(false); const [inputEditor, setInputEditor] = useState(null); const [outputEditor, setOutputEditor] = useState(null); @@ -99,6 +98,8 @@ export function Main() { [] ); + const [pastRequests, setPastRequests] = useState(() => history.getHistory()); + const sendCurrentRequest = useCallback(() => { inputEditor.focus(); inputEditor.sendCurrentRequestToES(() => { @@ -106,9 +107,23 @@ export function Main() { }, outputEditor); }, [inputEditor, outputEditor]); + const clearHistory = useCallback(() => { + history.clearHistory(); + setPastRequests(history.getHistory()); + }, []); + + const restoreFromHistory = useCallback((req: any) => { + history.restoreFromHistory(req); + }, []); + const renderConsoleHistory = () => { return editorReady ? ( - setShowHistory(false)} /> + setShowHistory(false)} + /> ) : null; }; From e143c645c15b93109bd1cd4b01f00017ea9b73a5 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 5 Sep 2019 16:05:44 +0200 Subject: [PATCH 31/35] Simplify split_panel and add tests --- .../__snapshots__/split_panel.test.tsx.snap | 93 +++++++++++++++++++ .../split_panel/components/resizer.tsx | 2 +- .../containers/panel_container.tsx | 50 ++++------ .../split_panel/split_panel.test.tsx | 86 +++++++++++++++++ 4 files changed, 199 insertions(+), 32 deletions(-) create mode 100644 src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/__snapshots__/split_panel.test.tsx.snap create mode 100644 src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/split_panel.test.tsx diff --git a/src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/__snapshots__/split_panel.test.tsx.snap b/src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/__snapshots__/split_panel.test.tsx.snap new file mode 100644 index 0000000000000..0a40e3e84211d --- /dev/null +++ b/src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/__snapshots__/split_panel.test.tsx.snap @@ -0,0 +1,93 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Split panel should render correctly 1`] = ` + + +
    + +
    +

    + A +

    +
    +
    + +
    + ︙ +
    +
    + +
    +

    + B +

    +
    +
    +
    +
    +
    +`; diff --git a/src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/components/resizer.tsx b/src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/components/resizer.tsx index 605f90a7fc606..9d7738ac6a5a9 100644 --- a/src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/components/resizer.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/components/resizer.tsx @@ -30,7 +30,7 @@ export interface Props { */ export function Resizer(props: Props) { return ( -
    +
    ); diff --git a/src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/containers/panel_container.tsx b/src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/containers/panel_container.tsx index 045a5ca6f280f..fef65a954bd60 100644 --- a/src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/containers/panel_container.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/containers/panel_container.tsx @@ -29,18 +29,16 @@ export interface Props { } interface State { - currentPanel: number; isDragging: boolean; currentResizerPos: number; } -const initialState = { currentPanel: -1, isDragging: false, currentResizerPos: -1 }; +const initialState: State = { isDragging: false, currentResizerPos: -1 }; const pxToPercent = (proportion: number, whole: number) => (proportion / whole) * 100; -// TODO: Write tests for this export function PanelsContainer({ children, onPanelWidthChange }: Props) { - const [firstChild, ...rest] = Children.toArray(children); + const [firstChild, secondChild] = Children.toArray(children); const registryRef = useRef(new PanelRegistry()); const containerRef = useRef(null); @@ -50,28 +48,21 @@ export function PanelsContainer({ children, onPanelWidthChange }: Props) { return containerRef.current!.getBoundingClientRect().width; }; - const childrenWithResizer = rest.reduce( - (acc: ReactNode[], child, idx) => { - // The target idx is offset by one, we want to target the panel to the left of the resizer - // for resizing. - return acc.concat([ - { - event.preventDefault(); - setState({ - ...state, - currentPanel: idx, - isDragging: true, - currentResizerPos: event.clientX, - }); - }} - />, - child, - ]); - }, - [firstChild] - ); + const childrenWithResizer = [ + firstChild, + { + event.preventDefault(); + setState({ + ...state, + isDragging: true, + currentResizerPos: event.clientX, + }); + }} + />, + secondChild, + ]; return ( @@ -82,19 +73,16 @@ export function PanelsContainer({ children, onPanelWidthChange }: Props) { if (state.isDragging) { const { clientX: x } = event; const { current: registry } = registryRef; - const [left, right] = registry.getResizerNeighbours(state.currentPanel); + const [left, right] = registry.getPanels(); const delta = x - state.currentResizerPos; const containerWidth = getContainerWidth(); const leftPercent = pxToPercent(left.getWidth() + delta, containerWidth); const rightPercent = pxToPercent(right.getWidth() - delta, containerWidth); - left.setWidth(leftPercent); right.setWidth(rightPercent); if (onPanelWidthChange) { - onPanelWidthChange( - registry.getPanels().map(panel => pxToPercent(panel.getWidth(), containerWidth)) - ); + onPanelWidthChange([leftPercent, rightPercent]); } setState({ ...state, currentResizerPos: x }); diff --git a/src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/split_panel.test.tsx b/src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/split_panel.test.tsx new file mode 100644 index 0000000000000..e60912a29355b --- /dev/null +++ b/src/legacy/core_plugins/console/np_ready/public/application/components/split_panel/split_panel.test.tsx @@ -0,0 +1,86 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React from 'react'; +import { mount } from 'enzyme'; +import toJson from 'enzyme-to-json'; +import { spy } from 'sinon'; + +import { PanelsContainer, Panel } from '.'; + +const testComponentA =

    A

    ; +const testComponentB =

    B

    ; + +describe('Split panel', () => { + it('should render correctly', () => { + const panelContainer = mount( + + {testComponentA} + {testComponentB} + + ); + expect(toJson(panelContainer)).toMatchSnapshot(); + }); + + it('should calculate sizes correctly on mouse drags', () => { + // Since this test is not running in the browser we can't expect all of the + // APIs for sizing to be available. The below is a very hacky way of setting + // the DOMElement width so that we have a lightweight test for width calculation + // logic. + const div = mount(
    ); + const proto = (div + .find('div') + .first() + .getDOMNode() as any).__proto__; + const originalGetBoundingClientRect = proto.getBoundingClientRect; + + proto.getBoundingClientRect = spy(() => { + return { + width: 1000, + }; + }); + + try { + // Everything here runs sync. + let widthsCache: number[] = []; + const onWidthChange = (widths: number[]) => { + widthsCache = widths; + }; + + const panelContainer = mount( + + {testComponentA} + {testComponentB} + + ); + + const resizer = panelContainer.find(`[data-test-subj~="splitPanelResizer"]`).first(); + + resizer.simulate('mousedown', { clientX: 0 }); + resizer.simulate('mousemove', { clientX: 250 }); + resizer.simulate('mouseup'); + + panelContainer.update(); + + expect(widthsCache).toEqual([125, 75]); + } finally { + proto.getBoundingClientRect = originalGetBoundingClientRect; + } + }); +}); From e0fcb2935bd582a490a02d1708702044db5a7d75 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Tue, 10 Sep 2019 13:23:58 +0200 Subject: [PATCH 32/35] Fix accessibility tabbing behaviour for ace editor --- .../editor/legacy/use_ui_ace_keyboard_mode.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx index 4f47a1581973f..efbed8cca19d1 100644 --- a/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx @@ -31,13 +31,7 @@ const Overlay = ({ // in this case // // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -
    +
    Press Enter to start editing. When you’re done, press Escape to stop editing.
    @@ -87,10 +81,17 @@ export function useUIAceKeyboardMode(aceTextAreaElement: HTMLTextAreaElement | n useEffect(() => { if (aceTextAreaElement) { const container = document.createElement('div'); + container.className = 'kbnUiAceKeyboardHint'; + container.setAttribute('role', 'application'); + container.tabIndex = 0; + container.addEventListener('focus', () => { + enableOverlay(); + }); aceTextAreaElement.parentElement!.insertBefore(container, aceTextAreaElement); mountNode.current = container; textArea.current = aceTextAreaElement; + textArea.current.setAttribute('tabindex', '-1'); // This listener fires on capture phase so that we get a look at the world before ace changes it. document.addEventListener('keydown', documentKeyDownListener, { capture: true }); From 0939758a265c1b178bf8655c48808f8cb92bb0c4 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Tue, 10 Sep 2019 16:27:56 +0200 Subject: [PATCH 33/35] Refactor ConsoleEditor into two separate components Remove unused changeCursor code Remove unused textArea ref Use default lodash debounce (remove unnecessary arg) --- .../application/containers/editor/index.ts | 2 +- .../legacy/console_editor/console_editor.tsx | 33 ------------------- .../editor/legacy/console_editor/editor.tsx | 10 ++---- ...{readonly_editor.tsx => editor_output.tsx} | 14 ++++---- .../editor/legacy/console_editor/index.ts | 3 +- .../containers/editor/legacy/index.ts | 2 +- .../legacy/use_ui_ace_keyboard_mode.tsx | 12 +++---- .../application/containers/main/main.tsx | 20 ++++------- 8 files changed, 24 insertions(+), 72 deletions(-) delete mode 100644 src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/console_editor.tsx rename src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/{readonly_editor.tsx => editor_output.tsx} (81%) diff --git a/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/index.ts b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/index.ts index 46cf31d6892dd..346b748e1be91 100644 --- a/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/index.ts +++ b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/index.ts @@ -17,4 +17,4 @@ * under the License. */ -export { ConsoleEditor, ConsoleHistory, autoIndent, getDocumentation } from './legacy'; +export { Editor, EditorOutput, ConsoleHistory, autoIndent, getDocumentation } from './legacy'; diff --git a/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/console_editor.tsx b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/console_editor.tsx deleted file mode 100644 index f6b7eb1a780ab..0000000000000 --- a/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/console_editor.tsx +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import React from 'react'; - -import { MemoReadOnlyEditor } from './readonly_editor'; -import { MemoEditor, EditorProps } from './editor'; - -export type ConsoleEditorProps = { readOnly?: boolean } & EditorProps; - -export function ConsoleEditor(props: ConsoleEditorProps) { - const { readOnly, ...editorProps } = props; - if (props.readOnly) { - return ; - } - return ; -} diff --git a/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/editor.tsx b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/editor.tsx index e2d928fe63443..0ce3d44caccd9 100644 --- a/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/editor.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/editor.tsx @@ -47,7 +47,7 @@ const abs: CSSProperties = { right: '0', }; -function Editor({ onEditorReady, docLinkVersion, sendCurrentRequest = () => {} }: EditorProps) { +function Component({ onEditorReady, docLinkVersion, sendCurrentRequest = () => {} }: EditorProps) { const { services: { history, settings }, } = useAppContext(); @@ -75,12 +75,6 @@ function Editor({ onEditorReady, docLinkVersion, sendCurrentRequest = () => {} } onEditorReady({ editor: editorInstanceRef.current, element: editorRef.current! }); } - const session = editorInstanceRef.current.getSession(); - session.getSelection().on('changeCursor', () => { - // Fire and forget - getDocumentation(editorInstanceRef.current!, docLinkVersion); - }); - setTextArea(editorRef.current!.querySelector('textarea')); }, []); @@ -133,4 +127,4 @@ function Editor({ onEditorReady, docLinkVersion, sendCurrentRequest = () => {} } ); } -export const MemoEditor = React.memo(Editor); +export const Editor = React.memo(Component); diff --git a/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/readonly_editor.tsx b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/editor_output.tsx similarity index 81% rename from src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/readonly_editor.tsx rename to src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/editor_output.tsx index 4c833261ff734..94e9162d46b03 100644 --- a/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/readonly_editor.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/editor_output.tsx @@ -19,15 +19,15 @@ import React, { useEffect, useRef } from 'react'; import $ from 'jquery'; -import { EditorProps } from './editor'; - // @ts-ignore import { initializeOutput } from '../../../../../../../public/quarantined/src/output'; import { useAppContext } from '../../../../context'; -export type ReadOnlyEditorProps = Pick; +export interface EditorOutputProps { + onReady?: (ref: any) => void; +} -function ReadOnlyEditor({ onEditorReady }: ReadOnlyEditorProps) { +function Component({ onReady }: EditorOutputProps) { const editorRef = useRef(null); const { services: { settings }, @@ -36,8 +36,8 @@ function ReadOnlyEditor({ onEditorReady }: ReadOnlyEditorProps) { useEffect(() => { const editor$ = $(editorRef.current!); const outputEditor = initializeOutput(editor$, settings); - if (onEditorReady) { - onEditorReady({ editor: outputEditor, element: editorRef.current! }); + if (onReady) { + onReady({ editor: outputEditor, element: editorRef.current! }); } }); @@ -48,4 +48,4 @@ function ReadOnlyEditor({ onEditorReady }: ReadOnlyEditorProps) { ); } -export const MemoReadOnlyEditor = React.memo(ReadOnlyEditor); +export const EditorOutput = React.memo(Component); diff --git a/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/index.ts b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/index.ts index f7152d818f096..a8c603e87e7cc 100644 --- a/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/index.ts +++ b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/console_editor/index.ts @@ -17,4 +17,5 @@ * under the License. */ -export { ConsoleEditor } from './console_editor'; +export { Editor } from './editor'; +export { EditorOutput } from './editor_output'; diff --git a/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/index.ts b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/index.ts index e2a495642a1b7..134f3de42833b 100644 --- a/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/index.ts +++ b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/index.ts @@ -17,6 +17,6 @@ * under the License. */ -export { ConsoleEditor } from './console_editor'; +export { EditorOutput, Editor } from './console_editor'; export { ConsoleHistory } from './console_history'; export { getDocumentation, autoIndent } from './console_menu_actions'; diff --git a/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx index efbed8cca19d1..c2f52e7f11951 100644 --- a/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx @@ -38,7 +38,6 @@ const Overlay = ({ ); export function useUIAceKeyboardMode(aceTextAreaElement: HTMLTextAreaElement | null) { - const textArea = useRef(null); const mountNode = useRef(null); const autoCompleteVisibleRef = useRef(false); @@ -46,7 +45,7 @@ export function useUIAceKeyboardMode(aceTextAreaElement: HTMLTextAreaElement | n if (ev.keyCode === keyCodes.ENTER) { ev.preventDefault(); unmountComponentAtNode(mountNode.current!); - textArea.current!.focus(); + aceTextAreaElement!.focus(); } } @@ -90,17 +89,16 @@ export function useUIAceKeyboardMode(aceTextAreaElement: HTMLTextAreaElement | n aceTextAreaElement.parentElement!.insertBefore(container, aceTextAreaElement); mountNode.current = container; - textArea.current = aceTextAreaElement; - textArea.current.setAttribute('tabindex', '-1'); + aceTextAreaElement.setAttribute('tabindex', '-1'); // This listener fires on capture phase so that we get a look at the world before ace changes it. document.addEventListener('keydown', documentKeyDownListener, { capture: true }); - textArea.current.addEventListener('keydown', aceKeydownListener); + aceTextAreaElement.addEventListener('keydown', aceKeydownListener); } return () => { - if (textArea.current) { + if (aceTextAreaElement) { document.removeEventListener('keydown', documentKeyDownListener); - textArea.current.removeEventListener('keydown', aceKeydownListener); + aceTextAreaElement.removeEventListener('keydown', aceKeydownListener); document.removeChild(mountNode.current!); } }; diff --git a/src/legacy/core_plugins/console/np_ready/public/application/containers/main/main.tsx b/src/legacy/core_plugins/console/np_ready/public/application/containers/main/main.tsx index ae2009c1cebb3..8386eaf46e445 100644 --- a/src/legacy/core_plugins/console/np_ready/public/application/containers/main/main.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/application/containers/main/main.tsx @@ -27,7 +27,7 @@ import mappings from '../../../../../public/quarantined/src/mappings'; // @ts-ignore import init from '../../../../../public/quarantined/src/app'; -import { ConsoleEditor, ConsoleHistory } from '../editor'; +import { EditorOutput, Editor, ConsoleHistory } from '../editor'; import { subscribeResizeChecker } from '../editor/legacy/subscribe_console_resize_checker'; import { @@ -88,13 +88,9 @@ export function Main() { ]); const onPanelWidthChange = useCallback( - debounce( - (widths: number[]) => { - storage.set(StorageKeys.WIDTH, widths); - }, - 300, - { trailing: true } - ), + debounce((widths: number[]) => { + storage.set(StorageKeys.WIDTH, widths); + }, 300), [] ); @@ -228,7 +224,7 @@ export function Main() { style={{ height: '100%', position: 'relative', minWidth: PANEL_MIN_WIDTH }} initialWidth={firstPanelWidth + '%'} > - - + From e351ba2ddec23746ad5c75f08c58570a309ca5d9 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Wed, 11 Sep 2019 13:50:36 +0200 Subject: [PATCH 34/35] Major a11y fix when tabbing Major fix for ace in IE11 and Edge browsers --- .../legacy/use_ui_ace_keyboard_mode.tsx | 68 +++++++++---------- .../console/public/quarantined/_app.scss | 5 +- 2 files changed, 38 insertions(+), 35 deletions(-) diff --git a/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx index c2f52e7f11951..2b2387e04622c 100644 --- a/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx +++ b/src/legacy/core_plugins/console/np_ready/public/application/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx @@ -17,43 +17,35 @@ * under the License. */ import React, { useEffect, useRef } from 'react'; -import { render, unmountComponentAtNode } from 'react-dom'; +import * as ReactDOM from 'react-dom'; import { keyCodes, EuiText } from '@elastic/eui'; -const Overlay = ({ - onMount, - onKeyDown, -}: { - onMount: (ref: HTMLDivElement) => void; - onKeyDown: (ev: React.KeyboardEvent) => void; -}) => ( +const OverlayText = () => ( // The point of this element is for accessibility purposes, so ignore eslint error // in this case // // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -
    + <> Press Enter to start editing. When you’re done, press Escape to stop editing. -
    + ); export function useUIAceKeyboardMode(aceTextAreaElement: HTMLTextAreaElement | null) { - const mountNode = useRef(null); + const overlayMountNode = useRef(null); const autoCompleteVisibleRef = useRef(false); - function onDismissOverlay(ev: React.KeyboardEvent) { - if (ev.keyCode === keyCodes.ENTER) { - ev.preventDefault(); - unmountComponentAtNode(mountNode.current!); + function onDismissOverlay(event: KeyboardEvent) { + if (event.keyCode === keyCodes.ENTER) { + event.preventDefault(); aceTextAreaElement!.focus(); } } function enableOverlay() { - render( - ref && ref.focus()} />, - mountNode.current! - ); + if (overlayMountNode.current) { + overlayMountNode.current.focus(); + } } const isAutoCompleteVisible = () => { @@ -69,29 +61,37 @@ export function useUIAceKeyboardMode(aceTextAreaElement: HTMLTextAreaElement | n autoCompleteVisibleRef.current = isAutoCompleteVisible(); }; - const aceKeydownListener = (ev: KeyboardEvent) => { - if (ev.keyCode === keyCodes.ESCAPE && !autoCompleteVisibleRef.current) { - ev.preventDefault(); - ev.stopPropagation(); + const aceKeydownListener = (event: KeyboardEvent) => { + if (event.keyCode === keyCodes.ESCAPE && !autoCompleteVisibleRef.current) { + event.preventDefault(); + event.stopPropagation(); enableOverlay(); } }; useEffect(() => { if (aceTextAreaElement) { - const container = document.createElement('div'); - container.className = 'kbnUiAceKeyboardHint'; - container.setAttribute('role', 'application'); - container.tabIndex = 0; - container.addEventListener('focus', () => { - enableOverlay(); - }); - aceTextAreaElement.parentElement!.insertBefore(container, aceTextAreaElement); + // We don't control HTML elements inside of ace so we imperatively create an element + // that acts as a container and insert it just before ace's textarea element + // so that the overlay lives at the correct spot in the DOM hierarchy. + overlayMountNode.current = document.createElement('div'); + overlayMountNode.current.className = 'kbnUiAceKeyboardHint'; + overlayMountNode.current.setAttribute('role', 'application'); + overlayMountNode.current.tabIndex = 0; + overlayMountNode.current.addEventListener('focus', enableOverlay); + overlayMountNode.current.addEventListener('keydown', onDismissOverlay); + + ReactDOM.render(, overlayMountNode.current); - mountNode.current = container; + aceTextAreaElement.parentElement!.insertBefore(overlayMountNode.current, aceTextAreaElement); aceTextAreaElement.setAttribute('tabindex', '-1'); - // This listener fires on capture phase so that we get a look at the world before ace changes it. + // Order of events: + // 1. Document capture event fires first and we check whether an autocomplete menu is open on keydown + // (not ideal because this is scoped to the entire document). + // 2. Ace changes it's state (like hiding or showing autocomplete menu) + // 3. We check what button was pressed and whether autocomplete was visible then determine + // whether it should act like a dismiss or if we should display an overlay. document.addEventListener('keydown', documentKeyDownListener, { capture: true }); aceTextAreaElement.addEventListener('keydown', aceKeydownListener); } @@ -99,7 +99,7 @@ export function useUIAceKeyboardMode(aceTextAreaElement: HTMLTextAreaElement | n if (aceTextAreaElement) { document.removeEventListener('keydown', documentKeyDownListener); aceTextAreaElement.removeEventListener('keydown', aceKeydownListener); - document.removeChild(mountNode.current!); + document.removeChild(overlayMountNode.current!); } }; }, [aceTextAreaElement]); diff --git a/src/legacy/core_plugins/console/public/quarantined/_app.scss b/src/legacy/core_plugins/console/public/quarantined/_app.scss index a142f3d8bc135..9fd746b19bfc5 100644 --- a/src/legacy/core_plugins/console/public/quarantined/_app.scss +++ b/src/legacy/core_plugins/console/public/quarantined/_app.scss @@ -19,7 +19,9 @@ width: 100%; display: flex; flex: 0 0 auto; - //position: relative; + + // NB: Required on IE11 to render ace editor correctly after first input. + position: relative; } .conApp__output { @@ -29,6 +31,7 @@ .conApp__editorContent, .conApp__outputContent { + height: 100%; flex: 1 1 1px; } From 08a9df071f55b9a4600b53174290c6469a5265b0 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 12 Sep 2019 11:10:51 +0200 Subject: [PATCH 35/35] Update comment --- src/legacy/core_plugins/console/public/quarantined/_app.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/legacy/core_plugins/console/public/quarantined/_app.scss b/src/legacy/core_plugins/console/public/quarantined/_app.scss index 9fd746b19bfc5..5fd2cd080d06d 100644 --- a/src/legacy/core_plugins/console/public/quarantined/_app.scss +++ b/src/legacy/core_plugins/console/public/quarantined/_app.scss @@ -20,7 +20,7 @@ display: flex; flex: 0 0 auto; - // NB: Required on IE11 to render ace editor correctly after first input. + // Required on IE11 to render ace editor correctly after first input. position: relative; }