From 21d620257908840797b032114dea09437854b2b8 Mon Sep 17 00:00:00 2001 From: igoristic Date: Mon, 23 Dec 2019 11:35:25 -0500 Subject: [PATCH] [Monitoring] Added safeguard for some EUI components (#53318) * merged master * addressed feedback * Addressed feedback Co-authored-by: Elastic Machine --- .../public/components/alerts/alerts.js | 11 +++++++- .../components/cluster/listing/listing.js | 8 +++++- .../cluster/overview/elasticsearch_panel.js | 5 +++- .../components/elasticsearch/nodes/nodes.js | 28 ++++++++++++++++--- .../shard_activity/source_destination.js | 8 +++++- .../shard_allocation/components/shard.js | 14 +++++----- .../public/components/table/eui_table_ssp.js | 5 ++++ 7 files changed, 64 insertions(+), 15 deletions(-) diff --git a/x-pack/legacy/plugins/monitoring/public/components/alerts/alerts.js b/x-pack/legacy/plugins/monitoring/public/components/alerts/alerts.js index 908e369ec03863..4c2f3b027bc8ae 100644 --- a/x-pack/legacy/plugins/monitoring/public/components/alerts/alerts.js +++ b/x-pack/legacy/plugins/monitoring/public/components/alerts/alerts.js @@ -29,7 +29,16 @@ const getColumns = (kbnUrl, scope) => [ field: 'status', sortable: true, render: severity => { - const severityIcon = mapSeverity(severity); + const severityIconDefaults = { + title: i18n.translate('xpack.monitoring.alerts.severityTitle.unknown', { + defaultMessage: 'Unknown', + }), + color: 'subdued', + value: i18n.translate('xpack.monitoring.alerts.severityValue.unknown', { + defaultMessage: 'N/A', + }), + }; + const severityIcon = { ...severityIconDefaults, ...mapSeverity(severity) }; return ( diff --git a/x-pack/legacy/plugins/monitoring/public/components/cluster/listing/listing.js b/x-pack/legacy/plugins/monitoring/public/components/cluster/listing/listing.js index 432aa124e60697..7e88890ea9316e 100644 --- a/x-pack/legacy/plugins/monitoring/public/components/cluster/listing/listing.js +++ b/x-pack/legacy/plugins/monitoring/public/components/cluster/listing/listing.js @@ -45,7 +45,13 @@ const IsAlertsSupported = props => { return {props.children}; } - const message = alertsMeta.message || clusterMeta.message; + const message = + alertsMeta.message || + clusterMeta.message || + i18n.translate('xpack.monitoring.cluster.listing.unknownHealthMessage', { + defaultMessage: 'Unknown', + }); + return ( diff --git a/x-pack/legacy/plugins/monitoring/public/components/cluster/overview/elasticsearch_panel.js b/x-pack/legacy/plugins/monitoring/public/components/cluster/overview/elasticsearch_panel.js index 7ce3e890cdeaf5..fc23110f940e88 100644 --- a/x-pack/legacy/plugins/monitoring/public/components/cluster/overview/elasticsearch_panel.js +++ b/x-pack/legacy/plugins/monitoring/public/components/cluster/overview/elasticsearch_panel.js @@ -117,6 +117,9 @@ const logLevelText = { fatal: i18n.translate('xpack.monitoring.cluster.overview.esPanel.fatalLogsTooltipText', { defaultMessage: 'The number of fatal logs', }), + unknown: i18n.translate('xpack.monitoring.cluster.overview.esPanel.unknownLogsTooltipText', { + defaultMessage: 'Unknown', + }), }; function renderLog(log) { @@ -124,7 +127,7 @@ function renderLog(log) { {log.levels.map((level, index) => ( - + {formatNumber(level.count, 'int_commas')} diff --git a/x-pack/legacy/plugins/monitoring/public/components/elasticsearch/nodes/nodes.js b/x-pack/legacy/plugins/monitoring/public/components/elasticsearch/nodes/nodes.js index 74aea88e812f6c..428da4ca913aa3 100644 --- a/x-pack/legacy/plugins/monitoring/public/components/elasticsearch/nodes/nodes.js +++ b/x-pack/legacy/plugins/monitoring/public/components/elasticsearch/nodes/nodes.js @@ -29,6 +29,29 @@ import _ from 'lodash'; import { ELASTICSEARCH_SYSTEM_ID } from '../../../../common/constants'; import { ListingCallOut } from '../../setup_mode/listing_callout'; +const getNodeTooltip = node => { + const { nodeTypeLabel, nodeTypeClass } = node; + + const nodeTypeLabelContent = + nodeTypeLabel || + i18n.translate('xpack.monitoring.elasticsearch.nodes.unknownNodeTypeLabel', { + defaultMessage: 'Unknown', + }); + const nodeTypeClassIcon = nodeTypeClass || 'empty'; + + if (nodeTypeLabel) { + return ( + <> + + + {' '} +   + + ); + } + return null; +}; + const getSortHandler = type => item => _.get(item, [type, 'summary', 'lastVal']); const getColumns = (showCgroupMetricsElasticsearch, setupMode, clusterUuid) => { const cols = []; @@ -86,10 +109,7 @@ const getColumns = (showCgroupMetricsElasticsearch, setupMode, clusterUuid) => {
- - {node.nodeTypeClass && } - -   + {getNodeTooltip(node)} {nameLink}
diff --git a/x-pack/legacy/plugins/monitoring/public/components/elasticsearch/shard_activity/source_destination.js b/x-pack/legacy/plugins/monitoring/public/components/elasticsearch/shard_activity/source_destination.js index febdf1835faf5c..e389e7655bcd0f 100644 --- a/x-pack/legacy/plugins/monitoring/public/components/elasticsearch/shard_activity/source_destination.js +++ b/x-pack/legacy/plugins/monitoring/public/components/elasticsearch/shard_activity/source_destination.js @@ -7,9 +7,15 @@ import React from 'react'; import { EuiIcon, EuiLink, EuiFlexGroup, EuiFlexItem, EuiToolTip } from '@elastic/eui'; import { SourceTooltip } from './source_tooltip'; +import { i18n } from '@kbn/i18n'; export const SourceDestination = props => { const { sourceName, targetName, targetTransportAddress } = props; + const targetTransportAddressContent = + targetTransportAddress || + i18n.translate('xpack.monitoring.elasticsearch.shardActivity.unknownTargetAddressContent', { + defaultMessage: 'Unknown', + }); return ( @@ -19,7 +25,7 @@ export const SourceDestination = props => { - + {targetName} diff --git a/x-pack/legacy/plugins/monitoring/public/components/elasticsearch/shard_allocation/components/shard.js b/x-pack/legacy/plugins/monitoring/public/components/elasticsearch/shard_allocation/components/shard.js index ac70f952008c57..1a1e8e3f029125 100644 --- a/x-pack/legacy/plugins/monitoring/public/components/elasticsearch/shard_allocation/components/shard.js +++ b/x-pack/legacy/plugins/monitoring/public/components/elasticsearch/shard_allocation/components/shard.js @@ -95,14 +95,14 @@ export class Shard extends React.Component { const classification = classes + ' ' + shard.shard; let shardUi = {shard.shard}; - + const tooltipContent = + shard.tooltip_message || + i18n.translate('xpack.monitoring.elasticsearch.shardAllocation.shardDisplayName', { + defaultMessage: 'Shard', + }); if (this.state.tooltipVisible) { shardUi = ( - +

{shardUi}

); @@ -114,7 +114,7 @@ export class Shard extends React.Component { onMouseEnter={this.toggle} onMouseLeave={this.toggle} className={classes} - data-shard-tooltip={this.props.shard.tooltip_message} + data-shard-tooltip={tooltipContent} data-shard-classification={classification} data-test-subj="shardIcon" > diff --git a/x-pack/legacy/plugins/monitoring/public/components/table/eui_table_ssp.js b/x-pack/legacy/plugins/monitoring/public/components/table/eui_table_ssp.js index 4d87548cb8ddd8..78e5917c5d9af1 100644 --- a/x-pack/legacy/plugins/monitoring/public/components/table/eui_table_ssp.js +++ b/x-pack/legacy/plugins/monitoring/public/components/table/eui_table_ssp.js @@ -26,6 +26,11 @@ export function EuiMonitoringSSPTable({ index: pagination.pageIndex, size: pagination.pageSize, }); + + if (!pagination.totalItemCount) { + pagination.totalItemCount = (items && items.length) || 0; + } + const [sort, setSort] = React.useState(props.sorting); if (search.box && !search.box['data-test-subj']) {