From be4f7b188460ca77dc4f6193d0b49d126470292c Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Wed, 21 Oct 2020 17:34:51 +0100 Subject: [PATCH] Show expanded details --- .../src/lib/vm-debugger/dropdown-panel.tsx | 17 +++++++++++++---- .../src/lib/vm-debugger/solidity-locals.tsx | 1 - .../src/lib/tree-view-item/tree-view-item.tsx | 10 +++++++--- libs/remix-ui/tree-view/src/types/index.ts | 4 +++- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/dropdown-panel.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/dropdown-panel.tsx index 6bffe3ef5e..8b6a771a75 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/dropdown-panel.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/dropdown-panel.tsx @@ -1,4 +1,4 @@ -import React, { useState, useRef, useEffect } from 'react' +import React, { useState, useEffect } from 'react' import { TreeView, TreeViewItem } from '@remix-ui/tree-view' import { DropdownPanelProps, ExtractData, ExtractFunc } from '../../types' import { CopyToClipboard } from '@remix-ui/clipboard' @@ -57,7 +57,8 @@ export const DropdownPanel = (props: DropdownPanelProps) => { }, copiableContent: '', updating: false, - data: null + data: null, + expandPath: [] }) useEffect(() => { @@ -81,6 +82,14 @@ export const DropdownPanel = (props: DropdownPanelProps) => { }) } + const handleExpand = (keyPath) => { + if (!state.expandPath.includes(keyPath)) { + state.expandPath.push(keyPath) + } else { + state.expandPath = state.expandPath.filter(path => !path.startsWith(keyPath)) + } + } + const message = (message) => { if (message === state.message.innerText) return setState(prevState => { @@ -148,14 +157,14 @@ export const DropdownPanel = (props: DropdownPanelProps) => { if (children && children.length > 0 ) { return ( - + handleExpand(keyPath)} expand={state.expandPath.includes(keyPath)}> { children } ) } else { - return + return handleExpand(keyPath)} expand={state.expandPath.includes(keyPath)} /> } } diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/solidity-locals.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/solidity-locals.tsx index b6439c8f9f..59f73f883b 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/solidity-locals.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/solidity-locals.tsx @@ -8,7 +8,6 @@ export const SolidityLocals = ({ data, message }) => { const [calldata, setCalldata] = useState(null) useEffect(() => { - console.log('data: ', data) if (!deepequal(calldata, data)) setCalldata(data) }, [data]) diff --git a/libs/remix-ui/tree-view/src/lib/tree-view-item/tree-view-item.tsx b/libs/remix-ui/tree-view/src/lib/tree-view-item/tree-view-item.tsx index f795249152..f19a87e705 100644 --- a/libs/remix-ui/tree-view/src/lib/tree-view-item/tree-view-item.tsx +++ b/libs/remix-ui/tree-view/src/lib/tree-view-item/tree-view-item.tsx @@ -1,14 +1,18 @@ -import React, { useState } from 'react' +import React, { useState, useEffect } from 'react' import { TreeViewItemProps } from '../../types' import './tree-view-item.css' export const TreeViewItem = (props: TreeViewItemProps) => { - const { id, children, label, ...otherProps } = props + const { id, children, label, expand, handleClick, ...otherProps } = props const [isExpanded, setIsExpanded] = useState(false) + useEffect(() => { + setIsExpanded(expand) + }, [expand]) + return ( -
  • +
  • setIsExpanded(!isExpanded)}>
    diff --git a/libs/remix-ui/tree-view/src/types/index.ts b/libs/remix-ui/tree-view/src/types/index.ts index 2a81f06cec..e06d474de6 100644 --- a/libs/remix-ui/tree-view/src/types/index.ts +++ b/libs/remix-ui/tree-view/src/types/index.ts @@ -6,5 +6,7 @@ export interface TreeViewProps { export interface TreeViewItemProps { children?: React.ReactNode, id: string, - label: string | number | React.ReactNode + label: string | number | React.ReactNode, + expand?: boolean, + handleClick?: (e) => void } \ No newline at end of file