From e88f1ca9bd7422f3d0e8b5bc3de53100743ae687 Mon Sep 17 00:00:00 2001 From: Ersin Erdal <92688503+ersin-erdal@users.noreply.github.com> Date: Mon, 29 Nov 2021 19:44:17 +0100 Subject: [PATCH] 119061 refactor observability (#119211) * group containers and components, create index files --- x-pack/plugins/observability/public/index.ts | 4 +- .../{ => components}/alerts_disclaimer.tsx | 0 .../alerts_flyout/alerts_flyout.stories.tsx | 10 ++--- .../alerts_flyout/alerts_flyout.test.tsx | 10 ++--- .../alerts_flyout/alerts_flyout.tsx} | 14 +++---- .../alerts_flyout}/example_data.ts | 0 .../alerts/components/alerts_flyout/index.ts | 8 ++++ .../{ => components}/alerts_search_bar.tsx | 4 +- .../{ => components}/alerts_status_filter.tsx | 4 +- .../{ => components}/default_cell_actions.tsx | 6 +-- .../{ => components}/filter_for_value.tsx | 0 .../public/pages/alerts/components/index.ts | 17 +++++++++ .../alerts/{ => components}/parse_alert.ts | 8 ++-- .../components/render_cell_value/index.ts | 8 ++++ .../render_cell_value.test.tsx | 8 ++-- .../render_cell_value}/render_cell_value.tsx | 16 ++++---- .../alerts/components/severity_badge/index.ts | 8 ++++ .../severity_badge.stories.tsx | 0 .../severity_badge}/severity_badge.tsx | 0 .../workflow_status_filter/index.ts | 8 ++++ .../workflow_status_filter.stories.tsx | 2 +- .../workflow_status_filter.test.tsx | 2 +- .../workflow_status_filter.tsx | 2 +- .../alerts_page/alerts_page.tsx} | 38 +++++++++---------- .../alerts/containers/alerts_page/index.ts | 9 +++++ .../{ => containers/alerts_page}/styles.scss | 0 .../alerts_table_t_grid.tsx | 28 +++++++------- .../containers/alerts_table_t_grid/index.ts | 8 ++++ .../public/pages/alerts/containers/index.ts | 10 +++++ .../state_container/index.tsx | 0 .../state_container/state_container.tsx | 4 +- .../use_alerts_page_state_container.tsx | 6 +-- .../public/pages/alerts/index.ts | 9 +++++ .../public/pages/cases/helpers.ts | 4 +- .../observability/public/routes/index.tsx | 2 +- 35 files changed, 171 insertions(+), 86 deletions(-) rename x-pack/plugins/observability/public/pages/alerts/{ => components}/alerts_disclaimer.tsx (100%) rename x-pack/plugins/observability/public/pages/alerts/{ => components}/alerts_flyout/alerts_flyout.stories.tsx (85%) rename x-pack/plugins/observability/public/pages/alerts/{ => components}/alerts_flyout/alerts_flyout.test.tsx (91%) rename x-pack/plugins/observability/public/pages/alerts/{alerts_flyout/index.tsx => components/alerts_flyout/alerts_flyout.tsx} (89%) rename x-pack/plugins/observability/public/pages/alerts/{ => components/alerts_flyout}/example_data.ts (100%) create mode 100644 x-pack/plugins/observability/public/pages/alerts/components/alerts_flyout/index.ts rename x-pack/plugins/observability/public/pages/alerts/{ => components}/alerts_search_bar.tsx (92%) rename x-pack/plugins/observability/public/pages/alerts/{ => components}/alerts_status_filter.tsx (94%) rename x-pack/plugins/observability/public/pages/alerts/{ => components}/default_cell_actions.tsx (85%) rename x-pack/plugins/observability/public/pages/alerts/{ => components}/filter_for_value.tsx (100%) create mode 100644 x-pack/plugins/observability/public/pages/alerts/components/index.ts rename x-pack/plugins/observability/public/pages/alerts/{ => components}/parse_alert.ts (78%) create mode 100644 x-pack/plugins/observability/public/pages/alerts/components/render_cell_value/index.ts rename x-pack/plugins/observability/public/pages/alerts/{ => components/render_cell_value}/render_cell_value.test.tsx (87%) rename x-pack/plugins/observability/public/pages/alerts/{ => components/render_cell_value}/render_cell_value.tsx (86%) create mode 100644 x-pack/plugins/observability/public/pages/alerts/components/severity_badge/index.ts rename x-pack/plugins/observability/public/pages/alerts/{ => components/severity_badge}/severity_badge.stories.tsx (100%) rename x-pack/plugins/observability/public/pages/alerts/{ => components/severity_badge}/severity_badge.tsx (100%) create mode 100644 x-pack/plugins/observability/public/pages/alerts/components/workflow_status_filter/index.ts rename x-pack/plugins/observability/public/pages/alerts/{ => components/workflow_status_filter}/workflow_status_filter.stories.tsx (92%) rename x-pack/plugins/observability/public/pages/alerts/{ => components/workflow_status_filter}/workflow_status_filter.test.tsx (95%) rename x-pack/plugins/observability/public/pages/alerts/{ => components/workflow_status_filter}/workflow_status_filter.tsx (95%) rename x-pack/plugins/observability/public/pages/alerts/{index.tsx => containers/alerts_page/alerts_page.tsx} (87%) create mode 100644 x-pack/plugins/observability/public/pages/alerts/containers/alerts_page/index.ts rename x-pack/plugins/observability/public/pages/alerts/{ => containers/alerts_page}/styles.scss (100%) rename x-pack/plugins/observability/public/pages/alerts/{ => containers/alerts_table_t_grid}/alerts_table_t_grid.tsx (94%) create mode 100644 x-pack/plugins/observability/public/pages/alerts/containers/alerts_table_t_grid/index.ts create mode 100644 x-pack/plugins/observability/public/pages/alerts/containers/index.ts rename x-pack/plugins/observability/public/pages/alerts/{ => containers}/state_container/index.tsx (100%) rename x-pack/plugins/observability/public/pages/alerts/{ => containers}/state_container/state_container.tsx (92%) rename x-pack/plugins/observability/public/pages/alerts/{ => containers}/state_container/use_alerts_page_state_container.tsx (92%) create mode 100644 x-pack/plugins/observability/public/pages/alerts/index.ts diff --git a/x-pack/plugins/observability/public/index.ts b/x-pack/plugins/observability/public/index.ts index 7646ac9bec9bb..2383044bc14c2 100644 --- a/x-pack/plugins/observability/public/index.ts +++ b/x-pack/plugins/observability/public/index.ts @@ -64,7 +64,9 @@ export { METRIC_TYPE, } from './hooks/use_track_metric'; -export const LazyAlertsFlyout = lazy(() => import('./pages/alerts/alerts_flyout')); +export const LazyAlertsFlyout = lazy( + () => import('./pages/alerts/components/alerts_flyout/alerts_flyout') +); export { useFetcher, FETCH_STATUS } from './hooks/use_fetcher'; export { useEsSearch, createEsParams } from './hooks/use_es_search'; diff --git a/x-pack/plugins/observability/public/pages/alerts/alerts_disclaimer.tsx b/x-pack/plugins/observability/public/pages/alerts/components/alerts_disclaimer.tsx similarity index 100% rename from x-pack/plugins/observability/public/pages/alerts/alerts_disclaimer.tsx rename to x-pack/plugins/observability/public/pages/alerts/components/alerts_disclaimer.tsx diff --git a/x-pack/plugins/observability/public/pages/alerts/alerts_flyout/alerts_flyout.stories.tsx b/x-pack/plugins/observability/public/pages/alerts/components/alerts_flyout/alerts_flyout.stories.tsx similarity index 85% rename from x-pack/plugins/observability/public/pages/alerts/alerts_flyout/alerts_flyout.stories.tsx rename to x-pack/plugins/observability/public/pages/alerts/components/alerts_flyout/alerts_flyout.stories.tsx index 64d495dbbc798..36b1fc2f2b6e2 100644 --- a/x-pack/plugins/observability/public/pages/alerts/alerts_flyout/alerts_flyout.stories.tsx +++ b/x-pack/plugins/observability/public/pages/alerts/components/alerts_flyout/alerts_flyout.stories.tsx @@ -7,11 +7,11 @@ import { ALERT_UUID } from '@kbn/rule-data-utils/technical_field_names'; import React, { ComponentType } from 'react'; -import { KibanaContextProvider } from '../../../../../../../src/plugins/kibana_react/public'; -import { PluginContext, PluginContextValue } from '../../../context/plugin_context'; -import { createObservabilityRuleTypeRegistryMock } from '../../../rules/observability_rule_type_registry_mock'; -import { apmAlertResponseExample } from '../example_data'; -import { AlertsFlyout } from './'; +import { KibanaContextProvider } from '../../../../../../../../src/plugins/kibana_react/public'; +import { PluginContext, PluginContextValue } from '../../../../context/plugin_context'; +import { createObservabilityRuleTypeRegistryMock } from '../../../../rules/observability_rule_type_registry_mock'; +import { apmAlertResponseExample } from './example_data'; +import { AlertsFlyout } from '..'; interface Args { alerts: Array>; diff --git a/x-pack/plugins/observability/public/pages/alerts/alerts_flyout/alerts_flyout.test.tsx b/x-pack/plugins/observability/public/pages/alerts/components/alerts_flyout/alerts_flyout.test.tsx similarity index 91% rename from x-pack/plugins/observability/public/pages/alerts/alerts_flyout/alerts_flyout.test.tsx rename to x-pack/plugins/observability/public/pages/alerts/components/alerts_flyout/alerts_flyout.test.tsx index 4fdc8d245799a..13fb5d805fb81 100644 --- a/x-pack/plugins/observability/public/pages/alerts/alerts_flyout/alerts_flyout.test.tsx +++ b/x-pack/plugins/observability/public/pages/alerts/components/alerts_flyout/alerts_flyout.test.tsx @@ -6,11 +6,11 @@ */ import React from 'react'; -import * as useUiSettingHook from '../../../../../../../src/plugins/kibana_react/public/ui_settings/use_ui_setting'; -import { createObservabilityRuleTypeRegistryMock } from '../../../rules/observability_rule_type_registry_mock'; -import { render } from '../../../utils/test_helper'; -import type { TopAlert } from '../'; -import { AlertsFlyout } from './'; +import * as useUiSettingHook from '../../../../../../../../src/plugins/kibana_react/public/ui_settings/use_ui_setting'; +import { createObservabilityRuleTypeRegistryMock } from '../../../../rules/observability_rule_type_registry_mock'; +import { render } from '../../../../utils/test_helper'; +import type { TopAlert } from '../../containers/alerts_page'; +import { AlertsFlyout } from '..'; describe('AlertsFlyout', () => { jest diff --git a/x-pack/plugins/observability/public/pages/alerts/alerts_flyout/index.tsx b/x-pack/plugins/observability/public/pages/alerts/components/alerts_flyout/alerts_flyout.tsx similarity index 89% rename from x-pack/plugins/observability/public/pages/alerts/alerts_flyout/index.tsx rename to x-pack/plugins/observability/public/pages/alerts/components/alerts_flyout/alerts_flyout.tsx index c5cad5f3b1c8c..ced4896c5f31d 100644 --- a/x-pack/plugins/observability/public/pages/alerts/alerts_flyout/index.tsx +++ b/x-pack/plugins/observability/public/pages/alerts/components/alerts_flyout/alerts_flyout.tsx @@ -35,14 +35,14 @@ import { } from '@kbn/rule-data-utils/alerts_as_data_status'; import moment from 'moment-timezone'; import React, { useMemo } from 'react'; -import type { TopAlert } from '../'; -import { useKibana, useUiSetting } from '../../../../../../../src/plugins/kibana_react/public'; -import { asDuration } from '../../../../common/utils/formatters'; -import type { ObservabilityRuleTypeRegistry } from '../../../rules/create_observability_rule_type_registry'; +import type { TopAlert } from '../../containers'; +import { useKibana, useUiSetting } from '../../../../../../../../src/plugins/kibana_react/public'; +import { asDuration } from '../../../../../common/utils/formatters'; +import type { ObservabilityRuleTypeRegistry } from '../../../../rules/create_observability_rule_type_registry'; import { parseAlert } from '../parse_alert'; -import { AlertStatusIndicator } from '../../../components/shared/alert_status_indicator'; -import { ExperimentalBadge } from '../../../components/shared/experimental_badge'; -import { translations, paths } from '../../../config'; +import { AlertStatusIndicator } from '../../../../components/shared/alert_status_indicator'; +import { ExperimentalBadge } from '../../../../components/shared/experimental_badge'; +import { translations, paths } from '../../../../config'; type AlertsFlyoutProps = { alert?: TopAlert; diff --git a/x-pack/plugins/observability/public/pages/alerts/example_data.ts b/x-pack/plugins/observability/public/pages/alerts/components/alerts_flyout/example_data.ts similarity index 100% rename from x-pack/plugins/observability/public/pages/alerts/example_data.ts rename to x-pack/plugins/observability/public/pages/alerts/components/alerts_flyout/example_data.ts diff --git a/x-pack/plugins/observability/public/pages/alerts/components/alerts_flyout/index.ts b/x-pack/plugins/observability/public/pages/alerts/components/alerts_flyout/index.ts new file mode 100644 index 0000000000000..4153ab6e5b596 --- /dev/null +++ b/x-pack/plugins/observability/public/pages/alerts/components/alerts_flyout/index.ts @@ -0,0 +1,8 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export { AlertsFlyout } from './alerts_flyout'; diff --git a/x-pack/plugins/observability/public/pages/alerts/alerts_search_bar.tsx b/x-pack/plugins/observability/public/pages/alerts/components/alerts_search_bar.tsx similarity index 92% rename from x-pack/plugins/observability/public/pages/alerts/alerts_search_bar.tsx rename to x-pack/plugins/observability/public/pages/alerts/components/alerts_search_bar.tsx index 926f03acf01d8..14d47d1e7e9d3 100644 --- a/x-pack/plugins/observability/public/pages/alerts/alerts_search_bar.tsx +++ b/x-pack/plugins/observability/public/pages/alerts/components/alerts_search_bar.tsx @@ -8,8 +8,8 @@ import { IndexPatternBase } from '@kbn/es-query'; import { i18n } from '@kbn/i18n'; import React, { useMemo, useState } from 'react'; -import { SearchBar, TimeHistory } from '../../../../../../src/plugins/data/public'; -import { Storage } from '../../../../../../src/plugins/kibana_utils/public'; +import { SearchBar, TimeHistory } from '../../../../../../../src/plugins/data/public'; +import { Storage } from '../../../../../../../src/plugins/kibana_utils/public'; export function AlertsSearchBar({ dynamicIndexPatterns, diff --git a/x-pack/plugins/observability/public/pages/alerts/alerts_status_filter.tsx b/x-pack/plugins/observability/public/pages/alerts/components/alerts_status_filter.tsx similarity index 94% rename from x-pack/plugins/observability/public/pages/alerts/alerts_status_filter.tsx rename to x-pack/plugins/observability/public/pages/alerts/components/alerts_status_filter.tsx index 38c753bbebf3b..d717e916de2c6 100644 --- a/x-pack/plugins/observability/public/pages/alerts/alerts_status_filter.tsx +++ b/x-pack/plugins/observability/public/pages/alerts/components/alerts_status_filter.tsx @@ -13,8 +13,8 @@ import { ALERT_STATUS_RECOVERED, } from '@kbn/rule-data-utils/alerts_as_data_status'; import { ALERT_STATUS } from '@kbn/rule-data-utils/technical_field_names'; -import { AlertStatusFilterButton } from '../../../common/typings'; -import { AlertStatusFilter } from '../../../common/typings'; +import { AlertStatusFilterButton } from '../../../../common/typings'; +import { AlertStatusFilter } from '../../../../common/typings'; export interface AlertStatusFilterProps { status: AlertStatusFilterButton; diff --git a/x-pack/plugins/observability/public/pages/alerts/default_cell_actions.tsx b/x-pack/plugins/observability/public/pages/alerts/components/default_cell_actions.tsx similarity index 85% rename from x-pack/plugins/observability/public/pages/alerts/default_cell_actions.tsx rename to x-pack/plugins/observability/public/pages/alerts/components/default_cell_actions.tsx index 3adfb0a1d9c89..5126647161fa5 100644 --- a/x-pack/plugins/observability/public/pages/alerts/default_cell_actions.tsx +++ b/x-pack/plugins/observability/public/pages/alerts/components/default_cell_actions.tsx @@ -9,9 +9,9 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { getMappedNonEcsValue } from './render_cell_value'; import FilterForValueButton from './filter_for_value'; -import { TimelineNonEcsData } from '../../../../timelines/common/search_strategy'; -import { TGridCellAction } from '../../../../timelines/common/types/timeline'; -import { getPageRowIndex } from '../../../../timelines/public'; +import { TimelineNonEcsData } from '../../../../../timelines/common/search_strategy'; +import { TGridCellAction } from '../../../../../timelines/common/types/timeline'; +import { getPageRowIndex } from '../../../../../timelines/public'; export const FILTER_FOR_VALUE = i18n.translate('xpack.observability.hoverActions.filterForValue', { defaultMessage: 'Filter for value', diff --git a/x-pack/plugins/observability/public/pages/alerts/filter_for_value.tsx b/x-pack/plugins/observability/public/pages/alerts/components/filter_for_value.tsx similarity index 100% rename from x-pack/plugins/observability/public/pages/alerts/filter_for_value.tsx rename to x-pack/plugins/observability/public/pages/alerts/components/filter_for_value.tsx diff --git a/x-pack/plugins/observability/public/pages/alerts/components/index.ts b/x-pack/plugins/observability/public/pages/alerts/components/index.ts new file mode 100644 index 0000000000000..57ad311f65d1c --- /dev/null +++ b/x-pack/plugins/observability/public/pages/alerts/components/index.ts @@ -0,0 +1,17 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export * from './alerts_flyout'; +export * from './render_cell_value'; +export * from './severity_badge'; +export * from './workflow_status_filter'; +export * from './alerts_search_bar'; +export * from './alerts_disclaimer'; +export * from './default_cell_actions'; +export * from './filter_for_value'; +export * from './parse_alert'; +export * from './alerts_status_filter'; diff --git a/x-pack/plugins/observability/public/pages/alerts/parse_alert.ts b/x-pack/plugins/observability/public/pages/alerts/components/parse_alert.ts similarity index 78% rename from x-pack/plugins/observability/public/pages/alerts/parse_alert.ts rename to x-pack/plugins/observability/public/pages/alerts/components/parse_alert.ts index 7b28803084067..680798811e9ab 100644 --- a/x-pack/plugins/observability/public/pages/alerts/parse_alert.ts +++ b/x-pack/plugins/observability/public/pages/alerts/components/parse_alert.ts @@ -12,10 +12,10 @@ import { ALERT_RULE_NAME, } from '@kbn/rule-data-utils/technical_field_names'; import { ALERT_STATUS_ACTIVE } from '@kbn/rule-data-utils/alerts_as_data_status'; -import type { TopAlert } from '.'; -import { parseTechnicalFields } from '../../../../rule_registry/common/parse_technical_fields'; -import { asDuration, asPercent } from '../../../common/utils/formatters'; -import { ObservabilityRuleTypeRegistry } from '../../rules/create_observability_rule_type_registry'; +import type { TopAlert } from '../'; +import { parseTechnicalFields } from '../../../../../rule_registry/common/parse_technical_fields'; +import { asDuration, asPercent } from '../../../../common/utils/formatters'; +import { ObservabilityRuleTypeRegistry } from '../../../rules/create_observability_rule_type_registry'; export const parseAlert = (observabilityRuleTypeRegistry: ObservabilityRuleTypeRegistry) => diff --git a/x-pack/plugins/observability/public/pages/alerts/components/render_cell_value/index.ts b/x-pack/plugins/observability/public/pages/alerts/components/render_cell_value/index.ts new file mode 100644 index 0000000000000..b6df77f075888 --- /dev/null +++ b/x-pack/plugins/observability/public/pages/alerts/components/render_cell_value/index.ts @@ -0,0 +1,8 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export { getRenderCellValue, getMappedNonEcsValue } from './render_cell_value'; diff --git a/x-pack/plugins/observability/public/pages/alerts/render_cell_value.test.tsx b/x-pack/plugins/observability/public/pages/alerts/components/render_cell_value/render_cell_value.test.tsx similarity index 87% rename from x-pack/plugins/observability/public/pages/alerts/render_cell_value.test.tsx rename to x-pack/plugins/observability/public/pages/alerts/components/render_cell_value/render_cell_value.test.tsx index 79a27faa96c69..25de2e36b08c3 100644 --- a/x-pack/plugins/observability/public/pages/alerts/render_cell_value.test.tsx +++ b/x-pack/plugins/observability/public/pages/alerts/components/render_cell_value/render_cell_value.test.tsx @@ -10,10 +10,10 @@ import { ALERT_STATUS_RECOVERED, } from '@kbn/rule-data-utils/alerts_as_data_status'; import { ALERT_STATUS } from '@kbn/rule-data-utils/technical_field_names'; -import type { CellValueElementProps } from '../../../../timelines/common'; -import { createObservabilityRuleTypeRegistryMock } from '../../rules/observability_rule_type_registry_mock'; -import * as PluginHook from '../../hooks/use_plugin_context'; -import { render } from '../../utils/test_helper'; +import type { CellValueElementProps } from '../../../../../../timelines/common'; +import { createObservabilityRuleTypeRegistryMock } from '../../../../rules/observability_rule_type_registry_mock'; +import * as PluginHook from '../../../../hooks/use_plugin_context'; +import { render } from '../../../../utils/test_helper'; import { getRenderCellValue } from './render_cell_value'; interface AlertsTableRow { diff --git a/x-pack/plugins/observability/public/pages/alerts/render_cell_value.tsx b/x-pack/plugins/observability/public/pages/alerts/components/render_cell_value/render_cell_value.tsx similarity index 86% rename from x-pack/plugins/observability/public/pages/alerts/render_cell_value.tsx rename to x-pack/plugins/observability/public/pages/alerts/components/render_cell_value/render_cell_value.tsx index 80ccd4a69b281..d9fa6c6e2221b 100644 --- a/x-pack/plugins/observability/public/pages/alerts/render_cell_value.tsx +++ b/x-pack/plugins/observability/public/pages/alerts/components/render_cell_value/render_cell_value.tsx @@ -17,14 +17,14 @@ import { ALERT_STATUS_ACTIVE, ALERT_STATUS_RECOVERED, } from '@kbn/rule-data-utils/alerts_as_data_status'; -import type { CellValueElementProps, TimelineNonEcsData } from '../../../../timelines/common'; -import { AlertStatusIndicator } from '../../components/shared/alert_status_indicator'; -import { TimestampTooltip } from '../../components/shared/timestamp_tooltip'; -import { asDuration } from '../../../common/utils/formatters'; -import { SeverityBadge } from './severity_badge'; -import { TopAlert } from '.'; -import { parseAlert } from './parse_alert'; -import { usePluginContext } from '../../hooks/use_plugin_context'; +import type { CellValueElementProps, TimelineNonEcsData } from '../../../../../../timelines/common'; +import { AlertStatusIndicator } from '../../../../components/shared/alert_status_indicator'; +import { TimestampTooltip } from '../../../../components/shared/timestamp_tooltip'; +import { asDuration } from '../../../../../common/utils/formatters'; +import { SeverityBadge } from '../severity_badge'; +import { TopAlert } from '../../'; +import { parseAlert } from '../parse_alert'; +import { usePluginContext } from '../../../../hooks/use_plugin_context'; export const getMappedNonEcsValue = ({ data, diff --git a/x-pack/plugins/observability/public/pages/alerts/components/severity_badge/index.ts b/x-pack/plugins/observability/public/pages/alerts/components/severity_badge/index.ts new file mode 100644 index 0000000000000..7974156327085 --- /dev/null +++ b/x-pack/plugins/observability/public/pages/alerts/components/severity_badge/index.ts @@ -0,0 +1,8 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export { SeverityBadge } from './severity_badge'; diff --git a/x-pack/plugins/observability/public/pages/alerts/severity_badge.stories.tsx b/x-pack/plugins/observability/public/pages/alerts/components/severity_badge/severity_badge.stories.tsx similarity index 100% rename from x-pack/plugins/observability/public/pages/alerts/severity_badge.stories.tsx rename to x-pack/plugins/observability/public/pages/alerts/components/severity_badge/severity_badge.stories.tsx diff --git a/x-pack/plugins/observability/public/pages/alerts/severity_badge.tsx b/x-pack/plugins/observability/public/pages/alerts/components/severity_badge/severity_badge.tsx similarity index 100% rename from x-pack/plugins/observability/public/pages/alerts/severity_badge.tsx rename to x-pack/plugins/observability/public/pages/alerts/components/severity_badge/severity_badge.tsx diff --git a/x-pack/plugins/observability/public/pages/alerts/components/workflow_status_filter/index.ts b/x-pack/plugins/observability/public/pages/alerts/components/workflow_status_filter/index.ts new file mode 100644 index 0000000000000..84badecd29dcd --- /dev/null +++ b/x-pack/plugins/observability/public/pages/alerts/components/workflow_status_filter/index.ts @@ -0,0 +1,8 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export { WorkflowStatusFilter } from './workflow_status_filter'; diff --git a/x-pack/plugins/observability/public/pages/alerts/workflow_status_filter.stories.tsx b/x-pack/plugins/observability/public/pages/alerts/components/workflow_status_filter/workflow_status_filter.stories.tsx similarity index 92% rename from x-pack/plugins/observability/public/pages/alerts/workflow_status_filter.stories.tsx rename to x-pack/plugins/observability/public/pages/alerts/components/workflow_status_filter/workflow_status_filter.stories.tsx index e06b5d333a9a6..4dce3ee80b833 100644 --- a/x-pack/plugins/observability/public/pages/alerts/workflow_status_filter.stories.tsx +++ b/x-pack/plugins/observability/public/pages/alerts/components/workflow_status_filter/workflow_status_filter.stories.tsx @@ -6,7 +6,7 @@ */ import React, { ComponentProps, useState } from 'react'; -import type { AlertWorkflowStatus } from '../../../common/typings'; +import type { AlertWorkflowStatus } from '../../../../../common/typings'; import { WorkflowStatusFilter } from './workflow_status_filter'; type Args = ComponentProps; diff --git a/x-pack/plugins/observability/public/pages/alerts/workflow_status_filter.test.tsx b/x-pack/plugins/observability/public/pages/alerts/components/workflow_status_filter/workflow_status_filter.test.tsx similarity index 95% rename from x-pack/plugins/observability/public/pages/alerts/workflow_status_filter.test.tsx rename to x-pack/plugins/observability/public/pages/alerts/components/workflow_status_filter/workflow_status_filter.test.tsx index 29c5e88788a89..a9819a6619dc5 100644 --- a/x-pack/plugins/observability/public/pages/alerts/workflow_status_filter.test.tsx +++ b/x-pack/plugins/observability/public/pages/alerts/components/workflow_status_filter/workflow_status_filter.test.tsx @@ -8,7 +8,7 @@ import { render } from '@testing-library/react'; import { Simulate } from 'react-dom/test-utils'; import React from 'react'; -import type { AlertWorkflowStatus } from '../../../common/typings'; +import type { AlertWorkflowStatus } from '../../../../../common/typings'; import { WorkflowStatusFilter } from './workflow_status_filter'; describe('StatusFilter', () => { diff --git a/x-pack/plugins/observability/public/pages/alerts/workflow_status_filter.tsx b/x-pack/plugins/observability/public/pages/alerts/components/workflow_status_filter/workflow_status_filter.tsx similarity index 95% rename from x-pack/plugins/observability/public/pages/alerts/workflow_status_filter.tsx rename to x-pack/plugins/observability/public/pages/alerts/components/workflow_status_filter/workflow_status_filter.tsx index d857b9d6bd650..86116fb969682 100644 --- a/x-pack/plugins/observability/public/pages/alerts/workflow_status_filter.tsx +++ b/x-pack/plugins/observability/public/pages/alerts/components/workflow_status_filter/workflow_status_filter.tsx @@ -8,7 +8,7 @@ import { EuiButtonGroup, EuiButtonGroupOptionProps } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import React from 'react'; -import type { AlertWorkflowStatus } from '../../../common/typings'; +import type { AlertWorkflowStatus } from '../../../../../common/typings'; export interface WorkflowStatusFilterProps { status: AlertWorkflowStatus; diff --git a/x-pack/plugins/observability/public/pages/alerts/index.tsx b/x-pack/plugins/observability/public/pages/alerts/containers/alerts_page/alerts_page.tsx similarity index 87% rename from x-pack/plugins/observability/public/pages/alerts/index.tsx rename to x-pack/plugins/observability/public/pages/alerts/containers/alerts_page/alerts_page.tsx index 2636463bcfd7a..b19a1dbe86fe1 100644 --- a/x-pack/plugins/observability/public/pages/alerts/index.tsx +++ b/x-pack/plugins/observability/public/pages/alerts/containers/alerts_page/alerts_page.tsx @@ -14,23 +14,25 @@ import useAsync from 'react-use/lib/useAsync'; import { AlertStatus } from '@kbn/rule-data-utils/alerts_as_data_status'; import { ALERT_STATUS } from '@kbn/rule-data-utils/technical_field_names'; -import { AlertStatusFilterButton } from '../../../common/typings'; -import { ParsedTechnicalFields } from '../../../../rule_registry/common/parse_technical_fields'; -import { ExperimentalBadge } from '../../components/shared/experimental_badge'; -import { useBreadcrumbs } from '../../hooks/use_breadcrumbs'; -import { useFetcher } from '../../hooks/use_fetcher'; -import { useHasData } from '../../hooks/use_has_data'; -import { usePluginContext } from '../../hooks/use_plugin_context'; -import { useTimefilterService } from '../../hooks/use_timefilter_service'; -import { callObservabilityApi } from '../../services/call_observability_api'; -import { getNoDataConfig } from '../../utils/no_data_config'; -import { LoadingObservability } from '../overview/loading_observability'; -import { AlertsSearchBar } from './alerts_search_bar'; -import { AlertsTableTGrid } from './alerts_table_t_grid'; -import { Provider, alertsPageStateContainer, useAlertsPageStateContainer } from './state_container'; +import { AlertStatusFilterButton } from '../../../../../common/typings'; +import { ParsedTechnicalFields } from '../../../../../../rule_registry/common/parse_technical_fields'; +import { ExperimentalBadge } from '../../../../components/shared/experimental_badge'; +import { useBreadcrumbs } from '../../../../hooks/use_breadcrumbs'; +import { useFetcher } from '../../../../hooks/use_fetcher'; +import { useHasData } from '../../../../hooks/use_has_data'; +import { usePluginContext } from '../../../../hooks/use_plugin_context'; +import { useTimefilterService } from '../../../../hooks/use_timefilter_service'; +import { callObservabilityApi } from '../../../../services/call_observability_api'; +import { getNoDataConfig } from '../../../../utils/no_data_config'; +import { LoadingObservability } from '../../../overview/loading_observability'; +import { AlertsTableTGrid } from '../alerts_table_t_grid'; +import { + Provider, + alertsPageStateContainer, + useAlertsPageStateContainer, +} from '../state_container'; import './styles.scss'; -import { AlertsStatusFilter } from './alerts_status_filter'; -import { AlertsDisclaimer } from './alerts_disclaimer'; +import { AlertsStatusFilter, AlertsDisclaimer, AlertsSearchBar } from '../../components'; export interface TopAlert { fields: ParsedTechnicalFields; @@ -243,12 +245,10 @@ function AlertsPage() { ); } -function WrappedAlertsPage() { +export function WrappedAlertsPage() { return ( ); } - -export { WrappedAlertsPage as AlertsPage }; diff --git a/x-pack/plugins/observability/public/pages/alerts/containers/alerts_page/index.ts b/x-pack/plugins/observability/public/pages/alerts/containers/alerts_page/index.ts new file mode 100644 index 0000000000000..e3509e04b2f2b --- /dev/null +++ b/x-pack/plugins/observability/public/pages/alerts/containers/alerts_page/index.ts @@ -0,0 +1,9 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export { WrappedAlertsPage as AlertsPage } from './alerts_page'; +export type { TopAlert } from './alerts_page'; diff --git a/x-pack/plugins/observability/public/pages/alerts/styles.scss b/x-pack/plugins/observability/public/pages/alerts/containers/alerts_page/styles.scss similarity index 100% rename from x-pack/plugins/observability/public/pages/alerts/styles.scss rename to x-pack/plugins/observability/public/pages/alerts/containers/alerts_page/styles.scss diff --git a/x-pack/plugins/observability/public/pages/alerts/alerts_table_t_grid.tsx b/x-pack/plugins/observability/public/pages/alerts/containers/alerts_table_t_grid/alerts_table_t_grid.tsx similarity index 94% rename from x-pack/plugins/observability/public/pages/alerts/alerts_table_t_grid.tsx rename to x-pack/plugins/observability/public/pages/alerts/containers/alerts_table_t_grid/alerts_table_t_grid.tsx index 4b64ae07ddf06..bf99bcedc16be 100644 --- a/x-pack/plugins/observability/public/pages/alerts/alerts_table_t_grid.tsx +++ b/x-pack/plugins/observability/public/pages/alerts/containers/alerts_table_t_grid/alerts_table_t_grid.tsx @@ -33,33 +33,33 @@ import styled from 'styled-components'; import React, { Suspense, useMemo, useState, useCallback, useEffect } from 'react'; import usePrevious from 'react-use/lib/usePrevious'; import { pick } from 'lodash'; -import { getAlertsPermissions } from '../../hooks/use_alert_permission'; +import { getAlertsPermissions } from '../../../../hooks/use_alert_permission'; import type { TimelinesUIStart, TGridType, TGridState, TGridModel, SortDirection, -} from '../../../../timelines/public'; +} from '../../../../../../timelines/public'; -import type { TopAlert } from './'; -import { useKibana } from '../../../../../../src/plugins/kibana_react/public'; +import type { TopAlert } from '../alerts_page/alerts_page'; +import { useKibana } from '../../../../../../../../src/plugins/kibana_react/public'; import type { ActionProps, AlertWorkflowStatus, ColumnHeaderOptions, ControlColumnProps, RowRenderer, -} from '../../../../timelines/common'; - -import { getRenderCellValue } from './render_cell_value'; -import { observabilityAppId, observabilityFeatureId } from '../../../common'; -import { useGetUserCasesPermissions } from '../../hooks/use_get_user_cases_permissions'; -import { usePluginContext } from '../../hooks/use_plugin_context'; -import { LazyAlertsFlyout } from '../..'; -import { parseAlert } from './parse_alert'; -import { CoreStart } from '../../../../../../src/core/public'; -import { translations, paths } from '../../config'; +} from '../../../../../../timelines/common'; + +import { getRenderCellValue } from '../../components/render_cell_value'; +import { observabilityAppId, observabilityFeatureId } from '../../../../../common'; +import { useGetUserCasesPermissions } from '../../../../hooks/use_get_user_cases_permissions'; +import { usePluginContext } from '../../../../hooks/use_plugin_context'; +import { LazyAlertsFlyout } from '../../../..'; +import { parseAlert } from '../../components/parse_alert'; +import { CoreStart } from '../../../../../../../../src/core/public'; +import { translations, paths } from '../../../../config'; const ALERT_TABLE_STATE_STORAGE_KEY = 'xpack.observability.alert.tableState'; diff --git a/x-pack/plugins/observability/public/pages/alerts/containers/alerts_table_t_grid/index.ts b/x-pack/plugins/observability/public/pages/alerts/containers/alerts_table_t_grid/index.ts new file mode 100644 index 0000000000000..7bbcc43230a44 --- /dev/null +++ b/x-pack/plugins/observability/public/pages/alerts/containers/alerts_table_t_grid/index.ts @@ -0,0 +1,8 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export { AlertsTableTGrid } from './alerts_table_t_grid'; diff --git a/x-pack/plugins/observability/public/pages/alerts/containers/index.ts b/x-pack/plugins/observability/public/pages/alerts/containers/index.ts new file mode 100644 index 0000000000000..074f48f426640 --- /dev/null +++ b/x-pack/plugins/observability/public/pages/alerts/containers/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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export * from './alerts_page'; +export * from './alerts_table_t_grid'; +export * from './state_container'; diff --git a/x-pack/plugins/observability/public/pages/alerts/state_container/index.tsx b/x-pack/plugins/observability/public/pages/alerts/containers/state_container/index.tsx similarity index 100% rename from x-pack/plugins/observability/public/pages/alerts/state_container/index.tsx rename to x-pack/plugins/observability/public/pages/alerts/containers/state_container/index.tsx diff --git a/x-pack/plugins/observability/public/pages/alerts/state_container/state_container.tsx b/x-pack/plugins/observability/public/pages/alerts/containers/state_container/state_container.tsx similarity index 92% rename from x-pack/plugins/observability/public/pages/alerts/state_container/state_container.tsx rename to x-pack/plugins/observability/public/pages/alerts/containers/state_container/state_container.tsx index 3e0a801fedbe2..d00109cc5d63f 100644 --- a/x-pack/plugins/observability/public/pages/alerts/state_container/state_container.tsx +++ b/x-pack/plugins/observability/public/pages/alerts/containers/state_container/state_container.tsx @@ -8,8 +8,8 @@ import { createStateContainer, createStateContainerReactHelpers, -} from '../../../../../../../src/plugins/kibana_utils/public'; -import type { AlertWorkflowStatus } from '../../../../common/typings'; +} from '../../../../../../../../src/plugins/kibana_utils/public'; +import type { AlertWorkflowStatus } from '../../../../../common/typings'; interface AlertsPageContainerState { rangeFrom: string; diff --git a/x-pack/plugins/observability/public/pages/alerts/state_container/use_alerts_page_state_container.tsx b/x-pack/plugins/observability/public/pages/alerts/containers/state_container/use_alerts_page_state_container.tsx similarity index 92% rename from x-pack/plugins/observability/public/pages/alerts/state_container/use_alerts_page_state_container.tsx rename to x-pack/plugins/observability/public/pages/alerts/containers/state_container/use_alerts_page_state_container.tsx index dfa4afcd939cc..5e81286affba7 100644 --- a/x-pack/plugins/observability/public/pages/alerts/state_container/use_alerts_page_state_container.tsx +++ b/x-pack/plugins/observability/public/pages/alerts/containers/state_container/use_alerts_page_state_container.tsx @@ -8,14 +8,14 @@ import { useEffect } from 'react'; import { useHistory } from 'react-router-dom'; -import { TimefilterContract } from '../../../../../../../src/plugins/data/public'; +import { TimefilterContract } from '../../../../../../../../src/plugins/data/public'; import { createKbnUrlStateStorage, syncState, IKbnUrlStateStorage, useContainerSelector, -} from '../../../../../../../src/plugins/kibana_utils/public'; -import { useTimefilterService } from '../../../hooks/use_timefilter_service'; +} from '../../../../../../../../src/plugins/kibana_utils/public'; +import { useTimefilterService } from '../../../../hooks/use_timefilter_service'; import { useContainer, diff --git a/x-pack/plugins/observability/public/pages/alerts/index.ts b/x-pack/plugins/observability/public/pages/alerts/index.ts new file mode 100644 index 0000000000000..525f3441c4470 --- /dev/null +++ b/x-pack/plugins/observability/public/pages/alerts/index.ts @@ -0,0 +1,9 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export * from './components'; +export * from './containers'; diff --git a/x-pack/plugins/observability/public/pages/cases/helpers.ts b/x-pack/plugins/observability/public/pages/cases/helpers.ts index 91f45c711d6a6..f4bc5af7f604d 100644 --- a/x-pack/plugins/observability/public/pages/cases/helpers.ts +++ b/x-pack/plugins/observability/public/pages/cases/helpers.ts @@ -6,10 +6,8 @@ */ import { useEffect, useState } from 'react'; import { isEmpty } from 'lodash'; - import { usePluginContext } from '../../hooks/use_plugin_context'; -import { parseAlert } from '../../pages/alerts/parse_alert'; -import { TopAlert } from '../../pages/alerts/'; +import { TopAlert, parseAlert } from '../../pages/alerts/'; import { useKibana } from '../../utils/kibana_react'; import { Ecs } from '../../../../cases/common'; diff --git a/x-pack/plugins/observability/public/routes/index.tsx b/x-pack/plugins/observability/public/routes/index.tsx index 169f4b5254c04..6f38a66cdb643 100644 --- a/x-pack/plugins/observability/public/routes/index.tsx +++ b/x-pack/plugins/observability/public/routes/index.tsx @@ -8,8 +8,8 @@ import * as t from 'io-ts'; import React from 'react'; import { casesPath } from '../../common'; -import { AlertsPage } from '../pages/alerts'; import { CasesPage } from '../pages/cases'; +import { AlertsPage } from '../pages/alerts/containers/alerts_page'; import { HomePage } from '../pages/home'; import { LandingPage } from '../pages/landing'; import { OverviewPage } from '../pages/overview';