@@ -4,15 +4,7 @@ import { Button, Typography, Flex, StatusIndicator, useMediaQuery } from '@neo4j
44import { useCredentials } from '../context/UserCredentials' ;
55import { useFileContext } from '../context/UsersFiles' ;
66import { extractAPI } from '../utils/FileAPI' ;
7- import {
8- BannerAlertProps ,
9- ContentProps ,
10- CustomFile ,
11- OptionType ,
12- UserCredentials ,
13- chunkdata ,
14- FileTableHandle ,
15- } from '../types' ;
7+ import { BannerAlertProps , ContentProps , CustomFile , OptionType , chunkdata , FileTableHandle } from '../types' ;
168import deleteAPI from '../services/DeleteFiles' ;
179import { postProcessing } from '../services/PostProcessing' ;
1810import { triggerStatusUpdateAPI } from '../services/ServerSideStatusUpdateAPI' ;
@@ -157,34 +149,36 @@ const Content: React.FC<ContentProps> = ({
157149 ( task ) => task !== 'graph_schema_consolidation' && task !== 'enable_communities'
158150 )
159151 : postProcessingTasks . filter ( ( task ) => task !== 'enable_communities' ) ;
160- const response = await postProcessing ( userCredentials as UserCredentials , payload ) ;
161- if ( response . data . status === 'Success' ) {
162- const communityfiles = response . data ?. data ;
163- if ( Array . isArray ( communityfiles ) && communityfiles . length ) {
164- communityfiles ?. forEach ( ( c : any ) => {
165- setFilesData ( ( prev ) => {
166- return prev . map ( ( f ) => {
167- if ( f . name === c . filename ) {
168- return {
169- ...f ,
170- chunkNodeCount : c . chunkNodeCount ?? 0 ,
171- entityNodeCount : c . entityNodeCount ?? 0 ,
172- communityNodeCount : c . communityNodeCount ?? 0 ,
173- chunkRelCount : c . chunkRelCount ?? 0 ,
174- entityEntityRelCount : c . entityEntityRelCount ?? 0 ,
175- communityRelCount : c . communityRelCount ?? 0 ,
176- nodesCount : c . nodeCount ,
177- relationshipsCount : c . relationshipCount ,
178- } ;
179- }
180- return f ;
152+ if ( payload . length ) {
153+ const response = await postProcessing ( payload ) ;
154+ if ( response . data . status === 'Success' ) {
155+ const communityfiles = response . data ?. data ;
156+ if ( Array . isArray ( communityfiles ) && communityfiles . length ) {
157+ communityfiles ?. forEach ( ( c : any ) => {
158+ setFilesData ( ( prev ) => {
159+ return prev . map ( ( f ) => {
160+ if ( f . name === c . filename ) {
161+ return {
162+ ...f ,
163+ chunkNodeCount : c . chunkNodeCount ?? 0 ,
164+ entityNodeCount : c . entityNodeCount ?? 0 ,
165+ communityNodeCount : c . communityNodeCount ?? 0 ,
166+ chunkRelCount : c . chunkRelCount ?? 0 ,
167+ entityEntityRelCount : c . entityEntityRelCount ?? 0 ,
168+ communityRelCount : c . communityRelCount ?? 0 ,
169+ nodesCount : c . nodeCount ,
170+ relationshipsCount : c . relationshipCount ,
171+ } ;
172+ }
173+ return f ;
174+ } ) ;
181175 } ) ;
182176 } ) ;
183- } ) ;
177+ }
178+ showSuccessToast ( 'All Q&A functionality is available now.' ) ;
179+ } else {
180+ throw new Error ( response . data . error ) ;
184181 }
185- showSuccessToast ( 'All Q&A functionality is available now.' ) ;
186- } else {
187- throw new Error ( response . data . error ) ;
188182 }
189183 } catch ( error ) {
190184 if ( error instanceof Error ) {
@@ -220,7 +214,7 @@ const Content: React.FC<ContentProps> = ({
220214 } ;
221215 const getChunks = async ( name : string , pageNo : number ) => {
222216 toggleChunksLoading ( ) ;
223- const response = await getChunkText ( userCredentials as UserCredentials , name , pageNo ) ;
217+ const response = await getChunkText ( name , pageNo ) ;
224218 setTextChunks ( response . data . data . pageitems ) ;
225219 if ( ! totalPageCount ) {
226220 setTotalPageCount ( response . data . data . total_pages ) ;
@@ -281,7 +275,6 @@ const Content: React.FC<ContentProps> = ({
281275
282276 const apiResponse = await extractAPI (
283277 fileItem . model ,
284- userCredentials as UserCredentials ,
285278 fileItem . fileSource ,
286279 fileItem . retryOption ?? '' ,
287280 fileItem . sourceUrl ,
@@ -384,7 +377,7 @@ const Content: React.FC<ContentProps> = ({
384377 } ;
385378
386379 const addFilesToQueue = async ( remainingFiles : CustomFile [ ] ) => {
387- if ( ! remainingFiles . length ) {
380+ if ( ! remainingFiles . length && postProcessingTasks . length ) {
388381 showNormalToast (
389382 < PostProcessingToast
390383 isGdsActive = { isGdsActive }
@@ -393,7 +386,7 @@ const Content: React.FC<ContentProps> = ({
393386 />
394387 ) ;
395388 try {
396- const response = await postProcessing ( userCredentials as UserCredentials , postProcessingTasks ) ;
389+ const response = await postProcessing ( postProcessingTasks ) ;
397390 if ( response . data . status === 'Success' ) {
398391 const communityfiles = response . data ?. data ;
399392 if ( Array . isArray ( communityfiles ) && communityfiles . length ) {
@@ -561,7 +554,7 @@ const Content: React.FC<ContentProps> = ({
561554 setConnectionStatus ( false ) ;
562555 localStorage . removeItem ( 'password' ) ;
563556 localStorage . removeItem ( 'selectedModel' ) ;
564- setUserCredentials ( { uri : '' , password : '' , userName : '' , database : '' } ) ;
557+ setUserCredentials ( { uri : '' , password : '' , userName : '' , database : '' , email : '' } ) ;
565558 setSelectedNodes ( [ ] ) ;
566559 setSelectedRels ( [ ] ) ;
567560 localStorage . removeItem ( 'instructions' ) ;
@@ -586,7 +579,7 @@ const Content: React.FC<ContentProps> = ({
586579 const retryHandler = async ( filename : string , retryoption : string ) => {
587580 try {
588581 setRetryLoading ( true ) ;
589- const response = await retry ( userCredentials as UserCredentials , filename , retryoption ) ;
582+ const response = await retry ( filename , retryoption ) ;
590583 setRetryLoading ( false ) ;
591584 if ( response . data . status === 'Failure' ) {
592585 throw new Error ( response . data . error ) ;
@@ -677,11 +670,7 @@ const Content: React.FC<ContentProps> = ({
677670 const handleDeleteFiles = async ( deleteEntities : boolean ) => {
678671 try {
679672 setIsDeleteLoading ( true ) ;
680- const response = await deleteAPI (
681- userCredentials as UserCredentials ,
682- childRef . current ?. getSelectedRows ( ) as CustomFile [ ] ,
683- deleteEntities
684- ) ;
673+ const response = await deleteAPI ( childRef . current ?. getSelectedRows ( ) as CustomFile [ ] , deleteEntities ) ;
685674 queue . clear ( ) ;
686675 setProcessedCount ( 0 ) ;
687676 setRowSelection ( { } ) ;
@@ -716,7 +705,7 @@ const Content: React.FC<ContentProps> = ({
716705 const selectedRows = childRef . current ?. getSelectedRows ( ) ;
717706 if ( selectedRows ?. length ) {
718707 const expiredFilesExists = selectedRows . some (
719- ( c ) => c . status !== 'Ready to Reprocess' && isExpired ( ( c ?. createdAt as Date ) ?? new Date ( ) )
708+ ( c ) => isFileReadyToProcess ( c , true ) && isExpired ( ( c ?. createdAt as Date ) ?? new Date ( ) )
720709 ) ;
721710 const largeFileExists = selectedRows . some (
722711 ( c ) => isFileReadyToProcess ( c , true ) && typeof c . size === 'number' && c . size > largeFileSize
@@ -729,7 +718,7 @@ const Content: React.FC<ContentProps> = ({
729718 handleGenerateGraph ( selectedRows . filter ( ( f ) => isFileReadyToProcess ( f , false ) ) ) ;
730719 }
731720 } else if ( filesData . length ) {
732- const expiredFileExists = filesData . some ( ( c ) => isExpired ( c ?. createdAt as Date ) ) ;
721+ const expiredFileExists = filesData . some ( ( c ) => isFileReadyToProcess ( c , true ) && isExpired ( c ?. createdAt as Date ) ) ;
733722 const largeFileExists = filesData . some (
734723 ( c ) => isFileReadyToProcess ( c , true ) && typeof c . size === 'number' && c . size > largeFileSize
735724 ) ;
0 commit comments