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

Bug 1868013: Point admin monitoring links to admin #6263

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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