Skip to content

Conversation

DisaPadla
Copy link

No description provided.

src/index.js Outdated
@@ -54,6 +55,7 @@ export default class JSONTree extends React.Component {
PropTypes.object
]).isRequired,
hideRoot: PropTypes.bool,
isNotAllowExtractNestedItemOfList: PropTypes.bool,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a generic library. It shouldn't know about our use case.

Instead, change this to maxClickableNodeDepth.

We will set it to 1 in our code if the data is a list.

src/index.js Outdated
@@ -97,6 +99,8 @@ export default class JSONTree extends React.Component {
<JSONNode
{...{ postprocessValue, hideRoot, styling, ...rest }}
keyPath={hideRoot ? [] : keyPath}
isRootTypeOfNodeIsArray={objType(value) === 'Array'}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't do this here. We should check this in our code, and set maxClickableNodeDepth.

remove isRootTypeOfNodeIsArray

@@ -106,6 +108,16 @@ export default class JSONNestedNode extends React.Component {

shouldComponentUpdate = shouldPureComponentUpdate;

isShouldExtract = () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this, make handleNodeClick and handleMouseOver do nothing and not stopPropagation if their keypath is deeper than maxClickableNodeDepth.

@@ -147,8 +137,10 @@ export default class JSONNestedNode extends React.Component {
itemType,
createItemString(data, collectionLimit)
);

const stylingArgs = [keyPath, nodeType, expanded, expandable, this.isShouldExtract()];
const hover = maxClickableNodeDepth && keyPath.length > maxClickableNodeDepth
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can just use this.state.hover, because if keyPath.length > maxClickableNodeDepth, then state.hover will never be set.

@mclin mclin merged commit 3046750 into dremio:master May 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants