Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions src/internal-packages/indexes/lib/component/usage-column.jsx
Original file line number Diff line number Diff line change
@@ -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.
*/
Expand All @@ -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.
*
Expand All @@ -23,13 +40,13 @@ class UsageColumn extends React.Component {
return (
<td className="usage-column">
<span className="usage">
<div className="quantity" title={`${this.props.usage} index hits since index creation or last\n server restart`}>
{this.props.usage}
<div className="quantity" title={this.tooltip()}>
{this.props.usage || 'N/A'}
</div>
<div className="usage-since">
since&nbsp;
<span>
{this.props.since.toDateString()}
{this.props.since ? this.props.since.toDateString() : 'N/A'}
</span>
</div>
</span>
Expand All @@ -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;