1
1
const React = require ( 'react' ) ;
2
2
3
+ /**
4
+ * No usage stats constant.
5
+ */
6
+ const NO_USAGE_STATS = 'Server versions prior to 3.2 do not support $indexStats' ;
7
+
3
8
/**
4
9
* Component for the usage column.
5
10
*/
@@ -14,6 +19,18 @@ class UsageColumn extends React.Component {
14
19
super ( props ) ;
15
20
}
16
21
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
+
17
34
/**
18
35
* Render the usage column.
19
36
*
@@ -23,13 +40,13 @@ class UsageColumn extends React.Component {
23
40
return (
24
41
< td className = "usage-column" >
25
42
< 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' }
28
45
</ div >
29
46
< div className = "usage-since" >
30
47
since
31
48
< span >
32
- { this . props . since . toDateString ( ) }
49
+ { this . props . since ? this . props . since . toDateString ( ) : 'N/A' }
33
50
</ span >
34
51
</ div >
35
52
</ span >
@@ -41,8 +58,8 @@ class UsageColumn extends React.Component {
41
58
UsageColumn . displayUsage = 'UsageColumn' ;
42
59
43
60
UsageColumn . propTypes = {
44
- usage : React . PropTypes . number . isRequired ,
45
- since : React . PropTypes . any . isRequired
61
+ usage : React . PropTypes . any ,
62
+ since : React . PropTypes . any
46
63
} ;
47
64
48
65
module . exports = UsageColumn ;
0 commit comments