diff --git a/frontend/src/components/Content.tsx b/frontend/src/components/Content.tsx index e181f57a7..672eababb 100644 --- a/frontend/src/components/Content.tsx +++ b/frontend/src/components/Content.tsx @@ -50,8 +50,6 @@ const ConfirmationDialog = lazy(() => import('./Popups/LargeFilePopUp/Confirmati let afterFirstRender = false; const Content: React.FC = ({ - isSchema, - setIsSchema, showEnhancementDialog, toggleEnhancementDialog, setOpenConnection, @@ -141,17 +139,17 @@ const Content: React.FC = ({ 0 || selectedRels.length > 0} /> ); try { const payload = isGdsActive - ? isSchema + ? selectedNodes.length > 0 || selectedRels.length > 0 ? postProcessingTasks.filter((task) => task !== 'graph_cleanup') : postProcessingTasks - : isSchema - ? postProcessingTasks.filter((task) => task !== 'graph_cleanup' && task !== 'enable_communities') - : postProcessingTasks.filter((task) => task !== 'enable_communities'); + : selectedNodes.length > 0 || selectedRels.length > 0 + ? postProcessingTasks.filter((task) => task !== 'graph_cleanup' && task !== 'enable_communities') + : postProcessingTasks.filter((task) => task !== 'enable_communities'); const response = await postProcessing(userCredentials as UserCredentials, payload); if (response.data.status === 'Success') { const communityfiles = response.data?.data; @@ -197,13 +195,6 @@ const Content: React.FC = ({ afterFirstRender = true; }, [queue.items.length, userCredentials]); - useEffect(() => { - const storedSchema = localStorage.getItem('isSchema'); - if (storedSchema !== null) { - setIsSchema(JSON.parse(storedSchema)); - } - }, [isSchema]); - const handleDropdownChange = (selectedOption: OptionType | null | void) => { if (selectedOption?.value) { setModel(selectedOption?.value); @@ -388,7 +379,7 @@ const Content: React.FC = ({ const addFilesToQueue = async (remainingFiles: CustomFile[]) => { if (!remainingFiles.length) { showNormalToast( - + 0 || selectedRels.length > 0} /> ); try { const response = await postProcessing(userCredentials as UserCredentials, postProcessingTasks); @@ -539,9 +530,8 @@ const Content: React.FC = ({ const handleOpenGraphClick = () => { const bloomUrl = process.env.VITE_BLOOM_URL; const uriCoded = userCredentials?.uri.replace(/:\d+$/, ''); - const connectURL = `${uriCoded?.split('//')[0]}//${userCredentials?.userName}@${uriCoded?.split('//')[1]}:${ - userCredentials?.port ?? '7687' - }`; + const connectURL = `${uriCoded?.split('//')[0]}//${userCredentials?.userName}@${uriCoded?.split('//')[1]}:${userCredentials?.port ?? '7687' + }`; const encodedURL = encodeURIComponent(connectURL); const replacedUrl = bloomUrl?.replace('{CONNECT_URL}', encodedURL); window.open(replacedUrl, '_blank'); @@ -601,12 +591,12 @@ const Content: React.FC = ({ return prev.map((f) => { return f.name === filename ? { - ...f, - status: 'Ready to Reprocess', - processingProgress: isStartFromBegining ? 0 : f.processingProgress, - nodesCount: isStartFromBegining ? 0 : f.nodesCount, - relationshipsCount: isStartFromBegining ? 0 : f.relationshipsCount, - } + ...f, + status: 'Ready to Reprocess', + processingProgress: isStartFromBegining ? 0 : f.processingProgress, + nodesCount: isStartFromBegining ? 0 : f.nodesCount, + relationshipsCount: isStartFromBegining ? 0 : f.relationshipsCount, + } : f; }); }); @@ -714,20 +704,22 @@ const Content: React.FC = ({ const selectedRows = childRef.current?.getSelectedRows(); if (selectedRows?.length) { const expiredFilesExists = selectedRows.some( - (c) => isFileReadyToProcess(c, true) && isExpired(c?.createdAt as Date) + (c) => c.status !== 'Ready to Reprocess' && isExpired(c?.createdAt as Date) ); const largeFileExists = selectedRows.some( (c) => isFileReadyToProcess(c, true) && typeof c.size === 'number' && c.size > largeFileSize ); if (expiredFilesExists) { - setshowConfirmationModal(true); - } else if (largeFileExists && isGCSActive) { setshowExpirationModal(true); + } else if (largeFileExists && isGCSActive) { + setshowConfirmationModal(true); } else { handleGenerateGraph(selectedRows.filter((f) => isFileReadyToProcess(f, false))); } } else if (filesData.length) { - const expiredFileExists = filesData.some((c) => isFileReadyToProcess(c, true) && isExpired(c.createdAt as Date)); + const expiredFileExists = filesData.some( + (c) => isExpired(c.createdAt as Date) + ); const largeFileExists = filesData.some( (c) => isFileReadyToProcess(c, true) && typeof c.size === 'number' && c.size > largeFileSize ); @@ -744,7 +736,7 @@ const Content: React.FC = ({ } else if (expiredFileExists && isGCSActive) { setshowExpirationModal(true); } else { - handleGenerateGraph(filesData.filter((f) => isFileReadyToProcess(f, false))); + handleGenerateGraph(filesData.filter((f) => f.status === 'New' || f.status === 'Ready to Reprocess')); } } }; @@ -788,6 +780,7 @@ const Content: React.FC = ({ onClose={() => setshowConfirmationModal(false)} loading={extractLoading} selectedRows={childRef.current?.getSelectedRows() as CustomFile[]} + isLargeDocumentAlert={true} > )} @@ -854,16 +847,14 @@ const Content: React.FC = ({ />
- {!isSchema ? ( + {selectedNodes.length === 0 || selectedRels.length === 0 ? ( - ) : selectedNodes.length || selectedRels.length ? ( - - ) : ( - - )} + ) : + ( + )}
- {isSchema ? ( + {selectedNodes.length > 0 || selectedRels.length > 0 ? ( {(!selectedNodes.length || !selectedRels.length) && 'Empty'} Graph Schema configured {selectedNodes.length || selectedRels.length diff --git a/frontend/src/components/Layout/Header.tsx b/frontend/src/components/Layout/Header.tsx index 2cd243b29..f722440c9 100644 --- a/frontend/src/components/Layout/Header.tsx +++ b/frontend/src/components/Layout/Header.tsx @@ -11,10 +11,9 @@ import { ArrowDownTrayIconOutline, } from '@neo4j-ndl/react/icons'; import { Button, TextLink, Typography } from '@neo4j-ndl/react'; -import { Dispatch, memo, SetStateAction, useCallback, useContext, useEffect, useRef, useState } from 'react'; +import { Dispatch, memo, SetStateAction, useCallback, useContext, useRef, useState } from 'react'; import { IconButtonWithToolTip } from '../UI/IconButtonToolTip'; import { buttonCaptions, tooltips } from '../../utils/Constants'; -import { useFileContext } from '../../context/UsersFiles'; import { ThemeWrapperContext } from '../../context/ThemeWrapper'; import { useCredentials } from '../../context/UserCredentials'; import { useNavigate } from 'react-router'; @@ -39,13 +38,9 @@ const Header: React.FC = ({ chatOnly, deleteOnClick, setOpenConnecti window.open(url, '_blank'); }, []); const downloadLinkRef = useRef(null); - const { isSchema, setIsSchema } = useFileContext(); const { connectionStatus } = useCredentials(); const chatAnchor = useRef(null); const [showChatModeOption, setshowChatModeOption] = useState(false); - useEffect(() => { - setIsSchema(isSchema); - }, [isSchema]); const openChatPopout = useCallback(() => { let session = localStorage.getItem('neo4j.connection'); diff --git a/frontend/src/components/Layout/PageLayout.tsx b/frontend/src/components/Layout/PageLayout.tsx index 1b6b478eb..69dcf155b 100644 --- a/frontend/src/components/Layout/PageLayout.tsx +++ b/frontend/src/components/Layout/PageLayout.tsx @@ -52,7 +52,7 @@ const PageLayout: React.FC = () => { }; const { messages, setClearHistoryData, clearHistoryData, setMessages, setIsDeleteChatLoading } = useMessageContext(); - const { isSchema, setIsSchema, setShowTextFromSchemaDialog, showTextFromSchemaDialog } = useFileContext(); + const { setShowTextFromSchemaDialog, showTextFromSchemaDialog } = useFileContext(); const { setConnectionStatus, setGdsActive, @@ -289,8 +289,6 @@ const PageLayout: React.FC = () => { openTextSchema={() => { setShowTextFromSchemaDialog({ triggeredFrom: 'schemadialog', show: true }); }} - isSchema={isSchema} - setIsSchema={setIsSchema} showEnhancementDialog={showEnhancementDialog} toggleEnhancementDialog={toggleEnhancementDialog} setOpenConnection={setOpenConnection} @@ -349,8 +347,6 @@ const PageLayout: React.FC = () => { openTextSchema={() => { setShowTextFromSchemaDialog({ triggeredFrom: 'schemadialog', show: true }); }} - isSchema={isSchema} - setIsSchema={setIsSchema} showEnhancementDialog={showEnhancementDialog} toggleEnhancementDialog={toggleEnhancementDialog} setOpenConnection={setOpenConnection} diff --git a/frontend/src/components/Popups/ExpirationModal/ExpiredFilesAlert.tsx b/frontend/src/components/Popups/ExpirationModal/ExpiredFilesAlert.tsx index 23738820c..2207c866a 100644 --- a/frontend/src/components/Popups/ExpirationModal/ExpiredFilesAlert.tsx +++ b/frontend/src/components/Popups/ExpirationModal/ExpiredFilesAlert.tsx @@ -7,6 +7,7 @@ import BellImage from '../../../assets/images/Stopwatch-blue.svg'; import AlertIcon from '../../Layout/AlertIcon'; import { isExpired } from '../../../utils/Utils'; import { EXPIRATION_DAYS } from '../../../utils/Constants'; +import { IconWithToolTip } from '../../UI/IconButtonToolTip'; const ExpiredFilesAlert: FC = ({ Files, handleToggle, checked }) => { return ( @@ -31,14 +32,8 @@ const ExpiredFilesAlert: FC = ({ Files, handleToggle, checked } { - if (e.target.checked) { - handleToggle(true, f.id); - } else { - handleToggle(false, f.id); - } - }} - isChecked={checked.indexOf(f.id) !== -1} + isChecked={checked.includes(f.id)} + onChange={(e) => handleToggle(e.target.checked, f.id)} htmlAttributes={{ tabIndex: -1 }} /> @@ -53,7 +48,9 @@ const ExpiredFilesAlert: FC = ({ Files, handleToggle, checked } {f.createdAt != undefined && isExpired(f.createdAt) ? ( - + + + ) : ( <> diff --git a/frontend/src/components/Popups/GraphEnhancementDialog/EnitityExtraction/EntityExtractionSetting.tsx b/frontend/src/components/Popups/GraphEnhancementDialog/EnitityExtraction/EntityExtractionSetting.tsx index 9743e5b14..4785952ae 100644 --- a/frontend/src/components/Popups/GraphEnhancementDialog/EnitityExtraction/EntityExtractionSetting.tsx +++ b/frontend/src/components/Popups/GraphEnhancementDialog/EnitityExtraction/EntityExtractionSetting.tsx @@ -35,8 +35,6 @@ export default function EntityExtractionSetting({ selectedRels, selectedSchemas, setSelectedSchemas, - isSchema, - setIsSchema, } = useFileContext(); const { userCredentials } = useCredentials(); const [loading, setLoading] = useState(false); @@ -60,7 +58,6 @@ export default function EntityExtractionSetting({ ); return filteredrels; }); - localStorage.setItem('isSchema', JSON.stringify(false)); }; const onChangeSchema = (selectedOptions: OnChangeValue, actionMeta: ActionMeta) => { if (actionMeta.action === 'remove-value') { @@ -120,20 +117,15 @@ export default function EntityExtractionSetting({ 'selectedRelationshipLabels', JSON.stringify({ db: userCredentials?.uri, selectedOptions: updatedOptions }) ); - localStorage.setItem('isSchema', JSON.stringify(true)); return updatedOptions; }); - setIsSchema(true); }; const onChangenodes = (selectedOptions: OnChangeValue, actionMeta: ActionMeta) => { if (actionMeta.action === 'clear') { localStorage.setItem('selectedNodeLabels', JSON.stringify({ db: userCredentials?.uri, selectedOptions: [] })); - localStorage.setItem('isSchema', JSON.stringify(false)); } setSelectedNodes(selectedOptions); - setIsSchema(true); localStorage.setItem('selectedNodeLabels', JSON.stringify({ db: userCredentials?.uri, selectedOptions })); - localStorage.setItem('isSchema', JSON.stringify(true)); }; const onChangerels = (selectedOptions: OnChangeValue, actionMeta: ActionMeta) => { if (actionMeta.action === 'clear') { @@ -143,7 +135,6 @@ export default function EntityExtractionSetting({ ); } setSelectedRels(selectedOptions); - setIsSchema(true); localStorage.setItem('selectedRelationshipLabels', JSON.stringify({ db: userCredentials?.uri, selectedOptions })); }; const [nodeLabelOptions, setnodeLabelOptions] = useState([]); @@ -190,8 +181,6 @@ export default function EntityExtractionSetting({ } }; getOptions(); - setIsSchema(true); - localStorage.setItem('isSchema', JSON.stringify(true)); } } }, [userCredentials, open]); @@ -200,8 +189,6 @@ export default function EntityExtractionSetting({ setSelectedSchemas([]); setSelectedNodes(nodeLabelOptions); setSelectedRels(relationshipTypeOptions); - setIsSchema(true); - localStorage.setItem('isSchema', JSON.stringify(true)); localStorage.setItem( 'selectedNodeLabels', JSON.stringify({ db: userCredentials?.uri, selectedOptions: nodeLabelOptions }) @@ -213,11 +200,9 @@ export default function EntityExtractionSetting({ }, [nodeLabelOptions, relationshipTypeOptions]); const handleClear = () => { - setIsSchema(false); setSelectedNodes([]); setSelectedRels([]); setSelectedSchemas([]); - localStorage.setItem('isSchema', JSON.stringify(false)); localStorage.setItem('selectedNodeLabels', JSON.stringify({ db: userCredentials?.uri, selectedOptions: [] })); localStorage.setItem( 'selectedRelationshipLabels', @@ -230,8 +215,6 @@ export default function EntityExtractionSetting({ } }; const handleApply = () => { - setIsSchema(true); - localStorage.setItem('isSchema', JSON.stringify(true)); showNormalToast(`Successfully Applied the Schema settings`); if (view === 'Tabs' && closeEnhanceGraphSchemaDialog != undefined) { closeEnhanceGraphSchemaDialog(); @@ -363,7 +346,7 @@ export default function EntityExtractionSetting({ placement='top' onClick={handleClear} label='Clear Graph Settings' - disabled={!isSchema} + disabled={selectedNodes.length === 0 || selectedRels.length === 0} > {buttonCaptions.clearSettings} @@ -373,7 +356,7 @@ export default function EntityExtractionSetting({ placement='top' onClick={handleApply} label='Apply Graph Settings' - disabled={!isSchema} + disabled={selectedNodes.length === 0 || selectedRels.length === 0} > {buttonCaptions.applyGraphSchema} diff --git a/frontend/src/components/Popups/GraphEnhancementDialog/PostProcessingCheckList/index.tsx b/frontend/src/components/Popups/GraphEnhancementDialog/PostProcessingCheckList/index.tsx index 4d65c8ea8..c55d47eac 100644 --- a/frontend/src/components/Popups/GraphEnhancementDialog/PostProcessingCheckList/index.tsx +++ b/frontend/src/components/Popups/GraphEnhancementDialog/PostProcessingCheckList/index.tsx @@ -7,7 +7,7 @@ import { useCredentials } from '../../../../context/UserCredentials'; export default function PostProcessingCheckList() { const { breakpoints } = tokens; const tablet = useMediaQuery(`(min-width:${breakpoints.xs}) and (max-width: ${breakpoints.lg})`); - const { postProcessingTasks, setPostProcessingTasks, selectedNodes, selectedRels, isSchema } = useFileContext(); + const { postProcessingTasks, setPostProcessingTasks, selectedNodes, selectedRels } = useFileContext(); const { isGdsActive } = useCredentials(); return ( @@ -22,7 +22,7 @@ export default function PostProcessingCheckList() { {POST_PROCESSING_JOBS.map((job, idx) => { const isGraphCleanupDisabled = job.title === 'graph_cleanup' - ? !(isSchema && selectedNodes.length === 0 && selectedRels.length === 0) + ? !(selectedNodes.length === 0 && selectedRels.length === 0) : false; const isDisabled = job.title === 'enable_communities' diff --git a/frontend/src/components/Popups/LargeFilePopUp/ConfirmationDialog.tsx b/frontend/src/components/Popups/LargeFilePopUp/ConfirmationDialog.tsx index 7762d0d77..e6273ce22 100644 --- a/frontend/src/components/Popups/LargeFilePopUp/ConfirmationDialog.tsx +++ b/frontend/src/components/Popups/LargeFilePopUp/ConfirmationDialog.tsx @@ -13,7 +13,7 @@ function ConfirmationDialog({ loading, extractHandler, selectedRows, - isLargeDocumentAlert = true, + isLargeDocumentAlert = false, }: { largeFiles: CustomFile[]; open: boolean; diff --git a/frontend/src/components/Popups/Settings/SchemaFromText.tsx b/frontend/src/components/Popups/Settings/SchemaFromText.tsx index f59ec86bf..791db5466 100644 --- a/frontend/src/components/Popups/Settings/SchemaFromText.tsx +++ b/frontend/src/components/Popups/Settings/SchemaFromText.tsx @@ -12,13 +12,13 @@ const SchemaFromTextDialog = ({ open, onClose }: { open: boolean; onClose: () => const [loading, setloading] = useState(false); const { setSelectedNodes, setSelectedRels } = useFileContext(); const { userCredentials } = useCredentials(); - const [isSchema, setIsSchema] = useState(false); + const [isSchemaText, setIsSchemaText] = useState(false); const { model } = useFileContext(); const clickHandler = useCallback(async () => { try { setloading(true); - const response = await getNodeLabelsAndRelTypesFromText(model, userText, isSchema); + const response = await getNodeLabelsAndRelTypesFromText(model, userText, isSchemaText); setloading(false); if (response.data.status === 'Success') { if (response.data?.data?.labels.length) { @@ -75,12 +75,12 @@ const SchemaFromTextDialog = ({ open, onClose }: { open: boolean; onClose: () => } onClose(); setUserText(''); - setIsSchema(false); + setIsSchemaText(false); } catch (error) { setloading(false); console.log(error); } - }, [userCredentials, userText, isSchema]); + }, [userCredentials, userText, isSchemaText]); return ( isOpen={open} onClose={() => { setloading(false); - setIsSchema(false); + setIsSchemaText(false); setUserText(''); onClose(); }} @@ -115,9 +115,9 @@ const SchemaFromTextDialog = ({ open, onClose }: { open: boolean; onClose: () => { - setIsSchema(e.target.checked); + setIsSchemaText(e.target.checked); }} - isChecked={isSchema} + isChecked={isSchemaText} /> = ({ children }) => { const [rowSelection, setRowSelection] = useState>({}); const [selectedRows, setSelectedRows] = useState([]); const [chatModes, setchatModes] = useState([chatModeLables['graph+vector+fulltext']]); - const [isSchema, setIsSchema] = useState(false); const [showTextFromSchemaDialog, setShowTextFromSchemaDialog] = useState({ triggeredFrom: '', show: false, @@ -90,8 +89,6 @@ const FileContextProvider: FC = ({ children }) => { setSelectedSchemas, chatModes, setchatModes, - isSchema, - setIsSchema, setShowTextFromSchemaDialog, showTextFromSchemaDialog, postProcessingTasks, diff --git a/frontend/src/types.ts b/frontend/src/types.ts index 4cf99a83e..d1b46124e 100644 --- a/frontend/src/types.ts +++ b/frontend/src/types.ts @@ -149,8 +149,6 @@ export interface ContentProps { showChatBot: boolean; openChatBot: () => void; openTextSchema: () => void; - isSchema: boolean; - setIsSchema: Dispatch>; showEnhancementDialog: boolean; toggleEnhancementDialog: () => void; setOpenConnection: Dispatch>; @@ -857,8 +855,6 @@ export interface FileContextType { setSelectedSchemas: Dispatch>; chatModes: string[]; setchatModes: Dispatch>; - isSchema: boolean; - setIsSchema: React.Dispatch>; showTextFromSchemaDialog: showTextFromSchemaDialogType; setShowTextFromSchemaDialog: React.Dispatch>; postProcessingTasks: string[]; diff --git a/frontend/src/utils/Utils.ts b/frontend/src/utils/Utils.ts index 206a2d097..58e66b1f5 100644 --- a/frontend/src/utils/Utils.ts +++ b/frontend/src/utils/Utils.ts @@ -540,7 +540,7 @@ export function isExpired(itemdate: Date) { export function isFileReadyToProcess(file: CustomFile, withLocalCheck: boolean) { if (withLocalCheck) { - return file.fileSource === 'local file' && (file.status === 'New' || file.status == 'Ready to Reprocess'); + return file.fileSource === 'local file' && (file.status === 'New'); } return file.status === 'New' || file.status == 'Ready to Reprocess'; }