Skip to content

Commit

Permalink
Fixed all external links (#68614)
Browse files Browse the repository at this point in the history
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
igoristic and elasticmachine authored Jun 12, 2020
1 parent 1225c32 commit b41151a
Show file tree
Hide file tree
Showing 45 changed files with 179 additions and 524 deletions.
12 changes: 0 additions & 12 deletions x-pack/plugins/monitoring/public/angular/app_modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ import { extractIp } from '../lib/extract_ip';
// @ts-ignore
import { PrivateProvider } from './providers/private';
// @ts-ignore
import { KbnUrlProvider } from './providers/url';
// @ts-ignore
import { breadcrumbsProvider } from '../services/breadcrumbs';
// @ts-ignore
import { monitoringClustersProvider } from '../services/clusters';
Expand Down Expand Up @@ -67,7 +65,6 @@ export const localAppModule = ({
createLocalPrivateModule();
createLocalStorage();
createLocalConfigModule(core);
createLocalKbnUrlModule();
createLocalStateModule(query);
createLocalTopNavModule(navigation);
createHrefModule(core);
Expand All @@ -80,7 +77,6 @@ export const localAppModule = ({
...thirdPartyAngularDependencies,
'monitoring/I18n',
'monitoring/Private',
'monitoring/KbnUrl',
'monitoring/Storage',
'monitoring/Config',
'monitoring/State',
Expand Down Expand Up @@ -126,14 +122,6 @@ function createLocalStateModule(query: any) {
});
}

function createLocalKbnUrlModule() {
angular
.module('monitoring/KbnUrl', ['monitoring/Private', 'ngRoute'])
.service('kbnUrl', function (Private: IPrivate) {
return Private(KbnUrlProvider);
});
}

function createMonitoringAppServices() {
angular
.module('monitoring/services', ['monitoring/Private'])
Expand Down
217 changes: 0 additions & 217 deletions x-pack/plugins/monitoring/public/angular/providers/url.js

This file was deleted.

11 changes: 3 additions & 8 deletions x-pack/plugins/monitoring/public/components/alerts/alerts.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const linkToCategories = {
[ALERT_TYPE_LICENSE_EXPIRATION]: 'License expiration',
[ALERT_TYPE_CLUSTER_STATE]: 'Cluster state',
};
const getColumns = (kbnUrl, scope, timezone) => [
const getColumns = (timezone) => [
{
name: i18n.translate('xpack.monitoring.alerts.statusColumnTitle', {
defaultMessage: 'Status',
Expand Down Expand Up @@ -109,11 +109,6 @@ const getColumns = (kbnUrl, scope, timezone) => [
suffix={alert.suffix}
message={message}
metadata={alert.metadata}
changeUrl={(target) => {
scope.$evalAsync(() => {
kbnUrl.changePath(target);
});
}}
/>
);
},
Expand Down Expand Up @@ -155,7 +150,7 @@ const getColumns = (kbnUrl, scope, timezone) => [
},
];

export const Alerts = ({ alerts, angular, sorting, pagination, onTableChange }) => {
export const Alerts = ({ alerts, sorting, pagination, onTableChange }) => {
const alertsFlattened = alerts.map((alert) => ({
...alert,
status: get(alert, 'metadata.severity', get(alert, 'severity', 0)),
Expand All @@ -169,7 +164,7 @@ export const Alerts = ({ alerts, angular, sorting, pagination, onTableChange })
<EuiMonitoringTable
className="alertsTable"
rows={alertsFlattened}
columns={getColumns(angular.kbnUrl, angular.scope, timezone)}
columns={getColumns(timezone)}
sorting={{
...sorting,
sort: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import React from 'react';
import { formatTimestampToDuration } from '../../../common/format_timestamp_to_duration';
import { CALCULATE_DURATION_UNTIL } from '../../../common/constants';
import { EuiLink } from '@elastic/eui';
import { getSafeForExternalLink } from '../../lib/get_safe_for_external_link';

export function FormattedAlert({ prefix, suffix, message, metadata, changeUrl }) {
export function FormattedAlert({ prefix, suffix, message, metadata }) {
const formattedAlert = (() => {
if (metadata && metadata.link) {
if (metadata.link.startsWith('https')) {
Expand All @@ -22,10 +23,8 @@ export function FormattedAlert({ prefix, suffix, message, metadata, changeUrl })
);
}

const goToLink = () => changeUrl(`/${metadata.link}`);

return (
<EuiLink onClick={goToLink} data-test-subj="alertAction">
<EuiLink href={getSafeForExternalLink(`#/${metadata.link}`)} data-test-subj="alertAction">
{message}
</EuiLink>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,12 @@ const getColumns = (
];
};

const changeCluster = (scope, globalState, kbnUrl, clusterUuid, ccs) => {
const changeCluster = (scope, globalState, clusterUuid, ccs) => {
scope.$evalAsync(() => {
globalState.cluster_uuid = clusterUuid;
globalState.ccs = ccs;
globalState.save();
kbnUrl.redirect('/overview');
window.history.replaceState(null, null, '#/overview');
});
};

Expand Down Expand Up @@ -399,12 +399,7 @@ export class Listing extends Component {
render() {
const { angular, clusters, sorting, pagination, onTableChange } = this.props;

const _changeCluster = partial(
changeCluster,
angular.scope,
angular.globalState,
angular.kbnUrl
);
const _changeCluster = partial(changeCluster, angular.scope, angular.globalState);
const _handleClickIncompatibleLicense = partial(handleClickIncompatibleLicense, angular.scope);
const _handleClickInvalidLicense = partial(handleClickInvalidLicense, angular.scope);
const hasStandaloneCluster = !!clusters.find(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import { formatDateTimeLocal } from '../../../../common/formatting';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
import { getSafeForExternalLink } from '../../../lib/get_safe_for_external_link';

import {
EuiFlexGroup,
Expand Down Expand Up @@ -60,15 +61,13 @@ function replaceTokens(alert) {
return text;
}

export function AlertsPanel({ alerts, changeUrl }) {
const goToAlerts = () => changeUrl('/alerts');

export function AlertsPanel({ alerts }) {
if (!alerts || !alerts.length) {
// no-op
return null;
}

// enclosed component for accessing changeUrl
// enclosed component for accessing
function TopAlertItem({ item, index }) {
const severityIcon = mapSeverity(item.metadata.severity);

Expand Down Expand Up @@ -101,7 +100,6 @@ export function AlertsPanel({ alerts, changeUrl }) {
suffix={item.suffix}
message={item.message}
metadata={item.metadata}
changeUrl={changeUrl}
/>
<EuiText size="xs">
<EuiSpacer size="m" />
Expand Down Expand Up @@ -183,7 +181,11 @@ export function AlertsPanel({ alerts, changeUrl }) {
</EuiTitle>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton size="s" onClick={goToAlerts} data-test-subj="viewAllAlerts">
<EuiButton
size="s"
href={getSafeForExternalLink('#/alerts')}
data-test-subj="viewAllAlerts"
>
<FormattedMessage
id="xpack.monitoring.cluster.overview.alertsPanel.viewAllButtonLabel"
defaultMessage="View all alerts"
Expand Down
Loading

0 comments on commit b41151a

Please sign in to comment.