[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 <kevin.delemme@elastic.co>
This commit is contained in:
Zacqary Adam Xeper 2024-12-03 12:40:48 -06:00 committed by GitHub
parent 5480451f27
commit 8f267fd83c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
209 changed files with 1162 additions and 1288 deletions

1
.github/CODEOWNERS vendored
View file

@ -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

View file

@ -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": []
}

View file

@ -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",

View file

@ -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';

View file

@ -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.

View file

@ -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';

View file

@ -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());

View file

@ -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 () => {

View file

@ -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;

View file

@ -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 {

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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

View file

@ -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

View file

@ -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';

View file

@ -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;

View file

@ -8,4 +8,3 @@
*/
export * from './transform_action';
export * from './transform_rule';

View file

@ -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';

View file

@ -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"
]
}

View file

@ -35,3 +35,7 @@ export interface RuleType<
}
export type RuleTypeIndex = Map<string, RuleType>;
export type RuleTypeWithDescription = RuleType<string, string> & { description?: string };
export type RuleTypeIndexWithDescriptions = Map<string, RuleTypeWithDescription>;

View file

@ -0,0 +1,3 @@
# @kbn/response-ops-rule-form
This package contains all components necessary to render the forms for creating and editing rules.

View file

@ -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';

View file

@ -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: ['<rootDir>/packages/response-ops/rule_form'],
setupFilesAfterEnv: ['<rootDir>/packages/response-ops/rule_form/setup_tests.ts'],
};

View file

@ -0,0 +1,5 @@
{
"type": "shared-browser",
"id": "@kbn/response-ops-rule-form",
"owner": "@elastic/response-ops"
}

View file

@ -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"
}

View file

@ -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';

View file

@ -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({

View file

@ -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<AsApiContract<RuleType>>): RuleType[] => {
return results.map((item) => rewriteBodyReq(item));
};
const rewriteBodyReq: RewriteRequestCase<RuleType> = ({
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<RuleType>) => ({
enabledInLicense,
recoveryActionGroup,
actionGroups,
defaultActionGroupId,
minimumLicenseRequired,
actionVariables,
authorizedConsumers,
ruleTaskTimeout,
doesSetRecoveryContext,
defaultScheduleInterval,
hasAlertsMappings,
hasFieldsForAAD,
...rest,
});
export async function fetchRuleTypes({ http }: { http: HttpSetup }): Promise<RuleType[]> {
const res = await http.get<Array<AsApiContract<RuleType<string, string>>>>(
`${BASE_ALERTING_API_PATH}/rule_types`
);
return rewriteResponseRes(res);
}

View file

@ -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<UiConfig> => {

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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;

View file

@ -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;

View file

@ -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;
}

View file

@ -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;

View file

@ -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',
}),
};

View file

@ -7,4 +7,4 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export * from './rule_actions';
export * from './types';

View file

@ -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,

View file

@ -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';

View file

@ -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<RuleExecutionStatus> = ({
last_execution_date: lastExecutionDate,

View file

@ -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';

View file

@ -7,15 +7,20 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import {
ES_QUERY_ID,
OBSERVABILITY_THRESHOLD_RULE_TYPE_ID,
ML_ANOMALY_DETECTION_RULE_TYPE_ID,
RuleCreationValidConsumer,
AlertConsumers,
} from '@kbn/rule-data-utils';
import { RuleNotifyWhen } from '@kbn/alerting-types';
import { RuleFormData } from './types';
import {
AlertConsumers,
ES_QUERY_ID,
ML_ANOMALY_DETECTION_RULE_TYPE_ID,
OBSERVABILITY_THRESHOLD_RULE_TYPE_ID,
RuleCreationValidConsumer,
} from '@kbn/rule-data-utils';
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;

View file

@ -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';

View file

@ -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;

View file

@ -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,

View file

@ -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';

View file

@ -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 { useLoadRuleTypeAadTemplateField } = jest.requireMock(
'../../common/hooks/use_load_rule_type_aad_template_fields'
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'
);
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 = {

View file

@ -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;

View file

@ -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';

View file

@ -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 = [

View file

@ -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';

View file

@ -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(),
}));

View file

@ -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 = ({
<>
<EuiSwitch
label={i18n.translate(
'alertsUIShared.ruleActionsAlertsFilter.ActionAlertsFilterQueryToggleLabel',
'responseOpsRuleForm.ruleActionsAlertsFilter.ActionAlertsFilterQueryToggleLabel',
{
defaultMessage: 'If alert matches a query',
}
@ -134,7 +134,7 @@ export const RuleActionsAlertsFilter = ({
showDatePicker={false}
showSubmitButton={false}
placeholder={i18n.translate(
'alertsUIShared.ruleActionsAlertsFilter.ActionAlertsFilterQueryPlaceholder',
'responseOpsRuleForm.ruleActionsAlertsFilter.ActionAlertsFilterQueryPlaceholder',
{
defaultMessage: 'Filter alerts using KQL syntax',
}

View file

@ -14,7 +14,7 @@ import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers';
import type { SettingsStart } from '@kbn/core-ui-settings-browser';
import { RuleActionsAlertsFilterTimeframe } from './rule_actions_alerts_filter_timeframe';
import { AlertsFilterTimeframe } from '@kbn/alerting-types';
import { getAction } from '../../common/test_utils/actions_test_utils';
import { getAction } from '../common/test_utils/actions_test_utils';
describe('ruleActionsAlertsFilterTimeframe', () => {
async function setup(timeframe?: AlertsFilterTimeframe) {

View file

@ -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<RuleActionsAlertsFilterT
<>
<EuiSwitch
label={i18n.translate(
'alertsUIShared.ruleForm.ruleActionsAlertsFilterTimeframeToggleLabel',
'responseOpsRuleForm.ruleForm.ruleActionsAlertsFilterTimeframeToggleLabel',
{
defaultMessage: 'If alert is generated during timeframe',
}
@ -175,7 +175,7 @@ export const RuleActionsAlertsFilterTimeframe: React.FC<RuleActionsAlertsFilterT
<EuiButtonGroup
isFullWidth
legend={i18n.translate(
'alertsUIShared.ruleForm.ruleActionsAlertsFilterTimeframeWeekdays',
'responseOpsRuleForm.ruleForm.ruleActionsAlertsFilterTimeframeWeekdays',
{
defaultMessage: 'Days of week',
}
@ -219,7 +219,7 @@ export const RuleActionsAlertsFilterTimeframe: React.FC<RuleActionsAlertsFilterT
<EuiFlexItem grow={1}>
<EuiComboBox
prepend={i18n.translate(
'alertsUIShared.ruleForm.ruleActionsAlertsFilterTimeframeTimezoneLabel',
'responseOpsRuleForm.ruleForm.ruleActionsAlertsFilterTimeframeTimezoneLabel',
{ defaultMessage: 'Timezone' }
)}
singleSelection={{ asPlainText: true }}

View file

@ -11,14 +11,14 @@ import React from 'react';
import { render, screen, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { RuleActionsConnectorsModal } from './rule_actions_connectors_modal';
import { ActionConnector, ActionTypeModel } from '../../common';
import type { ActionConnector, ActionTypeModel } from '@kbn/alerts-ui-shared';
import { TypeRegistry } from '@kbn/alerts-ui-shared/lib';
import { ActionType } from '@kbn/actions-types';
import { TypeRegistry } from '../../common/type_registry';
import {
getActionType,
getActionTypeModel,
getConnector,
} from '../../common/test_utils/actions_test_utils';
} from '../common/test_utils/actions_test_utils';
jest.mock('../hooks', () => ({
useRuleFormState: jest.fn(),

View file

@ -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,
EuiModal,
EuiModalHeader,
EuiFieldSearch,
EuiFacetButton,
EuiModalBody,
EuiHorizontalRule,
EuiModalHeaderTitle,
useEuiTheme,
EuiEmptyPrompt,
EuiFacetGroup,
EuiCard,
EuiIcon,
EuiText,
EuiSpacer,
useCurrentEuiBreakpoint,
EuiButton,
EuiLoadingSpinner,
EuiModal,
EuiModalBody,
EuiModalHeader,
EuiModalHeaderTitle,
EuiSpacer,
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<string, { actionTypeId: string; name: string; total: number }>;

View file

@ -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' })];

View file

@ -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',
}

View file

@ -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', () => ({

View file

@ -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';

View file

@ -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[] = [
<strong>
<FormattedMessage
defaultMessage="On status changes"
id="alertsUIShared.ruleActionsNotifyWhen.onActionGroupChange.label"
id="responseOpsRuleForm.ruleActionsNotifyWhen.onActionGroupChange.label"
/>
</strong>
<EuiText size="s" color="subdued">
<p>
<FormattedMessage
defaultMessage="Actions run if the alert status changes."
id="alertsUIShared.ruleActionsNotifyWhen.onActionGroupChange.description"
id="responseOpsRuleForm.ruleActionsNotifyWhen.onActionGroupChange.description"
/>
</p>
</EuiText>
@ -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: (
<>
<strong>
<FormattedMessage
defaultMessage="On check intervals"
id="alertsUIShared.ruleActionsNotifyWhen.onActiveAlert.label"
id="responseOpsRuleForm.ruleActionsNotifyWhen.onActiveAlert.label"
/>
</strong>
<EuiText size="s" color="subdued">
<p>
<FormattedMessage
defaultMessage="Actions run if rule conditions are met."
id="alertsUIShared.ruleActionsNotifyWhen.onActiveAlert.description"
id="responseOpsRuleForm.ruleActionsNotifyWhen.onActiveAlert.description"
/>
</p>
</EuiText>
@ -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[] = [
<strong>
<FormattedMessage
defaultMessage="On custom action intervals"
id="alertsUIShared.ruleActionsNotifyWhen.onThrottleInterval.label"
id="responseOpsRuleForm.ruleActionsNotifyWhen.onThrottleInterval.label"
/>
</strong>
<EuiText size="s" color="subdued">
<p>
<FormattedMessage
defaultMessage="Actions run if rule conditions are met."
id="alertsUIShared.ruleActionsNotifyWhen.onThrottleInterval.description"
id="responseOpsRuleForm.ruleActionsNotifyWhen.onThrottleInterval.description"
/>
</p>
</EuiText>
@ -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 (
<EuiFormRow
fullWidth
label={i18n.translate('alertsUIShared.ruleActionsNotifyWhen.actionFrequencyLabel', {
label={i18n.translate('responseOpsRuleForm.ruleActionsNotifyWhen.actionFrequencyLabel', {
defaultMessage: 'Action frequency',
})}
>
@ -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 = ({
<EuiSpacer size="xs" />
<EuiText size="xs" color="danger">
{i18n.translate(
'alertsUIShared.ruleActionsNotifyWhen.notifyWhenThrottleWarning',
'responseOpsRuleForm.ruleActionsNotifyWhen.notifyWhenThrottleWarning',
{
defaultMessage:
"Custom action intervals cannot be shorter than the rule's check interval",

View file

@ -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';

View file

@ -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',
}

View file

@ -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';

View file

@ -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 { RuleActionParam, RuleSystemAction } from '@kbn/alerting-types';
import { SavedObjectAttribute } from '@kbn/core/types';
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 { 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',
}

Some files were not shown because too many files have changed in this diff Show more