Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,7 @@ packages/kbn-resizable-layout @elastic/kibana-data-discovery
examples/resizable_layout_examples @elastic/kibana-data-discovery
x-pack/test/plugin_functional/plugins/resolver_test @elastic/security-solution
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
examples/response_stream @elastic/ml-ui
packages/kbn-rison @elastic/kibana-operations
Expand Down
5 changes: 3 additions & 2 deletions .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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": []
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,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",
Expand Down
4 changes: 4 additions & 0 deletions packages/kbn-alerts-ui-shared/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
1 change: 1 addition & 0 deletions packages/kbn-alerts-ui-shared/lib/README.md
Original file line number Diff line number Diff line change
@@ -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.
11 changes: 11 additions & 0 deletions packages/kbn-alerts-ui-shared/lib/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
7 changes: 2 additions & 5 deletions packages/kbn-alerts-ui-shared/src/common/apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
2 changes: 2 additions & 0 deletions packages/kbn-alerts-ui-shared/src/common/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
8 changes: 0 additions & 8 deletions packages/kbn-alerts-ui-shared/src/common/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@
*/

export * from './transform_action';
export * from './transform_rule';
14 changes: 14 additions & 0 deletions packages/kbn-alerts-ui-shared/src/rule_settings/index.ts
Original file line number Diff line number Diff line change
@@ -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';
22 changes: 3 additions & 19 deletions packages/kbn-alerts-ui-shared/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
]
}
4 changes: 4 additions & 0 deletions packages/kbn-triggers-actions-ui-types/rule_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
3 changes: 3 additions & 0 deletions packages/response-ops/rule_form/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @kbn/response-ops-rule-form

This package contains all components necessary to render the forms for creating and editing rules.
32 changes: 32 additions & 0 deletions packages/response-ops/rule_form/index.ts
Original file line number Diff line number Diff line change
@@ -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';
15 changes: 15 additions & 0 deletions packages/response-ops/rule_form/jest.config.js
Original file line number Diff line number Diff line change
@@ -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'],
};
5 changes: 5 additions & 0 deletions packages/response-ops/rule_form/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "shared-browser",
"id": "@kbn/response-ops-rule-form",
"owner": "@elastic/response-ops"
}
6 changes: 6 additions & 0 deletions packages/response-ops/rule_form/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
11 changes: 11 additions & 0 deletions packages/response-ops/rule_form/setup_tests.ts
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Loading