Skip to content

Commit a8a2620

Browse files
committed
Fix usage column error on 3.0 and lower servers (#587)
1 parent 61a4857 commit a8a2620

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

src/internal-packages/indexes/lib/component/usage-column.jsx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
const React = require('react');
22

3+
/**
4+
* No usage stats constant.
5+
*/
6+
const NO_USAGE_STATS = 'Server versions prior to 3.2 do not support $indexStats';
7+
38
/**
49
* Component for the usage column.
510
*/
@@ -14,6 +19,18 @@ class UsageColumn extends React.Component {
1419
super(props);
1520
}
1621

22+
/**
23+
* Render the usage tooltip text.
24+
*
25+
* @returns {String} The tooltip.
26+
*/
27+
tooltip() {
28+
if (this.props.usage) {
29+
return `${this.props.usage} index hits since index creation or last\n server restart`;
30+
}
31+
return NO_USAGE_STATS;
32+
}
33+
1734
/**
1835
* Render the usage column.
1936
*
@@ -23,13 +40,13 @@ class UsageColumn extends React.Component {
2340
return (
2441
<td className="usage-column">
2542
<span className="usage">
26-
<div className="quantity" title={`${this.props.usage} index hits since index creation or last\n server restart`}>
27-
{this.props.usage}
43+
<div className="quantity" title={this.tooltip()}>
44+
{this.props.usage || 'N/A'}
2845
</div>
2946
<div className="usage-since">
3047
since&nbsp;
3148
<span>
32-
{this.props.since.toDateString()}
49+
{this.props.since ? this.props.since.toDateString() : 'N/A'}
3350
</span>
3451
</div>
3552
</span>
@@ -41,8 +58,8 @@ class UsageColumn extends React.Component {
4158
UsageColumn.displayUsage = 'UsageColumn';
4259

4360
UsageColumn.propTypes = {
44-
usage: React.PropTypes.number.isRequired,
45-
since: React.PropTypes.any.isRequired
61+
usage: React.PropTypes.any,
62+
since: React.PropTypes.any
4663
};
4764

4865
module.exports = UsageColumn;

0 commit comments

Comments
 (0)