MCPcopy Create free account
hub / github.com/cs01/gdbgui / get_node_jsx

Method get_node_jsx

gdbgui/src/js/FileSystem.tsx:5–52  ·  view source on GitHub ↗
(node: any, depth = 0)

Source from the content-addressed store, hash-verified

3class FileSystem extends React.Component {
4 nodecount: any;
5 get_node_jsx(node: any, depth = 0) {
6 if (!node) {
7 return null;
8 }
9 this.nodecount++;
10
11 let get_child_jsx_for_node = (node: any) => {
12 if (!(node.children && node.toggled)) {
13 return null;
14 }
15 return (
16 <ul>{node.children.map((child: any) => this.get_node_jsx(child, depth + 1))}</ul>
17 );
18 };
19 let indent = "\u00A0\u00A0\u00A0".repeat(depth),
20 glyph = null;
21 let is_file = !node.children,
22 is_dir = !is_file;
23 if (is_dir) {
24 glyph = node.toggled ? "glyphicon-chevron-down" : "glyphicon-chevron-right";
25 }
26
27 let onClickName = null;
28 if (is_file) {
29 onClickName = () => {
30 // @ts-expect-error ts-migrate(2339) FIXME: Property 'onClickName' does not exist on type 'Rea... Remove this comment to see the full error message
31 this.props.onClickName(node);
32 };
33 }
34
35 return (
36 <React.Fragment key={this.nodecount}>
37 <li className="pointer">
38 {indent}
39 <span
40 className={"glyphicon " + glyph}
41 onClick={() => {
42 // @ts-expect-error ts-migrate(2339) FIXME: Property 'onToggle' does not exist on type 'Readon... Remove this comment to see the full error message
43 this.props.onToggle(node);
44 }}
45 />
46 {/* @ts-expect-error ts-migrate(2322) FIXME: Type 'null' is not assignable to type '((event: Mo... Remove this comment to see the full error message */}
47 <span onClick={onClickName}>{node.name}</span>
48 </li>
49 {get_child_jsx_for_node(node)}
50 </React.Fragment>
51 );
52 }
53
54 render() {
55 this.nodecount = -1;

Callers 2

renderMethod · 0.95

Calls 2

onClickNameMethod · 0.80
onToggleMethod · 0.80

Tested by

no test coverage detected