+
setIsPopoverOpen(!isPopoverOpen)}
+ />
+ }
+ closePopover={() => setIsPopoverOpen(false)}
+ >
+ Actions
+
+
+
+
+
+
+
+ {i18n.translate('xpack.observability.alertsTable.viewInAppButtonLabel', {
+ defaultMessage: 'View in app',
+ })}
+
+
+
+
+
+
+ );
+}
diff --git a/x-pack/plugins/observability/public/pages/alerts/index.tsx b/x-pack/plugins/observability/public/pages/alerts/index.tsx
index 6f696a70665ce..fed9ee0be3a4a 100644
--- a/x-pack/plugins/observability/public/pages/alerts/index.tsx
+++ b/x-pack/plugins/observability/public/pages/alerts/index.tsx
@@ -7,21 +7,20 @@
import { EuiButton, EuiCallOut, EuiFlexGroup, EuiFlexItem, EuiLink, EuiSpacer } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
-import React from 'react';
+import React, { useCallback, useMemo, useRef } from 'react';
import { useHistory } from 'react-router-dom';
import { ParsedTechnicalFields } from '../../../../rule_registry/common/parse_technical_fields';
import type { AlertStatus } from '../../../common/typings';
import { ExperimentalBadge } from '../../components/shared/experimental_badge';
import { useBreadcrumbs } from '../../hooks/use_breadcrumbs';
-import { useFetcher } from '../../hooks/use_fetcher';
import { usePluginContext } from '../../hooks/use_plugin_context';
import { RouteParams } from '../../routes';
-import { callObservabilityApi } from '../../services/call_observability_api';
import type { ObservabilityAPIReturnType } from '../../services/call_observability_api/types';
-import { getAbsoluteDateRange } from '../../utils/date';
import { AlertsSearchBar } from './alerts_search_bar';
-import { AlertsTable } from './alerts_table';
+import { AlertsTableTGrid } from './alerts_table_t_grid';
import { StatusFilter } from './status_filter';
+import { useFetcher } from '../../hooks/use_fetcher';
+import { callObservabilityApi } from '../../services/call_observability_api';
export type TopAlertResponse = ObservabilityAPIReturnType<'GET /api/observability/rules/alerts/top'>[number];
@@ -41,6 +40,7 @@ export function AlertsPage({ routeParams }: AlertsPageProps) {
const { core, ObservabilityPageTemplate } = usePluginContext();
const { prepend } = core.http.basePath;
const history = useHistory();
+ const refetch = useRef<() => void>();
const {
query: { rangeFrom = 'now-15m', rangeTo = 'now', kuery = '', status = 'open' },
} = routeParams;
@@ -59,37 +59,52 @@ export function AlertsPage({ routeParams }: AlertsPageProps) {
'/app/management/insightsAndAlerting/triggersActions/alerts'
);
- const { data: alerts } = useFetcher(
- ({ signal }) => {
- const { start, end } = getAbsoluteDateRange({ rangeFrom, rangeTo });
+ const { data: dynamicIndexPatternResp } = useFetcher(({ signal }) => {
+ return callObservabilityApi({
+ signal,
+ endpoint: 'GET /api/observability/rules/alerts/dynamic_index_pattern',
+ });
+ }, []);
+
+ const dynamicIndexPattern = useMemo(
+ () => (dynamicIndexPatternResp ? [dynamicIndexPatternResp] : []),
+ [dynamicIndexPatternResp]
+ );
+
+ const setStatusFilter = useCallback(
+ (value: AlertStatus) => {
+ const nextSearchParams = new URLSearchParams(history.location.search);
+ nextSearchParams.set('status', value);
+ history.push({
+ ...history.location,
+ search: nextSearchParams.toString(),
+ });
+ },
+ [history]
+ );
- if (!start || !end) {
- return;
+ const onQueryChange = useCallback(
+ ({ dateRange, query }) => {
+ if (rangeFrom === dateRange.from && rangeTo === dateRange.to && kuery === (query ?? '')) {
+ return refetch.current && refetch.current();
}
- return callObservabilityApi({
- signal,
- endpoint: 'GET /api/observability/rules/alerts/top',
- params: {
- query: {
- start,
- end,
- kuery,
- status,
- },
- },
+ const nextSearchParams = new URLSearchParams(history.location.search);
+
+ nextSearchParams.set('rangeFrom', dateRange.from);
+ nextSearchParams.set('rangeTo', dateRange.to);
+ nextSearchParams.set('kuery', query ?? '');
+
+ history.push({
+ ...history.location,
+ search: nextSearchParams.toString(),
});
},
- [kuery, rangeFrom, rangeTo, status]
+ [history, rangeFrom, rangeTo, kuery]
);
- function setStatusFilter(value: AlertStatus) {
- const nextSearchParams = new URLSearchParams(history.location.search);
- nextSearchParams.set('status', value);
- history.push({
- ...history.location,
- search: nextSearchParams.toString(),
- });
- }
+ const setRefetch = useCallback((ref) => {
+ refetch.current = ref;
+ }, []);
return (