Skip to content

Commit 415302d

Browse files
refetching the orphan nodes after every deletion
1 parent c65c4d6 commit 415302d

File tree

5 files changed

+45
-29
lines changed

5 files changed

+45
-29
lines changed

frontend/src/components/Content.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -595,12 +595,12 @@ const Content: React.FC<ContentProps> = ({
595595
<span className='n-body-small'>Not Connected</span>
596596
)}
597597
<div className='pt-1'>
598-
{!isSchema ? <StatusIndicator type='danger' /> : <StatusIndicator type='success' />}
599-
{isSchema ? (
600-
<span className='n-body-small'>Graph Schema configured</span>
601-
) : (
602-
<span className='n-body-small'>No Graph Schema configured</span>
603-
)}
598+
{!isSchema ? <StatusIndicator type='danger' /> : <StatusIndicator type='success' />}
599+
{isSchema ? (
600+
<span className='n-body-small'>Graph Schema configured</span>
601+
) : (
602+
<span className='n-body-small'>No Graph Schema configured</span>
603+
)}
604604
</div>
605605
</Typography>
606606
</div>

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

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Checkbox, DataGrid, DataGridComponents, Flex, Typography } from '@neo4j-ndl/react';
2-
import { useEffect, useMemo, useRef, useState } from 'react';
2+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
33
import { UserCredentials, orphanNodeProps } from '../../../../types';
44
import { getOrphanNodes } from '../../../../services/GetOrphanNodes';
55
import { useCredentials } from '../../../../context/UserCredentials';
@@ -31,24 +31,28 @@ export default function DeletePopUpForOrphanNodes({
3131
const [rowSelection, setRowSelection] = useState<Record<string, boolean>>({});
3232
const tableRef = useRef(null);
3333

34+
const fetchOrphanNodes = useCallback(async () => {
35+
try {
36+
setLoading(true);
37+
const apiresponse = await getOrphanNodes(userCredentials as UserCredentials);
38+
setLoading(false);
39+
if (apiresponse.data.data.length) {
40+
setOrphanNodes(apiresponse.data.data);
41+
setTotalOrphanNodes(
42+
apiresponse.data.message != undefined && typeof apiresponse.data.message != 'string'
43+
? apiresponse.data.message.total
44+
: 0
45+
);
46+
}
47+
} catch (error) {
48+
setLoading(false);
49+
console.log(error);
50+
}
51+
}, [userCredentials]);
52+
3453
useEffect(() => {
3554
(async () => {
36-
try {
37-
setLoading(true);
38-
const apiresponse = await getOrphanNodes(userCredentials as UserCredentials);
39-
setLoading(false);
40-
if (apiresponse.data.data.length) {
41-
setOrphanNodes(apiresponse.data.data);
42-
setTotalOrphanNodes(
43-
apiresponse.data.message != undefined && typeof apiresponse.data.message != 'string'
44-
? apiresponse.data.message.total
45-
: 0
46-
);
47-
}
48-
} catch (error) {
49-
setLoading(false);
50-
console.log(error);
51-
}
55+
await fetchOrphanNodes();
5256
})();
5357
return () => {
5458
setOrphanNodes([]);
@@ -226,6 +230,9 @@ export default function DeletePopUpForOrphanNodes({
226230
selectedRows.forEach((eid: string) => {
227231
setOrphanNodes((prev) => prev.filter((node) => node.e.elementId != eid));
228232
});
233+
if (totalOrphanNodes) {
234+
await fetchOrphanNodes();
235+
}
229236
}}
230237
size='large'
231238
loading={loading}

frontend/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,4 +559,4 @@ type RelationStyling = {
559559
export type GraphStyling = {
560560
node: Record<string, Partial<NodeStyling>>;
561561
relationship: Record<string, Partial<RelationStyling>>;
562-
};
562+
};

frontend/src/utils/Constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export const ChatModeOptions = [
161161
{ Icon: 'abc', value: 'graph+vector' },
162162
];
163163

164-
export const taskParam: string[] = ['update_similarity_graph', 'create_fulltext_index','create_entity_embedding'];
164+
export const taskParam: string[] = ['update_similarity_graph', 'create_fulltext_index', 'create_entity_embedding'];
165165

166166
export const nvlOptions: NvlOptions = {
167167
allowDynamicMinZoom: true,

frontend/src/utils/Utils.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ export const filterData = (
185185
// @ts-ignore
186186
filteredNodes = allNodes.filter((node) => !node.labels.includes('Document') && !node.labels.includes('Chunk'));
187187
// @ts-ignore
188-
filteredRelations = allRelationships.filter((rel) => !['PART_OF', 'FIRST_CHUNK', 'HAS_ENTITY', 'SIMILAR', 'NEXT_CHUNK'].includes(rel.caption));
188+
filteredRelations = allRelationships.filter(
189+
(rel) => !['PART_OF', 'FIRST_CHUNK', 'HAS_ENTITY', 'SIMILAR', 'NEXT_CHUNK'].includes(rel.caption)
190+
);
189191
filteredScheme = Object.fromEntries(entityTypes.map((key) => [key, scheme[key]])) as Scheme;
190192
} else if (!graphType.includes('Document') && !graphType.includes('Entities') && graphType.includes('Chunk')) {
191193
// Only Chunk
@@ -197,15 +199,22 @@ export const filterData = (
197199
} else if (graphType.includes('Document') && graphType.includes('Entities') && !graphType.includes('Chunk')) {
198200
// Document + Entity
199201
// @ts-ignore
200-
filteredNodes = allNodes.filter((node) =>node.labels.includes('Document') || (!node.labels.includes('Document') && !node.labels.includes('Chunk')));
202+
filteredNodes = allNodes.filter(
203+
(node) =>
204+
node.labels.includes('Document') || (!node.labels.includes('Document') && !node.labels.includes('Chunk'))
205+
);
201206
// @ts-ignore
202-
filteredRelations = allRelationships.filter((rel) => !['PART_OF', 'FIRST_CHUNK', 'HAS_ENTITY', 'SIMILAR', 'NEXT_CHUNK'].includes(rel.caption));
207+
filteredRelations = allRelationships.filter(
208+
(rel) => !['PART_OF', 'FIRST_CHUNK', 'HAS_ENTITY', 'SIMILAR', 'NEXT_CHUNK'].includes(rel.caption)
209+
);
203210
} else if (graphType.includes('Document') && !graphType.includes('Entities') && graphType.includes('Chunk')) {
204211
// Document + Chunk
205212
// @ts-ignore
206213
filteredNodes = allNodes.filter((node) => node.labels.includes('Document') || node.labels.includes('Chunk'));
207214
// @ts-ignore
208-
filteredRelations = allRelationships.filter((rel) =>['PART_OF', 'FIRST_CHUNK', 'SIMILAR', 'NEXT_CHUNK'].includes(rel.caption));
215+
filteredRelations = allRelationships.filter((rel) =>
216+
['PART_OF', 'FIRST_CHUNK', 'SIMILAR', 'NEXT_CHUNK'].includes(rel.caption)
217+
);
209218
filteredScheme = { Document: scheme.Document, Chunk: scheme.Chunk };
210219
} else if (!graphType.includes('Document') && graphType.includes('Entities') && graphType.includes('Chunk')) {
211220
// Chunk + Entity

0 commit comments

Comments
 (0)