2021-12-14 09:36:54 -06:00
|
|
|
import { useEffect } from 'react';
|
2022-04-22 08:33:13 -05:00
|
|
|
|
2022-09-19 04:49:35 -05:00
|
|
|
import { useDispatch } from 'app/types';
|
2022-04-22 08:33:13 -05:00
|
|
|
import { StateHistoryItem } from 'app/types/unified-alerting';
|
|
|
|
|
2021-12-14 09:36:54 -06:00
|
|
|
import { fetchGrafanaAnnotationsAction } from '../state/actions';
|
|
|
|
import { AsyncRequestState } from '../utils/redux';
|
2022-04-22 08:33:13 -05:00
|
|
|
|
2021-12-14 09:36:54 -06:00
|
|
|
import { useUnifiedAlertingSelector } from './useUnifiedAlertingSelector';
|
|
|
|
|
|
|
|
export function useManagedAlertStateHistory(alertId: string) {
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
const history = useUnifiedAlertingSelector<AsyncRequestState<StateHistoryItem[]>>(
|
|
|
|
(state) => state.managedAlertStateHistory
|
|
|
|
);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
dispatch(fetchGrafanaAnnotationsAction(alertId));
|
|
|
|
}, [dispatch, alertId]);
|
|
|
|
|
|
|
|
return history;
|
|
|
|
}
|