Skip to content

Removal of isSchema check for graphType post processing Job #990

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jan 8, 2025
63 changes: 27 additions & 36 deletions frontend/src/components/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ const ConfirmationDialog = lazy(() => import('./Popups/LargeFilePopUp/Confirmati
let afterFirstRender = false;

const Content: React.FC<ContentProps> = ({
isSchema,
setIsSchema,
showEnhancementDialog,
toggleEnhancementDialog,
setOpenConnection,
Expand Down Expand Up @@ -141,17 +139,17 @@ const Content: React.FC<ContentProps> = ({
<PostProcessingToast
isGdsActive={isGdsActive}
postProcessingTasks={postProcessingTasks}
isSchema={isSchema}
isSchema={selectedNodes.length > 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;
Expand Down Expand Up @@ -197,13 +195,6 @@ const Content: React.FC<ContentProps> = ({
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);
Expand Down Expand Up @@ -388,7 +379,7 @@ const Content: React.FC<ContentProps> = ({
const addFilesToQueue = async (remainingFiles: CustomFile[]) => {
if (!remainingFiles.length) {
showNormalToast(
<PostProcessingToast isGdsActive={isGdsActive} postProcessingTasks={postProcessingTasks} isSchema={isSchema} />
<PostProcessingToast isGdsActive={isGdsActive} postProcessingTasks={postProcessingTasks} isSchema={selectedNodes.length > 0 || selectedRels.length > 0} />
);
try {
const response = await postProcessing(userCredentials as UserCredentials, postProcessingTasks);
Expand Down Expand Up @@ -539,9 +530,8 @@ const Content: React.FC<ContentProps> = ({
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');
Expand Down Expand Up @@ -601,12 +591,12 @@ const Content: React.FC<ContentProps> = ({
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;
});
});
Expand Down Expand Up @@ -714,20 +704,22 @@ const Content: React.FC<ContentProps> = ({
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
);
Expand All @@ -744,7 +736,7 @@ const Content: React.FC<ContentProps> = ({
} 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'));
}
}
};
Expand Down Expand Up @@ -788,6 +780,7 @@ const Content: React.FC<ContentProps> = ({
onClose={() => setshowConfirmationModal(false)}
loading={extractLoading}
selectedRows={childRef.current?.getSelectedRows() as CustomFile[]}
isLargeDocumentAlert={true}
></ConfirmationDialog>
</Suspense>
)}
Expand Down Expand Up @@ -854,16 +847,14 @@ const Content: React.FC<ContentProps> = ({
/>
<div className='pt-1 flex gap-1 items-center'>
<div>
{!isSchema ? (
{selectedNodes.length === 0 || selectedRels.length === 0 ? (
<StatusIndicator type='danger' />
) : selectedNodes.length || selectedRels.length ? (
<StatusIndicator type='success' />
) : (
<StatusIndicator type='warning' />
)}
) :
(<StatusIndicator type='success' />
)}
</div>
<div>
{isSchema ? (
{selectedNodes.length > 0 || selectedRels.length > 0 ? (
<span className='n-body-small'>
{(!selectedNodes.length || !selectedRels.length) && 'Empty'} Graph Schema configured
{selectedNodes.length || selectedRels.length
Expand Down
7 changes: 1 addition & 6 deletions frontend/src/components/Layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -39,13 +38,9 @@ const Header: React.FC<HeaderProp> = ({ chatOnly, deleteOnClick, setOpenConnecti
window.open(url, '_blank');
}, []);
const downloadLinkRef = useRef<HTMLAnchorElement>(null);
const { isSchema, setIsSchema } = useFileContext();
const { connectionStatus } = useCredentials();
const chatAnchor = useRef<HTMLDivElement>(null);
const [showChatModeOption, setshowChatModeOption] = useState<boolean>(false);
useEffect(() => {
setIsSchema(isSchema);
}, [isSchema]);

const openChatPopout = useCallback(() => {
let session = localStorage.getItem('neo4j.connection');
Expand Down
6 changes: 1 addition & 5 deletions frontend/src/components/Layout/PageLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -289,8 +289,6 @@ const PageLayout: React.FC = () => {
openTextSchema={() => {
setShowTextFromSchemaDialog({ triggeredFrom: 'schemadialog', show: true });
}}
isSchema={isSchema}
setIsSchema={setIsSchema}
showEnhancementDialog={showEnhancementDialog}
toggleEnhancementDialog={toggleEnhancementDialog}
setOpenConnection={setOpenConnection}
Expand Down Expand Up @@ -349,8 +347,6 @@ const PageLayout: React.FC = () => {
openTextSchema={() => {
setShowTextFromSchemaDialog({ triggeredFrom: 'schemadialog', show: true });
}}
isSchema={isSchema}
setIsSchema={setIsSchema}
showEnhancementDialog={showEnhancementDialog}
toggleEnhancementDialog={toggleEnhancementDialog}
setOpenConnection={setOpenConnection}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<LargefilesProps> = ({ Files, handleToggle, checked }) => {
return (
Expand All @@ -31,14 +32,8 @@ const ExpiredFilesAlert: FC<LargefilesProps> = ({ Files, handleToggle, checked }
<ListItemIcon>
<Checkbox
ariaLabel='selection checkbox'
onChange={(e) => {
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 }}
/>
</ListItemIcon>
Expand All @@ -53,7 +48,9 @@ const ExpiredFilesAlert: FC<LargefilesProps> = ({ Files, handleToggle, checked }
</span>
{f.createdAt != undefined && isExpired(f.createdAt) ? (
<span>
<AlertIcon />
<IconWithToolTip label={'expired'} text={'File has expired'} placement='top'>
<AlertIcon />
</IconWithToolTip>
</span>
) : (
<></>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ export default function EntityExtractionSetting({
selectedRels,
selectedSchemas,
setSelectedSchemas,
isSchema,
setIsSchema,
} = useFileContext();
const { userCredentials } = useCredentials();
const [loading, setLoading] = useState<boolean>(false);
Expand All @@ -60,7 +58,6 @@ export default function EntityExtractionSetting({
);
return filteredrels;
});
localStorage.setItem('isSchema', JSON.stringify(false));
};
const onChangeSchema = (selectedOptions: OnChangeValue<OptionType, true>, actionMeta: ActionMeta<OptionType>) => {
if (actionMeta.action === 'remove-value') {
Expand Down Expand Up @@ -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<OptionType, true>, actionMeta: ActionMeta<OptionType>) => {
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<OptionType, true>, actionMeta: ActionMeta<OptionType>) => {
if (actionMeta.action === 'clear') {
Expand All @@ -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<OptionType[]>([]);
Expand Down Expand Up @@ -190,8 +181,6 @@ export default function EntityExtractionSetting({
}
};
getOptions();
setIsSchema(true);
localStorage.setItem('isSchema', JSON.stringify(true));
}
}
}, [userCredentials, open]);
Expand All @@ -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 })
Expand All @@ -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',
Expand All @@ -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();
Expand Down Expand Up @@ -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}
</ButtonWithToolTip>
Expand All @@ -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}
</ButtonWithToolTip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Flex gap={tablet ? '6' : '8'}>
Expand All @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function ConfirmationDialog({
loading,
extractHandler,
selectedRows,
isLargeDocumentAlert = true,
isLargeDocumentAlert = false,
}: {
largeFiles: CustomFile[];
open: boolean;
Expand Down
Loading