1
1
import { useEffect , useState , useMemo , useRef , Suspense , useReducer , useCallback } from 'react' ;
2
2
import FileTable from './FileTable' ;
3
- import { Button , Typography , Flex , StatusIndicator , useMediaQuery } from '@neo4j-ndl/react' ;
3
+ import { Button , Typography , Flex , StatusIndicator , useMediaQuery , Callout } from '@neo4j-ndl/react' ;
4
4
import { useCredentials } from '../context/UserCredentials' ;
5
5
import { useFileContext } from '../context/UsersFiles' ;
6
6
import { extractAPI } from '../utils/FileAPI' ;
@@ -63,8 +63,15 @@ const Content: React.FC<ContentProps> = ({
63
63
const [ openGraphView , setOpenGraphView ] = useState < boolean > ( false ) ;
64
64
const [ inspectedName , setInspectedName ] = useState < string > ( '' ) ;
65
65
const [ documentName , setDocumentName ] = useState < string > ( '' ) ;
66
- const { setUserCredentials, userCredentials, setConnectionStatus, isGdsActive, isReadOnlyUser, isGCSActive } =
67
- useCredentials ( ) ;
66
+ const {
67
+ setUserCredentials,
68
+ userCredentials,
69
+ setConnectionStatus,
70
+ isGdsActive,
71
+ isReadOnlyUser,
72
+ isGCSActive,
73
+ chunksToBeProces,
74
+ } = useCredentials ( ) ;
68
75
const [ showConfirmationModal , setshowConfirmationModal ] = useState < boolean > ( false ) ;
69
76
const [ showExpirationModal , setshowExpirationModal ] = useState < boolean > ( false ) ;
70
77
const [ extractLoading , setextractLoading ] = useState < boolean > ( false ) ;
@@ -106,7 +113,7 @@ const Content: React.FC<ContentProps> = ({
106
113
) ;
107
114
const [ showDeletePopUp , setshowDeletePopUp ] = useState < boolean > ( false ) ;
108
115
const [ deleteLoading , setdeleteLoading ] = useState < boolean > ( false ) ;
109
- const hasSelections = useHasSelections ( selectedNodes , selectedRels ) ;
116
+ const hasSelections = useHasSelections ( selectedNodes , selectedRels ) ;
110
117
111
118
const { updateStatusForLargeFiles } = useServerSideEvent (
112
119
( inMinutes , time , fileName ) => {
@@ -150,8 +157,10 @@ const Content: React.FC<ContentProps> = ({
150
157
? postProcessingTasks . filter ( ( task ) => task !== 'graph_schema_consolidation' )
151
158
: postProcessingTasks
152
159
: hasSelections
153
- ? postProcessingTasks . filter ( ( task ) => task !== 'graph_schema_consolidation' && task !== 'enable_communities' )
154
- : postProcessingTasks . filter ( ( task ) => task !== 'enable_communities' ) ;
160
+ ? postProcessingTasks . filter (
161
+ ( task ) => task !== 'graph_schema_consolidation' && task !== 'enable_communities'
162
+ )
163
+ : postProcessingTasks . filter ( ( task ) => task !== 'enable_communities' ) ;
155
164
const response = await postProcessing ( userCredentials as UserCredentials , payload ) ;
156
165
if ( response . data . status === 'Success' ) {
157
166
const communityfiles = response . data ?. data ;
@@ -381,7 +390,11 @@ const Content: React.FC<ContentProps> = ({
381
390
const addFilesToQueue = async ( remainingFiles : CustomFile [ ] ) => {
382
391
if ( ! remainingFiles . length ) {
383
392
showNormalToast (
384
- < PostProcessingToast isGdsActive = { isGdsActive } postProcessingTasks = { postProcessingTasks } isSchema = { hasSelections } />
393
+ < PostProcessingToast
394
+ isGdsActive = { isGdsActive }
395
+ postProcessingTasks = { postProcessingTasks }
396
+ isSchema = { hasSelections }
397
+ />
385
398
) ;
386
399
try {
387
400
const response = await postProcessing ( userCredentials as UserCredentials , postProcessingTasks ) ;
@@ -532,8 +545,9 @@ const Content: React.FC<ContentProps> = ({
532
545
const handleOpenGraphClick = ( ) => {
533
546
const bloomUrl = process . env . VITE_BLOOM_URL ;
534
547
const uriCoded = userCredentials ?. uri . replace ( / : \d + $ / , '' ) ;
535
- const connectURL = `${ uriCoded ?. split ( '//' ) [ 0 ] } //${ userCredentials ?. userName } @${ uriCoded ?. split ( '//' ) [ 1 ] } :${ userCredentials ?. port ?? '7687'
536
- } `;
548
+ const connectURL = `${ uriCoded ?. split ( '//' ) [ 0 ] } //${ userCredentials ?. userName } @${ uriCoded ?. split ( '//' ) [ 1 ] } :${
549
+ userCredentials ?. port ?? '7687'
550
+ } `;
537
551
const encodedURL = encodeURIComponent ( connectURL ) ;
538
552
const replacedUrl = bloomUrl ?. replace ( '{CONNECT_URL}' , encodedURL ) ;
539
553
window . open ( replacedUrl , '_blank' ) ;
@@ -586,19 +600,19 @@ const Content: React.FC<ContentProps> = ({
586
600
( response . data ?. message as string ) . includes ( 'Chunks are not created' )
587
601
) {
588
602
showNormalToast ( response . data . message as string ) ;
589
- retryOnclose ( )
603
+ retryOnclose ( ) ;
590
604
} else {
591
605
const isStartFromBegining = retryoption === RETRY_OPIONS [ 0 ] || retryoption === RETRY_OPIONS [ 1 ] ;
592
606
setFilesData ( ( prev ) => {
593
607
return prev . map ( ( f ) => {
594
608
return f . name === filename
595
609
? {
596
- ...f ,
597
- status : 'Ready to Reprocess' ,
598
- processingProgress : isStartFromBegining ? 0 : f . processingProgress ,
599
- nodesCount : isStartFromBegining ? 0 : f . nodesCount ,
600
- relationshipsCount : isStartFromBegining ? 0 : f . relationshipsCount ,
601
- }
610
+ ...f ,
611
+ status : 'Ready to Reprocess' ,
612
+ processingProgress : isStartFromBegining ? 0 : f . processingProgress ,
613
+ nodesCount : isStartFromBegining ? 0 : f . nodesCount ,
614
+ relationshipsCount : isStartFromBegining ? 0 : f . relationshipsCount ,
615
+ }
602
616
: f ;
603
617
} ) ;
604
618
} ) ;
@@ -706,7 +720,7 @@ const Content: React.FC<ContentProps> = ({
706
720
const selectedRows = childRef . current ?. getSelectedRows ( ) ;
707
721
if ( selectedRows ?. length ) {
708
722
const expiredFilesExists = selectedRows . some (
709
- ( c ) => c . status !== 'Ready to Reprocess' && isExpired ( c ?. createdAt as Date ?? new Date ( ) )
723
+ ( c ) => c . status !== 'Ready to Reprocess' && isExpired ( ( c ?. createdAt as Date ) ?? new Date ( ) )
710
724
) ;
711
725
const largeFileExists = selectedRows . some (
712
726
( c ) => isFileReadyToProcess ( c , true ) && typeof c . size === 'number' && c . size > largeFileSize
@@ -715,15 +729,12 @@ const Content: React.FC<ContentProps> = ({
715
729
setshowExpirationModal ( true ) ;
716
730
} else if ( largeFileExists && isGCSActive ) {
717
731
setshowConfirmationModal ( true ) ;
718
- } else if ( largeFileExists && isGCSActive ) {
719
732
setshowExpirationModal ( true ) ;
720
- } else {
733
+ } else {
721
734
handleGenerateGraph ( selectedRows . filter ( ( f ) => isFileReadyToProcess ( f , false ) ) ) ;
722
735
}
723
736
} else if ( filesData . length ) {
724
- const expiredFileExists = filesData . some (
725
- ( c ) => isExpired ( c ?. createdAt as Date )
726
- ) ;
737
+ const expiredFileExists = filesData . some ( ( c ) => isExpired ( c ?. createdAt as Date ) ) ;
727
738
const largeFileExists = filesData . some (
728
739
( c ) => isFileReadyToProcess ( c , true ) && typeof c . size === 'number' && c . size > largeFileSize
729
740
) ;
@@ -863,20 +874,12 @@ const Content: React.FC<ContentProps> = ({
863
874
uri = { userCredentials && userCredentials ?. uri }
864
875
/>
865
876
< div className = 'pt-1 flex gap-1 items-center' >
877
+ < div > { ! hasSelections ? < StatusIndicator type = 'danger' /> : < StatusIndicator type = 'success' /> } </ div >
866
878
< div >
867
- { ! hasSelections ? (
868
- < StatusIndicator type = 'danger' />
869
- ) :
870
- ( < StatusIndicator type = 'success' />
871
- ) }
872
- </ div >
873
- < div >
874
- { hasSelections ? (
879
+ { hasSelections ? (
875
880
< span className = 'n-body-small' >
876
- { ( hasSelections ) } Graph Schema configured
877
- { hasSelections
878
- ? `(${ selectedNodes . length } Labels + ${ selectedRels . length } Rel Types)`
879
- : '' }
881
+ { hasSelections } Graph Schema configured
882
+ { hasSelections ? `(${ selectedNodes . length } Labels + ${ selectedRels . length } Rel Types)` : '' }
880
883
</ span >
881
884
) : (
882
885
< span className = 'n-body-small' > No Graph Schema configured</ span >
@@ -913,7 +916,15 @@ const Content: React.FC<ContentProps> = ({
913
916
)
914
917
) }
915
918
</ div >
919
+ { connectionStatus && (
920
+ < Callout
921
+ className = '!w-[93%] m-auto '
922
+ type = 'note'
923
+ description = { `Large files may be partially processed up to ${ chunksToBeProces } chunks due to resource limits. If you need more comprehensive processing, consider splitting larger documents.` }
924
+ > </ Callout >
925
+ ) }
916
926
</ Flex >
927
+
917
928
< FileTable
918
929
connectionStatus = { connectionStatus }
919
930
setConnectionStatus = { setConnectionStatus }
@@ -940,6 +951,7 @@ const Content: React.FC<ContentProps> = ({
940
951
ref = { childRef }
941
952
handleGenerateGraph = { processWaitingFilesOnRefresh }
942
953
> </ FileTable >
954
+
943
955
< Flex
944
956
className = { `p-2.5 mt-1.5 absolute bottom-0 w-full` }
945
957
justifyContent = 'space-between'
0 commit comments