From dddb82e4148bd4ae33c77f56e8ce981309e05a2b Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Tue, 14 Jan 2020 13:53:24 +0100 Subject: [PATCH 01/15] Moved out of legacy folder --- x-pack/legacy/plugins/watcher/index.js | 9 -- .../plugins/watcher/plugin_definition.ts | 32 ---- .../legacy/plugins/watcher/public/legacy.ts | 147 ------------------ .../public/manage_angular_lifecycle.ts | 28 ---- .../watcher/public/register_feature.ts | 21 --- x-pack/{legacy => }/plugins/watcher/README.md | 0 .../helpers/app_context.mock.tsx | 4 +- .../helpers/body_response.ts | 0 .../client_integration/helpers/constants.ts | 0 .../helpers/http_requests.ts | 0 .../client_integration/helpers/index.ts | 2 +- .../helpers/setup_environment.ts | 2 +- .../helpers/watch_create_json.helpers.ts | 6 +- .../helpers/watch_create_threshold.helpers.ts | 6 +- .../helpers/watch_edit.helpers.ts | 6 +- .../helpers/watch_list.helpers.ts | 4 +- .../helpers/watch_status.helpers.ts | 4 +- .../watch_create_json.test.ts | 2 +- .../watch_create_threshold.test.tsx | 0 .../client_integration/watch_edit.test.ts | 4 +- .../client_integration/watch_list.test.ts | 0 .../client_integration/watch_status.test.ts | 0 .../watcher/common/constants/action_modes.ts | 0 .../watcher/common/constants/action_states.ts | 0 .../watcher/common/constants/action_types.ts | 0 .../watcher/common/constants/agg_types.ts | 0 .../watcher/common/constants/comparators.ts | 0 .../watcher/common/constants/error_codes.ts | 0 .../common/constants/es_scroll_settings.ts | 0 .../plugins/watcher/common/constants/index.ts | 0 .../watcher/common/constants/index_names.ts | 0 .../plugins/watcher/common/constants/lists.ts | 0 .../watcher/common/constants/pagination.ts | 0 .../watcher/common/constants/plugin.ts | 2 +- .../common/constants/refresh_intervals.ts | 0 .../watcher/common/constants/routes.ts | 0 .../watcher/common/constants/sort_orders.ts | 0 .../watcher/common/constants/time_units.ts | 0 .../watcher/common/constants/watch_history.ts | 0 .../common/constants/watch_state_comments.ts | 0 .../watcher/common/constants/watch_states.ts | 0 .../watcher/common/constants/watch_types.ts | 0 .../__tests__/get_action_type.js | 2 +- .../lib/get_action_type/get_action_type.ts | 0 .../common/lib/get_action_type/index.ts | 0 .../lib/get_moment/__tests__/get_moment.js | 0 .../common/lib/get_moment/get_moment.js | 0 .../watcher/common/lib/get_moment/index.js | 0 .../common/lib/serialization/index.d.ts | 0 .../watcher/common/lib/serialization/index.js | 0 .../serialization_helpers/build_actions.js | 0 .../serialization_helpers/build_condition.js | 2 +- .../serialization_helpers/build_input.js | 0 .../serialization_helpers/build_metadata.js | 0 .../serialization_helpers/build_transform.js | 2 +- .../serialization_helpers/build_trigger.js | 0 .../serialization_helpers/index.js | 0 .../single_line_script.js | 0 .../lib/serialization/serialize_json_watch.js | 0 .../serialize_json_watch.test.js | 0 .../serialize_threshold_watch.js | 0 .../serialize_threshold_watch.test.js | 0 .../watcher/common/models/action/action.js | 4 +- .../common/models/action/action.test.js | 2 +- .../common/models/action/base_action.js | 0 .../common/models/action/email_action.js | 2 +- .../watcher/common/models/action/index.js | 0 .../common/models/action/index_action.js | 2 +- .../common/models/action/jira_action.js | 2 +- .../common/models/action/logging_action.js | 2 +- .../common/models/action/pagerduty_action.js | 2 +- .../common/models/action/slack_action.js | 2 +- .../common/models/action/unknown_action.js | 2 +- .../common/models/action/webhook_action.js | 2 +- .../watcher/common/types/action_types.ts | 0 .../watcher/common/types/watch_types.ts | 0 .../{legacy => }/plugins/watcher/kibana.json | 4 +- .../watcher/public}/application/app.tsx | 4 +- .../public}/application/app_context.tsx | 4 +- .../watcher/public}/application/boot.tsx | 2 +- .../components/confirm_watches_modal.tsx | 0 .../components/delete_watches_modal.tsx | 0 .../application/components/form_errors.tsx | 0 .../public}/application/components/index.ts | 0 .../components/page_error/index.ts | 0 .../components/page_error/page_error.tsx | 0 .../page_error/page_error_forbidden.tsx | 0 .../page_error/page_error_not_exist.tsx | 0 .../application/components/section_error.tsx | 0 .../components/section_loading.tsx | 0 .../application/components/watch_status.tsx | 2 +- .../application/constants/base_path.ts | 0 .../public}/application/constants/index.ts | 0 .../watcher/public}/application/index.scss | 0 .../watcher/public}/application/lib/api.ts | 6 +- .../public}/application/lib/breadcrumbs.ts | 0 .../public}/application/lib/format_date.ts | 0 .../application/lib/get_search_value.ts | 0 .../application/lib/get_time_unit_label.ts | 2 +- .../public}/application/lib/navigation.ts | 0 .../public}/application/lib/use_request.ts | 0 .../application/models/action/action.js | 2 +- .../application/models/action/base_action.js | 0 .../application/models/action/email_action.js | 0 .../application/models/action/index.js | 0 .../application/models/action/index_action.js | 0 .../application/models/action/jira_action.js | 0 .../models/action/logging_action.js | 0 .../models/action/pagerduty_action.js | 0 .../application/models/action/slack_action.js | 0 .../models/action/unknown_action.js | 0 .../models/action/webhook_action.js | 0 .../models/action_status/action_status.js | 2 +- .../application/models/action_status/index.js | 0 .../models/execute_details/execute_details.js | 0 .../models/execute_details/index.js | 0 .../public}/application/models/index.d.ts | 0 .../application/models/settings/index.js | 0 .../application/models/settings/settings.js | 0 .../models/visualize_options/index.js | 0 .../visualize_options/visualize_options.js | 0 .../application/models/watch/agg_types.ts | 2 +- .../application/models/watch/base_watch.js | 0 .../application/models/watch/comparators.ts | 2 +- .../models/watch/default_watch.json | 0 .../models/watch/group_by_types.ts | 0 .../public}/application/models/watch/index.js | 0 .../application/models/watch/json_watch.js | 2 +- .../check_action_id_collision.js | 0 .../lib/check_action_id_collision/index.js | 0 .../lib/create_action_id/create_action_id.js | 0 .../watch/lib/create_action_id/index.js | 0 .../models/watch/monitoring_watch.js | 2 +- .../models/watch/threshold_watch.js | 2 +- .../public}/application/models/watch/watch.js | 2 +- .../application/models/watch_errors/index.js | 0 .../models/watch_errors/watch_errors.js | 0 .../models/watch_history_item/index.js | 0 .../watch_history_item/watch_history_item.js | 2 +- .../application/models/watch_status/index.js | 0 .../models/watch_status/watch_status.js | 2 +- .../components/json_watch_edit/index.ts | 0 .../json_watch_edit/json_watch_edit.tsx | 6 +- .../json_watch_edit/json_watch_edit_form.tsx | 2 +- .../json_watch_edit_simulate.tsx | 4 +- .../json_watch_edit_simulate_results.tsx | 2 +- .../components/monitoring_watch_edit/index.ts | 0 .../monitoring_watch_edit.tsx | 0 .../watch_edit/components/request_flyout.tsx | 0 .../action_fields/email_action_fields.tsx | 2 +- .../action_fields/index.ts | 0 .../action_fields/index_action_fields.tsx | 2 +- .../action_fields/jira_action_fields.tsx | 2 +- .../action_fields/logging_action_fields.tsx | 2 +- .../action_fields/pagerduty_action_fields.tsx | 2 +- .../action_fields/slack_action_fields.tsx | 2 +- .../action_fields/webhook_action_fields.tsx | 2 +- .../components/threshold_watch_edit/index.ts | 0 .../threshold_watch_action_accordion.tsx | 4 +- .../threshold_watch_action_dropdown.tsx | 2 +- .../threshold_watch_action_panel.tsx | 0 .../threshold_watch_edit.tsx | 4 +- .../watch_visualization.tsx | 2 +- .../watch_edit/components/watch_edit.tsx | 4 +- .../sections/watch_edit/watch_context.ts | 0 .../sections/watch_edit/watch_edit_actions.ts | 6 +- .../watch_list/components/watch_list.tsx | 2 +- .../watch_status/components/watch_detail.tsx | 2 +- .../watch_status/components/watch_history.tsx | 2 +- .../watch_status/components/watch_status.tsx | 0 .../watch_status/watch_details_context.ts | 0 .../public}/application/shared_imports.ts | 2 +- .../watcher/public}/index.ts | 0 .../watcher/public}/plugin.ts | 2 +- .../watcher/public}/types.ts | 0 .../watcher/server}/index.ts | 2 +- .../server}/lib/call_with_request_factory.ts | 2 +- .../server}/lib/elasticsearch_js_plugin.ts | 0 .../__tests__/fetch_all_from_scroll.js | 0 .../fetch_all_from_scroll.ts | 2 +- .../lib/fetch_all_from_scroll/index.ts | 0 .../watcher/server}/lib/is_es_error/index.ts | 0 .../server}/lib/is_es_error/is_es_error.ts | 0 .../__tests__/license_pre_routing_factory.js | 4 +- .../lib/license_pre_routing_factory/index.ts | 0 .../license_pre_routing_factory.ts | 6 +- .../lib/normalized_field_types/index.ts | 0 .../normalized_field_types.ts | 0 .../action_status/__tests__/action_status.js | 2 +- .../models/action_status/action_status.js | 4 +- .../server}/models/action_status/index.js | 0 .../__tests__/execute_details.js | 0 .../models/execute_details/execute_details.js | 0 .../server}/models/execute_details/index.js | 0 .../server}/models/fields/__tests__/fields.js | 0 .../watcher/server}/models/fields/fields.js | 0 .../watcher/server}/models/fields/index.js | 0 .../models/settings/__tests__/settings.js | 0 .../watcher/server}/models/settings/index.js | 0 .../server}/models/settings/settings.js | 2 +- .../server}/models/visualize_options/index.js | 0 .../visualize_options/visualize_options.js | 0 .../server}/models/watch/base_watch.js | 2 +- .../server}/models/watch/base_watch.test.js | 0 .../watcher/server}/models/watch/index.js | 0 .../server}/models/watch/json_watch.js | 4 +- .../server}/models/watch/json_watch.test.js | 0 .../lib/get_watch_type/get_watch_type.js | 2 +- .../models/watch/lib/get_watch_type/index.js | 0 .../server}/models/watch/monitoring_watch.js | 2 +- .../models/watch/monitoring_watch.test.js | 0 .../__tests__/format_visualize_data.js | 2 +- .../threshold_watch/build_visualize_query.js | 4 +- .../threshold_watch/data_samples/count.json | 0 .../data_samples/count.query.date.json | 0 .../data_samples/count.query.json | 0 .../data_samples/count_terms.json | 0 .../data_samples/count_terms.query.date.json | 0 .../data_samples/count_terms.query.json | 0 .../data_samples/non_count.json | 0 .../data_samples/non_count.query.date.json | 0 .../data_samples/non_count.query.json | 0 .../data_samples/non_count_terms.json | 0 .../non_count_terms.query.date.json | 0 .../data_samples/non_count_terms.query.json | 0 .../threshold_watch/format_visualize_data.js | 2 +- .../models/watch/threshold_watch/index.js | 0 .../watch/threshold_watch/threshold_watch.js | 4 +- .../threshold_watch/threshold_watch.test.js | 2 +- .../watcher/server}/models/watch/watch.js | 2 +- .../server}/models/watch/watch.test.js | 2 +- .../server}/models/watch_errors/index.js | 0 .../models/watch_errors/watch_errors.js | 0 .../models/watch_errors/watch_errors.test.js | 0 .../__tests__/watch_history_item.js | 0 .../models/watch_history_item/index.js | 0 .../watch_history_item/watch_history_item.js | 2 +- .../watch_status/__tests__/watch_status.js | 2 +- .../server}/models/watch_status/index.js | 0 .../models/watch_status/watch_status.js | 4 +- .../watcher/server}/plugin.ts | 7 +- .../server}/routes/api/indices/index.ts | 0 .../routes/api/indices/register_get_route.ts | 2 +- .../api/indices/register_indices_routes.ts | 0 .../server}/routes/api/license/index.ts | 0 .../api/license/register_license_routes.ts | 0 .../api/license/register_refresh_route.ts | 2 +- .../routes/api/register_list_fields_route.ts | 4 +- .../routes/api/register_load_history_route.ts | 6 +- .../server}/routes/api/settings/index.ts | 0 .../api/settings/register_load_route.ts | 4 +- .../api/settings/register_settings_routes.ts | 0 .../server}/routes/api/watch/action/index.ts | 0 .../action/register_acknowledge_route.ts | 4 +- .../watch/action/register_action_routes.ts | 0 .../watcher/server}/routes/api/watch/index.ts | 0 .../api/watch/register_activate_route.ts | 4 +- .../api/watch/register_deactivate_route.ts | 4 +- .../routes/api/watch/register_delete_route.ts | 2 +- .../api/watch/register_execute_route.ts | 8 +- .../api/watch/register_history_route.ts | 6 +- .../routes/api/watch/register_load_route.ts | 4 +- .../routes/api/watch/register_save_route.ts | 6 +- .../api/watch/register_visualize_route.ts | 6 +- .../routes/api/watch/register_watch_routes.ts | 0 .../server}/routes/api/watches/index.ts | 0 .../api/watches/register_delete_route.ts | 2 +- .../routes/api/watches/register_list_route.ts | 6 +- .../api/watches/register_watches_routes.ts | 0 .../watcher/server}/types.ts | 4 +- .../watcher/test/fixtures/execute_details.ts | 0 .../plugins/watcher/test/fixtures/index.ts | 0 .../plugins/watcher/test/fixtures/watch.ts | 2 +- .../watcher/test/fixtures/watch_history.ts | 2 +- 274 files changed, 161 insertions(+), 395 deletions(-) delete mode 100644 x-pack/legacy/plugins/watcher/index.js delete mode 100644 x-pack/legacy/plugins/watcher/plugin_definition.ts delete mode 100644 x-pack/legacy/plugins/watcher/public/legacy.ts delete mode 100644 x-pack/legacy/plugins/watcher/public/manage_angular_lifecycle.ts delete mode 100644 x-pack/legacy/plugins/watcher/public/register_feature.ts rename x-pack/{legacy => }/plugins/watcher/README.md (100%) rename x-pack/{legacy => }/plugins/watcher/__jest__/client_integration/helpers/app_context.mock.tsx (90%) rename x-pack/{legacy => }/plugins/watcher/__jest__/client_integration/helpers/body_response.ts (100%) rename x-pack/{legacy => }/plugins/watcher/__jest__/client_integration/helpers/constants.ts (100%) rename x-pack/{legacy => }/plugins/watcher/__jest__/client_integration/helpers/http_requests.ts (100%) rename x-pack/{legacy => }/plugins/watcher/__jest__/client_integration/helpers/index.ts (96%) rename x-pack/{legacy => }/plugins/watcher/__jest__/client_integration/helpers/setup_environment.ts (96%) rename x-pack/{legacy => }/plugins/watcher/__jest__/client_integration/helpers/watch_create_json.helpers.ts (87%) rename x-pack/{legacy => }/plugins/watcher/__jest__/client_integration/helpers/watch_create_threshold.helpers.ts (91%) rename x-pack/{legacy => }/plugins/watcher/__jest__/client_integration/helpers/watch_edit.helpers.ts (82%) rename x-pack/{legacy => }/plugins/watcher/__jest__/client_integration/helpers/watch_list.helpers.ts (94%) rename x-pack/{legacy => }/plugins/watcher/__jest__/client_integration/helpers/watch_status.helpers.ts (96%) rename x-pack/{legacy => }/plugins/watcher/__jest__/client_integration/watch_create_json.test.ts (98%) rename x-pack/{legacy => }/plugins/watcher/__jest__/client_integration/watch_create_threshold.test.tsx (100%) rename x-pack/{legacy => }/plugins/watcher/__jest__/client_integration/watch_edit.test.ts (97%) rename x-pack/{legacy => }/plugins/watcher/__jest__/client_integration/watch_list.test.ts (100%) rename x-pack/{legacy => }/plugins/watcher/__jest__/client_integration/watch_status.test.ts (100%) rename x-pack/{legacy => }/plugins/watcher/common/constants/action_modes.ts (100%) rename x-pack/{legacy => }/plugins/watcher/common/constants/action_states.ts (100%) rename x-pack/{legacy => }/plugins/watcher/common/constants/action_types.ts (100%) rename x-pack/{legacy => }/plugins/watcher/common/constants/agg_types.ts (100%) rename x-pack/{legacy => }/plugins/watcher/common/constants/comparators.ts (100%) rename x-pack/{legacy => }/plugins/watcher/common/constants/error_codes.ts (100%) rename x-pack/{legacy => }/plugins/watcher/common/constants/es_scroll_settings.ts (100%) rename x-pack/{legacy => }/plugins/watcher/common/constants/index.ts (100%) rename x-pack/{legacy => }/plugins/watcher/common/constants/index_names.ts (100%) rename x-pack/{legacy => }/plugins/watcher/common/constants/lists.ts (100%) rename x-pack/{legacy => }/plugins/watcher/common/constants/pagination.ts (100%) rename x-pack/{legacy => }/plugins/watcher/common/constants/plugin.ts (85%) rename x-pack/{legacy => }/plugins/watcher/common/constants/refresh_intervals.ts (100%) rename x-pack/{legacy => }/plugins/watcher/common/constants/routes.ts (100%) rename x-pack/{legacy => }/plugins/watcher/common/constants/sort_orders.ts (100%) rename x-pack/{legacy => }/plugins/watcher/common/constants/time_units.ts (100%) rename x-pack/{legacy => }/plugins/watcher/common/constants/watch_history.ts (100%) rename x-pack/{legacy => }/plugins/watcher/common/constants/watch_state_comments.ts (100%) rename x-pack/{legacy => }/plugins/watcher/common/constants/watch_states.ts (100%) rename x-pack/{legacy => }/plugins/watcher/common/constants/watch_types.ts (100%) rename x-pack/{legacy => }/plugins/watcher/common/lib/get_action_type/__tests__/get_action_type.js (97%) rename x-pack/{legacy => }/plugins/watcher/common/lib/get_action_type/get_action_type.ts (100%) rename x-pack/{legacy => }/plugins/watcher/common/lib/get_action_type/index.ts (100%) rename x-pack/{legacy => }/plugins/watcher/common/lib/get_moment/__tests__/get_moment.js (100%) rename x-pack/{legacy => }/plugins/watcher/common/lib/get_moment/get_moment.js (100%) rename x-pack/{legacy => }/plugins/watcher/common/lib/get_moment/index.js (100%) rename x-pack/{legacy => }/plugins/watcher/common/lib/serialization/index.d.ts (100%) rename x-pack/{legacy => }/plugins/watcher/common/lib/serialization/index.js (100%) rename x-pack/{legacy => }/plugins/watcher/common/lib/serialization/serialization_helpers/build_actions.js (100%) rename x-pack/{legacy => }/plugins/watcher/common/lib/serialization/serialization_helpers/build_condition.js (98%) rename x-pack/{legacy => }/plugins/watcher/common/lib/serialization/serialization_helpers/build_input.js (100%) rename x-pack/{legacy => }/plugins/watcher/common/lib/serialization/serialization_helpers/build_metadata.js (100%) rename x-pack/{legacy => }/plugins/watcher/common/lib/serialization/serialization_helpers/build_transform.js (98%) rename x-pack/{legacy => }/plugins/watcher/common/lib/serialization/serialization_helpers/build_trigger.js (100%) rename x-pack/{legacy => }/plugins/watcher/common/lib/serialization/serialization_helpers/index.js (100%) rename x-pack/{legacy => }/plugins/watcher/common/lib/serialization/serialization_helpers/single_line_script.js (100%) rename x-pack/{legacy => }/plugins/watcher/common/lib/serialization/serialize_json_watch.js (100%) rename x-pack/{legacy => }/plugins/watcher/common/lib/serialization/serialize_json_watch.test.js (100%) rename x-pack/{legacy => }/plugins/watcher/common/lib/serialization/serialize_threshold_watch.js (100%) rename x-pack/{legacy => }/plugins/watcher/common/lib/serialization/serialize_threshold_watch.test.js (100%) rename x-pack/{legacy => }/plugins/watcher/common/models/action/action.js (92%) rename x-pack/{legacy => }/plugins/watcher/common/models/action/action.test.js (97%) rename x-pack/{legacy => }/plugins/watcher/common/models/action/base_action.js (100%) rename x-pack/{legacy => }/plugins/watcher/common/models/action/email_action.js (98%) rename x-pack/{legacy => }/plugins/watcher/common/models/action/index.js (100%) rename x-pack/{legacy => }/plugins/watcher/common/models/action/index_action.js (97%) rename x-pack/{legacy => }/plugins/watcher/common/models/action/jira_action.js (98%) rename x-pack/{legacy => }/plugins/watcher/common/models/action/logging_action.js (97%) rename x-pack/{legacy => }/plugins/watcher/common/models/action/pagerduty_action.js (97%) rename x-pack/{legacy => }/plugins/watcher/common/models/action/slack_action.js (97%) rename x-pack/{legacy => }/plugins/watcher/common/models/action/unknown_action.js (96%) rename x-pack/{legacy => }/plugins/watcher/common/models/action/webhook_action.js (98%) rename x-pack/{legacy => }/plugins/watcher/common/types/action_types.ts (100%) rename x-pack/{legacy => }/plugins/watcher/common/types/watch_types.ts (100%) rename x-pack/{legacy => }/plugins/watcher/kibana.json (69%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/app.tsx (96%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/app_context.tsx (94%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/boot.tsx (94%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/components/confirm_watches_modal.tsx (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/components/delete_watches_modal.tsx (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/components/form_errors.tsx (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/components/index.ts (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/components/page_error/index.ts (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/components/page_error/page_error.tsx (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/components/page_error/page_error_forbidden.tsx (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/components/page_error/page_error_not_exist.tsx (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/components/section_error.tsx (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/components/section_loading.tsx (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/components/watch_status.tsx (95%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/constants/base_path.ts (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/constants/index.ts (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/index.scss (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/lib/api.ts (96%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/lib/breadcrumbs.ts (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/lib/format_date.ts (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/lib/get_search_value.ts (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/lib/get_time_unit_label.ts (95%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/lib/navigation.ts (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/lib/use_request.ts (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/action/action.js (95%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/action/base_action.js (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/action/email_action.js (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/action/index.js (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/action/index_action.js (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/action/jira_action.js (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/action/logging_action.js (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/action/pagerduty_action.js (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/action/slack_action.js (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/action/unknown_action.js (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/action/webhook_action.js (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/action_status/action_status.js (95%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/action_status/index.js (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/execute_details/execute_details.js (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/execute_details/index.js (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/index.d.ts (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/settings/index.js (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/settings/settings.js (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/visualize_options/index.js (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/visualize_options/visualize_options.js (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/watch/agg_types.ts (94%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/watch/base_watch.js (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/watch/comparators.ts (96%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/watch/default_watch.json (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/watch/group_by_types.ts (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/watch/index.js (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/watch/json_watch.js (98%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/watch/lib/check_action_id_collision/check_action_id_collision.js (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/watch/lib/check_action_id_collision/index.js (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/watch/lib/create_action_id/create_action_id.js (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/watch/lib/create_action_id/index.js (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/watch/monitoring_watch.js (92%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/watch/threshold_watch.js (99%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/watch/watch.js (93%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/watch_errors/index.js (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/watch_errors/watch_errors.js (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/watch_history_item/index.js (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/watch_history_item/watch_history_item.js (91%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/watch_status/index.js (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/models/watch_status/watch_status.js (94%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_edit/components/json_watch_edit/index.ts (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_edit/components/json_watch_edit/json_watch_edit.tsx (95%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_edit/components/json_watch_edit/json_watch_edit_form.tsx (99%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_edit/components/json_watch_edit/json_watch_edit_simulate.tsx (99%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_edit/components/json_watch_edit/json_watch_edit_simulate_results.tsx (99%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_edit/components/monitoring_watch_edit/index.ts (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_edit/components/monitoring_watch_edit/monitoring_watch_edit.tsx (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_edit/components/request_flyout.tsx (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_edit/components/threshold_watch_edit/action_fields/email_action_fields.tsx (97%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_edit/components/threshold_watch_edit/action_fields/index.ts (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_edit/components/threshold_watch_edit/action_fields/index_action_fields.tsx (94%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_edit/components/threshold_watch_edit/action_fields/jira_action_fields.tsx (97%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_edit/components/threshold_watch_edit/action_fields/logging_action_fields.tsx (94%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_edit/components/threshold_watch_edit/action_fields/pagerduty_action_fields.tsx (95%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_edit/components/threshold_watch_edit/action_fields/slack_action_fields.tsx (96%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_edit/components/threshold_watch_edit/action_fields/webhook_action_fields.tsx (98%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_edit/components/threshold_watch_edit/index.ts (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_action_accordion.tsx (98%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_action_dropdown.tsx (98%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_action_panel.tsx (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_edit.tsx (99%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_edit/components/threshold_watch_edit/watch_visualization.tsx (99%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_edit/components/watch_edit.tsx (97%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_edit/watch_context.ts (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_edit/watch_edit_actions.ts (95%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_list/components/watch_list.tsx (99%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_status/components/watch_detail.tsx (99%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_status/components/watch_history.tsx (99%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_status/components/watch_status.tsx (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/sections/watch_status/watch_details_context.ts (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/application/shared_imports.ts (79%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/index.ts (100%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/plugin.ts (96%) rename x-pack/{legacy/plugins/watcher/public/np_ready => plugins/watcher/public}/types.ts (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/index.ts (86%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/lib/call_with_request_factory.ts (93%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/lib/elasticsearch_js_plugin.ts (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/lib/fetch_all_from_scroll/__tests__/fetch_all_from_scroll.js (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/lib/fetch_all_from_scroll/fetch_all_from_scroll.ts (92%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/lib/fetch_all_from_scroll/index.ts (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/lib/is_es_error/index.ts (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/lib/is_es_error/is_es_error.ts (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.js (92%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/lib/license_pre_routing_factory/index.ts (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/lib/license_pre_routing_factory/license_pre_routing_factory.ts (87%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/lib/normalized_field_types/index.ts (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/lib/normalized_field_types/normalized_field_types.ts (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/action_status/__tests__/action_status.js (99%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/action_status/action_status.js (97%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/action_status/index.js (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/execute_details/__tests__/execute_details.js (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/execute_details/execute_details.js (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/execute_details/index.js (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/fields/__tests__/fields.js (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/fields/fields.js (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/fields/index.js (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/settings/__tests__/settings.js (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/settings/index.js (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/settings/settings.js (97%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/visualize_options/index.js (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/visualize_options/visualize_options.js (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch/base_watch.js (98%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch/base_watch.test.js (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch/index.js (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch/json_watch.js (92%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch/json_watch.test.js (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch/lib/get_watch_type/get_watch_type.js (88%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch/lib/get_watch_type/index.js (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch/monitoring_watch.js (97%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch/monitoring_watch.test.js (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch/threshold_watch/__tests__/format_visualize_data.js (99%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch/threshold_watch/build_visualize_query.js (95%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch/threshold_watch/data_samples/count.json (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch/threshold_watch/data_samples/count.query.date.json (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch/threshold_watch/data_samples/count.query.json (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch/threshold_watch/data_samples/count_terms.json (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch/threshold_watch/data_samples/count_terms.query.date.json (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch/threshold_watch/data_samples/count_terms.query.json (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch/threshold_watch/data_samples/non_count.json (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch/threshold_watch/data_samples/non_count.query.date.json (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch/threshold_watch/data_samples/non_count.query.json (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch/threshold_watch/data_samples/non_count_terms.json (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch/threshold_watch/data_samples/non_count_terms.query.date.json (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch/threshold_watch/data_samples/non_count_terms.query.json (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch/threshold_watch/format_visualize_data.js (97%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch/threshold_watch/index.js (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch/threshold_watch/threshold_watch.js (97%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch/threshold_watch/threshold_watch.test.js (99%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch/watch.js (97%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch/watch.test.js (98%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch_errors/index.js (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch_errors/watch_errors.js (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch_errors/watch_errors.test.js (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch_history_item/__tests__/watch_history_item.js (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch_history_item/index.js (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch_history_item/watch_history_item.js (97%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch_status/__tests__/watch_status.js (99%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch_status/index.js (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/models/watch_status/watch_status.js (98%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/plugin.ts (90%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/routes/api/indices/index.ts (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/routes/api/indices/register_get_route.ts (98%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/routes/api/indices/register_indices_routes.ts (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/routes/api/license/index.ts (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/routes/api/license/register_license_routes.ts (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/routes/api/license/register_refresh_route.ts (95%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/routes/api/register_list_fields_route.ts (95%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/routes/api/register_load_history_route.ts (95%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/routes/api/settings/index.ts (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/routes/api/settings/register_load_route.ts (91%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/routes/api/settings/register_settings_routes.ts (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/routes/api/watch/action/index.ts (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/routes/api/watch/action/register_acknowledge_route.ts (94%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/routes/api/watch/action/register_action_routes.ts (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/routes/api/watch/index.ts (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/routes/api/watch/register_activate_route.ts (94%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/routes/api/watch/register_deactivate_route.ts (94%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/routes/api/watch/register_delete_route.ts (97%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/routes/api/watch/register_execute_route.ts (93%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/routes/api/watch/register_history_route.ts (95%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/routes/api/watch/register_load_route.ts (95%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/routes/api/watch/register_save_route.ts (94%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/routes/api/watch/register_visualize_route.ts (95%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/routes/api/watch/register_watch_routes.ts (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/routes/api/watches/index.ts (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/routes/api/watches/register_delete_route.ts (97%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/routes/api/watches/register_list_route.ts (92%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/routes/api/watches/register_watches_routes.ts (100%) rename x-pack/{legacy/plugins/watcher/server/np_ready => plugins/watcher/server}/types.ts (83%) rename x-pack/{legacy => }/plugins/watcher/test/fixtures/execute_details.ts (100%) rename x-pack/{legacy => }/plugins/watcher/test/fixtures/index.ts (100%) rename x-pack/{legacy => }/plugins/watcher/test/fixtures/watch.ts (95%) rename x-pack/{legacy => }/plugins/watcher/test/fixtures/watch_history.ts (93%) diff --git a/x-pack/legacy/plugins/watcher/index.js b/x-pack/legacy/plugins/watcher/index.js deleted file mode 100644 index 64237b532ea8d..0000000000000 --- a/x-pack/legacy/plugins/watcher/index.js +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { pluginDefinition } from './plugin_definition'; - -export const watcher = kibana => new kibana.Plugin(pluginDefinition); diff --git a/x-pack/legacy/plugins/watcher/plugin_definition.ts b/x-pack/legacy/plugins/watcher/plugin_definition.ts deleted file mode 100644 index 2da05253fdb32..0000000000000 --- a/x-pack/legacy/plugins/watcher/plugin_definition.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { resolve } from 'path'; -import { plugin } from './server/np_ready'; -import { PLUGIN } from './common/constants'; - -export const pluginDefinition = { - id: PLUGIN.ID, - configPrefix: 'xpack.watcher', - publicDir: resolve(__dirname, 'public'), - require: ['kibana', 'elasticsearch', 'xpack_main'], - uiExports: { - styleSheetPaths: resolve(__dirname, 'public/np_ready/application/index.scss'), - managementSections: ['plugins/watcher/legacy'], - home: ['plugins/watcher/register_feature'], - }, - init(server: any) { - plugin({} as any).setup(server.newPlatform.setup.core, { - __LEGACY: { - route: server.route.bind(server), - plugins: { - watcher: server.plugins[PLUGIN.ID], - xpack_main: server.plugins.xpack_main, - }, - }, - }); - }, -}; diff --git a/x-pack/legacy/plugins/watcher/public/legacy.ts b/x-pack/legacy/plugins/watcher/public/legacy.ts deleted file mode 100644 index 21fcd718ea1b7..0000000000000 --- a/x-pack/legacy/plugins/watcher/public/legacy.ts +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { CoreSetup, App, AppUnmount } from 'src/core/public'; -import { i18n } from '@kbn/i18n'; - -/* Legacy UI imports */ -import { npSetup, npStart } from 'ui/new_platform'; -import routes from 'ui/routes'; -import { management, MANAGEMENT_BREADCRUMB } from 'ui/management'; -import { TimeBuckets } from 'ui/time_buckets'; -// @ts-ignore -import { xpackInfo } from 'plugins/xpack_main/services/xpack_info'; -/* Legacy UI imports */ - -import { plugin } from './np_ready'; -import { PLUGIN } from '../common/constants'; -import { LICENSE_STATUS_INVALID, LICENSE_STATUS_UNAVAILABLE } from '../../../common/constants'; -import { manageAngularLifecycle } from './manage_angular_lifecycle'; - -const template = ` -
-
`; - -let elem: HTMLElement; -let mountApp: () => AppUnmount | Promise; -let unmountApp: AppUnmount | Promise; -routes.when('/management/elasticsearch/watcher/:param1?/:param2?/:param3?/:param4?', { - template, - controller: class WatcherController { - constructor($injector: any, $scope: any) { - const $route = $injector.get('$route'); - const licenseStatus = xpackInfo.get(`features.${PLUGIN.ID}`); - const shimCore: CoreSetup = { - ...npSetup.core, - application: { - ...npSetup.core.application, - register(app: App): void { - mountApp = () => - app.mount(npStart as any, { - element: elem, - appBasePath: '/management/elasticsearch/watcher/', - onAppLeave: () => undefined, - }); - }, - }, - }; - - // clean up previously rendered React app if one exists - // this happens because of React Router redirects - if (elem) { - ((unmountApp as unknown) as AppUnmount)(); - } - - $scope.$$postDigest(() => { - elem = document.getElementById('watchReactRoot')!; - const instance = plugin(); - instance.setup(shimCore, { - ...(npSetup.plugins as typeof npSetup.plugins & { eui_utils: any }), - __LEGACY: { - MANAGEMENT_BREADCRUMB, - TimeBuckets, - licenseStatus, - }, - }); - - instance.start(npStart.core, npStart.plugins); - - (mountApp() as Promise).then(fn => (unmountApp = fn)); - - manageAngularLifecycle($scope, $route, elem); - }); - } - } as any, - // @ts-ignore - controllerAs: 'watchRoute', -}); - -routes.defaults(/\/management/, { - resolve: { - watcherManagementSection: () => { - const watchesSection = management.getSection('elasticsearch/watcher'); - const licenseStatus = xpackInfo.get(`features.${PLUGIN.ID}`); - const { status } = licenseStatus; - - if (status === LICENSE_STATUS_INVALID || status === LICENSE_STATUS_UNAVAILABLE) { - return watchesSection.hide(); - } - - watchesSection.show(); - }, - }, -}); - -management.getSection('elasticsearch').register('watcher', { - display: i18n.translate('xpack.watcher.sections.watchList.managementSection.watcherDisplayName', { - defaultMessage: 'Watcher', - }), - order: 6, - url: '#/management/elasticsearch/watcher/', -} as any); - -management.getSection('elasticsearch/watcher').register('watches', { - display: i18n.translate('xpack.watcher.sections.watchList.managementSection.watchesDisplayName', { - defaultMessage: 'Watches', - }), - order: 1, -} as any); - -management.getSection('elasticsearch/watcher').register('watch', { - visible: false, -} as any); - -management.getSection('elasticsearch/watcher/watch').register('status', { - display: i18n.translate('xpack.watcher.sections.watchList.managementSection.statusDisplayName', { - defaultMessage: 'Status', - }), - order: 1, - visible: false, -} as any); - -management.getSection('elasticsearch/watcher/watch').register('edit', { - display: i18n.translate('xpack.watcher.sections.watchList.managementSection.editDisplayName', { - defaultMessage: 'Edit', - }), - order: 2, - visible: false, -} as any); - -management.getSection('elasticsearch/watcher/watch').register('new', { - display: i18n.translate( - 'xpack.watcher.sections.watchList.managementSection.newWatchDisplayName', - { - defaultMessage: 'New Watch', - } - ), - order: 1, - visible: false, -} as any); - -management.getSection('elasticsearch/watcher/watch').register('history-item', { - order: 1, - visible: false, -} as any); diff --git a/x-pack/legacy/plugins/watcher/public/manage_angular_lifecycle.ts b/x-pack/legacy/plugins/watcher/public/manage_angular_lifecycle.ts deleted file mode 100644 index efd40eaf83daa..0000000000000 --- a/x-pack/legacy/plugins/watcher/public/manage_angular_lifecycle.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { unmountComponentAtNode } from 'react-dom'; - -export const manageAngularLifecycle = ($scope: any, $route: any, elem: HTMLElement) => { - const lastRoute = $route.current; - - const deregister = $scope.$on('$locationChangeSuccess', () => { - const currentRoute = $route.current; - if (lastRoute.$$route.template === currentRoute.$$route.template) { - $route.current = lastRoute; - } - }); - - $scope.$on('$destroy', () => { - if (deregister) { - deregister(); - } - - if (elem) { - unmountComponentAtNode(elem); - } - }); -}; diff --git a/x-pack/legacy/plugins/watcher/public/register_feature.ts b/x-pack/legacy/plugins/watcher/public/register_feature.ts deleted file mode 100644 index 0de41e09f788e..0000000000000 --- a/x-pack/legacy/plugins/watcher/public/register_feature.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { i18n } from '@kbn/i18n'; -import { npSetup } from 'ui/new_platform'; -import { FeatureCatalogueCategory } from 'ui/registry/feature_catalogue'; - -npSetup.plugins.home.featureCatalogue.register({ - id: 'watcher', - title: 'Watcher', // This is a product name so we don't translate it. - category: FeatureCatalogueCategory.ADMIN, - description: i18n.translate('xpack.watcher.watcherDescription', { - defaultMessage: 'Detect changes in your data by creating, managing, and monitoring alerts.', - }), - icon: 'watchesApp', - path: '/app/kibana#/management/elasticsearch/watcher/watches', - showOnHomePage: true, -}); diff --git a/x-pack/legacy/plugins/watcher/README.md b/x-pack/plugins/watcher/README.md similarity index 100% rename from x-pack/legacy/plugins/watcher/README.md rename to x-pack/plugins/watcher/README.md diff --git a/x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/app_context.mock.tsx b/x-pack/plugins/watcher/__jest__/client_integration/helpers/app_context.mock.tsx similarity index 90% rename from x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/app_context.mock.tsx rename to x-pack/plugins/watcher/__jest__/client_integration/helpers/app_context.mock.tsx index de285ee15b59d..42494792db3d8 100644 --- a/x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/app_context.mock.tsx +++ b/x-pack/plugins/watcher/__jest__/client_integration/helpers/app_context.mock.tsx @@ -12,8 +12,8 @@ import { uiSettingsServiceMock, notificationServiceMock, httpServiceMock, -} from '../../../../../../../src/core/public/mocks'; -import { AppContextProvider } from '../../../public/np_ready/application/app_context'; +} from '../../../../../../src/core/public/mocks'; +import { AppContextProvider } from '../../../public/application/app_context'; export const mockContextValue = { docLinks: docLinksServiceMock.createStartContract(), diff --git a/x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/body_response.ts b/x-pack/plugins/watcher/__jest__/client_integration/helpers/body_response.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/body_response.ts rename to x-pack/plugins/watcher/__jest__/client_integration/helpers/body_response.ts diff --git a/x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/constants.ts b/x-pack/plugins/watcher/__jest__/client_integration/helpers/constants.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/constants.ts rename to x-pack/plugins/watcher/__jest__/client_integration/helpers/constants.ts diff --git a/x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/http_requests.ts b/x-pack/plugins/watcher/__jest__/client_integration/helpers/http_requests.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/http_requests.ts rename to x-pack/plugins/watcher/__jest__/client_integration/helpers/http_requests.ts diff --git a/x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/index.ts b/x-pack/plugins/watcher/__jest__/client_integration/helpers/index.ts similarity index 96% rename from x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/index.ts rename to x-pack/plugins/watcher/__jest__/client_integration/helpers/index.ts index 814028fe599ff..bdafb4a313867 100644 --- a/x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/index.ts +++ b/x-pack/plugins/watcher/__jest__/client_integration/helpers/index.ts @@ -10,7 +10,7 @@ import { setup as watchCreateJsonSetup } from './watch_create_json.helpers'; import { setup as watchCreateThresholdSetup } from './watch_create_threshold.helpers'; import { setup as watchEditSetup } from './watch_edit.helpers'; -export { nextTick, getRandomString, findTestSubject, TestBed } from '../../../../../../test_utils'; +export { nextTick, getRandomString, findTestSubject, TestBed } from 'test_utils/index'; export { wrapBodyResponse, unwrapBodyResponse } from './body_response'; export { setupEnvironment } from './setup_environment'; diff --git a/x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/setup_environment.ts b/x-pack/plugins/watcher/__jest__/client_integration/helpers/setup_environment.ts similarity index 96% rename from x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/setup_environment.ts rename to x-pack/plugins/watcher/__jest__/client_integration/helpers/setup_environment.ts index 7e748073c1c6b..224a68186e1da 100644 --- a/x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/setup_environment.ts +++ b/x-pack/plugins/watcher/__jest__/client_integration/helpers/setup_environment.ts @@ -7,7 +7,7 @@ import axios from 'axios'; import axiosXhrAdapter from 'axios/lib/adapters/xhr'; import { init as initHttpRequests } from './http_requests'; -import { setHttpClient, setSavedObjectsClient } from '../../../public/np_ready/application/lib/api'; +import { setHttpClient, setSavedObjectsClient } from '../../../public/application/lib/api'; const mockHttpClient = axios.create({ adapter: axiosXhrAdapter }); mockHttpClient.interceptors.response.use( diff --git a/x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/watch_create_json.helpers.ts b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_create_json.helpers.ts similarity index 87% rename from x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/watch_create_json.helpers.ts rename to x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_create_json.helpers.ts index dafcf3a7070d2..0e0fc4e30da8f 100644 --- a/x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/watch_create_json.helpers.ts +++ b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_create_json.helpers.ts @@ -4,10 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ import { withAppContext } from './app_context.mock'; -import { registerTestBed, TestBed, TestBedConfig } from '../../../../../../test_utils'; -import { WatchEdit } from '../../../public/np_ready/application/sections/watch_edit/components/watch_edit'; +import { registerTestBed, TestBed, TestBedConfig } from 'test_utils/index'; +import { WatchEdit } from '../../../public/application/sections/watch_edit/components/watch_edit'; import { ROUTES, WATCH_TYPES } from '../../../common/constants'; -import { registerRouter } from '../../../public/np_ready/application/lib/navigation'; +import { registerRouter } from '../../../public/application/lib/navigation'; const testBedConfig: TestBedConfig = { memoryRouter: { diff --git a/x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/watch_create_threshold.helpers.ts b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_create_threshold.helpers.ts similarity index 91% rename from x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/watch_create_threshold.helpers.ts rename to x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_create_threshold.helpers.ts index 65648ae5f5a95..0c21e03f4eaf2 100644 --- a/x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/watch_create_threshold.helpers.ts +++ b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_create_threshold.helpers.ts @@ -3,10 +3,10 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed, TestBed, TestBedConfig } from '../../../../../../test_utils'; -import { WatchEdit } from '../../../public/np_ready/application/sections/watch_edit/components/watch_edit'; +import { registerTestBed, TestBed, TestBedConfig } from 'test_utils/index'; +import { WatchEdit } from '../../../public/application/sections/watch_edit/components/watch_edit'; import { ROUTES, WATCH_TYPES } from '../../../common/constants'; -import { registerRouter } from '../../../public/np_ready/application/lib/navigation'; +import { registerRouter } from '../../../public/application/lib/navigation'; import { withAppContext } from './app_context.mock'; const testBedConfig: TestBedConfig = { diff --git a/x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/watch_edit.helpers.ts b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_edit.helpers.ts similarity index 82% rename from x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/watch_edit.helpers.ts rename to x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_edit.helpers.ts index 187f4dcaa0a76..afa2012f533ac 100644 --- a/x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/watch_edit.helpers.ts +++ b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_edit.helpers.ts @@ -3,10 +3,10 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed, TestBed, TestBedConfig } from '../../../../../../test_utils'; -import { WatchEdit } from '../../../public/np_ready/application/sections/watch_edit/components/watch_edit'; +import { registerTestBed, TestBed, TestBedConfig } from 'test_utils/index'; +import { WatchEdit } from '../../../public/application/sections/watch_edit/components/watch_edit'; import { ROUTES } from '../../../common/constants'; -import { registerRouter } from '../../../public/np_ready/application/lib/navigation'; +import { registerRouter } from '../../../public/application/lib/navigation'; import { WATCH_ID } from './constants'; import { withAppContext } from './app_context.mock'; diff --git a/x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/watch_list.helpers.ts b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_list.helpers.ts similarity index 94% rename from x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/watch_list.helpers.ts rename to x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_list.helpers.ts index e33327ea42ffe..8afd57a089ede 100644 --- a/x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/watch_list.helpers.ts +++ b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_list.helpers.ts @@ -12,8 +12,8 @@ import { TestBed, TestBedConfig, nextTick, -} from '../../../../../../test_utils'; -import { WatchList } from '../../../public/np_ready/application/sections/watch_list/components/watch_list'; +} from 'test_utils/index'; +import { WatchList } from '../../../public/application/sections/watch_list/components/watch_list'; import { ROUTES } from '../../../common/constants'; import { withAppContext } from './app_context.mock'; diff --git a/x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/watch_status.helpers.ts b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_status.helpers.ts similarity index 96% rename from x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/watch_status.helpers.ts rename to x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_status.helpers.ts index e7bffe8924e31..1fdf2eb5c5c86 100644 --- a/x-pack/legacy/plugins/watcher/__jest__/client_integration/helpers/watch_status.helpers.ts +++ b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_status.helpers.ts @@ -12,8 +12,8 @@ import { TestBed, TestBedConfig, nextTick, -} from '../../../../../../test_utils'; -import { WatchStatus } from '../../../public/np_ready/application/sections/watch_status/components/watch_status'; +} from 'test_utils/index'; +import { WatchStatus } from '../../../public/application/sections/watch_status/components/watch_status'; import { ROUTES } from '../../../common/constants'; import { WATCH_ID } from './constants'; import { withAppContext } from './app_context.mock'; diff --git a/x-pack/legacy/plugins/watcher/__jest__/client_integration/watch_create_json.test.ts b/x-pack/plugins/watcher/__jest__/client_integration/watch_create_json.test.ts similarity index 98% rename from x-pack/legacy/plugins/watcher/__jest__/client_integration/watch_create_json.test.ts rename to x-pack/plugins/watcher/__jest__/client_integration/watch_create_json.test.ts index 4c893978ee5cb..26be3421b534e 100644 --- a/x-pack/legacy/plugins/watcher/__jest__/client_integration/watch_create_json.test.ts +++ b/x-pack/plugins/watcher/__jest__/client_integration/watch_create_json.test.ts @@ -7,7 +7,7 @@ import { act } from 'react-dom/test-utils'; import { setupEnvironment, pageHelpers, nextTick, wrapBodyResponse } from './helpers'; import { WatchCreateJsonTestBed } from './helpers/watch_create_json.helpers'; import { WATCH } from './helpers/constants'; -import defaultWatchJson from '../../public/np_ready/application/models/watch/default_watch.json'; +import defaultWatchJson from '../../public/application/models/watch/default_watch.json'; import { getExecuteDetails } from '../../test/fixtures'; const { setup } = pageHelpers.watchCreateJson; diff --git a/x-pack/legacy/plugins/watcher/__jest__/client_integration/watch_create_threshold.test.tsx b/x-pack/plugins/watcher/__jest__/client_integration/watch_create_threshold.test.tsx similarity index 100% rename from x-pack/legacy/plugins/watcher/__jest__/client_integration/watch_create_threshold.test.tsx rename to x-pack/plugins/watcher/__jest__/client_integration/watch_create_threshold.test.tsx diff --git a/x-pack/legacy/plugins/watcher/__jest__/client_integration/watch_edit.test.ts b/x-pack/plugins/watcher/__jest__/client_integration/watch_edit.test.ts similarity index 97% rename from x-pack/legacy/plugins/watcher/__jest__/client_integration/watch_edit.test.ts rename to x-pack/plugins/watcher/__jest__/client_integration/watch_edit.test.ts index 131400a8702c4..5acee16354438 100644 --- a/x-pack/legacy/plugins/watcher/__jest__/client_integration/watch_edit.test.ts +++ b/x-pack/plugins/watcher/__jest__/client_integration/watch_edit.test.ts @@ -9,9 +9,9 @@ import axios from 'axios'; import { setupEnvironment, pageHelpers, nextTick, wrapBodyResponse } from './helpers'; import { WatchEditTestBed } from './helpers/watch_edit.helpers'; import { WATCH } from './helpers/constants'; -import defaultWatchJson from '../../public/np_ready/application/models/watch/default_watch.json'; +import defaultWatchJson from '../../public/application/models/watch/default_watch.json'; import { getWatch } from '../../test/fixtures'; -import { getRandomString } from '../../../../../test_utils'; +import { getRandomString } from 'test_utils/index'; const mockHttpClient = axios.create({ adapter: axiosXhrAdapter }); diff --git a/x-pack/legacy/plugins/watcher/__jest__/client_integration/watch_list.test.ts b/x-pack/plugins/watcher/__jest__/client_integration/watch_list.test.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/__jest__/client_integration/watch_list.test.ts rename to x-pack/plugins/watcher/__jest__/client_integration/watch_list.test.ts diff --git a/x-pack/legacy/plugins/watcher/__jest__/client_integration/watch_status.test.ts b/x-pack/plugins/watcher/__jest__/client_integration/watch_status.test.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/__jest__/client_integration/watch_status.test.ts rename to x-pack/plugins/watcher/__jest__/client_integration/watch_status.test.ts diff --git a/x-pack/legacy/plugins/watcher/common/constants/action_modes.ts b/x-pack/plugins/watcher/common/constants/action_modes.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/common/constants/action_modes.ts rename to x-pack/plugins/watcher/common/constants/action_modes.ts diff --git a/x-pack/legacy/plugins/watcher/common/constants/action_states.ts b/x-pack/plugins/watcher/common/constants/action_states.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/common/constants/action_states.ts rename to x-pack/plugins/watcher/common/constants/action_states.ts diff --git a/x-pack/legacy/plugins/watcher/common/constants/action_types.ts b/x-pack/plugins/watcher/common/constants/action_types.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/common/constants/action_types.ts rename to x-pack/plugins/watcher/common/constants/action_types.ts diff --git a/x-pack/legacy/plugins/watcher/common/constants/agg_types.ts b/x-pack/plugins/watcher/common/constants/agg_types.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/common/constants/agg_types.ts rename to x-pack/plugins/watcher/common/constants/agg_types.ts diff --git a/x-pack/legacy/plugins/watcher/common/constants/comparators.ts b/x-pack/plugins/watcher/common/constants/comparators.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/common/constants/comparators.ts rename to x-pack/plugins/watcher/common/constants/comparators.ts diff --git a/x-pack/legacy/plugins/watcher/common/constants/error_codes.ts b/x-pack/plugins/watcher/common/constants/error_codes.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/common/constants/error_codes.ts rename to x-pack/plugins/watcher/common/constants/error_codes.ts diff --git a/x-pack/legacy/plugins/watcher/common/constants/es_scroll_settings.ts b/x-pack/plugins/watcher/common/constants/es_scroll_settings.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/common/constants/es_scroll_settings.ts rename to x-pack/plugins/watcher/common/constants/es_scroll_settings.ts diff --git a/x-pack/legacy/plugins/watcher/common/constants/index.ts b/x-pack/plugins/watcher/common/constants/index.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/common/constants/index.ts rename to x-pack/plugins/watcher/common/constants/index.ts diff --git a/x-pack/legacy/plugins/watcher/common/constants/index_names.ts b/x-pack/plugins/watcher/common/constants/index_names.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/common/constants/index_names.ts rename to x-pack/plugins/watcher/common/constants/index_names.ts diff --git a/x-pack/legacy/plugins/watcher/common/constants/lists.ts b/x-pack/plugins/watcher/common/constants/lists.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/common/constants/lists.ts rename to x-pack/plugins/watcher/common/constants/lists.ts diff --git a/x-pack/legacy/plugins/watcher/common/constants/pagination.ts b/x-pack/plugins/watcher/common/constants/pagination.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/common/constants/pagination.ts rename to x-pack/plugins/watcher/common/constants/pagination.ts diff --git a/x-pack/legacy/plugins/watcher/common/constants/plugin.ts b/x-pack/plugins/watcher/common/constants/plugin.ts similarity index 85% rename from x-pack/legacy/plugins/watcher/common/constants/plugin.ts rename to x-pack/plugins/watcher/common/constants/plugin.ts index a4279a0dd0c41..f89ef95e9261f 100644 --- a/x-pack/legacy/plugins/watcher/common/constants/plugin.ts +++ b/x-pack/plugins/watcher/common/constants/plugin.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { LICENSE_TYPE_GOLD, LicenseType } from '../../../../common/constants'; +import { LICENSE_TYPE_GOLD, LicenseType } from '../../../../legacy/common/constants'; export const PLUGIN = { ID: 'watcher', diff --git a/x-pack/legacy/plugins/watcher/common/constants/refresh_intervals.ts b/x-pack/plugins/watcher/common/constants/refresh_intervals.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/common/constants/refresh_intervals.ts rename to x-pack/plugins/watcher/common/constants/refresh_intervals.ts diff --git a/x-pack/legacy/plugins/watcher/common/constants/routes.ts b/x-pack/plugins/watcher/common/constants/routes.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/common/constants/routes.ts rename to x-pack/plugins/watcher/common/constants/routes.ts diff --git a/x-pack/legacy/plugins/watcher/common/constants/sort_orders.ts b/x-pack/plugins/watcher/common/constants/sort_orders.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/common/constants/sort_orders.ts rename to x-pack/plugins/watcher/common/constants/sort_orders.ts diff --git a/x-pack/legacy/plugins/watcher/common/constants/time_units.ts b/x-pack/plugins/watcher/common/constants/time_units.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/common/constants/time_units.ts rename to x-pack/plugins/watcher/common/constants/time_units.ts diff --git a/x-pack/legacy/plugins/watcher/common/constants/watch_history.ts b/x-pack/plugins/watcher/common/constants/watch_history.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/common/constants/watch_history.ts rename to x-pack/plugins/watcher/common/constants/watch_history.ts diff --git a/x-pack/legacy/plugins/watcher/common/constants/watch_state_comments.ts b/x-pack/plugins/watcher/common/constants/watch_state_comments.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/common/constants/watch_state_comments.ts rename to x-pack/plugins/watcher/common/constants/watch_state_comments.ts diff --git a/x-pack/legacy/plugins/watcher/common/constants/watch_states.ts b/x-pack/plugins/watcher/common/constants/watch_states.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/common/constants/watch_states.ts rename to x-pack/plugins/watcher/common/constants/watch_states.ts diff --git a/x-pack/legacy/plugins/watcher/common/constants/watch_types.ts b/x-pack/plugins/watcher/common/constants/watch_types.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/common/constants/watch_types.ts rename to x-pack/plugins/watcher/common/constants/watch_types.ts diff --git a/x-pack/legacy/plugins/watcher/common/lib/get_action_type/__tests__/get_action_type.js b/x-pack/plugins/watcher/common/lib/get_action_type/__tests__/get_action_type.js similarity index 97% rename from x-pack/legacy/plugins/watcher/common/lib/get_action_type/__tests__/get_action_type.js rename to x-pack/plugins/watcher/common/lib/get_action_type/__tests__/get_action_type.js index 164bbab285fce..1410488ee6413 100644 --- a/x-pack/legacy/plugins/watcher/common/lib/get_action_type/__tests__/get_action_type.js +++ b/x-pack/plugins/watcher/common/lib/get_action_type/__tests__/get_action_type.js @@ -6,7 +6,7 @@ import expect from '@kbn/expect'; import { getActionType } from '../get_action_type'; -import { ACTION_TYPES } from '../../../../common/constants'; +import { ACTION_TYPES } from '../../../constants'; describe('get_action_type', () => { describe('getActionType', () => { diff --git a/x-pack/legacy/plugins/watcher/common/lib/get_action_type/get_action_type.ts b/x-pack/plugins/watcher/common/lib/get_action_type/get_action_type.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/common/lib/get_action_type/get_action_type.ts rename to x-pack/plugins/watcher/common/lib/get_action_type/get_action_type.ts diff --git a/x-pack/legacy/plugins/watcher/common/lib/get_action_type/index.ts b/x-pack/plugins/watcher/common/lib/get_action_type/index.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/common/lib/get_action_type/index.ts rename to x-pack/plugins/watcher/common/lib/get_action_type/index.ts diff --git a/x-pack/legacy/plugins/watcher/common/lib/get_moment/__tests__/get_moment.js b/x-pack/plugins/watcher/common/lib/get_moment/__tests__/get_moment.js similarity index 100% rename from x-pack/legacy/plugins/watcher/common/lib/get_moment/__tests__/get_moment.js rename to x-pack/plugins/watcher/common/lib/get_moment/__tests__/get_moment.js diff --git a/x-pack/legacy/plugins/watcher/common/lib/get_moment/get_moment.js b/x-pack/plugins/watcher/common/lib/get_moment/get_moment.js similarity index 100% rename from x-pack/legacy/plugins/watcher/common/lib/get_moment/get_moment.js rename to x-pack/plugins/watcher/common/lib/get_moment/get_moment.js diff --git a/x-pack/legacy/plugins/watcher/common/lib/get_moment/index.js b/x-pack/plugins/watcher/common/lib/get_moment/index.js similarity index 100% rename from x-pack/legacy/plugins/watcher/common/lib/get_moment/index.js rename to x-pack/plugins/watcher/common/lib/get_moment/index.js diff --git a/x-pack/legacy/plugins/watcher/common/lib/serialization/index.d.ts b/x-pack/plugins/watcher/common/lib/serialization/index.d.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/common/lib/serialization/index.d.ts rename to x-pack/plugins/watcher/common/lib/serialization/index.d.ts diff --git a/x-pack/legacy/plugins/watcher/common/lib/serialization/index.js b/x-pack/plugins/watcher/common/lib/serialization/index.js similarity index 100% rename from x-pack/legacy/plugins/watcher/common/lib/serialization/index.js rename to x-pack/plugins/watcher/common/lib/serialization/index.js diff --git a/x-pack/legacy/plugins/watcher/common/lib/serialization/serialization_helpers/build_actions.js b/x-pack/plugins/watcher/common/lib/serialization/serialization_helpers/build_actions.js similarity index 100% rename from x-pack/legacy/plugins/watcher/common/lib/serialization/serialization_helpers/build_actions.js rename to x-pack/plugins/watcher/common/lib/serialization/serialization_helpers/build_actions.js diff --git a/x-pack/legacy/plugins/watcher/common/lib/serialization/serialization_helpers/build_condition.js b/x-pack/plugins/watcher/common/lib/serialization/serialization_helpers/build_condition.js similarity index 98% rename from x-pack/legacy/plugins/watcher/common/lib/serialization/serialization_helpers/build_condition.js rename to x-pack/plugins/watcher/common/lib/serialization/serialization_helpers/build_condition.js index 472349b87fbc1..620859608bc26 100644 --- a/x-pack/legacy/plugins/watcher/common/lib/serialization/serialization_helpers/build_condition.js +++ b/x-pack/plugins/watcher/common/lib/serialization/serialization_helpers/build_condition.js @@ -5,7 +5,7 @@ */ import { singleLineScript } from './single_line_script'; -import { COMPARATORS } from '../../../../common/constants'; +import { COMPARATORS } from '../../../constants'; const { BETWEEN } = COMPARATORS; /* watch.condition.script.inline diff --git a/x-pack/legacy/plugins/watcher/common/lib/serialization/serialization_helpers/build_input.js b/x-pack/plugins/watcher/common/lib/serialization/serialization_helpers/build_input.js similarity index 100% rename from x-pack/legacy/plugins/watcher/common/lib/serialization/serialization_helpers/build_input.js rename to x-pack/plugins/watcher/common/lib/serialization/serialization_helpers/build_input.js diff --git a/x-pack/legacy/plugins/watcher/common/lib/serialization/serialization_helpers/build_metadata.js b/x-pack/plugins/watcher/common/lib/serialization/serialization_helpers/build_metadata.js similarity index 100% rename from x-pack/legacy/plugins/watcher/common/lib/serialization/serialization_helpers/build_metadata.js rename to x-pack/plugins/watcher/common/lib/serialization/serialization_helpers/build_metadata.js diff --git a/x-pack/legacy/plugins/watcher/common/lib/serialization/serialization_helpers/build_transform.js b/x-pack/plugins/watcher/common/lib/serialization/serialization_helpers/build_transform.js similarity index 98% rename from x-pack/legacy/plugins/watcher/common/lib/serialization/serialization_helpers/build_transform.js rename to x-pack/plugins/watcher/common/lib/serialization/serialization_helpers/build_transform.js index 1ac4adb821804..1fcbd75aeaeea 100644 --- a/x-pack/legacy/plugins/watcher/common/lib/serialization/serialization_helpers/build_transform.js +++ b/x-pack/plugins/watcher/common/lib/serialization/serialization_helpers/build_transform.js @@ -5,7 +5,7 @@ */ import { singleLineScript } from './single_line_script'; -import { COMPARATORS } from '../../../../common/constants'; +import { COMPARATORS } from '../../../constants'; const { BETWEEN } = COMPARATORS; /* watch.transform.script.inline diff --git a/x-pack/legacy/plugins/watcher/common/lib/serialization/serialization_helpers/build_trigger.js b/x-pack/plugins/watcher/common/lib/serialization/serialization_helpers/build_trigger.js similarity index 100% rename from x-pack/legacy/plugins/watcher/common/lib/serialization/serialization_helpers/build_trigger.js rename to x-pack/plugins/watcher/common/lib/serialization/serialization_helpers/build_trigger.js diff --git a/x-pack/legacy/plugins/watcher/common/lib/serialization/serialization_helpers/index.js b/x-pack/plugins/watcher/common/lib/serialization/serialization_helpers/index.js similarity index 100% rename from x-pack/legacy/plugins/watcher/common/lib/serialization/serialization_helpers/index.js rename to x-pack/plugins/watcher/common/lib/serialization/serialization_helpers/index.js diff --git a/x-pack/legacy/plugins/watcher/common/lib/serialization/serialization_helpers/single_line_script.js b/x-pack/plugins/watcher/common/lib/serialization/serialization_helpers/single_line_script.js similarity index 100% rename from x-pack/legacy/plugins/watcher/common/lib/serialization/serialization_helpers/single_line_script.js rename to x-pack/plugins/watcher/common/lib/serialization/serialization_helpers/single_line_script.js diff --git a/x-pack/legacy/plugins/watcher/common/lib/serialization/serialize_json_watch.js b/x-pack/plugins/watcher/common/lib/serialization/serialize_json_watch.js similarity index 100% rename from x-pack/legacy/plugins/watcher/common/lib/serialization/serialize_json_watch.js rename to x-pack/plugins/watcher/common/lib/serialization/serialize_json_watch.js diff --git a/x-pack/legacy/plugins/watcher/common/lib/serialization/serialize_json_watch.test.js b/x-pack/plugins/watcher/common/lib/serialization/serialize_json_watch.test.js similarity index 100% rename from x-pack/legacy/plugins/watcher/common/lib/serialization/serialize_json_watch.test.js rename to x-pack/plugins/watcher/common/lib/serialization/serialize_json_watch.test.js diff --git a/x-pack/legacy/plugins/watcher/common/lib/serialization/serialize_threshold_watch.js b/x-pack/plugins/watcher/common/lib/serialization/serialize_threshold_watch.js similarity index 100% rename from x-pack/legacy/plugins/watcher/common/lib/serialization/serialize_threshold_watch.js rename to x-pack/plugins/watcher/common/lib/serialization/serialize_threshold_watch.js diff --git a/x-pack/legacy/plugins/watcher/common/lib/serialization/serialize_threshold_watch.test.js b/x-pack/plugins/watcher/common/lib/serialization/serialize_threshold_watch.test.js similarity index 100% rename from x-pack/legacy/plugins/watcher/common/lib/serialization/serialize_threshold_watch.test.js rename to x-pack/plugins/watcher/common/lib/serialization/serialize_threshold_watch.test.js diff --git a/x-pack/legacy/plugins/watcher/common/models/action/action.js b/x-pack/plugins/watcher/common/models/action/action.js similarity index 92% rename from x-pack/legacy/plugins/watcher/common/models/action/action.js rename to x-pack/plugins/watcher/common/models/action/action.js index e66a63eaed186..0375b6ebf5d47 100644 --- a/x-pack/legacy/plugins/watcher/common/models/action/action.js +++ b/x-pack/plugins/watcher/common/models/action/action.js @@ -5,8 +5,8 @@ */ import { set } from 'lodash'; -import { getActionType } from '../../../common/lib/get_action_type'; -import { ACTION_TYPES } from '../../../common/constants'; +import { getActionType } from '../../lib/get_action_type'; +import { ACTION_TYPES } from '../../constants'; import { LoggingAction } from './logging_action'; import { EmailAction } from './email_action'; import { SlackAction } from './slack_action'; diff --git a/x-pack/legacy/plugins/watcher/common/models/action/action.test.js b/x-pack/plugins/watcher/common/models/action/action.test.js similarity index 97% rename from x-pack/legacy/plugins/watcher/common/models/action/action.test.js rename to x-pack/plugins/watcher/common/models/action/action.test.js index ee1265cd2edee..8a5f47fe0e5ca 100644 --- a/x-pack/legacy/plugins/watcher/common/models/action/action.test.js +++ b/x-pack/plugins/watcher/common/models/action/action.test.js @@ -5,7 +5,7 @@ */ import { Action } from './action'; -import { ACTION_TYPES } from '../../../common/constants'; +import { ACTION_TYPES } from '../../constants'; jest.mock('./logging_action', () => ({ LoggingAction: { diff --git a/x-pack/legacy/plugins/watcher/common/models/action/base_action.js b/x-pack/plugins/watcher/common/models/action/base_action.js similarity index 100% rename from x-pack/legacy/plugins/watcher/common/models/action/base_action.js rename to x-pack/plugins/watcher/common/models/action/base_action.js diff --git a/x-pack/legacy/plugins/watcher/common/models/action/email_action.js b/x-pack/plugins/watcher/common/models/action/email_action.js similarity index 98% rename from x-pack/legacy/plugins/watcher/common/models/action/email_action.js rename to x-pack/plugins/watcher/common/models/action/email_action.js index de948100951ad..918a2d125c09a 100644 --- a/x-pack/legacy/plugins/watcher/common/models/action/email_action.js +++ b/x-pack/plugins/watcher/common/models/action/email_action.js @@ -5,7 +5,7 @@ */ import { BaseAction } from './base_action'; -import { ACTION_TYPES, ERROR_CODES } from '../../../common/constants'; +import { ACTION_TYPES, ERROR_CODES } from '../../constants'; import { i18n } from '@kbn/i18n'; export class EmailAction extends BaseAction { diff --git a/x-pack/legacy/plugins/watcher/common/models/action/index.js b/x-pack/plugins/watcher/common/models/action/index.js similarity index 100% rename from x-pack/legacy/plugins/watcher/common/models/action/index.js rename to x-pack/plugins/watcher/common/models/action/index.js diff --git a/x-pack/legacy/plugins/watcher/common/models/action/index_action.js b/x-pack/plugins/watcher/common/models/action/index_action.js similarity index 97% rename from x-pack/legacy/plugins/watcher/common/models/action/index_action.js rename to x-pack/plugins/watcher/common/models/action/index_action.js index 73932079977fd..3db4e4f9b0dab 100644 --- a/x-pack/legacy/plugins/watcher/common/models/action/index_action.js +++ b/x-pack/plugins/watcher/common/models/action/index_action.js @@ -5,7 +5,7 @@ */ import { BaseAction } from './base_action'; -import { ACTION_TYPES, ERROR_CODES } from '../../../common/constants'; +import { ACTION_TYPES, ERROR_CODES } from '../../constants'; import { i18n } from '@kbn/i18n'; export class IndexAction extends BaseAction { diff --git a/x-pack/legacy/plugins/watcher/common/models/action/jira_action.js b/x-pack/plugins/watcher/common/models/action/jira_action.js similarity index 98% rename from x-pack/legacy/plugins/watcher/common/models/action/jira_action.js rename to x-pack/plugins/watcher/common/models/action/jira_action.js index 75fa60986c49a..87bca6c480229 100644 --- a/x-pack/legacy/plugins/watcher/common/models/action/jira_action.js +++ b/x-pack/plugins/watcher/common/models/action/jira_action.js @@ -5,7 +5,7 @@ */ import { BaseAction } from './base_action'; -import { ACTION_TYPES, ERROR_CODES } from '../../../common/constants'; +import { ACTION_TYPES, ERROR_CODES } from '../../constants'; import { i18n } from '@kbn/i18n'; import { get } from 'lodash'; diff --git a/x-pack/legacy/plugins/watcher/common/models/action/logging_action.js b/x-pack/plugins/watcher/common/models/action/logging_action.js similarity index 97% rename from x-pack/legacy/plugins/watcher/common/models/action/logging_action.js rename to x-pack/plugins/watcher/common/models/action/logging_action.js index c3754b7ace238..e9dd0b3d7ddfb 100644 --- a/x-pack/legacy/plugins/watcher/common/models/action/logging_action.js +++ b/x-pack/plugins/watcher/common/models/action/logging_action.js @@ -5,7 +5,7 @@ */ import { BaseAction } from './base_action'; -import { ACTION_TYPES, ERROR_CODES } from '../../../common/constants'; +import { ACTION_TYPES, ERROR_CODES } from '../../constants'; import { i18n } from '@kbn/i18n'; export class LoggingAction extends BaseAction { diff --git a/x-pack/legacy/plugins/watcher/common/models/action/pagerduty_action.js b/x-pack/plugins/watcher/common/models/action/pagerduty_action.js similarity index 97% rename from x-pack/legacy/plugins/watcher/common/models/action/pagerduty_action.js rename to x-pack/plugins/watcher/common/models/action/pagerduty_action.js index cc15d10f7c622..b92fbf55bda16 100644 --- a/x-pack/legacy/plugins/watcher/common/models/action/pagerduty_action.js +++ b/x-pack/plugins/watcher/common/models/action/pagerduty_action.js @@ -5,7 +5,7 @@ */ import { BaseAction } from './base_action'; -import { ACTION_TYPES, ERROR_CODES } from '../../../common/constants'; +import { ACTION_TYPES, ERROR_CODES } from '../../constants'; import { i18n } from '@kbn/i18n'; export class PagerDutyAction extends BaseAction { diff --git a/x-pack/legacy/plugins/watcher/common/models/action/slack_action.js b/x-pack/plugins/watcher/common/models/action/slack_action.js similarity index 97% rename from x-pack/legacy/plugins/watcher/common/models/action/slack_action.js rename to x-pack/plugins/watcher/common/models/action/slack_action.js index a1986977c4633..24caa9ccfd581 100644 --- a/x-pack/legacy/plugins/watcher/common/models/action/slack_action.js +++ b/x-pack/plugins/watcher/common/models/action/slack_action.js @@ -5,7 +5,7 @@ */ import { BaseAction } from './base_action'; -import { ACTION_TYPES, ERROR_CODES } from '../../../common/constants'; +import { ACTION_TYPES, ERROR_CODES } from '../../constants'; import { i18n } from '@kbn/i18n'; export class SlackAction extends BaseAction { diff --git a/x-pack/legacy/plugins/watcher/common/models/action/unknown_action.js b/x-pack/plugins/watcher/common/models/action/unknown_action.js similarity index 96% rename from x-pack/legacy/plugins/watcher/common/models/action/unknown_action.js rename to x-pack/plugins/watcher/common/models/action/unknown_action.js index 95ed542e66fa5..4f304be2d58b6 100644 --- a/x-pack/legacy/plugins/watcher/common/models/action/unknown_action.js +++ b/x-pack/plugins/watcher/common/models/action/unknown_action.js @@ -5,7 +5,7 @@ */ import { BaseAction } from './base_action'; -import { ACTION_TYPES, ERROR_CODES } from '../../../common/constants'; +import { ACTION_TYPES, ERROR_CODES } from '../../constants'; import { i18n } from '@kbn/i18n'; export class UnknownAction extends BaseAction { diff --git a/x-pack/legacy/plugins/watcher/common/models/action/webhook_action.js b/x-pack/plugins/watcher/common/models/action/webhook_action.js similarity index 98% rename from x-pack/legacy/plugins/watcher/common/models/action/webhook_action.js rename to x-pack/plugins/watcher/common/models/action/webhook_action.js index d6f921a75a9ea..f0e9fc9fc44df 100644 --- a/x-pack/legacy/plugins/watcher/common/models/action/webhook_action.js +++ b/x-pack/plugins/watcher/common/models/action/webhook_action.js @@ -5,7 +5,7 @@ */ import { BaseAction } from './base_action'; -import { ACTION_TYPES, ERROR_CODES } from '../../../common/constants'; +import { ACTION_TYPES, ERROR_CODES } from '../../constants'; import { i18n } from '@kbn/i18n'; export class WebhookAction extends BaseAction { diff --git a/x-pack/legacy/plugins/watcher/common/types/action_types.ts b/x-pack/plugins/watcher/common/types/action_types.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/common/types/action_types.ts rename to x-pack/plugins/watcher/common/types/action_types.ts diff --git a/x-pack/legacy/plugins/watcher/common/types/watch_types.ts b/x-pack/plugins/watcher/common/types/watch_types.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/common/types/watch_types.ts rename to x-pack/plugins/watcher/common/types/watch_types.ts diff --git a/x-pack/legacy/plugins/watcher/kibana.json b/x-pack/plugins/watcher/kibana.json similarity index 69% rename from x-pack/legacy/plugins/watcher/kibana.json rename to x-pack/plugins/watcher/kibana.json index ccec8a1b77683..0816ab05b4e34 100644 --- a/x-pack/legacy/plugins/watcher/kibana.json +++ b/x-pack/plugins/watcher/kibana.json @@ -2,7 +2,9 @@ "id": "watcher", "version": "kibana", "requiredPlugins": [ - "home" + "home", + "licensing", + "management" ], "server": true, "ui": true diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/app.tsx b/x-pack/plugins/watcher/public/application/app.tsx similarity index 96% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/app.tsx rename to x-pack/plugins/watcher/public/application/app.tsx index 36fa1cce9d6dd..8cb29a4fc035e 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/app.tsx +++ b/x-pack/plugins/watcher/public/application/app.tsx @@ -11,7 +11,7 @@ import { HttpSetup, ToastsSetup, IUiSettingsClient, -} from 'src/core/public'; +} from 'kibana/public'; import { EuiCallOut, EuiLink } from '@elastic/eui'; import { @@ -28,7 +28,7 @@ import { WatchEdit } from './sections/watch_edit/components/watch_edit'; import { WatchList } from './sections/watch_list/components/watch_list'; import { registerRouter } from './lib/navigation'; import { BASE_PATH } from './constants'; -import { LICENSE_STATUS_VALID } from '../../../../../common/constants'; +import { LICENSE_STATUS_VALID } from '../../../../legacy/common/constants'; import { AppContextProvider } from './app_context'; import { LegacyDependencies } from '../types'; diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/app_context.tsx b/x-pack/plugins/watcher/public/application/app_context.tsx similarity index 94% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/app_context.tsx rename to x-pack/plugins/watcher/public/application/app_context.tsx index 5696ab3cb91ba..e5cf4c33b477a 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/app_context.tsx +++ b/x-pack/plugins/watcher/public/application/app_context.tsx @@ -5,8 +5,8 @@ */ import React, { createContext, useContext } from 'react'; -import { DocLinksStart } from 'src/core/public'; -import { ACTION_TYPES } from '../../../common/constants'; +import { DocLinksStart } from 'kibana/public'; +import { ACTION_TYPES } from '../../common/constants'; import { AppDeps } from './app'; interface ContextValue extends Omit { diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/boot.tsx b/x-pack/plugins/watcher/public/application/boot.tsx similarity index 94% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/boot.tsx rename to x-pack/plugins/watcher/public/application/boot.tsx index 3f2a10f004649..2e9421af242b9 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/boot.tsx +++ b/x-pack/plugins/watcher/public/application/boot.tsx @@ -6,7 +6,7 @@ import React from 'react'; import { render, unmountComponentAtNode } from 'react-dom'; -import { SavedObjectsClientContract } from 'src/core/public'; +import { SavedObjectsClientContract } from 'kibana/public'; import { App, AppDeps } from './app'; import { setHttpClient, setSavedObjectsClient } from './lib/api'; diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/components/confirm_watches_modal.tsx b/x-pack/plugins/watcher/public/application/components/confirm_watches_modal.tsx similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/components/confirm_watches_modal.tsx rename to x-pack/plugins/watcher/public/application/components/confirm_watches_modal.tsx diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/components/delete_watches_modal.tsx b/x-pack/plugins/watcher/public/application/components/delete_watches_modal.tsx similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/components/delete_watches_modal.tsx rename to x-pack/plugins/watcher/public/application/components/delete_watches_modal.tsx diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/components/form_errors.tsx b/x-pack/plugins/watcher/public/application/components/form_errors.tsx similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/components/form_errors.tsx rename to x-pack/plugins/watcher/public/application/components/form_errors.tsx diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/components/index.ts b/x-pack/plugins/watcher/public/application/components/index.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/components/index.ts rename to x-pack/plugins/watcher/public/application/components/index.ts diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/components/page_error/index.ts b/x-pack/plugins/watcher/public/application/components/page_error/index.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/components/page_error/index.ts rename to x-pack/plugins/watcher/public/application/components/page_error/index.ts diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/components/page_error/page_error.tsx b/x-pack/plugins/watcher/public/application/components/page_error/page_error.tsx similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/components/page_error/page_error.tsx rename to x-pack/plugins/watcher/public/application/components/page_error/page_error.tsx diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/components/page_error/page_error_forbidden.tsx b/x-pack/plugins/watcher/public/application/components/page_error/page_error_forbidden.tsx similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/components/page_error/page_error_forbidden.tsx rename to x-pack/plugins/watcher/public/application/components/page_error/page_error_forbidden.tsx diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/components/page_error/page_error_not_exist.tsx b/x-pack/plugins/watcher/public/application/components/page_error/page_error_not_exist.tsx similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/components/page_error/page_error_not_exist.tsx rename to x-pack/plugins/watcher/public/application/components/page_error/page_error_not_exist.tsx diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/components/section_error.tsx b/x-pack/plugins/watcher/public/application/components/section_error.tsx similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/components/section_error.tsx rename to x-pack/plugins/watcher/public/application/components/section_error.tsx diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/components/section_loading.tsx b/x-pack/plugins/watcher/public/application/components/section_loading.tsx similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/components/section_loading.tsx rename to x-pack/plugins/watcher/public/application/components/section_loading.tsx diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/components/watch_status.tsx b/x-pack/plugins/watcher/public/application/components/watch_status.tsx similarity index 95% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/components/watch_status.tsx rename to x-pack/plugins/watcher/public/application/components/watch_status.tsx index 8afd174f8561e..4e42a7eac5a9e 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/components/watch_status.tsx +++ b/x-pack/plugins/watcher/public/application/components/watch_status.tsx @@ -6,7 +6,7 @@ import React from 'react'; import { EuiIcon, EuiFlexGroup, EuiFlexItem, EuiText } from '@elastic/eui'; -import { ACTION_STATES, WATCH_STATES } from '../../../../common/constants'; +import { ACTION_STATES, WATCH_STATES } from '../../../common/constants'; function StatusIcon({ status }: { status: string }) { switch (status) { diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/constants/base_path.ts b/x-pack/plugins/watcher/public/application/constants/base_path.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/constants/base_path.ts rename to x-pack/plugins/watcher/public/application/constants/base_path.ts diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/constants/index.ts b/x-pack/plugins/watcher/public/application/constants/index.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/constants/index.ts rename to x-pack/plugins/watcher/public/application/constants/index.ts diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/index.scss b/x-pack/plugins/watcher/public/application/index.scss similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/index.scss rename to x-pack/plugins/watcher/public/application/index.scss diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/lib/api.ts b/x-pack/plugins/watcher/public/application/lib/api.ts similarity index 96% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/lib/api.ts rename to x-pack/plugins/watcher/public/application/lib/api.ts index c08545904e351..bf97e4b991ca8 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/lib/api.ts +++ b/x-pack/plugins/watcher/public/application/lib/api.ts @@ -3,16 +3,16 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { HttpSetup, SavedObjectsClientContract } from 'src/core/public'; +import { HttpSetup, SavedObjectsClientContract } from 'kibana/public'; import { Settings } from 'plugins/watcher/np_ready/application/models/settings'; import { Watch } from 'plugins/watcher/np_ready/application/models/watch'; import { WatchHistoryItem } from 'plugins/watcher/np_ready/application/models/watch_history_item'; import { WatchStatus } from 'plugins/watcher/np_ready/application/models/watch_status'; -import { BaseWatch, ExecutedWatchDetails } from '../../../../common/types/watch_types'; +import { BaseWatch, ExecutedWatchDetails } from '../../../common/types/watch_types'; import { useRequest, sendRequest } from './use_request'; -import { ROUTES } from '../../../../common/constants'; +import { ROUTES } from '../../../common/constants'; let httpClient: HttpSetup; diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/lib/breadcrumbs.ts b/x-pack/plugins/watcher/public/application/lib/breadcrumbs.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/lib/breadcrumbs.ts rename to x-pack/plugins/watcher/public/application/lib/breadcrumbs.ts diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/lib/format_date.ts b/x-pack/plugins/watcher/public/application/lib/format_date.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/lib/format_date.ts rename to x-pack/plugins/watcher/public/application/lib/format_date.ts diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/lib/get_search_value.ts b/x-pack/plugins/watcher/public/application/lib/get_search_value.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/lib/get_search_value.ts rename to x-pack/plugins/watcher/public/application/lib/get_search_value.ts diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/lib/get_time_unit_label.ts b/x-pack/plugins/watcher/public/application/lib/get_time_unit_label.ts similarity index 95% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/lib/get_time_unit_label.ts rename to x-pack/plugins/watcher/public/application/lib/get_time_unit_label.ts index ce3b96ac17def..5cb78b61488b7 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/lib/get_time_unit_label.ts +++ b/x-pack/plugins/watcher/public/application/lib/get_time_unit_label.ts @@ -5,7 +5,7 @@ */ import { i18n } from '@kbn/i18n'; -import { TIME_UNITS } from '../../../../common/constants'; +import { TIME_UNITS } from '../../../common/constants'; export function getTimeUnitLabel(timeUnit = TIME_UNITS.SECOND, timeValue = '0') { switch (timeUnit) { diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/lib/navigation.ts b/x-pack/plugins/watcher/public/application/lib/navigation.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/lib/navigation.ts rename to x-pack/plugins/watcher/public/application/lib/navigation.ts diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/lib/use_request.ts b/x-pack/plugins/watcher/public/application/lib/use_request.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/lib/use_request.ts rename to x-pack/plugins/watcher/public/application/lib/use_request.ts diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/action/action.js b/x-pack/plugins/watcher/public/application/models/action/action.js similarity index 95% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/action/action.js rename to x-pack/plugins/watcher/public/application/models/action/action.js index 5d5c44d7ae534..43874c9ee1dd1 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/action/action.js +++ b/x-pack/plugins/watcher/public/application/models/action/action.js @@ -5,7 +5,7 @@ */ import { get, set } from 'lodash'; -import { ACTION_TYPES } from '../../../../../common/constants'; +import { ACTION_TYPES } from '../../../../common/constants'; import { EmailAction } from './email_action'; import { LoggingAction } from './logging_action'; import { SlackAction } from './slack_action'; diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/action/base_action.js b/x-pack/plugins/watcher/public/application/models/action/base_action.js similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/action/base_action.js rename to x-pack/plugins/watcher/public/application/models/action/base_action.js diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/action/email_action.js b/x-pack/plugins/watcher/public/application/models/action/email_action.js similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/action/email_action.js rename to x-pack/plugins/watcher/public/application/models/action/email_action.js diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/action/index.js b/x-pack/plugins/watcher/public/application/models/action/index.js similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/action/index.js rename to x-pack/plugins/watcher/public/application/models/action/index.js diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/action/index_action.js b/x-pack/plugins/watcher/public/application/models/action/index_action.js similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/action/index_action.js rename to x-pack/plugins/watcher/public/application/models/action/index_action.js diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/action/jira_action.js b/x-pack/plugins/watcher/public/application/models/action/jira_action.js similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/action/jira_action.js rename to x-pack/plugins/watcher/public/application/models/action/jira_action.js diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/action/logging_action.js b/x-pack/plugins/watcher/public/application/models/action/logging_action.js similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/action/logging_action.js rename to x-pack/plugins/watcher/public/application/models/action/logging_action.js diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/action/pagerduty_action.js b/x-pack/plugins/watcher/public/application/models/action/pagerduty_action.js similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/action/pagerduty_action.js rename to x-pack/plugins/watcher/public/application/models/action/pagerduty_action.js diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/action/slack_action.js b/x-pack/plugins/watcher/public/application/models/action/slack_action.js similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/action/slack_action.js rename to x-pack/plugins/watcher/public/application/models/action/slack_action.js diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/action/unknown_action.js b/x-pack/plugins/watcher/public/application/models/action/unknown_action.js similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/action/unknown_action.js rename to x-pack/plugins/watcher/public/application/models/action/unknown_action.js diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/action/webhook_action.js b/x-pack/plugins/watcher/public/application/models/action/webhook_action.js similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/action/webhook_action.js rename to x-pack/plugins/watcher/public/application/models/action/webhook_action.js diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/action_status/action_status.js b/x-pack/plugins/watcher/public/application/models/action_status/action_status.js similarity index 95% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/action_status/action_status.js rename to x-pack/plugins/watcher/public/application/models/action_status/action_status.js index b177eb5bb2291..f38fa23b68f5a 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/action_status/action_status.js +++ b/x-pack/plugins/watcher/public/application/models/action_status/action_status.js @@ -5,7 +5,7 @@ */ import { get } from 'lodash'; -import { getMoment } from '../../../../../common/lib/get_moment'; +import { getMoment } from '../../../../common/lib/get_moment'; export class ActionStatus { constructor(props = {}) { diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/action_status/index.js b/x-pack/plugins/watcher/public/application/models/action_status/index.js similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/action_status/index.js rename to x-pack/plugins/watcher/public/application/models/action_status/index.js diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/execute_details/execute_details.js b/x-pack/plugins/watcher/public/application/models/execute_details/execute_details.js similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/execute_details/execute_details.js rename to x-pack/plugins/watcher/public/application/models/execute_details/execute_details.js diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/execute_details/index.js b/x-pack/plugins/watcher/public/application/models/execute_details/index.js similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/execute_details/index.js rename to x-pack/plugins/watcher/public/application/models/execute_details/index.js diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/index.d.ts b/x-pack/plugins/watcher/public/application/models/index.d.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/index.d.ts rename to x-pack/plugins/watcher/public/application/models/index.d.ts diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/settings/index.js b/x-pack/plugins/watcher/public/application/models/settings/index.js similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/settings/index.js rename to x-pack/plugins/watcher/public/application/models/settings/index.js diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/settings/settings.js b/x-pack/plugins/watcher/public/application/models/settings/settings.js similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/settings/settings.js rename to x-pack/plugins/watcher/public/application/models/settings/settings.js diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/visualize_options/index.js b/x-pack/plugins/watcher/public/application/models/visualize_options/index.js similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/visualize_options/index.js rename to x-pack/plugins/watcher/public/application/models/visualize_options/index.js diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/visualize_options/visualize_options.js b/x-pack/plugins/watcher/public/application/models/visualize_options/visualize_options.js similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/visualize_options/visualize_options.js rename to x-pack/plugins/watcher/public/application/models/visualize_options/visualize_options.js diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/agg_types.ts b/x-pack/plugins/watcher/public/application/models/watch/agg_types.ts similarity index 94% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/agg_types.ts rename to x-pack/plugins/watcher/public/application/models/watch/agg_types.ts index cefaaa3b1abd3..d2b1ddebf12a2 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/agg_types.ts +++ b/x-pack/plugins/watcher/public/application/models/watch/agg_types.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { AGG_TYPES } from '../../../../../common/constants'; +import { AGG_TYPES } from '../../../../common/constants'; export interface AggType { text: string; diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/base_watch.js b/x-pack/plugins/watcher/public/application/models/watch/base_watch.js similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/base_watch.js rename to x-pack/plugins/watcher/public/application/models/watch/base_watch.js diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/comparators.ts b/x-pack/plugins/watcher/public/application/models/watch/comparators.ts similarity index 96% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/comparators.ts rename to x-pack/plugins/watcher/public/application/models/watch/comparators.ts index edc3a03c25227..96904719098a0 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/comparators.ts +++ b/x-pack/plugins/watcher/public/application/models/watch/comparators.ts @@ -6,7 +6,7 @@ import { i18n } from '@kbn/i18n'; -import { COMPARATORS } from '../../../../../common/constants'; +import { COMPARATORS } from '../../../../common/constants'; export interface Comparator { text: string; diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/default_watch.json b/x-pack/plugins/watcher/public/application/models/watch/default_watch.json similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/default_watch.json rename to x-pack/plugins/watcher/public/application/models/watch/default_watch.json diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/group_by_types.ts b/x-pack/plugins/watcher/public/application/models/watch/group_by_types.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/group_by_types.ts rename to x-pack/plugins/watcher/public/application/models/watch/group_by_types.ts diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/index.js b/x-pack/plugins/watcher/public/application/models/watch/index.js similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/index.js rename to x-pack/plugins/watcher/public/application/models/watch/index.js diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/json_watch.js b/x-pack/plugins/watcher/public/application/models/watch/json_watch.js similarity index 98% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/json_watch.js rename to x-pack/plugins/watcher/public/application/models/watch/json_watch.js index 2d18c233ed5b4..19d016fcc48eb 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/json_watch.js +++ b/x-pack/plugins/watcher/public/application/models/watch/json_watch.js @@ -7,7 +7,7 @@ import uuid from 'uuid'; import { get } from 'lodash'; import { BaseWatch } from './base_watch'; -import { ACTION_TYPES, WATCH_TYPES } from '../../../../../common/constants'; +import { ACTION_TYPES, WATCH_TYPES } from '../../../../common/constants'; import defaultWatchJson from './default_watch.json'; import { i18n } from '@kbn/i18n'; diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/lib/check_action_id_collision/check_action_id_collision.js b/x-pack/plugins/watcher/public/application/models/watch/lib/check_action_id_collision/check_action_id_collision.js similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/lib/check_action_id_collision/check_action_id_collision.js rename to x-pack/plugins/watcher/public/application/models/watch/lib/check_action_id_collision/check_action_id_collision.js diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/lib/check_action_id_collision/index.js b/x-pack/plugins/watcher/public/application/models/watch/lib/check_action_id_collision/index.js similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/lib/check_action_id_collision/index.js rename to x-pack/plugins/watcher/public/application/models/watch/lib/check_action_id_collision/index.js diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/lib/create_action_id/create_action_id.js b/x-pack/plugins/watcher/public/application/models/watch/lib/create_action_id/create_action_id.js similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/lib/create_action_id/create_action_id.js rename to x-pack/plugins/watcher/public/application/models/watch/lib/create_action_id/create_action_id.js diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/lib/create_action_id/index.js b/x-pack/plugins/watcher/public/application/models/watch/lib/create_action_id/index.js similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/lib/create_action_id/index.js rename to x-pack/plugins/watcher/public/application/models/watch/lib/create_action_id/index.js diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/monitoring_watch.js b/x-pack/plugins/watcher/public/application/models/watch/monitoring_watch.js similarity index 92% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/monitoring_watch.js rename to x-pack/plugins/watcher/public/application/models/watch/monitoring_watch.js index 850953ebd963e..82cdffc79edc4 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/monitoring_watch.js +++ b/x-pack/plugins/watcher/public/application/models/watch/monitoring_watch.js @@ -5,7 +5,7 @@ */ import { BaseWatch } from './base_watch'; -import { WATCH_TYPES } from '../../../../../common/constants'; +import { WATCH_TYPES } from '../../../../common/constants'; /** * {@code MonitoringWatch} system defined watches created by the Monitoring plugin. diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/threshold_watch.js b/x-pack/plugins/watcher/public/application/models/watch/threshold_watch.js similarity index 99% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/threshold_watch.js rename to x-pack/plugins/watcher/public/application/models/watch/threshold_watch.js index 2383388dd89bf..c9db4237942b0 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/threshold_watch.js +++ b/x-pack/plugins/watcher/public/application/models/watch/threshold_watch.js @@ -6,7 +6,7 @@ import { BaseWatch } from './base_watch'; import uuid from 'uuid'; -import { WATCH_TYPES, SORT_ORDERS, COMPARATORS } from '../../../../../common/constants'; +import { WATCH_TYPES, SORT_ORDERS, COMPARATORS } from '../../../../common/constants'; import { getTimeUnitLabel } from '../../lib/get_time_unit_label'; import { i18n } from '@kbn/i18n'; import { aggTypes } from './agg_types'; diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/watch.js b/x-pack/plugins/watcher/public/application/models/watch/watch.js similarity index 93% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/watch.js rename to x-pack/plugins/watcher/public/application/models/watch/watch.js index fc33fab56d07c..934d1e338ed0c 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch/watch.js +++ b/x-pack/plugins/watcher/public/application/models/watch/watch.js @@ -5,7 +5,7 @@ */ import { get, set } from 'lodash'; -import { WATCH_TYPES } from '../../../../../common/constants'; +import { WATCH_TYPES } from '../../../../common/constants'; import { JsonWatch } from './json_watch'; import { ThresholdWatch } from './threshold_watch'; import { MonitoringWatch } from './monitoring_watch'; diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch_errors/index.js b/x-pack/plugins/watcher/public/application/models/watch_errors/index.js similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch_errors/index.js rename to x-pack/plugins/watcher/public/application/models/watch_errors/index.js diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch_errors/watch_errors.js b/x-pack/plugins/watcher/public/application/models/watch_errors/watch_errors.js similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch_errors/watch_errors.js rename to x-pack/plugins/watcher/public/application/models/watch_errors/watch_errors.js diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch_history_item/index.js b/x-pack/plugins/watcher/public/application/models/watch_history_item/index.js similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch_history_item/index.js rename to x-pack/plugins/watcher/public/application/models/watch_history_item/index.js diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch_history_item/watch_history_item.js b/x-pack/plugins/watcher/public/application/models/watch_history_item/watch_history_item.js similarity index 91% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch_history_item/watch_history_item.js rename to x-pack/plugins/watcher/public/application/models/watch_history_item/watch_history_item.js index 785f9d19b23dd..36fa9fa5aefe2 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch_history_item/watch_history_item.js +++ b/x-pack/plugins/watcher/public/application/models/watch_history_item/watch_history_item.js @@ -6,7 +6,7 @@ import 'moment-duration-format'; import { get } from 'lodash'; -import { getMoment } from '../../../../../common/lib/get_moment'; +import { getMoment } from '../../../../common/lib/get_moment'; import { WatchStatus } from '../watch_status'; export class WatchHistoryItem { diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch_status/index.js b/x-pack/plugins/watcher/public/application/models/watch_status/index.js similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch_status/index.js rename to x-pack/plugins/watcher/public/application/models/watch_status/index.js diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch_status/watch_status.js b/x-pack/plugins/watcher/public/application/models/watch_status/watch_status.js similarity index 94% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch_status/watch_status.js rename to x-pack/plugins/watcher/public/application/models/watch_status/watch_status.js index 7b35493ebdfa2..8cbdc1b5b30cc 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/models/watch_status/watch_status.js +++ b/x-pack/plugins/watcher/public/application/models/watch_status/watch_status.js @@ -5,7 +5,7 @@ */ import { get } from 'lodash'; -import { getMoment } from '../../../../../common/lib/get_moment'; +import { getMoment } from '../../../../common/lib/get_moment'; import { ActionStatus } from '../action_status'; export class WatchStatus { diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/json_watch_edit/index.ts b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/json_watch_edit/index.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/json_watch_edit/index.ts rename to x-pack/plugins/watcher/public/application/sections/watch_edit/components/json_watch_edit/index.ts diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/json_watch_edit/json_watch_edit.tsx b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/json_watch_edit/json_watch_edit.tsx similarity index 95% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/json_watch_edit/json_watch_edit.tsx rename to x-pack/plugins/watcher/public/application/sections/watch_edit/components/json_watch_edit/json_watch_edit.tsx index 010e430c0719a..aac51021bad3f 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/json_watch_edit/json_watch_edit.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/json_watch_edit/json_watch_edit.tsx @@ -17,9 +17,9 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { ExecuteDetails } from 'plugins/watcher/np_ready/application/models/execute_details/execute_details'; -import { getActionType } from '../../../../../../../common/lib/get_action_type'; -import { BaseWatch, ExecutedWatchDetails } from '../../../../../../../common/types/watch_types'; -import { ACTION_MODES, TIME_UNITS } from '../../../../../../../common/constants'; +import { getActionType } from '../../../../../../common/lib/get_action_type'; +import { BaseWatch, ExecutedWatchDetails } from '../../../../../../common/types/watch_types'; +import { ACTION_MODES, TIME_UNITS } from '../../../../../../common/constants'; import { JsonWatchEditForm } from './json_watch_edit_form'; import { JsonWatchEditSimulate } from './json_watch_edit_simulate'; import { WatchContext } from '../../watch_context'; diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/json_watch_edit/json_watch_edit_form.tsx b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/json_watch_edit/json_watch_edit_form.tsx similarity index 99% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/json_watch_edit/json_watch_edit_form.tsx rename to x-pack/plugins/watcher/public/application/sections/watch_edit/components/json_watch_edit/json_watch_edit_form.tsx index 376aeb205b855..91185ac604b34 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/json_watch_edit/json_watch_edit_form.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/json_watch_edit/json_watch_edit_form.tsx @@ -20,7 +20,7 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import { serializeJsonWatch } from '../../../../../../../common/lib/serialization'; +import { serializeJsonWatch } from '../../../../../../common/lib/serialization'; import { ErrableFormRow, SectionError, Error as ServerError } from '../../../../components'; import { onWatchSave } from '../../watch_edit_actions'; import { WatchContext } from '../../watch_context'; diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/json_watch_edit/json_watch_edit_simulate.tsx b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/json_watch_edit/json_watch_edit_simulate.tsx similarity index 99% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/json_watch_edit/json_watch_edit_simulate.tsx rename to x-pack/plugins/watcher/public/application/sections/watch_edit/components/json_watch_edit/json_watch_edit_simulate.tsx index 9ea2b3bcd1e9a..5a1cc62639ea0 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/json_watch_edit/json_watch_edit_simulate.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/json_watch_edit/json_watch_edit_simulate.tsx @@ -26,11 +26,11 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { ExecuteDetails } from 'plugins/watcher/np_ready/application/models/execute_details/execute_details'; import { WatchHistoryItem } from 'plugins/watcher/np_ready/application/models/watch_history_item'; -import { ACTION_MODES, TIME_UNITS } from '../../../../../../../common/constants'; +import { ACTION_MODES, TIME_UNITS } from '../../../../../../common/constants'; import { ExecutedWatchDetails, ExecutedWatchResults, -} from '../../../../../../../common/types/watch_types'; +} from '../../../../../../common/types/watch_types'; import { ErrableFormRow } from '../../../../components/form_errors'; import { executeWatch } from '../../../../lib/api'; import { WatchContext } from '../../watch_context'; diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/json_watch_edit/json_watch_edit_simulate_results.tsx b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/json_watch_edit/json_watch_edit_simulate_results.tsx similarity index 99% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/json_watch_edit/json_watch_edit_simulate_results.tsx rename to x-pack/plugins/watcher/public/application/sections/watch_edit/components/json_watch_edit/json_watch_edit_simulate_results.tsx index c3f11c6c3fa46..0a61e4401fdf1 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/json_watch_edit/json_watch_edit_simulate_results.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/json_watch_edit/json_watch_edit_simulate_results.tsx @@ -21,7 +21,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { ExecutedWatchDetails, ExecutedWatchResults, -} from '../../../../../../../common/types/watch_types'; +} from '../../../../../../common/types/watch_types'; import { getTypeFromAction } from '../../watch_edit_actions'; import { WatchContext } from '../../watch_context'; import { WatchStatus, SectionError } from '../../../../components'; diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/monitoring_watch_edit/index.ts b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/monitoring_watch_edit/index.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/monitoring_watch_edit/index.ts rename to x-pack/plugins/watcher/public/application/sections/watch_edit/components/monitoring_watch_edit/index.ts diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/monitoring_watch_edit/monitoring_watch_edit.tsx b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/monitoring_watch_edit/monitoring_watch_edit.tsx similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/monitoring_watch_edit/monitoring_watch_edit.tsx rename to x-pack/plugins/watcher/public/application/sections/watch_edit/components/monitoring_watch_edit/monitoring_watch_edit.tsx diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/request_flyout.tsx b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/request_flyout.tsx similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/request_flyout.tsx rename to x-pack/plugins/watcher/public/application/sections/watch_edit/components/request_flyout.tsx diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/action_fields/email_action_fields.tsx b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/action_fields/email_action_fields.tsx similarity index 97% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/action_fields/email_action_fields.tsx rename to x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/action_fields/email_action_fields.tsx index 3e70e49f42350..a94055271ff5b 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/action_fields/email_action_fields.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/action_fields/email_action_fields.tsx @@ -8,7 +8,7 @@ import React, { Fragment } from 'react'; import { EuiComboBox, EuiFieldText, EuiFormRow, EuiTextArea } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { ErrableFormRow } from '../../../../../components/form_errors'; -import { EmailAction } from '../../../../../../../../common/types/action_types'; +import { EmailAction } from '../../../../../../../common/types/action_types'; interface Props { action: EmailAction; diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/action_fields/index.ts b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/action_fields/index.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/action_fields/index.ts rename to x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/action_fields/index.ts diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/action_fields/index_action_fields.tsx b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/action_fields/index_action_fields.tsx similarity index 94% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/action_fields/index_action_fields.tsx rename to x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/action_fields/index_action_fields.tsx index b7ab76d9890bc..f1d36bce415d3 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/action_fields/index_action_fields.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/action_fields/index_action_fields.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { EuiFieldText } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { ErrableFormRow } from '../../../../../components/form_errors'; -import { IndexAction } from '../../../../../../../../common/types/action_types'; +import { IndexAction } from '../../../../../../../common/types/action_types'; interface Props { action: IndexAction; diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/action_fields/jira_action_fields.tsx b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/action_fields/jira_action_fields.tsx similarity index 97% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/action_fields/jira_action_fields.tsx rename to x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/action_fields/jira_action_fields.tsx index c09b3c44fde65..2bfc4f2eb1b5d 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/action_fields/jira_action_fields.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/action_fields/jira_action_fields.tsx @@ -8,7 +8,7 @@ import React, { Fragment } from 'react'; import { EuiFieldText } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { ErrableFormRow } from '../../../../../components/form_errors'; -import { JiraAction } from '../../../../../../../../common/types/action_types'; +import { JiraAction } from '../../../../../../../common/types/action_types'; interface Props { action: JiraAction; diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/action_fields/logging_action_fields.tsx b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/action_fields/logging_action_fields.tsx similarity index 94% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/action_fields/logging_action_fields.tsx rename to x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/action_fields/logging_action_fields.tsx index 7da2a22ecd6c4..17c69a7b05bb3 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/action_fields/logging_action_fields.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/action_fields/logging_action_fields.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { EuiFieldText } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { ErrableFormRow } from '../../../../../components/form_errors'; -import { LoggingAction } from '../../../../../../../../common/types/action_types'; +import { LoggingAction } from '../../../../../../../common/types/action_types'; interface Props { action: LoggingAction; diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/action_fields/pagerduty_action_fields.tsx b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/action_fields/pagerduty_action_fields.tsx similarity index 95% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/action_fields/pagerduty_action_fields.tsx rename to x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/action_fields/pagerduty_action_fields.tsx index 3287bdefa08aa..95215e8eac763 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/action_fields/pagerduty_action_fields.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/action_fields/pagerduty_action_fields.tsx @@ -7,7 +7,7 @@ import React, { Fragment } from 'react'; import { EuiFieldText } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { ErrableFormRow } from '../../../../../components/form_errors'; -import { PagerDutyAction } from '../../../../../../../../common/types/action_types'; +import { PagerDutyAction } from '../../../../../../../common/types/action_types'; interface Props { action: PagerDutyAction; diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/action_fields/slack_action_fields.tsx b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/action_fields/slack_action_fields.tsx similarity index 96% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/action_fields/slack_action_fields.tsx rename to x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/action_fields/slack_action_fields.tsx index a72cf232d8d09..5e8aaf8415898 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/action_fields/slack_action_fields.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/action_fields/slack_action_fields.tsx @@ -6,7 +6,7 @@ import React, { Fragment } from 'react'; import { EuiComboBox, EuiTextArea, EuiFormRow } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { SlackAction } from '../../../../../../../../common/types/action_types'; +import { SlackAction } from '../../../../../../../common/types/action_types'; interface Props { action: SlackAction; diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/action_fields/webhook_action_fields.tsx b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/action_fields/webhook_action_fields.tsx similarity index 98% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/action_fields/webhook_action_fields.tsx rename to x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/action_fields/webhook_action_fields.tsx index be0b551f4a39c..c1ebcdc262863 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/action_fields/webhook_action_fields.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/action_fields/webhook_action_fields.tsx @@ -18,7 +18,7 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { ErrableFormRow } from '../../../../../components/form_errors'; -import { WebhookAction } from '../../../../../../../../common/types/action_types'; +import { WebhookAction } from '../../../../../../../common/types/action_types'; interface Props { action: WebhookAction; diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/index.ts b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/index.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/index.ts rename to x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/index.ts diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_action_accordion.tsx b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_action_accordion.tsx similarity index 98% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_action_accordion.tsx rename to x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_action_accordion.tsx index 4fca772a18217..5cc5477dfb133 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_action_accordion.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_action_accordion.tsx @@ -25,8 +25,8 @@ import { ExecuteDetails } from 'plugins/watcher/np_ready/application/models/exec import { Action } from 'plugins/watcher/np_ready/application/models/action'; import { WatchHistoryItem } from 'plugins/watcher/np_ready/application/models/watch_history_item'; import { ThresholdWatch } from 'plugins/watcher/np_ready/application/models/watch/threshold_watch'; -import { ActionType } from '../../../../../../../common/types/action_types'; -import { ACTION_TYPES, ACTION_MODES } from '../../../../../../../common/constants'; +import { ActionType } from '../../../../../../common/types/action_types'; +import { ACTION_TYPES, ACTION_MODES } from '../../../../../../common/constants'; import { WatchContext } from '../../watch_context'; import { WebhookActionFields, diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_action_dropdown.tsx b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_action_dropdown.tsx similarity index 98% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_action_dropdown.tsx rename to x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_action_dropdown.tsx index d92cccfa00f14..a48ce7865a4f0 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_action_dropdown.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_action_dropdown.tsx @@ -18,7 +18,7 @@ import { i18n } from '@kbn/i18n'; import React, { useContext, useState } from 'react'; import { Action } from 'plugins/watcher/np_ready/application/models/action'; import { FormattedMessage } from '@kbn/i18n/react'; -import { ACTION_TYPES } from '../../../../../../../common/constants'; +import { ACTION_TYPES } from '../../../../../../common/constants'; import { WatchContext } from '../../watch_context'; const disabledMessage = i18n.translate( diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_action_panel.tsx b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_action_panel.tsx similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_action_panel.tsx rename to x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_action_panel.tsx diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_edit.tsx b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_edit.tsx similarity index 99% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_edit.tsx rename to x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_edit.tsx index f1b5d2c9eab7b..e3d729c33fddf 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_edit.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_edit.tsx @@ -26,8 +26,8 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import { TIME_UNITS } from '../../../../../../../common/constants'; -import { serializeThresholdWatch } from '../../../../../../../common/lib/serialization'; +import { TIME_UNITS } from '../../../../../../common/constants'; +import { serializeThresholdWatch } from '../../../../../../common/lib/serialization'; import { ErrableFormRow, SectionError, Error as ServerError } from '../../../../components'; import { fetchFields, getMatchingIndices, loadIndexPatterns } from '../../../../lib/api'; import { aggTypes } from '../../../../models/watch/agg_types'; diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/watch_visualization.tsx b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/watch_visualization.tsx similarity index 99% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/watch_visualization.tsx rename to x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/watch_visualization.tsx index 3901f84f506ef..84bb8546fad17 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/threshold_watch_edit/watch_visualization.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/watch_visualization.tsx @@ -17,7 +17,7 @@ import { } from '@elastic/charts'; import dateMath from '@elastic/datemath'; import moment from 'moment-timezone'; -import { IUiSettingsClient } from 'src/core/public'; +import { IUiSettingsClient } from 'kibana/public'; import { EuiCallOut, EuiLoadingChart, EuiSpacer, EuiEmptyPrompt, EuiText } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { VisualizeOptions } from 'plugins/watcher/np_ready/application/models/visualize_options'; diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/watch_edit.tsx b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/watch_edit.tsx similarity index 97% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/watch_edit.tsx rename to x-pack/plugins/watcher/public/application/sections/watch_edit/components/watch_edit.tsx index 9f252d3e542e0..3410414c48eac 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/components/watch_edit.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/watch_edit.tsx @@ -12,8 +12,8 @@ import { i18n } from '@kbn/i18n'; import { Watch } from 'plugins/watcher/np_ready/application/models/watch'; import { FormattedMessage } from '@kbn/i18n/react'; -import { WATCH_TYPES } from '../../../../../../common/constants'; -import { BaseWatch } from '../../../../../../common/types/watch_types'; +import { WATCH_TYPES } from '../../../../../common/constants'; +import { BaseWatch } from '../../../../../common/types/watch_types'; import { getPageErrorCode, PageError, SectionLoading, SectionError } from '../../../components'; import { loadWatch } from '../../../lib/api'; import { listBreadcrumb, editBreadcrumb, createBreadcrumb } from '../../../lib/breadcrumbs'; diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/watch_context.ts b/x-pack/plugins/watcher/public/application/sections/watch_edit/watch_context.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/watch_context.ts rename to x-pack/plugins/watcher/public/application/sections/watch_edit/watch_context.ts diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/watch_edit_actions.ts b/x-pack/plugins/watcher/public/application/sections/watch_edit/watch_edit_actions.ts similarity index 95% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/watch_edit_actions.ts rename to x-pack/plugins/watcher/public/application/sections/watch_edit/watch_edit_actions.ts index b93c2c510047d..ba2a3a7ce84e5 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_edit/watch_edit_actions.ts +++ b/x-pack/plugins/watcher/public/application/sections/watch_edit/watch_edit_actions.ts @@ -4,11 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ -import { ToastsSetup } from 'src/core/public'; +import { ToastsSetup } from 'kibana/public'; import { i18n } from '@kbn/i18n'; import { get } from 'lodash'; -import { ACTION_TYPES, WATCH_TYPES } from '../../../../../common/constants'; -import { BaseWatch } from '../../../../../common/types/watch_types'; +import { ACTION_TYPES, WATCH_TYPES } from '../../../../common/constants'; +import { BaseWatch } from '../../../../common/types/watch_types'; import { createWatch } from '../../lib/api'; import { goToWatchList } from '../../lib/navigation'; diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_list/components/watch_list.tsx b/x-pack/plugins/watcher/public/application/sections/watch_list/components/watch_list.tsx similarity index 99% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_list/components/watch_list.tsx rename to x-pack/plugins/watcher/public/application/sections/watch_list/components/watch_list.tsx index 5165915aa8406..011bc3d8a8fbb 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_list/components/watch_list.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_list/components/watch_list.tsx @@ -28,7 +28,7 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { Moment } from 'moment'; -import { REFRESH_INTERVALS, PAGINATION, WATCH_TYPES } from '../../../../../../common/constants'; +import { REFRESH_INTERVALS, PAGINATION, WATCH_TYPES } from '../../../../../common/constants'; import { listBreadcrumb } from '../../../lib/breadcrumbs'; import { getPageErrorCode, diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_status/components/watch_detail.tsx b/x-pack/plugins/watcher/public/application/sections/watch_status/components/watch_detail.tsx similarity index 99% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_status/components/watch_detail.tsx rename to x-pack/plugins/watcher/public/application/sections/watch_status/components/watch_detail.tsx index 197342bba4180..ce52114fd5fdf 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_status/components/watch_detail.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_status/components/watch_detail.tsx @@ -20,7 +20,7 @@ import { } from '@elastic/eui'; import { ackWatchAction } from '../../../lib/api'; import { WatchStatus } from '../../../components'; -import { PAGINATION } from '../../../../../../common/constants'; +import { PAGINATION } from '../../../../../common/constants'; import { WatchDetailsContext } from '../watch_details_context'; import { useAppContext } from '../../../app_context'; diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_status/components/watch_history.tsx b/x-pack/plugins/watcher/public/application/sections/watch_status/components/watch_history.tsx similarity index 99% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_status/components/watch_history.tsx rename to x-pack/plugins/watcher/public/application/sections/watch_status/components/watch_history.tsx index 16897d74665ef..b78a2e4230171 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_status/components/watch_history.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_status/components/watch_history.tsx @@ -23,7 +23,7 @@ import { EuiTitle, } from '@elastic/eui'; -import { PAGINATION } from '../../../../../../common/constants'; +import { PAGINATION } from '../../../../../common/constants'; import { WatchStatus, SectionError, Error } from '../../../components'; import { useLoadWatchHistory, useLoadWatchHistoryDetail } from '../../../lib/api'; import { WatchDetailsContext } from '../watch_details_context'; diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_status/components/watch_status.tsx b/x-pack/plugins/watcher/public/application/sections/watch_status/components/watch_status.tsx similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_status/components/watch_status.tsx rename to x-pack/plugins/watcher/public/application/sections/watch_status/components/watch_status.tsx diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_status/watch_details_context.ts b/x-pack/plugins/watcher/public/application/sections/watch_status/watch_details_context.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/sections/watch_status/watch_details_context.ts rename to x-pack/plugins/watcher/public/application/sections/watch_status/watch_details_context.ts diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/shared_imports.ts b/x-pack/plugins/watcher/public/application/shared_imports.ts similarity index 79% rename from x-pack/legacy/plugins/watcher/public/np_ready/application/shared_imports.ts rename to x-pack/plugins/watcher/public/application/shared_imports.ts index 60445b00c0985..cbc4dde7448ff 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/application/shared_imports.ts +++ b/x-pack/plugins/watcher/public/application/shared_imports.ts @@ -10,4 +10,4 @@ export { UseRequestConfig, sendRequest, useRequest, -} from '../../../../../../../src/plugins/es_ui_shared/public/request/np_ready_request'; +} from '../../../../../src/plugins/es_ui_shared/public/request/np_ready_request'; diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/index.ts b/x-pack/plugins/watcher/public/index.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/index.ts rename to x-pack/plugins/watcher/public/index.ts diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/plugin.ts b/x-pack/plugins/watcher/public/plugin.ts similarity index 96% rename from x-pack/legacy/plugins/watcher/public/np_ready/plugin.ts rename to x-pack/plugins/watcher/public/plugin.ts index 161de9b5fc060..a1ef85ddb722d 100644 --- a/x-pack/legacy/plugins/watcher/public/np_ready/plugin.ts +++ b/x-pack/plugins/watcher/public/plugin.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Plugin, CoreSetup, CoreStart } from 'src/core/public'; +import { Plugin, CoreSetup, CoreStart } from 'kibana/public'; import { LegacyDependencies } from './types'; diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/types.ts b/x-pack/plugins/watcher/public/types.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/public/np_ready/types.ts rename to x-pack/plugins/watcher/public/types.ts diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/index.ts b/x-pack/plugins/watcher/server/index.ts similarity index 86% rename from x-pack/legacy/plugins/watcher/server/np_ready/index.ts rename to x-pack/plugins/watcher/server/index.ts index 3f5e1a91209ea..d70f61afb3888 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/index.ts +++ b/x-pack/plugins/watcher/server/index.ts @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { PluginInitializerContext } from 'src/core/server'; +import { PluginInitializerContext } from 'kibana/server'; import { WatcherServerPlugin } from './plugin'; export const plugin = (ctx: PluginInitializerContext) => new WatcherServerPlugin(); diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/lib/call_with_request_factory.ts b/x-pack/plugins/watcher/server/lib/call_with_request_factory.ts similarity index 93% rename from x-pack/legacy/plugins/watcher/server/np_ready/lib/call_with_request_factory.ts rename to x-pack/plugins/watcher/server/lib/call_with_request_factory.ts index eaec9cd91b23c..4884c75436c24 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/lib/call_with_request_factory.ts +++ b/x-pack/plugins/watcher/server/lib/call_with_request_factory.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { ElasticsearchServiceSetup } from 'src/core/server'; +import { ElasticsearchServiceSetup } from 'kibana/server'; import { once } from 'lodash'; import { elasticsearchJsPlugin } from './elasticsearch_js_plugin'; diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/lib/elasticsearch_js_plugin.ts b/x-pack/plugins/watcher/server/lib/elasticsearch_js_plugin.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/lib/elasticsearch_js_plugin.ts rename to x-pack/plugins/watcher/server/lib/elasticsearch_js_plugin.ts diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/lib/fetch_all_from_scroll/__tests__/fetch_all_from_scroll.js b/x-pack/plugins/watcher/server/lib/fetch_all_from_scroll/__tests__/fetch_all_from_scroll.js similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/lib/fetch_all_from_scroll/__tests__/fetch_all_from_scroll.js rename to x-pack/plugins/watcher/server/lib/fetch_all_from_scroll/__tests__/fetch_all_from_scroll.js diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/lib/fetch_all_from_scroll/fetch_all_from_scroll.ts b/x-pack/plugins/watcher/server/lib/fetch_all_from_scroll/fetch_all_from_scroll.ts similarity index 92% rename from x-pack/legacy/plugins/watcher/server/np_ready/lib/fetch_all_from_scroll/fetch_all_from_scroll.ts rename to x-pack/plugins/watcher/server/lib/fetch_all_from_scroll/fetch_all_from_scroll.ts index d762b05f01d79..de01bd5965504 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/lib/fetch_all_from_scroll/fetch_all_from_scroll.ts +++ b/x-pack/plugins/watcher/server/lib/fetch_all_from_scroll/fetch_all_from_scroll.ts @@ -5,7 +5,7 @@ */ import { get } from 'lodash'; -import { ES_SCROLL_SETTINGS } from '../../../../common/constants'; +import { ES_SCROLL_SETTINGS } from '../../../common/constants'; export function fetchAllFromScroll(response: any, callWithRequest: any, hits: any[] = []) { const newHits = get(response, 'hits.hits', []); diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/lib/fetch_all_from_scroll/index.ts b/x-pack/plugins/watcher/server/lib/fetch_all_from_scroll/index.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/lib/fetch_all_from_scroll/index.ts rename to x-pack/plugins/watcher/server/lib/fetch_all_from_scroll/index.ts diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/lib/is_es_error/index.ts b/x-pack/plugins/watcher/server/lib/is_es_error/index.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/lib/is_es_error/index.ts rename to x-pack/plugins/watcher/server/lib/is_es_error/index.ts diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/lib/is_es_error/is_es_error.ts b/x-pack/plugins/watcher/server/lib/is_es_error/is_es_error.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/lib/is_es_error/is_es_error.ts rename to x-pack/plugins/watcher/server/lib/is_es_error/is_es_error.ts diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.js b/x-pack/plugins/watcher/server/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.js similarity index 92% rename from x-pack/legacy/plugins/watcher/server/np_ready/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.js rename to x-pack/plugins/watcher/server/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.js index 4a6ad50d6ebc5..c144530ab8724 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.js +++ b/x-pack/plugins/watcher/server/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.js @@ -5,12 +5,12 @@ */ import expect from '@kbn/expect'; -import { kibanaResponseFactory } from '../../../../../../../../../src/core/server'; +import { kibanaResponseFactory } from '../../../../../../../src/core/server'; import { licensePreRoutingFactory } from '../license_pre_routing_factory'; import { LICENSE_STATUS_VALID, LICENSE_STATUS_EXPIRED, -} from '../../../../../../../common/constants/license_status'; +} from '../../../../../../legacy/common/constants/license_status'; describe('license_pre_routing_factory', () => { describe('#reportingFeaturePreRoutingFactory', () => { diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/lib/license_pre_routing_factory/index.ts b/x-pack/plugins/watcher/server/lib/license_pre_routing_factory/index.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/lib/license_pre_routing_factory/index.ts rename to x-pack/plugins/watcher/server/lib/license_pre_routing_factory/index.ts diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/lib/license_pre_routing_factory/license_pre_routing_factory.ts b/x-pack/plugins/watcher/server/lib/license_pre_routing_factory/license_pre_routing_factory.ts similarity index 87% rename from x-pack/legacy/plugins/watcher/server/np_ready/lib/license_pre_routing_factory/license_pre_routing_factory.ts rename to x-pack/plugins/watcher/server/lib/license_pre_routing_factory/license_pre_routing_factory.ts index d2f4967246104..6b7db85a82321 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/lib/license_pre_routing_factory/license_pre_routing_factory.ts +++ b/x-pack/plugins/watcher/server/lib/license_pre_routing_factory/license_pre_routing_factory.ts @@ -9,9 +9,9 @@ import { KibanaResponseFactory, RequestHandler, RequestHandlerContext, -} from 'src/core/server'; -import { PLUGIN } from '../../../../common/constants'; -import { LICENSE_STATUS_VALID } from '../../../../../../common/constants/license_status'; +} from 'kibana/server'; +import { PLUGIN } from '../../../common/constants'; +import { LICENSE_STATUS_VALID } from '../../../../../legacy/common/constants/license_status'; import { ServerShim } from '../../types'; export const licensePreRoutingFactory = ( diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/lib/normalized_field_types/index.ts b/x-pack/plugins/watcher/server/lib/normalized_field_types/index.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/lib/normalized_field_types/index.ts rename to x-pack/plugins/watcher/server/lib/normalized_field_types/index.ts diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/lib/normalized_field_types/normalized_field_types.ts b/x-pack/plugins/watcher/server/lib/normalized_field_types/normalized_field_types.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/lib/normalized_field_types/normalized_field_types.ts rename to x-pack/plugins/watcher/server/lib/normalized_field_types/normalized_field_types.ts diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/action_status/__tests__/action_status.js b/x-pack/plugins/watcher/server/models/action_status/__tests__/action_status.js similarity index 99% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/action_status/__tests__/action_status.js rename to x-pack/plugins/watcher/server/models/action_status/__tests__/action_status.js index 21e27a1b12c46..3ed37c3e6c757 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/models/action_status/__tests__/action_status.js +++ b/x-pack/plugins/watcher/server/models/action_status/__tests__/action_status.js @@ -6,7 +6,7 @@ import expect from '@kbn/expect'; import { ActionStatus } from '../action_status'; -import { ACTION_STATES } from '../../../../../common/constants'; +import { ACTION_STATES } from '../../../../common/constants'; import moment from 'moment'; describe('action_status', () => { diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/action_status/action_status.js b/x-pack/plugins/watcher/server/models/action_status/action_status.js similarity index 97% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/action_status/action_status.js rename to x-pack/plugins/watcher/server/models/action_status/action_status.js index 6a484e7d4303a..5e821b074cf44 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/models/action_status/action_status.js +++ b/x-pack/plugins/watcher/server/models/action_status/action_status.js @@ -6,8 +6,8 @@ import { get } from 'lodash'; import { badImplementation, badRequest } from 'boom'; -import { getMoment } from '../../../../common/lib/get_moment'; -import { ACTION_STATES } from '../../../../common/constants'; +import { getMoment } from '../../../common/lib/get_moment'; +import { ACTION_STATES } from '../../../common/constants'; import { i18n } from '@kbn/i18n'; export class ActionStatus { diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/action_status/index.js b/x-pack/plugins/watcher/server/models/action_status/index.js similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/action_status/index.js rename to x-pack/plugins/watcher/server/models/action_status/index.js diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/execute_details/__tests__/execute_details.js b/x-pack/plugins/watcher/server/models/execute_details/__tests__/execute_details.js similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/execute_details/__tests__/execute_details.js rename to x-pack/plugins/watcher/server/models/execute_details/__tests__/execute_details.js diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/execute_details/execute_details.js b/x-pack/plugins/watcher/server/models/execute_details/execute_details.js similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/execute_details/execute_details.js rename to x-pack/plugins/watcher/server/models/execute_details/execute_details.js diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/execute_details/index.js b/x-pack/plugins/watcher/server/models/execute_details/index.js similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/execute_details/index.js rename to x-pack/plugins/watcher/server/models/execute_details/index.js diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/fields/__tests__/fields.js b/x-pack/plugins/watcher/server/models/fields/__tests__/fields.js similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/fields/__tests__/fields.js rename to x-pack/plugins/watcher/server/models/fields/__tests__/fields.js diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/fields/fields.js b/x-pack/plugins/watcher/server/models/fields/fields.js similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/fields/fields.js rename to x-pack/plugins/watcher/server/models/fields/fields.js diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/fields/index.js b/x-pack/plugins/watcher/server/models/fields/index.js similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/fields/index.js rename to x-pack/plugins/watcher/server/models/fields/index.js diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/settings/__tests__/settings.js b/x-pack/plugins/watcher/server/models/settings/__tests__/settings.js similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/settings/__tests__/settings.js rename to x-pack/plugins/watcher/server/models/settings/__tests__/settings.js diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/settings/index.js b/x-pack/plugins/watcher/server/models/settings/index.js similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/settings/index.js rename to x-pack/plugins/watcher/server/models/settings/index.js diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/settings/settings.js b/x-pack/plugins/watcher/server/models/settings/settings.js similarity index 97% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/settings/settings.js rename to x-pack/plugins/watcher/server/models/settings/settings.js index 4aa524731d88d..42fbda9cbe91d 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/models/settings/settings.js +++ b/x-pack/plugins/watcher/server/models/settings/settings.js @@ -5,7 +5,7 @@ */ import { merge } from 'lodash'; -import { ACTION_TYPES } from '../../../../common/constants'; +import { ACTION_TYPES } from '../../../common/constants'; function isEnabledByDefault(actionType) { switch (actionType) { diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/visualize_options/index.js b/x-pack/plugins/watcher/server/models/visualize_options/index.js similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/visualize_options/index.js rename to x-pack/plugins/watcher/server/models/visualize_options/index.js diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/visualize_options/visualize_options.js b/x-pack/plugins/watcher/server/models/visualize_options/visualize_options.js similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/visualize_options/visualize_options.js rename to x-pack/plugins/watcher/server/models/visualize_options/visualize_options.js diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/base_watch.js b/x-pack/plugins/watcher/server/models/watch/base_watch.js similarity index 98% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch/base_watch.js rename to x-pack/plugins/watcher/server/models/watch/base_watch.js index d77e6d6caa2fa..ea09fac6f8523 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/base_watch.js +++ b/x-pack/plugins/watcher/server/models/watch/base_watch.js @@ -6,7 +6,7 @@ import { get, map, pick } from 'lodash'; import { badRequest } from 'boom'; -import { Action } from '../../../../common/models/action'; +import { Action } from '../../../common/models/action'; import { WatchStatus } from '../watch_status'; import { i18n } from '@kbn/i18n'; import { WatchErrors } from '../watch_errors'; diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/base_watch.test.js b/x-pack/plugins/watcher/server/models/watch/base_watch.test.js similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch/base_watch.test.js rename to x-pack/plugins/watcher/server/models/watch/base_watch.test.js diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/index.js b/x-pack/plugins/watcher/server/models/watch/index.js similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch/index.js rename to x-pack/plugins/watcher/server/models/watch/index.js diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/json_watch.js b/x-pack/plugins/watcher/server/models/watch/json_watch.js similarity index 92% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch/json_watch.js rename to x-pack/plugins/watcher/server/models/watch/json_watch.js index 2440d4ef33881..dbb34e971f94a 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/json_watch.js +++ b/x-pack/plugins/watcher/server/models/watch/json_watch.js @@ -6,8 +6,8 @@ import { isEmpty, cloneDeep, has, merge } from 'lodash'; import { BaseWatch } from './base_watch'; -import { WATCH_TYPES } from '../../../../common/constants'; -import { serializeJsonWatch } from '../../../../common/lib/serialization'; +import { WATCH_TYPES } from '../../../common/constants'; +import { serializeJsonWatch } from '../../../common/lib/serialization'; export class JsonWatch extends BaseWatch { // This constructor should not be used directly. diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/json_watch.test.js b/x-pack/plugins/watcher/server/models/watch/json_watch.test.js similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch/json_watch.test.js rename to x-pack/plugins/watcher/server/models/watch/json_watch.test.js diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/lib/get_watch_type/get_watch_type.js b/x-pack/plugins/watcher/server/models/watch/lib/get_watch_type/get_watch_type.js similarity index 88% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch/lib/get_watch_type/get_watch_type.js rename to x-pack/plugins/watcher/server/models/watch/lib/get_watch_type/get_watch_type.js index 72c725eda2bd1..2bdd03e23c6dc 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/lib/get_watch_type/get_watch_type.js +++ b/x-pack/plugins/watcher/server/models/watch/lib/get_watch_type/get_watch_type.js @@ -5,7 +5,7 @@ */ import { get, contains, values } from 'lodash'; -import { WATCH_TYPES } from '../../../../../../common/constants'; +import { WATCH_TYPES } from '../../../../../common/constants'; export function getWatchType(watchJson) { const type = get(watchJson, 'metadata.xpack.type'); diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/lib/get_watch_type/index.js b/x-pack/plugins/watcher/server/models/watch/lib/get_watch_type/index.js similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch/lib/get_watch_type/index.js rename to x-pack/plugins/watcher/server/models/watch/lib/get_watch_type/index.js diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/monitoring_watch.js b/x-pack/plugins/watcher/server/models/watch/monitoring_watch.js similarity index 97% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch/monitoring_watch.js rename to x-pack/plugins/watcher/server/models/watch/monitoring_watch.js index 4aced5d0092d9..8f32621bfbb86 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/monitoring_watch.js +++ b/x-pack/plugins/watcher/server/models/watch/monitoring_watch.js @@ -7,7 +7,7 @@ import { merge } from 'lodash'; import { badRequest } from 'boom'; import { BaseWatch } from './base_watch'; -import { WATCH_TYPES } from '../../../../common/constants'; +import { WATCH_TYPES } from '../../../common/constants'; import { i18n } from '@kbn/i18n'; export class MonitoringWatch extends BaseWatch { diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/monitoring_watch.test.js b/x-pack/plugins/watcher/server/models/watch/monitoring_watch.test.js similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch/monitoring_watch.test.js rename to x-pack/plugins/watcher/server/models/watch/monitoring_watch.test.js diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/__tests__/format_visualize_data.js b/x-pack/plugins/watcher/server/models/watch/threshold_watch/__tests__/format_visualize_data.js similarity index 99% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/__tests__/format_visualize_data.js rename to x-pack/plugins/watcher/server/models/watch/threshold_watch/__tests__/format_visualize_data.js index 14aa8f7873e18..99e88c3628ea8 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/__tests__/format_visualize_data.js +++ b/x-pack/plugins/watcher/server/models/watch/threshold_watch/__tests__/format_visualize_data.js @@ -5,7 +5,7 @@ */ import expect from '@kbn/expect'; -import { AGG_TYPES } from '../../../../../../common/constants'; +import { AGG_TYPES } from '../../../../../common/constants'; import { formatVisualizeData } from '../format_visualize_data'; describe('watch', () => { diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/build_visualize_query.js b/x-pack/plugins/watcher/server/models/watch/threshold_watch/build_visualize_query.js similarity index 95% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/build_visualize_query.js rename to x-pack/plugins/watcher/server/models/watch/threshold_watch/build_visualize_query.js index cc79aec682400..84bdae6ad95fd 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/build_visualize_query.js +++ b/x-pack/plugins/watcher/server/models/watch/threshold_watch/build_visualize_query.js @@ -5,8 +5,8 @@ */ import { cloneDeep } from 'lodash'; -import { buildInput } from '../../../../../common/lib/serialization'; -import { AGG_TYPES } from '../../../../../common/constants'; +import { buildInput } from '../../../../common/lib/serialization'; +import { AGG_TYPES } from '../../../../common/constants'; /* input.search.request.body.query.bool.filter.range diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/data_samples/count.json b/x-pack/plugins/watcher/server/models/watch/threshold_watch/data_samples/count.json similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/data_samples/count.json rename to x-pack/plugins/watcher/server/models/watch/threshold_watch/data_samples/count.json diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/data_samples/count.query.date.json b/x-pack/plugins/watcher/server/models/watch/threshold_watch/data_samples/count.query.date.json similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/data_samples/count.query.date.json rename to x-pack/plugins/watcher/server/models/watch/threshold_watch/data_samples/count.query.date.json diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/data_samples/count.query.json b/x-pack/plugins/watcher/server/models/watch/threshold_watch/data_samples/count.query.json similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/data_samples/count.query.json rename to x-pack/plugins/watcher/server/models/watch/threshold_watch/data_samples/count.query.json diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/data_samples/count_terms.json b/x-pack/plugins/watcher/server/models/watch/threshold_watch/data_samples/count_terms.json similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/data_samples/count_terms.json rename to x-pack/plugins/watcher/server/models/watch/threshold_watch/data_samples/count_terms.json diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/data_samples/count_terms.query.date.json b/x-pack/plugins/watcher/server/models/watch/threshold_watch/data_samples/count_terms.query.date.json similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/data_samples/count_terms.query.date.json rename to x-pack/plugins/watcher/server/models/watch/threshold_watch/data_samples/count_terms.query.date.json diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/data_samples/count_terms.query.json b/x-pack/plugins/watcher/server/models/watch/threshold_watch/data_samples/count_terms.query.json similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/data_samples/count_terms.query.json rename to x-pack/plugins/watcher/server/models/watch/threshold_watch/data_samples/count_terms.query.json diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/data_samples/non_count.json b/x-pack/plugins/watcher/server/models/watch/threshold_watch/data_samples/non_count.json similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/data_samples/non_count.json rename to x-pack/plugins/watcher/server/models/watch/threshold_watch/data_samples/non_count.json diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/data_samples/non_count.query.date.json b/x-pack/plugins/watcher/server/models/watch/threshold_watch/data_samples/non_count.query.date.json similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/data_samples/non_count.query.date.json rename to x-pack/plugins/watcher/server/models/watch/threshold_watch/data_samples/non_count.query.date.json diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/data_samples/non_count.query.json b/x-pack/plugins/watcher/server/models/watch/threshold_watch/data_samples/non_count.query.json similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/data_samples/non_count.query.json rename to x-pack/plugins/watcher/server/models/watch/threshold_watch/data_samples/non_count.query.json diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/data_samples/non_count_terms.json b/x-pack/plugins/watcher/server/models/watch/threshold_watch/data_samples/non_count_terms.json similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/data_samples/non_count_terms.json rename to x-pack/plugins/watcher/server/models/watch/threshold_watch/data_samples/non_count_terms.json diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/data_samples/non_count_terms.query.date.json b/x-pack/plugins/watcher/server/models/watch/threshold_watch/data_samples/non_count_terms.query.date.json similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/data_samples/non_count_terms.query.date.json rename to x-pack/plugins/watcher/server/models/watch/threshold_watch/data_samples/non_count_terms.query.date.json diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/data_samples/non_count_terms.query.json b/x-pack/plugins/watcher/server/models/watch/threshold_watch/data_samples/non_count_terms.query.json similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/data_samples/non_count_terms.query.json rename to x-pack/plugins/watcher/server/models/watch/threshold_watch/data_samples/non_count_terms.query.json diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/format_visualize_data.js b/x-pack/plugins/watcher/server/models/watch/threshold_watch/format_visualize_data.js similarity index 97% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/format_visualize_data.js rename to x-pack/plugins/watcher/server/models/watch/threshold_watch/format_visualize_data.js index c8a6ac08df2c1..c93add71bfe38 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/format_visualize_data.js +++ b/x-pack/plugins/watcher/server/models/watch/threshold_watch/format_visualize_data.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { AGG_TYPES } from '../../../../../common/constants'; +import { AGG_TYPES } from '../../../../common/constants'; export function formatVisualizeData({ aggType, termField }, results) { if (aggType === AGG_TYPES.COUNT && !Boolean(termField)) { diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/index.js b/x-pack/plugins/watcher/server/models/watch/threshold_watch/index.js similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/index.js rename to x-pack/plugins/watcher/server/models/watch/threshold_watch/index.js diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/threshold_watch.js b/x-pack/plugins/watcher/server/models/watch/threshold_watch/threshold_watch.js similarity index 97% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/threshold_watch.js rename to x-pack/plugins/watcher/server/models/watch/threshold_watch/threshold_watch.js index e5410588ab566..ebef741200e00 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/threshold_watch.js +++ b/x-pack/plugins/watcher/server/models/watch/threshold_watch/threshold_watch.js @@ -6,8 +6,8 @@ import { merge } from 'lodash'; import { BaseWatch } from '../base_watch'; -import { WATCH_TYPES, COMPARATORS, SORT_ORDERS } from '../../../../../common/constants'; -import { serializeThresholdWatch } from '../../../../../common/lib/serialization'; +import { WATCH_TYPES, COMPARATORS, SORT_ORDERS } from '../../../../common/constants'; +import { serializeThresholdWatch } from '../../../../common/lib/serialization'; import { buildVisualizeQuery } from './build_visualize_query'; import { formatVisualizeData } from './format_visualize_data'; diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/threshold_watch.test.js b/x-pack/plugins/watcher/server/models/watch/threshold_watch/threshold_watch.test.js similarity index 99% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/threshold_watch.test.js rename to x-pack/plugins/watcher/server/models/watch/threshold_watch/threshold_watch.test.js index e65342708c9d5..af4aae54fbfea 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/threshold_watch/threshold_watch.test.js +++ b/x-pack/plugins/watcher/server/models/watch/threshold_watch/threshold_watch.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { COMPARATORS, SORT_ORDERS } from '../../../../../common/constants'; +import { COMPARATORS, SORT_ORDERS } from '../../../../common/constants'; import { WatchErrors } from '../../watch_errors'; import { ThresholdWatch } from './threshold_watch'; diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/watch.js b/x-pack/plugins/watcher/server/models/watch/watch.js similarity index 97% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch/watch.js rename to x-pack/plugins/watcher/server/models/watch/watch.js index cc92741de73ae..febf9c20b07a6 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/watch.js +++ b/x-pack/plugins/watcher/server/models/watch/watch.js @@ -6,7 +6,7 @@ import { set } from 'lodash'; import { badRequest } from 'boom'; -import { WATCH_TYPES } from '../../../../common/constants'; +import { WATCH_TYPES } from '../../../common/constants'; import { JsonWatch } from './json_watch'; import { MonitoringWatch } from './monitoring_watch'; import { ThresholdWatch } from './threshold_watch'; diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/watch.test.js b/x-pack/plugins/watcher/server/models/watch/watch.test.js similarity index 98% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch/watch.test.js rename to x-pack/plugins/watcher/server/models/watch/watch.test.js index d6e23e727d575..51eeb6a8c0538 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch/watch.test.js +++ b/x-pack/plugins/watcher/server/models/watch/watch.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { WATCH_TYPES } from '../../../../common/constants'; +import { WATCH_TYPES } from '../../../common/constants'; import { Watch } from './watch'; import { JsonWatch } from './json_watch'; import { MonitoringWatch } from './monitoring_watch'; diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch_errors/index.js b/x-pack/plugins/watcher/server/models/watch_errors/index.js similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch_errors/index.js rename to x-pack/plugins/watcher/server/models/watch_errors/index.js diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch_errors/watch_errors.js b/x-pack/plugins/watcher/server/models/watch_errors/watch_errors.js similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch_errors/watch_errors.js rename to x-pack/plugins/watcher/server/models/watch_errors/watch_errors.js diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch_errors/watch_errors.test.js b/x-pack/plugins/watcher/server/models/watch_errors/watch_errors.test.js similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch_errors/watch_errors.test.js rename to x-pack/plugins/watcher/server/models/watch_errors/watch_errors.test.js diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch_history_item/__tests__/watch_history_item.js b/x-pack/plugins/watcher/server/models/watch_history_item/__tests__/watch_history_item.js similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch_history_item/__tests__/watch_history_item.js rename to x-pack/plugins/watcher/server/models/watch_history_item/__tests__/watch_history_item.js diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch_history_item/index.js b/x-pack/plugins/watcher/server/models/watch_history_item/index.js similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch_history_item/index.js rename to x-pack/plugins/watcher/server/models/watch_history_item/index.js diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch_history_item/watch_history_item.js b/x-pack/plugins/watcher/server/models/watch_history_item/watch_history_item.js similarity index 97% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch_history_item/watch_history_item.js rename to x-pack/plugins/watcher/server/models/watch_history_item/watch_history_item.js index 391c68debfbd9..134b201628195 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch_history_item/watch_history_item.js +++ b/x-pack/plugins/watcher/server/models/watch_history_item/watch_history_item.js @@ -5,7 +5,7 @@ */ import { badRequest } from 'boom'; -import { getMoment } from '../../../../common/lib/get_moment'; +import { getMoment } from '../../../common/lib/get_moment'; import { get, cloneDeep } from 'lodash'; import { WatchStatus } from '../watch_status'; import { i18n } from '@kbn/i18n'; diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch_status/__tests__/watch_status.js b/x-pack/plugins/watcher/server/models/watch_status/__tests__/watch_status.js similarity index 99% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch_status/__tests__/watch_status.js rename to x-pack/plugins/watcher/server/models/watch_status/__tests__/watch_status.js index 505e1733e03cd..0d6731b90abe6 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch_status/__tests__/watch_status.js +++ b/x-pack/plugins/watcher/server/models/watch_status/__tests__/watch_status.js @@ -6,7 +6,7 @@ import expect from '@kbn/expect'; import { WatchStatus } from '../watch_status'; -import { ACTION_STATES, WATCH_STATES, WATCH_STATE_COMMENTS } from '../../../../../common/constants'; +import { ACTION_STATES, WATCH_STATES, WATCH_STATE_COMMENTS } from '../../../../common/constants'; import moment from 'moment'; describe('watch_status', () => { diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch_status/index.js b/x-pack/plugins/watcher/server/models/watch_status/index.js similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch_status/index.js rename to x-pack/plugins/watcher/server/models/watch_status/index.js diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch_status/watch_status.js b/x-pack/plugins/watcher/server/models/watch_status/watch_status.js similarity index 98% rename from x-pack/legacy/plugins/watcher/server/np_ready/models/watch_status/watch_status.js rename to x-pack/plugins/watcher/server/models/watch_status/watch_status.js index 3cdc1d8eb62e7..a346885965a16 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/models/watch_status/watch_status.js +++ b/x-pack/plugins/watcher/server/models/watch_status/watch_status.js @@ -6,9 +6,9 @@ import { get, map, forEach, max } from 'lodash'; import { badRequest } from 'boom'; -import { getMoment } from '../../../../common/lib/get_moment'; +import { getMoment } from '../../../common/lib/get_moment'; import { ActionStatus } from '../action_status'; -import { ACTION_STATES, WATCH_STATES, WATCH_STATE_COMMENTS } from '../../../../common/constants'; +import { ACTION_STATES, WATCH_STATES, WATCH_STATE_COMMENTS } from '../../../common/constants'; import { i18n } from '@kbn/i18n'; function getActionStatusTotals(watchStatus) { diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/plugin.ts b/x-pack/plugins/watcher/server/plugin.ts similarity index 90% rename from x-pack/legacy/plugins/watcher/server/np_ready/plugin.ts rename to x-pack/plugins/watcher/server/plugin.ts index a311c31082183..3d8714536eaee 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/plugin.ts +++ b/x-pack/plugins/watcher/server/plugin.ts @@ -3,12 +3,12 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { Plugin, CoreSetup } from 'src/core/server'; +import { Plugin, CoreSetup } from 'kibana/server'; import { i18n } from '@kbn/i18n'; -import { PLUGIN } from '../../common/constants'; +import { PLUGIN } from '../common/constants'; import { ServerShim, RouteDependencies } from './types'; -import { registerLicenseChecker } from '../../../../server/lib/register_license_checker'; +import { registerLicenseChecker } from '../../../legacy/server/lib/register_license_checker'; import { registerSettingsRoutes } from './routes/api/settings'; import { registerIndicesRoutes } from './routes/api/indices'; import { registerLicenseRoutes } from './routes/api/license'; @@ -29,6 +29,7 @@ export class WatcherServerPlugin implements Plugin { elasticsearchService, router, }; + // Register license checker registerLicenseChecker( serverShim as any, diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/indices/index.ts b/x-pack/plugins/watcher/server/routes/api/indices/index.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/routes/api/indices/index.ts rename to x-pack/plugins/watcher/server/routes/api/indices/index.ts diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/indices/register_get_route.ts b/x-pack/plugins/watcher/server/routes/api/indices/register_get_route.ts similarity index 98% rename from x-pack/legacy/plugins/watcher/server/np_ready/routes/api/indices/register_get_route.ts rename to x-pack/plugins/watcher/server/routes/api/indices/register_get_route.ts index 6b6b643dc4adf..98ee62b44f084 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/indices/register_get_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/indices/register_get_route.ts @@ -5,7 +5,7 @@ */ import { schema } from '@kbn/config-schema'; -import { RequestHandler } from 'src/core/server'; +import { RequestHandler } from 'kibana/server'; import { reduce, size } from 'lodash'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { isEsError } from '../../../lib/is_es_error'; diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/indices/register_indices_routes.ts b/x-pack/plugins/watcher/server/routes/api/indices/register_indices_routes.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/routes/api/indices/register_indices_routes.ts rename to x-pack/plugins/watcher/server/routes/api/indices/register_indices_routes.ts diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/license/index.ts b/x-pack/plugins/watcher/server/routes/api/license/index.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/routes/api/license/index.ts rename to x-pack/plugins/watcher/server/routes/api/license/index.ts diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/license/register_license_routes.ts b/x-pack/plugins/watcher/server/routes/api/license/register_license_routes.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/routes/api/license/register_license_routes.ts rename to x-pack/plugins/watcher/server/routes/api/license/register_license_routes.ts diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/license/register_refresh_route.ts b/x-pack/plugins/watcher/server/routes/api/license/register_refresh_route.ts similarity index 95% rename from x-pack/legacy/plugins/watcher/server/np_ready/routes/api/license/register_refresh_route.ts rename to x-pack/plugins/watcher/server/routes/api/license/register_refresh_route.ts index 08f1f26a84a4f..db7c2ca9816ce 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/license/register_refresh_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/license/register_refresh_route.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { RequestHandler } from 'src/core/server'; +import { RequestHandler } from 'kibana/server'; import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; import { RouteDependencies, ServerShim } from '../../../types'; diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/register_list_fields_route.ts b/x-pack/plugins/watcher/server/routes/api/register_list_fields_route.ts similarity index 95% rename from x-pack/legacy/plugins/watcher/server/np_ready/routes/api/register_list_fields_route.ts rename to x-pack/plugins/watcher/server/routes/api/register_list_fields_route.ts index f3222d24f0adf..b916333307940 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/register_list_fields_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/register_list_fields_route.ts @@ -5,12 +5,12 @@ */ import { schema } from '@kbn/config-schema'; -import { RequestHandler } from 'src/core/server'; +import { RequestHandler } from 'kibana/server'; import { callWithRequestFactory } from '../../lib/call_with_request_factory'; import { isEsError } from '../../lib/is_es_error'; import { licensePreRoutingFactory } from '../../lib/license_pre_routing_factory'; // @ts-ignore -import { Fields } from '../../models/fields'; +import { Fields } from '../../models/fields/index'; import { RouteDependencies, ServerShim } from '../../types'; function fetchFields(callWithRequest: any, indexes: string[]) { diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/register_load_history_route.ts b/x-pack/plugins/watcher/server/routes/api/register_load_history_route.ts similarity index 95% rename from x-pack/legacy/plugins/watcher/server/np_ready/routes/api/register_load_history_route.ts rename to x-pack/plugins/watcher/server/routes/api/register_load_history_route.ts index d62e4f48c5629..d7c2b98b45921 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/register_load_history_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/register_load_history_route.ts @@ -6,14 +6,14 @@ import { schema } from '@kbn/config-schema'; import { get } from 'lodash'; -import { RequestHandler } from 'src/core/server'; +import { RequestHandler } from 'kibana/server'; import { callWithRequestFactory } from '../../lib/call_with_request_factory'; import { isEsError } from '../../lib/is_es_error'; -import { INDEX_NAMES } from '../../../../common/constants'; +import { INDEX_NAMES } from '../../../common/constants'; import { licensePreRoutingFactory } from '../../lib/license_pre_routing_factory'; import { RouteDependencies, ServerShim } from '../../types'; // @ts-ignore -import { WatchHistoryItem } from '../../models/watch_history_item'; +import { WatchHistoryItem } from '../../models/watch_history_item/index'; function fetchHistoryItem(callWithRequest: any, watchHistoryItemId: string) { return callWithRequest('search', { diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/settings/index.ts b/x-pack/plugins/watcher/server/routes/api/settings/index.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/routes/api/settings/index.ts rename to x-pack/plugins/watcher/server/routes/api/settings/index.ts diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/settings/register_load_route.ts b/x-pack/plugins/watcher/server/routes/api/settings/register_load_route.ts similarity index 91% rename from x-pack/legacy/plugins/watcher/server/np_ready/routes/api/settings/register_load_route.ts rename to x-pack/plugins/watcher/server/routes/api/settings/register_load_route.ts index 710d079d810da..c4f3e87f00160 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/settings/register_load_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/settings/register_load_route.ts @@ -4,11 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IClusterClient, RequestHandler } from 'src/core/server'; +import { IClusterClient, RequestHandler } from 'kibana/server'; import { isEsError } from '../../../lib/is_es_error'; import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; // @ts-ignore -import { Settings } from '../../../models/settings'; +import { Settings } from '../../../models/settings/index'; import { RouteDependencies, ServerShim } from '../../../types'; function fetchClusterSettings(client: IClusterClient) { diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/settings/register_settings_routes.ts b/x-pack/plugins/watcher/server/routes/api/settings/register_settings_routes.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/routes/api/settings/register_settings_routes.ts rename to x-pack/plugins/watcher/server/routes/api/settings/register_settings_routes.ts diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/action/index.ts b/x-pack/plugins/watcher/server/routes/api/watch/action/index.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/action/index.ts rename to x-pack/plugins/watcher/server/routes/api/watch/action/index.ts diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/action/register_acknowledge_route.ts b/x-pack/plugins/watcher/server/routes/api/watch/action/register_acknowledge_route.ts similarity index 94% rename from x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/action/register_acknowledge_route.ts rename to x-pack/plugins/watcher/server/routes/api/watch/action/register_acknowledge_route.ts index d0cc0a27e87ff..3d7a16ab2103b 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/action/register_acknowledge_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watch/action/register_acknowledge_route.ts @@ -6,12 +6,12 @@ import { schema } from '@kbn/config-schema'; import { get } from 'lodash'; -import { RequestHandler } from 'src/core/server'; +import { RequestHandler } from 'kibana/server'; import { callWithRequestFactory } from '../../../../lib/call_with_request_factory'; import { isEsError } from '../../../../lib/is_es_error'; import { licensePreRoutingFactory } from '../../../../lib/license_pre_routing_factory'; // @ts-ignore -import { WatchStatus } from '../../../../models/watch_status'; +import { WatchStatus } from '../../../../models/watch_status/index'; import { RouteDependencies, ServerShim } from '../../../../types'; function acknowledgeAction(callWithRequest: any, watchId: string, actionId: string) { diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/action/register_action_routes.ts b/x-pack/plugins/watcher/server/routes/api/watch/action/register_action_routes.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/action/register_action_routes.ts rename to x-pack/plugins/watcher/server/routes/api/watch/action/register_action_routes.ts diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/index.ts b/x-pack/plugins/watcher/server/routes/api/watch/index.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/index.ts rename to x-pack/plugins/watcher/server/routes/api/watch/index.ts diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/register_activate_route.ts b/x-pack/plugins/watcher/server/routes/api/watch/register_activate_route.ts similarity index 94% rename from x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/register_activate_route.ts rename to x-pack/plugins/watcher/server/routes/api/watch/register_activate_route.ts index 28c482124aaee..b220d05d808c3 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/register_activate_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watch/register_activate_route.ts @@ -5,14 +5,14 @@ */ import { schema } from '@kbn/config-schema'; -import { RequestHandler } from 'src/core/server'; +import { RequestHandler } from 'kibana/server'; import { get } from 'lodash'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { isEsError } from '../../../lib/is_es_error'; import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; import { RouteDependencies, ServerShim } from '../../../types'; // @ts-ignore -import { WatchStatus } from '../../../models/watch_status'; +import { WatchStatus } from '../../../models/watch_status/index'; function activateWatch(callWithRequest: any, watchId: string) { return callWithRequest('watcher.activateWatch', { diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/register_deactivate_route.ts b/x-pack/plugins/watcher/server/routes/api/watch/register_deactivate_route.ts similarity index 94% rename from x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/register_deactivate_route.ts rename to x-pack/plugins/watcher/server/routes/api/watch/register_deactivate_route.ts index ac87066379a20..e0fbcb321d5f1 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/register_deactivate_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watch/register_deactivate_route.ts @@ -4,14 +4,14 @@ * you may not use this file except in compliance with the Elastic License. */ import { schema } from '@kbn/config-schema'; -import { RequestHandler } from 'src/core/server'; +import { RequestHandler } from 'kibana/server'; import { get } from 'lodash'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { isEsError } from '../../../lib/is_es_error'; import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; import { RouteDependencies, ServerShim } from '../../../types'; // @ts-ignore -import { WatchStatus } from '../../../models/watch_status'; +import { WatchStatus } from '../../../models/watch_status/index'; function deactivateWatch(callWithRequest: any, watchId: string) { return callWithRequest('watcher.deactivateWatch', { diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/register_delete_route.ts b/x-pack/plugins/watcher/server/routes/api/watch/register_delete_route.ts similarity index 97% rename from x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/register_delete_route.ts rename to x-pack/plugins/watcher/server/routes/api/watch/register_delete_route.ts index 3402cc283dba0..7f998aaefd9e8 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/register_delete_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watch/register_delete_route.ts @@ -5,7 +5,7 @@ */ import { schema } from '@kbn/config-schema'; -import { RequestHandler } from 'src/core/server'; +import { RequestHandler } from 'kibana/server'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { isEsError } from '../../../lib/is_es_error'; import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/register_execute_route.ts b/x-pack/plugins/watcher/server/routes/api/watch/register_execute_route.ts similarity index 93% rename from x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/register_execute_route.ts rename to x-pack/plugins/watcher/server/routes/api/watch/register_execute_route.ts index f3bce228653fe..52e4d37d0d228 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/register_execute_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watch/register_execute_route.ts @@ -5,7 +5,7 @@ */ import { schema } from '@kbn/config-schema'; -import { RequestHandler } from 'src/core/server'; +import { RequestHandler } from 'kibana/server'; import { get } from 'lodash'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { isEsError } from '../../../lib/is_es_error'; @@ -13,11 +13,11 @@ import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_facto import { RouteDependencies, ServerShim } from '../../../types'; // @ts-ignore -import { ExecuteDetails } from '../../../models/execute_details'; +import { ExecuteDetails } from '../../../models/execute_details/index'; // @ts-ignore -import { Watch } from '../../../models/watch'; +import { Watch } from '../../../models/watch/index'; // @ts-ignore -import { WatchHistoryItem } from '../../../models/watch_history_item'; +import { WatchHistoryItem } from '../../../models/watch_history_item/index'; function executeWatch(callWithRequest: any, executeDetails: any, watchJson: any) { const body = executeDetails; diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/register_history_route.ts b/x-pack/plugins/watcher/server/routes/api/watch/register_history_route.ts similarity index 95% rename from x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/register_history_route.ts rename to x-pack/plugins/watcher/server/routes/api/watch/register_history_route.ts index e236d7dd642a3..7bf34483373da 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/register_history_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watch/register_history_route.ts @@ -5,16 +5,16 @@ */ import { schema } from '@kbn/config-schema'; -import { RequestHandler } from 'src/core/server'; +import { RequestHandler } from 'kibana/server'; import { get } from 'lodash'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { fetchAllFromScroll } from '../../../lib/fetch_all_from_scroll'; -import { INDEX_NAMES, ES_SCROLL_SETTINGS } from '../../../../../common/constants'; +import { INDEX_NAMES, ES_SCROLL_SETTINGS } from '../../../../common/constants'; import { isEsError } from '../../../lib/is_es_error'; import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; import { RouteDependencies, ServerShim } from '../../../types'; // @ts-ignore -import { WatchHistoryItem } from '../../../models/watch_history_item'; +import { WatchHistoryItem } from '../../../models/watch_history_item/index'; function fetchHistoryItems(callWithRequest: any, watchId: any, startTime: any) { const params: any = { diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/register_load_route.ts b/x-pack/plugins/watcher/server/routes/api/watch/register_load_route.ts similarity index 95% rename from x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/register_load_route.ts rename to x-pack/plugins/watcher/server/routes/api/watch/register_load_route.ts index 7311ad08f73a6..4a53bd7c28a65 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/register_load_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watch/register_load_route.ts @@ -5,13 +5,13 @@ */ import { schema } from '@kbn/config-schema'; -import { RequestHandler } from 'src/core/server'; +import { RequestHandler } from 'kibana/server'; import { get } from 'lodash'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { isEsError } from '../../../lib/is_es_error'; import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; // @ts-ignore -import { Watch } from '../../../models/watch'; +import { Watch } from '../../../models/watch/index'; import { RouteDependencies, ServerShim } from '../../../types'; function fetchWatch(callWithRequest: any, watchId: string) { diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/register_save_route.ts b/x-pack/plugins/watcher/server/routes/api/watch/register_save_route.ts similarity index 94% rename from x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/register_save_route.ts rename to x-pack/plugins/watcher/server/routes/api/watch/register_save_route.ts index 5d22392d49ed8..01de7332f9e6b 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/register_save_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watch/register_save_route.ts @@ -5,13 +5,13 @@ */ import { schema } from '@kbn/config-schema'; -import { RequestHandler } from 'src/core/server'; +import { RequestHandler } from 'kibana/server'; import { i18n } from '@kbn/i18n'; -import { WATCH_TYPES } from '../../../../../common/constants'; +import { WATCH_TYPES } from '../../../../common/constants'; import { serializeJsonWatch, serializeThresholdWatch, -} from '../../../../../common/lib/serialization'; +} from '../../../../common/lib/serialization'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { isEsError } from '../../../lib/is_es_error'; import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/register_visualize_route.ts b/x-pack/plugins/watcher/server/routes/api/watch/register_visualize_route.ts similarity index 95% rename from x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/register_visualize_route.ts rename to x-pack/plugins/watcher/server/routes/api/watch/register_visualize_route.ts index d07a264b0b2b1..34a7bb2347067 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/register_visualize_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watch/register_visualize_route.ts @@ -5,16 +5,16 @@ */ import { schema } from '@kbn/config-schema'; -import { RequestHandler } from 'src/core/server'; +import { RequestHandler } from 'kibana/server'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { isEsError } from '../../../lib/is_es_error'; import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; import { RouteDependencies, ServerShim } from '../../../types'; // @ts-ignore -import { Watch } from '../../../models/watch'; +import { Watch } from '../../../models/watch/index'; // @ts-ignore -import { VisualizeOptions } from '../../../models/visualize_options'; +import { VisualizeOptions } from '../../../models/visualize_options/index'; function fetchVisualizeData(callWithRequest: any, index: any, body: any) { const params = { diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/register_watch_routes.ts b/x-pack/plugins/watcher/server/routes/api/watch/register_watch_routes.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watch/register_watch_routes.ts rename to x-pack/plugins/watcher/server/routes/api/watch/register_watch_routes.ts diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watches/index.ts b/x-pack/plugins/watcher/server/routes/api/watches/index.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watches/index.ts rename to x-pack/plugins/watcher/server/routes/api/watches/index.ts diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watches/register_delete_route.ts b/x-pack/plugins/watcher/server/routes/api/watches/register_delete_route.ts similarity index 97% rename from x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watches/register_delete_route.ts rename to x-pack/plugins/watcher/server/routes/api/watches/register_delete_route.ts index 29c539a0de138..5edf8b9d6c225 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watches/register_delete_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watches/register_delete_route.ts @@ -5,7 +5,7 @@ */ import { schema } from '@kbn/config-schema'; -import { RequestHandler } from 'src/core/server'; +import { RequestHandler } from 'kibana/server'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; import { RouteDependencies, ServerShim } from '../../../types'; diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watches/register_list_route.ts b/x-pack/plugins/watcher/server/routes/api/watches/register_list_route.ts similarity index 92% rename from x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watches/register_list_route.ts rename to x-pack/plugins/watcher/server/routes/api/watches/register_list_route.ts index b94c29e0f9892..f179e88b88bfb 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watches/register_list_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watches/register_list_route.ts @@ -4,16 +4,16 @@ * you may not use this file except in compliance with the Elastic License. */ -import { RequestHandler } from 'src/core/server'; +import { RequestHandler } from 'kibana/server'; import { get } from 'lodash'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { fetchAllFromScroll } from '../../../lib/fetch_all_from_scroll'; -import { INDEX_NAMES, ES_SCROLL_SETTINGS } from '../../../../../common/constants'; +import { INDEX_NAMES, ES_SCROLL_SETTINGS } from '../../../../common/constants'; import { isEsError } from '../../../lib/is_es_error'; import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; import { RouteDependencies, ServerShim } from '../../../types'; // @ts-ignore -import { Watch } from '../../../models/watch'; +import { Watch } from '../../../models/watch/index'; function fetchWatches(callWithRequest: any) { const params = { diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watches/register_watches_routes.ts b/x-pack/plugins/watcher/server/routes/api/watches/register_watches_routes.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/server/np_ready/routes/api/watches/register_watches_routes.ts rename to x-pack/plugins/watcher/server/routes/api/watches/register_watches_routes.ts diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/types.ts b/x-pack/plugins/watcher/server/types.ts similarity index 83% rename from x-pack/legacy/plugins/watcher/server/np_ready/types.ts rename to x-pack/plugins/watcher/server/types.ts index 3d4454aa2a8b7..5e7d6c7cc14a8 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/types.ts +++ b/x-pack/plugins/watcher/server/types.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IRouter, ElasticsearchServiceSetup, IClusterClient } from 'src/core/server'; -import { XPackMainPlugin } from '../../../xpack_main/server/xpack_main'; +import { IRouter, ElasticsearchServiceSetup, IClusterClient } from 'kibana/server'; +import { XPackMainPlugin } from '../../../legacy/plugins/xpack_main/server/xpack_main'; export interface ServerShim { route: any; diff --git a/x-pack/legacy/plugins/watcher/test/fixtures/execute_details.ts b/x-pack/plugins/watcher/test/fixtures/execute_details.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/test/fixtures/execute_details.ts rename to x-pack/plugins/watcher/test/fixtures/execute_details.ts diff --git a/x-pack/legacy/plugins/watcher/test/fixtures/index.ts b/x-pack/plugins/watcher/test/fixtures/index.ts similarity index 100% rename from x-pack/legacy/plugins/watcher/test/fixtures/index.ts rename to x-pack/plugins/watcher/test/fixtures/index.ts diff --git a/x-pack/legacy/plugins/watcher/test/fixtures/watch.ts b/x-pack/plugins/watcher/test/fixtures/watch.ts similarity index 95% rename from x-pack/legacy/plugins/watcher/test/fixtures/watch.ts rename to x-pack/plugins/watcher/test/fixtures/watch.ts index d948fddeefd58..206f10602ba47 100644 --- a/x-pack/legacy/plugins/watcher/test/fixtures/watch.ts +++ b/x-pack/plugins/watcher/test/fixtures/watch.ts @@ -5,7 +5,7 @@ */ import { Moment } from 'moment'; -import { getRandomString } from '../../../../../test_utils'; +import { getRandomString } from 'test_utils/index'; interface Watch { id: string; diff --git a/x-pack/legacy/plugins/watcher/test/fixtures/watch_history.ts b/x-pack/plugins/watcher/test/fixtures/watch_history.ts similarity index 93% rename from x-pack/legacy/plugins/watcher/test/fixtures/watch_history.ts rename to x-pack/plugins/watcher/test/fixtures/watch_history.ts index 70275e6e8869e..2c1b0666e387c 100644 --- a/x-pack/legacy/plugins/watcher/test/fixtures/watch_history.ts +++ b/x-pack/plugins/watcher/test/fixtures/watch_history.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { getRandomString } from '../../../../../test_utils'; +import { getRandomString } from 'test_utils/index'; interface WatchHistory { startTime: string; From f90ea195f9a07321c395a07a7cb5240a51223a17 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Tue, 14 Jan 2020 17:01:10 +0100 Subject: [PATCH 02/15] First iteration of watcher plugin that renders --- .github/CODEOWNERS | 2 +- x-pack/.i18nrc.json | 2 +- x-pack/dev-tools/jest/create_jest_config.js | 1 - x-pack/index.js | 2 - x-pack/plugins/watcher/kibana.json | 4 +- .../watcher/public/application/app.tsx | 34 +- .../watcher/public/application/boot.tsx | 6 +- .../watcher/public/application/lib/api.ts | 9 +- .../application/models/action/index.d.ts | 7 + .../models/execute_details/index.d.ts | 7 + .../public/application/models/index.d.ts | 39 -- .../application/models/settings/index.d.ts | 7 + .../models/visualize_options/index.d.ts | 7 + .../application/models/watch/index.d.ts | 7 + .../application/models/watch/json_watch.d.ts | 7 + .../models/watch/threshold_watch.d.ts | 7 + .../models/watch_history_item/index.d.ts | 7 + .../models/watch_status/index.d.ts | 7 + .../json_watch_edit/json_watch_edit.tsx | 2 +- .../json_watch_edit_simulate.tsx | 6 +- .../threshold_watch_action_accordion.tsx | 11 +- .../threshold_watch_action_dropdown.tsx | 3 +- .../watch_visualization.tsx | 19 +- .../watch_edit/components/watch_edit.tsx | 7 +- .../watch_list/components/watch_list.tsx | 2 +- .../watch_status/components/watch_status.tsx | 6 +- .../public/legacy/calc_auto_interval.ts | 132 ++++++ .../watcher/public/legacy/calc_es_interval.js | 58 +++ .../plugins/watcher/public/legacy/index.d.ts | 8 + x-pack/plugins/watcher/public/legacy/index.ts | 15 + .../public/legacy/parse_es_interval/index.ts | 10 + .../invalid_es_calendar_interval_error.ts | 39 ++ .../invalid_es_interval_format_error.ts | 30 ++ .../parse_es_interval/is_valid_es_interval.ts | 25 ++ .../parse_es_interval.test.ts | 56 +++ .../parse_es_interval/parse_es_interval.ts | 62 +++ .../watcher/public/legacy/time_buckets.js | 397 ++++++++++++++++++ x-pack/plugins/watcher/public/plugin.ts | 141 +++++-- x-pack/plugins/watcher/public/types.ts | 14 +- x-pack/plugins/watcher/server/index.ts | 2 +- x-pack/plugins/watcher/server/plugin.ts | 68 +-- .../routes/api/indices/register_get_route.ts | 7 +- .../api/indices/register_indices_routes.ts | 6 +- .../api/license/register_license_routes.ts | 6 +- .../api/license/register_refresh_route.ts | 7 +- .../routes/api/register_list_fields_route.ts | 7 +- .../routes/api/register_load_history_route.ts | 7 +- .../api/settings/register_load_route.ts | 7 +- .../api/settings/register_settings_routes.ts | 6 +- .../action/register_acknowledge_route.ts | 7 +- .../watch/action/register_action_routes.ts | 6 +- .../api/watch/register_activate_route.ts | 7 +- .../api/watch/register_deactivate_route.ts | 7 +- .../routes/api/watch/register_delete_route.ts | 7 +- .../api/watch/register_execute_route.ts | 7 +- .../api/watch/register_history_route.ts | 7 +- .../routes/api/watch/register_load_route.ts | 7 +- .../routes/api/watch/register_save_route.ts | 12 +- .../api/watch/register_visualize_route.ts | 7 +- .../routes/api/watch/register_watch_routes.ts | 22 +- .../api/watches/register_delete_route.ts | 7 +- .../routes/api/watches/register_list_route.ts | 7 +- .../api/watches/register_watches_routes.ts | 8 +- x-pack/plugins/watcher/server/types.ts | 6 + 64 files changed, 1167 insertions(+), 285 deletions(-) create mode 100644 x-pack/plugins/watcher/public/application/models/action/index.d.ts create mode 100644 x-pack/plugins/watcher/public/application/models/execute_details/index.d.ts delete mode 100644 x-pack/plugins/watcher/public/application/models/index.d.ts create mode 100644 x-pack/plugins/watcher/public/application/models/settings/index.d.ts create mode 100644 x-pack/plugins/watcher/public/application/models/visualize_options/index.d.ts create mode 100644 x-pack/plugins/watcher/public/application/models/watch/index.d.ts create mode 100644 x-pack/plugins/watcher/public/application/models/watch/json_watch.d.ts create mode 100644 x-pack/plugins/watcher/public/application/models/watch/threshold_watch.d.ts create mode 100644 x-pack/plugins/watcher/public/application/models/watch_history_item/index.d.ts create mode 100644 x-pack/plugins/watcher/public/application/models/watch_status/index.d.ts create mode 100644 x-pack/plugins/watcher/public/legacy/calc_auto_interval.ts create mode 100644 x-pack/plugins/watcher/public/legacy/calc_es_interval.js create mode 100644 x-pack/plugins/watcher/public/legacy/index.d.ts create mode 100644 x-pack/plugins/watcher/public/legacy/index.ts create mode 100644 x-pack/plugins/watcher/public/legacy/parse_es_interval/index.ts create mode 100644 x-pack/plugins/watcher/public/legacy/parse_es_interval/invalid_es_calendar_interval_error.ts create mode 100644 x-pack/plugins/watcher/public/legacy/parse_es_interval/invalid_es_interval_format_error.ts create mode 100644 x-pack/plugins/watcher/public/legacy/parse_es_interval/is_valid_es_interval.ts create mode 100644 x-pack/plugins/watcher/public/legacy/parse_es_interval/parse_es_interval.test.ts create mode 100644 x-pack/plugins/watcher/public/legacy/parse_es_interval/parse_es_interval.ts create mode 100644 x-pack/plugins/watcher/public/legacy/time_buckets.js diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index acfb7307f49c4..fc2459f170c87 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -151,4 +151,4 @@ /x-pack/legacy/plugins/rollup/ @elastic/es-ui /x-pack/legacy/plugins/searchprofiler/ @elastic/es-ui /x-pack/legacy/plugins/snapshot_restore/ @elastic/es-ui -/x-pack/legacy/plugins/watcher/ @elastic/es-ui +/x-pack/plugins/watcher/ @elastic/es-ui diff --git a/x-pack/.i18nrc.json b/x-pack/.i18nrc.json index 71e3bdd6c8c84..63efce91867c9 100644 --- a/x-pack/.i18nrc.json +++ b/x-pack/.i18nrc.json @@ -40,7 +40,7 @@ "xpack.transform": "legacy/plugins/transform", "xpack.upgradeAssistant": "legacy/plugins/upgrade_assistant", "xpack.uptime": "legacy/plugins/uptime", - "xpack.watcher": "legacy/plugins/watcher" + "xpack.watcher": "plugins/watcher" }, "translations": [ "plugins/translations/translations/zh-CN.json", diff --git a/x-pack/dev-tools/jest/create_jest_config.js b/x-pack/dev-tools/jest/create_jest_config.js index f38181ce56a2f..c84970e3a9411 100644 --- a/x-pack/dev-tools/jest/create_jest_config.js +++ b/x-pack/dev-tools/jest/create_jest_config.js @@ -20,7 +20,6 @@ export function createJestConfig({ kibanaDirectory, xPackKibanaDirectory }) { 'uiExports/(.*)': fileMockPath, '^src/core/(.*)': `${kibanaDirectory}/src/core/$1`, '^src/legacy/(.*)': `${kibanaDirectory}/src/legacy/$1`, - '^plugins/watcher/np_ready/application/models/(.*)': `${xPackKibanaDirectory}/legacy/plugins/watcher/public/np_ready/application/models/$1`, '^plugins/([^/.]*)(.*)': `${kibanaDirectory}/src/legacy/core_plugins/$1/public$2`, '^legacy/plugins/xpack_main/(.*);': `${xPackKibanaDirectory}/legacy/plugins/xpack_main/public/$1`, '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': fileMockPath, diff --git a/x-pack/index.js b/x-pack/index.js index 83a7b5540334f..bda081f28feac 100644 --- a/x-pack/index.js +++ b/x-pack/index.js @@ -12,7 +12,6 @@ import { security } from './legacy/plugins/security'; import { searchprofiler } from './legacy/plugins/searchprofiler'; import { ml } from './legacy/plugins/ml'; import { tilemap } from './legacy/plugins/tilemap'; -import { watcher } from './legacy/plugins/watcher'; import { grokdebugger } from './legacy/plugins/grokdebugger'; import { dashboardMode } from './legacy/plugins/dashboard_mode'; import { logstash } from './legacy/plugins/logstash'; @@ -55,7 +54,6 @@ module.exports = function(kibana) { searchprofiler(kibana), ml(kibana), tilemap(kibana), - watcher(kibana), grokdebugger(kibana), dashboardMode(kibana), logstash(kibana), diff --git a/x-pack/plugins/watcher/kibana.json b/x-pack/plugins/watcher/kibana.json index 0816ab05b4e34..93a28f8f59ed5 100644 --- a/x-pack/plugins/watcher/kibana.json +++ b/x-pack/plugins/watcher/kibana.json @@ -4,7 +4,9 @@ "requiredPlugins": [ "home", "licensing", - "management" + "management", + "eui_utils", + "data" ], "server": true, "ui": true diff --git a/x-pack/plugins/watcher/public/application/app.tsx b/x-pack/plugins/watcher/public/application/app.tsx index 8cb29a4fc035e..e0fb4d8e55bce 100644 --- a/x-pack/plugins/watcher/public/application/app.tsx +++ b/x-pack/plugins/watcher/public/application/app.tsx @@ -13,7 +13,6 @@ import { IUiSettingsClient, } from 'kibana/public'; -import { EuiCallOut, EuiLink } from '@elastic/eui'; import { HashRouter, Switch, @@ -22,15 +21,13 @@ import { withRouter, RouteComponentProps, } from 'react-router-dom'; -import { FormattedMessage } from '@kbn/i18n/react'; import { WatchStatus } from './sections/watch_status/components/watch_status'; import { WatchEdit } from './sections/watch_edit/components/watch_edit'; import { WatchList } from './sections/watch_list/components/watch_list'; import { registerRouter } from './lib/navigation'; import { BASE_PATH } from './constants'; -import { LICENSE_STATUS_VALID } from '../../../../legacy/common/constants'; import { AppContextProvider } from './app_context'; -import { LegacyDependencies } from '../types'; +import { DataPublicPluginSetup } from '../../../../../src/plugins/data/public'; const ShareRouter = withRouter(({ children, history }: RouteComponentProps & { children: any }) => { registerRouter({ history }); @@ -38,41 +35,18 @@ const ShareRouter = withRouter(({ children, history }: RouteComponentProps & { c }); export interface AppDeps { + data: DataPublicPluginSetup; chrome: ChromeStart; docLinks: DocLinksStart; toasts: ToastsSetup; http: HttpSetup; uiSettings: IUiSettingsClient; - legacy: LegacyDependencies; euiUtils: any; + TimeBuckets: any; + MANAGEMENT_BREADCRUMB: any; } export const App = (deps: AppDeps) => { - const { status, message } = deps.legacy.licenseStatus; - - if (status !== LICENSE_STATUS_VALID) { - return ( - - } - color="warning" - iconType="help" - > - {message}{' '} - - - - - ); - } - return ( diff --git a/x-pack/plugins/watcher/public/application/boot.tsx b/x-pack/plugins/watcher/public/application/boot.tsx index 2e9421af242b9..be6bc9dd6e2af 100644 --- a/x-pack/plugins/watcher/public/application/boot.tsx +++ b/x-pack/plugins/watcher/public/application/boot.tsx @@ -10,24 +10,22 @@ import { SavedObjectsClientContract } from 'kibana/public'; import { App, AppDeps } from './app'; import { setHttpClient, setSavedObjectsClient } from './lib/api'; -import { LegacyDependencies } from '../types'; interface BootDeps extends AppDeps { element: HTMLElement; savedObjects: SavedObjectsClientContract; I18nContext: any; - legacy: LegacyDependencies; } export const boot = (bootDeps: BootDeps) => { - const { I18nContext, element, legacy, savedObjects, ...appDeps } = bootDeps; + const { I18nContext, element, savedObjects, ...appDeps } = bootDeps; setHttpClient(appDeps.http); setSavedObjectsClient(savedObjects); render( - + , element ); diff --git a/x-pack/plugins/watcher/public/application/lib/api.ts b/x-pack/plugins/watcher/public/application/lib/api.ts index bf97e4b991ca8..c919b86d9d7c9 100644 --- a/x-pack/plugins/watcher/public/application/lib/api.ts +++ b/x-pack/plugins/watcher/public/application/lib/api.ts @@ -4,10 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ import { HttpSetup, SavedObjectsClientContract } from 'kibana/public'; -import { Settings } from 'plugins/watcher/np_ready/application/models/settings'; -import { Watch } from 'plugins/watcher/np_ready/application/models/watch'; -import { WatchHistoryItem } from 'plugins/watcher/np_ready/application/models/watch_history_item'; -import { WatchStatus } from 'plugins/watcher/np_ready/application/models/watch_status'; + +import { Settings } from '../models/settings'; +import { Watch } from '../models/watch'; +import { WatchHistoryItem } from '../models/watch_history_item'; +import { WatchStatus } from '../models/watch_status'; import { BaseWatch, ExecutedWatchDetails } from '../../../common/types/watch_types'; import { useRequest, sendRequest } from './use_request'; diff --git a/x-pack/plugins/watcher/public/application/models/action/index.d.ts b/x-pack/plugins/watcher/public/application/models/action/index.d.ts new file mode 100644 index 0000000000000..5415194b72958 --- /dev/null +++ b/x-pack/plugins/watcher/public/application/models/action/index.d.ts @@ -0,0 +1,7 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const Action: any; diff --git a/x-pack/plugins/watcher/public/application/models/execute_details/index.d.ts b/x-pack/plugins/watcher/public/application/models/execute_details/index.d.ts new file mode 100644 index 0000000000000..417c073cf0568 --- /dev/null +++ b/x-pack/plugins/watcher/public/application/models/execute_details/index.d.ts @@ -0,0 +1,7 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const ExecuteDetails: any; diff --git a/x-pack/plugins/watcher/public/application/models/index.d.ts b/x-pack/plugins/watcher/public/application/models/index.d.ts deleted file mode 100644 index a8ddb6ca2b76d..0000000000000 --- a/x-pack/plugins/watcher/public/application/models/index.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -declare module 'plugins/watcher/np_ready/application/models/visualize_options' { - export const VisualizeOptions: any; -} - -declare module 'plugins/watcher/np_ready/application/models/watch' { - export const Watch: any; -} - -declare module 'plugins/watcher/np_ready/application/models/watch/threshold_watch' { - export const ThresholdWatch: any; -} - -declare module 'plugins/watcher/np_ready/application/models/watch/json_watch' { - export const JsonWatch: any; -} - -declare module 'plugins/watcher/np_ready/application/models/execute_details/execute_details' { - export const ExecuteDetails: any; -} - -declare module 'plugins/watcher/np_ready/application/models/watch_history_item' { - export const WatchHistoryItem: any; -} - -declare module 'plugins/watcher/np_ready/application/models/watch_status' { - export const WatchStatus: any; -} - -declare module 'plugins/watcher/np_ready/application/models/settings' { - export const Settings: any; -} -declare module 'plugins/watcher/np_ready/application/models/action' { - export const Action: any; -} diff --git a/x-pack/plugins/watcher/public/application/models/settings/index.d.ts b/x-pack/plugins/watcher/public/application/models/settings/index.d.ts new file mode 100644 index 0000000000000..92a5de1df413c --- /dev/null +++ b/x-pack/plugins/watcher/public/application/models/settings/index.d.ts @@ -0,0 +1,7 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const Settings: any; diff --git a/x-pack/plugins/watcher/public/application/models/visualize_options/index.d.ts b/x-pack/plugins/watcher/public/application/models/visualize_options/index.d.ts new file mode 100644 index 0000000000000..cea10ff1e1046 --- /dev/null +++ b/x-pack/plugins/watcher/public/application/models/visualize_options/index.d.ts @@ -0,0 +1,7 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const VisualizeOptions: any; diff --git a/x-pack/plugins/watcher/public/application/models/watch/index.d.ts b/x-pack/plugins/watcher/public/application/models/watch/index.d.ts new file mode 100644 index 0000000000000..73ee2279d3912 --- /dev/null +++ b/x-pack/plugins/watcher/public/application/models/watch/index.d.ts @@ -0,0 +1,7 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const Watch: any; diff --git a/x-pack/plugins/watcher/public/application/models/watch/json_watch.d.ts b/x-pack/plugins/watcher/public/application/models/watch/json_watch.d.ts new file mode 100644 index 0000000000000..cef21880e6346 --- /dev/null +++ b/x-pack/plugins/watcher/public/application/models/watch/json_watch.d.ts @@ -0,0 +1,7 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const JsonWatch: any; diff --git a/x-pack/plugins/watcher/public/application/models/watch/threshold_watch.d.ts b/x-pack/plugins/watcher/public/application/models/watch/threshold_watch.d.ts new file mode 100644 index 0000000000000..ae85ae01304d6 --- /dev/null +++ b/x-pack/plugins/watcher/public/application/models/watch/threshold_watch.d.ts @@ -0,0 +1,7 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const ThresholdWatch: any; diff --git a/x-pack/plugins/watcher/public/application/models/watch_history_item/index.d.ts b/x-pack/plugins/watcher/public/application/models/watch_history_item/index.d.ts new file mode 100644 index 0000000000000..48fe71e2c55c0 --- /dev/null +++ b/x-pack/plugins/watcher/public/application/models/watch_history_item/index.d.ts @@ -0,0 +1,7 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const WatchHistoryItem: any; diff --git a/x-pack/plugins/watcher/public/application/models/watch_status/index.d.ts b/x-pack/plugins/watcher/public/application/models/watch_status/index.d.ts new file mode 100644 index 0000000000000..f8ff688961299 --- /dev/null +++ b/x-pack/plugins/watcher/public/application/models/watch_status/index.d.ts @@ -0,0 +1,7 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const WatchStatus: any; diff --git a/x-pack/plugins/watcher/public/application/sections/watch_edit/components/json_watch_edit/json_watch_edit.tsx b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/json_watch_edit/json_watch_edit.tsx index aac51021bad3f..b87fc355c3ead 100644 --- a/x-pack/plugins/watcher/public/application/sections/watch_edit/components/json_watch_edit/json_watch_edit.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/json_watch_edit/json_watch_edit.tsx @@ -16,7 +16,7 @@ import { EuiTitle, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { ExecuteDetails } from 'plugins/watcher/np_ready/application/models/execute_details/execute_details'; +import { ExecuteDetails } from '../../../../models/execute_details'; import { getActionType } from '../../../../../../common/lib/get_action_type'; import { BaseWatch, ExecutedWatchDetails } from '../../../../../../common/types/watch_types'; import { ACTION_MODES, TIME_UNITS } from '../../../../../../common/constants'; diff --git a/x-pack/plugins/watcher/public/application/sections/watch_edit/components/json_watch_edit/json_watch_edit_simulate.tsx b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/json_watch_edit/json_watch_edit_simulate.tsx index 5a1cc62639ea0..8bb1770d2f44d 100644 --- a/x-pack/plugins/watcher/public/application/sections/watch_edit/components/json_watch_edit/json_watch_edit_simulate.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/json_watch_edit/json_watch_edit_simulate.tsx @@ -24,9 +24,11 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import { ExecuteDetails } from 'plugins/watcher/np_ready/application/models/execute_details/execute_details'; -import { WatchHistoryItem } from 'plugins/watcher/np_ready/application/models/watch_history_item'; + +import { WatchHistoryItem } from '../../../../models/watch_history_item'; + import { ACTION_MODES, TIME_UNITS } from '../../../../../../common/constants'; +import { ExecuteDetails } from '../../../../models/execute_details'; import { ExecutedWatchDetails, ExecutedWatchResults, diff --git a/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_action_accordion.tsx b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_action_accordion.tsx index 5cc5477dfb133..36ca706ed1be2 100644 --- a/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_action_accordion.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_action_accordion.tsx @@ -21,13 +21,16 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import { ExecuteDetails } from 'plugins/watcher/np_ready/application/models/execute_details/execute_details'; -import { Action } from 'plugins/watcher/np_ready/application/models/action'; -import { WatchHistoryItem } from 'plugins/watcher/np_ready/application/models/watch_history_item'; -import { ThresholdWatch } from 'plugins/watcher/np_ready/application/models/watch/threshold_watch'; + +import { Action } from '../../../../models/action'; +import { WatchHistoryItem } from '../../../../models/watch_history_item'; +import { ThresholdWatch } from '../../../../models/watch/threshold_watch'; +import { ExecuteDetails } from '../../../../models/execute_details'; + import { ActionType } from '../../../../../../common/types/action_types'; import { ACTION_TYPES, ACTION_MODES } from '../../../../../../common/constants'; import { WatchContext } from '../../watch_context'; + import { WebhookActionFields, LoggingActionFields, diff --git a/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_action_dropdown.tsx b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_action_dropdown.tsx index a48ce7865a4f0..7a760ee58acbc 100644 --- a/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_action_dropdown.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/threshold_watch_action_dropdown.tsx @@ -16,8 +16,9 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import React, { useContext, useState } from 'react'; -import { Action } from 'plugins/watcher/np_ready/application/models/action'; import { FormattedMessage } from '@kbn/i18n/react'; + +import { Action } from '../../../../models/action'; import { ACTION_TYPES } from '../../../../../../common/constants'; import { WatchContext } from '../../watch_context'; diff --git a/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/watch_visualization.tsx b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/watch_visualization.tsx index 84bb8546fad17..7ce206716367e 100644 --- a/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/watch_visualization.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/watch_visualization.tsx @@ -20,8 +20,9 @@ import moment from 'moment-timezone'; import { IUiSettingsClient } from 'kibana/public'; import { EuiCallOut, EuiLoadingChart, EuiSpacer, EuiEmptyPrompt, EuiText } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; -import { VisualizeOptions } from 'plugins/watcher/np_ready/application/models/visualize_options'; -import { ThresholdWatch } from 'plugins/watcher/np_ready/application/models/watch/threshold_watch'; + +import { VisualizeOptions } from '../../../../models/visualize_options'; +import { ThresholdWatch } from '../../../../models/watch/threshold_watch'; import { useGetWatchVisualizationData } from '../../../../lib/api'; import { WatchContext } from '../../watch_context'; @@ -85,11 +86,7 @@ const getTimeBuckets = (watch: any, timeBuckets: any) => { }; export const WatchVisualization = () => { - const { - legacy: { TimeBuckets }, - euiUtils, - uiSettings, - } = useAppContext(); + const { TimeBuckets, euiUtils, uiSettings, data } = useAppContext(); const { watch } = useContext(WatchContext); const chartsTheme = euiUtils.useChartsTheme(); const { @@ -109,7 +106,7 @@ export const WatchVisualization = () => { } = watch; const domain = getDomain(watch); - const timeBuckets = new TimeBuckets(); + const timeBuckets = new TimeBuckets(uiSettings, data); timeBuckets.setBounds(domain); const interval = timeBuckets.getInterval().expression; const visualizeOptions = new VisualizeOptions({ @@ -196,8 +193,8 @@ export const WatchVisualization = () => { const actualThreshold = getThreshold(watch); let maxY = actualThreshold[actualThreshold.length - 1]; - (Object.values(watchVisualizationData) as number[][][]).forEach(data => { - data.forEach(([, y]) => { + (Object.values(watchVisualizationData) as number[][][]).forEach(watchData => { + watchData.forEach(([, y]) => { if (y > maxY) { maxY = y; } @@ -206,7 +203,7 @@ export const WatchVisualization = () => { const dateFormatter = (d: number) => { return moment(d) .tz(timezone) - .format(getTimeBuckets(watch, new TimeBuckets()).getScaledDateFormat()); + .format(getTimeBuckets(watch, new TimeBuckets(uiSettings, data)).getScaledDateFormat()); }; const aggLabel = aggTypes[watch.aggType].text; return ( diff --git a/x-pack/plugins/watcher/public/application/sections/watch_edit/components/watch_edit.tsx b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/watch_edit.tsx index 3410414c48eac..59a6079d74b42 100644 --- a/x-pack/plugins/watcher/public/application/sections/watch_edit/components/watch_edit.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/watch_edit.tsx @@ -10,8 +10,8 @@ import { isEqual } from 'lodash'; import { EuiPageContent } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { Watch } from 'plugins/watcher/np_ready/application/models/watch'; import { FormattedMessage } from '@kbn/i18n/react'; +import { Watch } from '../../../models/watch'; import { WATCH_TYPES } from '../../../../../common/constants'; import { BaseWatch } from '../../../../../common/types/watch_types'; import { getPageErrorCode, PageError, SectionLoading, SectionError } from '../../../components'; @@ -96,10 +96,7 @@ export const WatchEdit = ({ }; }) => { // hooks - const { - legacy: { MANAGEMENT_BREADCRUMB }, - chrome, - } = useAppContext(); + const { MANAGEMENT_BREADCRUMB, chrome } = useAppContext(); const [{ watch, loadError }, dispatch] = useReducer(watchReducer, { watch: null }); const setWatchProperty = (property: string, value: any) => { diff --git a/x-pack/plugins/watcher/public/application/sections/watch_list/components/watch_list.tsx b/x-pack/plugins/watcher/public/application/sections/watch_list/components/watch_list.tsx index 011bc3d8a8fbb..9f6a8ddbc843e 100644 --- a/x-pack/plugins/watcher/public/application/sections/watch_list/components/watch_list.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_list/components/watch_list.tsx @@ -47,7 +47,7 @@ export const WatchList = () => { // hooks const { chrome, - legacy: { MANAGEMENT_BREADCRUMB }, + MANAGEMENT_BREADCRUMB, links: { watcherGettingStartedUrl }, } = useAppContext(); const [selection, setSelection] = useState([]); diff --git a/x-pack/plugins/watcher/public/application/sections/watch_status/components/watch_status.tsx b/x-pack/plugins/watcher/public/application/sections/watch_status/components/watch_status.tsx index 53817c23e72eb..b15c047d06f67 100644 --- a/x-pack/plugins/watcher/public/application/sections/watch_status/components/watch_status.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_status/components/watch_status.tsx @@ -67,11 +67,7 @@ export const WatchStatus = ({ }; }; }) => { - const { - chrome, - legacy: { MANAGEMENT_BREADCRUMB }, - toasts, - } = useAppContext(); + const { chrome, MANAGEMENT_BREADCRUMB, toasts } = useAppContext(); const { error: watchDetailError, data: watchDetail, diff --git a/x-pack/plugins/watcher/public/legacy/calc_auto_interval.ts b/x-pack/plugins/watcher/public/legacy/calc_auto_interval.ts new file mode 100644 index 0000000000000..c910f1e6752d4 --- /dev/null +++ b/x-pack/plugins/watcher/public/legacy/calc_auto_interval.ts @@ -0,0 +1,132 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import moment from 'moment'; + +const boundsDescending = [ + { + bound: Infinity, + interval: Number(moment.duration(1, 'year')), + }, + { + bound: Number(moment.duration(1, 'year')), + interval: Number(moment.duration(1, 'month')), + }, + { + bound: Number(moment.duration(3, 'week')), + interval: Number(moment.duration(1, 'week')), + }, + { + bound: Number(moment.duration(1, 'week')), + interval: Number(moment.duration(1, 'd')), + }, + { + bound: Number(moment.duration(24, 'hour')), + interval: Number(moment.duration(12, 'hour')), + }, + { + bound: Number(moment.duration(6, 'hour')), + interval: Number(moment.duration(3, 'hour')), + }, + { + bound: Number(moment.duration(2, 'hour')), + interval: Number(moment.duration(1, 'hour')), + }, + { + bound: Number(moment.duration(45, 'minute')), + interval: Number(moment.duration(30, 'minute')), + }, + { + bound: Number(moment.duration(20, 'minute')), + interval: Number(moment.duration(10, 'minute')), + }, + { + bound: Number(moment.duration(9, 'minute')), + interval: Number(moment.duration(5, 'minute')), + }, + { + bound: Number(moment.duration(3, 'minute')), + interval: Number(moment.duration(1, 'minute')), + }, + { + bound: Number(moment.duration(45, 'second')), + interval: Number(moment.duration(30, 'second')), + }, + { + bound: Number(moment.duration(15, 'second')), + interval: Number(moment.duration(10, 'second')), + }, + { + bound: Number(moment.duration(7.5, 'second')), + interval: Number(moment.duration(5, 'second')), + }, + { + bound: Number(moment.duration(5, 'second')), + interval: Number(moment.duration(1, 'second')), + }, + { + bound: Number(moment.duration(500, 'ms')), + interval: Number(moment.duration(100, 'ms')), + }, +]; + +function getPerBucketMs(count: number, duration: number) { + const ms = duration / count; + return isFinite(ms) ? ms : NaN; +} + +function normalizeMinimumInterval(targetMs: number) { + const value = isNaN(targetMs) ? 0 : Math.max(Math.floor(targetMs), 1); + return moment.duration(value); +} + +/** + * Using some simple rules we pick a "pretty" interval that will + * produce around the number of buckets desired given a time range. + * + * @param targetBucketCount desired number of buckets + * @param duration time range the agg covers + */ +export function calcAutoIntervalNear(targetBucketCount: number, duration: number) { + const targetPerBucketMs = getPerBucketMs(targetBucketCount, duration); + + // Find the first bound which is smaller than our target. + const lowerBoundIndex = boundsDescending.findIndex(({ bound }) => { + const boundMs = Number(bound); + return boundMs <= targetPerBucketMs; + }); + + // The bound immediately preceeding that lower bound contains the + // interval most closely matching our target. + if (lowerBoundIndex !== -1) { + const nearestInterval = boundsDescending[lowerBoundIndex - 1].interval; + return moment.duration(nearestInterval); + } + + // If the target is smaller than any of our bounds, then we'll use it for the interval as-is. + return normalizeMinimumInterval(targetPerBucketMs); +} + +/** + * Pick a "pretty" interval that produces no more than the maxBucketCount + * for the given time range. + * + * @param maxBucketCount maximum number of buckets to create + * @param duration amount of time covered by the agg + */ +export function calcAutoIntervalLessThan(maxBucketCount: number, duration: number) { + const maxPerBucketMs = getPerBucketMs(maxBucketCount, duration); + + for (const { interval } of boundsDescending) { + // Find the highest interval which meets our per bucket limitation. + if (interval <= maxPerBucketMs) { + return moment.duration(interval); + } + } + + // If the max is smaller than any of our intervals, then we'll use it for the interval as-is. + return normalizeMinimumInterval(maxPerBucketMs); +} diff --git a/x-pack/plugins/watcher/public/legacy/calc_es_interval.js b/x-pack/plugins/watcher/public/legacy/calc_es_interval.js new file mode 100644 index 0000000000000..234fb67772fef --- /dev/null +++ b/x-pack/plugins/watcher/public/legacy/calc_es_interval.js @@ -0,0 +1,58 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import dateMath from '@elastic/datemath'; + +import { parseEsInterval } from './index'; + +const unitsDesc = dateMath.unitsDesc; +const largeMax = unitsDesc.indexOf('M'); + +/** + * Convert a moment.duration into an es + * compatible expression, and provide + * associated metadata + * + * @param {moment.duration} duration + * @return {object} + */ +export function convertDurationToNormalizedEsInterval(duration) { + for (let i = 0; i < unitsDesc.length; i++) { + const unit = unitsDesc[i]; + const val = duration.as(unit); + // find a unit that rounds neatly + if (val >= 1 && Math.floor(val) === val) { + // if the unit is "large", like years, but + // isn't set to 1 ES will puke. So keep going until + // we get out of the "large" units + if (i <= largeMax && val !== 1) { + continue; + } + + return { + value: val, + unit: unit, + expression: val + unit, + }; + } + } + + const ms = duration.as('ms'); + return { + value: ms, + unit: 'ms', + expression: ms + 'ms', + }; +} + +export function convertIntervalToEsInterval(interval) { + const { value, unit } = parseEsInterval(interval); + return { + value, + unit, + expression: interval, + }; +} diff --git a/x-pack/plugins/watcher/public/legacy/index.d.ts b/x-pack/plugins/watcher/public/legacy/index.d.ts new file mode 100644 index 0000000000000..5cd297038f642 --- /dev/null +++ b/x-pack/plugins/watcher/public/legacy/index.d.ts @@ -0,0 +1,8 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const TimeBuckets: any; +export const MANAGEMENT_BREADCRUMB: { text: string; href?: string }; diff --git a/x-pack/plugins/watcher/public/legacy/index.ts b/x-pack/plugins/watcher/public/legacy/index.ts new file mode 100644 index 0000000000000..97b07991ea3c5 --- /dev/null +++ b/x-pack/plugins/watcher/public/legacy/index.ts @@ -0,0 +1,15 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { i18n } from '@kbn/i18n'; + +export { TimeBuckets } from './time_buckets'; + +export const MANAGEMENT_BREADCRUMB = Object.freeze({ + text: i18n.translate('common.ui.management.breadcrumb', { + defaultMessage: 'Management', + }), + href: '#/management', +}); diff --git a/x-pack/plugins/watcher/public/legacy/parse_es_interval/index.ts b/x-pack/plugins/watcher/public/legacy/parse_es_interval/index.ts new file mode 100644 index 0000000000000..6c8e29211078c --- /dev/null +++ b/x-pack/plugins/watcher/public/legacy/parse_es_interval/index.ts @@ -0,0 +1,10 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export { parseEsInterval, ParsedInterval } from './parse_es_interval'; +export { InvalidEsCalendarIntervalError } from './invalid_es_calendar_interval_error'; +export { InvalidEsIntervalFormatError } from './invalid_es_interval_format_error'; +export { isValidEsInterval } from './is_valid_es_interval'; diff --git a/x-pack/plugins/watcher/public/legacy/parse_es_interval/invalid_es_calendar_interval_error.ts b/x-pack/plugins/watcher/public/legacy/parse_es_interval/invalid_es_calendar_interval_error.ts new file mode 100644 index 0000000000000..504442ba0e215 --- /dev/null +++ b/x-pack/plugins/watcher/public/legacy/parse_es_interval/invalid_es_calendar_interval_error.ts @@ -0,0 +1,39 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { Unit } from '@elastic/datemath'; +import { i18n } from '@kbn/i18n'; + +export class InvalidEsCalendarIntervalError extends Error { + constructor( + public readonly interval: string, + public readonly value: number, + public readonly unit: Unit, + public readonly type: string + ) { + super( + i18n.translate('data.parseEsInterval.invalidEsCalendarIntervalErrorMessage', { + defaultMessage: 'Invalid calendar interval: {interval}, value must be 1', + values: { interval }, + }) + ); + + this.name = 'InvalidEsCalendarIntervalError'; + this.value = value; + this.unit = unit; + this.type = type; + + // captureStackTrace is only available in the V8 engine, so any browser using + // a different JS engine won't have access to this method. + if (Error.captureStackTrace) { + Error.captureStackTrace(this, InvalidEsCalendarIntervalError); + } + + // Babel doesn't support traditional `extends` syntax for built-in classes. + // https://babeljs.io/docs/en/caveats/#classes + Object.setPrototypeOf(this, InvalidEsCalendarIntervalError.prototype); + } +} diff --git a/x-pack/plugins/watcher/public/legacy/parse_es_interval/invalid_es_interval_format_error.ts b/x-pack/plugins/watcher/public/legacy/parse_es_interval/invalid_es_interval_format_error.ts new file mode 100644 index 0000000000000..b10b13516fc46 --- /dev/null +++ b/x-pack/plugins/watcher/public/legacy/parse_es_interval/invalid_es_interval_format_error.ts @@ -0,0 +1,30 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { i18n } from '@kbn/i18n'; + +export class InvalidEsIntervalFormatError extends Error { + constructor(public readonly interval: string) { + super( + i18n.translate('data.parseEsInterval.invalidEsIntervalFormatErrorMessage', { + defaultMessage: 'Invalid interval format: {interval}', + values: { interval }, + }) + ); + + this.name = 'InvalidEsIntervalFormatError'; + + // captureStackTrace is only available in the V8 engine, so any browser using + // a different JS engine won't have access to this method. + if (Error.captureStackTrace) { + Error.captureStackTrace(this, InvalidEsIntervalFormatError); + } + + // Babel doesn't support traditional `extends` syntax for built-in classes. + // https://babeljs.io/docs/en/caveats/#classes + Object.setPrototypeOf(this, InvalidEsIntervalFormatError.prototype); + } +} diff --git a/x-pack/plugins/watcher/public/legacy/parse_es_interval/is_valid_es_interval.ts b/x-pack/plugins/watcher/public/legacy/parse_es_interval/is_valid_es_interval.ts new file mode 100644 index 0000000000000..1bdb65740409a --- /dev/null +++ b/x-pack/plugins/watcher/public/legacy/parse_es_interval/is_valid_es_interval.ts @@ -0,0 +1,25 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { parseEsInterval } from './parse_es_interval'; + +/** + * Checks whether a given interval string (e.g. 1w, 24h, ...) is a valid Elasticsearch interval. + * Will return false if the interval is not valid in Elasticsearch, otherwise true. + * Invalid intervals might be: 2f, since there is no unit 'f'; 2w, since weeks and month intervals + * are only allowed with a value of 1, etc. + * + * @param interval The interval string like 1w, 24h + * @returns True if the interval is valid for Elasticsearch + */ +export function isValidEsInterval(interval: string): boolean { + try { + parseEsInterval(interval); + return true; + } catch { + return false; + } +} diff --git a/x-pack/plugins/watcher/public/legacy/parse_es_interval/parse_es_interval.test.ts b/x-pack/plugins/watcher/public/legacy/parse_es_interval/parse_es_interval.test.ts new file mode 100644 index 0000000000000..76de807101559 --- /dev/null +++ b/x-pack/plugins/watcher/public/legacy/parse_es_interval/parse_es_interval.test.ts @@ -0,0 +1,56 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { InvalidEsCalendarIntervalError } from './invalid_es_calendar_interval_error'; +import { InvalidEsIntervalFormatError } from './invalid_es_interval_format_error'; +import { parseEsInterval } from './parse_es_interval'; + +describe('parseEsInterval', () => { + it('should correctly parse an interval containing unit and single value', () => { + expect(parseEsInterval('1ms')).toEqual({ value: 1, unit: 'ms', type: 'fixed' }); + expect(parseEsInterval('1s')).toEqual({ value: 1, unit: 's', type: 'fixed' }); + expect(parseEsInterval('1m')).toEqual({ value: 1, unit: 'm', type: 'calendar' }); + expect(parseEsInterval('1h')).toEqual({ value: 1, unit: 'h', type: 'calendar' }); + expect(parseEsInterval('1d')).toEqual({ value: 1, unit: 'd', type: 'calendar' }); + expect(parseEsInterval('1w')).toEqual({ value: 1, unit: 'w', type: 'calendar' }); + expect(parseEsInterval('1M')).toEqual({ value: 1, unit: 'M', type: 'calendar' }); + expect(parseEsInterval('1y')).toEqual({ value: 1, unit: 'y', type: 'calendar' }); + }); + + it('should correctly parse an interval containing unit and multiple value', () => { + expect(parseEsInterval('250ms')).toEqual({ value: 250, unit: 'ms', type: 'fixed' }); + expect(parseEsInterval('90s')).toEqual({ value: 90, unit: 's', type: 'fixed' }); + expect(parseEsInterval('60m')).toEqual({ value: 60, unit: 'm', type: 'fixed' }); + expect(parseEsInterval('12h')).toEqual({ value: 12, unit: 'h', type: 'fixed' }); + expect(parseEsInterval('7d')).toEqual({ value: 7, unit: 'd', type: 'fixed' }); + }); + + it('should throw a InvalidEsCalendarIntervalError for intervals containing calendar unit and multiple value', () => { + const intervals = ['4w', '12M', '10y']; + expect.assertions(intervals.length); + + intervals.forEach(interval => { + try { + parseEsInterval(interval); + } catch (error) { + expect(error instanceof InvalidEsCalendarIntervalError).toBe(true); + } + }); + }); + + it('should throw a InvalidEsIntervalFormatError for invalid interval formats', () => { + const intervals = ['1', 'h', '0m', '0.5h']; + expect.assertions(intervals.length); + + intervals.forEach(interval => { + try { + parseEsInterval(interval); + } catch (error) { + expect(error instanceof InvalidEsIntervalFormatError).toBe(true); + } + }); + }); +}); diff --git a/x-pack/plugins/watcher/public/legacy/parse_es_interval/parse_es_interval.ts b/x-pack/plugins/watcher/public/legacy/parse_es_interval/parse_es_interval.ts new file mode 100644 index 0000000000000..19ac03da03411 --- /dev/null +++ b/x-pack/plugins/watcher/public/legacy/parse_es_interval/parse_es_interval.ts @@ -0,0 +1,62 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import dateMath, { Unit } from '@elastic/datemath'; + +import { InvalidEsCalendarIntervalError } from './invalid_es_calendar_interval_error'; +import { InvalidEsIntervalFormatError } from './invalid_es_interval_format_error'; + +const ES_INTERVAL_STRING_REGEX = new RegExp( + '^([1-9][0-9]*)\\s*(' + dateMath.units.join('|') + ')$' +); + +export type ParsedInterval = ReturnType; + +/** + * Extracts interval properties from an ES interval string. Disallows unrecognized interval formats + * and fractional values. Converts some intervals from "calendar" to "fixed" when the number of + * units is larger than 1, and throws an error for others. + * + * Conversion rules: + * + * | Interval | Single unit type | Multiple units type | + * | -------- | ---------------- | ------------------- | + * | ms | fixed | fixed | + * | s | fixed | fixed | + * | m | calendar | fixed | + * | h | calendar | fixed | + * | d | calendar | fixed | + * | w | calendar | N/A - disallowed | + * | M | calendar | N/A - disallowed | + * | y | calendar | N/A - disallowed | + * + */ +export function parseEsInterval(interval: string) { + const matches = String(interval) + .trim() + .match(ES_INTERVAL_STRING_REGEX); + + if (!matches) { + throw new InvalidEsIntervalFormatError(interval); + } + + const value = parseFloat(matches[1]); + const unit = matches[2] as Unit; + const type = dateMath.unitsMap[unit].type; + + if (type === 'calendar' && value !== 1) { + throw new InvalidEsCalendarIntervalError(interval, value, unit, type); + } + + return { + value, + unit, + type: + (type === 'mixed' && value === 1) || type === 'calendar' + ? ('calendar' as 'calendar') + : ('fixed' as 'fixed'), + }; +} diff --git a/x-pack/plugins/watcher/public/legacy/time_buckets.js b/x-pack/plugins/watcher/public/legacy/time_buckets.js new file mode 100644 index 0000000000000..8b7e4be784fe7 --- /dev/null +++ b/x-pack/plugins/watcher/public/legacy/time_buckets.js @@ -0,0 +1,397 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import _ from 'lodash'; +import moment from 'moment'; +import { parseInterval, FIELD_FORMAT_IDS } from '../../../../../src/plugins/data/public'; +import { calcAutoIntervalLessThan, calcAutoIntervalNear } from './calc_auto_interval'; +import { + convertDurationToNormalizedEsInterval, + convertIntervalToEsInterval, +} from './calc_es_interval'; + +function isValidMoment(m) { + return m && 'isValid' in m && m.isValid(); +} + +/** + * Helper class for wrapping the concept of an "Interval", + * which describes a timespan that will separate moments. + * + * @param {state} object - one of "" + * @param {[type]} display [description] + */ +function TimeBuckets(uiSettings, data) { + this.data = data; + this.getConfig = (...args) => uiSettings.get(...args); + return TimeBuckets.__cached__(this); +} + +/**** + * PUBLIC API + ****/ + +/** + * Set the bounds that these buckets are expected to cover. + * This is required to support interval "auto" as well + * as interval scaling. + * + * @param {object} input - an object with properties min and max, + * representing the edges for the time span + * we should cover + * + * @returns {undefined} + */ +TimeBuckets.prototype.setBounds = function(input) { + if (!input) return this.clearBounds(); + + let bounds; + if (_.isPlainObject(input)) { + // accept the response from timefilter.getActiveBounds() + bounds = [input.min, input.max]; + } else { + bounds = Array.isArray(input) ? input : []; + } + + const moments = _(bounds) + .map(_.ary(moment, 1)) + .sortBy(Number); + + const valid = moments.size() === 2 && moments.every(isValidMoment); + if (!valid) { + this.clearBounds(); + throw new Error('invalid bounds set: ' + input); + } + + this._lb = moments.shift(); + this._ub = moments.pop(); + if (this.getDuration().asSeconds() < 0) { + throw new TypeError('Intervals must be positive'); + } +}; + +/** + * Clear the stored bounds + * + * @return {undefined} + */ +TimeBuckets.prototype.clearBounds = function() { + this._lb = this._ub = null; +}; + +/** + * Check to see if we have received bounds yet + * + * @return {Boolean} + */ +TimeBuckets.prototype.hasBounds = function() { + return isValidMoment(this._ub) && isValidMoment(this._lb); +}; + +/** + * Return the current bounds, if we have any. + * + * THIS DOES NOT CLONE THE BOUNDS, so editing them + * may have unexpected side-effects. Always + * call bounds.min.clone() before editing + * + * @return {object|undefined} - If bounds are not defined, this + * returns undefined, else it returns the bounds + * for these buckets. This object has two props, + * min and max. Each property will be a moment() + * object + * + */ +TimeBuckets.prototype.getBounds = function() { + if (!this.hasBounds()) return; + return { + min: this._lb, + max: this._ub, + }; +}; + +/** + * Get a moment duration object representing + * the distance between the bounds, if the bounds + * are set. + * + * @return {moment.duration|undefined} + */ +TimeBuckets.prototype.getDuration = function() { + if (!this.hasBounds()) return; + return moment.duration(this._ub - this._lb, 'ms'); +}; + +/** + * Update the interval at which buckets should be + * generated. + * + * Input can be one of the following: + * - Any object from src/legacy/ui/agg_types/buckets/_interval_options.js + * - "auto" + * - Pass a valid moment unit + * - a moment.duration object. + * + * @param {object|string|moment.duration} input - see desc + */ +TimeBuckets.prototype.setInterval = function(input) { + // Preserve the original units because they're lost when the interval is converted to a + // moment duration object. + this.originalInterval = input; + + let interval = input; + + // selection object -> val + if (_.isObject(input)) { + interval = input.val; + } + + if (!interval || interval === 'auto') { + this._i = 'auto'; + return; + } + + if (_.isString(interval)) { + input = interval; + interval = parseInterval(interval); + if (+interval === 0) { + interval = null; + } + } + + // if the value wasn't converted to a duration, and isn't + // already a duration, we have a problem + if (!moment.isDuration(interval)) { + throw new TypeError('"' + input + '" is not a valid interval.'); + } + + this._i = interval; +}; + +/** + * Get the interval for the buckets. If the + * number of buckets created by the interval set + * is larger than config:histogram:maxBars then the + * interval will be scaled up. If the number of buckets + * created is less than one, the interval is scaled back. + * + * The interval object returned is a moment.duration + * object that has been decorated with the following + * properties. + * + * interval.description: a text description of the interval. + * designed to be used list "field per {{ desc }}". + * - "minute" + * - "10 days" + * - "3 years" + * + * interval.expr: the elasticsearch expression that creates this + * interval. If the interval does not properly form an elasticsearch + * expression it will be forced into one. + * + * interval.scaled: the interval was adjusted to + * accommodate the maxBars setting. + * + * interval.scale: the number that y-values should be + * multiplied by + * + * interval.scaleDescription: a description that reflects + * the values which will be produced by using the + * interval.scale. + * + * + * @return {[type]} [description] + */ +TimeBuckets.prototype.getInterval = function(useNormalizedEsInterval = true) { + const self = this; + const duration = self.getDuration(); + const parsedInterval = readInterval(); + + if (useNormalizedEsInterval) { + return decorateInterval(maybeScaleInterval(parsedInterval)); + } else { + return decorateInterval(parsedInterval); + } + + // either pull the interval from state or calculate the auto-interval + function readInterval() { + const interval = self._i; + if (moment.isDuration(interval)) return interval; + return calcAutoIntervalNear(self.getConfig('histogram:barTarget'), Number(duration)); + } + + // check to see if the interval should be scaled, and scale it if so + function maybeScaleInterval(interval) { + if (!self.hasBounds()) return interval; + + const maxLength = self.getConfig('histogram:maxBars'); + const approxLen = duration / interval; + let scaled; + + if (approxLen > maxLength) { + scaled = calcAutoIntervalLessThan(maxLength, Number(duration)); + } else { + return interval; + } + + if (+scaled === +interval) return interval; + + decorateInterval(interval); + return _.assign(scaled, { + preScaled: interval, + scale: interval / scaled, + scaled: true, + }); + } + + // append some TimeBuckets specific props to the interval + function decorateInterval(interval) { + const esInterval = useNormalizedEsInterval + ? convertDurationToNormalizedEsInterval(interval) + : convertIntervalToEsInterval(self.originalInterval); + interval.esValue = esInterval.value; + interval.esUnit = esInterval.unit; + interval.expression = esInterval.expression; + interval.overflow = duration > interval ? moment.duration(interval - duration) : false; + + const prettyUnits = moment.normalizeUnits(esInterval.unit); + if (esInterval.value === 1) { + interval.description = prettyUnits; + } else { + interval.description = esInterval.value + ' ' + prettyUnits + 's'; + } + + return interval; + } +}; + +/** + * Get a date format string that will represent dates that + * progress at our interval. + * + * Since our interval can be as small as 1ms, the default + * date format is usually way too much. with `dateFormat:scaled` + * users can modify how dates are formatted within series + * produced by TimeBuckets + * + * @return {string} + */ +TimeBuckets.prototype.getScaledDateFormat = function() { + const interval = this.getInterval(); + const rules = this.getConfig('dateFormat:scaled'); + + for (let i = rules.length - 1; i >= 0; i--) { + const rule = rules[i]; + if (!rule[0] || interval >= moment.duration(rule[0])) { + return rule[1]; + } + } + + return this.getConfig('dateFormat'); +}; + +TimeBuckets.prototype.getScaledDateFormatter = function() { + const fieldFormats = this.data.fieldFormats; + const DateFieldFormat = fieldFormats.getType(FIELD_FORMAT_IDS.DATE); + + return new DateFieldFormat( + { + pattern: this.getScaledDateFormat(), + }, + this.getConfig.bind(this) + ); +}; + +TimeBuckets.__cached__ = function(self) { + let cache = {}; + const sameMoment = same(moment.isMoment); + const sameDuration = same(moment.isDuration); + + const desc = { + __cached__: { + value: self, + }, + }; + + const breakers = { + setBounds: 'bounds', + clearBounds: 'bounds', + setInterval: 'interval', + }; + + const resources = { + bounds: { + setup: function() { + return [self._lb, self._ub]; + }, + changes: function(prev) { + return !sameMoment(prev[0], self._lb) || !sameMoment(prev[1], self._ub); + }, + }, + interval: { + setup: function() { + return self._i; + }, + changes: function(prev) { + return !sameDuration(prev, this._i); + }, + }, + }; + + function cachedGetter(prop) { + return { + value: function cachedGetter(...rest) { + if (cache.hasOwnProperty(prop)) { + return cache[prop]; + } + + return (cache[prop] = self[prop](...rest)); + }, + }; + } + + function cacheBreaker(prop) { + const resource = resources[breakers[prop]]; + const setup = resource.setup; + const changes = resource.changes; + const fn = self[prop]; + + return { + value: function cacheBreaker() { + const prev = setup.call(self); + const ret = fn.apply(self, arguments); + + if (changes.call(self, prev)) { + cache = {}; + } + + return ret; + }, + }; + } + + function same(checkType) { + return function(a, b) { + if (a === b) return true; + if (checkType(a) === checkType(b)) return +a === +b; + return false; + }; + } + + _.forOwn(TimeBuckets.prototype, function(fn, prop) { + if (prop[0] === '_') return; + + if (breakers.hasOwnProperty(prop)) { + desc[prop] = cacheBreaker(prop); + } else { + desc[prop] = cachedGetter(prop); + } + }); + + return Object.create(self, desc); +}; + +export { TimeBuckets }; diff --git a/x-pack/plugins/watcher/public/plugin.ts b/x-pack/plugins/watcher/public/plugin.ts index a1ef85ddb722d..da68ee27351e8 100644 --- a/x-pack/plugins/watcher/public/plugin.ts +++ b/x-pack/plugins/watcher/public/plugin.ts @@ -3,60 +3,111 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ +// import { i18n } from '@kbn/i18n'; +import { CoreSetup, Plugin, CoreStart } from 'kibana/public'; +import { TimeBuckets, MANAGEMENT_BREADCRUMB } from './legacy'; +import { PLUGIN } from '../common/constants'; +import { LICENSE_CHECK_STATE } from '../../licensing/public'; +import { Dependencies } from './types'; -import { Plugin, CoreSetup, CoreStart } from 'kibana/public'; +export class WatcherUIPlugin implements Plugin { + hasValidLicense: boolean = false; -import { LegacyDependencies } from './types'; + setup( + { application, notifications, http, uiSettings, getStartServices }: CoreSetup, + { licensing, management, data }: Dependencies + ) { + licensing.license$.subscribe(license => { + const { state } = license.check(PLUGIN.ID, PLUGIN.MINIMUM_LICENSE_REQUIRED); + this.hasValidLicense = + state === LICENSE_CHECK_STATE.Valid && license.getFeature(PLUGIN.ID).isAvailable; -interface LegacyPlugins { - __LEGACY: LegacyDependencies; -} - -export class WatcherUIPlugin implements Plugin { - /* TODO: Remove this in future. We need this at mount (setup) but it's only available on start plugins. */ - euiUtils: any = null; + if (this.hasValidLicense) { + management.sections.getSection('elasticsearch')!.registerApp({ + id: 'watcher', + title: 'Watcher', + mount: async ({ element }) => { + if (!this.hasValidLicense) { + return null; + } + const [core, plugins] = await getStartServices(); + const { chrome, i18n, docLinks, savedObjects } = core; + const { eui_utils } = plugins as any; + const { boot } = await import('./application/boot'); - setup({ application, notifications, http, uiSettings }: CoreSetup, { __LEGACY }: LegacyPlugins) { - application.register({ - id: 'watcher', - title: 'Watcher', - mount: async ( - { - core: { - docLinks, - chrome, - // Waiting for types to be updated. - // @ts-ignore - savedObjects, - i18n: { Context: I18nContext }, - }, - }, - { element } - ) => { - const euiUtils = this.euiUtils!; - const { boot } = await import('./application/boot'); - return boot({ - element, - toasts: notifications.toasts, - http, - uiSettings, - docLinks, - chrome, - euiUtils, - savedObjects: savedObjects.client, - I18nContext, - legacy: { - ...__LEGACY, + return boot({ + element, + toasts: notifications.toasts, + http, + uiSettings, + docLinks, + chrome, + euiUtils: eui_utils, + savedObjects: savedObjects.client, + I18nContext: i18n.Context, + TimeBuckets, + MANAGEMENT_BREADCRUMB, + data, + }); }, }); - }, + } + + // management.sections.getSection('elasticsearch/watcher').register('watches', { + // display: i18n.translate( + // 'xpack.watcher.sections.watchList.managementSection.watchesDisplayName', + // { + // defaultMessage: 'Watches', + // } + // ), + // order: 1, + // } as any); + // + // management.sections.getSection('elasticsearch/watcher').register('watch', { + // visible: false, + // } as any); + // + // management.sections.getSection('elasticsearch/watcher/watch').register('status', { + // display: i18n.translate( + // 'xpack.watcher.sections.watchList.managementSection.statusDisplayName', + // { + // defaultMessage: 'Status', + // } + // ), + // order: 1, + // visible: false, + // } as any); + // + // management.sections.getSection('elasticsearch/watcher/watch').register('edit', { + // display: i18n.translate( + // 'xpack.watcher.sections.watchList.managementSection.editDisplayName', + // { + // defaultMessage: 'Edit', + // } + // ), + // order: 2, + // visible: false, + // } as any); + // + // management.sections.getSection('elasticsearch/watcher/watch').register('new', { + // display: i18n.translate( + // 'xpack.watcher.sections.watchList.managementSection.newWatchDisplayName', + // { + // defaultMessage: 'New Watch', + // } + // ), + // order: 1, + // visible: false, + // } as any); + // + // management.sections.getSection('elasticsearch/watcher/watch').register('history-item', { + // order: 1, + // visible: false, + // } as any); }); } - start(core: CoreStart, { eui_utils }: any) { - // eslint-disable-next-line @typescript-eslint/camelcase - this.euiUtils = eui_utils; - } + start(core: CoreStart) {} stop() {} } diff --git a/x-pack/plugins/watcher/public/types.ts b/x-pack/plugins/watcher/public/types.ts index 22109f99c2c48..7489e00309848 100644 --- a/x-pack/plugins/watcher/public/types.ts +++ b/x-pack/plugins/watcher/public/types.ts @@ -4,8 +4,14 @@ * you may not use this file except in compliance with the Elastic License. */ -export interface LegacyDependencies { - MANAGEMENT_BREADCRUMB: { text: string; href?: string }; - TimeBuckets: any; - licenseStatus: any; +import { ManagementSetup } from 'src/plugins/management/public'; +import { EuiUtilsStart } from 'src/plugins/eui_utils/public'; +import { LicensingPluginSetup } from '../../licensing/public'; +import { DataPublicPluginSetup } from '../../../../src/plugins/data/public'; + +export interface Dependencies { + management: ManagementSetup; + licensing: LicensingPluginSetup; + eui_utils: EuiUtilsStart; + data: DataPublicPluginSetup; } diff --git a/x-pack/plugins/watcher/server/index.ts b/x-pack/plugins/watcher/server/index.ts index d70f61afb3888..51eb7bfa543fe 100644 --- a/x-pack/plugins/watcher/server/index.ts +++ b/x-pack/plugins/watcher/server/index.ts @@ -6,4 +6,4 @@ import { PluginInitializerContext } from 'kibana/server'; import { WatcherServerPlugin } from './plugin'; -export const plugin = (ctx: PluginInitializerContext) => new WatcherServerPlugin(); +export const plugin = (ctx: PluginInitializerContext) => new WatcherServerPlugin(ctx); diff --git a/x-pack/plugins/watcher/server/plugin.ts b/x-pack/plugins/watcher/server/plugin.ts index 3d8714536eaee..0540b923e4302 100644 --- a/x-pack/plugins/watcher/server/plugin.ts +++ b/x-pack/plugins/watcher/server/plugin.ts @@ -3,12 +3,11 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { Plugin, CoreSetup } from 'kibana/server'; -import { i18n } from '@kbn/i18n'; +import { CoreSetup, Logger, Plugin, PluginInitializerContext } from 'kibana/server'; import { PLUGIN } from '../common/constants'; -import { ServerShim, RouteDependencies } from './types'; +import { Dependencies, RouteDependencies } from './types'; +import { LICENSE_CHECK_STATE } from '../../licensing/server'; -import { registerLicenseChecker } from '../../../legacy/server/lib/register_license_checker'; import { registerSettingsRoutes } from './routes/api/settings'; import { registerIndicesRoutes } from './routes/api/indices'; import { registerLicenseRoutes } from './routes/api/license'; @@ -18,33 +17,48 @@ import { registerListFieldsRoute } from './routes/api/register_list_fields_route import { registerLoadHistoryRoute } from './routes/api/register_load_history_route'; export class WatcherServerPlugin implements Plugin { + log: Logger; + + constructor(ctx: PluginInitializerContext) { + this.log = ctx.logger.get(PLUGIN.ID); + } + async setup( { http, elasticsearch: elasticsearchService }: CoreSetup, - { __LEGACY: serverShim }: { __LEGACY: ServerShim } + { licensing }: Dependencies ) { - const elasticsearch = await elasticsearchService.adminClient; - const router = http.createRouter(); - const routeDependencies: RouteDependencies = { - elasticsearch, - elasticsearchService, - router, - }; - - // Register license checker - registerLicenseChecker( - serverShim as any, - PLUGIN.ID, - PLUGIN.getI18nName(i18n), - PLUGIN.MINIMUM_LICENSE_REQUIRED - ); + licensing.license$.subscribe(async license => { + const { state, message } = license.check(PLUGIN.ID, PLUGIN.MINIMUM_LICENSE_REQUIRED); + const hasMinimumLicense = state === LICENSE_CHECK_STATE.Valid; + if (hasMinimumLicense && license.getFeature(PLUGIN.ID)) { + try { + const elasticsearch = await elasticsearchService.adminClient; + const router = http.createRouter(); + const routeDependencies: RouteDependencies = { + elasticsearch, + elasticsearchService, + router, + }; - registerListFieldsRoute(routeDependencies, serverShim); - registerLoadHistoryRoute(routeDependencies, serverShim); - registerIndicesRoutes(routeDependencies, serverShim); - registerLicenseRoutes(routeDependencies, serverShim); - registerSettingsRoutes(routeDependencies, serverShim); - registerWatchesRoutes(routeDependencies, serverShim); - registerWatchRoutes(routeDependencies, serverShim); + registerListFieldsRoute(routeDependencies); + registerLoadHistoryRoute(routeDependencies); + registerIndicesRoutes(routeDependencies); + registerLicenseRoutes(routeDependencies); + registerSettingsRoutes(routeDependencies); + registerWatchesRoutes(routeDependencies); + registerWatchRoutes(routeDependencies); + } catch (e) { + // TODO: Get back to testing why the server side crashes on license updates + // eslint-disable-next-line + console.log('here', e); + throw e; + } + } else { + if (message) { + this.log.info(message); + } + } + }); } start() {} stop() {} diff --git a/x-pack/plugins/watcher/server/routes/api/indices/register_get_route.ts b/x-pack/plugins/watcher/server/routes/api/indices/register_get_route.ts index 98ee62b44f084..250aa913d766f 100644 --- a/x-pack/plugins/watcher/server/routes/api/indices/register_get_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/indices/register_get_route.ts @@ -9,8 +9,7 @@ import { RequestHandler } from 'kibana/server'; import { reduce, size } from 'lodash'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { isEsError } from '../../../lib/is_es_error'; -import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; -import { RouteDependencies, ServerShim } from '../../../types'; +import { RouteDependencies } from '../../../types'; function getIndexNamesFromAliasesResponse(json: Record) { return reduce( @@ -61,7 +60,7 @@ function getIndices(callWithRequest: any, pattern: string, limit = 10) { }); } -export function registerGetRoute(deps: RouteDependencies, legacy: ServerShim) { +export function registerGetRoute(deps: RouteDependencies) { const handler: RequestHandler = async (ctx, request, response) => { const callWithRequest = callWithRequestFactory(deps.elasticsearchService, request); const { pattern } = request.body; @@ -87,6 +86,6 @@ export function registerGetRoute(deps: RouteDependencies, legacy: ServerShim) { body: schema.object({}, { allowUnknowns: true }), }, }, - licensePreRoutingFactory(legacy, handler) + handler ); } diff --git a/x-pack/plugins/watcher/server/routes/api/indices/register_indices_routes.ts b/x-pack/plugins/watcher/server/routes/api/indices/register_indices_routes.ts index 647a85c311532..db8dbdc8618d4 100644 --- a/x-pack/plugins/watcher/server/routes/api/indices/register_indices_routes.ts +++ b/x-pack/plugins/watcher/server/routes/api/indices/register_indices_routes.ts @@ -5,8 +5,8 @@ */ import { registerGetRoute } from './register_get_route'; -import { RouteDependencies, ServerShim } from '../../../types'; +import { RouteDependencies } from '../../../types'; -export function registerIndicesRoutes(deps: RouteDependencies, legacy: ServerShim) { - registerGetRoute(deps, legacy); +export function registerIndicesRoutes(deps: RouteDependencies) { + registerGetRoute(deps); } diff --git a/x-pack/plugins/watcher/server/routes/api/license/register_license_routes.ts b/x-pack/plugins/watcher/server/routes/api/license/register_license_routes.ts index c5965d9315b01..9b7f6272442bd 100644 --- a/x-pack/plugins/watcher/server/routes/api/license/register_license_routes.ts +++ b/x-pack/plugins/watcher/server/routes/api/license/register_license_routes.ts @@ -5,8 +5,8 @@ */ import { registerRefreshRoute } from './register_refresh_route'; -import { RouteDependencies, ServerShim } from '../../../types'; +import { RouteDependencies } from '../../../types'; -export function registerLicenseRoutes(deps: RouteDependencies, legacy: ServerShim) { - registerRefreshRoute(deps, legacy); +export function registerLicenseRoutes(deps: RouteDependencies) { + registerRefreshRoute(deps); } diff --git a/x-pack/plugins/watcher/server/routes/api/license/register_refresh_route.ts b/x-pack/plugins/watcher/server/routes/api/license/register_refresh_route.ts index db7c2ca9816ce..2fa3919e5e674 100644 --- a/x-pack/plugins/watcher/server/routes/api/license/register_refresh_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/license/register_refresh_route.ts @@ -5,8 +5,7 @@ */ import { RequestHandler } from 'kibana/server'; -import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; -import { RouteDependencies, ServerShim } from '../../../types'; +import { RouteDependencies } from '../../../types'; /* In order for the client to have the most up-to-date snapshot of the current license, @@ -14,7 +13,7 @@ it needs to make a round-trip to the kibana server. This refresh endpoint is pro for when the client needs to check the license, but doesn't need to pull data from the server for any reason, i.e., when adding a new watch. */ -export function registerRefreshRoute(deps: RouteDependencies, legacy: ServerShim) { +export function registerRefreshRoute(deps: RouteDependencies) { const handler: RequestHandler = (ctx, request, response) => { return response.ok({ body: { success: true } }); }; @@ -24,6 +23,6 @@ export function registerRefreshRoute(deps: RouteDependencies, legacy: ServerShim path: '/api/watcher/license/refresh', validate: false, }, - licensePreRoutingFactory(legacy, handler) + handler ); } diff --git a/x-pack/plugins/watcher/server/routes/api/register_list_fields_route.ts b/x-pack/plugins/watcher/server/routes/api/register_list_fields_route.ts index b916333307940..8276f5ba492d9 100644 --- a/x-pack/plugins/watcher/server/routes/api/register_list_fields_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/register_list_fields_route.ts @@ -8,10 +8,9 @@ import { schema } from '@kbn/config-schema'; import { RequestHandler } from 'kibana/server'; import { callWithRequestFactory } from '../../lib/call_with_request_factory'; import { isEsError } from '../../lib/is_es_error'; -import { licensePreRoutingFactory } from '../../lib/license_pre_routing_factory'; // @ts-ignore import { Fields } from '../../models/fields/index'; -import { RouteDependencies, ServerShim } from '../../types'; +import { RouteDependencies } from '../../types'; function fetchFields(callWithRequest: any, indexes: string[]) { const params = { @@ -25,7 +24,7 @@ function fetchFields(callWithRequest: any, indexes: string[]) { return callWithRequest('fieldCaps', params); } -export function registerListFieldsRoute(deps: RouteDependencies, legacy: ServerShim) { +export function registerListFieldsRoute(deps: RouteDependencies) { const handler: RequestHandler = async (ctx, request, response) => { const callWithRequest = callWithRequestFactory(deps.elasticsearchService, request); const { indexes } = request.body; @@ -60,6 +59,6 @@ export function registerListFieldsRoute(deps: RouteDependencies, legacy: ServerS }), }, }, - licensePreRoutingFactory(legacy, handler) + handler ); } diff --git a/x-pack/plugins/watcher/server/routes/api/register_load_history_route.ts b/x-pack/plugins/watcher/server/routes/api/register_load_history_route.ts index d7c2b98b45921..baa7205966523 100644 --- a/x-pack/plugins/watcher/server/routes/api/register_load_history_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/register_load_history_route.ts @@ -10,8 +10,7 @@ import { RequestHandler } from 'kibana/server'; import { callWithRequestFactory } from '../../lib/call_with_request_factory'; import { isEsError } from '../../lib/is_es_error'; import { INDEX_NAMES } from '../../../common/constants'; -import { licensePreRoutingFactory } from '../../lib/license_pre_routing_factory'; -import { RouteDependencies, ServerShim } from '../../types'; +import { RouteDependencies } from '../../types'; // @ts-ignore import { WatchHistoryItem } from '../../models/watch_history_item/index'; @@ -28,7 +27,7 @@ function fetchHistoryItem(callWithRequest: any, watchHistoryItemId: string) { }); } -export function registerLoadHistoryRoute(deps: RouteDependencies, legacy: ServerShim) { +export function registerLoadHistoryRoute(deps: RouteDependencies) { const handler: RequestHandler = async (ctx, request, response) => { const callWithRequest = callWithRequestFactory(deps.elasticsearchService, request); const id = request.params.id; @@ -72,6 +71,6 @@ export function registerLoadHistoryRoute(deps: RouteDependencies, legacy: Server }), }, }, - licensePreRoutingFactory(legacy, handler) + handler ); } diff --git a/x-pack/plugins/watcher/server/routes/api/settings/register_load_route.ts b/x-pack/plugins/watcher/server/routes/api/settings/register_load_route.ts index c4f3e87f00160..8df57b7bc8fe5 100644 --- a/x-pack/plugins/watcher/server/routes/api/settings/register_load_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/settings/register_load_route.ts @@ -6,10 +6,9 @@ import { IClusterClient, RequestHandler } from 'kibana/server'; import { isEsError } from '../../../lib/is_es_error'; -import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; // @ts-ignore import { Settings } from '../../../models/settings/index'; -import { RouteDependencies, ServerShim } from '../../../types'; +import { RouteDependencies } from '../../../types'; function fetchClusterSettings(client: IClusterClient) { return client.callAsInternalUser('cluster.getSettings', { @@ -18,7 +17,7 @@ function fetchClusterSettings(client: IClusterClient) { }); } -export function registerLoadRoute(deps: RouteDependencies, legacy: ServerShim) { +export function registerLoadRoute(deps: RouteDependencies) { const handler: RequestHandler = async (ctx, request, response) => { try { const settings = await fetchClusterSettings(deps.elasticsearch); @@ -38,6 +37,6 @@ export function registerLoadRoute(deps: RouteDependencies, legacy: ServerShim) { path: '/api/watcher/settings', validate: false, }, - licensePreRoutingFactory(legacy, handler) + handler ); } diff --git a/x-pack/plugins/watcher/server/routes/api/settings/register_settings_routes.ts b/x-pack/plugins/watcher/server/routes/api/settings/register_settings_routes.ts index 0b24ec0e90bd4..ea4aa6ea4381d 100644 --- a/x-pack/plugins/watcher/server/routes/api/settings/register_settings_routes.ts +++ b/x-pack/plugins/watcher/server/routes/api/settings/register_settings_routes.ts @@ -5,8 +5,8 @@ */ import { registerLoadRoute } from './register_load_route'; -import { RouteDependencies, ServerShim } from '../../../types'; +import { RouteDependencies } from '../../../types'; -export function registerSettingsRoutes(deps: RouteDependencies, legacy: ServerShim) { - registerLoadRoute(deps, legacy); +export function registerSettingsRoutes(deps: RouteDependencies) { + registerLoadRoute(deps); } diff --git a/x-pack/plugins/watcher/server/routes/api/watch/action/register_acknowledge_route.ts b/x-pack/plugins/watcher/server/routes/api/watch/action/register_acknowledge_route.ts index 3d7a16ab2103b..953394c12cd3f 100644 --- a/x-pack/plugins/watcher/server/routes/api/watch/action/register_acknowledge_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watch/action/register_acknowledge_route.ts @@ -9,10 +9,9 @@ import { get } from 'lodash'; import { RequestHandler } from 'kibana/server'; import { callWithRequestFactory } from '../../../../lib/call_with_request_factory'; import { isEsError } from '../../../../lib/is_es_error'; -import { licensePreRoutingFactory } from '../../../../lib/license_pre_routing_factory'; // @ts-ignore import { WatchStatus } from '../../../../models/watch_status/index'; -import { RouteDependencies, ServerShim } from '../../../../types'; +import { RouteDependencies } from '../../../../types'; function acknowledgeAction(callWithRequest: any, watchId: string, actionId: string) { return callWithRequest('watcher.ackWatch', { @@ -21,7 +20,7 @@ function acknowledgeAction(callWithRequest: any, watchId: string, actionId: stri }); } -export function registerAcknowledgeRoute(deps: RouteDependencies, legacy: ServerShim) { +export function registerAcknowledgeRoute(deps: RouteDependencies) { const handler: RequestHandler = async (ctx, request, response) => { const callWithRequest = callWithRequestFactory(deps.elasticsearchService, request); const { watchId, actionId } = request.params; @@ -60,6 +59,6 @@ export function registerAcknowledgeRoute(deps: RouteDependencies, legacy: Server }), }, }, - licensePreRoutingFactory(legacy, handler) + handler ); } diff --git a/x-pack/plugins/watcher/server/routes/api/watch/action/register_action_routes.ts b/x-pack/plugins/watcher/server/routes/api/watch/action/register_action_routes.ts index 022c844867938..c3109e1d091c1 100644 --- a/x-pack/plugins/watcher/server/routes/api/watch/action/register_action_routes.ts +++ b/x-pack/plugins/watcher/server/routes/api/watch/action/register_action_routes.ts @@ -5,8 +5,8 @@ */ import { registerAcknowledgeRoute } from './register_acknowledge_route'; -import { RouteDependencies, ServerShim } from '../../../../types'; +import { RouteDependencies } from '../../../../types'; -export function registerActionRoutes(server: RouteDependencies, legacy: ServerShim) { - registerAcknowledgeRoute(server, legacy); +export function registerActionRoutes(deps: RouteDependencies) { + registerAcknowledgeRoute(deps); } diff --git a/x-pack/plugins/watcher/server/routes/api/watch/register_activate_route.ts b/x-pack/plugins/watcher/server/routes/api/watch/register_activate_route.ts index b220d05d808c3..c915e94b2f86c 100644 --- a/x-pack/plugins/watcher/server/routes/api/watch/register_activate_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watch/register_activate_route.ts @@ -9,8 +9,7 @@ import { RequestHandler } from 'kibana/server'; import { get } from 'lodash'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { isEsError } from '../../../lib/is_es_error'; -import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; -import { RouteDependencies, ServerShim } from '../../../types'; +import { RouteDependencies } from '../../../types'; // @ts-ignore import { WatchStatus } from '../../../models/watch_status/index'; @@ -20,7 +19,7 @@ function activateWatch(callWithRequest: any, watchId: string) { }); } -export function registerActivateRoute(deps: RouteDependencies, legacy: ServerShim) { +export function registerActivateRoute(deps: RouteDependencies) { const handler: RequestHandler = async (ctx, request, response) => { const callWithRequest = callWithRequestFactory(deps.elasticsearchService, request); @@ -61,6 +60,6 @@ export function registerActivateRoute(deps: RouteDependencies, legacy: ServerShi }), }, }, - licensePreRoutingFactory(legacy, handler) + handler ); } diff --git a/x-pack/plugins/watcher/server/routes/api/watch/register_deactivate_route.ts b/x-pack/plugins/watcher/server/routes/api/watch/register_deactivate_route.ts index e0fbcb321d5f1..17df2530c0319 100644 --- a/x-pack/plugins/watcher/server/routes/api/watch/register_deactivate_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watch/register_deactivate_route.ts @@ -8,8 +8,7 @@ import { RequestHandler } from 'kibana/server'; import { get } from 'lodash'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { isEsError } from '../../../lib/is_es_error'; -import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; -import { RouteDependencies, ServerShim } from '../../../types'; +import { RouteDependencies } from '../../../types'; // @ts-ignore import { WatchStatus } from '../../../models/watch_status/index'; @@ -19,7 +18,7 @@ function deactivateWatch(callWithRequest: any, watchId: string) { }); } -export function registerDeactivateRoute(deps: RouteDependencies, legacy: ServerShim) { +export function registerDeactivateRoute(deps: RouteDependencies) { const handler: RequestHandler = async (ctx, request, response) => { const callWithRequest = callWithRequestFactory(deps.elasticsearchService, request); @@ -60,6 +59,6 @@ export function registerDeactivateRoute(deps: RouteDependencies, legacy: ServerS }), }, }, - licensePreRoutingFactory(legacy, handler) + handler ); } diff --git a/x-pack/plugins/watcher/server/routes/api/watch/register_delete_route.ts b/x-pack/plugins/watcher/server/routes/api/watch/register_delete_route.ts index 7f998aaefd9e8..0133cb0b07747 100644 --- a/x-pack/plugins/watcher/server/routes/api/watch/register_delete_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watch/register_delete_route.ts @@ -8,8 +8,7 @@ import { schema } from '@kbn/config-schema'; import { RequestHandler } from 'kibana/server'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { isEsError } from '../../../lib/is_es_error'; -import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; -import { RouteDependencies, ServerShim } from '../../../types'; +import { RouteDependencies } from '../../../types'; function deleteWatch(callWithRequest: any, watchId: string) { return callWithRequest('watcher.deleteWatch', { @@ -17,7 +16,7 @@ function deleteWatch(callWithRequest: any, watchId: string) { }); } -export function registerDeleteRoute(deps: RouteDependencies, legacy: ServerShim) { +export function registerDeleteRoute(deps: RouteDependencies) { const handler: RequestHandler = async (ctx, request, response) => { const callWithRequest = callWithRequestFactory(deps.elasticsearchService, request); @@ -47,6 +46,6 @@ export function registerDeleteRoute(deps: RouteDependencies, legacy: ServerShim) }), }, }, - licensePreRoutingFactory(legacy, handler) + handler ); } diff --git a/x-pack/plugins/watcher/server/routes/api/watch/register_execute_route.ts b/x-pack/plugins/watcher/server/routes/api/watch/register_execute_route.ts index 52e4d37d0d228..b284f197668b7 100644 --- a/x-pack/plugins/watcher/server/routes/api/watch/register_execute_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watch/register_execute_route.ts @@ -9,9 +9,8 @@ import { RequestHandler } from 'kibana/server'; import { get } from 'lodash'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { isEsError } from '../../../lib/is_es_error'; -import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; -import { RouteDependencies, ServerShim } from '../../../types'; +import { RouteDependencies } from '../../../types'; // @ts-ignore import { ExecuteDetails } from '../../../models/execute_details/index'; // @ts-ignore @@ -28,7 +27,7 @@ function executeWatch(callWithRequest: any, executeDetails: any, watchJson: any) }); } -export function registerExecuteRoute(deps: RouteDependencies, legacy: ServerShim) { +export function registerExecuteRoute(deps: RouteDependencies) { const handler: RequestHandler = async (ctx, request, response) => { const callWithRequest = callWithRequestFactory(deps.elasticsearchService, request); const executeDetails = ExecuteDetails.fromDownstreamJson(request.body.executeDetails); @@ -73,6 +72,6 @@ export function registerExecuteRoute(deps: RouteDependencies, legacy: ServerShim }), }, }, - licensePreRoutingFactory(legacy, handler) + handler ); } diff --git a/x-pack/plugins/watcher/server/routes/api/watch/register_history_route.ts b/x-pack/plugins/watcher/server/routes/api/watch/register_history_route.ts index 7bf34483373da..4f530fee124d3 100644 --- a/x-pack/plugins/watcher/server/routes/api/watch/register_history_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watch/register_history_route.ts @@ -11,8 +11,7 @@ import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { fetchAllFromScroll } from '../../../lib/fetch_all_from_scroll'; import { INDEX_NAMES, ES_SCROLL_SETTINGS } from '../../../../common/constants'; import { isEsError } from '../../../lib/is_es_error'; -import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; -import { RouteDependencies, ServerShim } from '../../../types'; +import { RouteDependencies } from '../../../types'; // @ts-ignore import { WatchHistoryItem } from '../../../models/watch_history_item/index'; @@ -42,7 +41,7 @@ function fetchHistoryItems(callWithRequest: any, watchId: any, startTime: any) { ); } -export function registerHistoryRoute(deps: RouteDependencies, legacy: ServerShim) { +export function registerHistoryRoute(deps: RouteDependencies) { const handler: RequestHandler = async (ctx, request, response) => { const callWithRequest = callWithRequestFactory(deps.elasticsearchService, request); const { watchId } = request.params; @@ -92,6 +91,6 @@ export function registerHistoryRoute(deps: RouteDependencies, legacy: ServerShim }), }, }, - licensePreRoutingFactory(legacy, handler) + handler ); } diff --git a/x-pack/plugins/watcher/server/routes/api/watch/register_load_route.ts b/x-pack/plugins/watcher/server/routes/api/watch/register_load_route.ts index 4a53bd7c28a65..57cb84448fbd3 100644 --- a/x-pack/plugins/watcher/server/routes/api/watch/register_load_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watch/register_load_route.ts @@ -9,10 +9,9 @@ import { RequestHandler } from 'kibana/server'; import { get } from 'lodash'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { isEsError } from '../../../lib/is_es_error'; -import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; // @ts-ignore import { Watch } from '../../../models/watch/index'; -import { RouteDependencies, ServerShim } from '../../../types'; +import { RouteDependencies } from '../../../types'; function fetchWatch(callWithRequest: any, watchId: string) { return callWithRequest('watcher.getWatch', { @@ -20,7 +19,7 @@ function fetchWatch(callWithRequest: any, watchId: string) { }); } -export function registerLoadRoute(deps: RouteDependencies, legacy: ServerShim) { +export function registerLoadRoute(deps: RouteDependencies) { const handler: RequestHandler = async (ctx, request, response) => { const callWithRequest = callWithRequestFactory(deps.elasticsearchService, request); @@ -64,6 +63,6 @@ export function registerLoadRoute(deps: RouteDependencies, legacy: ServerShim) { }), }, }, - licensePreRoutingFactory(legacy, handler) + handler ); } diff --git a/x-pack/plugins/watcher/server/routes/api/watch/register_save_route.ts b/x-pack/plugins/watcher/server/routes/api/watch/register_save_route.ts index 01de7332f9e6b..88c31c795426b 100644 --- a/x-pack/plugins/watcher/server/routes/api/watch/register_save_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watch/register_save_route.ts @@ -8,14 +8,10 @@ import { schema } from '@kbn/config-schema'; import { RequestHandler } from 'kibana/server'; import { i18n } from '@kbn/i18n'; import { WATCH_TYPES } from '../../../../common/constants'; -import { - serializeJsonWatch, - serializeThresholdWatch, -} from '../../../../common/lib/serialization'; +import { serializeJsonWatch, serializeThresholdWatch } from '../../../../common/lib/serialization'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { isEsError } from '../../../lib/is_es_error'; -import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; -import { RouteDependencies, ServerShim } from '../../../types'; +import { RouteDependencies } from '../../../types'; function fetchWatch(callWithRequest: any, watchId: string) { return callWithRequest('watcher.getWatch', { @@ -30,7 +26,7 @@ function saveWatch(callWithRequest: any, id: string, body: any) { }); } -export function registerSaveRoute(deps: RouteDependencies, legacy: ServerShim) { +export function registerSaveRoute(deps: RouteDependencies) { const handler: RequestHandler = async (ctx, request, response) => { const callWithRequest = callWithRequestFactory(deps.elasticsearchService, request); const { id } = request.params; @@ -99,6 +95,6 @@ export function registerSaveRoute(deps: RouteDependencies, legacy: ServerShim) { body: schema.object({}, { allowUnknowns: true }), }, }, - licensePreRoutingFactory(legacy, handler) + handler ); } diff --git a/x-pack/plugins/watcher/server/routes/api/watch/register_visualize_route.ts b/x-pack/plugins/watcher/server/routes/api/watch/register_visualize_route.ts index 34a7bb2347067..5ef571216a598 100644 --- a/x-pack/plugins/watcher/server/routes/api/watch/register_visualize_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watch/register_visualize_route.ts @@ -8,8 +8,7 @@ import { schema } from '@kbn/config-schema'; import { RequestHandler } from 'kibana/server'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { isEsError } from '../../../lib/is_es_error'; -import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; -import { RouteDependencies, ServerShim } from '../../../types'; +import { RouteDependencies } from '../../../types'; // @ts-ignore import { Watch } from '../../../models/watch/index'; @@ -28,7 +27,7 @@ function fetchVisualizeData(callWithRequest: any, index: any, body: any) { return callWithRequest('search', params); } -export function registerVisualizeRoute(deps: RouteDependencies, legacy: ServerShim) { +export function registerVisualizeRoute(deps: RouteDependencies) { const handler: RequestHandler = async (ctx, request, response) => { const callWithRequest = callWithRequestFactory(deps.elasticsearchService, request); const watch = Watch.fromDownstreamJson(request.body.watch); @@ -65,6 +64,6 @@ export function registerVisualizeRoute(deps: RouteDependencies, legacy: ServerSh }), }, }, - licensePreRoutingFactory(legacy, handler) + handler ); } diff --git a/x-pack/plugins/watcher/server/routes/api/watch/register_watch_routes.ts b/x-pack/plugins/watcher/server/routes/api/watch/register_watch_routes.ts index 5ecbf3e0d2b46..fd295ff81782c 100644 --- a/x-pack/plugins/watcher/server/routes/api/watch/register_watch_routes.ts +++ b/x-pack/plugins/watcher/server/routes/api/watch/register_watch_routes.ts @@ -13,16 +13,16 @@ import { registerActivateRoute } from './register_activate_route'; import { registerDeactivateRoute } from './register_deactivate_route'; import { registerVisualizeRoute } from './register_visualize_route'; import { registerActionRoutes } from './action'; -import { RouteDependencies, ServerShim } from '../../../types'; +import { RouteDependencies } from '../../../types'; -export function registerWatchRoutes(deps: RouteDependencies, legacy: ServerShim) { - registerDeleteRoute(deps, legacy); - registerExecuteRoute(deps, legacy); - registerLoadRoute(deps, legacy); - registerSaveRoute(deps, legacy); - registerHistoryRoute(deps, legacy); - registerActivateRoute(deps, legacy); - registerDeactivateRoute(deps, legacy); - registerActionRoutes(deps, legacy); - registerVisualizeRoute(deps, legacy); +export function registerWatchRoutes(deps: RouteDependencies) { + registerDeleteRoute(deps); + registerExecuteRoute(deps); + registerLoadRoute(deps); + registerSaveRoute(deps); + registerHistoryRoute(deps); + registerActivateRoute(deps); + registerDeactivateRoute(deps); + registerActionRoutes(deps); + registerVisualizeRoute(deps); } diff --git a/x-pack/plugins/watcher/server/routes/api/watches/register_delete_route.ts b/x-pack/plugins/watcher/server/routes/api/watches/register_delete_route.ts index 5edf8b9d6c225..6d10220843e12 100644 --- a/x-pack/plugins/watcher/server/routes/api/watches/register_delete_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watches/register_delete_route.ts @@ -7,8 +7,7 @@ import { schema } from '@kbn/config-schema'; import { RequestHandler } from 'kibana/server'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; -import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; -import { RouteDependencies, ServerShim } from '../../../types'; +import { RouteDependencies } from '../../../types'; function deleteWatches(callWithRequest: any, watchIds: string[]) { const deletePromises = watchIds.map(watchId => { @@ -37,7 +36,7 @@ function deleteWatches(callWithRequest: any, watchIds: string[]) { }); } -export function registerDeleteRoute(deps: RouteDependencies, legacy: ServerShim) { +export function registerDeleteRoute(deps: RouteDependencies) { const handler: RequestHandler = async (ctx, request, response) => { const callWithRequest = callWithRequestFactory(deps.elasticsearchService, request); @@ -58,6 +57,6 @@ export function registerDeleteRoute(deps: RouteDependencies, legacy: ServerShim) }), }, }, - licensePreRoutingFactory(legacy, handler) + handler ); } diff --git a/x-pack/plugins/watcher/server/routes/api/watches/register_list_route.ts b/x-pack/plugins/watcher/server/routes/api/watches/register_list_route.ts index f179e88b88bfb..14deeefa27760 100644 --- a/x-pack/plugins/watcher/server/routes/api/watches/register_list_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watches/register_list_route.ts @@ -10,8 +10,7 @@ import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { fetchAllFromScroll } from '../../../lib/fetch_all_from_scroll'; import { INDEX_NAMES, ES_SCROLL_SETTINGS } from '../../../../common/constants'; import { isEsError } from '../../../lib/is_es_error'; -import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; -import { RouteDependencies, ServerShim } from '../../../types'; +import { RouteDependencies } from '../../../types'; // @ts-ignore import { Watch } from '../../../models/watch/index'; @@ -30,7 +29,7 @@ function fetchWatches(callWithRequest: any) { ); } -export function registerListRoute(deps: RouteDependencies, legacy: ServerShim) { +export function registerListRoute(deps: RouteDependencies) { const handler: RequestHandler = async (ctx, request, response) => { const callWithRequest = callWithRequestFactory(deps.elasticsearchService, request); @@ -81,6 +80,6 @@ export function registerListRoute(deps: RouteDependencies, legacy: ServerShim) { path: '/api/watcher/watches', validate: false, }, - licensePreRoutingFactory(legacy, handler) + handler ); } diff --git a/x-pack/plugins/watcher/server/routes/api/watches/register_watches_routes.ts b/x-pack/plugins/watcher/server/routes/api/watches/register_watches_routes.ts index dd5f55078e591..b515b6264a544 100644 --- a/x-pack/plugins/watcher/server/routes/api/watches/register_watches_routes.ts +++ b/x-pack/plugins/watcher/server/routes/api/watches/register_watches_routes.ts @@ -6,9 +6,9 @@ import { registerListRoute } from './register_list_route'; import { registerDeleteRoute } from './register_delete_route'; -import { RouteDependencies, ServerShim } from '../../../types'; +import { RouteDependencies } from '../../../types'; -export function registerWatchesRoutes(deps: RouteDependencies, legacy: ServerShim) { - registerListRoute(deps, legacy); - registerDeleteRoute(deps, legacy); +export function registerWatchesRoutes(deps: RouteDependencies) { + registerListRoute(deps); + registerDeleteRoute(deps); } diff --git a/x-pack/plugins/watcher/server/types.ts b/x-pack/plugins/watcher/server/types.ts index 5e7d6c7cc14a8..832c476b567c6 100644 --- a/x-pack/plugins/watcher/server/types.ts +++ b/x-pack/plugins/watcher/server/types.ts @@ -5,8 +5,14 @@ */ import { IRouter, ElasticsearchServiceSetup, IClusterClient } from 'kibana/server'; +import { LicensingPluginSetup } from '../../licensing/server'; + import { XPackMainPlugin } from '../../../legacy/plugins/xpack_main/server/xpack_main'; +export interface Dependencies { + licensing: LicensingPluginSetup; +} + export interface ServerShim { route: any; plugins: { From 1e630f3f867187cbe48a7b4ca2c7541d681114df Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Wed, 15 Jan 2020 11:42:27 +0100 Subject: [PATCH 03/15] Move create Timebuckets to plugin root Update route registration and fix license checking for NP --- .../watcher/public/application/app.tsx | 4 +- .../watcher/public/application/boot.tsx | 4 +- .../watch_visualization.tsx | 6 +- x-pack/plugins/watcher/public/plugin.ts | 7 +- .../__tests__/license_pre_routing_factory.js | 64 ------------------- .../license_pre_routing_factory.test.js | 40 ++++++++++++ .../license_pre_routing_factory.ts | 23 +++---- x-pack/plugins/watcher/server/plugin.ts | 55 +++++++++------- .../routes/api/indices/register_get_route.ts | 3 +- .../api/license/register_refresh_route.ts | 4 +- .../routes/api/register_list_fields_route.ts | 3 +- .../routes/api/register_load_history_route.ts | 3 +- .../api/settings/register_load_route.ts | 3 +- .../action/register_acknowledge_route.ts | 3 +- .../api/watch/register_activate_route.ts | 3 +- .../api/watch/register_deactivate_route.ts | 3 +- .../routes/api/watch/register_delete_route.ts | 3 +- .../api/watch/register_execute_route.ts | 3 +- .../api/watch/register_history_route.ts | 3 +- .../routes/api/watch/register_load_route.ts | 3 +- .../routes/api/watch/register_save_route.ts | 3 +- .../api/watch/register_visualize_route.ts | 3 +- .../api/watches/register_delete_route.ts | 3 +- .../routes/api/watches/register_list_route.ts | 3 +- x-pack/plugins/watcher/server/types.ts | 6 ++ 25 files changed, 128 insertions(+), 130 deletions(-) delete mode 100644 x-pack/plugins/watcher/server/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.js create mode 100644 x-pack/plugins/watcher/server/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.test.js diff --git a/x-pack/plugins/watcher/public/application/app.tsx b/x-pack/plugins/watcher/public/application/app.tsx index e0fb4d8e55bce..af203685234a2 100644 --- a/x-pack/plugins/watcher/public/application/app.tsx +++ b/x-pack/plugins/watcher/public/application/app.tsx @@ -27,7 +27,6 @@ import { WatchList } from './sections/watch_list/components/watch_list'; import { registerRouter } from './lib/navigation'; import { BASE_PATH } from './constants'; import { AppContextProvider } from './app_context'; -import { DataPublicPluginSetup } from '../../../../../src/plugins/data/public'; const ShareRouter = withRouter(({ children, history }: RouteComponentProps & { children: any }) => { registerRouter({ history }); @@ -35,14 +34,13 @@ const ShareRouter = withRouter(({ children, history }: RouteComponentProps & { c }); export interface AppDeps { - data: DataPublicPluginSetup; chrome: ChromeStart; docLinks: DocLinksStart; toasts: ToastsSetup; http: HttpSetup; uiSettings: IUiSettingsClient; euiUtils: any; - TimeBuckets: any; + createTimeBuckets: () => any; MANAGEMENT_BREADCRUMB: any; } diff --git a/x-pack/plugins/watcher/public/application/boot.tsx b/x-pack/plugins/watcher/public/application/boot.tsx index be6bc9dd6e2af..8461bd65bbd5e 100644 --- a/x-pack/plugins/watcher/public/application/boot.tsx +++ b/x-pack/plugins/watcher/public/application/boot.tsx @@ -29,5 +29,7 @@ export const boot = (bootDeps: BootDeps) => { , element ); - return () => unmountComponentAtNode(element); + return () => { + unmountComponentAtNode(element); + }; }; diff --git a/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/watch_visualization.tsx b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/watch_visualization.tsx index 7ce206716367e..35d9efd36ad0f 100644 --- a/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/watch_visualization.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_edit/components/threshold_watch_edit/watch_visualization.tsx @@ -86,7 +86,7 @@ const getTimeBuckets = (watch: any, timeBuckets: any) => { }; export const WatchVisualization = () => { - const { TimeBuckets, euiUtils, uiSettings, data } = useAppContext(); + const { createTimeBuckets, euiUtils, uiSettings } = useAppContext(); const { watch } = useContext(WatchContext); const chartsTheme = euiUtils.useChartsTheme(); const { @@ -106,7 +106,7 @@ export const WatchVisualization = () => { } = watch; const domain = getDomain(watch); - const timeBuckets = new TimeBuckets(uiSettings, data); + const timeBuckets = createTimeBuckets(); timeBuckets.setBounds(domain); const interval = timeBuckets.getInterval().expression; const visualizeOptions = new VisualizeOptions({ @@ -203,7 +203,7 @@ export const WatchVisualization = () => { const dateFormatter = (d: number) => { return moment(d) .tz(timezone) - .format(getTimeBuckets(watch, new TimeBuckets(uiSettings, data)).getScaledDateFormat()); + .format(getTimeBuckets(watch, createTimeBuckets()).getScaledDateFormat()); }; const aggLabel = aggTypes[watch.aggType].text; return ( diff --git a/x-pack/plugins/watcher/public/plugin.ts b/x-pack/plugins/watcher/public/plugin.ts index da68ee27351e8..44e56810df136 100644 --- a/x-pack/plugins/watcher/public/plugin.ts +++ b/x-pack/plugins/watcher/public/plugin.ts @@ -28,13 +28,15 @@ export class WatcherUIPlugin implements Plugin { title: 'Watcher', mount: async ({ element }) => { if (!this.hasValidLicense) { - return null; + return () => undefined; } const [core, plugins] = await getStartServices(); const { chrome, i18n, docLinks, savedObjects } = core; const { eui_utils } = plugins as any; const { boot } = await import('./application/boot'); + const createTimeBuckets = () => new TimeBuckets(uiSettings, data); + return boot({ element, toasts: notifications.toasts, @@ -45,9 +47,8 @@ export class WatcherUIPlugin implements Plugin { euiUtils: eui_utils, savedObjects: savedObjects.client, I18nContext: i18n.Context, - TimeBuckets, + createTimeBuckets, MANAGEMENT_BREADCRUMB, - data, }); }, }); diff --git a/x-pack/plugins/watcher/server/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.js b/x-pack/plugins/watcher/server/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.js deleted file mode 100644 index c144530ab8724..0000000000000 --- a/x-pack/plugins/watcher/server/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.js +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import expect from '@kbn/expect'; -import { kibanaResponseFactory } from '../../../../../../../src/core/server'; -import { licensePreRoutingFactory } from '../license_pre_routing_factory'; -import { - LICENSE_STATUS_VALID, - LICENSE_STATUS_EXPIRED, -} from '../../../../../../legacy/common/constants/license_status'; - -describe('license_pre_routing_factory', () => { - describe('#reportingFeaturePreRoutingFactory', () => { - let mockServer; - let mockLicenseCheckResults; - - beforeEach(() => { - mockServer = { - plugins: { - xpack_main: { - info: { - feature: () => ({ - getLicenseCheckResults: () => mockLicenseCheckResults, - }), - }, - }, - }, - }; - }); - - describe('status is not valid', () => { - beforeEach(() => { - mockLicenseCheckResults = { - status: LICENSE_STATUS_EXPIRED, - }; - }); - - it('replies with 403', () => { - const licensePreRouting = licensePreRoutingFactory(mockServer, () => {}); - const stubRequest = {}; - const response = licensePreRouting({}, stubRequest, kibanaResponseFactory); - expect(response.status).to.be(403); - }); - }); - - describe('status is valid', () => { - beforeEach(() => { - mockLicenseCheckResults = { - status: LICENSE_STATUS_VALID, - }; - }); - - it('replies with nothing', () => { - const licensePreRouting = licensePreRoutingFactory(mockServer, () => null); - const stubRequest = {}; - const response = licensePreRouting({}, stubRequest, kibanaResponseFactory); - expect(response).to.be(null); - }); - }); - }); -}); diff --git a/x-pack/plugins/watcher/server/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.test.js b/x-pack/plugins/watcher/server/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.test.js new file mode 100644 index 0000000000000..be6873a61e902 --- /dev/null +++ b/x-pack/plugins/watcher/server/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.test.js @@ -0,0 +1,40 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import expect from '@kbn/expect'; +import { kibanaResponseFactory } from '../../../../../../../src/core/server'; +import { licensePreRoutingFactory } from '../license_pre_routing_factory'; + +describe('license_pre_routing_factory', () => { + describe('#reportingFeaturePreRoutingFactory', () => { + let mockDeps; + let licenseStatus; + + beforeEach(() => { + mockDeps = { getLicenseStatus: () => licenseStatus }; + }); + + describe('status is not valid', () => { + it('replies with 403', () => { + licenseStatus = { hasRequired: false }; + const routeWithLicenseCheck = licensePreRoutingFactory(mockDeps, () => {}); + const stubRequest = {}; + const response = routeWithLicenseCheck({}, stubRequest, kibanaResponseFactory); + expect(response.status).to.be(403); + }); + }); + + describe('status is valid', () => { + it('replies with nothing', () => { + licenseStatus = { hasRequired: true }; + const routeWithLicenseCheck = licensePreRoutingFactory(mockDeps, () => null); + const stubRequest = {}; + const response = routeWithLicenseCheck({}, stubRequest, kibanaResponseFactory); + expect(response).to.be(null); + }); + }); + }); +}); diff --git a/x-pack/plugins/watcher/server/lib/license_pre_routing_factory/license_pre_routing_factory.ts b/x-pack/plugins/watcher/server/lib/license_pre_routing_factory/license_pre_routing_factory.ts index 6b7db85a82321..d010a23952725 100644 --- a/x-pack/plugins/watcher/server/lib/license_pre_routing_factory/license_pre_routing_factory.ts +++ b/x-pack/plugins/watcher/server/lib/license_pre_routing_factory/license_pre_routing_factory.ts @@ -10,29 +10,22 @@ import { RequestHandler, RequestHandlerContext, } from 'kibana/server'; -import { PLUGIN } from '../../../common/constants'; -import { LICENSE_STATUS_VALID } from '../../../../../legacy/common/constants/license_status'; -import { ServerShim } from '../../types'; +import { RouteDependencies } from '../../types'; export const licensePreRoutingFactory = ( - server: ServerShim, - handler: RequestHandler -): RequestHandler => { - const xpackMainPlugin = server.plugins.xpack_main; - - // License checking and enable/disable logic - return function licensePreRouting( + { getLicenseStatus }: RouteDependencies, + handler: RequestHandler +) => { + return function licenseCheck( ctx: RequestHandlerContext, request: KibanaRequest, response: KibanaResponseFactory ) { - const licenseCheckResults = xpackMainPlugin.info.feature(PLUGIN.ID).getLicenseCheckResults(); - const { status } = licenseCheckResults; - - if (status !== LICENSE_STATUS_VALID) { + const licenseStatus = getLicenseStatus(); + if (!licenseStatus.hasRequired) { return response.customError({ body: { - message: licenseCheckResults.messsage, + message: licenseStatus.message || '', }, statusCode: 403, }); diff --git a/x-pack/plugins/watcher/server/plugin.ts b/x-pack/plugins/watcher/server/plugin.ts index 0540b923e4302..1f7b3823609ec 100644 --- a/x-pack/plugins/watcher/server/plugin.ts +++ b/x-pack/plugins/watcher/server/plugin.ts @@ -5,7 +5,7 @@ */ import { CoreSetup, Logger, Plugin, PluginInitializerContext } from 'kibana/server'; import { PLUGIN } from '../common/constants'; -import { Dependencies, RouteDependencies } from './types'; +import { Dependencies, LicenseStatus, RouteDependencies } from './types'; import { LICENSE_CHECK_STATE } from '../../licensing/server'; import { registerSettingsRoutes } from './routes/api/settings'; @@ -19,44 +19,51 @@ import { registerLoadHistoryRoute } from './routes/api/register_load_history_rou export class WatcherServerPlugin implements Plugin { log: Logger; + private licenseStatus: LicenseStatus = { + hasRequired: false, + }; + constructor(ctx: PluginInitializerContext) { - this.log = ctx.logger.get(PLUGIN.ID); + this.log = ctx.logger.get(); } async setup( { http, elasticsearch: elasticsearchService }: CoreSetup, { licensing }: Dependencies ) { + const elasticsearch = await elasticsearchService.adminClient; + const router = http.createRouter(); + const routeDependencies: RouteDependencies = { + elasticsearch, + elasticsearchService, + router, + getLicenseStatus: () => this.licenseStatus, + }; + + registerListFieldsRoute(routeDependencies); + registerLoadHistoryRoute(routeDependencies); + registerIndicesRoutes(routeDependencies); + registerLicenseRoutes(routeDependencies); + registerSettingsRoutes(routeDependencies); + registerWatchesRoutes(routeDependencies); + registerWatchRoutes(routeDependencies); + licensing.license$.subscribe(async license => { const { state, message } = license.check(PLUGIN.ID, PLUGIN.MINIMUM_LICENSE_REQUIRED); const hasMinimumLicense = state === LICENSE_CHECK_STATE.Valid; if (hasMinimumLicense && license.getFeature(PLUGIN.ID)) { - try { - const elasticsearch = await elasticsearchService.adminClient; - const router = http.createRouter(); - const routeDependencies: RouteDependencies = { - elasticsearch, - elasticsearchService, - router, - }; - - registerListFieldsRoute(routeDependencies); - registerLoadHistoryRoute(routeDependencies); - registerIndicesRoutes(routeDependencies); - registerLicenseRoutes(routeDependencies); - registerSettingsRoutes(routeDependencies); - registerWatchesRoutes(routeDependencies); - registerWatchRoutes(routeDependencies); - } catch (e) { - // TODO: Get back to testing why the server side crashes on license updates - // eslint-disable-next-line - console.log('here', e); - throw e; - } + this.log.info('Enabling Watcher plugin.'); + this.licenseStatus = { + hasRequired: true, + }; } else { if (message) { this.log.info(message); } + this.licenseStatus = { + hasRequired: false, + message, + }; } }); } diff --git a/x-pack/plugins/watcher/server/routes/api/indices/register_get_route.ts b/x-pack/plugins/watcher/server/routes/api/indices/register_get_route.ts index 250aa913d766f..30607b82e3295 100644 --- a/x-pack/plugins/watcher/server/routes/api/indices/register_get_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/indices/register_get_route.ts @@ -10,6 +10,7 @@ import { reduce, size } from 'lodash'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { isEsError } from '../../../lib/is_es_error'; import { RouteDependencies } from '../../../types'; +import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; function getIndexNamesFromAliasesResponse(json: Record) { return reduce( @@ -86,6 +87,6 @@ export function registerGetRoute(deps: RouteDependencies) { body: schema.object({}, { allowUnknowns: true }), }, }, - handler + licensePreRoutingFactory(deps, handler) ); } diff --git a/x-pack/plugins/watcher/server/routes/api/license/register_refresh_route.ts b/x-pack/plugins/watcher/server/routes/api/license/register_refresh_route.ts index 2fa3919e5e674..a61fd16e8be4a 100644 --- a/x-pack/plugins/watcher/server/routes/api/license/register_refresh_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/license/register_refresh_route.ts @@ -6,7 +6,7 @@ import { RequestHandler } from 'kibana/server'; import { RouteDependencies } from '../../../types'; - +import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; /* In order for the client to have the most up-to-date snapshot of the current license, it needs to make a round-trip to the kibana server. This refresh endpoint is provided @@ -23,6 +23,6 @@ export function registerRefreshRoute(deps: RouteDependencies) { path: '/api/watcher/license/refresh', validate: false, }, - handler + licensePreRoutingFactory(deps, handler) ); } diff --git a/x-pack/plugins/watcher/server/routes/api/register_list_fields_route.ts b/x-pack/plugins/watcher/server/routes/api/register_list_fields_route.ts index 8276f5ba492d9..7c47379b87589 100644 --- a/x-pack/plugins/watcher/server/routes/api/register_list_fields_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/register_list_fields_route.ts @@ -10,6 +10,7 @@ import { callWithRequestFactory } from '../../lib/call_with_request_factory'; import { isEsError } from '../../lib/is_es_error'; // @ts-ignore import { Fields } from '../../models/fields/index'; +import { licensePreRoutingFactory } from '../../lib/license_pre_routing_factory'; import { RouteDependencies } from '../../types'; function fetchFields(callWithRequest: any, indexes: string[]) { @@ -59,6 +60,6 @@ export function registerListFieldsRoute(deps: RouteDependencies) { }), }, }, - handler + licensePreRoutingFactory(deps, handler) ); } diff --git a/x-pack/plugins/watcher/server/routes/api/register_load_history_route.ts b/x-pack/plugins/watcher/server/routes/api/register_load_history_route.ts index baa7205966523..1be8477df79bc 100644 --- a/x-pack/plugins/watcher/server/routes/api/register_load_history_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/register_load_history_route.ts @@ -11,6 +11,7 @@ import { callWithRequestFactory } from '../../lib/call_with_request_factory'; import { isEsError } from '../../lib/is_es_error'; import { INDEX_NAMES } from '../../../common/constants'; import { RouteDependencies } from '../../types'; +import { licensePreRoutingFactory } from '../../lib/license_pre_routing_factory'; // @ts-ignore import { WatchHistoryItem } from '../../models/watch_history_item/index'; @@ -71,6 +72,6 @@ export function registerLoadHistoryRoute(deps: RouteDependencies) { }), }, }, - handler + licensePreRoutingFactory(deps, handler) ); } diff --git a/x-pack/plugins/watcher/server/routes/api/settings/register_load_route.ts b/x-pack/plugins/watcher/server/routes/api/settings/register_load_route.ts index 8df57b7bc8fe5..6c70c2d0d07b6 100644 --- a/x-pack/plugins/watcher/server/routes/api/settings/register_load_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/settings/register_load_route.ts @@ -9,6 +9,7 @@ import { isEsError } from '../../../lib/is_es_error'; // @ts-ignore import { Settings } from '../../../models/settings/index'; import { RouteDependencies } from '../../../types'; +import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; function fetchClusterSettings(client: IClusterClient) { return client.callAsInternalUser('cluster.getSettings', { @@ -37,6 +38,6 @@ export function registerLoadRoute(deps: RouteDependencies) { path: '/api/watcher/settings', validate: false, }, - handler + licensePreRoutingFactory(deps, handler) ); } diff --git a/x-pack/plugins/watcher/server/routes/api/watch/action/register_acknowledge_route.ts b/x-pack/plugins/watcher/server/routes/api/watch/action/register_acknowledge_route.ts index 953394c12cd3f..08eec7456e3a5 100644 --- a/x-pack/plugins/watcher/server/routes/api/watch/action/register_acknowledge_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watch/action/register_acknowledge_route.ts @@ -12,6 +12,7 @@ import { isEsError } from '../../../../lib/is_es_error'; // @ts-ignore import { WatchStatus } from '../../../../models/watch_status/index'; import { RouteDependencies } from '../../../../types'; +import { licensePreRoutingFactory } from '../../../../lib/license_pre_routing_factory'; function acknowledgeAction(callWithRequest: any, watchId: string, actionId: string) { return callWithRequest('watcher.ackWatch', { @@ -59,6 +60,6 @@ export function registerAcknowledgeRoute(deps: RouteDependencies) { }), }, }, - handler + licensePreRoutingFactory(deps, handler) ); } diff --git a/x-pack/plugins/watcher/server/routes/api/watch/register_activate_route.ts b/x-pack/plugins/watcher/server/routes/api/watch/register_activate_route.ts index c915e94b2f86c..fdc20854ed8c2 100644 --- a/x-pack/plugins/watcher/server/routes/api/watch/register_activate_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watch/register_activate_route.ts @@ -10,6 +10,7 @@ import { get } from 'lodash'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { isEsError } from '../../../lib/is_es_error'; import { RouteDependencies } from '../../../types'; +import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; // @ts-ignore import { WatchStatus } from '../../../models/watch_status/index'; @@ -60,6 +61,6 @@ export function registerActivateRoute(deps: RouteDependencies) { }), }, }, - handler + licensePreRoutingFactory(deps, handler) ); } diff --git a/x-pack/plugins/watcher/server/routes/api/watch/register_deactivate_route.ts b/x-pack/plugins/watcher/server/routes/api/watch/register_deactivate_route.ts index 17df2530c0319..08d99f42df054 100644 --- a/x-pack/plugins/watcher/server/routes/api/watch/register_deactivate_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watch/register_deactivate_route.ts @@ -9,6 +9,7 @@ import { get } from 'lodash'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { isEsError } from '../../../lib/is_es_error'; import { RouteDependencies } from '../../../types'; +import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; // @ts-ignore import { WatchStatus } from '../../../models/watch_status/index'; @@ -59,6 +60,6 @@ export function registerDeactivateRoute(deps: RouteDependencies) { }), }, }, - handler + licensePreRoutingFactory(deps, handler) ); } diff --git a/x-pack/plugins/watcher/server/routes/api/watch/register_delete_route.ts b/x-pack/plugins/watcher/server/routes/api/watch/register_delete_route.ts index 0133cb0b07747..4094daf0cd27c 100644 --- a/x-pack/plugins/watcher/server/routes/api/watch/register_delete_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watch/register_delete_route.ts @@ -9,6 +9,7 @@ import { RequestHandler } from 'kibana/server'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { isEsError } from '../../../lib/is_es_error'; import { RouteDependencies } from '../../../types'; +import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; function deleteWatch(callWithRequest: any, watchId: string) { return callWithRequest('watcher.deleteWatch', { @@ -46,6 +47,6 @@ export function registerDeleteRoute(deps: RouteDependencies) { }), }, }, - handler + licensePreRoutingFactory(deps, handler) ); } diff --git a/x-pack/plugins/watcher/server/routes/api/watch/register_execute_route.ts b/x-pack/plugins/watcher/server/routes/api/watch/register_execute_route.ts index b284f197668b7..fef6d07317da5 100644 --- a/x-pack/plugins/watcher/server/routes/api/watch/register_execute_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watch/register_execute_route.ts @@ -9,6 +9,7 @@ import { RequestHandler } from 'kibana/server'; import { get } from 'lodash'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { isEsError } from '../../../lib/is_es_error'; +import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; import { RouteDependencies } from '../../../types'; // @ts-ignore @@ -72,6 +73,6 @@ export function registerExecuteRoute(deps: RouteDependencies) { }), }, }, - handler + licensePreRoutingFactory(deps, handler) ); } diff --git a/x-pack/plugins/watcher/server/routes/api/watch/register_history_route.ts b/x-pack/plugins/watcher/server/routes/api/watch/register_history_route.ts index 4f530fee124d3..7f0f1ac8d66a3 100644 --- a/x-pack/plugins/watcher/server/routes/api/watch/register_history_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watch/register_history_route.ts @@ -12,6 +12,7 @@ import { fetchAllFromScroll } from '../../../lib/fetch_all_from_scroll'; import { INDEX_NAMES, ES_SCROLL_SETTINGS } from '../../../../common/constants'; import { isEsError } from '../../../lib/is_es_error'; import { RouteDependencies } from '../../../types'; +import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; // @ts-ignore import { WatchHistoryItem } from '../../../models/watch_history_item/index'; @@ -91,6 +92,6 @@ export function registerHistoryRoute(deps: RouteDependencies) { }), }, }, - handler + licensePreRoutingFactory(deps, handler) ); } diff --git a/x-pack/plugins/watcher/server/routes/api/watch/register_load_route.ts b/x-pack/plugins/watcher/server/routes/api/watch/register_load_route.ts index 57cb84448fbd3..91d71cd737121 100644 --- a/x-pack/plugins/watcher/server/routes/api/watch/register_load_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watch/register_load_route.ts @@ -9,6 +9,7 @@ import { RequestHandler } from 'kibana/server'; import { get } from 'lodash'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { isEsError } from '../../../lib/is_es_error'; +import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; // @ts-ignore import { Watch } from '../../../models/watch/index'; import { RouteDependencies } from '../../../types'; @@ -63,6 +64,6 @@ export function registerLoadRoute(deps: RouteDependencies) { }), }, }, - handler + licensePreRoutingFactory(deps, handler) ); } diff --git a/x-pack/plugins/watcher/server/routes/api/watch/register_save_route.ts b/x-pack/plugins/watcher/server/routes/api/watch/register_save_route.ts index 88c31c795426b..1c2195d57e1e1 100644 --- a/x-pack/plugins/watcher/server/routes/api/watch/register_save_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watch/register_save_route.ts @@ -12,6 +12,7 @@ import { serializeJsonWatch, serializeThresholdWatch } from '../../../../common/ import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { isEsError } from '../../../lib/is_es_error'; import { RouteDependencies } from '../../../types'; +import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; function fetchWatch(callWithRequest: any, watchId: string) { return callWithRequest('watcher.getWatch', { @@ -95,6 +96,6 @@ export function registerSaveRoute(deps: RouteDependencies) { body: schema.object({}, { allowUnknowns: true }), }, }, - handler + licensePreRoutingFactory(deps, handler) ); } diff --git a/x-pack/plugins/watcher/server/routes/api/watch/register_visualize_route.ts b/x-pack/plugins/watcher/server/routes/api/watch/register_visualize_route.ts index 5ef571216a598..f2110bcc0ebdb 100644 --- a/x-pack/plugins/watcher/server/routes/api/watch/register_visualize_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watch/register_visualize_route.ts @@ -9,6 +9,7 @@ import { RequestHandler } from 'kibana/server'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { isEsError } from '../../../lib/is_es_error'; import { RouteDependencies } from '../../../types'; +import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; // @ts-ignore import { Watch } from '../../../models/watch/index'; @@ -64,6 +65,6 @@ export function registerVisualizeRoute(deps: RouteDependencies) { }), }, }, - handler + licensePreRoutingFactory(deps, handler) ); } diff --git a/x-pack/plugins/watcher/server/routes/api/watches/register_delete_route.ts b/x-pack/plugins/watcher/server/routes/api/watches/register_delete_route.ts index 6d10220843e12..2ac824529f9a6 100644 --- a/x-pack/plugins/watcher/server/routes/api/watches/register_delete_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watches/register_delete_route.ts @@ -8,6 +8,7 @@ import { schema } from '@kbn/config-schema'; import { RequestHandler } from 'kibana/server'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { RouteDependencies } from '../../../types'; +import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; function deleteWatches(callWithRequest: any, watchIds: string[]) { const deletePromises = watchIds.map(watchId => { @@ -57,6 +58,6 @@ export function registerDeleteRoute(deps: RouteDependencies) { }), }, }, - handler + licensePreRoutingFactory(deps, handler) ); } diff --git a/x-pack/plugins/watcher/server/routes/api/watches/register_list_route.ts b/x-pack/plugins/watcher/server/routes/api/watches/register_list_route.ts index 14deeefa27760..fcbdf688a2ab4 100644 --- a/x-pack/plugins/watcher/server/routes/api/watches/register_list_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watches/register_list_route.ts @@ -11,6 +11,7 @@ import { fetchAllFromScroll } from '../../../lib/fetch_all_from_scroll'; import { INDEX_NAMES, ES_SCROLL_SETTINGS } from '../../../../common/constants'; import { isEsError } from '../../../lib/is_es_error'; import { RouteDependencies } from '../../../types'; +import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory'; // @ts-ignore import { Watch } from '../../../models/watch/index'; @@ -80,6 +81,6 @@ export function registerListRoute(deps: RouteDependencies) { path: '/api/watcher/watches', validate: false, }, - handler + licensePreRoutingFactory(deps, handler) ); } diff --git a/x-pack/plugins/watcher/server/types.ts b/x-pack/plugins/watcher/server/types.ts index 832c476b567c6..d9f2d3c3b1e7a 100644 --- a/x-pack/plugins/watcher/server/types.ts +++ b/x-pack/plugins/watcher/server/types.ts @@ -23,6 +23,12 @@ export interface ServerShim { export interface RouteDependencies { router: IRouter; + getLicenseStatus: () => LicenseStatus; elasticsearchService: ElasticsearchServiceSetup; elasticsearch: IClusterClient; } + +export interface LicenseStatus { + hasRequired: boolean; + message?: string; +} From 5e2954158428da7b2a58e5b6bfb9c014a37f22aa Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Wed, 15 Jan 2020 11:56:06 +0100 Subject: [PATCH 04/15] Re-enable Component integration tests --- .../helpers/app_context.mock.tsx | 27 +++++++++---------- .../client_integration/helpers/index.ts | 2 +- .../helpers/setup_environment.ts | 1 + .../helpers/watch_create_json.helpers.ts | 6 +++-- .../helpers/watch_create_threshold.helpers.ts | 6 +++-- .../helpers/watch_edit.helpers.ts | 6 +++-- .../helpers/watch_list.helpers.ts | 3 ++- .../helpers/watch_status.helpers.ts | 3 ++- .../watch_create_threshold.test.tsx | 4 +-- .../client_integration/watch_edit.test.ts | 6 ++--- x-pack/plugins/watcher/test/fixtures/watch.ts | 2 +- .../watcher/test/fixtures/watch_history.ts | 2 +- 12 files changed, 38 insertions(+), 30 deletions(-) diff --git a/x-pack/plugins/watcher/__jest__/client_integration/helpers/app_context.mock.tsx b/x-pack/plugins/watcher/__jest__/client_integration/helpers/app_context.mock.tsx index 42494792db3d8..9c75b782c3094 100644 --- a/x-pack/plugins/watcher/__jest__/client_integration/helpers/app_context.mock.tsx +++ b/x-pack/plugins/watcher/__jest__/client_integration/helpers/app_context.mock.tsx @@ -13,25 +13,24 @@ import { notificationServiceMock, httpServiceMock, } from '../../../../../../src/core/public/mocks'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { AppContextProvider } from '../../../public/application/app_context'; +class MockTimeBuckets { + setBounds(_domain: any) { + return {}; + } + getInterval() { + return { + expression: {}, + }; + } +} export const mockContextValue = { docLinks: docLinksServiceMock.createStartContract(), chrome: chromeServiceMock.createStartContract(), - legacy: { - TimeBuckets: class MockTimeBuckets { - setBounds(_domain: any) { - return {}; - } - getInterval() { - return { - expression: {}, - }; - } - }, - MANAGEMENT_BREADCRUMB: { text: 'test' }, - licenseStatus: {}, - }, + MANAGEMENT_BREADCRUMB: { text: 'test' }, + createTimeBuckets: () => new MockTimeBuckets(), uiSettings: uiSettingsServiceMock.createSetupContract(), toasts: notificationServiceMock.createSetupContract().toasts, euiUtils: { diff --git a/x-pack/plugins/watcher/__jest__/client_integration/helpers/index.ts b/x-pack/plugins/watcher/__jest__/client_integration/helpers/index.ts index bdafb4a313867..7c5ec0917494a 100644 --- a/x-pack/plugins/watcher/__jest__/client_integration/helpers/index.ts +++ b/x-pack/plugins/watcher/__jest__/client_integration/helpers/index.ts @@ -10,7 +10,7 @@ import { setup as watchCreateJsonSetup } from './watch_create_json.helpers'; import { setup as watchCreateThresholdSetup } from './watch_create_threshold.helpers'; import { setup as watchEditSetup } from './watch_edit.helpers'; -export { nextTick, getRandomString, findTestSubject, TestBed } from 'test_utils/index'; +export { nextTick, getRandomString, findTestSubject, TestBed } from '../../../../../test_utils'; export { wrapBodyResponse, unwrapBodyResponse } from './body_response'; export { setupEnvironment } from './setup_environment'; diff --git a/x-pack/plugins/watcher/__jest__/client_integration/helpers/setup_environment.ts b/x-pack/plugins/watcher/__jest__/client_integration/helpers/setup_environment.ts index 224a68186e1da..c084f87ea8c3a 100644 --- a/x-pack/plugins/watcher/__jest__/client_integration/helpers/setup_environment.ts +++ b/x-pack/plugins/watcher/__jest__/client_integration/helpers/setup_environment.ts @@ -7,6 +7,7 @@ import axios from 'axios'; import axiosXhrAdapter from 'axios/lib/adapters/xhr'; import { init as initHttpRequests } from './http_requests'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { setHttpClient, setSavedObjectsClient } from '../../../public/application/lib/api'; const mockHttpClient = axios.create({ adapter: axiosXhrAdapter }); diff --git a/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_create_json.helpers.ts b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_create_json.helpers.ts index 0e0fc4e30da8f..77d5a76257fd2 100644 --- a/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_create_json.helpers.ts +++ b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_create_json.helpers.ts @@ -4,10 +4,12 @@ * you may not use this file except in compliance with the Elastic License. */ import { withAppContext } from './app_context.mock'; -import { registerTestBed, TestBed, TestBedConfig } from 'test_utils/index'; +import { registerTestBed, TestBed, TestBedConfig } from '../../../../../test_utils'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { WatchEdit } from '../../../public/application/sections/watch_edit/components/watch_edit'; -import { ROUTES, WATCH_TYPES } from '../../../common/constants'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { registerRouter } from '../../../public/application/lib/navigation'; +import { ROUTES, WATCH_TYPES } from '../../../common/constants'; const testBedConfig: TestBedConfig = { memoryRouter: { diff --git a/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_create_threshold.helpers.ts b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_create_threshold.helpers.ts index 0c21e03f4eaf2..8262e6702be70 100644 --- a/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_create_threshold.helpers.ts +++ b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_create_threshold.helpers.ts @@ -3,10 +3,12 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed, TestBed, TestBedConfig } from 'test_utils/index'; +import { registerTestBed, TestBed, TestBedConfig } from '../../../../../test_utils'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { WatchEdit } from '../../../public/application/sections/watch_edit/components/watch_edit'; -import { ROUTES, WATCH_TYPES } from '../../../common/constants'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { registerRouter } from '../../../public/application/lib/navigation'; +import { ROUTES, WATCH_TYPES } from '../../../common/constants'; import { withAppContext } from './app_context.mock'; const testBedConfig: TestBedConfig = { diff --git a/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_edit.helpers.ts b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_edit.helpers.ts index afa2012f533ac..949d43e774212 100644 --- a/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_edit.helpers.ts +++ b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_edit.helpers.ts @@ -3,10 +3,12 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed, TestBed, TestBedConfig } from 'test_utils/index'; +import { registerTestBed, TestBed, TestBedConfig } from '../../../../../test_utils'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { WatchEdit } from '../../../public/application/sections/watch_edit/components/watch_edit'; -import { ROUTES } from '../../../common/constants'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { registerRouter } from '../../../public/application/lib/navigation'; +import { ROUTES } from '../../../common/constants'; import { WATCH_ID } from './constants'; import { withAppContext } from './app_context.mock'; diff --git a/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_list.helpers.ts b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_list.helpers.ts index 8afd57a089ede..b5cf3df9509fc 100644 --- a/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_list.helpers.ts +++ b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_list.helpers.ts @@ -12,7 +12,8 @@ import { TestBed, TestBedConfig, nextTick, -} from 'test_utils/index'; +} from '../../../../../test_utils'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { WatchList } from '../../../public/application/sections/watch_list/components/watch_list'; import { ROUTES } from '../../../common/constants'; import { withAppContext } from './app_context.mock'; diff --git a/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_status.helpers.ts b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_status.helpers.ts index 1fdf2eb5c5c86..e67c98ff9e9a0 100644 --- a/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_status.helpers.ts +++ b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_status.helpers.ts @@ -12,7 +12,8 @@ import { TestBed, TestBedConfig, nextTick, -} from 'test_utils/index'; +} from '../../../../../test_utils'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { WatchStatus } from '../../../public/application/sections/watch_status/components/watch_status'; import { ROUTES } from '../../../common/constants'; import { WATCH_ID } from './constants'; diff --git a/x-pack/plugins/watcher/__jest__/client_integration/watch_create_threshold.test.tsx b/x-pack/plugins/watcher/__jest__/client_integration/watch_create_threshold.test.tsx index 2800b0107da24..431eb1cae0608 100644 --- a/x-pack/plugins/watcher/__jest__/client_integration/watch_create_threshold.test.tsx +++ b/x-pack/plugins/watcher/__jest__/client_integration/watch_create_threshold.test.tsx @@ -48,8 +48,8 @@ const WATCH_VISUALIZE_DATA = { const mockHttpClient = axios.create({ adapter: axiosXhrAdapter }); -jest.mock('../../public/np_ready/application/lib/api', () => ({ - ...jest.requireActual('../../public/np_ready/application/lib/api'), +jest.mock('../../public/application/lib/api', () => ({ + ...jest.requireActual('../../public/application/lib/api'), loadIndexPatterns: async () => { const INDEX_PATTERNS = [ { attributes: { title: 'index1' } }, diff --git a/x-pack/plugins/watcher/__jest__/client_integration/watch_edit.test.ts b/x-pack/plugins/watcher/__jest__/client_integration/watch_edit.test.ts index 5acee16354438..545bfbdf7cbc2 100644 --- a/x-pack/plugins/watcher/__jest__/client_integration/watch_edit.test.ts +++ b/x-pack/plugins/watcher/__jest__/client_integration/watch_edit.test.ts @@ -11,12 +11,12 @@ import { WatchEditTestBed } from './helpers/watch_edit.helpers'; import { WATCH } from './helpers/constants'; import defaultWatchJson from '../../public/application/models/watch/default_watch.json'; import { getWatch } from '../../test/fixtures'; -import { getRandomString } from 'test_utils/index'; +import { getRandomString } from '../../../../test_utils'; const mockHttpClient = axios.create({ adapter: axiosXhrAdapter }); -jest.mock('../../public/np_ready/application/lib/api', () => ({ - ...jest.requireActual('../../public/np_ready/application/lib/api'), +jest.mock('../../public/application/lib/api', () => ({ + ...jest.requireActual('../../public/application/lib/api'), loadIndexPatterns: async () => { const INDEX_PATTERNS = [ { attributes: { title: 'index1' } }, diff --git a/x-pack/plugins/watcher/test/fixtures/watch.ts b/x-pack/plugins/watcher/test/fixtures/watch.ts index 206f10602ba47..3342ebc149770 100644 --- a/x-pack/plugins/watcher/test/fixtures/watch.ts +++ b/x-pack/plugins/watcher/test/fixtures/watch.ts @@ -5,7 +5,7 @@ */ import { Moment } from 'moment'; -import { getRandomString } from 'test_utils/index'; +import { getRandomString } from '../../../../test_utils'; interface Watch { id: string; diff --git a/x-pack/plugins/watcher/test/fixtures/watch_history.ts b/x-pack/plugins/watcher/test/fixtures/watch_history.ts index 2c1b0666e387c..b8f725aa84a18 100644 --- a/x-pack/plugins/watcher/test/fixtures/watch_history.ts +++ b/x-pack/plugins/watcher/test/fixtures/watch_history.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { getRandomString } from 'test_utils/index'; +import { getRandomString } from '../../../../test_utils'; interface WatchHistory { startTime: string; From 00d6821732d82942e47a0ab1dd7303395cb6dca5 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Wed, 15 Jan 2020 12:03:37 +0100 Subject: [PATCH 05/15] Minor fix for data deserializer in api.ts --- x-pack/plugins/watcher/public/application/lib/api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/watcher/public/application/lib/api.ts b/x-pack/plugins/watcher/public/application/lib/api.ts index c919b86d9d7c9..82ec2925ba6dc 100644 --- a/x-pack/plugins/watcher/public/application/lib/api.ts +++ b/x-pack/plugins/watcher/public/application/lib/api.ts @@ -156,7 +156,7 @@ export const useGetWatchVisualizationData = (watchModel: BaseWatch, visualizeOpt watch: watchModel.upstreamJson, options: visualizeOptions.upstreamJson, }), - deserializer: ({ visualizeData }: { visualizeData: any }) => visualizeData, + deserializer: (data: { visualizeData: any }) => data?.visualizeData, }); }; From d2d189912851e1b40b08b279c4fecea474822e06 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Wed, 15 Jan 2020 12:14:20 +0100 Subject: [PATCH 06/15] Slight logic refactor, more defensive plugin startup --- x-pack/plugins/watcher/public/plugin.ts | 57 +++++++++++++------------ 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/x-pack/plugins/watcher/public/plugin.ts b/x-pack/plugins/watcher/public/plugin.ts index 44e56810df136..99cb2dba91937 100644 --- a/x-pack/plugins/watcher/public/plugin.ts +++ b/x-pack/plugins/watcher/public/plugin.ts @@ -23,35 +23,38 @@ export class WatcherUIPlugin implements Plugin { state === LICENSE_CHECK_STATE.Valid && license.getFeature(PLUGIN.ID).isAvailable; if (this.hasValidLicense) { - management.sections.getSection('elasticsearch')!.registerApp({ - id: 'watcher', - title: 'Watcher', - mount: async ({ element }) => { - if (!this.hasValidLicense) { - return () => undefined; - } - const [core, plugins] = await getStartServices(); - const { chrome, i18n, docLinks, savedObjects } = core; - const { eui_utils } = plugins as any; - const { boot } = await import('./application/boot'); + const esSection = management.sections.getSection('elasticsearch'); + if (esSection) { + esSection.registerApp({ + id: 'watcher', + title: 'Watcher', + mount: async ({ element }) => { + if (!this.hasValidLicense) { + return () => undefined; + } + const [core, plugins] = await getStartServices(); + const { chrome, i18n, docLinks, savedObjects } = core; + const { eui_utils } = plugins as any; + const { boot } = await import('./application/boot'); - const createTimeBuckets = () => new TimeBuckets(uiSettings, data); + const createTimeBuckets = () => new TimeBuckets(uiSettings, data); - return boot({ - element, - toasts: notifications.toasts, - http, - uiSettings, - docLinks, - chrome, - euiUtils: eui_utils, - savedObjects: savedObjects.client, - I18nContext: i18n.Context, - createTimeBuckets, - MANAGEMENT_BREADCRUMB, - }); - }, - }); + return boot({ + element, + toasts: notifications.toasts, + http, + uiSettings, + docLinks, + chrome, + euiUtils: eui_utils, + savedObjects: savedObjects.client, + I18nContext: i18n.Context, + createTimeBuckets, + MANAGEMENT_BREADCRUMB, + }); + }, + }); + } } // management.sections.getSection('elasticsearch/watcher').register('watches', { From 8b1c2b08f9ad38dafc640b984b28938ebf92cc37 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Wed, 15 Jan 2020 12:39:14 +0100 Subject: [PATCH 07/15] Re-add legacy folder for SCSS pipeline --- x-pack/index.js | 2 ++ x-pack/legacy/plugins/watcher/index.ts | 19 ++++++++++++++ .../legacy/plugins/watcher/public/index.scss | 25 +++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 x-pack/legacy/plugins/watcher/index.ts create mode 100644 x-pack/legacy/plugins/watcher/public/index.scss diff --git a/x-pack/index.js b/x-pack/index.js index bda081f28feac..83a7b5540334f 100644 --- a/x-pack/index.js +++ b/x-pack/index.js @@ -12,6 +12,7 @@ import { security } from './legacy/plugins/security'; import { searchprofiler } from './legacy/plugins/searchprofiler'; import { ml } from './legacy/plugins/ml'; import { tilemap } from './legacy/plugins/tilemap'; +import { watcher } from './legacy/plugins/watcher'; import { grokdebugger } from './legacy/plugins/grokdebugger'; import { dashboardMode } from './legacy/plugins/dashboard_mode'; import { logstash } from './legacy/plugins/logstash'; @@ -54,6 +55,7 @@ module.exports = function(kibana) { searchprofiler(kibana), ml(kibana), tilemap(kibana), + watcher(kibana), grokdebugger(kibana), dashboardMode(kibana), logstash(kibana), diff --git a/x-pack/legacy/plugins/watcher/index.ts b/x-pack/legacy/plugins/watcher/index.ts new file mode 100644 index 0000000000000..fdf9ba1bad6e4 --- /dev/null +++ b/x-pack/legacy/plugins/watcher/index.ts @@ -0,0 +1,19 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { resolve } from 'path'; + +const pluginDefinition = { + id: 'watcher', + configPrefix: 'xpack.watcher', + publicDir: resolve(__dirname, 'public'), + require: ['kibana'], + uiExports: { + styleSheetPaths: resolve(__dirname, 'public/index.scss'), + }, + init(server: any) {}, +}; + +export const watcher = (kibana: any) => new kibana.Plugin(pluginDefinition); diff --git a/x-pack/legacy/plugins/watcher/public/index.scss b/x-pack/legacy/plugins/watcher/public/index.scss new file mode 100644 index 0000000000000..33ebf21326c7b --- /dev/null +++ b/x-pack/legacy/plugins/watcher/public/index.scss @@ -0,0 +1,25 @@ +// Import the EUI global scope so we can use EUI constants +@import 'src/legacy/ui/public/styles/_styling_constants'; + +// Watcher plugin styles + +// Prefix all styles with "watcher" to avoid conflicts. +// Examples +// watcherChart +// watcherChart__legend +// watcherChart__legend--small +// watcherChart__legend-isLoading + +.watcherThresholdWatchActionDropdownContainer { + justify-content: flex-end; + flex-direction: row; +} + +.watcherThresholdWatchActionContextMenuItem, +.watcherThresholdWatchInBetweenComparatorText { + align-self: center; +} + +.watcherThresholdAlertAggFieldContainer { + width: 300px; +} From bcb285976e75f63acef6481553f7175f64f300ab Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Wed, 15 Jan 2020 12:42:17 +0100 Subject: [PATCH 08/15] Remove duplicate style sheet --- .../watcher/public/application/index.scss | 25 ------------------- 1 file changed, 25 deletions(-) delete mode 100644 x-pack/plugins/watcher/public/application/index.scss diff --git a/x-pack/plugins/watcher/public/application/index.scss b/x-pack/plugins/watcher/public/application/index.scss deleted file mode 100644 index 33ebf21326c7b..0000000000000 --- a/x-pack/plugins/watcher/public/application/index.scss +++ /dev/null @@ -1,25 +0,0 @@ -// Import the EUI global scope so we can use EUI constants -@import 'src/legacy/ui/public/styles/_styling_constants'; - -// Watcher plugin styles - -// Prefix all styles with "watcher" to avoid conflicts. -// Examples -// watcherChart -// watcherChart__legend -// watcherChart__legend--small -// watcherChart__legend-isLoading - -.watcherThresholdWatchActionDropdownContainer { - justify-content: flex-end; - flex-direction: row; -} - -.watcherThresholdWatchActionContextMenuItem, -.watcherThresholdWatchInBetweenComparatorText { - align-self: center; -} - -.watcherThresholdAlertAggFieldContainer { - width: 300px; -} From 1d7f3011ad26c0f974415be11c6a1f2b15c018e9 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 16 Jan 2020 13:43:09 +0100 Subject: [PATCH 09/15] Fix type issue with TimeBuckets export --- x-pack/plugins/watcher/public/legacy/index.d.ts | 3 +-- x-pack/plugins/watcher/public/legacy/time_buckets.d.ts | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 x-pack/plugins/watcher/public/legacy/time_buckets.d.ts diff --git a/x-pack/plugins/watcher/public/legacy/index.d.ts b/x-pack/plugins/watcher/public/legacy/index.d.ts index 5cd297038f642..307e365040fb7 100644 --- a/x-pack/plugins/watcher/public/legacy/index.d.ts +++ b/x-pack/plugins/watcher/public/legacy/index.d.ts @@ -4,5 +4,4 @@ * you may not use this file except in compliance with the Elastic License. */ -export const TimeBuckets: any; -export const MANAGEMENT_BREADCRUMB: { text: string; href?: string }; +export declare const MANAGEMENT_BREADCRUMB: { text: string; href?: string }; diff --git a/x-pack/plugins/watcher/public/legacy/time_buckets.d.ts b/x-pack/plugins/watcher/public/legacy/time_buckets.d.ts new file mode 100644 index 0000000000000..e84051b086344 --- /dev/null +++ b/x-pack/plugins/watcher/public/legacy/time_buckets.d.ts @@ -0,0 +1,7 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export declare const TimeBuckets: any; From 21c25ef166577956e6aaaf1589bc9ffc43aa6d2d Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 16 Jan 2020 14:47:26 +0100 Subject: [PATCH 10/15] Update license management routing logic (issued warning for using basepath on navigating away from license management) Remove commented out code in watcher --- .../public/np_ready/application/app.js | 8 +-- .../public/np_ready/application/boot.tsx | 2 +- .../license_dashboard/license_dashboard.js | 8 ++- x-pack/plugins/watcher/public/plugin.ts | 56 +------------------ 4 files changed, 10 insertions(+), 64 deletions(-) diff --git a/x-pack/legacy/plugins/license_management/public/np_ready/application/app.js b/x-pack/legacy/plugins/license_management/public/np_ready/application/app.js index 7122e7269732a..7c497518b9df5 100644 --- a/x-pack/legacy/plugins/license_management/public/np_ready/application/app.js +++ b/x-pack/legacy/plugins/license_management/public/np_ready/application/app.js @@ -8,7 +8,7 @@ import React, { Component } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { LicenseDashboard, UploadLicense } from './sections'; import { Switch, Route } from 'react-router-dom'; -import { APP_PERMISSION } from '../../../common/constants'; +import { APP_PERMISSION, BASE_PATH } from '../../../common/constants'; import { EuiPageBody, EuiEmptyPrompt, EuiText, EuiLoadingSpinner, EuiCallOut } from '@elastic/eui'; export class App extends Component { @@ -88,10 +88,8 @@ export class App extends Component { return ( - - - {/* Match all */} - + + ); diff --git a/x-pack/legacy/plugins/license_management/public/np_ready/application/boot.tsx b/x-pack/legacy/plugins/license_management/public/np_ready/application/boot.tsx index d0bf5deacfac1..2780b54230eba 100644 --- a/x-pack/legacy/plugins/license_management/public/np_ready/application/boot.tsx +++ b/x-pack/legacy/plugins/license_management/public/np_ready/application/boot.tsx @@ -63,7 +63,7 @@ export const boot = (deps: AppDependencies) => { render( - + diff --git a/x-pack/legacy/plugins/license_management/public/np_ready/application/sections/license_dashboard/license_dashboard.js b/x-pack/legacy/plugins/license_management/public/np_ready/application/sections/license_dashboard/license_dashboard.js index 3dc44796fd0ef..e14d392fe6706 100644 --- a/x-pack/legacy/plugins/license_management/public/np_ready/application/sections/license_dashboard/license_dashboard.js +++ b/x-pack/legacy/plugins/license_management/public/np_ready/application/sections/license_dashboard/license_dashboard.js @@ -4,8 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import React from 'react'; - +import React, { useEffect } from 'react'; import { LicenseStatus } from './license_status'; import { RevertToBasic } from './revert_to_basic'; import { StartTrial } from './start_trial'; @@ -14,7 +13,10 @@ import { RequestTrialExtension } from './request_trial_extension'; import { EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui'; export const LicenseDashboard = ({ setBreadcrumb } = { setBreadcrumb: () => {} }) => { - setBreadcrumb('dashboard'); + useEffect(() => { + setBreadcrumb('dashboard'); + }); + return (
diff --git a/x-pack/plugins/watcher/public/plugin.ts b/x-pack/plugins/watcher/public/plugin.ts index 99cb2dba91937..7c04e6fc73faa 100644 --- a/x-pack/plugins/watcher/public/plugin.ts +++ b/x-pack/plugins/watcher/public/plugin.ts @@ -37,8 +37,6 @@ export class WatcherUIPlugin implements Plugin { const { eui_utils } = plugins as any; const { boot } = await import('./application/boot'); - const createTimeBuckets = () => new TimeBuckets(uiSettings, data); - return boot({ element, toasts: notifications.toasts, @@ -49,65 +47,13 @@ export class WatcherUIPlugin implements Plugin { euiUtils: eui_utils, savedObjects: savedObjects.client, I18nContext: i18n.Context, - createTimeBuckets, + createTimeBuckets: () => new TimeBuckets(uiSettings, data), MANAGEMENT_BREADCRUMB, }); }, }); } } - - // management.sections.getSection('elasticsearch/watcher').register('watches', { - // display: i18n.translate( - // 'xpack.watcher.sections.watchList.managementSection.watchesDisplayName', - // { - // defaultMessage: 'Watches', - // } - // ), - // order: 1, - // } as any); - // - // management.sections.getSection('elasticsearch/watcher').register('watch', { - // visible: false, - // } as any); - // - // management.sections.getSection('elasticsearch/watcher/watch').register('status', { - // display: i18n.translate( - // 'xpack.watcher.sections.watchList.managementSection.statusDisplayName', - // { - // defaultMessage: 'Status', - // } - // ), - // order: 1, - // visible: false, - // } as any); - // - // management.sections.getSection('elasticsearch/watcher/watch').register('edit', { - // display: i18n.translate( - // 'xpack.watcher.sections.watchList.managementSection.editDisplayName', - // { - // defaultMessage: 'Edit', - // } - // ), - // order: 2, - // visible: false, - // } as any); - // - // management.sections.getSection('elasticsearch/watcher/watch').register('new', { - // display: i18n.translate( - // 'xpack.watcher.sections.watchList.managementSection.newWatchDisplayName', - // { - // defaultMessage: 'New Watch', - // } - // ), - // order: 1, - // visible: false, - // } as any); - // - // management.sections.getSection('elasticsearch/watcher/watch').register('history-item', { - // order: 1, - // visible: false, - // } as any); }); } From da4f3d2ae1dc7e5d8a051f6cc7c3069bb4766695 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 16 Jan 2020 15:53:32 +0100 Subject: [PATCH 11/15] More defensive plugin registration --- x-pack/plugins/watcher/public/plugin.ts | 67 +++++++++++++++---------- 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/x-pack/plugins/watcher/public/plugin.ts b/x-pack/plugins/watcher/public/plugin.ts index 7c04e6fc73faa..f88a422f0a27f 100644 --- a/x-pack/plugins/watcher/public/plugin.ts +++ b/x-pack/plugins/watcher/public/plugin.ts @@ -12,6 +12,7 @@ import { Dependencies } from './types'; export class WatcherUIPlugin implements Plugin { hasValidLicense: boolean = false; + hasRegisteredESManagementSection = false; setup( { application, notifications, http, uiSettings, getStartServices }: CoreSetup, @@ -25,33 +26,47 @@ export class WatcherUIPlugin implements Plugin { if (this.hasValidLicense) { const esSection = management.sections.getSection('elasticsearch'); if (esSection) { - esSection.registerApp({ - id: 'watcher', - title: 'Watcher', - mount: async ({ element }) => { - if (!this.hasValidLicense) { - return () => undefined; - } - const [core, plugins] = await getStartServices(); - const { chrome, i18n, docLinks, savedObjects } = core; - const { eui_utils } = plugins as any; - const { boot } = await import('./application/boot'); + if (!this.hasRegisteredESManagementSection) { + esSection.registerApp({ + id: 'watcher', + title: 'Watcher', + mount: async ({ element }) => { + if (!this.hasValidLicense) { + return () => undefined; + } + const [core, plugins] = await getStartServices(); + const { chrome, i18n, docLinks, savedObjects } = core; + const { eui_utils } = plugins as any; + const { boot } = await import('./application/boot'); - return boot({ - element, - toasts: notifications.toasts, - http, - uiSettings, - docLinks, - chrome, - euiUtils: eui_utils, - savedObjects: savedObjects.client, - I18nContext: i18n.Context, - createTimeBuckets: () => new TimeBuckets(uiSettings, data), - MANAGEMENT_BREADCRUMB, - }); - }, - }); + return boot({ + element, + toasts: notifications.toasts, + http, + uiSettings, + docLinks, + chrome, + euiUtils: eui_utils, + savedObjects: savedObjects.client, + I18nContext: i18n.Context, + createTimeBuckets: () => new TimeBuckets(uiSettings, data), + MANAGEMENT_BREADCRUMB, + }); + }, + }); + this.hasRegisteredESManagementSection = true; + } else { + // App must exist at this point + esSection.getApp(PLUGIN.ID)!.enable(); + } + } + } else { + const esSection = management.sections.getSection('elasticsearch'); + if (esSection) { + const app = esSection.getApp(PLUGIN.ID); + if (app) { + app.disable(); + } } } }); From 0c8f3eabcd0293d88f8ac55c4d929b5a9b8026a3 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Fri, 17 Jan 2020 13:48:37 +0100 Subject: [PATCH 12/15] Fix i18n issues and restore registration of feature on home view --- .../translations/translations/ja-JP.json | 6 +--- .../translations/translations/zh-CN.json | 6 +--- x-pack/plugins/watcher/public/legacy/index.ts | 2 +- .../invalid_es_calendar_interval_error.ts | 2 +- .../invalid_es_interval_format_error.ts | 2 +- x-pack/plugins/watcher/public/plugin.ts | 34 +++++++++++++++---- x-pack/plugins/watcher/public/types.ts | 2 ++ 7 files changed, 34 insertions(+), 20 deletions(-) diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 5661020ba6fa6..cb9dbf3c67ddd 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -11924,11 +11924,7 @@ "xpack.watcher.sections.watchList.createThresholdAlertButtonLabel": "しきい値アラートを作成", "xpack.watcher.sections.watchList.createThresholdAlertButtonTooltip": "特定の条件でアラートを送信します", "xpack.watcher.sections.watchList.header": "しきい値アラートを作成", - "xpack.watcher.sections.watchList.managementSection.editDisplayName": "編集", - "xpack.watcher.sections.watchList.managementSection.newWatchDisplayName": "新規ウォッチ", - "xpack.watcher.sections.watchList.managementSection.statusDisplayName": "ステータス", "xpack.watcher.sections.watchList.managementSection.watcherDisplayName": "Watcher", - "xpack.watcher.sections.watchList.managementSection.watchesDisplayName": "ウォッチ", "xpack.watcher.sections.watchList.subhead": "特定のパラメーターに到達した際にメール、Slack メッセージ、ログイベントを送信します。", "xpack.watcher.thresholdPreviewChart.dataDoesNotExistTextMessage": "インデックスと条件がデータを返しませんでした", "xpack.watcher.thresholdWatchExpression.comparators.isAboveLabel": "より大きい:", @@ -12694,4 +12690,4 @@ "xpack.licensing.welcomeBanner.licenseIsExpiredDescription.updateYourLicenseLinkText": "ライセンスを更新", "xpack.licensing.welcomeBanner.licenseIsExpiredTitle": "ご使用の {licenseType} ライセンスは期限切れです" } -} \ No newline at end of file +} diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 1bcfab4240aed..cc37aa385ad98 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -12013,11 +12013,7 @@ "xpack.watcher.sections.watchList.createThresholdAlertButtonLabel": "创建阈值告警", "xpack.watcher.sections.watchList.createThresholdAlertButtonTooltip": "在特定条件下发送告警", "xpack.watcher.sections.watchList.header": "创建阈值告警", - "xpack.watcher.sections.watchList.managementSection.editDisplayName": "编辑", - "xpack.watcher.sections.watchList.managementSection.newWatchDisplayName": "新建监视", - "xpack.watcher.sections.watchList.managementSection.statusDisplayName": "状态", "xpack.watcher.sections.watchList.managementSection.watcherDisplayName": "Watcher", - "xpack.watcher.sections.watchList.managementSection.watchesDisplayName": "监视", "xpack.watcher.sections.watchList.subhead": "特定参数命中时,发出电子邮件、Slack 消息和日志事件", "xpack.watcher.thresholdPreviewChart.dataDoesNotExistTextMessage": "您的索引和条件未返回任何数据", "xpack.watcher.thresholdWatchExpression.comparators.isAboveLabel": "高于", @@ -12783,4 +12779,4 @@ "xpack.licensing.welcomeBanner.licenseIsExpiredDescription.updateYourLicenseLinkText": "更新您的许可", "xpack.licensing.welcomeBanner.licenseIsExpiredTitle": "您的{licenseType}许可已过期" } -} \ No newline at end of file +} diff --git a/x-pack/plugins/watcher/public/legacy/index.ts b/x-pack/plugins/watcher/public/legacy/index.ts index 97b07991ea3c5..d14081a667acc 100644 --- a/x-pack/plugins/watcher/public/legacy/index.ts +++ b/x-pack/plugins/watcher/public/legacy/index.ts @@ -8,7 +8,7 @@ import { i18n } from '@kbn/i18n'; export { TimeBuckets } from './time_buckets'; export const MANAGEMENT_BREADCRUMB = Object.freeze({ - text: i18n.translate('common.ui.management.breadcrumb', { + text: i18n.translate('xpack.watcher.management.breadcrumb', { defaultMessage: 'Management', }), href: '#/management', diff --git a/x-pack/plugins/watcher/public/legacy/parse_es_interval/invalid_es_calendar_interval_error.ts b/x-pack/plugins/watcher/public/legacy/parse_es_interval/invalid_es_calendar_interval_error.ts index 504442ba0e215..62864c91756c4 100644 --- a/x-pack/plugins/watcher/public/legacy/parse_es_interval/invalid_es_calendar_interval_error.ts +++ b/x-pack/plugins/watcher/public/legacy/parse_es_interval/invalid_es_calendar_interval_error.ts @@ -15,7 +15,7 @@ export class InvalidEsCalendarIntervalError extends Error { public readonly type: string ) { super( - i18n.translate('data.parseEsInterval.invalidEsCalendarIntervalErrorMessage', { + i18n.translate('xpack.watcher.data.parseEsInterval.invalidEsCalendarIntervalErrorMessage', { defaultMessage: 'Invalid calendar interval: {interval}, value must be 1', values: { interval }, }) diff --git a/x-pack/plugins/watcher/public/legacy/parse_es_interval/invalid_es_interval_format_error.ts b/x-pack/plugins/watcher/public/legacy/parse_es_interval/invalid_es_interval_format_error.ts index b10b13516fc46..894a4fd5d6922 100644 --- a/x-pack/plugins/watcher/public/legacy/parse_es_interval/invalid_es_interval_format_error.ts +++ b/x-pack/plugins/watcher/public/legacy/parse_es_interval/invalid_es_interval_format_error.ts @@ -9,7 +9,7 @@ import { i18n } from '@kbn/i18n'; export class InvalidEsIntervalFormatError extends Error { constructor(public readonly interval: string) { super( - i18n.translate('data.parseEsInterval.invalidEsIntervalFormatErrorMessage', { + i18n.translate('xpack.watcher.data.parseEsInterval.invalidEsIntervalFormatErrorMessage', { defaultMessage: 'Invalid interval format: {interval}', values: { interval }, }) diff --git a/x-pack/plugins/watcher/public/plugin.ts b/x-pack/plugins/watcher/public/plugin.ts index f88a422f0a27f..6638f7cec0ab5 100644 --- a/x-pack/plugins/watcher/public/plugin.ts +++ b/x-pack/plugins/watcher/public/plugin.ts @@ -3,39 +3,46 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -// import { i18n } from '@kbn/i18n'; +import { i18n } from '@kbn/i18n'; import { CoreSetup, Plugin, CoreStart } from 'kibana/public'; +import { FeatureCatalogueCategory } from '../../../../src/plugins/home/public'; + +import { LICENSE_CHECK_STATE } from '../../licensing/public'; import { TimeBuckets, MANAGEMENT_BREADCRUMB } from './legacy'; import { PLUGIN } from '../common/constants'; -import { LICENSE_CHECK_STATE } from '../../licensing/public'; import { Dependencies } from './types'; export class WatcherUIPlugin implements Plugin { + // Reference for when `mount` gets called, we don't want to render if + // we don't have a valid license. Under certain conditions the Watcher app link + // may still be present so this is a final guard. hasValidLicense: boolean = false; hasRegisteredESManagementSection = false; setup( { application, notifications, http, uiSettings, getStartServices }: CoreSetup, - { licensing, management, data }: Dependencies + { licensing, management, data, home }: Dependencies ) { licensing.license$.subscribe(license => { const { state } = license.check(PLUGIN.ID, PLUGIN.MINIMUM_LICENSE_REQUIRED); this.hasValidLicense = state === LICENSE_CHECK_STATE.Valid && license.getFeature(PLUGIN.ID).isAvailable; - if (this.hasValidLicense) { const esSection = management.sections.getSection('elasticsearch'); if (esSection) { if (!this.hasRegisteredESManagementSection) { esSection.registerApp({ id: 'watcher', - title: 'Watcher', + title: i18n.translate( + 'xpack.watcher.sections.watchList.managementSection.watcherDisplayName', + { defaultMessage: 'Watcher' } + ), mount: async ({ element }) => { if (!this.hasValidLicense) { return () => undefined; } const [core, plugins] = await getStartServices(); - const { chrome, i18n, docLinks, savedObjects } = core; + const { chrome, i18n: i18nDep, docLinks, savedObjects } = core; const { eui_utils } = plugins as any; const { boot } = await import('./application/boot'); @@ -48,13 +55,26 @@ export class WatcherUIPlugin implements Plugin { chrome, euiUtils: eui_utils, savedObjects: savedObjects.client, - I18nContext: i18n.Context, + I18nContext: i18nDep.Context, createTimeBuckets: () => new TimeBuckets(uiSettings, data), MANAGEMENT_BREADCRUMB, }); }, }); this.hasRegisteredESManagementSection = true; + + home.featureCatalogue.register({ + id: 'watcher', + title: 'Watcher', // This is a product name so we don't translate it. + category: FeatureCatalogueCategory.ADMIN, + description: i18n.translate('xpack.watcher.watcherDescription', { + defaultMessage: + 'Detect changes in your data by creating, managing, and monitoring alerts.', + }), + icon: 'watchesApp', + path: '/app/kibana#/management/elasticsearch/watcher/watches', + showOnHomePage: true, + }); } else { // App must exist at this point esSection.getApp(PLUGIN.ID)!.enable(); diff --git a/x-pack/plugins/watcher/public/types.ts b/x-pack/plugins/watcher/public/types.ts index 7489e00309848..930185051514a 100644 --- a/x-pack/plugins/watcher/public/types.ts +++ b/x-pack/plugins/watcher/public/types.ts @@ -8,8 +8,10 @@ import { ManagementSetup } from 'src/plugins/management/public'; import { EuiUtilsStart } from 'src/plugins/eui_utils/public'; import { LicensingPluginSetup } from '../../licensing/public'; import { DataPublicPluginSetup } from '../../../../src/plugins/data/public'; +import { HomePublicPluginSetup } from '../../../../src/plugins/home/public'; export interface Dependencies { + home: HomePublicPluginSetup; management: ManagementSetup; licensing: LicensingPluginSetup; eui_utils: EuiUtilsStart; From 84720a79b10301df8575a3b72534e34a1da74aa9 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Mon, 20 Jan 2020 10:34:40 +0100 Subject: [PATCH 13/15] Remove watcher license error check copy --- x-pack/plugins/translations/translations/ja-JP.json | 2 -- x-pack/plugins/translations/translations/zh-CN.json | 2 -- 2 files changed, 4 deletions(-) diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 3e7e11d0f96f9..31519470fef9a 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -12886,8 +12886,6 @@ "xpack.uptime.snapshotHistogram.yAxis.title": "ピング", "xpack.uptime.snapshotHistogram.yAxisId": "スナップショットY軸", "xpack.uptime.uptimeFeatureCatalogueTitle": "起動時間", - "xpack.watcher.app.licenseErrorLinkText": "ライセンスを管理します。", - "xpack.watcher.app.licenseErrorTitle": "ライセンスエラー", "xpack.watcher.appName": "Watcher", "xpack.watcher.breadcrumb.createLabel": "作成", "xpack.watcher.breadcrumb.editLabel": "編集", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 4decf9272969b..096f55665659a 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -12885,8 +12885,6 @@ "xpack.uptime.snapshotHistogram.yAxis.title": "Ping", "xpack.uptime.snapshotHistogram.yAxisId": "快照 Y 轴", "xpack.uptime.uptimeFeatureCatalogueTitle": "运行时间", - "xpack.watcher.app.licenseErrorLinkText": "管理您的许可。", - "xpack.watcher.app.licenseErrorTitle": "许可错误", "xpack.watcher.appName": "Watcher", "xpack.watcher.breadcrumb.createLabel": "创建", "xpack.watcher.breadcrumb.editLabel": "缂栬緫", From ea6fbbefb4220ff0344e9a291d2c2bd953eadd69 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Mon, 20 Jan 2020 16:20:11 +0100 Subject: [PATCH 14/15] Restore license error message in watcher --- .../translations/translations/ja-JP.json | 2 + .../translations/translations/zh-CN.json | 2 + .../watcher/common/types/license_status.ts | 10 ++ .../watcher/public/application/app.tsx | 31 +++++ x-pack/plugins/watcher/public/plugin.ts | 115 ++++++++---------- 5 files changed, 98 insertions(+), 62 deletions(-) create mode 100644 x-pack/plugins/watcher/common/types/license_status.ts diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 74725abe6afe3..f09c4c6b352e4 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -12885,6 +12885,8 @@ "xpack.uptime.snapshotHistogram.yAxis.title": "ピング", "xpack.uptime.snapshotHistogram.yAxisId": "スナップショットY軸", "xpack.uptime.uptimeFeatureCatalogueTitle": "起動時間", + "xpack.watcher.app.licenseErrorLinkText": "ライセンスを管理します。", + "xpack.watcher.app.licenseErrorTitle": "ライセンスエラー", "xpack.watcher.appName": "Watcher", "xpack.watcher.breadcrumb.createLabel": "作成", "xpack.watcher.breadcrumb.editLabel": "編集", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index a634c523fae48..babc58f19dcd1 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -12884,6 +12884,8 @@ "xpack.uptime.snapshotHistogram.yAxis.title": "Ping", "xpack.uptime.snapshotHistogram.yAxisId": "快照 Y 轴", "xpack.uptime.uptimeFeatureCatalogueTitle": "运行时间", + "xpack.watcher.app.licenseErrorLinkText": "管理您的许可。", + "xpack.watcher.app.licenseErrorTitle": "许可错误", "xpack.watcher.appName": "Watcher", "xpack.watcher.breadcrumb.createLabel": "创建", "xpack.watcher.breadcrumb.editLabel": "缂栬緫", diff --git a/x-pack/plugins/watcher/common/types/license_status.ts b/x-pack/plugins/watcher/common/types/license_status.ts new file mode 100644 index 0000000000000..3872559fc0066 --- /dev/null +++ b/x-pack/plugins/watcher/common/types/license_status.ts @@ -0,0 +1,10 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export interface LicenseStatus { + valid: boolean; + message?: string; +} diff --git a/x-pack/plugins/watcher/public/application/app.tsx b/x-pack/plugins/watcher/public/application/app.tsx index af203685234a2..83501eca1429b 100644 --- a/x-pack/plugins/watcher/public/application/app.tsx +++ b/x-pack/plugins/watcher/public/application/app.tsx @@ -21,6 +21,12 @@ import { withRouter, RouteComponentProps, } from 'react-router-dom'; + +import { EuiCallOut, EuiLink } from '@elastic/eui'; + +import { FormattedMessage } from '@kbn/i18n/react'; + +import { LicenseStatus } from '../../common/types/license_status'; import { WatchStatus } from './sections/watch_status/components/watch_status'; import { WatchEdit } from './sections/watch_edit/components/watch_edit'; import { WatchList } from './sections/watch_list/components/watch_list'; @@ -41,10 +47,35 @@ export interface AppDeps { uiSettings: IUiSettingsClient; euiUtils: any; createTimeBuckets: () => any; + getLicenseStatus: () => LicenseStatus; MANAGEMENT_BREADCRUMB: any; } export const App = (deps: AppDeps) => { + const { valid, message } = deps.getLicenseStatus(); + + if (!valid) { + return ( + + } + color="danger" + iconType="help" + > + {message}{' '} + + + + + ); + } return ( diff --git a/x-pack/plugins/watcher/public/plugin.ts b/x-pack/plugins/watcher/public/plugin.ts index 6638f7cec0ab5..d59041b41253d 100644 --- a/x-pack/plugins/watcher/public/plugin.ts +++ b/x-pack/plugins/watcher/public/plugin.ts @@ -5,8 +5,11 @@ */ import { i18n } from '@kbn/i18n'; import { CoreSetup, Plugin, CoreStart } from 'kibana/public'; + import { FeatureCatalogueCategory } from '../../../../src/plugins/home/public'; +import { LicenseStatus } from '../common/types/license_status'; + import { LICENSE_CHECK_STATE } from '../../licensing/public'; import { TimeBuckets, MANAGEMENT_BREADCRUMB } from './legacy'; import { PLUGIN } from '../common/constants'; @@ -16,77 +19,65 @@ export class WatcherUIPlugin implements Plugin { // Reference for when `mount` gets called, we don't want to render if // we don't have a valid license. Under certain conditions the Watcher app link // may still be present so this is a final guard. - hasValidLicense: boolean = false; - hasRegisteredESManagementSection = false; + private licenseStatus: LicenseStatus = { valid: false }; + private hasRegisteredESManagementSection = false; setup( { application, notifications, http, uiSettings, getStartServices }: CoreSetup, { licensing, management, data, home }: Dependencies ) { licensing.license$.subscribe(license => { - const { state } = license.check(PLUGIN.ID, PLUGIN.MINIMUM_LICENSE_REQUIRED); - this.hasValidLicense = - state === LICENSE_CHECK_STATE.Valid && license.getFeature(PLUGIN.ID).isAvailable; - if (this.hasValidLicense) { + const { state, message } = license.check(PLUGIN.ID, PLUGIN.MINIMUM_LICENSE_REQUIRED); + this.licenseStatus = { + valid: state === LICENSE_CHECK_STATE.Valid && license.getFeature(PLUGIN.ID).isAvailable, + message, + }; + if (this.licenseStatus.valid) { const esSection = management.sections.getSection('elasticsearch'); - if (esSection) { - if (!this.hasRegisteredESManagementSection) { - esSection.registerApp({ - id: 'watcher', - title: i18n.translate( - 'xpack.watcher.sections.watchList.managementSection.watcherDisplayName', - { defaultMessage: 'Watcher' } - ), - mount: async ({ element }) => { - if (!this.hasValidLicense) { - return () => undefined; - } - const [core, plugins] = await getStartServices(); - const { chrome, i18n: i18nDep, docLinks, savedObjects } = core; - const { eui_utils } = plugins as any; - const { boot } = await import('./application/boot'); + if (esSection && !this.hasRegisteredESManagementSection) { + esSection.registerApp({ + id: 'watcher', + title: i18n.translate( + 'xpack.watcher.sections.watchList.managementSection.watcherDisplayName', + { defaultMessage: 'Watcher' } + ), + mount: async ({ element }) => { + const [core, plugins] = await getStartServices(); + const { chrome, i18n: i18nDep, docLinks, savedObjects } = core; + const { eui_utils } = plugins as any; + const { boot } = await import('./application/boot'); - return boot({ - element, - toasts: notifications.toasts, - http, - uiSettings, - docLinks, - chrome, - euiUtils: eui_utils, - savedObjects: savedObjects.client, - I18nContext: i18nDep.Context, - createTimeBuckets: () => new TimeBuckets(uiSettings, data), - MANAGEMENT_BREADCRUMB, - }); - }, - }); - this.hasRegisteredESManagementSection = true; + return boot({ + getLicenseStatus: () => this.licenseStatus, + element, + toasts: notifications.toasts, + http, + uiSettings, + docLinks, + chrome, + euiUtils: eui_utils, + savedObjects: savedObjects.client, + I18nContext: i18nDep.Context, + createTimeBuckets: () => new TimeBuckets(uiSettings, data), + MANAGEMENT_BREADCRUMB, + }); + }, + }); - home.featureCatalogue.register({ - id: 'watcher', - title: 'Watcher', // This is a product name so we don't translate it. - category: FeatureCatalogueCategory.ADMIN, - description: i18n.translate('xpack.watcher.watcherDescription', { - defaultMessage: - 'Detect changes in your data by creating, managing, and monitoring alerts.', - }), - icon: 'watchesApp', - path: '/app/kibana#/management/elasticsearch/watcher/watches', - showOnHomePage: true, - }); - } else { - // App must exist at this point - esSection.getApp(PLUGIN.ID)!.enable(); - } - } - } else { - const esSection = management.sections.getSection('elasticsearch'); - if (esSection) { - const app = esSection.getApp(PLUGIN.ID); - if (app) { - app.disable(); - } + home.featureCatalogue.register({ + id: 'watcher', + title: 'Watcher', // This is a product name so we don't translate it. + category: FeatureCatalogueCategory.ADMIN, + description: i18n.translate('xpack.watcher.watcherDescription', { + defaultMessage: + 'Detect changes in your data by creating, managing, and monitoring alerts.', + }), + icon: 'watchesApp', + path: '/app/kibana#/management/elasticsearch/watcher/watches', + showOnHomePage: true, + }); + + this.hasRegisteredESManagementSection = true; } } }); From b680298012e24437141d525e7eb4700f449ed63c Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Mon, 20 Jan 2020 17:12:32 +0100 Subject: [PATCH 15/15] Fix mock context value --- .../__jest__/client_integration/helpers/app_context.mock.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/x-pack/plugins/watcher/__jest__/client_integration/helpers/app_context.mock.tsx b/x-pack/plugins/watcher/__jest__/client_integration/helpers/app_context.mock.tsx index 9c75b782c3094..3d8ae2894b320 100644 --- a/x-pack/plugins/watcher/__jest__/client_integration/helpers/app_context.mock.tsx +++ b/x-pack/plugins/watcher/__jest__/client_integration/helpers/app_context.mock.tsx @@ -27,6 +27,9 @@ class MockTimeBuckets { } } export const mockContextValue = { + getLicenseStatus: () => ({ + valid: true, + }), docLinks: docLinksServiceMock.createStartContract(), chrome: chromeServiceMock.createStartContract(), MANAGEMENT_BREADCRUMB: { text: 'test' },