1
0
mirror of https://github.com/sasjs/server.git synced 2026-01-12 16:40:05 +00:00

fix: modify the directory tree algorithm to include relative path with each node

This commit is contained in:
2021-10-18 19:48:25 +00:00
parent bc3cb7bb20
commit 91e2e2bc4a
2 changed files with 45 additions and 11 deletions

View File

@@ -16,9 +16,10 @@ import ExpandMoreIcon from '@mui/icons-material/ExpandMore'
import ChevronRightIcon from '@mui/icons-material/ChevronRight'
interface TreeNode {
path: string
name: string
children?: readonly TreeNode[]
relativePath: string
absolutePath: string
children: Array<TreeNode>
}
const useStyles = makeStyles(() => ({
@@ -49,21 +50,21 @@ const SideBar = (props: any) => {
}, [])
const handleSelect = (node: TreeNode) => {
if (!node.children) {
if (!node.children.length) {
window.history.pushState(
'',
'',
`${baseUrl}/SASjsDrive?filepath=${node.path}`
`${baseUrl}/SASjsDrive?filepath=${node.relativePath}`
)
props.setSelectedFilePath(node.path)
props.setSelectedFilePath(node.relativePath)
}
}
const renderTree = (nodes: TreeNode) => (
<TreeItem
classes={{ root: classes.root }}
key={nodes.path}
nodeId={nodes.path}
key={nodes.relativePath}
nodeId={nodes.relativePath}
label={
<ListItem
className={classes.listItem}