Skip to content

Commit 0f997d7

Browse files
committed
docs: add comments for clearer code explanation
1 parent 3939ec6 commit 0f997d7

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

src/components/DatasetDetailPage/FileTree/FileTree.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//renders the header (title, counts, total size) and the scrollable area.
12
import FileTreeRow from "./FileTreeRow";
23
import type { TreeNode } from "./types";
34
import FolderIcon from "@mui/icons-material/Folder";
@@ -58,7 +59,7 @@ const FileTree: React.FC<Props> = ({
5859

5960
<Box sx={{ flex: 1, minHeight: 0, overflowY: "auto", py: 0.5 }}>
6061
{tree.map((n) => (
61-
<FileTreeRow key={n.path} node={n} level={0} onPreview={onPreview} />
62+
<FileTreeRow key={n.path} node={n} level={0} onPreview={onPreview} /> // pass the handlePreview(onPreview = handlePreview) function to FileTreeRow
6263
))}
6364
</Box>
6465
</Box>

src/components/DatasetDetailPage/FileTree/FileTreeRow.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ const FileTreeRow: React.FC<Props> = ({ node, level, onPreview }) => {
123123
{open ? <ExpandLess /> : <ExpandMore />}
124124
</Box>
125125

126+
{/*timeout controls the duration of the expand/collapse animation*/}
126127
<Collapse in={open} timeout="auto" unmountOnExit>
127128
{node.children.map((child) => (
128129
<FileTreeRow
@@ -136,7 +137,7 @@ const FileTreeRow: React.FC<Props> = ({ node, level, onPreview }) => {
136137
</>
137138
);
138139
}
139-
140+
// if the node is a file
140141
return (
141142
<Box
142143
sx={{ display: "flex", alignItems: "flex-start", gap: 1, py: 0.5, px: 1 }}

src/components/DatasetDetailPage/FileTree/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const formatLeafValue = (v: any): string => {
2727
// key === "_id" || key === "_rev" || key.startsWith(".");
2828
export const shouldSkipKey = (_key: string) => false;
2929

30-
// build path -> {url, index} lookup, built from extractDataLinks function
30+
// build path -> {url, index} lookup, built from extractDataLinks function (return { name, size, path, url, index })
3131
// if external link objects have {path, url, index}, build a Map for the tree
3232
export const makeLinkMap = <
3333
T extends { path: string; url: string; index: number }

src/pages/UpdatedDatasetDetailPage.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,10 +1175,11 @@ const UpdatedDatasetDetailPage: React.FC = () => {
11751175
<Box sx={{ flex: 1, minHeight: 240, overflow: "hidden" }}>
11761176
<FileTree
11771177
title={treeTitle}
1178-
tree={treeData} // this is already built from subjectsOnly when hasTopLevelSubjects === true
1178+
tree={treeData}
11791179
filesCount={filesCount}
11801180
totalBytes={totalBytes}
1181-
onPreview={(url, index) => handlePreview(url, index, false)}
1181+
// onPreview={(url, index) => handlePreview(url, index, false)}
1182+
onPreview={handlePreview} // pass the function down to FileTree
11821183
/>
11831184
</Box>
11841185

0 commit comments

Comments
 (0)