Skip to content

Commit

Permalink
fix(frontend): update mui Tree* dependency for FieldsView.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffycyang committed Aug 6, 2024
1 parent 61b9f70 commit d022308
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@mui/icons-material": "^5.10.9",
"@mui/lab": "^5.0.0-alpha.104",
"@mui/material": "^5.10.10",
"@mui/x-tree-view": "^7.12.0",
"@reduxjs/toolkit": "^1.8.6",
"@types/lodash": "^4.14.186",
"@wojtekmaj/react-datetimerange-picker": "^5.2.0",
Expand Down
36 changes: 20 additions & 16 deletions frontend/src/features/fields/FieldsView.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import _ from 'lodash';

import { List, ListItem, ListItemText, ListSubheader, Switch, Stack, Tooltip, Typography, IconButton} from '@mui/material';
import {TreeView, TreeItem} from '@mui/lab';
import { SimpleTreeView, TreeItem } from '@mui/x-tree-view';
import {ExpandMore, ChevronRight} from '@mui/icons-material';

import { useAppSelector, useAppDispatch } from '../../app/hooks';
Expand Down Expand Up @@ -37,7 +37,7 @@ export function FieldsView(){
function renderTree(node: FieldNode, tree: any, noDiff: boolean) {
return <TreeItem
key={node.id}
nodeId={node.id}
itemId={node.id}
label={label(selectedEndpoint, node, tree, noDiff)}
onClick={() => dispatch(selectFieldPrefix(node.id))}
disabled={ disabledNode === node.id }
Expand Down Expand Up @@ -89,19 +89,23 @@ export function FieldsView(){
return `${metric.name}: ${metric.differences} diffs | ${metric.noise/(metric.differences)*100.00}% noise/diffs`
}
return (<List subheader={<ListSubheader>Fields</ListSubheader>}>
<TreeView
defaultCollapseIcon={<ExpandMore />}
defaultExpanded={['request']}
defaultExpandIcon={<ChevronRight />}
>
{request && renderTree(request, tree, true)}
</TreeView>
<TreeView
defaultCollapseIcon={<ExpandMore />}
defaultExpanded={['response']}
defaultExpandIcon={<ChevronRight />}
>
<SimpleTreeView
slots={{
expandIcon: ExpandMore,
collapseIcon: ChevronRight,
}}
defaultExpandedItems={['request']}
>
{request && renderTree(request, tree, true)}
</SimpleTreeView>
<SimpleTreeView
slots={{
expandIcon: ExpandMore,
collapseIcon: ChevronRight,
}}
defaultExpandedItems={['request']}
>
{response && renderTree(response, tree, false)}
</TreeView>
</SimpleTreeView>
</List>);
}
}

0 comments on commit d022308

Please sign in to comment.