diff --git a/package.json b/package.json index 38b12f77027..a03ac54cf75 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "start": "hadron-build develop", "pretest": "mongodb-runner install", "test": "xvfb-maybe hadron-build test", - "check": "mongodb-js-precommit ./src/app/*.js ./src/app/**/**/*.js ./src/{app/**/*.js,main/**/*.js} ./test/*.js", + "check": "mongodb-js-precommit ./src/app/*.js ./src/app/**/**/*.js ./src/{app/**/*.js,main/**/*.js} ./test/*.js ./src/internal-packages/**/*.js ./src/internal-packages/**/**/*{.js,.jsx} ./src/internal-packages/**/**/**/*{.js,.jsx} ./src/internal-packages/**/**/**/**/*{.js,.jsx}", "ci": "npm run check && npm run test-unit", "clean": "hadron-build clean", "compile-ui": "hadron-build ui", diff --git a/src/internal-packages/crud/index.js b/src/internal-packages/crud/index.js index dd12364b1ee..9c5cabdd974 100644 --- a/src/internal-packages/crud/index.js +++ b/src/internal-packages/crud/index.js @@ -1,5 +1,3 @@ -'use strict'; - const app = require('ampersand-app'); const Document = require('./lib/component/document'); const DocumentList = require('./lib/component/document-list'); diff --git a/src/internal-packages/crud/lib/actions.js b/src/internal-packages/crud/lib/actions.js index 4ddd3f84356..90351033582 100644 --- a/src/internal-packages/crud/lib/actions.js +++ b/src/internal-packages/crud/lib/actions.js @@ -1,5 +1,3 @@ -'use strict'; - const Reflux = require('reflux'); const Actions = Reflux.createActions([ diff --git a/src/internal-packages/crud/lib/component/binary-value.jsx b/src/internal-packages/crud/lib/component/binary-value.jsx index 2249b89a344..653175bf597 100644 --- a/src/internal-packages/crud/lib/component/binary-value.jsx +++ b/src/internal-packages/crud/lib/component/binary-value.jsx @@ -1,5 +1,3 @@ -'use strict'; - const React = require('react'); const truncate = require('hadron-app-registry').truncate; @@ -35,7 +33,21 @@ class BinaryValue extends React.Component { */ constructor(props) { super(props); - this.value = props.element.currentValue; + this.element = props.element; + } + + /** + * Render the value. + * + * @returns {Component} The component. + */ + renderValue() { + const type = this.element.currentValue.sub_type; + const buffer = this.element.currentValue.buffer; + if (type === UUID || type === UUID_OLD) { + return `Binary('${truncate(buffer.toString())}')`; + } + return `Binary('${truncate(buffer.toString(BASE_64))}')`; } /** @@ -50,22 +62,12 @@ class BinaryValue extends React.Component { ); } - - /** - * Render the value. - * - * @returns {Component} The component. - */ - renderValue() { - var type = this.value.sub_type; - var buffer = this.value.buffer; - if (type === UUID || type === UUID_OLD) { - return `Binary('${truncate(buffer.toString())}')`; - } - return `Binary('${truncate(buffer.toString(BASE_64))}')`; - } } BinaryValue.displayName = 'BinaryValue'; +BinaryValue.propTypes = { + element: React.PropTypes.object.isRequired +}; + module.exports = BinaryValue; diff --git a/src/internal-packages/crud/lib/component/code-value.jsx b/src/internal-packages/crud/lib/component/code-value.jsx index 7463aab1536..eba854ee096 100644 --- a/src/internal-packages/crud/lib/component/code-value.jsx +++ b/src/internal-packages/crud/lib/component/code-value.jsx @@ -1,5 +1,3 @@ -'use strict'; - const React = require('react'); const truncate = require('hadron-app-registry').truncate; @@ -20,7 +18,7 @@ class CodeValue extends React.Component { */ constructor(props) { super(props); - this.value = props.element.currentValue; + this.element = props.element; } /** @@ -31,7 +29,7 @@ class CodeValue extends React.Component { render() { return (
-
- {this.props.index.name}
-
-
-
- - {fields} - - |
- );
- }
-
/**
* Render the direction of the index field.
*
@@ -50,23 +16,22 @@ class NameColumn extends React.Component {
renderDirection(field) {
if (field.value === 1) {
return (
-
-
+
+
);
} else if (field.value === -1) {
return (
-
-
-
- );
- } else {
- return (
-
- {field.value}
+
+
);
}
+ return (
+
+ {field.value}
+
+ );
}
/**
@@ -78,14 +43,37 @@ class NameColumn extends React.Component {
*/
renderField(field) {
return (
-
-
+
+
{field.field}
{this.renderDirection(field)}
);
}
+
+ /**
+ * Render the name column.
+ *
+ * @returns {React.Component} The name column.
+ */
+ render() {
+ const fields = _.map(this.props.index.fields.serialize(), (field) => {
+ return this.renderField(field);
+ });
+ return (
+
+
+ {this.props.index.name}
+
+
+
+ + {fields} + + |
+ );
+ }
}
NameColumn.displayName = 'NameColumn';
diff --git a/src/internal-packages/indexes/lib/component/property-column.jsx b/src/internal-packages/indexes/lib/component/property-column.jsx
index d9935ffeb58..c939a47a2f0 100644
--- a/src/internal-packages/indexes/lib/component/property-column.jsx
+++ b/src/internal-packages/indexes/lib/component/property-column.jsx
@@ -1,5 +1,3 @@
-'use strict';
-
const _ = require('lodash');
const format = require('util').format;
const React = require('react');
@@ -10,23 +8,22 @@ const openIndexHelpLink = require('../index-link-helper');
*/
class PropertyColumn extends React.Component {
- /**
- * Render the property column.
- *
- * @returns {React.Component} The property column.
- */
- render() {
- let properties = _.map(this.props.index.properties, (prop) => {
- return this.renderProperty(prop);
- });
- return (
-
-
- {properties}
- {this.renderCardinality()}
-
- |
- );
+ _clickHelp(evt) {
+ evt.preventDefault();
+ evt.stopPropagation();
+ openIndexHelpLink(evt.target.parentNode.innerText);
+ }
+
+ _link() {
+ return ();
+ }
+
+ _partialTooltip() {
+ return format('partialFilterExpression: %j', this.props.index.extra.partialFilterExpression);
+ }
+
+ _ttlTooltip() {
+ return format('expireAfterSeconds: %d', this.props.index.extra.expireAfterSeconds);
}
/**
@@ -37,7 +34,7 @@ class PropertyColumn extends React.Component {
renderCardinality() {
if (this.props.index.cardinality === 'compound') {
return (
-
+
+ {properties}
+ {this.renderCardinality()}
+
+ |
+ );
}
- _ttlTooltip() {
- return format('expireAfterSeconds: %d', this.props.index.extra.expireAfterSeconds);
- }
}
PropertyColumn.displayProperty = 'PropertyColumn';
diff --git a/src/internal-packages/indexes/lib/component/size-column.jsx b/src/internal-packages/indexes/lib/component/size-column.jsx
index ad54eee1b4f..4ecc5972836 100644
--- a/src/internal-packages/indexes/lib/component/size-column.jsx
+++ b/src/internal-packages/indexes/lib/component/size-column.jsx
@@ -1,5 +1,3 @@
-'use strict';
-
const React = require('react');
const numeral = require('numeral');
@@ -8,13 +6,9 @@ const numeral = require('numeral');
*/
class SizeColumn extends React.Component {
- /**
- * The component constructor.
- *
- * @param {Object} props - The properties.
- */
- constructor(props) {
- super(props);
+ _format(size) {
+ const precision = size <= 1000 ? '0' : '0.0';
+ return numeral(size).format(precision + ' b');
}
/**
@@ -23,27 +17,22 @@ class SizeColumn extends React.Component {
* @returns {React.Component} The size column.
*/
render() {
- let indexSize = this._format(this.props.size).split(' ');
+ const indexSize = this._format(this.props.size).split(' ');
return (
-
-
+
+ |
);
}
-
- _format(size) {
- let precision = size <= 1000 ? '0' : '0.0';
- return numeral(size).format(precision + ' b');
- }
}
SizeColumn.displaySize = 'SizeColumn';
diff --git a/src/internal-packages/indexes/lib/component/type-column.jsx b/src/internal-packages/indexes/lib/component/type-column.jsx
index 95a0b472200..25cffaa2166 100644
--- a/src/internal-packages/indexes/lib/component/type-column.jsx
+++ b/src/internal-packages/indexes/lib/component/type-column.jsx
@@ -1,6 +1,5 @@
-'use strict';
-
const _ = require('lodash');
+const format = require('util').format;
const React = require('react');
const openIndexHelpLink = require('../index-link-helper');
@@ -9,21 +8,27 @@ const openIndexHelpLink = require('../index-link-helper');
*/
class TypeColumn extends React.Component {
- /**
- * Render the type column.
- *
- * @returns {React.Component} The type column.
- */
- render() {
- return (
-
{indexSize[0]}
-
+
{indexSize[1]}
-
-
+
+
- {this.renderType()}
- |
- );
+ _clickHelp(evt) {
+ evt.preventDefault();
+ evt.stopPropagation();
+ openIndexHelpLink(evt.target.parentNode.innerText);
+ }
+
+ _link() {
+ return ();
+ }
+
+ _textTooltip() {
+ const info = _.pick(this.props.index.extra, ['weights', 'default_language', 'language_override']);
+ return _.map(info, (v, k) => {
+ return format('%s: %j', k, v);
+ }).join('\n');
}
/**
* Render the type div.
+ *
+ * @returns {React.Component} The type div.
*/
renderType() {
if (this.props.index.type === 'text') {
@@ -42,21 +47,17 @@ class TypeColumn extends React.Component {
);
}
- _clickHelp(evt) {
- evt.preventDefault();
- evt.stopPropagation();
- openIndexHelpLink(evt.target.parentNode.innerText);
- }
-
- _link() {
- return ();
- }
-
- _textTooltip() {
- let info = _.pick(this.props.index.extra, ['weights', 'default_language', 'language_override']);
- return _.map(info, (v, k) => {
- return format('%s: %j', k, v);
- }).join('\n');
+ /**
+ * Render the type column.
+ *
+ * @returns {React.Component} The type column.
+ */
+ render() {
+ return (
+
+ {this.renderType()}
+ |
+ );
}
}
diff --git a/src/internal-packages/indexes/lib/component/usage-column.jsx b/src/internal-packages/indexes/lib/component/usage-column.jsx
index 2b42114155f..c500cd0d02e 100644
--- a/src/internal-packages/indexes/lib/component/usage-column.jsx
+++ b/src/internal-packages/indexes/lib/component/usage-column.jsx
@@ -1,5 +1,3 @@
-'use strict';
-
const React = require('react');
/**
@@ -23,12 +21,12 @@ class UsageColumn extends React.Component {
*/
render() {
return (
-
-
- |
+
+
+ |
{this.props.usage}
-
+
since
{this.props.since.toDateString()}
@@ -43,7 +41,8 @@ class UsageColumn extends React.Component {
UsageColumn.displayUsage = 'UsageColumn';
UsageColumn.propTypes = {
- usage: React.PropTypes.number.isRequired
+ usage: React.PropTypes.number.isRequired,
+ since: React.PropTypes.any.isRequired
};
module.exports = UsageColumn;
diff --git a/src/internal-packages/indexes/lib/index-link-helper.js b/src/internal-packages/indexes/lib/index-link-helper.js
index c7fcb7ce180..58fda227850 100644
--- a/src/internal-packages/indexes/lib/index-link-helper.js
+++ b/src/internal-packages/indexes/lib/index-link-helper.js
@@ -1,5 +1,3 @@
-'use strict';
-
const _ = require('lodash');
const shell = require('electron').shell;
@@ -26,7 +24,7 @@ const HELP_URLS = {
* @param {String} section - The name of the section to open.
*/
function openIndexHelpLink(section) {
- let url = _.get(HELP_URLS, section, 'UNKNOWN');
+ const url = _.get(HELP_URLS, section, 'UNKNOWN');
if (url) {
shell.openExternal(url);
}
diff --git a/src/internal-packages/indexes/lib/store/load-indexes-store.js b/src/internal-packages/indexes/lib/store/load-indexes-store.js
index a210c0c0706..d6714875eab 100644
--- a/src/internal-packages/indexes/lib/store/load-indexes-store.js
+++ b/src/internal-packages/indexes/lib/store/load-indexes-store.js
@@ -1,5 +1,3 @@
-'use strict';
-
const _ = require('lodash');
const Reflux = require('reflux');
const app = require('ampersand-app');
@@ -25,7 +23,9 @@ const LoadIndexesStore = Reflux.createStore({
loadIndexes: function() {
if (NamespaceStore.ns) {
app.dataService.indexes(NamespaceStore.ns, {}, (err, indexes) => {
- this.trigger(this._convertToModels(indexes));
+ if (!err) {
+ this.trigger(this._convertToModels(indexes));
+ }
});
}
},
@@ -38,9 +38,9 @@ const LoadIndexesStore = Reflux.createStore({
* @returns {Array} The index models.
*/
_convertToModels(indexes) {
- let maxSize = this._computeMaxSize(indexes);
+ const maxSize = this._computeMaxSize(indexes);
return _.map(indexes, (index) => {
- let model = new IndexModel(new IndexModel().parse(index));
+ const model = new IndexModel(new IndexModel().parse(index));
model.relativeSize = model.size / maxSize * 100;
return model;
});
diff --git a/src/internal-packages/indexes/lib/store/sort-indexes-store.js b/src/internal-packages/indexes/lib/store/sort-indexes-store.js
index 5555b6fb813..4d88bcae087 100644
--- a/src/internal-packages/indexes/lib/store/sort-indexes-store.js
+++ b/src/internal-packages/indexes/lib/store/sort-indexes-store.js
@@ -1,5 +1,3 @@
-'use strict';
-
const Reflux = require('reflux');
const Action = require('../action/index-actions');
const LoadIndexesStore = require('./load-indexes-store');
@@ -65,7 +63,7 @@ const SortIndexesStore = Reflux.createStore({
* @returns {Function} The function.
*/
_comparator(field) {
- let order = (this.sortOrder === ASC) ? 1 : -1;
+ const order = (this.sortOrder === ASC) ? 1 : -1;
if (field === 'properties') {
return this._propertiesComparator(order);
}
@@ -77,7 +75,7 @@ const SortIndexesStore = Reflux.createStore({
return -order;
}
return 0;
- }
+ };
},
/**
@@ -89,8 +87,8 @@ const SortIndexesStore = Reflux.createStore({
*/
_propertiesComparator(order) {
return function(a, b) {
- let aValue = (a.cardinality === 'compound') ? 'compound' : (a.properties[0] || '');
- let bValue = (b.cardinality === 'compound') ? 'compound' : (b.properties[0] || '');
+ const aValue = (a.cardinality === 'compound') ? 'compound' : (a.properties[0] || '');
+ const bValue = (b.cardinality === 'compound') ? 'compound' : (b.properties[0] || '');
if (aValue > bValue) {
return order;
}
@@ -98,7 +96,7 @@ const SortIndexesStore = Reflux.createStore({
return -order;
}
return 0;
- }
+ };
},
/**
@@ -111,9 +109,8 @@ const SortIndexesStore = Reflux.createStore({
return 'name';
} else if (this.sortField === USAGE) {
return 'usageCount';
- } else {
- return this.sortField.toLowerCase();
}
+ return this.sortField.toLowerCase();
}
});
diff --git a/src/internal-packages/query/lib/component/sampling-message.jsx b/src/internal-packages/query/lib/component/sampling-message.jsx
index b626a17f3f0..1fc8adc0281 100644
--- a/src/internal-packages/query/lib/component/sampling-message.jsx
+++ b/src/internal-packages/query/lib/component/sampling-message.jsx
@@ -1,5 +1,3 @@
-'use strict';
-
const React = require('react');
const app = require('ampersand-app');
const TextButton = require('hadron-app-registry').TextButton;
@@ -11,6 +9,20 @@ const pluralize = require('pluralize');
*/
class SamplingMessage extends React.Component {
+ /**
+ * The component constructor.
+ *
+ * @param {Object} props - The properties.
+ */
+ constructor(props) {
+ super(props);
+ this.state = { count: 0, loaded: 20 };
+ this.resetDocumentListStore = app.appRegistry.getStore('Store::CRUD::ResetDocumentListStore');
+ this.insertDocumentStore = app.appRegistry.getStore('Store::CRUD::InsertDocumentStore');
+ this.documentRemovedAction = app.appRegistry.getAction('Action::CRUD::DocumentRemoved');
+ this.loadMoreDocumentsStore = app.appRegistry.getStore('Store::CRUD::LoadMoreDocumentsStore');
+ }
+
/**
* Fetch the state when the component mounts.
*/
@@ -21,6 +33,20 @@ class SamplingMessage extends React.Component {
this.unsubscribeLoadMore = this.loadMoreDocumentsStore.listen(this.handleLoadMore.bind(this));
}
+ /**
+ * Only update when the count changes.
+ *
+ * @param {Object} nextProps - The next properties.
+ * @param {Object} nextState - The next state.
+ *
+ * @returns {Boolean} If the component should update.
+ */
+ shouldComponentUpdate(nextProps, nextState) {
+ return (nextState.count !== this.state.count) ||
+ (nextState.loaded !== this.state.loaded) ||
+ (nextProps.sampleSize !== this.props.sampleSize);
+ }
+
/**
* Unsibscribe from the document list store when unmounting.
*/
@@ -31,22 +57,10 @@ class SamplingMessage extends React.Component {
this.unsubscribeLoadMore();
}
- /**
- * The component constructor.
- *
- * @param {Object} props - The properties.
- */
- constructor(props) {
- super(props);
- this.state = { count: 0, loaded: 20 };
- this.resetDocumentListStore = app.appRegistry.getStore('Store::CRUD::ResetDocumentListStore');
- this.insertDocumentStore = app.appRegistry.getStore('Store::CRUD::InsertDocumentStore');
- this.documentRemovedAction = app.appRegistry.getAction('Action::CRUD::DocumentRemoved');
- this.loadMoreDocumentsStore = app.appRegistry.getStore('Store::CRUD::LoadMoreDocumentsStore');
- }
-
/**
* Handle updating the count on document insert.
+ *
+ * @param {Boolean} success - If the insert succeeded.
*/
handleInsert(success) {
if (success) {
@@ -80,16 +94,20 @@ class SamplingMessage extends React.Component {
this.setState({ loaded: this.state.loaded + documents.length });
}
- /**
- * Render the sampling message.
- *
- * @returns {React.Component} The document list.
- */
- render() {
- if (this.props.insertHandler) {
- return this.renderQueryMessage();
+
+ _loadedMessage() {
+ if (this.state.count > 20) {
+ return (
+
+ Displaying documents 1-{this.state.loaded}
+
+ );
}
- return this.renderSamplingMessage();
+ }
+
+ _samplePercentage() {
+ const percent = (this.state.count === 0) ? 0 : this.props.sampleSize / this.state.count;
+ return numeral(percent).format('0.00%');
}
/**
@@ -98,14 +116,14 @@ class SamplingMessage extends React.Component {
* @returns {React.Component} The sampling message.
*/
renderSamplingMessage() {
- var noun = pluralize('document', this.state.count);
+ const noun = pluralize('document', this.state.count);
return (
-
+
Query returned
{this.state.count} {noun}.
This report is based on a sample of
{this.props.sampleSize} {noun} ({this._samplePercentage()}).
-
+
);
}
@@ -116,44 +134,37 @@ class SamplingMessage extends React.Component {
* @returns {React.Component} The count message.
*/
renderQueryMessage() {
- var noun = pluralize('document', this.state.count);
+ const noun = pluralize('document', this.state.count);
return (
-
+
Query returned {this.state.count} {noun}.
{this._loadedMessage()}
);
}
/**
- * Only update when the count changes.
+ * Render the sampling message.
+ *
+ * @returns {React.Component} The document list.
*/
- shouldComponentUpdate(nextProps, nextState) {
- return (nextState.count !== this.state.count) ||
- (nextState.loaded != this.state.loaded) ||
- (nextProps.sampleSize !== this.props.sampleSize);
- }
-
- _loadedMessage() {
- if (this.state.count > 20) {
- return (
-
- Displaying documents 1-{this.state.loaded}
-
- );
+ render() {
+ if (this.props.insertHandler) {
+ return this.renderQueryMessage();
}
- }
-
- _samplePercentage() {
- var percent = (this.state.count === 0) ? 0 : this.props.sampleSize / this.state.count;
- return numeral(percent).format('0.00%');
+ return this.renderSamplingMessage();
}
}
SamplingMessage.displayName = 'SamplingMessage';
+SamplingMessage.propTypes = {
+ sampleSize: React.PropTypes.number,
+ insertHandler: React.PropTypes.func
+};
+
module.exports = SamplingMessage;
diff --git a/src/internal-packages/schema/index.js b/src/internal-packages/schema/index.js
index 010935e4532..9bfaec9df93 100644
--- a/src/internal-packages/schema/index.js
+++ b/src/internal-packages/schema/index.js
@@ -1,5 +1,3 @@
-'use strict';
-
const app = require('ampersand-app');
const SchemaComponent = require('./lib/component');
const SchemaAction = require('./lib/action');
diff --git a/src/internal-packages/schema/lib/component/document.jsx b/src/internal-packages/schema/lib/component/document.jsx
index 049128b95ee..cd9536d0741 100644
--- a/src/internal-packages/schema/lib/component/document.jsx
+++ b/src/internal-packages/schema/lib/component/document.jsx
@@ -2,8 +2,6 @@ const React = require('react');
const pluralize = require('pluralize');
const _ = require('lodash');
-const debug = require('debug')('mongodb-compass:schema:array');
-
const DocumentMinichart = React.createClass({
propTypes: {
diff --git a/src/internal-packages/schema/lib/d3/coordinates.js b/src/internal-packages/schema/lib/d3/coordinates.js
index 1e99bd8d0cf..e442e3f7400 100644
--- a/src/internal-packages/schema/lib/d3/coordinates.js
+++ b/src/internal-packages/schema/lib/d3/coordinates.js
@@ -55,7 +55,7 @@ const minicharts_d3fns_geo = function() {
// const project = d3.geo.mercator();
// const unproject = d3.geo.mercator().invert;
- let update;
+ const update = null;
function querybuilder() {
if (circleCenter && circleOuter) {
diff --git a/src/internal-packages/schema/lib/d3/d3-tip.js b/src/internal-packages/schema/lib/d3/d3-tip.js
index d84c2514f9d..9c9cf52d8c1 100644
--- a/src/internal-packages/schema/lib/d3/d3-tip.js
+++ b/src/internal-packages/schema/lib/d3/d3-tip.js
@@ -20,13 +20,13 @@
//
// Returns a tip
return function() {
- var direction = d3_tip_direction;
- var offset = d3_tip_offset;
- var html = d3_tip_html;
- var node = initNode();
- var svg = null;
- var point = null;
- var target = null;
+ const direction = d3_tip_direction;
+ const offset = d3_tip_offset;
+ const html = d3_tip_html;
+ const node = initNode();
+ let svg = null;
+ let point = null;
+ let target = null;
function tip(vis) {
svg = getSVGNode(vis);
@@ -41,17 +41,17 @@
//
// Returns a tip
tip.show = function() {
- var args = Array.prototype.slice.call(arguments);
+ const args = Array.prototype.slice.call(arguments);
if (args[args.length - 1] instanceof SVGElement) {
target = args.pop();
}
- var content = html.apply(this, args),
+ const content = html.apply(this, args),
poffset = offset.apply(this, args),
dir = direction.apply(this, args),
nodel = getNodeEl(),
i = directions.length,
- coords,
+ coords = null,
scrollTop = document.documentElement.scrollTop || document.body.scrollTop,
scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
@@ -77,7 +77,7 @@
//
// Returns a tip
tip.hide = function() {
- var nodel = getNodeEl();
+ const nodel = getNodeEl();
nodel.style({
opacity: 0,
'pointer-events': 'none'
@@ -95,7 +95,7 @@
if (arguments.length < 2 && typeof n === 'string') {
return getNodeEl().attr(n);
} else {
- var args = Array.prototype.slice.call(arguments);
+ const args = Array.prototype.slice.call(arguments);
d3.selection.prototype.attr.apply(getNodeEl(), args);
}
@@ -112,7 +112,7 @@
if (arguments.length < 2 && typeof n === 'string') {
return getNodeEl().style(n);
} else {
- var args = Array.prototype.slice.call(arguments);
+ const args = Array.prototype.slice.call(arguments);
d3.selection.prototype.style.apply(getNodeEl(), args);
}
@@ -183,7 +183,7 @@
return ' ';
}
- var direction_callbacks = d3.map({
+ const direction_callbacks = d3.map({
n: direction_n,
s: direction_s,
e: direction_e,
@@ -197,7 +197,7 @@
directions = direction_callbacks.keys();
function direction_n() {
- var bbox = getScreenBBox();
+ const bbox = getScreenBBox();
return {
top: bbox.n.y - node.offsetHeight,
left: bbox.n.x - node.offsetWidth / 2
@@ -205,7 +205,7 @@
}
function direction_s() {
- var bbox = getScreenBBox();
+ const bbox = getScreenBBox();
return {
top: bbox.s.y,
left: bbox.s.x - node.offsetWidth / 2
@@ -213,7 +213,7 @@
}
function direction_e() {
- var bbox = getScreenBBox();
+ const bbox = getScreenBBox();
return {
top: bbox.e.y - node.offsetHeight / 2,
left: bbox.e.x
@@ -221,7 +221,7 @@
}
function direction_w() {
- var bbox = getScreenBBox();
+ const bbox = getScreenBBox();
return {
top: bbox.w.y - node.offsetHeight / 2,
left: bbox.w.x - node.offsetWidth
@@ -229,7 +229,7 @@
}
function direction_nw() {
- var bbox = getScreenBBox();
+ const bbox = getScreenBBox();
return {
top: bbox.nw.y - node.offsetHeight,
left: bbox.nw.x - node.offsetWidth
@@ -237,7 +237,7 @@
}
function direction_ne() {
- var bbox = getScreenBBox();
+ const bbox = getScreenBBox();
return {
top: bbox.ne.y - node.offsetHeight,
left: bbox.ne.x
@@ -245,7 +245,7 @@
}
function direction_sw() {
- var bbox = getScreenBBox();
+ const bbox = getScreenBBox();
return {
top: bbox.sw.y,
left: bbox.sw.x - node.offsetWidth
@@ -253,7 +253,7 @@
}
function direction_se() {
- var bbox = getScreenBBox();
+ const bbox = getScreenBBox();
return {
top: bbox.se.y,
left: bbox.e.x
@@ -261,7 +261,7 @@
}
function initNode() {
- var node = d3.select(document.createElement('div'));
+ const node = d3.select(document.createElement('div'));
node.style({
position: 'absolute',
top: 0,
@@ -308,13 +308,13 @@
//
// Returns an Object {n, s, e, w, nw, sw, ne, se}
function getScreenBBox() {
- var targetel = target || d3.event.target;
+ const targetel = target || d3.event.target;
while ('undefined' === typeof targetel.getScreenCTM && 'undefined' === targetel.parentNode) {
targetel = targetel.parentNode;
}
- var bbox = {},
+ const bbox = {},
matrix = targetel.getScreenCTM(),
tbbox = targetel.getBBox(),
width = tbbox.width,
diff --git a/src/internal-packages/schema/lib/d3/shared.js b/src/internal-packages/schema/lib/d3/shared.js
index 1d039bad895..166ec6e5cff 100644
--- a/src/internal-packages/schema/lib/d3/shared.js
+++ b/src/internal-packages/schema/lib/d3/shared.js
@@ -1,12 +1,12 @@
/* eslint camelcase: 0 */
-var d3 = require('d3');
+const d3 = require('d3');
// source: http://bit.ly/1Tc9Tp5
function decimalPlaces(number) {
return ((+number).toFixed(20)).replace(/^-?\d*\.?|0+$/g, '').length;
}
-var minicharts_d3fns_shared = {
+const minicharts_d3fns_shared = {
margin: {
top: 10,
@@ -16,11 +16,11 @@ var minicharts_d3fns_shared = {
},
friendlyPercentFormat: function(vmax) {
- var prec1Format = d3.format('.1r');
- var intFormat = d3.format('.0f');
- var format = vmax > 1 ? intFormat : prec1Format;
- var maxFormatted = format(vmax);
- var maxDecimals = decimalPlaces(maxFormatted);
+ const prec1Format = d3.format('.1r');
+ const intFormat = d3.format('.0f');
+ const format = vmax > 1 ? intFormat : prec1Format;
+ const maxFormatted = format(vmax);
+ const maxDecimals = decimalPlaces(maxFormatted);
return function(v, incPrec) {
if (v === vmax) {
diff --git a/src/internal-packages/server-stats/lib/d3/stats-chart.js b/src/internal-packages/server-stats/lib/d3/stats-chart.js
index 201876ff935..4ba253da7c2 100644
--- a/src/internal-packages/server-stats/lib/d3/stats-chart.js
+++ b/src/internal-packages/server-stats/lib/d3/stats-chart.js
@@ -1,5 +1,6 @@
const d3 = require('d3');
-// const debug = require('debug')('mongodb-compass:server-stats-chart');
+
+/* eslint complexity:0 */
const graphfunction = function() {
let width = 520;
@@ -125,12 +126,11 @@ const graphfunction = function() {
}
errorState = true;
return;
- } else {
- if (errorState) {
- errorState = false;
- container.selectAll('rect.error-overlay').remove();
- container.selectAll('text.error-message').remove();
- }
+ }
+ if (errorState) {
+ errorState = false;
+ container.selectAll('rect.error-overlay').remove();
+ container.selectAll('text.error-message').remove();
}
// Redraw anything hidden by errors
container.selectAll('.legend, .overlay, .axis-labels, .line-div')
diff --git a/src/internal-packages/status/index.js b/src/internal-packages/status/index.js
index 5e2773a2db3..416300a4901 100644
--- a/src/internal-packages/status/index.js
+++ b/src/internal-packages/status/index.js
@@ -1,5 +1,3 @@
-'use strict';
-
const app = require('ampersand-app');
const StatusComponent = require('./lib/component');
const StatusAction = require('./lib/action');
|