Skip to content

Commit 0314b9b

Browse files
prakriti-solankeyaashipandyakaustubh-darekar
authored
Removal of isSchema check for graphType post processing Job (#990)
* removed ready to reprocess check * checkbox-graph-clenaup * additional instructions and graph clenaup backend * added additinal instructions * query update * checkbox changes * Updated renaming query, refined code * updated log * correct log * schema removed handling with labels --------- Co-authored-by: aashipandya <[email protected]> Co-authored-by: kaustubh-darekar <[email protected]>
1 parent 3b9457c commit 0314b9b

File tree

11 files changed

+48
-93
lines changed

11 files changed

+48
-93
lines changed

frontend/src/components/Content.tsx

+27-36
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ const ConfirmationDialog = lazy(() => import('./Popups/LargeFilePopUp/Confirmati
5050
let afterFirstRender = false;
5151

5252
const Content: React.FC<ContentProps> = ({
53-
isSchema,
54-
setIsSchema,
5553
showEnhancementDialog,
5654
toggleEnhancementDialog,
5755
setOpenConnection,
@@ -141,17 +139,17 @@ const Content: React.FC<ContentProps> = ({
141139
<PostProcessingToast
142140
isGdsActive={isGdsActive}
143141
postProcessingTasks={postProcessingTasks}
144-
isSchema={isSchema}
142+
isSchema={selectedNodes.length > 0 || selectedRels.length > 0}
145143
/>
146144
);
147145
try {
148146
const payload = isGdsActive
149-
? isSchema
147+
? selectedNodes.length > 0 || selectedRels.length > 0
150148
? postProcessingTasks.filter((task) => task !== 'graph_cleanup')
151149
: postProcessingTasks
152-
: isSchema
153-
? postProcessingTasks.filter((task) => task !== 'graph_cleanup' && task !== 'enable_communities')
154-
: postProcessingTasks.filter((task) => task !== 'enable_communities');
150+
: selectedNodes.length > 0 || selectedRels.length > 0
151+
? postProcessingTasks.filter((task) => task !== 'graph_cleanup' && task !== 'enable_communities')
152+
: postProcessingTasks.filter((task) => task !== 'enable_communities');
155153
const response = await postProcessing(userCredentials as UserCredentials, payload);
156154
if (response.data.status === 'Success') {
157155
const communityfiles = response.data?.data;
@@ -197,13 +195,6 @@ const Content: React.FC<ContentProps> = ({
197195
afterFirstRender = true;
198196
}, [queue.items.length, userCredentials]);
199197

200-
useEffect(() => {
201-
const storedSchema = localStorage.getItem('isSchema');
202-
if (storedSchema !== null) {
203-
setIsSchema(JSON.parse(storedSchema));
204-
}
205-
}, [isSchema]);
206-
207198
const handleDropdownChange = (selectedOption: OptionType | null | void) => {
208199
if (selectedOption?.value) {
209200
setModel(selectedOption?.value);
@@ -388,7 +379,7 @@ const Content: React.FC<ContentProps> = ({
388379
const addFilesToQueue = async (remainingFiles: CustomFile[]) => {
389380
if (!remainingFiles.length) {
390381
showNormalToast(
391-
<PostProcessingToast isGdsActive={isGdsActive} postProcessingTasks={postProcessingTasks} isSchema={isSchema} />
382+
<PostProcessingToast isGdsActive={isGdsActive} postProcessingTasks={postProcessingTasks} isSchema={selectedNodes.length > 0 || selectedRels.length > 0} />
392383
);
393384
try {
394385
const response = await postProcessing(userCredentials as UserCredentials, postProcessingTasks);
@@ -539,9 +530,8 @@ const Content: React.FC<ContentProps> = ({
539530
const handleOpenGraphClick = () => {
540531
const bloomUrl = process.env.VITE_BLOOM_URL;
541532
const uriCoded = userCredentials?.uri.replace(/:\d+$/, '');
542-
const connectURL = `${uriCoded?.split('//')[0]}//${userCredentials?.userName}@${uriCoded?.split('//')[1]}:${
543-
userCredentials?.port ?? '7687'
544-
}`;
533+
const connectURL = `${uriCoded?.split('//')[0]}//${userCredentials?.userName}@${uriCoded?.split('//')[1]}:${userCredentials?.port ?? '7687'
534+
}`;
545535
const encodedURL = encodeURIComponent(connectURL);
546536
const replacedUrl = bloomUrl?.replace('{CONNECT_URL}', encodedURL);
547537
window.open(replacedUrl, '_blank');
@@ -601,12 +591,12 @@ const Content: React.FC<ContentProps> = ({
601591
return prev.map((f) => {
602592
return f.name === filename
603593
? {
604-
...f,
605-
status: 'Ready to Reprocess',
606-
processingProgress: isStartFromBegining ? 0 : f.processingProgress,
607-
nodesCount: isStartFromBegining ? 0 : f.nodesCount,
608-
relationshipsCount: isStartFromBegining ? 0 : f.relationshipsCount,
609-
}
594+
...f,
595+
status: 'Ready to Reprocess',
596+
processingProgress: isStartFromBegining ? 0 : f.processingProgress,
597+
nodesCount: isStartFromBegining ? 0 : f.nodesCount,
598+
relationshipsCount: isStartFromBegining ? 0 : f.relationshipsCount,
599+
}
610600
: f;
611601
});
612602
});
@@ -714,20 +704,22 @@ const Content: React.FC<ContentProps> = ({
714704
const selectedRows = childRef.current?.getSelectedRows();
715705
if (selectedRows?.length) {
716706
const expiredFilesExists = selectedRows.some(
717-
(c) => isFileReadyToProcess(c, true) && isExpired(c?.createdAt as Date)
707+
(c) => c.status !== 'Ready to Reprocess' && isExpired(c?.createdAt as Date)
718708
);
719709
const largeFileExists = selectedRows.some(
720710
(c) => isFileReadyToProcess(c, true) && typeof c.size === 'number' && c.size > largeFileSize
721711
);
722712
if (expiredFilesExists) {
723-
setshowConfirmationModal(true);
724-
} else if (largeFileExists && isGCSActive) {
725713
setshowExpirationModal(true);
714+
} else if (largeFileExists && isGCSActive) {
715+
setshowConfirmationModal(true);
726716
} else {
727717
handleGenerateGraph(selectedRows.filter((f) => isFileReadyToProcess(f, false)));
728718
}
729719
} else if (filesData.length) {
730-
const expiredFileExists = filesData.some((c) => isFileReadyToProcess(c, true) && isExpired(c.createdAt as Date));
720+
const expiredFileExists = filesData.some(
721+
(c) => isExpired(c.createdAt as Date)
722+
);
731723
const largeFileExists = filesData.some(
732724
(c) => isFileReadyToProcess(c, true) && typeof c.size === 'number' && c.size > largeFileSize
733725
);
@@ -744,7 +736,7 @@ const Content: React.FC<ContentProps> = ({
744736
} else if (expiredFileExists && isGCSActive) {
745737
setshowExpirationModal(true);
746738
} else {
747-
handleGenerateGraph(filesData.filter((f) => isFileReadyToProcess(f, false)));
739+
handleGenerateGraph(filesData.filter((f) => f.status === 'New' || f.status === 'Ready to Reprocess'));
748740
}
749741
}
750742
};
@@ -788,6 +780,7 @@ const Content: React.FC<ContentProps> = ({
788780
onClose={() => setshowConfirmationModal(false)}
789781
loading={extractLoading}
790782
selectedRows={childRef.current?.getSelectedRows() as CustomFile[]}
783+
isLargeDocumentAlert={true}
791784
></ConfirmationDialog>
792785
</Suspense>
793786
)}
@@ -854,16 +847,14 @@ const Content: React.FC<ContentProps> = ({
854847
/>
855848
<div className='pt-1 flex gap-1 items-center'>
856849
<div>
857-
{!isSchema ? (
850+
{selectedNodes.length === 0 || selectedRels.length === 0 ? (
858851
<StatusIndicator type='danger' />
859-
) : selectedNodes.length || selectedRels.length ? (
860-
<StatusIndicator type='success' />
861-
) : (
862-
<StatusIndicator type='warning' />
863-
)}
852+
) :
853+
(<StatusIndicator type='success' />
854+
)}
864855
</div>
865856
<div>
866-
{isSchema ? (
857+
{selectedNodes.length > 0 || selectedRels.length > 0 ? (
867858
<span className='n-body-small'>
868859
{(!selectedNodes.length || !selectedRels.length) && 'Empty'} Graph Schema configured
869860
{selectedNodes.length || selectedRels.length

frontend/src/components/Layout/Header.tsx

+1-6
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ import {
1111
ArrowDownTrayIconOutline,
1212
} from '@neo4j-ndl/react/icons';
1313
import { Button, TextLink, Typography } from '@neo4j-ndl/react';
14-
import { Dispatch, memo, SetStateAction, useCallback, useContext, useEffect, useRef, useState } from 'react';
14+
import { Dispatch, memo, SetStateAction, useCallback, useContext, useRef, useState } from 'react';
1515
import { IconButtonWithToolTip } from '../UI/IconButtonToolTip';
1616
import { buttonCaptions, tooltips } from '../../utils/Constants';
17-
import { useFileContext } from '../../context/UsersFiles';
1817
import { ThemeWrapperContext } from '../../context/ThemeWrapper';
1918
import { useCredentials } from '../../context/UserCredentials';
2019
import { useNavigate } from 'react-router';
@@ -39,13 +38,9 @@ const Header: React.FC<HeaderProp> = ({ chatOnly, deleteOnClick, setOpenConnecti
3938
window.open(url, '_blank');
4039
}, []);
4140
const downloadLinkRef = useRef<HTMLAnchorElement>(null);
42-
const { isSchema, setIsSchema } = useFileContext();
4341
const { connectionStatus } = useCredentials();
4442
const chatAnchor = useRef<HTMLDivElement>(null);
4543
const [showChatModeOption, setshowChatModeOption] = useState<boolean>(false);
46-
useEffect(() => {
47-
setIsSchema(isSchema);
48-
}, [isSchema]);
4944

5045
const openChatPopout = useCallback(() => {
5146
let session = localStorage.getItem('neo4j.connection');

frontend/src/components/Layout/PageLayout.tsx

+1-5
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const PageLayout: React.FC = () => {
5252
};
5353

5454
const { messages, setClearHistoryData, clearHistoryData, setMessages, setIsDeleteChatLoading } = useMessageContext();
55-
const { isSchema, setIsSchema, setShowTextFromSchemaDialog, showTextFromSchemaDialog } = useFileContext();
55+
const { setShowTextFromSchemaDialog, showTextFromSchemaDialog } = useFileContext();
5656
const {
5757
setConnectionStatus,
5858
setGdsActive,
@@ -289,8 +289,6 @@ const PageLayout: React.FC = () => {
289289
openTextSchema={() => {
290290
setShowTextFromSchemaDialog({ triggeredFrom: 'schemadialog', show: true });
291291
}}
292-
isSchema={isSchema}
293-
setIsSchema={setIsSchema}
294292
showEnhancementDialog={showEnhancementDialog}
295293
toggleEnhancementDialog={toggleEnhancementDialog}
296294
setOpenConnection={setOpenConnection}
@@ -349,8 +347,6 @@ const PageLayout: React.FC = () => {
349347
openTextSchema={() => {
350348
setShowTextFromSchemaDialog({ triggeredFrom: 'schemadialog', show: true });
351349
}}
352-
isSchema={isSchema}
353-
setIsSchema={setIsSchema}
354350
showEnhancementDialog={showEnhancementDialog}
355351
toggleEnhancementDialog={toggleEnhancementDialog}
356352
setOpenConnection={setOpenConnection}

frontend/src/components/Popups/ExpirationModal/ExpiredFilesAlert.tsx

+6-9
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import BellImage from '../../../assets/images/Stopwatch-blue.svg';
77
import AlertIcon from '../../Layout/AlertIcon';
88
import { isExpired } from '../../../utils/Utils';
99
import { EXPIRATION_DAYS } from '../../../utils/Constants';
10+
import { IconWithToolTip } from '../../UI/IconButtonToolTip';
1011

1112
const ExpiredFilesAlert: FC<LargefilesProps> = ({ Files, handleToggle, checked }) => {
1213
return (
@@ -31,14 +32,8 @@ const ExpiredFilesAlert: FC<LargefilesProps> = ({ Files, handleToggle, checked }
3132
<ListItemIcon>
3233
<Checkbox
3334
ariaLabel='selection checkbox'
34-
onChange={(e) => {
35-
if (e.target.checked) {
36-
handleToggle(true, f.id);
37-
} else {
38-
handleToggle(false, f.id);
39-
}
40-
}}
41-
isChecked={checked.indexOf(f.id) !== -1}
35+
isChecked={checked.includes(f.id)}
36+
onChange={(e) => handleToggle(e.target.checked, f.id)}
4237
htmlAttributes={{ tabIndex: -1 }}
4338
/>
4439
</ListItemIcon>
@@ -53,7 +48,9 @@ const ExpiredFilesAlert: FC<LargefilesProps> = ({ Files, handleToggle, checked }
5348
</span>
5449
{f.createdAt != undefined && isExpired(f.createdAt) ? (
5550
<span>
56-
<AlertIcon />
51+
<IconWithToolTip label={'expired'} text={'File has expired'} placement='top'>
52+
<AlertIcon />
53+
</IconWithToolTip>
5754
</span>
5855
) : (
5956
<></>

frontend/src/components/Popups/GraphEnhancementDialog/EnitityExtraction/EntityExtractionSetting.tsx

+2-19
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ export default function EntityExtractionSetting({
3535
selectedRels,
3636
selectedSchemas,
3737
setSelectedSchemas,
38-
isSchema,
39-
setIsSchema,
4038
} = useFileContext();
4139
const { userCredentials } = useCredentials();
4240
const [loading, setLoading] = useState<boolean>(false);
@@ -60,7 +58,6 @@ export default function EntityExtractionSetting({
6058
);
6159
return filteredrels;
6260
});
63-
localStorage.setItem('isSchema', JSON.stringify(false));
6461
};
6562
const onChangeSchema = (selectedOptions: OnChangeValue<OptionType, true>, actionMeta: ActionMeta<OptionType>) => {
6663
if (actionMeta.action === 'remove-value') {
@@ -120,20 +117,15 @@ export default function EntityExtractionSetting({
120117
'selectedRelationshipLabels',
121118
JSON.stringify({ db: userCredentials?.uri, selectedOptions: updatedOptions })
122119
);
123-
localStorage.setItem('isSchema', JSON.stringify(true));
124120
return updatedOptions;
125121
});
126-
setIsSchema(true);
127122
};
128123
const onChangenodes = (selectedOptions: OnChangeValue<OptionType, true>, actionMeta: ActionMeta<OptionType>) => {
129124
if (actionMeta.action === 'clear') {
130125
localStorage.setItem('selectedNodeLabels', JSON.stringify({ db: userCredentials?.uri, selectedOptions: [] }));
131-
localStorage.setItem('isSchema', JSON.stringify(false));
132126
}
133127
setSelectedNodes(selectedOptions);
134-
setIsSchema(true);
135128
localStorage.setItem('selectedNodeLabels', JSON.stringify({ db: userCredentials?.uri, selectedOptions }));
136-
localStorage.setItem('isSchema', JSON.stringify(true));
137129
};
138130
const onChangerels = (selectedOptions: OnChangeValue<OptionType, true>, actionMeta: ActionMeta<OptionType>) => {
139131
if (actionMeta.action === 'clear') {
@@ -143,7 +135,6 @@ export default function EntityExtractionSetting({
143135
);
144136
}
145137
setSelectedRels(selectedOptions);
146-
setIsSchema(true);
147138
localStorage.setItem('selectedRelationshipLabels', JSON.stringify({ db: userCredentials?.uri, selectedOptions }));
148139
};
149140
const [nodeLabelOptions, setnodeLabelOptions] = useState<OptionType[]>([]);
@@ -190,8 +181,6 @@ export default function EntityExtractionSetting({
190181
}
191182
};
192183
getOptions();
193-
setIsSchema(true);
194-
localStorage.setItem('isSchema', JSON.stringify(true));
195184
}
196185
}
197186
}, [userCredentials, open]);
@@ -200,8 +189,6 @@ export default function EntityExtractionSetting({
200189
setSelectedSchemas([]);
201190
setSelectedNodes(nodeLabelOptions);
202191
setSelectedRels(relationshipTypeOptions);
203-
setIsSchema(true);
204-
localStorage.setItem('isSchema', JSON.stringify(true));
205192
localStorage.setItem(
206193
'selectedNodeLabels',
207194
JSON.stringify({ db: userCredentials?.uri, selectedOptions: nodeLabelOptions })
@@ -213,11 +200,9 @@ export default function EntityExtractionSetting({
213200
}, [nodeLabelOptions, relationshipTypeOptions]);
214201

215202
const handleClear = () => {
216-
setIsSchema(false);
217203
setSelectedNodes([]);
218204
setSelectedRels([]);
219205
setSelectedSchemas([]);
220-
localStorage.setItem('isSchema', JSON.stringify(false));
221206
localStorage.setItem('selectedNodeLabels', JSON.stringify({ db: userCredentials?.uri, selectedOptions: [] }));
222207
localStorage.setItem(
223208
'selectedRelationshipLabels',
@@ -230,8 +215,6 @@ export default function EntityExtractionSetting({
230215
}
231216
};
232217
const handleApply = () => {
233-
setIsSchema(true);
234-
localStorage.setItem('isSchema', JSON.stringify(true));
235218
showNormalToast(`Successfully Applied the Schema settings`);
236219
if (view === 'Tabs' && closeEnhanceGraphSchemaDialog != undefined) {
237220
closeEnhanceGraphSchemaDialog();
@@ -363,7 +346,7 @@ export default function EntityExtractionSetting({
363346
placement='top'
364347
onClick={handleClear}
365348
label='Clear Graph Settings'
366-
disabled={!isSchema}
349+
disabled={selectedNodes.length === 0 || selectedRels.length === 0}
367350
>
368351
{buttonCaptions.clearSettings}
369352
</ButtonWithToolTip>
@@ -373,7 +356,7 @@ export default function EntityExtractionSetting({
373356
placement='top'
374357
onClick={handleApply}
375358
label='Apply Graph Settings'
376-
disabled={!isSchema}
359+
disabled={selectedNodes.length === 0 || selectedRels.length === 0}
377360
>
378361
{buttonCaptions.applyGraphSchema}
379362
</ButtonWithToolTip>

frontend/src/components/Popups/GraphEnhancementDialog/PostProcessingCheckList/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { useCredentials } from '../../../../context/UserCredentials';
77
export default function PostProcessingCheckList() {
88
const { breakpoints } = tokens;
99
const tablet = useMediaQuery(`(min-width:${breakpoints.xs}) and (max-width: ${breakpoints.lg})`);
10-
const { postProcessingTasks, setPostProcessingTasks, selectedNodes, selectedRels, isSchema } = useFileContext();
10+
const { postProcessingTasks, setPostProcessingTasks, selectedNodes, selectedRels } = useFileContext();
1111
const { isGdsActive } = useCredentials();
1212
return (
1313
<Flex gap={tablet ? '6' : '8'}>
@@ -22,7 +22,7 @@ export default function PostProcessingCheckList() {
2222
{POST_PROCESSING_JOBS.map((job, idx) => {
2323
const isGraphCleanupDisabled =
2424
job.title === 'graph_cleanup'
25-
? !(isSchema && selectedNodes.length === 0 && selectedRels.length === 0)
25+
? !(selectedNodes.length === 0 && selectedRels.length === 0)
2626
: false;
2727
const isDisabled =
2828
job.title === 'enable_communities'

frontend/src/components/Popups/LargeFilePopUp/ConfirmationDialog.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function ConfirmationDialog({
1313
loading,
1414
extractHandler,
1515
selectedRows,
16-
isLargeDocumentAlert = true,
16+
isLargeDocumentAlert = false,
1717
}: {
1818
largeFiles: CustomFile[];
1919
open: boolean;

0 commit comments

Comments
 (0)