Skip to content

Commit 224f35e

Browse files
UI bug fixes (#527)
* delete popup * table changes * Format fixes and added the warning status indicator for the 0 selected labels and rels * menu changes * entity dividers * added the status indicator --------- Co-authored-by: kartikpersistent <[email protected]>
1 parent e88ba2f commit 224f35e

File tree

10 files changed

+118
-59
lines changed

10 files changed

+118
-59
lines changed

frontend/src/components/ChatBot/ChatModeToggle.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { StatusIndicator } from '@neo4j-ndl/react';
12
import { useMemo } from 'react';
23
import { useFileContext } from '../../context/UsersFiles';
34
import CustomMenu from '../UI/Menu';
@@ -35,7 +36,13 @@ export default function ChatModeToggle({
3536
setchatMode(m);
3637
},
3738
disabledCondition: false,
38-
description: `${chatMode === m ? 'selected' : ''}`,
39+
description: <span>
40+
{chatMode === m && (
41+
<>
42+
<StatusIndicator type={`${chatMode === m ? 'success' : 'unknown'}`} /> Selected
43+
</>
44+
)}
45+
</span>,
3946
};
4047
}),
4148
[chatMode, chatModes]

frontend/src/components/ChatBot/Chatbot.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ const Chatbot: React.FC<ChatbotProps> = (props) => {
405405
onChange={handleInputChange}
406406
/>
407407
<Button type='submit' disabled={loading}>
408-
{buttonCaptions.submit}
408+
Ask
409409
</Button>
410410
</form>
411411
</div>

frontend/src/components/Content.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,7 @@ const Content: React.FC<ContentProps> = ({
569569
deleteHandler={(delentities: boolean) => handleDeleteFiles(delentities)}
570570
deleteCloseHandler={() => setshowDeletePopUp(false)}
571571
loading={deleteLoading}
572+
view='contentView'
572573
></DeletePopUp>
573574
)}
574575
{showSettingnModal && (
@@ -606,9 +607,20 @@ const Content: React.FC<ContentProps> = ({
606607
<span className='n-body-small'>Not Connected</span>
607608
)}
608609
<div className='pt-1'>
609-
{!isSchema ? <StatusIndicator type='danger' /> : <StatusIndicator type='success' />}
610+
{!isSchema ? (
611+
<StatusIndicator type='danger' />
612+
) : selectedNodes.length || selectedRels.length ? (
613+
<StatusIndicator type='success' />
614+
) : (
615+
<StatusIndicator type='warning' />
616+
)}
610617
{isSchema ? (
611-
<span className='n-body-small'>Graph Schema configured</span>
618+
<span className='n-body-small'>
619+
Empty Graph Schema configured{' '}
620+
{selectedNodes.length || selectedRels.length
621+
? `${selectedNodes.length} Labels + ${selectedRels.length} Rel Types`
622+
: ''}{' '}
623+
</span>
612624
) : (
613625
<span className='n-body-small'>No Graph Schema configured</span>
614626
)}

frontend/src/components/Popups/DeletePopUp/DeletePopUp.tsx

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,53 @@
11
import { Button, Checkbox, Dialog } from '@neo4j-ndl/react';
22
import { useState } from 'react';
3-
43
export default function DeletePopUp({
54
open,
65
no_of_files,
76
deleteHandler,
87
deleteCloseHandler,
98
loading,
9+
view,
1010
}: {
1111
open: boolean;
1212
no_of_files: number;
1313
deleteHandler: (delentities: boolean) => void;
1414
deleteCloseHandler: () => void;
1515
loading: boolean;
16+
view?: 'contentView' | 'settingsView';
1617
}) {
1718
const [deleteEntities, setDeleteEntities] = useState<boolean>(true);
19+
const message =
20+
view === 'contentView'
21+
? `Are you sure you want to permanently delete ${no_of_files} ${no_of_files > 1 ? 'Files' : 'File'} ${
22+
deleteEntities ? 'and associated entities' : ''
23+
} from the graph database?`
24+
: `Are you sure you want to permanently delete ${no_of_files} ${
25+
no_of_files > 1 ? 'Nodes' : 'Node'
26+
} from the graph database? `;
1827
return (
1928
<Dialog open={open} onClose={deleteCloseHandler}>
2029
<Dialog.Content>
21-
<h5 className='max-w-[90%]'>
22-
Are you sure you want to permanently delete {no_of_files} {no_of_files > 1 ? 'Files' : 'File'}{' '}
23-
{deleteEntities ? 'and associated entities' : ''} from the graph database ?
24-
</h5>
25-
<div className='mt-1'>
26-
<Checkbox
27-
label='Delete Entities'
28-
checked={deleteEntities}
29-
onChange={(e) => {
30-
if (e.target.checked) {
31-
setDeleteEntities(true);
32-
} else {
33-
setDeleteEntities(false);
34-
}
35-
}}
36-
/>
37-
</div>
30+
<h5 className='max-w-[90%]'>{message}</h5>
31+
{view === 'contentView' && (
32+
<div className='mt-5'>
33+
<Checkbox
34+
label='Delete Entities'
35+
checked={deleteEntities}
36+
onChange={(e) => {
37+
if (e.target.checked) {
38+
setDeleteEntities(true);
39+
} else {
40+
setDeleteEntities(false);
41+
}
42+
}}
43+
/>
44+
</div>
45+
)}
3846
</Dialog.Content>
3947
<Dialog.Actions className='mt-3'>
48+
<Button onClick={deleteCloseHandler} size='large' disabled={loading}>
49+
Cancel
50+
</Button>
4051
<Button onClick={() => deleteHandler(deleteEntities)} size='large' loading={loading}>
4152
Continue
4253
</Button>

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

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
Row,
1818
getSortedRowModel,
1919
} from '@tanstack/react-table';
20+
import DeletePopUp from '../../DeletePopUp/DeletePopUp';
2021
export default function DeletePopUpForOrphanNodes({
2122
deleteHandler,
2223
loading,
@@ -30,6 +31,7 @@ export default function DeletePopUpForOrphanNodes({
3031
const { userCredentials } = useCredentials();
3132
const [rowSelection, setRowSelection] = useState<Record<string, boolean>>({});
3233
const tableRef = useRef(null);
34+
const [showDeletePopUp, setshowDeletePopUp] = useState<boolean>(false);
3335

3436
const fetchOrphanNodes = useCallback(async () => {
3537
try {
@@ -64,7 +66,7 @@ export default function DeletePopUpForOrphanNodes({
6466
const columns = useMemo(
6567
() => [
6668
{
67-
id: 'select',
69+
id: 'Check to Delete All Files',
6870
header: ({ table }: { table: Table<orphanNodeProps> }) => {
6971
return (
7072
<Checkbox
@@ -80,7 +82,7 @@ export default function DeletePopUpForOrphanNodes({
8082
<Checkbox
8183
aria-label='row-checkbox'
8284
onChange={row.getToggleSelectedHandler()}
83-
title='select row for deletion'
85+
title='Select the Row for Deletion'
8486
checked={row.getIsSelected()}
8587
/>
8688
</div>
@@ -118,7 +120,7 @@ export default function DeletePopUpForOrphanNodes({
118120
id: 'Connnected Documents',
119121
cell: (info) => {
120122
return (
121-
<Flex>
123+
<Flex className='textellipsis'>
122124
{Array.from(new Set([...info.getValue()])).map((d, index) => (
123125
<Flex key={`d${index}`} flexDirection='row'>
124126
<span>
@@ -168,16 +170,41 @@ export default function DeletePopUpForOrphanNodes({
168170
},
169171
});
170172

173+
const selectedFilesCheck = table.getSelectedRowModel().rows.length
174+
? `Delete Selected Nodes (${table.getSelectedRowModel().rows.length})`
175+
: 'Select Node(s) to delete';
176+
177+
const onDeleteHandler = async () => {
178+
await deleteHandler(table.getSelectedRowModel().rows.map((r) => r.id));
179+
const selectedRows = table.getSelectedRowModel().rows.map((r) => r.id);
180+
setTotalOrphanNodes((prev) => prev - selectedRows.length);
181+
selectedRows.forEach((eid: string) => {
182+
setOrphanNodes((prev) => prev.filter((node) => node.e.elementId != eid));
183+
});
184+
setshowDeletePopUp(false);
185+
if (totalOrphanNodes) {
186+
await fetchOrphanNodes();
187+
}
188+
};
189+
171190
return (
172191
<div>
192+
{showDeletePopUp && (
193+
<DeletePopUp
194+
open={showDeletePopUp}
195+
no_of_files={table.getSelectedRowModel().rows.length ?? 0}
196+
deleteHandler={onDeleteHandler}
197+
deleteCloseHandler={() => setshowDeletePopUp(false)}
198+
loading={loading}
199+
view='settingsView'
200+
/>
201+
)}
173202
<div>
174203
<Flex flexDirection='column'>
175204
<Flex justifyContent='space-between' flexDirection='row'>
176205
<Typography variant='subheading-large'>Orphan Nodes Deletion (100 nodes per batch)</Typography>
177-
{totalOrphanNodes > 0 ? (
206+
{totalOrphanNodes > 0 && (
178207
<Typography variant='subheading-large'>Total Nodes: {totalOrphanNodes}</Typography>
179-
) : (
180-
<></>
181208
)}
182209
</Flex>
183210
<Flex justifyContent='space-between' flexDirection='row'>
@@ -221,19 +248,9 @@ export default function DeletePopUpForOrphanNodes({
221248
},
222249
}}
223250
/>
224-
<Flex className='mt-1' flexDirection='row' justifyContent='flex-end'>
251+
<Flex className='mt-3' flexDirection='row' justifyContent='flex-end'>
225252
<ButtonWithToolTip
226-
onClick={async () => {
227-
await deleteHandler(table.getSelectedRowModel().rows.map((r) => r.id));
228-
const selectedRows = table.getSelectedRowModel().rows.map((r) => r.id);
229-
setTotalOrphanNodes((prev) => prev - selectedRows.length);
230-
selectedRows.forEach((eid: string) => {
231-
setOrphanNodes((prev) => prev.filter((node) => node.e.elementId != eid));
232-
});
233-
if (totalOrphanNodes) {
234-
await fetchOrphanNodes();
235-
}
236-
}}
253+
onClick={() => setshowDeletePopUp(true)}
237254
size='large'
238255
loading={loading}
239256
text={
@@ -249,9 +266,7 @@ export default function DeletePopUpForOrphanNodes({
249266
disabled={!table.getSelectedRowModel().rows.length}
250267
placement='top'
251268
>
252-
{table.getSelectedRowModel().rows.length
253-
? `Delete Selected Nodes (${table.getSelectedRowModel().rows.length})`
254-
: 'Select Node(s) to delete'}
269+
{selectedFilesCheck}
255270
</ButtonWithToolTip>
256271
</Flex>
257272
</div>

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

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Dialog, Tabs, Box, Typography } from '@neo4j-ndl/react';
1+
import { Dialog, Tabs, Box, Typography, Flex } from '@neo4j-ndl/react';
22
import graphenhancement from '../../../assets/images/graph-enhancements.svg';
33
import { useState } from 'react';
44
import DeletePopUpForOrphanNodes from './DeleteTabForOrphanNodes';
@@ -47,30 +47,32 @@ export default function GraphEnhancementDialog({
4747
disableCloseButton={false}
4848
onClose={onClose}
4949
>
50-
<Dialog.Header className='flex justify-between self-end !mb-0'>
50+
<Dialog.Header className='flex justify-between self-end !mb-0 '>
5151
<Box className='n-bg-palette-neutral-bg-weak px-4'>
5252
<Box className='flex flex-row items-center mb-2'>
53-
<img src={graphenhancement} style={{ width: 200, height: 200, marginRight: 10 }} loading='lazy' />
53+
<img src={graphenhancement} style={{ width: 250, height: 250, marginRight: 10 }} loading='lazy' />
5454
<Box className='flex flex-col'>
5555
<Typography variant='h2'>Graph Enhancements</Typography>
5656
<Typography variant='subheading-medium' className='mb-2'>
5757
This set of tools will help you enhance the quality of your Knowledge Graph by removing possible
5858
duplicated entities, disconnected nodes and set a Graph Schema for improving the quality of the entity
5959
extraction process
6060
</Typography>
61+
<Flex className='pt-2'>
62+
<Tabs fill='underline' onChange={setactiveTab} size='large' value={activeTab}>
63+
<Tabs.Tab tabId={0} aria-label='Database'>
64+
Entity Extraction Settings
65+
</Tabs.Tab>
66+
<Tabs.Tab tabId={1} aria-label='Add database'>
67+
Disconnected Nodes
68+
</Tabs.Tab>
69+
</Tabs>
70+
</Flex>
6171
</Box>
6272
</Box>
6373
</Box>
6474
</Dialog.Header>
65-
<Dialog.Content className='flex flex-col n-gap-token- grow overflow-auto w-[80%] mx-auto'>
66-
<Tabs fill='underline' onChange={setactiveTab} size='large' value={activeTab}>
67-
<Tabs.Tab tabId={0} aria-label='Database'>
68-
Entity Extraction Settings
69-
</Tabs.Tab>
70-
<Tabs.Tab tabId={1} aria-label='Add database'>
71-
Disconnected Nodes
72-
</Tabs.Tab>
73-
</Tabs>
75+
<Dialog.Content className='flex flex-col n-gap-token- grow overflow-auto w-[90%] mx-auto'>
7476
<Tabs.TabPanel className='n-flex n-flex-col n-gap-token-4 n-p-token-6' value={activeTab} tabId={0}>
7577
<div className='w-[80%] mx-auto'>
7678
<EntityExtractionSettings
@@ -80,7 +82,7 @@ export default function GraphEnhancementDialog({
8082
}}
8183
colseEnhanceGraphSchemaDialog={onClose}
8284
settingView='headerView'
83-
></EntityExtractionSettings>
85+
/>
8486
</div>
8587
</Tabs.TabPanel>
8688
<Tabs.TabPanel className='n-flex n-flex-col n-gap-token-4 n-p-token-6' value={activeTab} tabId={1}>

frontend/src/components/Popups/Settings/EntityExtractionSetting.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { MouseEventHandler, useCallback, useEffect, useState } from 'react';
22
import ButtonWithToolTip from '../../UI/ButtonWithToolTip';
3-
import { buttonCaptions, tooltips } from '../../../utils/Constants';
3+
import { appLabels, buttonCaptions, tooltips } from '../../../utils/Constants';
44
import { Dropdown, Flex, Typography } from '@neo4j-ndl/react';
55
import { useCredentials } from '../../../context/UserCredentials';
66
import { useFileContext } from '../../../context/UsersFiles';
@@ -238,6 +238,9 @@ export default function EntityExtractionSetting({
238238
</span>
239239
</Typography>
240240
<div className='mt-4'>
241+
<div className='flex align-self-center justify-center'>
242+
<h5>{appLabels.predefinedSchema}</h5>
243+
</div>
241244
<Dropdown
242245
helpText='Schema Examples'
243246
label='Predefined Schema'
@@ -252,6 +255,9 @@ export default function EntityExtractionSetting({
252255
}}
253256
type='select'
254257
/>
258+
<div className='flex align-self-center justify-center'>
259+
<h5>{appLabels.ownSchema}</h5>
260+
</div>
255261
<Dropdown
256262
helpText='You can select more than one values'
257263
label='Node Labels'
@@ -280,6 +286,7 @@ export default function EntityExtractionSetting({
280286
}}
281287
type='creatable'
282288
/>
289+
283290
<Flex className='!mt-4 flex items-center' flexDirection='row' justifyContent='flex-end'>
284291
<Flex flexDirection='row' gap='4'>
285292
<ButtonWithToolTip

frontend/src/components/UI/Menu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ export default function CustomMenu({
3333
{items?.map((i, idx) => {
3434
return (
3535
<Menu.Item
36-
description={i.description}
3736
key={`${idx}${i.title}`}
3837
title={i.title}
3938
onClick={i.onClick}
4039
disabled={i.disabledCondition}
4140
className={i.isSelected ? i.selectedClassName : ''}
41+
description={i.description}
4242
/>
4343
);
4444
})}

frontend/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ export interface Menuitems {
520520
title: string;
521521
onClick: () => void;
522522
disabledCondition: boolean;
523-
description?: string;
523+
description?: string | React.ReactNode;
524524
isSelected?: boolean;
525525
selectedClassName?: string;
526526
}

frontend/src/utils/Constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,8 @@ export const intitalGraphType: GraphType[] = ['Document', 'Entities', 'Chunk'];
185185
export const knowledgeGraph = 'Knowledge Graph';
186186
export const lexicalGraph = 'Lexical Graph';
187187
export const entityGraph = 'Entity Graph';
188+
189+
export const appLabels = {
190+
ownSchema: 'Or Define your own Schema',
191+
predefinedSchema: 'Select a Pre-defined Schema',
192+
};

0 commit comments

Comments
 (0)