diff --git a/devtools/.eslintrc.js b/devtools/.eslintrc.js index abcdd402fe4a..7773defa2fde 100644 --- a/devtools/.eslintrc.js +++ b/devtools/.eslintrc.js @@ -200,6 +200,7 @@ module.exports = { "react/prop-types": "error", "react/sort-comp": ["error", { order: [ + "static-methods", "lifecycle", "everything-else", "render" diff --git a/devtools/client/memory/app.js b/devtools/client/memory/app.js index 3387f1ab91a0..14a1f0f96210 100644 --- a/devtools/client/memory/app.js +++ b/devtools/client/memory/app.js @@ -55,7 +55,21 @@ const { app: appModel } = require("./models"); class MemoryApp extends Component { static get propTypes() { - return appModel; + return { + allocations: appModel.allocations, + censusDisplay: appModel.censusDisplay, + diffing: appModel.diffing, + dispatch: appModel.dispatch, + filter: appModel.filter, + front: appModel.front, + heapWorker: appModel.heapWorker, + individuals: appModel.individuals, + labelDisplay: appModel.labelDisplay, + sizes: appModel.sizes, + snapshots: appModel.snapshots, + toolbox: appModel.toolbox, + view: appModel.view, + }; } static get childContextTypes() { diff --git a/devtools/client/shared/components/tree/TreeView.js b/devtools/client/shared/components/tree/TreeView.js index 35e8079930db..6d100ba61f48 100644 --- a/devtools/client/shared/components/tree/TreeView.js +++ b/devtools/client/shared/components/tree/TreeView.js @@ -134,51 +134,6 @@ define(function(require, exports, module) { return defaultProps; } - constructor(props) { - super(props); - - this.state = { - expandedNodes: props.expandedNodes, - columns: ensureDefaultColumn(props.columns), - selected: props.selected, - lastSelectedIndex: 0 - }; - - this.toggle = this.toggle.bind(this); - this.isExpanded = this.isExpanded.bind(this); - this.onKeyDown = this.onKeyDown.bind(this); - this.onClickRow = this.onClickRow.bind(this); - this.getSelectedRow = this.getSelectedRow.bind(this); - this.selectRow = this.selectRow.bind(this); - this.isSelected = this.isSelected.bind(this); - this.onFilter = this.onFilter.bind(this); - this.onSort = this.onSort.bind(this); - this.getMembers = this.getMembers.bind(this); - this.renderRows = this.renderRows.bind(this); - } - - componentWillReceiveProps(nextProps) { - const { expandedNodes, selected } = nextProps; - const state = { - expandedNodes, - lastSelectedIndex: this.getSelectedRowIndex() - }; - - if (selected) { - state.selected = selected; - } - - this.setState(Object.assign({}, this.state, state)); - } - - componentDidUpdate() { - const selected = this.getSelectedRow(); - if (!selected && this.rows.length > 0) { - this.selectRow(this.rows[ - Math.min(this.state.lastSelectedIndex, this.rows.length - 1)]); - } - } - static subPath(path, subKey) { return path + "/" + String(subKey).replace(/[\\/]/g, "\\$&"); } @@ -226,6 +181,51 @@ define(function(require, exports, module) { return expandedNodes; } + constructor(props) { + super(props); + + this.state = { + expandedNodes: props.expandedNodes, + columns: ensureDefaultColumn(props.columns), + selected: props.selected, + lastSelectedIndex: 0 + }; + + this.toggle = this.toggle.bind(this); + this.isExpanded = this.isExpanded.bind(this); + this.onKeyDown = this.onKeyDown.bind(this); + this.onClickRow = this.onClickRow.bind(this); + this.getSelectedRow = this.getSelectedRow.bind(this); + this.selectRow = this.selectRow.bind(this); + this.isSelected = this.isSelected.bind(this); + this.onFilter = this.onFilter.bind(this); + this.onSort = this.onSort.bind(this); + this.getMembers = this.getMembers.bind(this); + this.renderRows = this.renderRows.bind(this); + } + + componentWillReceiveProps(nextProps) { + const { expandedNodes, selected } = nextProps; + const state = { + expandedNodes, + lastSelectedIndex: this.getSelectedRowIndex() + }; + + if (selected) { + state.selected = selected; + } + + this.setState(Object.assign({}, this.state, state)); + } + + componentDidUpdate() { + const selected = this.getSelectedRow(); + if (!selected && this.rows.length > 0) { + this.selectRow(this.rows[ + Math.min(this.state.lastSelectedIndex, this.rows.length - 1)]); + } + } + // Node expand/collapse toggle(nodePath) {