Alerting: Fix silencing from policy instances (#90417)

Fix silencing from policy instances
This commit is contained in:
Sonia Aguilar 2024-07-15 11:27:46 +02:00 committed by GitHub
parent aabb4286e3
commit 73336362a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 8 deletions

View File

@ -200,7 +200,7 @@ const AmRoutes = () => {
updatingTree
);
const [deleteModal, openDeleteModal, closeDeleteModal] = useDeletePolicyModal(handleDelete, updatingTree);
const [alertInstancesModal, showAlertGroupsModal] = useAlertGroupsModal();
const [alertInstancesModal, showAlertGroupsModal] = useAlertGroupsModal(selectedAlertmanager ?? '');
useCleanup((state) => (state.unifiedAlerting.saveAMConfig = initialAsyncRequestState));

View File

@ -212,11 +212,9 @@ const useDeletePolicyModal = (handleDelete: (route: RouteWithID) => void, loadin
return [modalElement, handleShow, handleDismiss];
};
const useAlertGroupsModal = (): [
JSX.Element,
(alertGroups: AlertmanagerGroup[], matchers?: ObjectMatcher[]) => void,
() => void,
] => {
const useAlertGroupsModal = (
alertManagerSourceName: string
): [JSX.Element, (alertGroups: AlertmanagerGroup[], matchers?: ObjectMatcher[]) => void, () => void] => {
const [showModal, setShowModal] = useState(false);
const [alertGroups, setAlertGroups] = useState<AlertmanagerGroup[]>([]);
const [matchers, setMatchers] = useState<ObjectMatcher[]>([]);
@ -271,7 +269,7 @@ const useAlertGroupsModal = (): [
/>
<div>
{alertGroups.map((group, index) => (
<AlertGroup key={index} alertManagerSourceName={''} group={group} />
<AlertGroup key={index} alertManagerSourceName={alertManagerSourceName} group={group} />
))}
</div>
</Stack>
@ -282,7 +280,7 @@ const useAlertGroupsModal = (): [
</Modal.ButtonRow>
</Modal>
),
[alertGroups, handleDismiss, instancesByState, matchers, formatter, showModal]
[alertGroups, handleDismiss, instancesByState, matchers, formatter, showModal, alertManagerSourceName]
);
return [modalElement, handleShow, handleDismiss];