@@ -4,7 +4,15 @@ 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 { BannerAlertProps , ChildRef , ContentProps , CustomFile , OptionType , UserCredentials , chunkdata } from '../types' ;
7+ import {
8+ BannerAlertProps ,
9+ ContentProps ,
10+ CustomFile ,
11+ OptionType ,
12+ UserCredentials ,
13+ chunkdata ,
14+ FileTableHandle ,
15+ } from '../types' ;
816import deleteAPI from '../services/DeleteFiles' ;
917import { postProcessing } from '../services/PostProcessing' ;
1018import { triggerStatusUpdateAPI } from '../services/ServerSideStatusUpdateAPI' ;
@@ -35,7 +43,7 @@ import { useMessageContext } from '../context/UserMessages';
3543import PostProcessingToast from './Popups/GraphEnhancementDialog/PostProcessingCheckList/PostProcessingToast' ;
3644import { getChunkText } from '../services/getChunkText' ;
3745import ChunkPopUp from './Popups/ChunkPopUp' ;
38- import { isExpired } from '../utils/Utils' ;
46+ import { isExpired , isFileReadyToProcess } from '../utils/Utils' ;
3947
4048const ConfirmationDialog = lazy ( ( ) => import ( './Popups/LargeFilePopUp/ConfirmationDialog' ) ) ;
4149
@@ -106,7 +114,7 @@ const Content: React.FC<ContentProps> = ({
106114 showErrorToast ( `${ fileName } Failed to process` ) ;
107115 }
108116 ) ;
109- const childRef = useRef < ChildRef > ( null ) ;
117+ const childRef = useRef < FileTableHandle > ( null ) ;
110118
111119 const incrementPage = async ( ) => {
112120 setCurrentPage ( ( prev ) => prev + 1 ) ;
@@ -665,74 +673,38 @@ const Content: React.FC<ContentProps> = ({
665673 const onClickHandler = ( ) => {
666674 const selectedRows = childRef . current ?. getSelectedRows ( ) ;
667675 if ( selectedRows ?. length ) {
668- const selectedLargeFiles : CustomFile [ ] = [ ] ;
669- const expiredFiles : CustomFile [ ] = [ ] ;
670- for ( let index = 0 ; index < selectedRows . length ; index ++ ) {
671- const parsedData : CustomFile = selectedRows [ index ] ;
672- if (
673- parsedData . fileSource === 'local file' &&
674- typeof parsedData . size === 'number' &&
675- ( parsedData . status === 'New' || parsedData . status == 'Ready to Reprocess' ) &&
676- parsedData . size > largeFileSize
677- ) {
678- selectedLargeFiles . push ( parsedData ) ;
679- }
680- if (
681- parsedData . fileSource === 'local file' &&
682- ( parsedData . status === 'New' || parsedData . status == 'Ready to Reprocess' ) &&
683- isExpired ( parsedData ?. createdAt as Date )
684- ) {
685- expiredFiles . push ( parsedData ) ;
686- }
687- }
688- if ( selectedLargeFiles . length ) {
676+ const expiredFilesExists = selectedRows . some (
677+ ( c ) => isFileReadyToProcess ( c , true ) && isExpired ( c ?. createdAt as Date )
678+ ) ;
679+ const largeFileExists = selectedRows . some (
680+ ( c ) => isFileReadyToProcess ( c , true ) && typeof c . size === 'number' && c . size > largeFileSize
681+ ) ;
682+ if ( expiredFilesExists ) {
689683 setshowConfirmationModal ( true ) ;
690- } else if ( expiredFiles . length && isGCSActive ) {
684+ } else if ( largeFileExists && isGCSActive ) {
691685 setshowExpirationModal ( true ) ;
692686 } else {
693- handleGenerateGraph ( selectedRows . filter ( ( f ) => f . status === 'New' || f . status === 'Ready to Reprocess' ) ) ;
687+ handleGenerateGraph ( selectedRows . filter ( ( f ) => isFileReadyToProcess ( f , false ) ) ) ;
694688 }
695689 } else if ( filesData . length ) {
696- const largefiles = filesData . filter ( ( f ) => {
697- if (
698- typeof f . size === 'number' &&
699- ( f . status === 'New' || f . status == 'Ready to Reprocess' ) &&
700- f . size > largeFileSize
701- ) {
702- return true ;
703- }
704- return false ;
705- } ) ;
706- const expiredFiles = filesData . filter ( ( f ) => {
707- console . log (
708- f . fileSource === 'local file'
709- ? { isExpired : isExpired ( f ?. createdAt as Date ) , name : f . name , createdAt : f . createdAt }
710- : 'Not Local File'
711- ) ;
712- if (
713- f . fileSource === 'local file' &&
714- ( f . status === 'New' || f . status == 'Ready to Reprocess' ) &&
715- isExpired ( f ?. createdAt as Date )
716- ) {
717- return true ;
718- }
719- return false ;
720- } ) ;
721- const selectAllNewFiles = filesData . filter ( ( f ) => f . status === 'New' || f . status === 'Ready to Reprocess' ) ;
690+ const expiredFileExists = filesData . some ( ( c ) => isFileReadyToProcess ( c , true ) && isExpired ( c . createdAt as Date ) ) ;
691+ const largeFileExists = filesData . some (
692+ ( c ) => isFileReadyToProcess ( c , true ) && typeof c . size === 'number' && c . size > largeFileSize
693+ ) ;
694+ const selectAllNewFiles = filesData . filter ( ( f ) => isFileReadyToProcess ( f , false ) ) ;
722695 const stringified = selectAllNewFiles . reduce ( ( accu , f ) => {
723696 const key = f . id ;
724697 // @ts -ignore
725698 accu [ key ] = true ;
726699 return accu ;
727700 } , { } ) ;
728- console . log ( expiredFiles ) ;
729701 setRowSelection ( stringified ) ;
730- if ( largefiles . length ) {
702+ if ( largeFileExists ) {
731703 setshowConfirmationModal ( true ) ;
732- } else if ( expiredFiles . length && isGCSActive ) {
704+ } else if ( expiredFileExists && isGCSActive ) {
733705 setshowExpirationModal ( true ) ;
734706 } else {
735- handleGenerateGraph ( filesData . filter ( ( f ) => f . status === 'New' || f . status === 'Ready to Reprocess' ) ) ;
707+ handleGenerateGraph ( filesData . filter ( ( f ) => isFileReadyToProcess ( f , false ) ) ) ;
736708 }
737709 }
738710 } ;
0 commit comments