diff --git a/src/plugins/sections/Tree.js b/src/plugins/sections/Tree.js
index 45576b68c..a0cf16f21 100644
--- a/src/plugins/sections/Tree.js
+++ b/src/plugins/sections/Tree.js
@@ -7,7 +7,15 @@
import type {SectionComponentHierarchy} from './Models';
-import {PureComponent, styled, Toolbar, Spacer, colors} from 'flipper';
+import {
+ Button,
+ Glyph,
+ PureComponent,
+ styled,
+ Toolbar,
+ Spacer,
+ colors,
+} from 'flipper';
import {Tree} from 'react-d3-tree';
import {Fragment} from 'react';
@@ -51,6 +59,17 @@ const Container = styled('div')({
'10px 10px,10px 10px,100px 100px,100px 100px,100px 100px,100px 100px,100px 100px,100px 100px',
});
+const LabelContainer = styled('div')({
+ display: 'flex',
+});
+
+const IconButton = styled('div')({
+ position: 'relative',
+ left: 5,
+ top: -8,
+ background: colors.white,
+});
+
type TreeData = Array<{
identifier: string,
name: string,
@@ -80,14 +99,46 @@ type State = {
zoom: number,
};
-const NodeLabel = (props: {
- nodeData: {
- name: string,
- },
-}) => {
- const name = props?.nodeData?.name;
- return ;
-};
+class NodeLabel extends PureComponent {
+ state = {
+ collapsed: false,
+ };
+
+ showNodeData = e => {
+ e.stopPropagation();
+ this.props.onLabelClicked(this.props?.nodeData);
+ };
+
+ toggleClicked = () => {
+ this.setState({
+ collapsed: !this.state.collapsed,
+ });
+ };
+
+ render() {
+ const name = this.props?.nodeData?.name;
+ const isSection = this.props?.nodeData?.attributes.isSection;
+ const chevron = this.state.collapsed ? 'chevron-right' : 'chevron-left';
+
+ return (
+
+
+ {isSection && (
+
+
+
+ )}
+
+ );
+ }
+}
export default class extends PureComponent {
treeFromFlatArray = (data: TreeData) => {
@@ -214,7 +265,9 @@ export default class extends PureComponent {
zoom={this.state.zoom}
nodeLabelComponent={{
// $FlowFixMe props are passed in by react-d3-tree
- render: ,
+ render: (
+
+ ),
}}
allowForeignObjects
nodeSvgShape={{
@@ -230,7 +283,6 @@ export default class extends PureComponent {
},
}}
nodeSize={{x: 300, y: 100}}
- onClick={this.props.nodeClickHandler}
/>
)}
diff --git a/src/plugins/sections/index.js b/src/plugins/sections/index.js
index c975ff95c..84e39b4cc 100644
--- a/src/plugins/sections/index.js
+++ b/src/plugins/sections/index.js
@@ -172,8 +172,10 @@ export default class extends FlipperPlugin {
onNodeClicked = (targetNode: any, evt: InputEvent) => {
if (targetNode.attributes.isSection) {
+ const sectionData = {};
+ sectionData['global_key'] = targetNode.attributes.identifier;
this.setState({
- selectedTreeNode: null,
+ selectedTreeNode: {sectionData},
});
return;
}