mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[RAC] Remove alerts from the table if user changes their workflow status (#110227)
This commit is contained in:
parent
891c277d05
commit
754bf980f3
1 changed files with 21 additions and 3 deletions
|
@ -38,7 +38,8 @@ import {
|
|||
} from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import styled from 'styled-components';
|
||||
import React, { Suspense, useMemo, useState, useCallback } from 'react';
|
||||
import React, { Suspense, useMemo, useState, useCallback, useEffect } from 'react';
|
||||
import usePrevious from 'react-use/lib/usePrevious';
|
||||
import { get } from 'lodash';
|
||||
import {
|
||||
getAlertsPermissions,
|
||||
|
@ -286,6 +287,7 @@ function ObservabilityActions({
|
|||
|
||||
export function AlertsTableTGrid(props: AlertsTableTGridProps) {
|
||||
const { indexNames, rangeFrom, rangeTo, kuery, workflowStatus, setRefetch, addToQuery } = props;
|
||||
const prevWorkflowStatus = usePrevious(workflowStatus);
|
||||
const {
|
||||
timelines,
|
||||
application: { capabilities },
|
||||
|
@ -302,6 +304,20 @@ export function AlertsTableTGrid(props: AlertsTableTGridProps) {
|
|||
[capabilities]
|
||||
);
|
||||
|
||||
const [deletedEventIds, setDeletedEventIds] = useState<string[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
if (workflowStatus !== prevWorkflowStatus) {
|
||||
setDeletedEventIds([]);
|
||||
}
|
||||
}, [workflowStatus, prevWorkflowStatus]);
|
||||
|
||||
const setEventsDeleted = useCallback<ObservabilityActionsProps['setEventsDeleted']>((action) => {
|
||||
if (action.isDeleted) {
|
||||
setDeletedEventIds((ids) => [...ids, ...action.eventIds]);
|
||||
}
|
||||
}, []);
|
||||
|
||||
const leadingControlColumns = useMemo(() => {
|
||||
return [
|
||||
{
|
||||
|
@ -320,6 +336,7 @@ export function AlertsTableTGrid(props: AlertsTableTGridProps) {
|
|||
return (
|
||||
<ObservabilityActions
|
||||
{...actionProps}
|
||||
setEventsDeleted={setEventsDeleted}
|
||||
currentStatus={workflowStatus}
|
||||
setFlyoutAlert={setFlyoutAlert}
|
||||
/>
|
||||
|
@ -327,7 +344,7 @@ export function AlertsTableTGrid(props: AlertsTableTGridProps) {
|
|||
},
|
||||
},
|
||||
];
|
||||
}, [workflowStatus]);
|
||||
}, [workflowStatus, setEventsDeleted]);
|
||||
|
||||
const tGridProps = useMemo(() => {
|
||||
const type: TGridType = 'standalone';
|
||||
|
@ -337,7 +354,7 @@ export function AlertsTableTGrid(props: AlertsTableTGridProps) {
|
|||
casePermissions,
|
||||
type,
|
||||
columns,
|
||||
deletedEventIds: [],
|
||||
deletedEventIds,
|
||||
defaultCellActions: getDefaultCellActions({ addToQuery }),
|
||||
end: rangeTo,
|
||||
filters: [],
|
||||
|
@ -385,6 +402,7 @@ export function AlertsTableTGrid(props: AlertsTableTGridProps) {
|
|||
rangeFrom,
|
||||
setRefetch,
|
||||
leadingControlColumns,
|
||||
deletedEventIds,
|
||||
]);
|
||||
const handleFlyoutClose = () => setFlyoutAlert(undefined);
|
||||
const { observabilityRuleTypeRegistry } = usePluginContext();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue