@@ -13,7 +13,7 @@ import {
1313 Alert ,
1414 Button ,
1515 Collapse ,
16- Snackbar ,
16+ Tooltip ,
1717} from "@mui/material" ;
1818import FileTree from "components/DatasetDetailPage/FileTree/FileTree" ;
1919import {
@@ -56,29 +56,17 @@ interface InternalDataLink {
5656const UpdatedDatasetDetailPage : React . FC = ( ) => {
5757 const { dbName, docId } = useParams < { dbName : string ; docId : string } > ( ) ;
5858 const navigate = useNavigate ( ) ;
59- const [ searchParams , setSearchParams ] = useSearchParams ( ) ;
60- // for highlight
61- const focus = searchParams . get ( "focus" ) || undefined ;
62-
63- // for revision
64- const rev = searchParams . get ( "rev" ) || undefined ;
65-
66- const handleSelectRevision = ( newRev ?: string | null ) => {
67- setSearchParams ( ( prev ) => {
68- const p = new URLSearchParams ( prev ) ; // copy of the query url
69- if ( newRev ) p . set ( "rev" , newRev ) ;
70- else p . delete ( "rev" ) ;
71- return p ;
72- } ) ;
73- } ;
74-
7559 const dispatch = useAppDispatch ( ) ;
7660 const {
7761 selectedDocument : datasetDocument ,
7862 loading,
7963 error,
8064 datasetViewInfo : dbViewInfo ,
8165 } = useAppSelector ( NeurojsonSelector ) ;
66+ // get params from url
67+ const [ searchParams , setSearchParams ] = useSearchParams ( ) ;
68+ const focus = searchParams . get ( "focus" ) || undefined ; // get highlight from url
69+ const rev = searchParams . get ( "rev" ) || undefined ; // get revision from url
8270
8371 const [ externalLinks , setExternalLinks ] = useState < ExternalDataLink [ ] > ( [ ] ) ;
8472 const [ internalLinks , setInternalLinks ] = useState < InternalDataLink [ ] > ( [ ] ) ;
@@ -90,6 +78,7 @@ const UpdatedDatasetDetailPage: React.FC = () => {
9078 const [ isExternalExpanded , setIsExternalExpanded ] = useState ( true ) ;
9179 const [ jsonSize , setJsonSize ] = useState < number > ( 0 ) ;
9280 const [ previewIndex , setPreviewIndex ] = useState < number > ( 0 ) ;
81+ const [ isPreviewLoading , setIsPreviewLoading ] = useState ( false ) ;
9382 const [ copiedToast , setCopiedToast ] = useState < {
9483 open : boolean ;
9584 text : string ;
@@ -98,6 +87,14 @@ const UpdatedDatasetDetailPage: React.FC = () => {
9887 text : "" ,
9988 } ) ;
10089 const aiSummary = datasetDocument ?. [ ".datainfo" ] ?. AISummary ?? "" ;
90+ const handleSelectRevision = ( newRev ?: string | null ) => {
91+ setSearchParams ( ( prev ) => {
92+ const p = new URLSearchParams ( prev ) ; // copy of the query url
93+ if ( newRev ) p . set ( "rev" , newRev ) ;
94+ else p . delete ( "rev" ) ;
95+ return p ;
96+ } ) ;
97+ } ;
10198
10299 const linkMap = useMemo ( ( ) => makeLinkMap ( externalLinks ) , [ externalLinks ] ) ; // => external Link Map
103100
@@ -107,18 +104,17 @@ const UpdatedDatasetDetailPage: React.FC = () => {
107104 ) ;
108105
109106 const treeTitle = "Files" ;
110- const filesCount = externalLinks . length ;
111- const totalBytes = useMemo ( ( ) => {
112- let bytes = 0 ;
113- for ( const l of externalLinks ) {
114- const m = l . url . match ( / s i z e = ( \d + ) / ) ;
115- if ( m ) bytes += parseInt ( m [ 1 ] , 10 ) ;
116- }
117- return bytes ;
118- } , [ externalLinks ] ) ;
107+ // const filesCount = externalLinks.length;
108+ // const totalBytes = useMemo(() => {
109+ // let bytes = 0;
110+ // for (const l of externalLinks) {
111+ // const m = l.url.match(/size=(\d+)/);
112+ // if (m) bytes += parseInt(m[1], 10);
113+ // }
114+ // return bytes;
115+ // }, [externalLinks]);
119116
120117 // add spinner
121- const [ isPreviewLoading , setIsPreviewLoading ] = useState ( false ) ;
122118
123119 const formatSize = ( sizeInBytes : number ) : string => {
124120 if ( sizeInBytes < 1024 ) {
@@ -159,7 +155,7 @@ const UpdatedDatasetDetailPage: React.FC = () => {
159155 links . push ( {
160156 name : `${ label } (${ size } ) [/${ subpath } ]` ,
161157 size,
162- path : currentPath , // keep full JSON path for file placement
158+ path : currentPath , // parent path (not include _DataLink_)
163159 url : correctedUrl ,
164160 index : links . length ,
165161 } ) ;
@@ -203,7 +199,6 @@ const UpdatedDatasetDetailPage: React.FC = () => {
203199 obj . MeshNode ?. hasOwnProperty ( "_ArrayZipData_" ) &&
204200 typeof obj . MeshNode [ "_ArrayZipData_" ] === "string"
205201 ) {
206- // console.log("path", path);
207202 internalLinks . push ( {
208203 name : "JMesh" ,
209204 data : obj ,
@@ -252,7 +247,6 @@ const UpdatedDatasetDetailPage: React.FC = () => {
252247 } ) ;
253248 }
254249 }
255-
256250 return internalLinks ;
257251 } ;
258252 // Build a shareable preview URL for a JSON path in this dataset
@@ -442,14 +436,14 @@ const UpdatedDatasetDetailPage: React.FC = () => {
442436 idx : number ,
443437 isInternal : boolean = false
444438 ) => {
445- console . log (
446- "🟢 Preview button clicked for:" ,
447- dataOrUrl ,
448- "Index:" ,
449- idx ,
450- "Is Internal:" ,
451- isInternal
452- ) ;
439+ // console.log(
440+ // "🟢 Preview button clicked for:",
441+ // dataOrUrl,
442+ // "Index:",
443+ // idx,
444+ // "Is Internal:",
445+ // isInternal
446+ // );
453447
454448 // Clear any stale preview type from last run
455449 delete ( window as any ) . __previewType ;
@@ -588,7 +582,7 @@ const UpdatedDatasetDetailPage: React.FC = () => {
588582 } ,
589583 [ datasetDocument ]
590584 ) ;
591-
585+ // check if the url has preview param
592586 useEffect ( ( ) => {
593587 const p = searchParams . get ( "preview" ) ;
594588 if ( ! p || ! datasetDocument ) return ;
@@ -613,8 +607,7 @@ const UpdatedDatasetDetailPage: React.FC = () => {
613607 externalLinks ,
614608 searchParams ,
615609 internalMap ,
616- // externalMap,
617- linkMap ,
610+ linkMap , // externalMap
618611 ] ) ;
619612
620613 const handleClosePreview = ( ) => {
@@ -892,8 +885,8 @@ const UpdatedDatasetDetailPage: React.FC = () => {
892885 < FileTree
893886 title = { treeTitle }
894887 tree = { treeData }
895- filesCount = { filesCount }
896- totalBytes = { totalBytes }
888+ // filesCount={filesCount}
889+ // totalBytes={totalBytes}
897890 onPreview = { handlePreview } // pass the function down to FileTree
898891 getInternalByPath = { getInternalByPath }
899892 getJsonByPath = { getJsonByPath }
@@ -1051,7 +1044,7 @@ const UpdatedDatasetDetailPage: React.FC = () => {
10511044 >
10521045 Preview
10531046 </ Button >
1054- { /* <Button
1047+ < Button
10551048 variant = "outlined"
10561049 size = "small"
10571050 sx = { {
@@ -1070,7 +1063,7 @@ const UpdatedDatasetDetailPage: React.FC = () => {
10701063 >
10711064 < ContentCopyIcon sx = { { fontSize : 16 , mr : 0.5 } } />
10721065 Copy URL
1073- </Button> */ }
1066+ </ Button >
10741067 </ Box >
10751068 </ Box >
10761069 ) )
@@ -1205,7 +1198,7 @@ const UpdatedDatasetDetailPage: React.FC = () => {
12051198 Preview
12061199 </ Button >
12071200 ) }
1208- { /* { isPreviewable && (
1201+ { isPreviewable && (
12091202 < Button
12101203 variant = "outlined"
12111204 size = "small"
@@ -1226,7 +1219,7 @@ const UpdatedDatasetDetailPage: React.FC = () => {
12261219 < ContentCopyIcon sx = { { fontSize : 16 , mr : 0.5 } } />
12271220 Copy URL
12281221 </ Button >
1229- )} */ }
1222+ ) }
12301223 </ Box >
12311224 </ Box >
12321225 ) ;
@@ -1282,7 +1275,7 @@ const UpdatedDatasetDetailPage: React.FC = () => {
12821275 < CircularProgress color = "inherit" />
12831276 </ Backdrop >
12841277
1285- { /* Preview Modal Component - Add Here */ }
1278+ { /* Preview Modal Component */ }
12861279 < PreviewModal
12871280 isOpen = { previewOpen }
12881281 dataKey = { previewDataKey }
0 commit comments