Created
February 26, 2018 15:26
-
-
Save MikeRatcliffe/27ef8c9e5988ae7ba935df8a539be8f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
render() { | |
let { | |
dispatch, | |
snapshots, | |
front, | |
heapWorker, | |
allocations, | |
toolbox, | |
filter, | |
diffing, | |
view, | |
sizes, | |
censusDisplay, | |
labelDisplay, | |
individuals, | |
} = this.props; | |
const selectedSnapshot = snapshots.find(s => s.selected); | |
const onClickSnapshotListItem = diffing && diffing.state === diffingState.SELECTING | |
? snapshot => dispatch(selectSnapshotForDiffingAndRefresh(heapWorker, snapshot)) | |
: snapshot => dispatch(selectSnapshotAndRefresh(heapWorker, snapshot.id)); | |
return ( | |
dom.div( | |
{ | |
id: "memory-tool" | |
}, | |
Toolbar({ | |
snapshots, | |
censusDisplays: this._getCensusDisplays(), | |
censusDisplay, | |
onCensusDisplayChange: newDisplay => | |
dispatch(setCensusDisplayAndRefresh(heapWorker, newDisplay)), | |
onImportClick: () => dispatch(pickFileAndImportSnapshotAndCensus(heapWorker)), | |
onClearSnapshotsClick: () => dispatch(clearSnapshots(heapWorker)), | |
onTakeSnapshotClick: () => dispatch(takeSnapshotAndCensus(front, heapWorker)), | |
onToggleRecordAllocationStacks: () => | |
dispatch(toggleRecordingAllocationStacks(front)), | |
allocations, | |
filterString: filter, | |
setFilterString: filterString => | |
dispatch(setFilterStringAndRefresh(filterString, heapWorker)), | |
diffing, | |
onToggleDiffing: () => dispatch(toggleDiffing()), | |
view, | |
labelDisplays: this._getLabelDisplays(), | |
labelDisplay, | |
onLabelDisplayChange: newDisplay => | |
dispatch(setLabelDisplayAndRefresh(heapWorker, newDisplay)), | |
treeMapDisplays: this._getTreeMapDisplays(), | |
onTreeMapDisplayChange: newDisplay => | |
dispatch(setTreeMapDisplayAndRefresh(heapWorker, newDisplay)), | |
onViewChange: v => dispatch(changeViewAndRefresh(v, heapWorker)), | |
}), | |
dom.div( | |
{ | |
id: "memory-tool-container" | |
}, | |
List({ | |
itemComponent: SnapshotListItem, | |
items: snapshots, | |
onSave: snapshot => dispatch(pickFileAndExportSnapshot(snapshot)), | |
onDelete: snapshot => dispatch(deleteSnapshot(heapWorker, snapshot)), | |
onClick: onClickSnapshotListItem, | |
diffing, | |
}), | |
Heap({ | |
snapshot: selectedSnapshot, | |
diffing, | |
onViewSourceInDebugger: frame => | |
toolbox.viewSourceInDebugger(frame.source, frame.line), | |
onSnapshotClick: () => | |
dispatch(takeSnapshotAndCensus(front, heapWorker)), | |
onLoadMoreSiblings: lazyChildren => | |
dispatch(fetchImmediatelyDominated(heapWorker, | |
selectedSnapshot.id, | |
lazyChildren)), | |
onPopView: () => dispatch(popViewAndRefresh(heapWorker)), | |
individuals, | |
onViewIndividuals: node => { | |
const snapshotId = diffing | |
? diffing.secondSnapshotId | |
: selectedSnapshot.id; | |
dispatch(fetchIndividuals(heapWorker, | |
snapshotId, | |
censusDisplay.breakdown, | |
node.reportLeafIndex)); | |
}, | |
onFocusIndividual: node => { | |
assert(view.state === viewState.INDIVIDUALS, | |
"Should be in the individuals view"); | |
dispatch(focusIndividual(node)); | |
}, | |
onCensusExpand: (census, node) => { | |
if (diffing) { | |
assert(diffing.census === census, | |
"Should only expand active census"); | |
dispatch(expandDiffingCensusNode(node)); | |
} else { | |
assert(selectedSnapshot && selectedSnapshot.census === census, | |
"If not diffing, " + | |
"should be expanding on selected snapshot's census"); | |
dispatch(expandCensusNode(selectedSnapshot.id, node)); | |
} | |
}, | |
onCensusCollapse: (census, node) => { | |
if (diffing) { | |
assert(diffing.census === census, | |
"Should only collapse active census"); | |
dispatch(collapseDiffingCensusNode(node)); | |
} else { | |
assert(selectedSnapshot && selectedSnapshot.census === census, | |
"If not diffing, " + | |
"should be collapsing on selected snapshot's census"); | |
dispatch(collapseCensusNode(selectedSnapshot.id, node)); | |
} | |
}, | |
onCensusFocus: (census, node) => { | |
if (diffing) { | |
assert(diffing.census === census, | |
"Should only focus nodes in active census"); | |
dispatch(focusDiffingCensusNode(node)); | |
} else { | |
assert(selectedSnapshot && selectedSnapshot.census === census, | |
"If not diffing, " + | |
"should be focusing on nodes in selected snapshot's census"); | |
dispatch(focusCensusNode(selectedSnapshot.id, node)); | |
} | |
}, | |
onDominatorTreeExpand: node => { | |
assert(view.state === viewState.DOMINATOR_TREE, | |
"If expanding dominator tree nodes, " + | |
"should be in dominator tree view"); | |
assert(selectedSnapshot, "...and we should have a selected snapshot"); | |
assert(selectedSnapshot.dominatorTree, | |
"...and that snapshot should have a dominator tree"); | |
dispatch(expandDominatorTreeNode(selectedSnapshot.id, node)); | |
}, | |
onDominatorTreeCollapse: node => { | |
assert(view.state === viewState.DOMINATOR_TREE, | |
"If collapsing dominator tree nodes, " + | |
"should be in dominator tree view"); | |
assert(selectedSnapshot, "...and we should have a selected snapshot"); | |
assert(selectedSnapshot.dominatorTree, | |
"...and that snapshot should have a dominator tree"); | |
dispatch(collapseDominatorTreeNode(selectedSnapshot.id, node)); | |
}, | |
onDominatorTreeFocus: node => { | |
assert(view.state === viewState.DOMINATOR_TREE, | |
"If focusing dominator tree nodes, " + | |
"should be in dominator tree view"); | |
assert(selectedSnapshot, "...and we should have a selected snapshot"); | |
assert(selectedSnapshot.dominatorTree, | |
"...and that snapshot should have a dominator tree"); | |
dispatch(focusDominatorTreeNode(selectedSnapshot.id, node)); | |
}, | |
onShortestPathsResize: newSize => { | |
dispatch(resizeShortestPaths(newSize)); | |
}, | |
sizes, | |
view, | |
}) | |
) | |
) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment