1+ //renders the header (title, counts, total size) and the scrollable area.
12import FileTreeRow from "./FileTreeRow" ;
23import type { TreeNode } from "./types" ;
34import FolderIcon from "@mui/icons-material/Folder" ;
@@ -9,7 +10,10 @@ type Props = {
910 tree : TreeNode [ ] ;
1011 filesCount : number ;
1112 totalBytes : number ;
12- onPreview : ( url : string , index : number ) => void ;
13+ // for preview in tree row
14+ onPreview : ( src : string | any , index : number , isInternal ?: boolean ) => void ;
15+ getInternalByPath : ( path : string ) => { data : any ; index : number } | undefined ;
16+ getJsonByPath ?: ( path : string ) => any ;
1317} ;
1418
1519const formatSize = ( n : number ) => {
@@ -26,6 +30,8 @@ const FileTree: React.FC<Props> = ({
2630 filesCount,
2731 totalBytes,
2832 onPreview,
33+ getInternalByPath,
34+ getJsonByPath,
2935} ) => (
3036 < Box
3137 sx = { {
@@ -49,16 +55,23 @@ const FileTree: React.FC<Props> = ({
4955 flexShrink : 0 ,
5056 } }
5157 >
52- < FolderIcon />
58+ { /* <FolderIcon /> */ }
5359 < Typography sx = { { fontWeight : 700 , flex : 1 } } > { title } </ Typography >
54- < Typography variant = "body2" sx = { { color : "text.secondary" } } >
60+ { /* <Typography variant="body2" sx={{ color: "text.secondary" }}>
5561 Files: {filesCount} Size: {formatSize(totalBytes)}
56- </ Typography >
62+ </Typography> */ }
5763 </ Box >
5864
5965 < Box sx = { { flex : 1 , minHeight : 0 , overflowY : "auto" , py : 0.5 } } >
6066 { tree . map ( ( n ) => (
61- < FileTreeRow key = { n . path } node = { n } level = { 0 } onPreview = { onPreview } />
67+ < FileTreeRow
68+ key = { n . path }
69+ node = { n }
70+ level = { 0 }
71+ onPreview = { onPreview }
72+ getInternalByPath = { getInternalByPath }
73+ getJsonByPath = { getJsonByPath }
74+ /> // pass the handlePreview(onPreview = handlePreview) function to FileTreeRow
6275 ) ) }
6376 </ Box >
6477 </ Box >
0 commit comments