From 7223ba5ceeac295a2ef167a2be7dde6b46af58a3 Mon Sep 17 00:00:00 2001 From: Zacqary Adam Xeper Date: Tue, 3 Dec 2024 12:40:48 -0600 Subject: [PATCH] [ResponseOps][Rules] Move Rule Form code into @kbn/response-ops-rule-form (#198725) ## Summary Part of #195211 Moves Rule Form code out of `@kbn/alerts-ui-shared` and into a new package called `@kbn/response-ops-rule-form`. Some types and hooks that are used by multiple features or solutions are still in `@kbn/alerts-ui-shared` and have been rerouted. The bulk of Rule Form-specific code is in this new package. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Kevin Delemme --- .github/CODEOWNERS | 1 + .i18nrc.json | 5 +- package.json | 1 + packages/kbn-alerts-ui-shared/index.ts | 4 + packages/kbn-alerts-ui-shared/lib/README.md | 1 + packages/kbn-alerts-ui-shared/lib/index.ts | 11 + .../src/action_variables/transforms.test.ts | 2 +- .../check_action_type_enabled.scss | 0 .../check_action_type_enabled.test.ts | 4 +- .../check_action_type_enabled.ts | 4 +- .../get_license_check_result.tsx | 2 +- .../src/check_action_type_enabled/index.ts | 10 + .../src/common/apis/index.ts | 7 +- .../src/common/constants/index.ts | 2 + .../src/common/hooks/index.ts | 8 - .../hooks/use_fetch_alerts_fields_query.ts | 4 +- .../use_fetch_alerts_index_names_query.ts | 4 +- .../hooks/use_fetch_flapping_settings.ts | 2 +- .../common/hooks/use_load_rule_types_query.ts | 15 +- .../src/common/transformations/index.ts | 1 - .../src/rule_settings/index.ts | 14 + packages/kbn-alerts-ui-shared/tsconfig.json | 22 +- .../rule_types.ts | 4 + packages/response-ops/rule_form/README.md | 3 + packages/response-ops/rule_form/index.ts | 32 ++ .../response-ops/rule_form/jest.config.js | 15 + packages/response-ops/rule_form/kibana.jsonc | 5 + packages/response-ops/rule_form/package.json | 6 + .../response-ops/rule_form/setup_tests.ts | 11 + .../apis/create_rule/create_rule.test.ts | 0 .../common/apis/create_rule/create_rule.ts | 2 +- .../src/common/apis/create_rule/index.ts | 0 .../transform_create_rule_body.test.ts | 0 .../create_rule/transform_create_rule_body.ts | 0 .../src/common/apis/create_rule/types.ts | 0 .../src/common/apis/fetch_rule_types.ts | 54 +++ .../fetch_ui_config/fetch_ui_config.test.ts | 0 .../apis/fetch_ui_config/fetch_ui_config.ts | 2 +- .../src/common/apis/fetch_ui_config/index.ts | 0 .../src/common/apis/fetch_ui_config/types.ts | 0 .../rule_form/src/common/apis/index.ts | 13 + .../src/common/apis/resolve_rule/index.ts | 0 .../apis/resolve_rule/resolve_rule.test.ts | 0 .../common/apis/resolve_rule/resolve_rule.ts | 2 +- .../src/common/apis/update_rule/index.ts | 0 .../transform_update_rule_body.test.ts | 0 .../update_rule/transform_update_rule_body.ts | 0 .../src/common/apis/update_rule/types.ts | 0 .../apis/update_rule/update_rule.test.ts | 0 .../common/apis/update_rule/update_rule.ts | 2 +- .../rule_form/src/common/hooks/index.ts | 15 + .../src/common/hooks/use_create_rule.test.tsx | 0 .../src/common/hooks/use_create_rule.ts | 0 .../hooks/use_load_connector_types.test.tsx | 0 .../common/hooks/use_load_connector_types.ts | 2 +- .../common/hooks/use_load_connectors.test.tsx | 0 .../src/common/hooks/use_load_connectors.ts | 2 +- ...oad_rule_type_aad_template_fields.test.tsx | 0 .../use_load_rule_type_aad_template_fields.ts | 7 +- .../src/common/hooks/use_load_ui_config.ts | 0 .../common/hooks/use_resolve_rule.test.tsx | 0 .../src/common/hooks/use_resolve_rule.ts | 2 +- .../src/common/hooks/use_update_rule.test.tsx | 0 .../src/common/hooks/use_update_rule.ts | 0 .../rule_form}/src/common/i18n.ts | 22 +- .../rule_form/src/common}/index.ts | 2 +- .../common/test_utils/actions_test_utils.ts | 9 +- .../src/common/transformations/index.ts | 10 + .../common/transformations/transform_rule.ts | 4 +- .../rule_form/src/common/types/index.ts | 10 + .../rule_form/src/constants/index.ts} | 17 +- .../rule_form/src/constants/routes.ts | 12 + .../rule_form/src/constants/rule_flapping.ts | 11 + .../rule_form/src}/create_rule_form.tsx | 2 +- .../rule_form/src}/edit_rule_form.tsx | 2 +- .../rule_form/src}/hooks/index.ts | 0 .../src}/hooks/use_load_dependencies.test.tsx | 38 ++- .../src}/hooks/use_load_dependencies.ts | 18 +- .../src}/hooks/use_rule_form_dispatch.ts | 0 .../src}/hooks/use_rule_form_state.ts | 0 .../rule_form/src/rule_actions}/index.ts | 10 +- .../src}/rule_actions/rule_actions.test.tsx | 10 +- .../src}/rule_actions/rule_actions.tsx | 3 +- .../rule_actions_alerts_filter.test.tsx | 6 +- .../rule_actions_alerts_filter.tsx | 14 +- ...e_actions_alerts_filter_timeframe.test.tsx | 2 +- .../rule_actions_alerts_filter_timeframe.tsx | 10 +- .../rule_actions_connectors_modal.test.tsx | 6 +- .../rule_actions_connectors_modal.tsx | 31 +- .../rule_actions/rule_actions_item.test.tsx | 10 +- .../src}/rule_actions/rule_actions_item.tsx | 24 +- .../rule_actions_message.test.tsx | 6 +- .../rule_actions/rule_actions_message.tsx | 3 +- .../rule_actions_notify_when.test.tsx | 0 .../rule_actions/rule_actions_notify_when.tsx | 44 +-- .../rule_actions_settings.test.tsx | 4 +- .../rule_actions/rule_actions_settings.tsx | 6 +- .../rule_actions_system_actions_item.test.tsx | 6 +- .../rule_actions_system_actions_item.tsx | 27 +- .../rule_form/src}/rule_definition/index.ts | 0 .../rule_definition/rule_alert_delay.test.tsx | 0 .../src}/rule_definition/rule_alert_delay.tsx | 0 .../rule_consumer_selection.test.tsx | 0 .../rule_consumer_selection.tsx | 0 .../rule_definition/rule_definition.test.tsx | 8 +- .../src}/rule_definition/rule_definition.tsx | 48 +-- .../rule_definition/rule_schedule.test.tsx | 0 .../src}/rule_definition/rule_schedule.tsx | 2 +- .../rule_form/src}/rule_details/index.ts | 0 .../src}/rule_details/rule_details.test.tsx | 0 .../src}/rule_details/rule_details.tsx | 0 .../rule_form/src}/rule_form.tsx | 0 .../rule_form/src}/rule_form_errors/index.ts | 0 .../rule_form_action_permission_error.tsx | 0 .../rule_form_circuit_breaker_error.test.tsx | 0 .../rule_form_circuit_breaker_error.tsx | 0 .../rule_form_error_prompt_wrapper.tsx | 0 .../rule_form_health_check_error.test.tsx | 2 +- .../rule_form_health_check_error.tsx | 2 +- .../rule_form_resolve_rule_error.tsx | 0 .../rule_form_rule_type_error.tsx | 0 .../rule_form/src}/rule_form_state/index.ts | 0 .../rule_form_state_context.tsx | 0 .../rule_form_state_provider.tsx | 0 .../rule_form_state_reducer.test.tsx | 2 +- .../rule_form_state_reducer.ts | 2 +- .../rule_form/src}/rule_page/index.ts | 0 .../src}/rule_page/rule_page.test.tsx | 0 .../rule_form/src}/rule_page/rule_page.tsx | 42 ++- .../rule_page_confirm_create_rule.test.tsx | 0 .../rule_page_confirm_create_rule.tsx | 0 .../src}/rule_page/rule_page_footer.test.tsx | 0 .../src}/rule_page/rule_page_footer.tsx | 0 .../rule_page/rule_page_name_input.test.tsx | 0 .../src}/rule_page/rule_page_name_input.tsx | 0 .../rule_page_show_request_modal.test.tsx | 0 .../rule_page_show_request_modal.tsx | 18 +- .../filter_and_count_rule_types.test.ts | 0 .../helpers/filter_and_count_rule_types.ts | 0 .../src/rule_type_modal/components/index.tsx | 2 +- .../components/rule_type_list.test.tsx | 0 .../components/rule_type_list.tsx | 22 +- .../components/rule_type_modal.tsx | 6 +- .../rule_form}/src/rule_type_modal/index.tsx | 0 .../rule_form}/src/rule_type_modal/types.ts | 0 .../rule_form/src}/translations.ts | 240 +++++++------ .../rule_form/src}/types.ts | 27 +- .../src}/utils/get_authorized_consumers.ts | 2 +- .../src}/utils/get_authorized_rule_types.ts | 6 +- .../src}/utils/get_default_params.ts | 3 +- .../src}/utils/get_initial_consumer.ts | 2 +- .../src}/utils/get_initial_multi_consumer.ts | 2 +- .../src}/utils/get_initial_schedule.ts | 2 +- .../utils/get_selected_action_group.test.ts | 2 +- .../src}/utils/get_selected_action_group.ts | 4 +- .../src}/utils/get_time_options.test.ts | 0 .../rule_form/src}/utils/get_time_options.ts | 8 +- .../src}/utils/has_fields_for_aad.test.ts | 2 +- .../src}/utils/has_fields_for_aad.ts | 2 +- .../rule_form/src}/utils/index.ts | 0 .../src}/utils/parse_duration.test.ts | 0 .../rule_form/src}/utils/parse_duration.ts | 0 ...arse_rule_circuit_breaker_error_message.ts | 0 .../rule_form/src}/validation/index.ts | 0 .../src}/validation/validate_form.test.ts | 4 +- .../src}/validation/validate_form.ts | 4 +- .../validate_params_for_warnings.test.ts | 0 .../validate_params_for_warnings.ts | 2 +- packages/response-ops/rule_form/tsconfig.json | 43 +++ tsconfig.base.json | 2 + .../public/application.tsx | 6 +- .../triggers_actions_ui_example/tsconfig.json | 2 +- .../public/pages/rules/rules.tsx | 2 +- .../observability/tsconfig.json | 3 +- .../connector_types/inference/params.tsx | 2 +- x-pack/plugins/stack_connectors/tsconfig.json | 2 +- .../translations/translations/fr-FR.json | 322 +++++++----------- .../translations/translations/ja-JP.json | 207 ----------- .../translations/translations/zh-CN.json | 177 ---------- .../hooks/use_load_config_query.ts | 2 +- .../public/application/lib/index.ts | 1 - .../action_connector_form/action_form.tsx | 2 +- .../action_type_form.tsx | 11 +- .../action_type_menu.tsx | 2 +- .../system_action_type_form.tsx | 3 +- .../components/actions_connectors_list.tsx | 2 +- .../with_bulk_rule_api_operations.test.tsx | 6 +- .../with_bulk_rule_api_operations.tsx | 2 +- .../components/rule_details.test.tsx | 2 +- .../rule_details/components/rule_details.tsx | 2 +- .../components/rule_details_route.test.tsx | 2 +- .../sections/rule_form/rule_add.test.tsx | 8 +- .../sections/rule_form/rule_add.tsx | 55 +-- .../sections/rule_form/rule_edit.test.tsx | 4 +- .../sections/rule_form/rule_edit.tsx | 58 ++-- .../sections/rule_form/rule_form_route.tsx | 2 +- .../sections/rule_form/show_request_modal.tsx | 20 +- .../rules_list/components/rules_list.test.tsx | 2 +- .../rules_list/components/rules_list.tsx | 2 +- .../rules_list_bulk_delete.test.tsx | 2 +- .../rules_list_bulk_disable.test.tsx | 2 +- .../components/rules_list_bulk_edit.test.tsx | 2 +- .../rules_list_bulk_enable.test.tsx | 2 +- .../triggers_actions_ui/public/index.ts | 2 +- .../triggers_actions_ui/public/types.ts | 217 ++++++------ .../plugins/triggers_actions_ui/tsconfig.json | 3 +- .../services/observability/alerts/common.ts | 5 + .../apps/observability/pages/alerts/index.ts | 1 + yarn.lock | 4 + 209 files changed, 1110 insertions(+), 1236 deletions(-) create mode 100644 packages/kbn-alerts-ui-shared/lib/README.md create mode 100644 packages/kbn-alerts-ui-shared/lib/index.ts rename packages/kbn-alerts-ui-shared/src/{rule_form/utils => check_action_type_enabled}/check_action_type_enabled.scss (100%) rename packages/kbn-alerts-ui-shared/src/{rule_form/utils => check_action_type_enabled}/check_action_type_enabled.test.ts (98%) rename packages/kbn-alerts-ui-shared/src/{rule_form/utils => check_action_type_enabled}/check_action_type_enabled.ts (97%) rename packages/kbn-alerts-ui-shared/src/{rule_form/utils => check_action_type_enabled}/get_license_check_result.tsx (97%) create mode 100644 packages/kbn-alerts-ui-shared/src/check_action_type_enabled/index.ts create mode 100644 packages/kbn-alerts-ui-shared/src/rule_settings/index.ts create mode 100644 packages/response-ops/rule_form/README.md create mode 100644 packages/response-ops/rule_form/index.ts create mode 100644 packages/response-ops/rule_form/jest.config.js create mode 100644 packages/response-ops/rule_form/kibana.jsonc create mode 100644 packages/response-ops/rule_form/package.json create mode 100644 packages/response-ops/rule_form/setup_tests.ts rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/apis/create_rule/create_rule.test.ts (100%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/apis/create_rule/create_rule.ts (94%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/apis/create_rule/index.ts (100%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/apis/create_rule/transform_create_rule_body.test.ts (100%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/apis/create_rule/transform_create_rule_body.ts (100%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/apis/create_rule/types.ts (100%) create mode 100644 packages/response-ops/rule_form/src/common/apis/fetch_rule_types.ts rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/apis/fetch_ui_config/fetch_ui_config.test.ts (100%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/apis/fetch_ui_config/fetch_ui_config.ts (91%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/apis/fetch_ui_config/index.ts (100%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/apis/fetch_ui_config/types.ts (100%) create mode 100644 packages/response-ops/rule_form/src/common/apis/index.ts rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/apis/resolve_rule/index.ts (100%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/apis/resolve_rule/resolve_rule.test.ts (100%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/apis/resolve_rule/resolve_rule.ts (93%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/apis/update_rule/index.ts (100%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/apis/update_rule/transform_update_rule_body.test.ts (100%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/apis/update_rule/transform_update_rule_body.ts (100%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/apis/update_rule/types.ts (100%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/apis/update_rule/update_rule.test.ts (100%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/apis/update_rule/update_rule.ts (96%) create mode 100644 packages/response-ops/rule_form/src/common/hooks/index.ts rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/hooks/use_create_rule.test.tsx (100%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/hooks/use_create_rule.ts (100%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/hooks/use_load_connector_types.test.tsx (100%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/hooks/use_load_connector_types.ts (92%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/hooks/use_load_connectors.test.tsx (100%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/hooks/use_load_connectors.ts (93%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/hooks/use_load_rule_type_aad_template_fields.test.tsx (100%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/hooks/use_load_rule_type_aad_template_fields.ts (91%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/hooks/use_load_ui_config.ts (100%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/hooks/use_resolve_rule.test.tsx (100%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/hooks/use_resolve_rule.ts (97%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/hooks/use_update_rule.test.tsx (100%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/hooks/use_update_rule.ts (100%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/i18n.ts (53%) rename packages/{kbn-alerts-ui-shared/src/rule_form/rule_actions => response-ops/rule_form/src/common}/index.ts (93%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/test_utils/actions_test_utils.ts (91%) create mode 100644 packages/response-ops/rule_form/src/common/transformations/index.ts rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/common/transformations/transform_rule.ts (95%) create mode 100644 packages/response-ops/rule_form/src/common/types/index.ts rename packages/{kbn-alerts-ui-shared/src/rule_form/constants.ts => response-ops/rule_form/src/constants/index.ts} (84%) create mode 100644 packages/response-ops/rule_form/src/constants/routes.ts create mode 100644 packages/response-ops/rule_form/src/constants/rule_flapping.ts rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/create_rule_form.tsx (99%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/edit_rule_form.tsx (99%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/hooks/index.ts (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/hooks/use_load_dependencies.test.tsx (88%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/hooks/use_load_dependencies.ts (92%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/hooks/use_rule_form_dispatch.ts (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/hooks/use_rule_form_state.ts (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src/rule_actions}/index.ts (71%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_actions/rule_actions.test.tsx (96%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_actions/rule_actions.tsx (97%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_actions/rule_actions_alerts_filter.test.tsx (97%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_actions/rule_actions_alerts_filter.tsx (91%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_actions/rule_actions_alerts_filter_timeframe.test.tsx (98%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_actions/rule_actions_alerts_filter_timeframe.tsx (94%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_actions/rule_actions_connectors_modal.test.tsx (98%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_actions/rule_actions_connectors_modal.tsx (98%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_actions/rule_actions_item.test.tsx (96%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_actions/rule_actions_item.tsx (96%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_actions/rule_actions_message.test.tsx (98%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_actions/rule_actions_message.tsx (97%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_actions/rule_actions_notify_when.test.tsx (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_actions/rule_actions_notify_when.tsx (88%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_actions/rule_actions_settings.test.tsx (99%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_actions/rule_actions_settings.tsx (97%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_actions/rule_actions_system_actions_item.test.tsx (98%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_actions/rule_actions_system_actions_item.tsx (97%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_definition/index.ts (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_definition/rule_alert_delay.test.tsx (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_definition/rule_alert_delay.tsx (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_definition/rule_consumer_selection.test.tsx (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_definition/rule_consumer_selection.tsx (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_definition/rule_definition.test.tsx (97%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_definition/rule_definition.tsx (96%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_definition/rule_schedule.test.tsx (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_definition/rule_schedule.tsx (98%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_details/index.ts (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_details/rule_details.test.tsx (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_details/rule_details.tsx (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_form.tsx (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_form_errors/index.ts (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_form_errors/rule_form_action_permission_error.tsx (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_form_errors/rule_form_circuit_breaker_error.test.tsx (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_form_errors/rule_form_circuit_breaker_error.tsx (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_form_errors/rule_form_error_prompt_wrapper.tsx (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_form_errors/rule_form_health_check_error.test.tsx (97%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_form_errors/rule_form_health_check_error.tsx (97%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_form_errors/rule_form_resolve_rule_error.tsx (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_form_errors/rule_form_rule_type_error.tsx (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_form_state/index.ts (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_form_state/rule_form_state_context.tsx (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_form_state/rule_form_state_provider.tsx (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_form_state/rule_form_state_reducer.test.tsx (99%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_form_state/rule_form_state_reducer.ts (99%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_page/index.ts (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_page/rule_page.test.tsx (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_page/rule_page.tsx (94%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_page/rule_page_confirm_create_rule.test.tsx (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_page/rule_page_confirm_create_rule.tsx (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_page/rule_page_footer.test.tsx (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_page/rule_page_footer.tsx (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_page/rule_page_name_input.test.tsx (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_page/rule_page_name_input.tsx (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_page/rule_page_show_request_modal.test.tsx (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/rule_page/rule_page_show_request_modal.tsx (86%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/rule_type_modal/components/helpers/filter_and_count_rule_types.test.ts (100%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/rule_type_modal/components/helpers/filter_and_count_rule_types.ts (100%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/rule_type_modal/components/index.tsx (97%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/rule_type_modal/components/rule_type_list.test.tsx (100%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/rule_type_modal/components/rule_type_list.tsx (89%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/rule_type_modal/components/rule_type_modal.tsx (94%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/rule_type_modal/index.tsx (100%) rename packages/{kbn-alerts-ui-shared => response-ops/rule_form}/src/rule_type_modal/types.ts (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/translations.ts (62%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/types.ts (92%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/utils/get_authorized_consumers.ts (94%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/utils/get_authorized_rule_types.ts (96%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/utils/get_default_params.ts (90%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/utils/get_initial_consumer.ts (93%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/utils/get_initial_multi_consumer.ts (98%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/utils/get_initial_schedule.ts (98%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/utils/get_selected_action_group.test.ts (99%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/utils/get_selected_action_group.ts (95%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/utils/get_time_options.test.ts (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/utils/get_time_options.ts (86%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/utils/has_fields_for_aad.test.ts (97%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/utils/has_fields_for_aad.ts (95%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/utils/index.ts (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/utils/parse_duration.test.ts (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/utils/parse_duration.ts (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/utils/parse_rule_circuit_breaker_error_message.ts (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/validation/index.ts (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/validation/validate_form.test.ts (97%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/validation/validate_form.ts (97%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/validation/validate_params_for_warnings.test.ts (100%) rename packages/{kbn-alerts-ui-shared/src/rule_form => response-ops/rule_form/src}/validation/validate_params_for_warnings.ts (94%) create mode 100644 packages/response-ops/rule_form/tsconfig.json diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index b2c49732f70d3..6c70346b65ced 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -561,6 +561,7 @@ packages/react/kibana_context/styled @elastic/appex-sharedux packages/react/kibana_context/theme @elastic/appex-sharedux packages/react/kibana_mount @elastic/appex-sharedux packages/response-ops/feature_flag_service @elastic/response-ops +packages/response-ops/rule_form @elastic/response-ops packages/response-ops/rule_params @elastic/response-ops packages/serverless/project_switcher @elastic/appex-sharedux packages/serverless/settings/common @elastic/appex-sharedux @elastic/kibana-management diff --git a/.i18nrc.json b/.i18nrc.json index 5c7642e6283eb..38629974722f3 100644 --- a/.i18nrc.json +++ b/.i18nrc.json @@ -117,7 +117,7 @@ "searchTypes": "packages/kbn-search-types", "securitySolutionPackages": "x-pack/packages/security-solution", "serverlessPackages": "packages/serverless", - "sse": [ "packages/kbn-sse-utils" ], + "sse": ["packages/kbn-sse-utils"], "coloring": "packages/kbn-coloring/src", "languageDocumentation": "packages/kbn-language-documentation/src", "esql": "src/plugins/esql", @@ -154,7 +154,8 @@ "unifiedDataTable": "packages/kbn-unified-data-table", "unsavedChangesBadge": "packages/kbn-unsaved-changes-badge", "unsavedChangesPrompt": "packages/kbn-unsaved-changes-prompt", - "managedContentBadge": "packages/kbn-managed-content-badge" + "managedContentBadge": "packages/kbn-managed-content-badge", + "responseOpsRuleForm": "packages/response-ops/rule_form" }, "translations": [] } diff --git a/package.json b/package.json index 791295f9e8400..cca5b35d07ad7 100644 --- a/package.json +++ b/package.json @@ -759,6 +759,7 @@ "@kbn/resizable-layout-examples-plugin": "link:examples/resizable_layout_examples", "@kbn/resolver-test-plugin": "link:x-pack/test/plugin_functional/plugins/resolver_test", "@kbn/response-ops-feature-flag-service": "link:packages/response-ops/feature_flag_service", + "@kbn/response-ops-rule-form": "link:packages/response-ops/rule_form", "@kbn/response-ops-rule-params": "link:packages/response-ops/rule_params", "@kbn/response-stream-plugin": "link:examples/response_stream", "@kbn/rison": "link:packages/kbn-rison", diff --git a/packages/kbn-alerts-ui-shared/index.ts b/packages/kbn-alerts-ui-shared/index.ts index a81942a5f956c..c579fa7ed74fd 100644 --- a/packages/kbn-alerts-ui-shared/index.ts +++ b/packages/kbn-alerts-ui-shared/index.ts @@ -19,3 +19,7 @@ export type { AlertsSearchBarProps } from './src/alerts_search_bar/types'; export * from './src/alert_fields_table'; export * from './src/alert_filter_controls/types'; export * from './src/common/types'; +export * from './src/check_action_type_enabled'; +export * from './src/action_variables'; + +export { useFetchFlappingSettings } from './src/common/hooks/use_fetch_flapping_settings'; diff --git a/packages/kbn-alerts-ui-shared/lib/README.md b/packages/kbn-alerts-ui-shared/lib/README.md new file mode 100644 index 0000000000000..3034f4804bd7c --- /dev/null +++ b/packages/kbn-alerts-ui-shared/lib/README.md @@ -0,0 +1 @@ +Export files in here that are only meant to be used by other KBN packages and not directly imported by plugins. This helps to keep bundle sizes efficient. diff --git a/packages/kbn-alerts-ui-shared/lib/index.ts b/packages/kbn-alerts-ui-shared/lib/index.ts new file mode 100644 index 0000000000000..808c936f18d27 --- /dev/null +++ b/packages/kbn-alerts-ui-shared/lib/index.ts @@ -0,0 +1,11 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +export * from '../src/common/type_registry'; +export * from '../src/rule_settings'; diff --git a/packages/kbn-alerts-ui-shared/src/action_variables/transforms.test.ts b/packages/kbn-alerts-ui-shared/src/action_variables/transforms.test.ts index 6f362fd34710b..8411ff911e284 100644 --- a/packages/kbn-alerts-ui-shared/src/action_variables/transforms.test.ts +++ b/packages/kbn-alerts-ui-shared/src/action_variables/transforms.test.ts @@ -9,7 +9,7 @@ import { ActionVariables, RuleType } from '@kbn/triggers-actions-ui-types'; import { transformActionVariables } from './transforms'; -import { ALERTING_FEATURE_ID } from '../rule_form'; +import { ALERTING_FEATURE_ID } from '../common/constants'; beforeEach(() => jest.resetAllMocks()); diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/utils/check_action_type_enabled.scss b/packages/kbn-alerts-ui-shared/src/check_action_type_enabled/check_action_type_enabled.scss similarity index 100% rename from packages/kbn-alerts-ui-shared/src/rule_form/utils/check_action_type_enabled.scss rename to packages/kbn-alerts-ui-shared/src/check_action_type_enabled/check_action_type_enabled.scss diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/utils/check_action_type_enabled.test.ts b/packages/kbn-alerts-ui-shared/src/check_action_type_enabled/check_action_type_enabled.test.ts similarity index 98% rename from packages/kbn-alerts-ui-shared/src/rule_form/utils/check_action_type_enabled.test.ts rename to packages/kbn-alerts-ui-shared/src/check_action_type_enabled/check_action_type_enabled.test.ts index 7794f83825c76..8c1017af17f73 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_form/utils/check_action_type_enabled.test.ts +++ b/packages/kbn-alerts-ui-shared/src/check_action_type_enabled/check_action_type_enabled.test.ts @@ -8,11 +8,11 @@ */ import { ActionType } from '@kbn/actions-types'; +import { PreConfiguredActionConnector } from '../common/types'; import { - checkActionTypeEnabled, checkActionFormActionTypeEnabled, + checkActionTypeEnabled, } from './check_action_type_enabled'; -import { PreConfiguredActionConnector } from '../../common'; describe('checkActionTypeEnabled', () => { test(`returns isEnabled:true when action type isn't provided`, async () => { diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/utils/check_action_type_enabled.ts b/packages/kbn-alerts-ui-shared/src/check_action_type_enabled/check_action_type_enabled.ts similarity index 97% rename from packages/kbn-alerts-ui-shared/src/rule_form/utils/check_action_type_enabled.ts rename to packages/kbn-alerts-ui-shared/src/check_action_type_enabled/check_action_type_enabled.ts index 79c26b7052e86..0df3c542969fd 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_form/utils/check_action_type_enabled.ts +++ b/packages/kbn-alerts-ui-shared/src/check_action_type_enabled/check_action_type_enabled.ts @@ -8,9 +8,9 @@ */ import { ActionType } from '@kbn/actions-types'; -import { configurationCheckResult, getLicenseCheckResult } from './get_license_check_result'; -import { ActionConnector } from '../../common'; +import { ActionConnector } from '../common/types'; import './check_action_type_enabled.scss'; +import { configurationCheckResult, getLicenseCheckResult } from './get_license_check_result'; export interface IsEnabledResult { isEnabled: true; diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/utils/get_license_check_result.tsx b/packages/kbn-alerts-ui-shared/src/check_action_type_enabled/get_license_check_result.tsx similarity index 97% rename from packages/kbn-alerts-ui-shared/src/rule_form/utils/get_license_check_result.tsx rename to packages/kbn-alerts-ui-shared/src/check_action_type_enabled/get_license_check_result.tsx index e4477822ca92f..b774d203f9215 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_form/utils/get_license_check_result.tsx +++ b/packages/kbn-alerts-ui-shared/src/check_action_type_enabled/get_license_check_result.tsx @@ -13,7 +13,7 @@ import { i18n } from '@kbn/i18n'; import { EuiCard, EuiLink } from '@elastic/eui'; import { ActionType } from '@kbn/actions-types'; import { FormattedMessage } from '@kbn/i18n-react'; -import { VIEW_LICENSE_OPTIONS_LINK } from '../../common/constants'; +import { VIEW_LICENSE_OPTIONS_LINK } from '../common/constants'; export const getLicenseCheckResult = (actionType: ActionType) => { return { diff --git a/packages/kbn-alerts-ui-shared/src/check_action_type_enabled/index.ts b/packages/kbn-alerts-ui-shared/src/check_action_type_enabled/index.ts new file mode 100644 index 0000000000000..509a53df7a586 --- /dev/null +++ b/packages/kbn-alerts-ui-shared/src/check_action_type_enabled/index.ts @@ -0,0 +1,10 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +export * from './check_action_type_enabled'; diff --git a/packages/kbn-alerts-ui-shared/src/common/apis/index.ts b/packages/kbn-alerts-ui-shared/src/common/apis/index.ts index 36a68df832c36..16ecd225a01c8 100644 --- a/packages/kbn-alerts-ui-shared/src/common/apis/index.ts +++ b/packages/kbn-alerts-ui-shared/src/common/apis/index.ts @@ -7,13 +7,10 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -export * from './create_rule'; export * from './fetch_alerting_framework_health'; export * from './fetch_alerts_fields'; -export * from './fetch_connector_types'; +export * from './fetch_alerts_index_names'; export * from './fetch_connectors'; +export * from './fetch_connector_types'; export * from './fetch_rule_type_aad_template_fields'; -export * from './fetch_ui_config'; export * from './fetch_ui_health_status'; -export * from './resolve_rule'; -export * from './update_rule'; diff --git a/packages/kbn-alerts-ui-shared/src/common/constants/index.ts b/packages/kbn-alerts-ui-shared/src/common/constants/index.ts index 5213094216c6b..991e151da1957 100644 --- a/packages/kbn-alerts-ui-shared/src/common/constants/index.ts +++ b/packages/kbn-alerts-ui-shared/src/common/constants/index.ts @@ -12,3 +12,5 @@ export * from './i18n_weekdays'; export * from './routes'; export const VIEW_LICENSE_OPTIONS_LINK = 'https://www.elastic.co/subscriptions'; + +export const ALERTING_FEATURE_ID = 'alerts'; diff --git a/packages/kbn-alerts-ui-shared/src/common/hooks/index.ts b/packages/kbn-alerts-ui-shared/src/common/hooks/index.ts index 8abf5482682f5..88cc7a4666d1f 100644 --- a/packages/kbn-alerts-ui-shared/src/common/hooks/index.ts +++ b/packages/kbn-alerts-ui-shared/src/common/hooks/index.ts @@ -8,16 +8,8 @@ */ export * from './use_alerts_data_view'; -export * from './use_create_rule'; -export * from './use_update_rule'; -export * from './use_resolve_rule'; -export * from './use_load_connectors'; -export * from './use_load_connector_types'; export * from './use_get_alerts_group_aggregations_query'; export * from './use_health_check'; export * from './use_load_alerting_framework_health'; export * from './use_load_rule_types_query'; -export * from './use_load_ui_config'; export * from './use_load_ui_health'; -export * from './use_resolve_rule'; -export * from './use_update_rule'; diff --git a/packages/kbn-alerts-ui-shared/src/common/hooks/use_fetch_alerts_fields_query.ts b/packages/kbn-alerts-ui-shared/src/common/hooks/use_fetch_alerts_fields_query.ts index 5099587904f4c..9b4c56e955d46 100644 --- a/packages/kbn-alerts-ui-shared/src/common/hooks/use_fetch_alerts_fields_query.ts +++ b/packages/kbn-alerts-ui-shared/src/common/hooks/use_fetch_alerts_fields_query.ts @@ -14,7 +14,9 @@ import { fetchAlertsFields, FetchAlertsFieldsParams } from '../apis/fetch_alerts export type UseFetchAlertsFieldsQueryParams = FetchAlertsFieldsParams; -export const queryKeyPrefix = ['alerts', fetchAlertsFields.name]; +// Query key prefix MUST contain explicit strings, not fetchAlertsFields.name +// Production builds cannot guarantee a unique function name +export const queryKeyPrefix = ['alerts', 'fetchAlertsFields']; /** * Fetch alerts indexes browser fields for the given feature ids diff --git a/packages/kbn-alerts-ui-shared/src/common/hooks/use_fetch_alerts_index_names_query.ts b/packages/kbn-alerts-ui-shared/src/common/hooks/use_fetch_alerts_index_names_query.ts index 80e53e961f4e3..26a15f8e450ef 100644 --- a/packages/kbn-alerts-ui-shared/src/common/hooks/use_fetch_alerts_index_names_query.ts +++ b/packages/kbn-alerts-ui-shared/src/common/hooks/use_fetch_alerts_index_names_query.ts @@ -16,7 +16,9 @@ import type { QueryOptionsOverrides } from '../types/tanstack_query_utility_type export type UseFetchAlertsIndexNamesQueryParams = FetchAlertsIndexNamesParams; -export const queryKeyPrefix = ['alerts', fetchAlertsIndexNames.name]; +// Query key prefix MUST contain explicit strings, not fetchAlertsIndexNames.name +// Production builds cannot guarantee a unique function name +export const queryKeyPrefix = ['alerts', 'fetchAlertsIndexNames']; /** * Fetch alerts index names feature ids diff --git a/packages/kbn-alerts-ui-shared/src/common/hooks/use_fetch_flapping_settings.ts b/packages/kbn-alerts-ui-shared/src/common/hooks/use_fetch_flapping_settings.ts index 6b72c2fea734b..da1c441892988 100644 --- a/packages/kbn-alerts-ui-shared/src/common/hooks/use_fetch_flapping_settings.ts +++ b/packages/kbn-alerts-ui-shared/src/common/hooks/use_fetch_flapping_settings.ts @@ -8,7 +8,7 @@ */ import { useQuery } from '@tanstack/react-query'; -import { HttpStart } from '@kbn/core-http-browser'; +import type { HttpStart } from '@kbn/core-http-browser'; import { RulesSettingsFlapping } from '@kbn/alerting-types/rule_settings'; import { fetchFlappingSettings } from '../apis/fetch_flapping_settings'; diff --git a/packages/kbn-alerts-ui-shared/src/common/hooks/use_load_rule_types_query.ts b/packages/kbn-alerts-ui-shared/src/common/hooks/use_load_rule_types_query.ts index ecbdab2a585bc..7cd838d0d24cb 100644 --- a/packages/kbn-alerts-ui-shared/src/common/hooks/use_load_rule_types_query.ts +++ b/packages/kbn-alerts-ui-shared/src/common/hooks/use_load_rule_types_query.ts @@ -7,16 +7,19 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { keyBy } from 'lodash'; -import { i18n } from '@kbn/i18n'; -import { useMemo } from 'react'; -import { useQuery } from '@tanstack/react-query'; import type { HttpStart } from '@kbn/core-http-browser'; import type { ToastsStart } from '@kbn/core-notifications-browser'; +import { i18n } from '@kbn/i18n'; import type { RuleType } from '@kbn/triggers-actions-ui-types'; -import { ALERTS_FEATURE_ID } from '../constants'; +import { + RuleTypeIndexWithDescriptions, + RuleTypeWithDescription, +} from '@kbn/triggers-actions-ui-types'; +import { useQuery } from '@tanstack/react-query'; +import { keyBy } from 'lodash'; +import { useMemo } from 'react'; import { fetchRuleTypes } from '../apis/fetch_rule_types'; -import { RuleTypeIndexWithDescriptions, RuleTypeWithDescription } from '../types'; +import { ALERTS_FEATURE_ID } from '../constants'; export interface UseRuleTypesProps { http: HttpStart; diff --git a/packages/kbn-alerts-ui-shared/src/common/transformations/index.ts b/packages/kbn-alerts-ui-shared/src/common/transformations/index.ts index 4350bb38e1ef8..2d50470efdb45 100644 --- a/packages/kbn-alerts-ui-shared/src/common/transformations/index.ts +++ b/packages/kbn-alerts-ui-shared/src/common/transformations/index.ts @@ -8,4 +8,3 @@ */ export * from './transform_action'; -export * from './transform_rule'; diff --git a/packages/kbn-alerts-ui-shared/src/rule_settings/index.ts b/packages/kbn-alerts-ui-shared/src/rule_settings/index.ts new file mode 100644 index 0000000000000..a80abf808a1d1 --- /dev/null +++ b/packages/kbn-alerts-ui-shared/src/rule_settings/index.ts @@ -0,0 +1,14 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +export * from './rule_settings_flapping_form'; +export * from './rule_settings_flapping_inputs'; +export * from './rule_settings_flapping_message'; +export * from './rule_settings_flapping_title_tooltip'; +export * from './rule_settings_range_input'; diff --git a/packages/kbn-alerts-ui-shared/tsconfig.json b/packages/kbn-alerts-ui-shared/tsconfig.json index 317f80dd209f3..07a52c9d9c1b9 100644 --- a/packages/kbn-alerts-ui-shared/tsconfig.json +++ b/packages/kbn-alerts-ui-shared/tsconfig.json @@ -2,19 +2,10 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "outDir": "target/types", - "types": [ - "jest", - "node", - "react" - ] + "types": ["jest", "node", "react"] }, - "include": [ - "**/*.ts", - "**/*.tsx" - ], - "exclude": [ - "target/**/*" - ], + "include": ["**/*.ts", "**/*.tsx"], + "exclude": ["target/**/*"], "kbn_references": [ "@kbn/i18n", "@kbn/rule-data-utils", @@ -40,16 +31,9 @@ "@kbn/search-types", "@kbn/utility-types", "@kbn/safer-lodash-set", - "@kbn/core-application-browser", - "@kbn/react-kibana-mount", - "@kbn/core-i18n-browser", - "@kbn/core-theme-browser", "@kbn/alerts-as-data-utils", - "@kbn/test-jest-helpers", - "@kbn/core-ui-settings-browser", "@kbn/core-http-browser-mocks", "@kbn/core-notifications-browser-mocks", - "@kbn/kibana-react-plugin", "@kbn/shared-ux-table-persist" ] } diff --git a/packages/kbn-triggers-actions-ui-types/rule_types.ts b/packages/kbn-triggers-actions-ui-types/rule_types.ts index 5fe3234e7a136..1d7f8e823b260 100644 --- a/packages/kbn-triggers-actions-ui-types/rule_types.ts +++ b/packages/kbn-triggers-actions-ui-types/rule_types.ts @@ -35,3 +35,7 @@ export interface RuleType< } export type RuleTypeIndex = Map; + +export type RuleTypeWithDescription = RuleType & { description?: string }; + +export type RuleTypeIndexWithDescriptions = Map; diff --git a/packages/response-ops/rule_form/README.md b/packages/response-ops/rule_form/README.md new file mode 100644 index 0000000000000..5196cc65ceedd --- /dev/null +++ b/packages/response-ops/rule_form/README.md @@ -0,0 +1,3 @@ +# @kbn/response-ops-rule-form + +This package contains all components necessary to render the forms for creating and editing rules. diff --git a/packages/response-ops/rule_form/index.ts b/packages/response-ops/rule_form/index.ts new file mode 100644 index 0000000000000..9a654f12bba7b --- /dev/null +++ b/packages/response-ops/rule_form/index.ts @@ -0,0 +1,32 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +export * from './src/types'; +export * from './src/rule_type_modal'; + +export { RuleForm } from './src/rule_form'; + +export { + fetchUiConfig, + createRule, + updateRule, + type CreateRuleBody, + UPDATE_FIELDS_WITH_ACTIONS, + transformCreateRuleBody, + transformUpdateRuleBody, + resolveRule, +} from './src/common/apis'; + +export { CREATE_RULE_ROUTE, EDIT_RULE_ROUTE } from './src/constants'; + +export { + RuleActionsNotifyWhen, + RuleActionsAlertsFilter, + RuleActionsAlertsFilterTimeframe, +} from './src/rule_actions'; diff --git a/packages/response-ops/rule_form/jest.config.js b/packages/response-ops/rule_form/jest.config.js new file mode 100644 index 0000000000000..babc1df67680c --- /dev/null +++ b/packages/response-ops/rule_form/jest.config.js @@ -0,0 +1,15 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../..', + roots: ['/packages/response-ops/rule_form'], + setupFilesAfterEnv: ['/packages/response-ops/rule_form/setup_tests.ts'], +}; diff --git a/packages/response-ops/rule_form/kibana.jsonc b/packages/response-ops/rule_form/kibana.jsonc new file mode 100644 index 0000000000000..e8538a088a557 --- /dev/null +++ b/packages/response-ops/rule_form/kibana.jsonc @@ -0,0 +1,5 @@ +{ + "type": "shared-browser", + "id": "@kbn/response-ops-rule-form", + "owner": "@elastic/response-ops" +} diff --git a/packages/response-ops/rule_form/package.json b/packages/response-ops/rule_form/package.json new file mode 100644 index 0000000000000..c3a412a09c9bb --- /dev/null +++ b/packages/response-ops/rule_form/package.json @@ -0,0 +1,6 @@ +{ + "name": "@kbn/response-ops-rule-form", + "private": true, + "version": "1.0.0", + "license": "Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0" +} \ No newline at end of file diff --git a/packages/response-ops/rule_form/setup_tests.ts b/packages/response-ops/rule_form/setup_tests.ts new file mode 100644 index 0000000000000..5ebc6d3dac1ca --- /dev/null +++ b/packages/response-ops/rule_form/setup_tests.ts @@ -0,0 +1,11 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +// eslint-disable-next-line import/no-extraneous-dependencies +import '@testing-library/jest-dom'; diff --git a/packages/kbn-alerts-ui-shared/src/common/apis/create_rule/create_rule.test.ts b/packages/response-ops/rule_form/src/common/apis/create_rule/create_rule.test.ts similarity index 100% rename from packages/kbn-alerts-ui-shared/src/common/apis/create_rule/create_rule.test.ts rename to packages/response-ops/rule_form/src/common/apis/create_rule/create_rule.test.ts diff --git a/packages/kbn-alerts-ui-shared/src/common/apis/create_rule/create_rule.ts b/packages/response-ops/rule_form/src/common/apis/create_rule/create_rule.ts similarity index 94% rename from packages/kbn-alerts-ui-shared/src/common/apis/create_rule/create_rule.ts rename to packages/response-ops/rule_form/src/common/apis/create_rule/create_rule.ts index 46bbdba958ff0..571bb0712f6aa 100644 --- a/packages/kbn-alerts-ui-shared/src/common/apis/create_rule/create_rule.ts +++ b/packages/response-ops/rule_form/src/common/apis/create_rule/create_rule.ts @@ -11,7 +11,7 @@ import type { HttpSetup } from '@kbn/core/public'; import type { AsApiContract } from '@kbn/actions-types'; import type { Rule } from '../../types'; import { CreateRuleBody, transformCreateRuleBody } from '.'; -import { BASE_ALERTING_API_PATH } from '../../constants'; +import { BASE_ALERTING_API_PATH } from '../../../constants'; import { transformRule } from '../../transformations'; export async function createRule({ diff --git a/packages/kbn-alerts-ui-shared/src/common/apis/create_rule/index.ts b/packages/response-ops/rule_form/src/common/apis/create_rule/index.ts similarity index 100% rename from packages/kbn-alerts-ui-shared/src/common/apis/create_rule/index.ts rename to packages/response-ops/rule_form/src/common/apis/create_rule/index.ts diff --git a/packages/kbn-alerts-ui-shared/src/common/apis/create_rule/transform_create_rule_body.test.ts b/packages/response-ops/rule_form/src/common/apis/create_rule/transform_create_rule_body.test.ts similarity index 100% rename from packages/kbn-alerts-ui-shared/src/common/apis/create_rule/transform_create_rule_body.test.ts rename to packages/response-ops/rule_form/src/common/apis/create_rule/transform_create_rule_body.test.ts diff --git a/packages/kbn-alerts-ui-shared/src/common/apis/create_rule/transform_create_rule_body.ts b/packages/response-ops/rule_form/src/common/apis/create_rule/transform_create_rule_body.ts similarity index 100% rename from packages/kbn-alerts-ui-shared/src/common/apis/create_rule/transform_create_rule_body.ts rename to packages/response-ops/rule_form/src/common/apis/create_rule/transform_create_rule_body.ts diff --git a/packages/kbn-alerts-ui-shared/src/common/apis/create_rule/types.ts b/packages/response-ops/rule_form/src/common/apis/create_rule/types.ts similarity index 100% rename from packages/kbn-alerts-ui-shared/src/common/apis/create_rule/types.ts rename to packages/response-ops/rule_form/src/common/apis/create_rule/types.ts diff --git a/packages/response-ops/rule_form/src/common/apis/fetch_rule_types.ts b/packages/response-ops/rule_form/src/common/apis/fetch_rule_types.ts new file mode 100644 index 0000000000000..bf2da123b8cf5 --- /dev/null +++ b/packages/response-ops/rule_form/src/common/apis/fetch_rule_types.ts @@ -0,0 +1,54 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +import { HttpSetup } from '@kbn/core/public'; +import type { AsApiContract, RewriteRequestCase } from '@kbn/actions-types'; +import type { RuleType } from '@kbn/triggers-actions-ui-types'; +import { BASE_ALERTING_API_PATH } from '../../constants'; + +const rewriteResponseRes = (results: Array>): RuleType[] => { + return results.map((item) => rewriteBodyReq(item)); +}; + +const rewriteBodyReq: RewriteRequestCase = ({ + enabled_in_license: enabledInLicense, + recovery_action_group: recoveryActionGroup, + action_groups: actionGroups, + default_action_group_id: defaultActionGroupId, + minimum_license_required: minimumLicenseRequired, + action_variables: actionVariables, + authorized_consumers: authorizedConsumers, + rule_task_timeout: ruleTaskTimeout, + does_set_recovery_context: doesSetRecoveryContext, + default_schedule_interval: defaultScheduleInterval, + has_alerts_mappings: hasAlertsMappings, + has_fields_for_a_a_d: hasFieldsForAAD, + ...rest +}: AsApiContract) => ({ + enabledInLicense, + recoveryActionGroup, + actionGroups, + defaultActionGroupId, + minimumLicenseRequired, + actionVariables, + authorizedConsumers, + ruleTaskTimeout, + doesSetRecoveryContext, + defaultScheduleInterval, + hasAlertsMappings, + hasFieldsForAAD, + ...rest, +}); + +export async function fetchRuleTypes({ http }: { http: HttpSetup }): Promise { + const res = await http.get>>>( + `${BASE_ALERTING_API_PATH}/rule_types` + ); + return rewriteResponseRes(res); +} diff --git a/packages/kbn-alerts-ui-shared/src/common/apis/fetch_ui_config/fetch_ui_config.test.ts b/packages/response-ops/rule_form/src/common/apis/fetch_ui_config/fetch_ui_config.test.ts similarity index 100% rename from packages/kbn-alerts-ui-shared/src/common/apis/fetch_ui_config/fetch_ui_config.test.ts rename to packages/response-ops/rule_form/src/common/apis/fetch_ui_config/fetch_ui_config.test.ts diff --git a/packages/kbn-alerts-ui-shared/src/common/apis/fetch_ui_config/fetch_ui_config.ts b/packages/response-ops/rule_form/src/common/apis/fetch_ui_config/fetch_ui_config.ts similarity index 91% rename from packages/kbn-alerts-ui-shared/src/common/apis/fetch_ui_config/fetch_ui_config.ts rename to packages/response-ops/rule_form/src/common/apis/fetch_ui_config/fetch_ui_config.ts index 89bc5e0bbe5fe..0e33bd0c6497a 100644 --- a/packages/kbn-alerts-ui-shared/src/common/apis/fetch_ui_config/fetch_ui_config.ts +++ b/packages/response-ops/rule_form/src/common/apis/fetch_ui_config/fetch_ui_config.ts @@ -8,7 +8,7 @@ */ import type { HttpStart } from '@kbn/core-http-browser'; -import { BASE_TRIGGERS_ACTIONS_UI_API_PATH } from '../../constants'; +import { BASE_TRIGGERS_ACTIONS_UI_API_PATH } from '../../../constants'; import { UiConfig } from '.'; export const fetchUiConfig = async ({ http }: { http: HttpStart }): Promise => { diff --git a/packages/kbn-alerts-ui-shared/src/common/apis/fetch_ui_config/index.ts b/packages/response-ops/rule_form/src/common/apis/fetch_ui_config/index.ts similarity index 100% rename from packages/kbn-alerts-ui-shared/src/common/apis/fetch_ui_config/index.ts rename to packages/response-ops/rule_form/src/common/apis/fetch_ui_config/index.ts diff --git a/packages/kbn-alerts-ui-shared/src/common/apis/fetch_ui_config/types.ts b/packages/response-ops/rule_form/src/common/apis/fetch_ui_config/types.ts similarity index 100% rename from packages/kbn-alerts-ui-shared/src/common/apis/fetch_ui_config/types.ts rename to packages/response-ops/rule_form/src/common/apis/fetch_ui_config/types.ts diff --git a/packages/response-ops/rule_form/src/common/apis/index.ts b/packages/response-ops/rule_form/src/common/apis/index.ts new file mode 100644 index 0000000000000..58b53aa6aee43 --- /dev/null +++ b/packages/response-ops/rule_form/src/common/apis/index.ts @@ -0,0 +1,13 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +export * from './create_rule'; +export * from './fetch_ui_config'; +export * from './resolve_rule'; +export * from './update_rule'; diff --git a/packages/kbn-alerts-ui-shared/src/common/apis/resolve_rule/index.ts b/packages/response-ops/rule_form/src/common/apis/resolve_rule/index.ts similarity index 100% rename from packages/kbn-alerts-ui-shared/src/common/apis/resolve_rule/index.ts rename to packages/response-ops/rule_form/src/common/apis/resolve_rule/index.ts diff --git a/packages/kbn-alerts-ui-shared/src/common/apis/resolve_rule/resolve_rule.test.ts b/packages/response-ops/rule_form/src/common/apis/resolve_rule/resolve_rule.test.ts similarity index 100% rename from packages/kbn-alerts-ui-shared/src/common/apis/resolve_rule/resolve_rule.test.ts rename to packages/response-ops/rule_form/src/common/apis/resolve_rule/resolve_rule.test.ts diff --git a/packages/kbn-alerts-ui-shared/src/common/apis/resolve_rule/resolve_rule.ts b/packages/response-ops/rule_form/src/common/apis/resolve_rule/resolve_rule.ts similarity index 93% rename from packages/kbn-alerts-ui-shared/src/common/apis/resolve_rule/resolve_rule.ts rename to packages/response-ops/rule_form/src/common/apis/resolve_rule/resolve_rule.ts index 6446d27136ee1..9d9141eae9765 100644 --- a/packages/kbn-alerts-ui-shared/src/common/apis/resolve_rule/resolve_rule.ts +++ b/packages/response-ops/rule_form/src/common/apis/resolve_rule/resolve_rule.ts @@ -9,7 +9,7 @@ import { HttpSetup } from '@kbn/core-http-browser'; import { AsApiContract } from '@kbn/actions-types'; -import { INTERNAL_BASE_ALERTING_API_PATH } from '../../constants'; +import { INTERNAL_BASE_ALERTING_API_PATH } from '../../../constants'; import { transformResolvedRule } from '../../transformations'; import { ResolvedRule } from '../../types'; diff --git a/packages/kbn-alerts-ui-shared/src/common/apis/update_rule/index.ts b/packages/response-ops/rule_form/src/common/apis/update_rule/index.ts similarity index 100% rename from packages/kbn-alerts-ui-shared/src/common/apis/update_rule/index.ts rename to packages/response-ops/rule_form/src/common/apis/update_rule/index.ts diff --git a/packages/kbn-alerts-ui-shared/src/common/apis/update_rule/transform_update_rule_body.test.ts b/packages/response-ops/rule_form/src/common/apis/update_rule/transform_update_rule_body.test.ts similarity index 100% rename from packages/kbn-alerts-ui-shared/src/common/apis/update_rule/transform_update_rule_body.test.ts rename to packages/response-ops/rule_form/src/common/apis/update_rule/transform_update_rule_body.test.ts diff --git a/packages/kbn-alerts-ui-shared/src/common/apis/update_rule/transform_update_rule_body.ts b/packages/response-ops/rule_form/src/common/apis/update_rule/transform_update_rule_body.ts similarity index 100% rename from packages/kbn-alerts-ui-shared/src/common/apis/update_rule/transform_update_rule_body.ts rename to packages/response-ops/rule_form/src/common/apis/update_rule/transform_update_rule_body.ts diff --git a/packages/kbn-alerts-ui-shared/src/common/apis/update_rule/types.ts b/packages/response-ops/rule_form/src/common/apis/update_rule/types.ts similarity index 100% rename from packages/kbn-alerts-ui-shared/src/common/apis/update_rule/types.ts rename to packages/response-ops/rule_form/src/common/apis/update_rule/types.ts diff --git a/packages/kbn-alerts-ui-shared/src/common/apis/update_rule/update_rule.test.ts b/packages/response-ops/rule_form/src/common/apis/update_rule/update_rule.test.ts similarity index 100% rename from packages/kbn-alerts-ui-shared/src/common/apis/update_rule/update_rule.test.ts rename to packages/response-ops/rule_form/src/common/apis/update_rule/update_rule.test.ts diff --git a/packages/kbn-alerts-ui-shared/src/common/apis/update_rule/update_rule.ts b/packages/response-ops/rule_form/src/common/apis/update_rule/update_rule.ts similarity index 96% rename from packages/kbn-alerts-ui-shared/src/common/apis/update_rule/update_rule.ts rename to packages/response-ops/rule_form/src/common/apis/update_rule/update_rule.ts index d5fd360a0c949..413a23e5fb279 100644 --- a/packages/kbn-alerts-ui-shared/src/common/apis/update_rule/update_rule.ts +++ b/packages/response-ops/rule_form/src/common/apis/update_rule/update_rule.ts @@ -11,7 +11,7 @@ import { HttpSetup } from '@kbn/core/public'; import { pick } from 'lodash'; import { AsApiContract } from '@kbn/actions-types'; import { UpdateRuleBody } from './types'; -import { BASE_ALERTING_API_PATH } from '../../constants'; +import { BASE_ALERTING_API_PATH } from '../../../constants'; import { transformUpdateRuleBody } from './transform_update_rule_body'; import { transformRule } from '../../transformations'; import { Rule } from '../../types'; diff --git a/packages/response-ops/rule_form/src/common/hooks/index.ts b/packages/response-ops/rule_form/src/common/hooks/index.ts new file mode 100644 index 0000000000000..57a70045552a8 --- /dev/null +++ b/packages/response-ops/rule_form/src/common/hooks/index.ts @@ -0,0 +1,15 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +export * from './use_create_rule'; +export * from './use_load_connector_types'; +export * from './use_load_connectors'; +export * from './use_load_ui_config'; +export * from './use_resolve_rule'; +export * from './use_update_rule'; diff --git a/packages/kbn-alerts-ui-shared/src/common/hooks/use_create_rule.test.tsx b/packages/response-ops/rule_form/src/common/hooks/use_create_rule.test.tsx similarity index 100% rename from packages/kbn-alerts-ui-shared/src/common/hooks/use_create_rule.test.tsx rename to packages/response-ops/rule_form/src/common/hooks/use_create_rule.test.tsx diff --git a/packages/kbn-alerts-ui-shared/src/common/hooks/use_create_rule.ts b/packages/response-ops/rule_form/src/common/hooks/use_create_rule.ts similarity index 100% rename from packages/kbn-alerts-ui-shared/src/common/hooks/use_create_rule.ts rename to packages/response-ops/rule_form/src/common/hooks/use_create_rule.ts diff --git a/packages/kbn-alerts-ui-shared/src/common/hooks/use_load_connector_types.test.tsx b/packages/response-ops/rule_form/src/common/hooks/use_load_connector_types.test.tsx similarity index 100% rename from packages/kbn-alerts-ui-shared/src/common/hooks/use_load_connector_types.test.tsx rename to packages/response-ops/rule_form/src/common/hooks/use_load_connector_types.test.tsx diff --git a/packages/kbn-alerts-ui-shared/src/common/hooks/use_load_connector_types.ts b/packages/response-ops/rule_form/src/common/hooks/use_load_connector_types.ts similarity index 92% rename from packages/kbn-alerts-ui-shared/src/common/hooks/use_load_connector_types.ts rename to packages/response-ops/rule_form/src/common/hooks/use_load_connector_types.ts index a72315c19e798..950f77346ef68 100644 --- a/packages/kbn-alerts-ui-shared/src/common/hooks/use_load_connector_types.ts +++ b/packages/response-ops/rule_form/src/common/hooks/use_load_connector_types.ts @@ -9,7 +9,7 @@ import { useQuery } from '@tanstack/react-query'; import type { HttpStart } from '@kbn/core-http-browser'; -import { fetchConnectorTypes } from '../apis'; +import { fetchConnectorTypes } from '@kbn/alerts-ui-shared/src/common/apis/fetch_connector_types'; export interface UseLoadConnectorTypesProps { http: HttpStart; diff --git a/packages/kbn-alerts-ui-shared/src/common/hooks/use_load_connectors.test.tsx b/packages/response-ops/rule_form/src/common/hooks/use_load_connectors.test.tsx similarity index 100% rename from packages/kbn-alerts-ui-shared/src/common/hooks/use_load_connectors.test.tsx rename to packages/response-ops/rule_form/src/common/hooks/use_load_connectors.test.tsx diff --git a/packages/kbn-alerts-ui-shared/src/common/hooks/use_load_connectors.ts b/packages/response-ops/rule_form/src/common/hooks/use_load_connectors.ts similarity index 93% rename from packages/kbn-alerts-ui-shared/src/common/hooks/use_load_connectors.ts rename to packages/response-ops/rule_form/src/common/hooks/use_load_connectors.ts index 8c93881762b1a..d6e77b5b42571 100644 --- a/packages/kbn-alerts-ui-shared/src/common/hooks/use_load_connectors.ts +++ b/packages/response-ops/rule_form/src/common/hooks/use_load_connectors.ts @@ -9,7 +9,7 @@ import { useQuery } from '@tanstack/react-query'; import type { HttpStart } from '@kbn/core-http-browser'; -import { fetchConnectors } from '../apis'; +import { fetchConnectors } from '@kbn/alerts-ui-shared/src/common/apis/fetch_connectors'; export interface UseLoadConnectorsProps { http: HttpStart; diff --git a/packages/kbn-alerts-ui-shared/src/common/hooks/use_load_rule_type_aad_template_fields.test.tsx b/packages/response-ops/rule_form/src/common/hooks/use_load_rule_type_aad_template_fields.test.tsx similarity index 100% rename from packages/kbn-alerts-ui-shared/src/common/hooks/use_load_rule_type_aad_template_fields.test.tsx rename to packages/response-ops/rule_form/src/common/hooks/use_load_rule_type_aad_template_fields.test.tsx diff --git a/packages/kbn-alerts-ui-shared/src/common/hooks/use_load_rule_type_aad_template_fields.ts b/packages/response-ops/rule_form/src/common/hooks/use_load_rule_type_aad_template_fields.ts similarity index 91% rename from packages/kbn-alerts-ui-shared/src/common/hooks/use_load_rule_type_aad_template_fields.ts rename to packages/response-ops/rule_form/src/common/hooks/use_load_rule_type_aad_template_fields.ts index c9dbc6c75ff35..90c98d3c8153d 100644 --- a/packages/kbn-alerts-ui-shared/src/common/hooks/use_load_rule_type_aad_template_fields.ts +++ b/packages/response-ops/rule_form/src/common/hooks/use_load_rule_type_aad_template_fields.ts @@ -11,7 +11,10 @@ import { EcsFlat } from '@elastic/ecs'; import { ActionVariable } from '@kbn/alerting-types'; import type { HttpStart } from '@kbn/core-http-browser'; import { useQuery } from '@tanstack/react-query'; -import { fetchRuleTypeAadTemplateFields, getDescription } from '../apis'; +import { + fetchRuleTypeAadTemplateFields, + getDescription, +} from '@kbn/alerts-ui-shared/src/common/apis'; export interface UseLoadRuleTypeAadTemplateFieldProps { http: HttpStart; @@ -23,7 +26,7 @@ export interface UseLoadRuleTypeAadTemplateFieldProps { export const useLoadRuleTypeAadTemplateField = (props: UseLoadRuleTypeAadTemplateFieldProps) => { const { http, ruleTypeId, enabled, cacheTime } = props; - const queryFn = () => { + const queryFn = async () => { if (!ruleTypeId) { return; } diff --git a/packages/kbn-alerts-ui-shared/src/common/hooks/use_load_ui_config.ts b/packages/response-ops/rule_form/src/common/hooks/use_load_ui_config.ts similarity index 100% rename from packages/kbn-alerts-ui-shared/src/common/hooks/use_load_ui_config.ts rename to packages/response-ops/rule_form/src/common/hooks/use_load_ui_config.ts diff --git a/packages/kbn-alerts-ui-shared/src/common/hooks/use_resolve_rule.test.tsx b/packages/response-ops/rule_form/src/common/hooks/use_resolve_rule.test.tsx similarity index 100% rename from packages/kbn-alerts-ui-shared/src/common/hooks/use_resolve_rule.test.tsx rename to packages/response-ops/rule_form/src/common/hooks/use_resolve_rule.test.tsx diff --git a/packages/kbn-alerts-ui-shared/src/common/hooks/use_resolve_rule.ts b/packages/response-ops/rule_form/src/common/hooks/use_resolve_rule.ts similarity index 97% rename from packages/kbn-alerts-ui-shared/src/common/hooks/use_resolve_rule.ts rename to packages/response-ops/rule_form/src/common/hooks/use_resolve_rule.ts index 95c3ca6baad02..ea480b4039e86 100644 --- a/packages/kbn-alerts-ui-shared/src/common/hooks/use_resolve_rule.ts +++ b/packages/response-ops/rule_form/src/common/hooks/use_resolve_rule.ts @@ -10,7 +10,7 @@ import { useQuery } from '@tanstack/react-query'; import type { HttpStart } from '@kbn/core-http-browser'; import { resolveRule } from '../apis/resolve_rule'; -import { RuleFormData } from '../../rule_form'; +import { RuleFormData } from '../../types'; export interface UseResolveProps { http: HttpStart; diff --git a/packages/kbn-alerts-ui-shared/src/common/hooks/use_update_rule.test.tsx b/packages/response-ops/rule_form/src/common/hooks/use_update_rule.test.tsx similarity index 100% rename from packages/kbn-alerts-ui-shared/src/common/hooks/use_update_rule.test.tsx rename to packages/response-ops/rule_form/src/common/hooks/use_update_rule.test.tsx diff --git a/packages/kbn-alerts-ui-shared/src/common/hooks/use_update_rule.ts b/packages/response-ops/rule_form/src/common/hooks/use_update_rule.ts similarity index 100% rename from packages/kbn-alerts-ui-shared/src/common/hooks/use_update_rule.ts rename to packages/response-ops/rule_form/src/common/hooks/use_update_rule.ts diff --git a/packages/kbn-alerts-ui-shared/src/common/i18n.ts b/packages/response-ops/rule_form/src/common/i18n.ts similarity index 53% rename from packages/kbn-alerts-ui-shared/src/common/i18n.ts rename to packages/response-ops/rule_form/src/common/i18n.ts index 754ab78e12249..9cb100485ebbc 100644 --- a/packages/kbn-alerts-ui-shared/src/common/i18n.ts +++ b/packages/response-ops/rule_form/src/common/i18n.ts @@ -10,37 +10,37 @@ import { i18n } from '@kbn/i18n'; export const PRODUCER_DISPLAY_NAMES = { - apm: i18n.translate('alertsUIShared.producerDisplayNames.apm', { + apm: i18n.translate('responseOpsRuleForm.producerDisplayNames.apm', { defaultMessage: 'APM and User Experience', }), - uptime: i18n.translate('alertsUIShared.producerDisplayNames.uptime', { + uptime: i18n.translate('responseOpsRuleForm.producerDisplayNames.uptime', { defaultMessage: 'Synthetics and Uptime', }), - stackAlerts: i18n.translate('alertsUIShared.producerDisplayNames.stackAlerts', { + stackAlerts: i18n.translate('responseOpsRuleForm.producerDisplayNames.stackAlerts', { defaultMessage: 'Stack Alerts', }), - metrics: i18n.translate('alertsUIShared.producerDisplayNames.metrics', { + metrics: i18n.translate('responseOpsRuleForm.producerDisplayNames.metrics', { defaultMessage: 'Metrics', }), - logs: i18n.translate('alertsUIShared.producerDisplayNames.logs', { + logs: i18n.translate('responseOpsRuleForm.producerDisplayNames.logs', { defaultMessage: 'Logs', }), - siem: i18n.translate('alertsUIShared.producerDisplayNames.siem', { + siem: i18n.translate('responseOpsRuleForm.producerDisplayNames.siem', { defaultMessage: 'Security', }), - observability: i18n.translate('alertsUIShared.producerDisplayNames.observability', { + observability: i18n.translate('responseOpsRuleForm.producerDisplayNames.observability', { defaultMessage: 'Observability', }), - ml: i18n.translate('alertsUIShared.producerDisplayNames.ml', { + ml: i18n.translate('responseOpsRuleForm.producerDisplayNames.ml', { defaultMessage: 'Machine Learning', }), - slo: i18n.translate('alertsUIShared.producerDisplayNames.slo', { + slo: i18n.translate('responseOpsRuleForm.producerDisplayNames.slo', { defaultMessage: 'SLOs', }), - infrastructure: i18n.translate('alertsUIShared.producerDisplayNames.infrastructure', { + infrastructure: i18n.translate('responseOpsRuleForm.producerDisplayNames.infrastructure', { defaultMessage: 'Infrastructure', }), - monitoring: i18n.translate('alertsUIShared.producerDisplayNames.monitoring', { + monitoring: i18n.translate('responseOpsRuleForm.producerDisplayNames.monitoring', { defaultMessage: 'Stack Monitoring', }), }; diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/index.ts b/packages/response-ops/rule_form/src/common/index.ts similarity index 93% rename from packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/index.ts rename to packages/response-ops/rule_form/src/common/index.ts index f250421b5e716..34d385a3f5d62 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/index.ts +++ b/packages/response-ops/rule_form/src/common/index.ts @@ -7,4 +7,4 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -export * from './rule_actions'; +export * from './types'; diff --git a/packages/kbn-alerts-ui-shared/src/common/test_utils/actions_test_utils.ts b/packages/response-ops/rule_form/src/common/test_utils/actions_test_utils.ts similarity index 91% rename from packages/kbn-alerts-ui-shared/src/common/test_utils/actions_test_utils.ts rename to packages/response-ops/rule_form/src/common/test_utils/actions_test_utils.ts index 01f88ab1e01b4..1551541013064 100644 --- a/packages/kbn-alerts-ui-shared/src/common/test_utils/actions_test_utils.ts +++ b/packages/response-ops/rule_form/src/common/test_utils/actions_test_utils.ts @@ -9,8 +9,13 @@ import { ActionType } from '@kbn/actions-types'; import { RuleSystemAction } from '@kbn/alerting-types'; -import { ActionConnector, ActionTypeModel, GenericValidationResult, RuleAction } from '../types'; -import { actionTypeRegistryMock } from './action_type_registry.mock'; +import { + ActionConnector, + ActionTypeModel, + GenericValidationResult, + RuleAction, +} from '@kbn/alerts-ui-shared'; +import { actionTypeRegistryMock } from '@kbn/alerts-ui-shared/src/common/test_utils/action_type_registry.mock'; export const getConnector = ( id: string, diff --git a/packages/response-ops/rule_form/src/common/transformations/index.ts b/packages/response-ops/rule_form/src/common/transformations/index.ts new file mode 100644 index 0000000000000..2f0fd7d84539b --- /dev/null +++ b/packages/response-ops/rule_form/src/common/transformations/index.ts @@ -0,0 +1,10 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +export * from './transform_rule'; diff --git a/packages/kbn-alerts-ui-shared/src/common/transformations/transform_rule.ts b/packages/response-ops/rule_form/src/common/transformations/transform_rule.ts similarity index 95% rename from packages/kbn-alerts-ui-shared/src/common/transformations/transform_rule.ts rename to packages/response-ops/rule_form/src/common/transformations/transform_rule.ts index b04e98887f2e5..d1f11c4109ed1 100644 --- a/packages/kbn-alerts-ui-shared/src/common/transformations/transform_rule.ts +++ b/packages/response-ops/rule_form/src/common/transformations/transform_rule.ts @@ -9,8 +9,8 @@ import { AsApiContract, RewriteRequestCase } from '@kbn/actions-types'; import { RuleExecutionStatus, RuleLastRun } from '@kbn/alerting-types'; -import type { ResolvedRule, RuleUiAction, Rule } from '..'; -import { transformAction } from '.'; +import { transformAction } from '@kbn/alerts-ui-shared/src/common/transformations'; +import type { ResolvedRule, Rule, RuleUiAction } from '..'; const transformExecutionStatus: RewriteRequestCase = ({ last_execution_date: lastExecutionDate, diff --git a/packages/response-ops/rule_form/src/common/types/index.ts b/packages/response-ops/rule_form/src/common/types/index.ts new file mode 100644 index 0000000000000..a9486c387724a --- /dev/null +++ b/packages/response-ops/rule_form/src/common/types/index.ts @@ -0,0 +1,10 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +export * from '@kbn/alerts-ui-shared/src/common/types/rule_types'; diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/constants.ts b/packages/response-ops/rule_form/src/constants/index.ts similarity index 84% rename from packages/kbn-alerts-ui-shared/src/rule_form/constants.ts rename to packages/response-ops/rule_form/src/constants/index.ts index a3748eeabe697..78718f7e11de1 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_form/constants.ts +++ b/packages/response-ops/rule_form/src/constants/index.ts @@ -7,15 +7,20 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ +import { RuleNotifyWhen } from '@kbn/alerting-types'; import { + AlertConsumers, ES_QUERY_ID, - OBSERVABILITY_THRESHOLD_RULE_TYPE_ID, ML_ANOMALY_DETECTION_RULE_TYPE_ID, + OBSERVABILITY_THRESHOLD_RULE_TYPE_ID, RuleCreationValidConsumer, - AlertConsumers, } from '@kbn/rule-data-utils'; -import { RuleNotifyWhen } from '@kbn/alerting-types'; -import { RuleFormData } from './types'; +import { RuleFormData } from '../types'; + +export * from './routes'; +export * from './rule_flapping'; + +export const VIEW_LICENSE_OPTIONS_LINK = 'https://www.elastic.co/subscriptions'; export const DEFAULT_RULE_INTERVAL = '1m'; @@ -67,5 +72,5 @@ export const DEFAULT_VALID_CONSUMERS: RuleCreationValidConsumer[] = [ 'alerts', ]; -export const createRuleRoute = '/rule/create/:ruleTypeId' as const; -export const editRuleRoute = '/rule/edit/:id' as const; +export const CREATE_RULE_ROUTE = '/rule/create/:ruleTypeId' as const; +export const EDIT_RULE_ROUTE = '/rule/edit/:id' as const; diff --git a/packages/response-ops/rule_form/src/constants/routes.ts b/packages/response-ops/rule_form/src/constants/routes.ts new file mode 100644 index 0000000000000..a447f83c13ef2 --- /dev/null +++ b/packages/response-ops/rule_form/src/constants/routes.ts @@ -0,0 +1,12 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +export const BASE_ALERTING_API_PATH = '/api/alerting'; +export const INTERNAL_BASE_ALERTING_API_PATH = '/internal/alerting'; +export const BASE_TRIGGERS_ACTIONS_UI_API_PATH = '/internal/triggers_actions_ui'; diff --git a/packages/response-ops/rule_form/src/constants/rule_flapping.ts b/packages/response-ops/rule_form/src/constants/rule_flapping.ts new file mode 100644 index 0000000000000..542bb055fd431 --- /dev/null +++ b/packages/response-ops/rule_form/src/constants/rule_flapping.ts @@ -0,0 +1,11 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +// Feature flag for frontend rule specific flapping in rule flyout +export const IS_RULE_SPECIFIC_FLAPPING_ENABLED = true; diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/create_rule_form.tsx b/packages/response-ops/rule_form/src/create_rule_form.tsx similarity index 99% rename from packages/kbn-alerts-ui-shared/src/rule_form/create_rule_form.tsx rename to packages/response-ops/rule_form/src/create_rule_form.tsx index b0d95a7d5c2c9..d7ba545935495 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_form/create_rule_form.tsx +++ b/packages/response-ops/rule_form/src/create_rule_form.tsx @@ -14,7 +14,7 @@ import { type RuleCreationValidConsumer } from '@kbn/rule-data-utils'; import type { RuleFormData, RuleFormPlugins } from './types'; import { DEFAULT_VALID_CONSUMERS, getDefaultFormData } from './constants'; import { RuleFormStateProvider } from './rule_form_state'; -import { useCreateRule } from '../common/hooks'; +import { useCreateRule } from './common/hooks'; import { RulePage } from './rule_page'; import { RuleFormCircuitBreakerError, diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/edit_rule_form.tsx b/packages/response-ops/rule_form/src/edit_rule_form.tsx similarity index 99% rename from packages/kbn-alerts-ui-shared/src/rule_form/edit_rule_form.tsx rename to packages/response-ops/rule_form/src/edit_rule_form.tsx index ace31d1b7b6fb..7350a42475b69 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_form/edit_rule_form.tsx +++ b/packages/response-ops/rule_form/src/edit_rule_form.tsx @@ -12,7 +12,7 @@ import { EuiLoadingElastic } from '@elastic/eui'; import { toMountPoint } from '@kbn/react-kibana-mount'; import type { RuleFormData, RuleFormPlugins } from './types'; import { RuleFormStateProvider } from './rule_form_state'; -import { useUpdateRule } from '../common/hooks'; +import { useUpdateRule } from './common/hooks'; import { RulePage } from './rule_page'; import { RuleFormHealthCheckError } from './rule_form_errors/rule_form_health_check_error'; import { useLoadDependencies } from './hooks/use_load_dependencies'; diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/hooks/index.ts b/packages/response-ops/rule_form/src/hooks/index.ts similarity index 100% rename from packages/kbn-alerts-ui-shared/src/rule_form/hooks/index.ts rename to packages/response-ops/rule_form/src/hooks/index.ts diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/hooks/use_load_dependencies.test.tsx b/packages/response-ops/rule_form/src/hooks/use_load_dependencies.test.tsx similarity index 88% rename from packages/kbn-alerts-ui-shared/src/rule_form/hooks/use_load_dependencies.test.tsx rename to packages/response-ops/rule_form/src/hooks/use_load_dependencies.test.tsx index 3dd6a6a3cee11..227240efbf8e7 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_form/hooks/use_load_dependencies.test.tsx +++ b/packages/response-ops/rule_form/src/hooks/use_load_dependencies.test.tsx @@ -14,52 +14,56 @@ import type { HttpStart } from '@kbn/core-http-browser'; import type { ToastsStart } from '@kbn/core-notifications-browser'; import { useLoadDependencies } from './use_load_dependencies'; -import { RuleTypeRegistryContract } from '../../common'; +import type { RuleTypeRegistryContract } from '../common/types'; import { ApplicationStart } from '@kbn/core-application-browser'; -jest.mock('../../common/hooks/use_load_ui_config', () => ({ +jest.mock('../common/hooks/use_load_ui_config', () => ({ useLoadUiConfig: jest.fn(), })); -jest.mock('../../common/hooks/use_health_check', () => ({ +jest.mock('@kbn/alerts-ui-shared/src/common/hooks/use_health_check', () => ({ useHealthCheck: jest.fn(), })); -jest.mock('../../common/hooks/use_resolve_rule', () => ({ +jest.mock('../common/hooks/use_resolve_rule', () => ({ useResolveRule: jest.fn(), })); -jest.mock('../../common/hooks/use_load_rule_types_query', () => ({ +jest.mock('@kbn/alerts-ui-shared/src/common/hooks/use_load_rule_types_query', () => ({ useLoadRuleTypesQuery: jest.fn(), })); -jest.mock('../../common/hooks/use_load_connectors', () => ({ +jest.mock('../common/hooks/use_load_connectors', () => ({ useLoadConnectors: jest.fn(), })); -jest.mock('../../common/hooks/use_load_connector_types', () => ({ +jest.mock('../common/hooks/use_load_connector_types', () => ({ useLoadConnectorTypes: jest.fn(), })); -jest.mock('../../common/hooks/use_load_rule_type_aad_template_fields', () => ({ +jest.mock('../common/hooks/use_load_rule_type_aad_template_fields', () => ({ useLoadRuleTypeAadTemplateField: jest.fn(), })); -jest.mock('../../common/hooks/use_fetch_flapping_settings', () => ({ +jest.mock('@kbn/alerts-ui-shared/src/common/hooks/use_fetch_flapping_settings', () => ({ useFetchFlappingSettings: jest.fn(), })); -const { useLoadUiConfig } = jest.requireMock('../../common/hooks/use_load_ui_config'); -const { useHealthCheck } = jest.requireMock('../../common/hooks/use_health_check'); -const { useResolveRule } = jest.requireMock('../../common/hooks/use_resolve_rule'); -const { useLoadConnectors } = jest.requireMock('../../common/hooks/use_load_connectors'); -const { useLoadConnectorTypes } = jest.requireMock('../../common/hooks/use_load_connector_types'); +const { useLoadUiConfig } = jest.requireMock('../common/hooks/use_load_ui_config'); +const { useHealthCheck } = jest.requireMock( + '@kbn/alerts-ui-shared/src/common/hooks/use_health_check' +); +const { useResolveRule } = jest.requireMock('../common/hooks/use_resolve_rule'); +const { useLoadConnectors } = jest.requireMock('../common/hooks/use_load_connectors'); +const { useLoadConnectorTypes } = jest.requireMock('../common/hooks/use_load_connector_types'); const { useLoadRuleTypeAadTemplateField } = jest.requireMock( - '../../common/hooks/use_load_rule_type_aad_template_fields' + '../common/hooks/use_load_rule_type_aad_template_fields' +); +const { useLoadRuleTypesQuery } = jest.requireMock( + '@kbn/alerts-ui-shared/src/common/hooks/use_load_rule_types_query' ); -const { useLoadRuleTypesQuery } = jest.requireMock('../../common/hooks/use_load_rule_types_query'); const { useFetchFlappingSettings } = jest.requireMock( - '../../common/hooks/use_fetch_flapping_settings' + '@kbn/alerts-ui-shared/src/common/hooks/use_fetch_flapping_settings' ); const uiConfigMock = { diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/hooks/use_load_dependencies.ts b/packages/response-ops/rule_form/src/hooks/use_load_dependencies.ts similarity index 92% rename from packages/kbn-alerts-ui-shared/src/rule_form/hooks/use_load_dependencies.ts rename to packages/response-ops/rule_form/src/hooks/use_load_dependencies.ts index b4a7d3bb777b0..1cd734f9c837a 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_form/hooks/use_load_dependencies.ts +++ b/packages/response-ops/rule_form/src/hooks/use_load_dependencies.ts @@ -7,23 +7,25 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { HttpStart } from '@kbn/core-http-browser'; +import type { HttpStart } from '@kbn/core-http-browser'; import type { ToastsStart } from '@kbn/core-notifications-browser'; -import { ApplicationStart } from '@kbn/core-application-browser'; +import type { ApplicationStart } from '@kbn/core-application-browser'; import { RuleCreationValidConsumer } from '@kbn/rule-data-utils'; import { useMemo } from 'react'; import { useHealthCheck, + useLoadRuleTypesQuery, + useFetchFlappingSettings, +} from '@kbn/alerts-ui-shared'; +import { useLoadConnectors, useLoadConnectorTypes, - useLoadRuleTypesQuery, useLoadUiConfig, useResolveRule, -} from '../../common/hooks'; -import { RuleTypeRegistryContract } from '../../common'; -import { useFetchFlappingSettings } from '../../common/hooks/use_fetch_flapping_settings'; -import { IS_RULE_SPECIFIC_FLAPPING_ENABLED } from '../../common/constants/rule_flapping'; -import { useLoadRuleTypeAadTemplateField } from '../../common/hooks/use_load_rule_type_aad_template_fields'; +} from '../common/hooks'; +import type { RuleTypeRegistryContract } from '../common/types'; +import { IS_RULE_SPECIFIC_FLAPPING_ENABLED } from '../constants'; +import { useLoadRuleTypeAadTemplateField } from '../common/hooks/use_load_rule_type_aad_template_fields'; export interface UseLoadDependencies { http: HttpStart; diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/hooks/use_rule_form_dispatch.ts b/packages/response-ops/rule_form/src/hooks/use_rule_form_dispatch.ts similarity index 100% rename from packages/kbn-alerts-ui-shared/src/rule_form/hooks/use_rule_form_dispatch.ts rename to packages/response-ops/rule_form/src/hooks/use_rule_form_dispatch.ts diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/hooks/use_rule_form_state.ts b/packages/response-ops/rule_form/src/hooks/use_rule_form_state.ts similarity index 100% rename from packages/kbn-alerts-ui-shared/src/rule_form/hooks/use_rule_form_state.ts rename to packages/response-ops/rule_form/src/hooks/use_rule_form_state.ts diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/index.ts b/packages/response-ops/rule_form/src/rule_actions/index.ts similarity index 71% rename from packages/kbn-alerts-ui-shared/src/rule_form/index.ts rename to packages/response-ops/rule_form/src/rule_actions/index.ts index cb175c6827459..6269ff1b48fbd 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_form/index.ts +++ b/packages/response-ops/rule_form/src/rule_actions/index.ts @@ -7,11 +7,7 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -export * from './rule_definition'; export * from './rule_actions'; -export * from './rule_details'; -export * from './rule_page'; -export * from './rule_form'; -export * from './utils'; -export * from './types'; -export * from './constants'; +export * from './rule_actions_notify_when'; +export * from './rule_actions_alerts_filter'; +export * from './rule_actions_alerts_filter_timeframe'; diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions.test.tsx b/packages/response-ops/rule_form/src/rule_actions/rule_actions.test.tsx similarity index 96% rename from packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions.test.tsx rename to packages/response-ops/rule_form/src/rule_actions/rule_actions.test.tsx index 9560d933060f6..e172405e3695b 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions.test.tsx +++ b/packages/response-ops/rule_form/src/rule_actions/rule_actions.test.tsx @@ -17,11 +17,11 @@ import { getSystemAction, getConnector, getActionTypeModel, -} from '../../common/test_utils/actions_test_utils'; +} from '../common/test_utils/actions_test_utils'; import userEvent from '@testing-library/user-event'; -import { ActionConnector, ActionTypeModel } from '../../common/types'; +import type { ActionConnector, ActionTypeModel } from '@kbn/alerts-ui-shared'; +import { TypeRegistry } from '@kbn/alerts-ui-shared/lib'; import { RuleActionsItemProps } from './rule_actions_item'; -import { TypeRegistry } from '../../common/type_registry'; const http = httpServiceMock.createStartContract(); @@ -84,7 +84,7 @@ jest.mock('uuid', () => ({ v4: jest.fn().mockReturnValue('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'), })); -jest.mock('../../common/hooks', () => ({ +jest.mock('../common/hooks', () => ({ useLoadConnectors: jest.fn(), useLoadConnectorTypes: jest.fn(), useLoadRuleTypeAadTemplateField: jest.fn(), @@ -96,7 +96,7 @@ const mockValidate = jest.fn().mockResolvedValue({ const { useRuleFormState, useRuleFormDispatch } = jest.requireMock('../hooks'); const { useLoadConnectors, useLoadConnectorTypes, useLoadRuleTypeAadTemplateField } = - jest.requireMock('../../common/hooks'); + jest.requireMock('../common/hooks'); const mockConnectors = [getConnector('1')]; const mockConnectorTypes = [ diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions.tsx b/packages/response-ops/rule_form/src/rule_actions/rule_actions.tsx similarity index 97% rename from packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions.tsx rename to packages/response-ops/rule_form/src/rule_actions/rule_actions.tsx index 47588b487be6d..2479c07edfb5f 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions.tsx +++ b/packages/response-ops/rule_form/src/rule_actions/rule_actions.tsx @@ -11,10 +11,11 @@ import React, { useCallback, useMemo, useState } from 'react'; import { EuiButton, EuiSpacer, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import { v4 as uuidv4 } from 'uuid'; import { RuleSystemAction } from '@kbn/alerting-types'; +import { ActionConnector } from '@kbn/alerts-ui-shared'; import { ADD_ACTION_TEXT } from '../translations'; import { RuleActionsConnectorsModal } from './rule_actions_connectors_modal'; import { useRuleFormDispatch, useRuleFormState } from '../hooks'; -import { ActionConnector, RuleAction, RuleFormParamsErrors } from '../../common/types'; +import { RuleAction, RuleFormParamsErrors } from '../common/types'; import { DEFAULT_FREQUENCY, MULTI_CONSUMER_RULE_TYPE_IDS } from '../constants'; import { RuleActionsItem } from './rule_actions_item'; import { RuleActionsSystemActionsItem } from './rule_actions_system_actions_item'; diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_alerts_filter.test.tsx b/packages/response-ops/rule_form/src/rule_actions/rule_actions_alerts_filter.test.tsx similarity index 97% rename from packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_alerts_filter.test.tsx rename to packages/response-ops/rule_form/src/rule_actions/rule_actions_alerts_filter.test.tsx index 0d97c7b5a1e12..947508751fe9f 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_alerts_filter.test.tsx +++ b/packages/response-ops/rule_form/src/rule_actions/rule_actions_alerts_filter.test.tsx @@ -12,8 +12,8 @@ import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { httpServiceMock } from '@kbn/core/public/mocks'; import { FilterStateStore } from '@kbn/es-query'; -import { AlertsSearchBarProps, AlertsSearchBar } from '../../alerts_search_bar'; -import { getAction } from '../../common/test_utils/actions_test_utils'; +import { AlertsSearchBarProps, AlertsSearchBar } from '@kbn/alerts-ui-shared'; +import { getAction } from '../common/test_utils/actions_test_utils'; import { RuleActionsAlertsFilter } from './rule_actions_alerts_filter'; const http = httpServiceMock.createStartContract(); @@ -22,7 +22,7 @@ jest.mock('../hooks', () => ({ useRuleFormState: jest.fn(), })); -jest.mock('../../alerts_search_bar', () => ({ +jest.mock('@kbn/alerts-ui-shared', () => ({ AlertsSearchBar: jest.fn(), })); diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_alerts_filter.tsx b/packages/response-ops/rule_form/src/rule_actions/rule_actions_alerts_filter.tsx similarity index 91% rename from packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_alerts_filter.tsx rename to packages/response-ops/rule_form/src/rule_actions/rule_actions_alerts_filter.tsx index a305c45d7961a..1fb4806b2aff8 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_alerts_filter.tsx +++ b/packages/response-ops/rule_form/src/rule_actions/rule_actions_alerts_filter.tsx @@ -7,16 +7,16 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import React, { useCallback, useEffect, useMemo, useState } from 'react'; +import { EuiSpacer, EuiSwitch } from '@elastic/eui'; +import type { AlertsFilter } from '@kbn/alerting-types'; +import { AlertsSearchBar, type AlertsSearchBarProps } from '@kbn/alerts-ui-shared'; import { Filter } from '@kbn/es-query'; import { i18n } from '@kbn/i18n'; -import { EuiSwitch, EuiSpacer } from '@elastic/eui'; -import type { AlertsFilter } from '@kbn/alerting-types'; import deepEqual from 'fast-deep-equal'; +import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { useRuleFormState } from '../hooks'; -import { RuleAction } from '../../common'; +import type { RuleAction } from '../types'; import { RuleFormPlugins } from '../types'; -import { AlertsSearchBar, AlertsSearchBarProps } from '../../alerts_search_bar'; const DEFAULT_QUERY = { kql: '', filters: [] }; @@ -104,7 +104,7 @@ export const RuleActionsAlertsFilter = ({ <> { async function setup(timeframe?: AlertsFilterTimeframe) { diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_alerts_filter_timeframe.tsx b/packages/response-ops/rule_form/src/rule_actions/rule_actions_alerts_filter_timeframe.tsx similarity index 94% rename from packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_alerts_filter_timeframe.tsx rename to packages/response-ops/rule_form/src/rule_actions/rule_actions_alerts_filter_timeframe.tsx index 2c37b7de470e4..79c0287adabc1 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_alerts_filter_timeframe.tsx +++ b/packages/response-ops/rule_form/src/rule_actions/rule_actions_alerts_filter_timeframe.tsx @@ -23,8 +23,8 @@ import { } from '@elastic/eui'; import deepEqual from 'fast-deep-equal'; import { ISO_WEEKDAYS, type IsoWeekday, type AlertsFilterTimeframe } from '@kbn/alerting-types'; -import { I18N_WEEKDAY_OPTIONS_DDD } from '../../common/constants'; -import { RuleAction } from '../../common'; +import { I18N_WEEKDAY_OPTIONS_DDD } from '@kbn/alerts-ui-shared/src/common/constants'; +import type { RuleAction } from '../types'; export interface RuleActionsAlertsFilterTimeframeProps { action: RuleAction; @@ -159,7 +159,7 @@ export const RuleActionsAlertsFilterTimeframe: React.FC ({ useRuleFormState: jest.fn(), diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_connectors_modal.tsx b/packages/response-ops/rule_form/src/rule_actions/rule_actions_connectors_modal.tsx similarity index 98% rename from packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_connectors_modal.tsx rename to packages/response-ops/rule_form/src/rule_actions/rule_actions_connectors_modal.tsx index 82496d9578ff0..64db54845530a 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_connectors_modal.tsx +++ b/packages/response-ops/rule_form/src/rule_actions/rule_actions_connectors_modal.tsx @@ -7,30 +7,30 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import React, { useState, useCallback, useMemo, Suspense } from 'react'; import { + EuiButton, + EuiCard, + EuiEmptyPrompt, + EuiFacetButton, + EuiFacetGroup, + EuiFieldSearch, EuiFlexGroup, EuiFlexItem, + EuiHorizontalRule, + EuiIcon, + EuiLoadingSpinner, EuiModal, - EuiModalHeader, - EuiFieldSearch, - EuiFacetButton, EuiModalBody, - EuiHorizontalRule, + EuiModalHeader, EuiModalHeaderTitle, - useEuiTheme, - EuiEmptyPrompt, - EuiFacetGroup, - EuiCard, - EuiIcon, - EuiText, EuiSpacer, - useCurrentEuiBreakpoint, - EuiButton, - EuiLoadingSpinner, + EuiText, EuiToolTip, + useCurrentEuiBreakpoint, + useEuiTheme, } from '@elastic/eui'; -import { ActionConnector } from '../../common'; +import { ActionConnector, checkActionFormActionTypeEnabled } from '@kbn/alerts-ui-shared'; +import React, { Suspense, useCallback, useMemo, useState } from 'react'; import { useRuleFormState } from '../hooks'; import { ACTION_TYPE_MODAL_EMPTY_TEXT, @@ -40,7 +40,6 @@ import { MODAL_SEARCH_CLEAR_FILTERS_TEXT, MODAL_SEARCH_PLACEHOLDER, } from '../translations'; -import { checkActionFormActionTypeEnabled } from '../utils/check_action_type_enabled'; type ConnectorsMap = Record; diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_item.test.tsx b/packages/response-ops/rule_form/src/rule_actions/rule_actions_item.test.tsx similarity index 96% rename from packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_item.test.tsx rename to packages/response-ops/rule_form/src/rule_actions/rule_actions_item.test.tsx index fb162cd606406..a26f5c08ba515 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_item.test.tsx +++ b/packages/response-ops/rule_form/src/rule_actions/rule_actions_item.test.tsx @@ -10,14 +10,14 @@ import React from 'react'; import { render, screen } from '@testing-library/react'; import { RuleType } from '@kbn/alerting-types'; -import { ActionTypeModel, RuleTypeModel } from '../../common'; -import { TypeRegistry } from '../../common/type_registry'; +import type { ActionTypeModel, RuleTypeModel } from '@kbn/alerts-ui-shared'; +import { TypeRegistry } from '@kbn/alerts-ui-shared/lib'; import { getAction, getActionType, getActionTypeModel, getConnector, -} from '../../common/test_utils/actions_test_utils'; +} from '../common/test_utils/actions_test_utils'; import { RuleActionsItem } from './rule_actions_item'; import userEvent from '@testing-library/user-event'; @@ -93,7 +93,7 @@ jest.mock('../validation/validate_params_for_warnings', () => ({ validateParamsForWarnings: jest.fn(), })); -jest.mock('../../action_variables/get_available_action_variables', () => ({ +jest.mock('@kbn/alerts-ui-shared/src/action_variables/get_available_action_variables', () => ({ getAvailableActionVariables: jest.fn(), })); @@ -149,7 +149,7 @@ const { validateParamsForWarnings } = jest.requireMock( ); const { getAvailableActionVariables } = jest.requireMock( - '../../action_variables/get_available_action_variables' + '@kbn/alerts-ui-shared/src/action_variables/get_available_action_variables' ); const mockConnectors = [getConnector('1', { id: 'action-1' })]; diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_item.tsx b/packages/response-ops/rule_form/src/rule_actions/rule_actions_item.tsx similarity index 96% rename from packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_item.tsx rename to packages/response-ops/rule_form/src/rule_actions/rule_actions_item.tsx index 41c8d1b904cd1..d3a77b21c1379 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_item.tsx +++ b/packages/response-ops/rule_form/src/rule_actions/rule_actions_item.tsx @@ -36,12 +36,16 @@ import { RuleActionParam, RuleActionParams, } from '@kbn/alerting-types'; +import { + ActionConnector, + checkActionFormActionTypeEnabled, + getAvailableActionVariables, +} from '@kbn/alerts-ui-shared'; import { isEmpty, some } from 'lodash'; import { css } from '@emotion/react'; import { SavedObjectAttribute } from '@kbn/core/types'; import { useRuleFormDispatch, useRuleFormState } from '../hooks'; -import { ActionConnector, RuleFormParamsErrors } from '../../common/types'; -import { getAvailableActionVariables } from '../../action_variables'; +import { RuleFormParamsErrors } from '../common/types'; import { validateAction, validateParamsForWarnings } from '../validation'; import { RuleActionsSettings } from './rule_actions_settings'; @@ -55,14 +59,16 @@ import { TECH_PREVIEW_DESCRIPTION, TECH_PREVIEW_LABEL, } from '../translations'; -import { checkActionFormActionTypeEnabled } from '../utils/check_action_type_enabled'; -const SUMMARY_GROUP_TITLE = i18n.translate('alertsUIShared.ruleActionsItem.summaryGroupTitle', { - defaultMessage: 'Summary of alerts', -}); +const SUMMARY_GROUP_TITLE = i18n.translate( + 'responseOpsRuleForm.ruleActionsItem.summaryGroupTitle', + { + defaultMessage: 'Summary of alerts', + } +); const RUN_WHEN_GROUP_TITLE = (groupName: string) => - i18n.translate('alertsUIShared.ruleActionsItem.runWhenGroupTitle', { + i18n.translate('responseOpsRuleForm.ruleActionsItem.runWhenGroupTitle', { defaultMessage: 'Run when {groupName}', values: { groupName, @@ -70,7 +76,7 @@ const RUN_WHEN_GROUP_TITLE = (groupName: string) => }); const ACTION_TITLE = (connector: ActionConnector) => - i18n.translate('alertsUIShared.ruleActionsItem.existingAlertActionTypeEditTitle', { + i18n.translate('responseOpsRuleForm.ruleActionsItem.existingAlertActionTypeEditTitle', { defaultMessage: '{actionConnectorName}', values: { actionConnectorName: `${connector.name} ${ @@ -674,7 +680,7 @@ export const RuleActionsItem = (props: RuleActionsItemProps) => { marginRight: euiTheme.size.l, }} aria-label={i18n.translate( - 'alertsUIShared.ruleActionsSystemActionsItem.deleteActionAriaLabel', + 'responseOpsRuleForm.ruleActionsSystemActionsItem.deleteActionAriaLabel', { defaultMessage: 'delete action', } diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_message.test.tsx b/packages/response-ops/rule_form/src/rule_actions/rule_actions_message.test.tsx similarity index 98% rename from packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_message.test.tsx rename to packages/response-ops/rule_form/src/rule_actions/rule_actions_message.test.tsx index d2c064cba2aad..f3ceafd98a72e 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_message.test.tsx +++ b/packages/response-ops/rule_form/src/rule_actions/rule_actions_message.test.tsx @@ -11,15 +11,15 @@ import React, { lazy } from 'react'; import { render, screen, waitFor } from '@testing-library/react'; import { RuleActionsMessage } from './rule_actions_message'; import { RuleType } from '@kbn/alerting-types'; -import { ActionParamsProps, ActionTypeModel, RuleTypeModel } from '../../common'; -import { TypeRegistry } from '../../common/type_registry'; +import type { ActionParamsProps, ActionTypeModel, RuleTypeModel } from '@kbn/alerts-ui-shared'; +import { TypeRegistry } from '@kbn/alerts-ui-shared/lib'; import { getAction, getActionType, getActionTypeModel, getConnector, getSystemAction, -} from '../../common/test_utils/actions_test_utils'; +} from '../common/test_utils/actions_test_utils'; import userEvent from '@testing-library/user-event'; jest.mock('../hooks', () => ({ diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_message.tsx b/packages/response-ops/rule_form/src/rule_actions/rule_actions_message.tsx similarity index 97% rename from packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_message.tsx rename to packages/response-ops/rule_form/src/rule_actions/rule_actions_message.tsx index e828f0bb22cf8..039e3d79258b7 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_message.tsx +++ b/packages/response-ops/rule_form/src/rule_actions/rule_actions_message.tsx @@ -17,8 +17,9 @@ import { EuiSwitch, } from '@elastic/eui'; import { ActionVariable, RuleActionParam } from '@kbn/alerting-types'; +import { ActionConnector, ActionConnectorMode } from '@kbn/alerts-ui-shared'; import { useRuleFormState } from '../hooks'; -import { ActionConnector, ActionConnectorMode, RuleAction, RuleUiAction } from '../../common'; +import { RuleAction, RuleUiAction } from '../common'; import { getSelectedActionGroup } from '../utils'; import { ACTION_USE_AAD_TEMPLATE_FIELDS_LABEL } from '../translations'; diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_notify_when.test.tsx b/packages/response-ops/rule_form/src/rule_actions/rule_actions_notify_when.test.tsx similarity index 100% rename from packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_notify_when.test.tsx rename to packages/response-ops/rule_form/src/rule_actions/rule_actions_notify_when.test.tsx diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_notify_when.tsx b/packages/response-ops/rule_form/src/rule_actions/rule_actions_notify_when.tsx similarity index 88% rename from packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_notify_when.tsx rename to packages/response-ops/rule_form/src/rule_actions/rule_actions_notify_when.tsx index d3695ba28a8db..cdd1a51e646c2 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_notify_when.tsx +++ b/packages/response-ops/rule_form/src/rule_actions/rule_actions_notify_when.tsx @@ -38,12 +38,15 @@ import { pipe } from 'fp-ts/lib/pipeable'; import { DEFAULT_FREQUENCY } from '../constants'; import { getTimeOptions } from '../utils'; -const FOR_EACH_ALERT = i18n.translate('alertsUIShared.actiActionsonNotifyWhen.forEachOption', { +const FOR_EACH_ALERT = i18n.translate('responseOpsRuleForm.actiActionsonNotifyWhen.forEachOption', { defaultMessage: 'For each alert', }); -const SUMMARY_OF_ALERTS = i18n.translate('alertsUIShared.actiActionsonNotifyWhen.summaryOption', { - defaultMessage: 'Summary of alerts', -}); +const SUMMARY_OF_ALERTS = i18n.translate( + 'responseOpsRuleForm.actiActionsonNotifyWhen.summaryOption', + { + defaultMessage: 'Summary of alerts', + } +); export interface NotifyWhenSelectOptions { isSummaryOption?: boolean; @@ -58,7 +61,7 @@ export const NOTIFY_WHEN_OPTIONS: NotifyWhenSelectOptions[] = [ value: { value: 'onActionGroupChange', inputDisplay: i18n.translate( - 'alertsUIShared.ruleActionsNotifyWhen.onActionGroupChange.display', + 'responseOpsRuleForm.ruleActionsNotifyWhen.onActionGroupChange.display', { defaultMessage: 'On status changes', } @@ -69,14 +72,14 @@ export const NOTIFY_WHEN_OPTIONS: NotifyWhenSelectOptions[] = [

@@ -89,23 +92,26 @@ export const NOTIFY_WHEN_OPTIONS: NotifyWhenSelectOptions[] = [ isForEachAlertOption: true, value: { value: 'onActiveAlert', - inputDisplay: i18n.translate('alertsUIShared.ruleActionsNotifyWhen.onActiveAlert.display', { - defaultMessage: 'On check intervals', - }), + inputDisplay: i18n.translate( + 'responseOpsRuleForm.ruleActionsNotifyWhen.onActiveAlert.display', + { + defaultMessage: 'On check intervals', + } + ), 'data-test-subj': 'onActiveAlert', dropdownDisplay: ( <>

@@ -119,7 +125,7 @@ export const NOTIFY_WHEN_OPTIONS: NotifyWhenSelectOptions[] = [ value: { value: 'onThrottleInterval', inputDisplay: i18n.translate( - 'alertsUIShared.ruleActionsNotifyWhen.onThrottleInterval.display', + 'responseOpsRuleForm.ruleActionsNotifyWhen.onThrottleInterval.display', { defaultMessage: 'On custom action intervals', } @@ -130,14 +136,14 @@ export const NOTIFY_WHEN_OPTIONS: NotifyWhenSelectOptions[] = [

@@ -290,7 +296,7 @@ export const RuleActionsNotifyWhen = ({ anchorPosition="downLeft" aria-label={frequency.summary ? SUMMARY_OF_ALERTS : FOR_EACH_ALERT} aria-roledescription={i18n.translate( - 'alertsUIShared.ruleActionsNotifyWhen.summaryOrRulePerSelectRoleDescription', + 'responseOpsRuleForm.ruleActionsNotifyWhen.summaryOrRulePerSelectRoleDescription', { defaultMessage: 'Action frequency type select' } )} button={ @@ -311,7 +317,7 @@ export const RuleActionsNotifyWhen = ({ return ( @@ -338,7 +344,7 @@ export const RuleActionsNotifyWhen = ({ name="throttle" data-test-subj="throttleInput" prepend={i18n.translate( - 'alertsUIShared.ruleActionsNotifyWhen.frequencyNotifyWhen.label', + 'responseOpsRuleForm.ruleActionsNotifyWhen.frequencyNotifyWhen.label', { defaultMessage: 'Run every', } @@ -380,7 +386,7 @@ export const RuleActionsNotifyWhen = ({ {i18n.translate( - 'alertsUIShared.ruleActionsNotifyWhen.notifyWhenThrottleWarning', + 'responseOpsRuleForm.ruleActionsNotifyWhen.notifyWhenThrottleWarning', { defaultMessage: "Custom action intervals cannot be shorter than the rule's check interval", diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_settings.test.tsx b/packages/response-ops/rule_form/src/rule_actions/rule_actions_settings.test.tsx similarity index 99% rename from packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_settings.test.tsx rename to packages/response-ops/rule_form/src/rule_actions/rule_actions_settings.test.tsx index cd1c7dd95f26d..ce2976ff08cf5 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_settings.test.tsx +++ b/packages/response-ops/rule_form/src/rule_actions/rule_actions_settings.test.tsx @@ -10,8 +10,8 @@ import React from 'react'; import { render, screen } from '@testing-library/react'; import { RuleActionsSettings } from './rule_actions_settings'; -import { getAction } from '../../common/test_utils/actions_test_utils'; -import { RuleTypeModel } from '../../common'; +import { getAction } from '../common/test_utils/actions_test_utils'; +import { RuleTypeModel } from '../common'; import { RuleType } from '@kbn/alerting-types'; import userEvent from '@testing-library/user-event'; import type { RuleActionsNotifyWhenProps } from './rule_actions_notify_when'; diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_settings.tsx b/packages/response-ops/rule_form/src/rule_actions/rule_actions_settings.tsx similarity index 97% rename from packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_settings.tsx rename to packages/response-ops/rule_form/src/rule_actions/rule_actions_settings.tsx index a7c0fae73e964..5f12271cc20cb 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_settings.tsx +++ b/packages/response-ops/rule_form/src/rule_actions/rule_actions_settings.tsx @@ -18,7 +18,7 @@ import { } from '@kbn/alerting-types'; import { isSiemRuleType } from '@kbn/rule-data-utils'; import { useRuleFormState } from '../hooks'; -import { RuleAction, RuleTypeWithDescription } from '../../common'; +import { RuleAction, RuleTypeWithDescription } from '../common'; import { getActionGroups, getDurationNumberInItsUnit, @@ -63,13 +63,13 @@ const getMinimumThrottleWarnings = ({ }; const ACTION_GROUP_NOT_SUPPORTED = (actionGroupName: string) => - i18n.translate('alertsUIShared.ruleActionsSetting.actionGroupNotSupported', { + i18n.translate('responseOpsRuleForm.ruleActionsSetting.actionGroupNotSupported', { defaultMessage: '{actionGroupName} (Not Currently Supported)', values: { actionGroupName }, }); const ACTION_GROUP_RUN_WHEN = i18n.translate( - 'alertsUIShared.ruleActionsSetting.actionGroupRunWhen', + 'responseOpsRuleForm.ruleActionsSetting.actionGroupRunWhen', { defaultMessage: 'Run when', } diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_system_actions_item.test.tsx b/packages/response-ops/rule_form/src/rule_actions/rule_actions_system_actions_item.test.tsx similarity index 98% rename from packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_system_actions_item.test.tsx rename to packages/response-ops/rule_form/src/rule_actions/rule_actions_system_actions_item.test.tsx index c94062e320a8d..f6e76538eba97 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_system_actions_item.test.tsx +++ b/packages/response-ops/rule_form/src/rule_actions/rule_actions_system_actions_item.test.tsx @@ -11,14 +11,14 @@ import React from 'react'; import { render, screen } from '@testing-library/react'; import { RuleType } from '@kbn/alerting-types'; import userEvent from '@testing-library/user-event'; -import { TypeRegistry } from '../../common/type_registry'; +import type { ActionTypeModel } from '@kbn/alerts-ui-shared'; +import { TypeRegistry } from '@kbn/alerts-ui-shared/lib'; import { getAction, getActionType, getActionTypeModel, getConnector, -} from '../../common/test_utils/actions_test_utils'; -import { ActionTypeModel } from '../../common'; +} from '../common/test_utils/actions_test_utils'; import { RuleActionsMessageProps } from './rule_actions_message'; import { RuleActionsSystemActionsItem } from './rule_actions_system_actions_item'; import { I18nProvider } from '@kbn/i18n-react'; diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_system_actions_item.tsx b/packages/response-ops/rule_form/src/rule_actions/rule_actions_system_actions_item.tsx similarity index 97% rename from packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_system_actions_item.tsx rename to packages/response-ops/rule_form/src/rule_actions/rule_actions_system_actions_item.tsx index 7432aa4c4343d..4ed0305ec6e8d 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_form/rule_actions/rule_actions_system_actions_item.tsx +++ b/packages/response-ops/rule_form/src/rule_actions/rule_actions_system_actions_item.tsx @@ -7,9 +7,6 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import React, { Suspense, useCallback, useMemo, useState } from 'react'; -import { i18n } from '@kbn/i18n'; -import { isEmpty, some } from 'lodash'; import { EuiAccordion, EuiBadge, @@ -24,25 +21,29 @@ import { useEuiBackgroundColor, useEuiTheme, } from '@elastic/eui'; +import { css } from '@emotion/react'; import { RuleActionParam, RuleSystemAction } from '@kbn/alerting-types'; +import { + getAvailableActionVariables, + IsDisabledResult, + IsEnabledResult, + checkActionFormActionTypeEnabled, + ActionConnector, +} from '@kbn/alerts-ui-shared'; import { SavedObjectAttribute } from '@kbn/core/types'; -import { css } from '@emotion/react'; +import { i18n } from '@kbn/i18n'; +import { isEmpty, some } from 'lodash'; +import React, { Suspense, useCallback, useMemo, useState } from 'react'; import { useRuleFormDispatch, useRuleFormState } from '../hooks'; -import { ActionConnector, RuleFormParamsErrors } from '../../common'; +import { RuleFormParamsErrors } from '../common'; import { ACTION_ERROR_TOOLTIP, ACTION_WARNING_TITLE, TECH_PREVIEW_DESCRIPTION, TECH_PREVIEW_LABEL, } from '../translations'; -import { RuleActionsMessage } from './rule_actions_message'; import { validateParamsForWarnings } from '../validation'; -import { getAvailableActionVariables } from '../../action_variables'; -import { - IsDisabledResult, - IsEnabledResult, - checkActionFormActionTypeEnabled, -} from '../utils/check_action_type_enabled'; +import { RuleActionsMessage } from './rule_actions_message'; interface RuleActionsSystemActionsItemProps { action: RuleSystemAction; @@ -252,7 +253,7 @@ export const RuleActionsSystemActionsItem = (props: RuleActionsSystemActionsItem marginRight: euiTheme.size.l, }} aria-label={i18n.translate( - 'alertsUIShared.ruleActionsSystemActionsItem.deleteActionAriaLabel', + 'responseOpsRuleForm.ruleActionsSystemActionsItem.deleteActionAriaLabel', { defaultMessage: 'delete action', } diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/rule_definition/index.ts b/packages/response-ops/rule_form/src/rule_definition/index.ts similarity index 100% rename from packages/kbn-alerts-ui-shared/src/rule_form/rule_definition/index.ts rename to packages/response-ops/rule_form/src/rule_definition/index.ts diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/rule_definition/rule_alert_delay.test.tsx b/packages/response-ops/rule_form/src/rule_definition/rule_alert_delay.test.tsx similarity index 100% rename from packages/kbn-alerts-ui-shared/src/rule_form/rule_definition/rule_alert_delay.test.tsx rename to packages/response-ops/rule_form/src/rule_definition/rule_alert_delay.test.tsx diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/rule_definition/rule_alert_delay.tsx b/packages/response-ops/rule_form/src/rule_definition/rule_alert_delay.tsx similarity index 100% rename from packages/kbn-alerts-ui-shared/src/rule_form/rule_definition/rule_alert_delay.tsx rename to packages/response-ops/rule_form/src/rule_definition/rule_alert_delay.tsx diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/rule_definition/rule_consumer_selection.test.tsx b/packages/response-ops/rule_form/src/rule_definition/rule_consumer_selection.test.tsx similarity index 100% rename from packages/kbn-alerts-ui-shared/src/rule_form/rule_definition/rule_consumer_selection.test.tsx rename to packages/response-ops/rule_form/src/rule_definition/rule_consumer_selection.test.tsx diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/rule_definition/rule_consumer_selection.tsx b/packages/response-ops/rule_form/src/rule_definition/rule_consumer_selection.tsx similarity index 100% rename from packages/kbn-alerts-ui-shared/src/rule_form/rule_definition/rule_consumer_selection.tsx rename to packages/response-ops/rule_form/src/rule_definition/rule_consumer_selection.tsx diff --git a/packages/kbn-alerts-ui-shared/src/rule_form/rule_definition/rule_definition.test.tsx b/packages/response-ops/rule_form/src/rule_definition/rule_definition.test.tsx similarity index 97% rename from packages/kbn-alerts-ui-shared/src/rule_form/rule_definition/rule_definition.test.tsx rename to packages/response-ops/rule_form/src/rule_definition/rule_definition.test.tsx index f45d1d0ae00fc..ca01bbc484570 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_form/rule_definition/rule_definition.test.tsx +++ b/packages/response-ops/rule_form/src/rule_definition/rule_definition.test.tsx @@ -18,8 +18,8 @@ import type { DocLinksStart } from '@kbn/core-doc-links-browser'; import { RuleDefinition } from './rule_definition'; import { RuleType } from '@kbn/alerting-types'; -import { RuleTypeModel } from '../../common/types'; -import { RuleSettingsFlappingFormProps } from '../../rule_settings/rule_settings_flapping_form'; +import { RuleTypeModel } from '../common/types'; +import { RuleSettingsFlappingFormProps } from '@kbn/alerts-ui-shared/src/rule_settings/rule_settings_flapping_form'; import { ALERT_FLAPPING_DETECTION_TITLE } from '../translations'; import userEvent from '@testing-library/user-event'; import { __IntlProvider as IntlProvider } from '@kbn/i18n-react'; @@ -29,11 +29,11 @@ jest.mock('../hooks', () => ({ useRuleFormDispatch: jest.fn(), })); -jest.mock('../../common/constants/rule_flapping', () => ({ +jest.mock('../constants/rule_flapping', () => ({ IS_RULE_SPECIFIC_FLAPPING_ENABLED: true, })); -jest.mock('../../rule_settings/rule_settings_flapping_form', () => ({ +jest.mock('@kbn/alerts-ui-shared/src/rule_settings/rule_settings_flapping_form', () => ({ RuleSettingsFlappingForm: (props: RuleSettingsFlappingFormProps) => (