From 5d944ccf7fe3dae540aaed8b8e96ca7aa2823aa2 Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Sun, 13 Nov 2016 15:42:41 +0100 Subject: [PATCH] Fix usage column error on 3.0 and lower servers --- .../indexes/lib/component/usage-column.jsx | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/internal-packages/indexes/lib/component/usage-column.jsx b/src/internal-packages/indexes/lib/component/usage-column.jsx index c500cd0d02e..35a6cd1c8d4 100644 --- a/src/internal-packages/indexes/lib/component/usage-column.jsx +++ b/src/internal-packages/indexes/lib/component/usage-column.jsx @@ -1,5 +1,10 @@ const React = require('react'); +/** + * No usage stats constant. + */ +const NO_USAGE_STATS = 'Server versions prior to 3.2 do not support $indexStats'; + /** * Component for the usage column. */ @@ -14,6 +19,18 @@ class UsageColumn extends React.Component { super(props); } + /** + * Render the usage tooltip text. + * + * @returns {String} The tooltip. + */ + tooltip() { + if (this.props.usage) { + return `${this.props.usage} index hits since index creation or last\n server restart`; + } + return NO_USAGE_STATS; + } + /** * Render the usage column. * @@ -23,13 +40,13 @@ class UsageColumn extends React.Component { return ( -
- {this.props.usage} +
+ {this.props.usage || 'N/A'}
since  - {this.props.since.toDateString()} + {this.props.since ? this.props.since.toDateString() : 'N/A'}
@@ -41,8 +58,8 @@ class UsageColumn extends React.Component { UsageColumn.displayUsage = 'UsageColumn'; UsageColumn.propTypes = { - usage: React.PropTypes.number.isRequired, - since: React.PropTypes.any.isRequired + usage: React.PropTypes.any, + since: React.PropTypes.any }; module.exports = UsageColumn;