From 17b13f5e1abaedf1d170577235989807dd4e3b4d Mon Sep 17 00:00:00 2001 From: igoristic Date: Fri, 12 Jun 2020 17:43:02 -0400 Subject: [PATCH] Fixed all external links (#68614) Co-authored-by: Elastic Machine # Conflicts: # x-pack/plugins/monitoring/public/components/logstash/pipeline_listing/pipeline_listing.js --- .../monitoring/public/angular/app_modules.ts | 12 - .../public/angular/providers/url.js | 217 ------------------ .../public/components/alerts/alerts.js | 11 +- .../components/alerts/formatted_alert.js | 7 +- .../components/cluster/listing/listing.js | 11 +- .../cluster/overview/alerts_panel.js | 14 +- .../components/cluster/overview/apm_panel.js | 11 +- .../cluster/overview/beats_panel.js | 10 +- .../cluster/overview/elasticsearch_panel.js | 16 +- .../components/cluster/overview/index.js | 23 +- .../cluster/overview/kibana_panel.js | 11 +- .../cluster/overview/logstash_panel.js | 15 +- .../components/elasticsearch/index/index.js | 13 +- .../components/elasticsearch/node/node.js | 13 +- .../shard_allocation/components/assigned.js | 18 +- .../components/cluster_view.js | 6 - .../shard_allocation/components/table_body.js | 15 +- .../lib/generate_query_and_link.js | 15 -- .../shard_allocation/shard_allocation.js | 3 +- .../components/kibana/instances/instances.js | 4 +- .../components/logstash/listing/listing.js | 10 +- .../logstash/listing/listing.test.js | 8 - .../pipeline_listing/pipeline_listing.js | 11 +- .../public/components/no_data/no_data.js | 4 +- .../__snapshots__/tooltip.test.js.snap | 50 ++-- .../public/components/setup_mode/tooltip.js | 12 +- .../components/setup_mode/tooltip.test.js | 6 +- .../elasticsearch/ml_job_listing/index.js | 15 +- .../public/directives/main/index.js | 7 +- .../plugins/monitoring/public/legacy_shims.ts | 37 ++- .../public/lib/ajax_error_handler.tsx | 6 +- .../monitoring/public/lib/route_init.js | 11 +- x-pack/plugins/monitoring/public/url_state.ts | 10 +- .../public/views/access_denied/index.js | 11 +- .../monitoring/public/views/alerts/index.js | 2 - .../public/views/beats/listing/index.js | 5 - .../public/views/cluster/listing/index.js | 8 +- .../public/views/cluster/overview/index.js | 8 - .../public/views/elasticsearch/index/index.js | 2 - .../public/views/elasticsearch/node/index.js | 2 - .../public/views/kibana/instances/index.js | 6 - .../views/logstash/node/pipelines/index.js | 5 - .../public/views/logstash/nodes/index.js | 3 - .../public/views/logstash/pipelines/index.js | 5 - .../public/views/no_data/controller.js | 14 +- 45 files changed, 179 insertions(+), 524 deletions(-) delete mode 100644 x-pack/plugins/monitoring/public/angular/providers/url.js delete mode 100644 x-pack/plugins/monitoring/public/components/elasticsearch/shard_allocation/lib/generate_query_and_link.js diff --git a/x-pack/plugins/monitoring/public/angular/app_modules.ts b/x-pack/plugins/monitoring/public/angular/app_modules.ts index 96b122801085fd..726d4be4924d77 100644 --- a/x-pack/plugins/monitoring/public/angular/app_modules.ts +++ b/x-pack/plugins/monitoring/public/angular/app_modules.ts @@ -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'; @@ -67,7 +65,6 @@ export const localAppModule = ({ createLocalPrivateModule(); createLocalStorage(); createLocalConfigModule(core); - createLocalKbnUrlModule(); createLocalStateModule(query); createLocalTopNavModule(navigation); createHrefModule(core); @@ -80,7 +77,6 @@ export const localAppModule = ({ ...thirdPartyAngularDependencies, 'monitoring/I18n', 'monitoring/Private', - 'monitoring/KbnUrl', 'monitoring/Storage', 'monitoring/Config', 'monitoring/State', @@ -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']) diff --git a/x-pack/plugins/monitoring/public/angular/providers/url.js b/x-pack/plugins/monitoring/public/angular/providers/url.js deleted file mode 100644 index 0c984a71c9f2c2..00000000000000 --- a/x-pack/plugins/monitoring/public/angular/providers/url.js +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import _ from 'lodash'; - -export function KbnUrlProvider($injector, $location, $rootScope, $parse) { - /** - * the `kbnUrl` service was created to smooth over some of the - * inconsistent behavior that occurs when modifying the url via - * the `$location` api. In general it is recommended that you use - * the `kbnUrl` service any time you want to modify the url. - * - * "features" that `kbnUrl` does it's best to guarantee, which - * are not guaranteed with the `$location` service: - * - calling `kbnUrl.change()` with a url that resolves to the current - * route will force a full transition (rather than just updating the - * properties of the $route object) - * - * Additional features of `kbnUrl` - * - parameterized urls - * - easily include an app state with the url - * - * @type {KbnUrl} - */ - const self = this; - - /** - * Navigate to a url - * - * @param {String} url - the new url, can be a template. See #eval - * @param {Object} [paramObj] - optional set of parameters for the url template - * @return {undefined} - */ - self.change = function (url, paramObj, appState) { - self._changeLocation('url', url, paramObj, false, appState); - }; - - /** - * Same as #change except only changes the url's path, - * leaving the search string and such intact - * - * @param {String} path - the new path, can be a template. See #eval - * @param {Object} [paramObj] - optional set of parameters for the path template - * @return {undefined} - */ - self.changePath = function (path, paramObj) { - self._changeLocation('path', path, paramObj); - }; - - /** - * Same as #change except that it removes the current url from history - * - * @param {String} url - the new url, can be a template. See #eval - * @param {Object} [paramObj] - optional set of parameters for the url template - * @return {undefined} - */ - self.redirect = function (url, paramObj, appState) { - self._changeLocation('url', url, paramObj, true, appState); - }; - - /** - * Same as #redirect except only changes the url's path, - * leaving the search string and such intact - * - * @param {String} path - the new path, can be a template. See #eval - * @param {Object} [paramObj] - optional set of parameters for the path template - * @return {undefined} - */ - self.redirectPath = function (path, paramObj) { - self._changeLocation('path', path, paramObj, true); - }; - - /** - * Evaluate a url template. templates can contain double-curly wrapped - * expressions that are evaluated in the context of the paramObj - * - * @param {String} template - the url template to evaluate - * @param {Object} [paramObj] - the variables to expose to the template - * @return {String} - the evaluated result - * @throws {Error} If any of the expressions can't be parsed. - */ - self.eval = function (template, paramObj) { - paramObj = paramObj || {}; - - return template.replace(/\{\{([^\}]+)\}\}/g, function (match, expr) { - // remove filters - const key = expr.split('|')[0].trim(); - - // verify that the expression can be evaluated - const p = $parse(key)(paramObj); - - // if evaluation can't be made, throw - if (_.isUndefined(p)) { - throw new Error(`Replacement failed, unresolved expression: ${expr}`); - } - - return encodeURIComponent($parse(expr)(paramObj)); - }); - }; - - /** - * convert an object's route to an href, compatible with - * window.location.href= and - * - * @param {Object} obj - any object that list's it's routes at obj.routes{} - * @param {string} route - the route name - * @return {string} - the computed href - */ - self.getRouteHref = function (obj, route) { - return '#' + self.getRouteUrl(obj, route); - }; - - /** - * convert an object's route to a url, compatible with url.change() or $location.url() - * - * @param {Object} obj - any object that list's it's routes at obj.routes{} - * @param {string} route - the route name - * @return {string} - the computed url - */ - self.getRouteUrl = function (obj, route) { - const template = obj && obj.routes && obj.routes[route]; - if (template) return self.eval(template, obj); - }; - - /** - * Similar to getRouteUrl, supports objects which list their routes, - * and redirects to the named route. See #redirect - * - * @param {Object} obj - any object that list's it's routes at obj.routes{} - * @param {string} route - the route name - * @return {undefined} - */ - self.redirectToRoute = function (obj, route) { - self.redirect(self.getRouteUrl(obj, route)); - }; - - /** - * Similar to getRouteUrl, supports objects which list their routes, - * and changes the url to the named route. See #change - * - * @param {Object} obj - any object that list's it's routes at obj.routes{} - * @param {string} route - the route name - * @return {undefined} - */ - self.changeToRoute = function (obj, route) { - self.change(self.getRouteUrl(obj, route)); - }; - - /** - * Removes the given parameter from the url. Does so without modifying the browser - * history. - * @param param - */ - self.removeParam = function (param) { - $location.search(param, null).replace(); - }; - - ///// - // private api - ///// - let reloading; - - self._changeLocation = function (type, url, paramObj, replace, appState) { - const prev = { - path: $location.path(), - search: $location.search(), - }; - - url = self.eval(url, paramObj); - $location[type](url); - if (replace) $location.replace(); - - if (appState) { - $location.search(appState.getQueryParamName(), appState.toQueryParam()); - } - - const next = { - path: $location.path(), - search: $location.search(), - }; - - if ($injector.has('$route')) { - const $route = $injector.get('$route'); - - if (self._shouldForceReload(next, prev, $route)) { - reloading = $rootScope.$on('$locationChangeSuccess', function () { - // call the "unlisten" function returned by $on - reloading(); - reloading = false; - - $route.reload(); - }); - } - } - }; - - // determine if the router will automatically reload the route - self._shouldForceReload = function (next, prev, $route) { - if (reloading) return false; - - const route = $route.current && $route.current.$$route; - if (!route) return false; - - // for the purposes of determining whether the router will - // automatically be reloading, '' and '/' are equal - const nextPath = next.path || '/'; - const prevPath = prev.path || '/'; - if (nextPath !== prevPath) return false; - - const reloadOnSearch = route.reloadOnSearch; - const searchSame = _.isEqual(next.search, prev.search); - return (reloadOnSearch && searchSame) || !reloadOnSearch; - }; -} diff --git a/x-pack/plugins/monitoring/public/components/alerts/alerts.js b/x-pack/plugins/monitoring/public/components/alerts/alerts.js index 0ac67228db359b..b3fc70e9ffd7d1 100644 --- a/x-pack/plugins/monitoring/public/components/alerts/alerts.js +++ b/x-pack/plugins/monitoring/public/components/alerts/alerts.js @@ -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', @@ -109,11 +109,6 @@ const getColumns = (kbnUrl, scope, timezone) => [ suffix={alert.suffix} message={message} metadata={alert.metadata} - changeUrl={(target) => { - scope.$evalAsync(() => { - kbnUrl.changePath(target); - }); - }} /> ); }, @@ -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)), @@ -169,7 +164,7 @@ export const Alerts = ({ alerts, angular, sorting, pagination, onTableChange }) { if (metadata && metadata.link) { if (metadata.link.startsWith('https')) { @@ -22,10 +23,8 @@ export function FormattedAlert({ prefix, suffix, message, metadata, changeUrl }) ); } - const goToLink = () => changeUrl(`/${metadata.link}`); - return ( - + {message} ); diff --git a/x-pack/plugins/monitoring/public/components/cluster/listing/listing.js b/x-pack/plugins/monitoring/public/components/cluster/listing/listing.js index 402ae77d59b2e7..bc490bc902a987 100644 --- a/x-pack/plugins/monitoring/public/components/cluster/listing/listing.js +++ b/x-pack/plugins/monitoring/public/components/cluster/listing/listing.js @@ -230,12 +230,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'); }); }; @@ -398,12 +398,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( diff --git a/x-pack/plugins/monitoring/public/components/cluster/overview/alerts_panel.js b/x-pack/plugins/monitoring/public/components/cluster/overview/alerts_panel.js index ff311281b1247b..2470b070317be8 100644 --- a/x-pack/plugins/monitoring/public/components/cluster/overview/alerts_panel.js +++ b/x-pack/plugins/monitoring/public/components/cluster/overview/alerts_panel.js @@ -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, @@ -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); @@ -101,7 +100,6 @@ export function AlertsPanel({ alerts, changeUrl }) { suffix={item.suffix} message={item.message} metadata={item.metadata} - changeUrl={changeUrl} />

@@ -181,7 +179,11 @@ export function AlertsPanel({ alerts, changeUrl }) { - + props.changeUrl('apm'); - const goToInstances = () => props.changeUrl('apm/instances'); - + const goToInstances = () => getSafeForExternalLink('#/apm/instances'); const setupModeData = get(setupMode.data, 'apm'); const setupModeTooltip = setupMode && setupMode.enabled ? ( ) : null; @@ -64,7 +63,7 @@ export function ApmPanel(props) {

props.changeUrl('beats'); - const goToInstances = () => props.changeUrl('beats/beats'); - const setupModeData = get(setupMode.data, 'beats'); const setupModeTooltip = setupMode && setupMode.enabled ? ( ) : null; @@ -77,7 +75,7 @@ export function BeatsPanel(props) {

props.changeUrl('elasticsearch'); - const goToNodes = () => props.changeUrl('elasticsearch/nodes'); - const goToIndices = () => props.changeUrl('elasticsearch/indices'); + const goToElasticsearch = () => getSafeForExternalLink('#/elasticsearch'); + const goToNodes = () => getSafeForExternalLink('#/elasticsearch/nodes'); + const goToIndices = () => getSafeForExternalLink('#/elasticsearch/indices'); const { primaries, replicas } = calculateShards(get(props, 'cluster_stats.indices.shards', {})); @@ -162,7 +162,7 @@ export function ElasticsearchPanel(props) { ) : null; @@ -215,7 +215,7 @@ export function ElasticsearchPanel(props) {

- + {kibanaAlerts} - + {!isFromStandaloneCluster ? ( @@ -38,32 +38,19 @@ export function Overview(props) { {...props.cluster.elasticsearch} version={props.cluster.version} ml={props.cluster.ml} - changeUrl={props.changeUrl} license={props.cluster.license} setupMode={props.setupMode} showLicenseExpiration={props.showLicenseExpiration} /> - + ) : null} - + - + - + ); diff --git a/x-pack/plugins/monitoring/public/components/cluster/overview/kibana_panel.js b/x-pack/plugins/monitoring/public/components/cluster/overview/kibana_panel.js index 541c240b3c35aa..8bf2bc472b8fdc 100644 --- a/x-pack/plugins/monitoring/public/components/cluster/overview/kibana_panel.js +++ b/x-pack/plugins/monitoring/public/components/cluster/overview/kibana_panel.js @@ -29,6 +29,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; import { SetupModeTooltip } from '../../setup_mode/tooltip'; import { KIBANA_SYSTEM_ID } from '../../../../common/constants'; +import { getSafeForExternalLink } from '../../../lib/get_safe_for_external_link'; export function KibanaPanel(props) { const setupMode = props.setupMode; @@ -40,8 +41,8 @@ export function KibanaPanel(props) { const statusIndicator = ; - const goToKibana = () => props.changeUrl('kibana'); - const goToInstances = () => props.changeUrl('kibana/instances'); + const goToKibana = () => getSafeForExternalLink('#/kibana'); + const goToInstances = () => getSafeForExternalLink('#/kibana/instances'); const setupModeData = get(setupMode.data, 'kibana'); const setupModeTooltip = @@ -49,7 +50,7 @@ export function KibanaPanel(props) { ) : null; @@ -70,7 +71,7 @@ export function KibanaPanel(props) {

props.changeUrl('logstash'); - const goToNodes = () => props.changeUrl('logstash/nodes'); - const goToPipelines = () => props.changeUrl('logstash/pipelines'); + const goToLogstash = () => getSafeForExternalLink('#/logstash'); + const goToNodes = () => getSafeForExternalLink('#/logstash/nodes'); + const goToPipelines = () => getSafeForExternalLink('#/logstash/pipelines'); const setupModeData = get(setupMode.data, 'logstash'); const setupModeTooltip = @@ -51,7 +52,7 @@ export function LogstashPanel(props) { ) : null; @@ -71,7 +72,7 @@ export function LogstashPanel(props) {

{ +export const Index = ({ scope, indexSummary, metrics, clusterUuid, indexUuid, logs, ...props }) => { const metricsToShow = [ metrics.index_mem, metrics.index_size, @@ -59,7 +50,7 @@ export const Index = ({ - + diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/node/node.js b/x-pack/plugins/monitoring/public/components/elasticsearch/node/node.js index b585de23c62541..95410337ceffe9 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/node/node.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/node/node.js @@ -19,16 +19,7 @@ import { Logs } from '../../logs/'; import { MonitoringTimeseriesContainer } from '../../chart'; import { ShardAllocation } from '../shard_allocation/shard_allocation'; -export const Node = ({ - nodeSummary, - metrics, - logs, - nodeId, - clusterUuid, - scope, - kbnUrl, - ...props -}) => { +export const Node = ({ nodeSummary, metrics, logs, nodeId, clusterUuid, scope, ...props }) => { const metricsToShow = [ metrics.node_jvm_mem, metrics.node_mem, @@ -62,7 +53,7 @@ export const Node = ({ - + diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/shard_allocation/components/assigned.js b/x-pack/plugins/monitoring/public/components/elasticsearch/shard_allocation/components/assigned.js index 96de9202848cb0..5d6366fb555c54 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/shard_allocation/components/assigned.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/shard_allocation/components/assigned.js @@ -8,8 +8,18 @@ import { get, sortBy } from 'lodash'; import React from 'react'; import { Shard } from './shard'; import { calculateClass } from '../lib/calculate_class'; -import { generateQueryAndLink } from '../lib/generate_query_and_link'; import { EuiFlexGroup, EuiFlexItem, EuiIcon, EuiKeyboardAccessible } from '@elastic/eui'; +import { getSafeForExternalLink } from '../../../../lib/get_safe_for_external_link'; + +const generateQueryAndLink = (data) => { + let type = 'indices'; + let ident = data.name; + if (data.type === 'node') { + type = 'nodes'; + ident = data.id; + } + return getSafeForExternalLink(`#/elasticsearch/${type}/${ident}`); +}; function sortByName(item) { if (item.type === 'node') { @@ -40,17 +50,13 @@ export class Assigned extends React.Component { } } - const changeUrl = () => { - this.props.changeUrl(generateQueryAndLink(data)); - }; - // TODO: redesign for shard allocation, possibly giving shard display the // ability to use the euiLink CSS class (blue link text instead of white link text) // Disabling eslint because EuiKeyboardAccessible does it for us /* eslint-disable jsx-a11y/click-events-have-key-events */ const name = ( - + {data.name} diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/shard_allocation/components/cluster_view.js b/x-pack/plugins/monitoring/public/components/elasticsearch/shard_allocation/components/cluster_view.js index ccd5c266bcfd51..23bf87e19df73e 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/shard_allocation/components/cluster_view.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/shard_allocation/components/cluster_view.js @@ -19,8 +19,6 @@ export class ClusterView extends React.Component { constructor(props) { super(props); - const scope = props.scope; - const kbnChangePath = props.kbnUrl.changePath; this.state = { labels: props.scope.labels || [], @@ -28,9 +26,6 @@ export class ClusterView extends React.Component { shardStats: props.scope.pageData.shardStats, showSystemIndices: props.showSystemIndices, toggleShowSystemIndices: props.toggleShowSystemIndices, - angularChangeUrl: (url) => { - scope.$evalAsync(() => kbnChangePath(url)); - }, }; } @@ -71,7 +66,6 @@ export class ClusterView extends React.Component { rows={this.state.showing} cols={this.state.labels.length} shardStats={this.state.shardStats} - changeUrl={this.state.angularChangeUrl} /> ); diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/shard_allocation/components/table_body.js b/x-pack/plugins/monitoring/public/components/elasticsearch/shard_allocation/components/table_body.js index d2df988ed28939..378a9cb9962912 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/shard_allocation/components/table_body.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/shard_allocation/components/table_body.js @@ -22,11 +22,7 @@ const ShardRow = (props) => { return ( {unassigned} - + ); }; @@ -40,14 +36,7 @@ export class TableBody extends React.Component { ); createRow = (data, index) => { - return ( - - ); + return ; }; render() { diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/shard_allocation/lib/generate_query_and_link.js b/x-pack/plugins/monitoring/public/components/elasticsearch/shard_allocation/lib/generate_query_and_link.js deleted file mode 100644 index 04802e96cdf4b1..00000000000000 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/shard_allocation/lib/generate_query_and_link.js +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export function generateQueryAndLink(data) { - let type = 'indices'; - let ident = data.name; - if (data.type === 'node') { - type = 'nodes'; - ident = data.id; - } - return '/elasticsearch/' + type + '/' + ident; -} diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/shard_allocation/shard_allocation.js b/x-pack/plugins/monitoring/public/components/elasticsearch/shard_allocation/shard_allocation.js index c5ddfecb044888..c11de3538b97fe 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/shard_allocation/shard_allocation.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/shard_allocation/shard_allocation.js @@ -10,7 +10,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; import { ClusterView } from './components/cluster_view'; -export const ShardAllocation = ({ scope, kbnUrl, type, shardStats }) => { +export const ShardAllocation = ({ scope, type, shardStats }) => { const types = [ { label: i18n.translate('xpack.monitoring.elasticsearch.shardAllocation.primaryLabel', { @@ -78,7 +78,6 @@ export const ShardAllocation = ({ scope, kbnUrl, type, shardStats }) => { { export class KibanaInstances extends PureComponent { render() { - const { clusterStatus, angular, setupMode, sorting, pagination, onTableChange } = this.props; + const { clusterStatus, setupMode, sorting, pagination, onTableChange } = this.props; let setupModeCallOut = null; // Merge the instances data with the setup data if enabled @@ -253,7 +253,7 @@ export class KibanaInstances extends PureComponent {
- { - scope.$evalAsync(() => { - kbnUrl.changePath(`/logstash/node/${node.logstash.uuid}`); - }); - }} - > + {name}
diff --git a/x-pack/plugins/monitoring/public/components/logstash/listing/listing.test.js b/x-pack/plugins/monitoring/public/components/logstash/listing/listing.test.js index 525918f7c99ad5..e8baee6408b226 100644 --- a/x-pack/plugins/monitoring/public/components/logstash/listing/listing.test.js +++ b/x-pack/plugins/monitoring/public/components/logstash/listing/listing.test.js @@ -54,10 +54,6 @@ describe('Listing', () => { it('should render with expected props', () => { const props = { data: expectedData, - angular: { - scope: null, - kbnUrl: null, - }, sorting: { sort: 'asc', }, @@ -74,10 +70,6 @@ describe('Listing', () => { const { os, process, logstash, jvm, events, ...rest } = item; // eslint-disable-line no-unused-vars return rest; }), - angular: { - scope: null, - kbnUrl: null, - }, sorting: { sort: 'asc', }, diff --git a/x-pack/plugins/monitoring/public/components/logstash/pipeline_listing/pipeline_listing.js b/x-pack/plugins/monitoring/public/components/logstash/pipeline_listing/pipeline_listing.js index 90fb93d430ff0b..af181fb2a674df 100644 --- a/x-pack/plugins/monitoring/public/components/logstash/pipeline_listing/pipeline_listing.js +++ b/x-pack/plugins/monitoring/public/components/logstash/pipeline_listing/pipeline_listing.js @@ -22,6 +22,7 @@ import { ClusterStatus } from '../cluster_status'; import { Sparkline } from '../../../components/sparkline'; import { EuiMonitoringSSPTable } from '../../table'; import { i18n } from '@kbn/i18n'; +import { getSafeForExternalLink } from '../../../lib/get_safe_for_external_link'; export class PipelineListing extends Component { tooltipXValueFormatter(xValue, dateFormat) { @@ -34,7 +35,6 @@ export class PipelineListing extends Component { getColumns() { const { onBrush, dateFormat } = this.props; - const { kbnUrl, scope } = this.props.angular; return [ { @@ -44,14 +44,7 @@ export class PipelineListing extends Component { field: 'id', sortable: true, render: (id) => ( - { - scope.$evalAsync(() => { - kbnUrl.changePath(`/logstash/pipelines/${id}`); - }); - }} - > + {id} ), diff --git a/x-pack/plugins/monitoring/public/components/no_data/no_data.js b/x-pack/plugins/monitoring/public/components/no_data/no_data.js index ca5be8adf3ef84..fc5df7ea7b56e4 100644 --- a/x-pack/plugins/monitoring/public/components/no_data/no_data.js +++ b/x-pack/plugins/monitoring/public/components/no_data/no_data.js @@ -26,6 +26,7 @@ import { toggleSetupMode } from '../../lib/setup_mode'; import { CheckingSettings } from './checking_settings'; import { ReasonFound, WeTried } from './reasons'; import { CheckerErrors } from './checker_errors'; +import { getSafeForExternalLink } from '../../lib/get_safe_for_external_link'; function NoDataMessage(props) { const { isLoading, reason, checkMessage } = props; @@ -48,7 +49,7 @@ export function NoData(props) { async function startSetup() { setIsLoading(true); await toggleSetupMode(true); - props.changePath('/elasticsearch/nodes'); + window.location.hash = getSafeForExternalLink('#/elasticsearch/nodes'); } if (useInternalCollection) { @@ -150,7 +151,6 @@ export function NoData(props) { } NoData.propTypes = { - changePath: PropTypes.func, isLoading: PropTypes.bool.isRequired, reason: PropTypes.object, checkMessage: PropTypes.string, diff --git a/x-pack/plugins/monitoring/public/components/setup_mode/__snapshots__/tooltip.test.js.snap b/x-pack/plugins/monitoring/public/components/setup_mode/__snapshots__/tooltip.test.js.snap index 49ce0e84fdaccc..aafba6791f4a00 100644 --- a/x-pack/plugins/monitoring/public/components/setup_mode/__snapshots__/tooltip.test.js.snap +++ b/x-pack/plugins/monitoring/public/components/setup_mode/__snapshots__/tooltip.test.js.snap @@ -11,8 +11,8 @@ exports[`setupMode SetupModeTooltip allInternalCollection should render for apm > Self monitoring @@ -32,8 +32,8 @@ exports[`setupMode SetupModeTooltip allInternalCollection should render for beat > Self monitoring @@ -53,8 +53,8 @@ exports[`setupMode SetupModeTooltip allInternalCollection should render for elas > Self monitoring @@ -74,8 +74,8 @@ exports[`setupMode SetupModeTooltip allInternalCollection should render for kiba > Self monitoring @@ -95,8 +95,8 @@ exports[`setupMode SetupModeTooltip allInternalCollection should render for logs > Self monitoring @@ -116,8 +116,8 @@ exports[`setupMode SetupModeTooltip allMonitoredByMetricbeat should render for a > Metricbeat monitoring @@ -137,8 +137,8 @@ exports[`setupMode SetupModeTooltip allMonitoredByMetricbeat should render for b > Metricbeat monitoring @@ -158,8 +158,8 @@ exports[`setupMode SetupModeTooltip allMonitoredByMetricbeat should render for e > Metricbeat monitoring @@ -179,8 +179,8 @@ exports[`setupMode SetupModeTooltip allMonitoredByMetricbeat should render for k > Metricbeat monitoring @@ -200,8 +200,8 @@ exports[`setupMode SetupModeTooltip allMonitoredByMetricbeat should render for l > Metricbeat monitoring @@ -221,8 +221,8 @@ exports[`setupMode SetupModeTooltip internalCollectionOn should render for apm 1 > Self monitoring is on @@ -242,8 +242,8 @@ exports[`setupMode SetupModeTooltip internalCollectionOn should render for beats > Self monitoring is on @@ -263,8 +263,8 @@ exports[`setupMode SetupModeTooltip internalCollectionOn should render for elast > Self monitoring is on @@ -284,8 +284,8 @@ exports[`setupMode SetupModeTooltip internalCollectionOn should render for kiban > Self monitoring is on @@ -305,8 +305,8 @@ exports[`setupMode SetupModeTooltip internalCollectionOn should render for logst > Self monitoring is on @@ -326,8 +326,8 @@ exports[`setupMode SetupModeTooltip no detectable instances should render for ap > No usage @@ -347,8 +347,8 @@ exports[`setupMode SetupModeTooltip no detectable instances should render for be > No usage @@ -368,8 +368,8 @@ exports[`setupMode SetupModeTooltip no detectable instances should render for el > No usage @@ -389,8 +389,8 @@ exports[`setupMode SetupModeTooltip no detectable instances should render for ki > No usage @@ -410,8 +410,8 @@ exports[`setupMode SetupModeTooltip no detectable instances should render for lo > No usage @@ -431,8 +431,8 @@ exports[`setupMode SetupModeTooltip only detectable instances should render for > No monitoring @@ -452,8 +452,8 @@ exports[`setupMode SetupModeTooltip only detectable instances should render for > No monitoring @@ -473,8 +473,8 @@ exports[`setupMode SetupModeTooltip only detectable instances should render for > No monitoring @@ -494,8 +494,8 @@ exports[`setupMode SetupModeTooltip only detectable instances should render for > No monitoring @@ -515,8 +515,8 @@ exports[`setupMode SetupModeTooltip only detectable instances should render for > No monitoring diff --git a/x-pack/plugins/monitoring/public/components/setup_mode/tooltip.js b/x-pack/plugins/monitoring/public/components/setup_mode/tooltip.js index 1189da08161ba7..c549c1a801bfbb 100644 --- a/x-pack/plugins/monitoring/public/components/setup_mode/tooltip.js +++ b/x-pack/plugins/monitoring/public/components/setup_mode/tooltip.js @@ -10,7 +10,7 @@ import { EuiBadge, EuiFlexItem, EuiToolTip } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { getIdentifier } from './formatting'; -export function SetupModeTooltip({ setupModeData, badgeClickAction, productName }) { +export function SetupModeTooltip({ setupModeData, badgeClickLink, productName }) { if (!setupModeData) { return null; } @@ -45,7 +45,7 @@ export function SetupModeTooltip({ setupModeData, badgeClickAction, productName {detectedText} @@ -70,7 +70,7 @@ export function SetupModeTooltip({ setupModeData, badgeClickAction, productName {noMonitoringText} @@ -98,7 +98,7 @@ export function SetupModeTooltip({ setupModeData, badgeClickAction, productName {internalCollection} @@ -122,7 +122,7 @@ export function SetupModeTooltip({ setupModeData, badgeClickAction, productName {internalAndMB} @@ -146,7 +146,7 @@ export function SetupModeTooltip({ setupModeData, badgeClickAction, productName {metricbeatCollection} diff --git a/x-pack/plugins/monitoring/public/components/setup_mode/tooltip.test.js b/x-pack/plugins/monitoring/public/components/setup_mode/tooltip.test.js index abb0b972d97567..1415c5060ccdaf 100644 --- a/x-pack/plugins/monitoring/public/components/setup_mode/tooltip.test.js +++ b/x-pack/plugins/monitoring/public/components/setup_mode/tooltip.test.js @@ -82,11 +82,7 @@ describe('setupMode SetupModeTooltip', () => { for (const { name } of PRODUCTS) { it(`should render for ${name}`, () => { const component = shallow( - {}} - /> + ); expect(component).toMatchSnapshot(); }); diff --git a/x-pack/plugins/monitoring/public/directives/elasticsearch/ml_job_listing/index.js b/x-pack/plugins/monitoring/public/directives/elasticsearch/ml_job_listing/index.js index 530c665cac0ee4..bef0fce4cd088b 100644 --- a/x-pack/plugins/monitoring/public/directives/elasticsearch/ml_job_listing/index.js +++ b/x-pack/plugins/monitoring/public/directives/elasticsearch/ml_job_listing/index.js @@ -15,8 +15,9 @@ import { EuiLink, EuiPage, EuiPageContent, EuiPageBody, EuiPanel, EuiSpacer } fr import { ClusterStatus } from '../../../components/elasticsearch/cluster_status'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; +import { getSafeForExternalLink } from '../../../lib/get_safe_for_external_link'; -const getColumns = (kbnUrl, scope) => [ +const getColumns = () => [ { name: i18n.translate('xpack.monitoring.elasticsearch.mlJobListing.jobIdTitle', { defaultMessage: 'Job ID', @@ -71,13 +72,7 @@ const getColumns = (kbnUrl, scope) => [ render: (name, node) => { if (node) { return ( - { - scope.$evalAsync(() => kbnUrl.changePath(`/elasticsearch/nodes/${node.id}`)); - }} - > - {name} - + {name} ); } @@ -92,7 +87,7 @@ const getColumns = (kbnUrl, scope) => [ ]; //monitoringMlListing -export function monitoringMlListingProvider(kbnUrl) { +export function monitoringMlListingProvider() { return { restrict: 'E', scope: { @@ -104,7 +99,7 @@ export function monitoringMlListingProvider(kbnUrl) { }, link(scope, $el) { scope.$on('$destroy', () => $el && $el[0] && unmountComponentAtNode($el[0])); - const columns = getColumns(kbnUrl, scope); + const columns = getColumns(); const filterJobsPlaceholder = i18n.translate( 'xpack.monitoring.elasticsearch.mlJobListing.filterJobsPlaceholder', diff --git a/x-pack/plugins/monitoring/public/directives/main/index.js b/x-pack/plugins/monitoring/public/directives/main/index.js index 5cb6272e8880ab..97ec66c9b3415b 100644 --- a/x-pack/plugins/monitoring/public/directives/main/index.js +++ b/x-pack/plugins/monitoring/public/directives/main/index.js @@ -13,6 +13,7 @@ import { Legacy } from '../../legacy_shims'; import { shortenPipelineHash } from '../../../common/formatting'; import { getSetupModeState, initSetupModeState } from '../../lib/setup_mode'; import { Subscription } from 'rxjs'; +import { getSafeForExternalLink } from '../../lib/get_safe_for_external_link'; const setOptions = (controller) => { if ( @@ -104,7 +105,6 @@ export class MonitoringMainController { const timefilter = Legacy.shims.timefilter; this._licenseService = options.licenseService; this._breadcrumbsService = options.breadcrumbsService; - this._kbnUrlService = options.kbnUrlService; this._executorService = options.executorService; Object.assign(this, options.attributes); @@ -132,7 +132,7 @@ export class MonitoringMainController { if (this.pipelineHash) { this.pipelineHashShort = shortenPipelineHash(this.pipelineHash); this.onChangePipelineHash = () => { - return this._kbnUrlService.changePath( + window.location.hash = getSafeForExternalLink( `/logstash/pipelines/${this.pipelineId}/${this.pipelineHash}` ); }; @@ -198,7 +198,7 @@ export class MonitoringMainController { } } -export function monitoringMainProvider(breadcrumbs, license, kbnUrl, $injector) { +export function monitoringMainProvider(breadcrumbs, license, $injector) { const $executor = $injector.get('$executor'); return { @@ -234,7 +234,6 @@ export function monitoringMainProvider(breadcrumbs, license, kbnUrl, $injector) licenseService: license, breadcrumbsService: breadcrumbs, executorService: $executor, - kbnUrlService: kbnUrl, attributes: { name: attributes.name, product: attributes.product, diff --git a/x-pack/plugins/monitoring/public/legacy_shims.ts b/x-pack/plugins/monitoring/public/legacy_shims.ts index 47aa1048c51306..450a34b797c38e 100644 --- a/x-pack/plugins/monitoring/public/legacy_shims.ts +++ b/x-pack/plugins/monitoring/public/legacy_shims.ts @@ -6,9 +6,16 @@ import { CoreStart } from 'kibana/public'; import angular from 'angular'; +import { Observable } from 'rxjs'; import { HttpRequestInit } from '../../../../src/core/public'; import { MonitoringPluginDependencies } from './types'; +interface BreadcrumbItem { + ['data-test-subj']?: string; + href?: string; + text: string; +} + export interface KFetchQuery { [key: string]: string | number | boolean | undefined; } @@ -29,7 +36,10 @@ export interface IShims { getAngularInjector: () => angular.auto.IInjectorService; getBasePath: () => string; getInjected: (name: string, defaultValue?: unknown) => unknown; - breadcrumbs: { set: () => void }; + breadcrumbs: { + set: (breadcrumbs: BreadcrumbItem[]) => void; + update: (breadcrumbs?: BreadcrumbItem[]) => void; + }; I18nContext: CoreStart['i18n']['Context']; docLinks: CoreStart['docLinks']; docTitle: CoreStart['chrome']['docTitle']; @@ -56,7 +66,30 @@ export class Legacy { getInjected: (name: string, defaultValue?: unknown): string | unknown => core.injectedMetadata.getInjectedVar(name, defaultValue), breadcrumbs: { - set: (...args: any[0]) => core.chrome.setBreadcrumbs.apply(this, args), + set: (breadcrumbs: BreadcrumbItem[]) => this._shims.breadcrumbs.update(breadcrumbs), + update: (breadcrumbs?: BreadcrumbItem[]) => { + if (!breadcrumbs) { + const currentBreadcrumbs: Observable & { + value?: BreadcrumbItem[]; + } = core.chrome.getBreadcrumbs$()?.source; + breadcrumbs = currentBreadcrumbs?.value; + } + const globalStateStr = location.hash.split('?')[1]; + if ( + !breadcrumbs?.length || + globalStateStr?.indexOf('_g') !== 0 || + breadcrumbs[0].href?.split('?')[1] === globalStateStr + ) { + return; + } + breadcrumbs.forEach((breadcrumb: BreadcrumbItem) => { + const breadcrumbHref = breadcrumb.href?.split('?')[0]; + if (breadcrumbHref) { + breadcrumb.href = `${breadcrumbHref}?${globalStateStr}`; + } + }); + core.chrome.setBreadcrumbs(breadcrumbs.slice(0)); + }, }, I18nContext: core.i18n.Context, docLinks: core.docLinks, diff --git a/x-pack/plugins/monitoring/public/lib/ajax_error_handler.tsx b/x-pack/plugins/monitoring/public/lib/ajax_error_handler.tsx index d729457f60df1e..14f838cff7a3ca 100644 --- a/x-pack/plugins/monitoring/public/lib/ajax_error_handler.tsx +++ b/x-pack/plugins/monitoring/public/lib/ajax_error_handler.tsx @@ -33,13 +33,11 @@ export function formatMonitoringError(err: any) { return formatMsg(err); } -export function ajaxErrorHandlersProvider($injector: any) { - const kbnUrl = $injector.get('kbnUrl'); - +export function ajaxErrorHandlersProvider() { return (err: any) => { if (err.status === 403) { // redirect to error message view - kbnUrl.redirect('access-denied'); + history.replaceState(null, '', '#/access-denied'); } else if (err.status === 404 && !contains(window.location.hash, 'no-data')) { // pass through if this is a 404 and we're already on the no-data page Legacy.shims.toastNotifications.addDanger({ diff --git a/x-pack/plugins/monitoring/public/lib/route_init.js b/x-pack/plugins/monitoring/public/lib/route_init.js index 451304010dcf98..9467535d556b0e 100644 --- a/x-pack/plugins/monitoring/public/lib/route_init.js +++ b/x-pack/plugins/monitoring/public/lib/route_init.js @@ -9,7 +9,7 @@ import { ajaxErrorHandlersProvider } from './ajax_error_handler'; import { isInSetupMode } from './setup_mode'; import { getClusterFromClusters } from './get_cluster_from_clusters'; -export function routeInitProvider(Private, monitoringClusters, globalState, license, kbnUrl) { +export function routeInitProvider(Private, monitoringClusters, globalState, license) { const ajaxErrorHandlers = Private(ajaxErrorHandlersProvider); function isOnPage(hash) { @@ -31,7 +31,8 @@ export function routeInitProvider(Private, monitoringClusters, globalState, lice const inSetupMode = isInSetupMode(); const cluster = getClusterFromClusters(clusters, globalState); if (!cluster && !inSetupMode) { - return kbnUrl.redirect('/no-data'); + window.history.replaceState(null, null, '#/no-data'); + return Promise.resolve(); } if (cluster) { @@ -39,13 +40,15 @@ export function routeInitProvider(Private, monitoringClusters, globalState, lice // check if we need to redirect because of license problems if (!(isOnPage('license') || isOnPage('home')) && license.isExpired()) { - return kbnUrl.redirect('/license'); + window.history.replaceState(null, null, '#/license'); + return Promise.resolve(); } // check if we need to redirect because of attempt at unsupported multi-cluster monitoring const clusterSupported = cluster.isSupported || clusters.length === 1; if (!isOnPage('home') && !clusterSupported) { - return kbnUrl.redirect('/home'); + window.history.replaceState(null, null, '#/home'); + return Promise.resolve(); } } diff --git a/x-pack/plugins/monitoring/public/url_state.ts b/x-pack/plugins/monitoring/public/url_state.ts index ab81258fe25563..f2ae0a93d5df03 100644 --- a/x-pack/plugins/monitoring/public/url_state.ts +++ b/x-pack/plugins/monitoring/public/url_state.ts @@ -5,9 +5,9 @@ */ import { Subscription } from 'rxjs'; -import { History } from 'history'; -import { createHashHistory } from 'history'; +import { History, createHashHistory } from 'history'; import { MonitoringPluginDependencies } from './types'; +import { Legacy } from './legacy_shims'; import { RefreshInterval, @@ -95,11 +95,11 @@ export class GlobalState { this.stateContainerChangeSub = this.stateContainer.state$.subscribe(() => { this.lastAssignedState = this.getState(); if (!this.stateContainer.get() && this.lastKnownGlobalState) { - rootScope.$applyAsync(() => - ngLocation.search(`${GLOBAL_STATE_KEY}=${this.lastKnownGlobalState}`).replace() - ); + ngLocation.search(`${GLOBAL_STATE_KEY}=${this.lastKnownGlobalState}`).replace(); } + Legacy.shims.breadcrumbs.update(); this.syncExternalState(externalState); + rootScope.$applyAsync(); }); this.syncQueryStateWithUrlManager = syncQueryStateWithUrl(queryService, this.stateStorage); diff --git a/x-pack/plugins/monitoring/public/views/access_denied/index.js b/x-pack/plugins/monitoring/public/views/access_denied/index.js index f7a4d03a26452b..2db34842b9324d 100644 --- a/x-pack/plugins/monitoring/public/views/access_denied/index.js +++ b/x-pack/plugins/monitoring/public/views/access_denied/index.js @@ -8,10 +8,10 @@ import { kbnBaseUrl } from '../../../../../../src/plugins/kibana_legacy/common/k import { uiRoutes } from '../../angular/helpers/routes'; import template from './index.html'; -const tryPrivilege = ($http, kbnUrl) => { +const tryPrivilege = ($http) => { return $http .get('../api/monitoring/v1/check_access') - .then(() => kbnUrl.redirect('/home')) + .then(() => window.history.replaceState(null, null, '#/home')) .catch(() => true); }; @@ -25,21 +25,20 @@ uiRoutes.when('/access-denied', { * privilege one time up front (doing it in the resolve makes it happen * before the template renders), and then keep retrying every 5 seconds. */ - initialCheck($http, kbnUrl) { - return tryPrivilege($http, kbnUrl); + initialCheck($http) { + return tryPrivilege($http); }, }, controllerAs: 'accessDenied', controller: function ($scope, $injector) { const $http = $injector.get('$http'); - const kbnUrl = $injector.get('kbnUrl'); const $interval = $injector.get('$interval'); // The template's "Back to Kibana" button click handler this.goToKibanaURL = kbnBaseUrl; // keep trying to load data in the background - const accessPoller = $interval(() => tryPrivilege($http, kbnUrl), 5 * 1000); // every 5 seconds + const accessPoller = $interval(() => tryPrivilege($http), 5 * 1000); // every 5 seconds $scope.$on('$destroy', () => $interval.cancel(accessPoller)); }, }); diff --git a/x-pack/plugins/monitoring/public/views/alerts/index.js b/x-pack/plugins/monitoring/public/views/alerts/index.js index ce27e1a9df26db..ea857cb69d22b4 100644 --- a/x-pack/plugins/monitoring/public/views/alerts/index.js +++ b/x-pack/plugins/monitoring/public/views/alerts/index.js @@ -68,7 +68,6 @@ uiRoutes.when('/alerts', { constructor($injector, $scope) { const $route = $injector.get('$route'); const globalState = $injector.get('globalState'); - const kbnUrl = $injector.get('kbnUrl'); // breadcrumbs + page title $scope.cluster = find($route.current.locals.clusters, { @@ -94,7 +93,6 @@ uiRoutes.when('/alerts', { ) : ( {bottomBarComponent} diff --git a/x-pack/plugins/monitoring/public/views/cluster/listing/index.js b/x-pack/plugins/monitoring/public/views/cluster/listing/index.js index ede6ccd3279c64..b00945ca37e192 100644 --- a/x-pack/plugins/monitoring/public/views/cluster/listing/index.js +++ b/x-pack/plugins/monitoring/public/views/cluster/listing/index.js @@ -23,16 +23,16 @@ uiRoutes .when('/home', { template, resolve: { - clusters: (Private, kbnUrl) => { + clusters: (Private) => { const routeInit = Private(routeInitProvider); return routeInit({ codePaths: CODE_PATHS, fetchAllClusters: true }).then((clusters) => { if (!clusters || !clusters.length) { - kbnUrl.changePath('/no-data'); + window.location.hash = '#/no-data'; return Promise.reject(); } if (clusters.length === 1) { // Bypass the cluster listing if there is just 1 cluster - kbnUrl.redirect('/overview'); + window.history.replaceState(null, null, '#/overview'); return Promise.reject(); } return clusters; @@ -51,7 +51,6 @@ uiRoutes }); const $route = $injector.get('$route'); - const kbnUrl = $injector.get('kbnUrl'); const globalState = $injector.get('globalState'); const storage = $injector.get('localStorage'); const showLicenseExpiration = $injector.get('showLicenseExpiration'); @@ -67,7 +66,6 @@ uiRoutes angular={{ scope: $scope, globalState, - kbnUrl, storage, showLicenseExpiration, }} diff --git a/x-pack/plugins/monitoring/public/views/cluster/overview/index.js b/x-pack/plugins/monitoring/public/views/cluster/overview/index.js index 6cf0eb4e01c19c..d47b31cfb5b793 100644 --- a/x-pack/plugins/monitoring/public/views/cluster/overview/index.js +++ b/x-pack/plugins/monitoring/public/views/cluster/overview/index.js @@ -32,7 +32,6 @@ uiRoutes.when('/overview', { }, controller: class extends MonitoringViewBaseController { constructor($injector, $scope) { - const kbnUrl = $injector.get('kbnUrl'); const monitoringClusters = $injector.get('monitoringClusters'); const globalState = $injector.get('globalState'); const showLicenseExpiration = $injector.get('showLicenseExpiration'); @@ -56,12 +55,6 @@ uiRoutes.when('/overview', { $injector, }); - const changeUrl = (target) => { - $scope.$evalAsync(() => { - kbnUrl.changePath(target); - }); - }; - $scope.$watch( () => this.data, async (data) => { @@ -85,7 +78,6 @@ uiRoutes.when('/overview', { cluster={data} emailAddress={emailAddress} setupMode={setupMode} - changeUrl={changeUrl} showLicenseExpiration={showLicenseExpiration} /> {bottomBarComponent} diff --git a/x-pack/plugins/monitoring/public/views/elasticsearch/index/index.js b/x-pack/plugins/monitoring/public/views/elasticsearch/index/index.js index 483cc13c4036fe..afe16acc0d0010 100644 --- a/x-pack/plugins/monitoring/public/views/elasticsearch/index/index.js +++ b/x-pack/plugins/monitoring/public/views/elasticsearch/index/index.js @@ -57,7 +57,6 @@ uiRoutes.when('/elasticsearch/indices/:index', { controller: class extends MonitoringViewBaseController { constructor($injector, $scope) { const $route = $injector.get('$route'); - const kbnUrl = $injector.get('kbnUrl'); const indexName = $route.current.params.index; super({ @@ -97,7 +96,6 @@ uiRoutes.when('/elasticsearch/indices/:index', { this.renderReact( { this.renderReact( {bottomBarComponent} diff --git a/x-pack/plugins/monitoring/public/views/logstash/node/pipelines/index.js b/x-pack/plugins/monitoring/public/views/logstash/node/pipelines/index.js index 78426a503337f8..cdd9b48b24b28c 100644 --- a/x-pack/plugins/monitoring/public/views/logstash/node/pipelines/index.js +++ b/x-pack/plugins/monitoring/public/views/logstash/node/pipelines/index.js @@ -72,7 +72,6 @@ uiRoutes.when('/logstash/node/:uuid/pipelines', { }, controller: class extends MonitoringViewBaseEuiTableController { constructor($injector, $scope) { - const kbnUrl = $injector.get('kbnUrl'); const config = $injector.get('config'); super({ @@ -116,10 +115,6 @@ uiRoutes.when('/logstash/node/:uuid/pipelines', { {...this.getPaginationTableProps(pagination)} dateFormat={config.get('dateFormat')} upgradeMessage={makeUpgradeMessage(data.nodeSummary.version, i18n)} - angular={{ - kbnUrl, - scope: $scope, - }} /> ); } diff --git a/x-pack/plugins/monitoring/public/views/logstash/nodes/index.js b/x-pack/plugins/monitoring/public/views/logstash/nodes/index.js index 102e245b541c41..f78a426b9b7c39 100644 --- a/x-pack/plugins/monitoring/public/views/logstash/nodes/index.js +++ b/x-pack/plugins/monitoring/public/views/logstash/nodes/index.js @@ -25,8 +25,6 @@ uiRoutes.when('/logstash/nodes', { controllerAs: 'lsNodes', controller: class LsNodesList extends MonitoringViewBaseEuiTableController { constructor($injector, $scope) { - const kbnUrl = $injector.get('kbnUrl'); - super({ title: 'Logstash - Nodes', storageKey: 'logstash.nodes', @@ -54,7 +52,6 @@ uiRoutes.when('/logstash/nodes', { sorting={this.sorting} pagination={this.pagination} onTableChange={this.onTableChange} - angular={{ kbnUrl, scope: $scope }} /> {bottomBarComponent} diff --git a/x-pack/plugins/monitoring/public/views/logstash/pipelines/index.js b/x-pack/plugins/monitoring/public/views/logstash/pipelines/index.js index cf8d6663069fe4..62ef12d8e92f14 100644 --- a/x-pack/plugins/monitoring/public/views/logstash/pipelines/index.js +++ b/x-pack/plugins/monitoring/public/views/logstash/pipelines/index.js @@ -79,7 +79,6 @@ uiRoutes.when('/logstash/pipelines', { }); const $route = $injector.get('$route'); - const kbnUrl = $injector.get('kbnUrl'); const config = $injector.get('config'); this.data = $route.current.locals.pageData; const globalState = $injector.get('globalState'); @@ -110,10 +109,6 @@ uiRoutes.when('/logstash/pipelines', { {...this.getPaginationTableProps(pagination)} upgradeMessage={upgradeMessage} dateFormat={config.get('dateFormat')} - angular={{ - kbnUrl, - scope: $scope, - }} /> ); }; diff --git a/x-pack/plugins/monitoring/public/views/no_data/controller.js b/x-pack/plugins/monitoring/public/views/no_data/controller.js index 3e6c07e936b952..5982c9c100734b 100644 --- a/x-pack/plugins/monitoring/public/views/no_data/controller.js +++ b/x-pack/plugins/monitoring/public/views/no_data/controller.js @@ -22,7 +22,6 @@ export class NoDataController extends MonitoringViewBaseController { constructor($injector, $scope) { window.injectorThree = $injector; const monitoringClusters = $injector.get('monitoringClusters'); - const kbnUrl = $injector.get('kbnUrl'); const $http = $injector.get('$http'); const checkers = [new ClusterSettingsChecker($http), new NodeSettingsChecker($http)]; @@ -33,7 +32,7 @@ export class NoDataController extends MonitoringViewBaseController { CODE_PATH_LICENSE, ]); if (monitoringClustersData && monitoringClustersData.length) { - kbnUrl.redirect('/home'); + window.history.replaceState(null, null, '#/home'); return monitoringClustersData; } } catch (err) { @@ -81,8 +80,6 @@ export class NoDataController extends MonitoringViewBaseController { }, true ); - - this.changePath = (path) => kbnUrl.changePath(path); } getDefaultModel() { @@ -99,13 +96,6 @@ export class NoDataController extends MonitoringViewBaseController { render(enabler) { const props = this; - this.renderReact( - - ); + this.renderReact(); } }