Show expanded details

pull/453/head
ioedeveloper 4 years ago
parent 4212cae344
commit be4f7b1884
  1. 17
      libs/remix-ui/debugger-ui/src/lib/vm-debugger/dropdown-panel.tsx
  2. 1
      libs/remix-ui/debugger-ui/src/lib/vm-debugger/solidity-locals.tsx
  3. 10
      libs/remix-ui/tree-view/src/lib/tree-view-item/tree-view-item.tsx
  4. 4
      libs/remix-ui/tree-view/src/types/index.ts

@ -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 { TreeView, TreeViewItem } from '@remix-ui/tree-view'
import { DropdownPanelProps, ExtractData, ExtractFunc } from '../../types' import { DropdownPanelProps, ExtractData, ExtractFunc } from '../../types'
import { CopyToClipboard } from '@remix-ui/clipboard' import { CopyToClipboard } from '@remix-ui/clipboard'
@ -57,7 +57,8 @@ export const DropdownPanel = (props: DropdownPanelProps) => {
}, },
copiableContent: '', copiableContent: '',
updating: false, updating: false,
data: null data: null,
expandPath: []
}) })
useEffect(() => { 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) => { const message = (message) => {
if (message === state.message.innerText) return if (message === state.message.innerText) return
setState(prevState => { setState(prevState => {
@ -148,14 +157,14 @@ export const DropdownPanel = (props: DropdownPanelProps) => {
if (children && children.length > 0 ) { if (children && children.length > 0 ) {
return ( return (
<TreeViewItem id={`treeViewItem${key}`} key={keyPath} label={ formatSelfFunc ? formatSelfFunc(key, data) : formatSelfDefault(key, data) }> <TreeViewItem id={`treeViewItem${key}`} key={keyPath} label={ formatSelfFunc ? formatSelfFunc(key, data) : formatSelfDefault(key, data) } handleClick={() => handleExpand(keyPath)} expand={state.expandPath.includes(keyPath)}>
<TreeView id={`treeView${key}`} key={keyPath}> <TreeView id={`treeView${key}`} key={keyPath}>
{ children } { children }
</TreeView> </TreeView>
</TreeViewItem> </TreeViewItem>
) )
} else { } else {
return <TreeViewItem id={key.toString()} key={keyPath} label={ formatSelfFunc ? formatSelfFunc(key, data) : formatSelfDefault(key, data) } /> return <TreeViewItem id={key.toString()} key={keyPath} label={ formatSelfFunc ? formatSelfFunc(key, data) : formatSelfDefault(key, data) } handleClick={() => handleExpand(keyPath)} expand={state.expandPath.includes(keyPath)} />
} }
} }

@ -8,7 +8,6 @@ export const SolidityLocals = ({ data, message }) => {
const [calldata, setCalldata] = useState(null) const [calldata, setCalldata] = useState(null)
useEffect(() => { useEffect(() => {
console.log('data: ', data)
if (!deepequal(calldata, data)) setCalldata(data) if (!deepequal(calldata, data)) setCalldata(data)
}, [data]) }, [data])

@ -1,14 +1,18 @@
import React, { useState } from 'react' import React, { useState, useEffect } from 'react'
import { TreeViewItemProps } from '../../types' import { TreeViewItemProps } from '../../types'
import './tree-view-item.css' import './tree-view-item.css'
export const TreeViewItem = (props: TreeViewItemProps) => { export const TreeViewItem = (props: TreeViewItemProps) => {
const { id, children, label, ...otherProps } = props const { id, children, label, expand, handleClick, ...otherProps } = props
const [isExpanded, setIsExpanded] = useState(false) const [isExpanded, setIsExpanded] = useState(false)
useEffect(() => {
setIsExpanded(expand)
}, [expand])
return ( return (
<li key={`treeViewLi${id}`} data-id={`treeViewLi${id}`} className='li_tv' {...otherProps}> <li key={`treeViewLi${id}`} data-id={`treeViewLi${id}`} className='li_tv' onClick={handleClick} {...otherProps}>
<div key={`treeViewDiv${id}`} data-id={`treeViewDiv${id}`} className='d-flex flex-row align-items-center' onClick={() => setIsExpanded(!isExpanded)}> <div key={`treeViewDiv${id}`} data-id={`treeViewDiv${id}`} className='d-flex flex-row align-items-center' onClick={() => setIsExpanded(!isExpanded)}>
<div className={isExpanded ? 'px-1 fas fa-caret-down caret caret_tv' : 'px-1 fas fa-caret-right caret caret_tv'} style={{ visibility: children ? 'visible' : 'hidden' }}></div> <div className={isExpanded ? 'px-1 fas fa-caret-down caret caret_tv' : 'px-1 fas fa-caret-right caret caret_tv'} style={{ visibility: children ? 'visible' : 'hidden' }}></div>
<span className='w-100 pl-1'> <span className='w-100 pl-1'>

@ -6,5 +6,7 @@ export interface TreeViewProps {
export interface TreeViewItemProps { export interface TreeViewItemProps {
children?: React.ReactNode, children?: React.ReactNode,
id: string, id: string,
label: string | number | React.ReactNode label: string | number | React.ReactNode,
expand?: boolean,
handleClick?: (e) => void
} }
Loading…
Cancel
Save