diff --git a/x-pack/plugins/apm/public/components/app/alerts_overview/index.tsx b/x-pack/plugins/apm/public/components/app/alerts_overview/index.tsx index dbf2d94b20699..b5ed35059bda9 100644 --- a/x-pack/plugins/apm/public/components/app/alerts_overview/index.tsx +++ b/x-pack/plugins/apm/public/components/app/alerts_overview/index.tsx @@ -53,6 +53,7 @@ export function AlertsOverview() { timefilter: { timefilter: timeFilterService }, }, }, + uiSettings, } = services; const useToasts = () => notifications!.toasts; @@ -98,7 +99,12 @@ export function AlertsOverview() { rangeTo={rangeTo} rangeFrom={rangeFrom} status={alertStatusFilter} - services={{ timeFilterService, AlertsSearchBar, useToasts }} + services={{ + timeFilterService, + AlertsSearchBar, + useToasts, + uiSettings, + }} /> diff --git a/x-pack/plugins/apm/public/plugin.ts b/x-pack/plugins/apm/public/plugin.ts index 173e52e5955cd..065eba1b7e64f 100644 --- a/x-pack/plugins/apm/public/plugin.ts +++ b/x-pack/plugins/apm/public/plugin.ts @@ -70,6 +70,7 @@ import { UiActionsSetup, UiActionsStart } from '@kbn/ui-actions-plugin/public'; import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public'; import { UsageCollectionStart } from '@kbn/usage-collection-plugin/public'; import { DashboardStart } from '@kbn/dashboard-plugin/public'; +import type { IUiSettingsClient } from '@kbn/core-ui-settings-browser'; import { from } from 'rxjs'; import { map } from 'rxjs/operators'; import type { ConfigSchema } from '.'; @@ -84,6 +85,7 @@ import { getLazyAPMPolicyEditExtension } from './components/fleet_integration/la import { featureCatalogueEntry } from './feature_catalogue_entry'; import { APMServiceDetailLocator } from './locator/service_detail_locator'; import { ITelemetryClient, TelemetryService } from './services/telemetry'; + export type ApmPluginSetup = ReturnType; export type ApmPluginStart = void; @@ -137,6 +139,7 @@ export interface ApmPluginStartDeps { observabilityAIAssistant: ObservabilityAIAssistantPluginStart; dashboard: DashboardStart; metricsDataAccess: MetricsDataPluginStart; + uiSettings: IUiSettingsClient; } const servicesTitle = i18n.translate('xpack.apm.navigation.servicesTitle', { diff --git a/x-pack/plugins/apm/tsconfig.json b/x-pack/plugins/apm/tsconfig.json index ba23f19f78c4a..83736c390ef83 100644 --- a/x-pack/plugins/apm/tsconfig.json +++ b/x-pack/plugins/apm/tsconfig.json @@ -107,7 +107,8 @@ "@kbn/elastic-agent-utils", "@kbn/shared-ux-link-redirect-app", "@kbn/observability-get-padded-alert-time-range-util", - "@kbn/core-lifecycle-server" + "@kbn/core-lifecycle-server", + "@kbn/core-ui-settings-browser" ], "exclude": ["target/**/*"] } diff --git a/x-pack/plugins/observability/public/components/alert_search_bar/alert_search_bar.test.tsx b/x-pack/plugins/observability/public/components/alert_search_bar/alert_search_bar.test.tsx index 5937fd4f8f7aa..248731d8cab2a 100644 --- a/x-pack/plugins/observability/public/components/alert_search_bar/alert_search_bar.test.tsx +++ b/x-pack/plugins/observability/public/components/alert_search_bar/alert_search_bar.test.tsx @@ -8,6 +8,8 @@ import React from 'react'; import { waitFor } from '@testing-library/react'; import { timefilterServiceMock } from '@kbn/data-plugin/public/query/timefilter/timefilter_service.mock'; +import { uiSettingsServiceMock } from '@kbn/core-ui-settings-browser-mocks'; + import { ObservabilityAlertSearchBarProps, Services } from './types'; import { ObservabilityAlertSearchBar } from './alert_search_bar'; import { observabilityAlertFeatureIds } from '../../../common/constants'; @@ -33,6 +35,7 @@ describe('ObservabilityAlertSearchBar', () => { rangeFrom: 'now-15m', status: 'all', services: { + uiSettings: uiSettingsServiceMock.createStartContract(), timeFilterService: timefilterServiceMock.createStartContract().timefilter, AlertsSearchBar: getAlertsSearchBarMock.mockReturnValue(
diff --git a/x-pack/plugins/observability/public/components/alert_search_bar/alert_search_bar.tsx b/x-pack/plugins/observability/public/components/alert_search_bar/alert_search_bar.tsx index 74dfbe15d77f5..d27e32970f2fa 100644 --- a/x-pack/plugins/observability/public/components/alert_search_bar/alert_search_bar.tsx +++ b/x-pack/plugins/observability/public/components/alert_search_bar/alert_search_bar.tsx @@ -17,7 +17,6 @@ import { ALERT_STATUS_QUERY, DEFAULT_QUERIES, DEFAULT_QUERY_STRING } from './con import { ObservabilityAlertSearchBarProps } from './types'; import { buildEsQuery } from '../../utils/build_es_query'; import { AlertStatus } from '../../../common/typings'; -import { useKibana } from '../../utils/kibana_react'; const getAlertStatusQuery = (status: string): Query[] => { return ALERT_STATUS_QUERY[status] @@ -39,11 +38,10 @@ export function ObservabilityAlertSearchBar({ kuery, rangeFrom, rangeTo, - services: { AlertsSearchBar, timeFilterService, useToasts }, + services: { AlertsSearchBar, timeFilterService, useToasts, uiSettings }, status, }: ObservabilityAlertSearchBarProps) { const toasts = useToasts(); - const { uiSettings } = useKibana().services; const onAlertStatusChange = useCallback( (alertStatus: AlertStatus) => { diff --git a/x-pack/plugins/observability/public/components/alert_search_bar/alert_search_bar_with_url_sync.tsx b/x-pack/plugins/observability/public/components/alert_search_bar/alert_search_bar_with_url_sync.tsx index 91a3453c23ea0..0ce6be6003517 100644 --- a/x-pack/plugins/observability/public/components/alert_search_bar/alert_search_bar_with_url_sync.tsx +++ b/x-pack/plugins/observability/public/components/alert_search_bar/alert_search_bar_with_url_sync.tsx @@ -26,13 +26,14 @@ function AlertSearchbarWithUrlSync(props: AlertSearchBarWithUrlSyncProps) { }, }, triggersActionsUi: { getAlertsSearchBar: AlertsSearchBar }, + uiSettings, } = useKibana().services; return ( ); } diff --git a/x-pack/plugins/observability/public/components/alert_search_bar/types.ts b/x-pack/plugins/observability/public/components/alert_search_bar/types.ts index 426aea00886cf..a527f5deca40c 100644 --- a/x-pack/plugins/observability/public/components/alert_search_bar/types.ts +++ b/x-pack/plugins/observability/public/components/alert_search_bar/types.ts @@ -10,8 +10,8 @@ import { ToastsStart } from '@kbn/core-notifications-browser'; import { TimefilterContract } from '@kbn/data-plugin/public'; import { AlertsSearchBarProps } from '@kbn/triggers-actions-ui-plugin/public/application/sections/alerts_search_bar'; import { BoolQuery, Query } from '@kbn/es-query'; +import type { IUiSettingsClient } from '@kbn/core-ui-settings-browser'; import { AlertStatus } from '../../../common/typings'; - export interface AlertStatusFilterProps { status: AlertStatus; onChange: (id: AlertStatus) => void; @@ -37,6 +37,7 @@ export interface Services { timeFilterService: TimefilterContract; AlertsSearchBar: (props: AlertsSearchBarProps) => ReactElement; useToasts: () => ToastsStart; + uiSettings: IUiSettingsClient; } export interface ObservabilityAlertSearchBarProps diff --git a/x-pack/plugins/observability/public/pages/alerts/alerts.tsx b/x-pack/plugins/observability/public/pages/alerts/alerts.tsx index daf02e9f6fd09..903a76328bdd4 100644 --- a/x-pack/plugins/observability/public/pages/alerts/alerts.tsx +++ b/x-pack/plugins/observability/public/pages/alerts/alerts.tsx @@ -63,6 +63,7 @@ function InternalAlertsPage() { getAlertsStateTable: AlertsStateTable, getAlertSummaryWidget: AlertSummaryWidget, }, + uiSettings, } = kibanaServices; const { ObservabilityPageTemplate } = usePluginContext(); const alertSearchBarStateProps = useAlertSearchBarStateContainer(ALERTS_URL_STORAGE_KEY, { @@ -198,7 +199,7 @@ function InternalAlertsPage() { {...alertSearchBarStateProps} appName={ALERTS_SEARCH_BAR_ID} onEsQueryChange={setEsQuery} - services={{ timeFilterService, AlertsSearchBar, useToasts }} + services={{ timeFilterService, AlertsSearchBar, useToasts, uiSettings }} /> diff --git a/x-pack/plugins/observability/tsconfig.json b/x-pack/plugins/observability/tsconfig.json index cf3402a90c888..ba9ac59725adc 100644 --- a/x-pack/plugins/observability/tsconfig.json +++ b/x-pack/plugins/observability/tsconfig.json @@ -101,7 +101,8 @@ "@kbn/task-manager-plugin", "@kbn/core-elasticsearch-client-server-mocks", "@kbn/ingest-pipelines-plugin", - "@kbn/core-saved-objects-api-server-mocks" + "@kbn/core-saved-objects-api-server-mocks", + "@kbn/core-ui-settings-browser-mocks" ], "exclude": [ "target/**/*"