Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCPBUGS-45987: Fix alert rule link to alert in dev perspective #14608

Open
wants to merge 1 commit into
base: release-4.18
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import * as _ from 'lodash';
import { Dispatch } from 'redux';
import { PrometheusRulesResponse } from '@console/dynamic-plugin-sdk';
import { PrometheusRulesResponse, useActivePerspective } from '@console/dynamic-plugin-sdk';
import {
alertingErrored,
alertingLoaded,
Expand All @@ -26,6 +26,8 @@ export const useRulesAlertsPoller = (
getAlertingRules: (namespace?: string) => Promise<PrometheusRulesResponse>;
}[],
) => {
const [perspective] = useActivePerspective();

React.useEffect(() => {
const url = getPrometheusURL({
endpoint: PrometheusEndpoint.RULES,
Expand All @@ -36,7 +38,10 @@ export const useRulesAlertsPoller = (
const poller = (): void => {
fetchAlerts(url, alertsSource, namespace)
.then(({ data }) => {
const { alerts: fetchedAlerts, rules: fetchedRules } = getAlertsAndRules(data);
const { alerts: fetchedAlerts, rules: fetchedRules } = getAlertsAndRules(
data,
perspective,
);
const sortThanosRules = _.sortBy(fetchedRules, alertingRuleStateOrder);
dispatch(alertingSetRules('devRules', sortThanosRules, 'dev'));
dispatch(alertingLoaded('devAlerts', fetchedAlerts, 'dev'));
Expand All @@ -57,5 +62,5 @@ export const useRulesAlertsPoller = (
clearTimeout(pollerTimeout);
}
};
}, [namespace, alertsSource, dispatch]);
}, [namespace, alertsSource, dispatch, perspective]);
};