Skip to content

Commit

Permalink
Merge pull request #6263 from abhinandan13jan/monitoring-links
Browse files Browse the repository at this point in the history
Bug 1868013: Point admin monitoring links to admin
  • Loading branch information
openshift-merge-robot committed Aug 22, 2020
2 parents 94ec863 + cfd1d17 commit 11fe709
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import * as React from 'react';
import { connect } from 'react-redux';
import * as _ from 'lodash';
import { Alert } from '@patternfly/react-core';
import { Link } from 'react-router-dom';
import { getActivePerspective } from '@console/internal/reducers/ui';
import { RootState } from '@console/internal/redux';
import { fromNow } from '@console/internal/components/utils/datetime';
import { Alert as AlertType } from '@console/internal/components/monitoring/types';
import { labelsToParams } from '@console/internal/components/monitoring/utils';
Expand All @@ -13,7 +16,14 @@ interface MonitoringOverviewAlertsProps {
alerts: AlertType[];
}

const MonitoringOverviewAlerts: React.FC<MonitoringOverviewAlertsProps> = ({ alerts }) => {
interface StateProps {
activePerspective?: string;
}

const MonitoringOverviewAlerts: React.FC<MonitoringOverviewAlertsProps & StateProps> = ({
alerts,
activePerspective,
}) => {
const sortedAlerts = sortMonitoringAlerts(alerts);

return (
Expand All @@ -25,9 +35,10 @@ const MonitoringOverviewAlerts: React.FC<MonitoringOverviewAlertsProps> = ({ ale
labels: { severity, alertname, namespace },
rule: { name, id },
} = alert;
const alertDetailsPageLink = `/dev-monitoring/ns/${namespace}/alerts/${id}?${labelsToParams(
alert.labels,
)}`;
const alertDetailsPageLink =
activePerspective === 'admin'
? `/monitoring/alerts/${id}?${labelsToParams(alert.labels)}`
: `/dev-monitoring/ns/${namespace}/alerts/${id}?${labelsToParams(alert.labels)}`;
return (
<Alert
variant={getAlertType(severity)}
Expand All @@ -46,4 +57,9 @@ const MonitoringOverviewAlerts: React.FC<MonitoringOverviewAlertsProps> = ({ ale
);
};

export default MonitoringOverviewAlerts;
const stateToProps = (state: RootState) => ({
activePerspective: getActivePerspective(state),
});

export const InternalMonitoringOverviewAlerts = MonitoringOverviewAlerts;
export default connect<StateProps>(stateToProps)(MonitoringOverviewAlerts);
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
expectedSortedAlerts,
} from '@console/shared/src/utils/__mocks__/alerts-and-rules-data';
import { sortMonitoringAlerts } from '@console/shared';
import MonitoringOverviewAlerts from '../MonitoringOverviewAlerts';
import { InternalMonitoringOverviewAlerts as MonitoringOverviewAlerts } from '../MonitoringOverviewAlerts';

describe('Monitoring Alerts Section', () => {
const monitoringOverviewProps: React.ComponentProps<typeof MonitoringOverviewAlerts> = {
Expand Down

0 comments on commit 11fe709

Please sign in to comment.