Skip to content

Commit 3e6c4c6

Browse files
UI for graph enhancement operations (#501)
* added the new image for web sources header * added the GraphEnhancement Dialog * added the entity extraction and orphan node deletion in tabs * added the orphan nodes deletion table * image size changes * added the status indicator for graph schema settings * added the description for the Entity extraction and orphan node deletion * added the size for the orphan node deletion columns * Resetting the state on unmount phase --------- Co-authored-by: Prakriti Solankey <[email protected]>
1 parent 3a93615 commit 3e6c4c6

File tree

14 files changed

+939
-537
lines changed

14 files changed

+939
-537
lines changed

frontend/src/App.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
.filetable {
22
/* width: calc(-360px + 100dvw); */
3-
height: calc(-322px + 100dvh);
3+
height: calc(-400px + 100dvh);
44
border: 1px solid #d1d5db;
55
}
66

77
.fileTableWithExpansion {
88
width: calc(-640px + 100dvw) !important;
9-
height: calc(-322px + 100dvh);
9+
height: calc(-400px + 100dvh);
1010
border: 1px solid #d1d5db;
1111
}
1212

1313
.fileTableWithBothDrawers {
1414
width: calc(-650px + 100dvw) !important;
15-
height: calc(-322px + 100dvh);
15+
height: calc(-400px + 100dvh);
1616
border: 1px solid #d1d5db;
1717
}
1818

frontend/src/assets/images/data-from-cloud.svg

Lines changed: 77 additions & 0 deletions
Loading

frontend/src/assets/images/graph-enhancements.svg

Lines changed: 150 additions & 0 deletions
Loading

frontend/src/components/Content.tsx

Lines changed: 62 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { useEffect, useState, useMemo, useCallback } from 'react';
1+
import { useEffect, useState, useMemo } from 'react';
22
import ConnectionModal from './Popups/ConnectionModal/ConnectionModal';
33
import FileTable from './FileTable';
44
import { Button, Typography, Flex, StatusIndicator } from '@neo4j-ndl/react';
55
import { useCredentials } from '../context/UserCredentials';
66
import { useFileContext } from '../context/UsersFiles';
77
import CustomAlert from './UI/Alert';
88
import { extractAPI } from '../utils/FileAPI';
9-
import { ContentProps, CustomFile, Menuitems, OptionType, UserCredentials, alertStateType } from '../types';
9+
import { ContentProps, CustomFile, OptionType, UserCredentials, alertStateType } from '../types';
1010
import deleteAPI from '../services/DeleteFiles';
1111
import { postProcessing } from '../services/PostProcessing';
1212
import DeletePopUp from './Popups/DeletePopUp/DeletePopUp';
@@ -20,15 +20,16 @@ import connectAPI from '../services/ConnectAPI';
2020
import SettingModalHOC from '../HOC/SettingModalHOC';
2121
import DropdownComponent from './Dropdown';
2222
import GraphViewModal from './Graph/GraphViewModal';
23-
import CustomMenu from './UI/Menu';
23+
import GraphEnhancementDialog from './Popups/GraphEnhancementDialog';
24+
import { OverridableStringUnion } from '@mui/types';
25+
import { AlertColor, AlertPropsColorOverrides } from '@mui/material';
2426

2527
const Content: React.FC<ContentProps> = ({
2628
isLeftExpanded,
2729
isRightExpanded,
2830
openTextSchema,
2931
isSchema,
3032
setIsSchema,
31-
openOrphanNodeDeletionModal,
3233
}) => {
3334
const [init, setInit] = useState<boolean>(false);
3435
const [openConnection, setOpenConnection] = useState<boolean>(false);
@@ -40,8 +41,7 @@ const Content: React.FC<ContentProps> = ({
4041
const [extractLoading, setextractLoading] = useState<boolean>(false);
4142
const [isLargeFile, setIsLargeFile] = useState<boolean>(false);
4243
const [showSettingnModal, setshowSettingModal] = useState<boolean>(false);
43-
const [openDeleteMenu, setopenDeleteMenu] = useState<boolean>(false);
44-
const [deleteAnchor, setdeleteAnchor] = useState<HTMLElement | null>(null);
44+
const [showEnhancementDialog, setshowEnhancementDialog] = useState<boolean>(false);
4545

4646
const {
4747
filesData,
@@ -81,7 +81,22 @@ const Content: React.FC<ContentProps> = ({
8181
});
8282
}
8383
);
84-
84+
const openGraphEnhancementDialog = () => {
85+
setshowEnhancementDialog(true);
86+
};
87+
const closeGraphEnhancementDialog = () => {
88+
setshowEnhancementDialog(false);
89+
};
90+
const showAlert = (
91+
alertmsg: string,
92+
alerttype: OverridableStringUnion<AlertColor, AlertPropsColorOverrides> | undefined
93+
) => {
94+
setalertDetails({
95+
showAlert: true,
96+
alertMessage: alertmsg,
97+
alertType: alerttype,
98+
});
99+
};
85100
useEffect(() => {
86101
if (!init && !searchParams.has('connectURL')) {
87102
let session = localStorage.getItem('neo4j.connection');
@@ -492,23 +507,6 @@ const Content: React.FC<ContentProps> = ({
492507
}
493508
};
494509

495-
const deleteMenuItems: Menuitems[] = useMemo(
496-
() => [
497-
{
498-
title: `Delete Files ${selectedfileslength > 0 ? `(${selectedfileslength})` : ''}`,
499-
onClick: () => setshowDeletePopUp(true),
500-
disabledCondition: !selectedfileslength,
501-
description: tooltips.deleteFile,
502-
},
503-
{
504-
title: 'Deleted unconnected Nodes',
505-
onClick: () => openOrphanNodeDeletionModal(),
506-
disabledCondition: false,
507-
},
508-
],
509-
[selectedfileslength]
510-
);
511-
512510
const handleContinue = () => {
513511
if (!isLargeFile) {
514512
handleGenerateGraph(true, filesData);
@@ -573,6 +571,13 @@ const Content: React.FC<ContentProps> = ({
573571
setIsSchema={setIsSchema}
574572
/>
575573
)}
574+
{showEnhancementDialog && (
575+
<GraphEnhancementDialog
576+
open={showEnhancementDialog}
577+
onClose={closeGraphEnhancementDialog}
578+
showAlert={showAlert}
579+
></GraphEnhancementDialog>
580+
)}
576581
<div className={`n-bg-palette-neutral-bg-default ${classNameCheck}`}>
577582
<Flex className='w-full' alignItems='center' justifyContent='space-between' flexDirection='row'>
578583
<ConnectionModal
@@ -591,17 +596,34 @@ const Content: React.FC<ContentProps> = ({
591596
)}
592597
</Typography>
593598
</div>
594-
595599
{!connectionStatus ? (
596600
<Button className='mr-2.5' onClick={() => setOpenConnection(true)}>
597601
{buttonCaptions.connectToNeo4j}
598602
</Button>
599603
) : (
600-
<Button className='mr-2.5' onClick={disconnect}>
601-
{buttonCaptions.disconnect}
602-
</Button>
604+
<div>
605+
<Button className='mr-2.5' onClick={openGraphEnhancementDialog}>
606+
Graph Enhancement
607+
</Button>
608+
<Button className='mr-2.5' onClick={disconnect}>
609+
{buttonCaptions.disconnect}
610+
</Button>
611+
</div>
603612
)}
604613
</Flex>
614+
<Flex className='w-full' alignItems='center' flexDirection='row'>
615+
<div className='connectionstatus__container'>
616+
<span className='h6 px-1'>Schema Settings</span>
617+
<Typography variant='body-medium'>
618+
{!isSchema ? <StatusIndicator type='danger' /> : <StatusIndicator type='success' />}
619+
{isSchema ? (
620+
<span className='n-body-small'>Graph Schema configured</span>
621+
) : (
622+
<span className='n-body-small'>No Graph Schema configured</span>
623+
)}
624+
</Typography>
625+
</div>
626+
</Flex>
605627
<FileTable
606628
isExpanded={isLeftExpanded && isRightExpanded}
607629
connectionStatus={connectionStatus}
@@ -659,25 +681,19 @@ const Content: React.FC<ContentProps> = ({
659681
>
660682
{buttonCaptions.exploreGraphWithBloom}
661683
</ButtonWithToolTip>
662-
<CustomMenu
663-
open={openDeleteMenu}
664-
closeHandler={useCallback(() => {
665-
setopenDeleteMenu(false);
666-
}, [])}
667-
items={deleteMenuItems}
668-
MenuAnchor={deleteAnchor}
669-
anchorOrigin={useMemo(() => ({ horizontal: 'left', vertical: 'bottom' }), [])}
670-
transformOrigin={useMemo(() => ({ horizontal: 'right', vertical: 'top' }), [])}
671-
></CustomMenu>
672-
<Button
673-
label='Delete Menu trigger'
674-
onClick={(e) => {
675-
setdeleteAnchor(e.currentTarget);
676-
setopenDeleteMenu(true);
677-
}}
684+
<ButtonWithToolTip
685+
text={
686+
!selectedfileslength ? tooltips.deleteFile : `${selectedfileslength} ${tooltips.deleteSelectedFiles}`
687+
}
688+
placement='top'
689+
onClick={() => setshowDeletePopUp(true)}
690+
disabled={!selectedfileslength}
691+
className='ml-0.5'
692+
label='Delete Files'
678693
>
679-
Delete
680-
</Button>
694+
{buttonCaptions.deleteFiles}
695+
{selectedfileslength > 0 && `(${selectedfileslength})`}
696+
</ButtonWithToolTip>
681697
</Flex>
682698
</Flex>
683699
</div>

frontend/src/components/Layout/Header.tsx

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,15 @@ import {
44
MoonIconOutline,
55
SunIconOutline,
66
CodeBracketSquareIconOutline,
7-
Cog8ToothIconOutline,
87
InformationCircleIconOutline,
98
} from '@neo4j-ndl/react/icons';
109
import { Typography } from '@neo4j-ndl/react';
1110
import { useCallback, useEffect } from 'react';
1211
import IconButtonWithToolTip from '../UI/IconButtonToolTip';
1312
import { tooltips } from '../../utils/Constants';
1413
import { useFileContext } from '../../context/UsersFiles';
15-
import { Badge } from '@mui/material';
1614

17-
export default function Header({
18-
themeMode,
19-
toggleTheme,
20-
openSettingsModal,
21-
}: {
22-
themeMode: string;
23-
toggleTheme: () => void;
24-
openSettingsModal: () => void;
25-
}) {
15+
export default function Header({ themeMode, toggleTheme }: { themeMode: string; toggleTheme: () => void }) {
2616
const handleURLClick = useCallback((url: string) => {
2717
window.open(url, '_blank');
2818
}, []);
@@ -86,6 +76,7 @@ export default function Header({
8676
clean
8777
size='large'
8878
onClick={toggleTheme}
79+
placement='left'
8980
>
9081
{themeMode === 'dark' ? (
9182
<span role='img' aria-label='sun'>
@@ -97,18 +88,6 @@ export default function Header({
9788
</span>
9889
)}
9990
</IconButtonWithToolTip>
100-
<Badge color={isSchema ? 'success' : 'error'} overlap='circular' badgeContent=' ' variant='dot'>
101-
<IconButtonWithToolTip
102-
label={tooltips.settings}
103-
text={tooltips.settings}
104-
size='large'
105-
clean
106-
onClick={openSettingsModal}
107-
placement='left'
108-
>
109-
<Cog8ToothIconOutline />
110-
</IconButtonWithToolTip>
111-
</Badge>
11291
</div>
11392
</div>
11493
</section>

frontend/src/components/Layout/PageLayout.tsx

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useCallback, useState } from 'react';
1+
import { useState } from 'react';
22
import SideNav from './SideNav';
33
import DrawerDropzone from './DrawerDropzone';
44
import DrawerChatbot from './DrawerChatbot';
@@ -13,23 +13,15 @@ import { OverridableStringUnion } from '@mui/types';
1313
import { useFileContext } from '../../context/UsersFiles';
1414
import SchemaFromTextDialog from '../Popups/Settings/SchemaFromText';
1515
import CustomAlert from '../UI/Alert';
16-
import DeletePopUpForOrphanNodes from '../Popups/DeletePopUpForOrphanNodes';
17-
import deleteOrphanAPI from '../../services/DeleteOrphanNodes';
1816

1917
export default function PageLayoutNew({
2018
isSettingPanelExpanded,
2119
closeSettingModal,
2220
openSettingsDialog,
23-
closeOrphanNodeDeletionModal,
24-
showOrphanNodeDeletionModal,
25-
openOrphanNodeDeletionModal,
2621
}: {
2722
isSettingPanelExpanded: boolean;
2823
closeSettingModal: () => void;
2924
openSettingsDialog: () => void;
30-
closeOrphanNodeDeletionModal: () => void;
31-
showOrphanNodeDeletionModal: boolean;
32-
openOrphanNodeDeletionModal: () => void;
3325
}) {
3426
const [isLeftExpanded, setIsLeftExpanded] = useState<boolean>(true);
3527
const [isRightExpanded, setIsRightExpanded] = useState<boolean>(false);
@@ -39,17 +31,13 @@ export default function PageLayoutNew({
3931
const { userCredentials } = useCredentials();
4032
const toggleLeftDrawer = () => setIsLeftExpanded(!isLeftExpanded);
4133
const toggleRightDrawer = () => setIsRightExpanded(!isRightExpanded);
42-
const [openTextSchemaDialog, setOpenTextSchemaDialog] = useState<boolean>(false);
43-
const [orphanDeleteAPIloading, setorphanDeleteAPIloading] = useState<boolean>(false);
4434
const [alertDetails, setalertDetails] = useState<alertStateType>({
4535
showAlert: false,
4636
alertType: 'error',
4737
alertMessage: '',
4838
});
4939
const { messages } = useMessageContext();
50-
const openSchemaFromTextDialog = useCallback(() => setOpenTextSchemaDialog(true), []);
51-
const closeSchemaFromTextDialog = useCallback(() => setOpenTextSchemaDialog(false), []);
52-
const { isSchema, setIsSchema } = useFileContext();
40+
const { isSchema, setIsSchema, setShowTextFromSchemaDialog, showTextFromSchemaDialog } = useFileContext();
5341

5442
const deleteOnClick = async () => {
5543
try {
@@ -84,16 +72,7 @@ export default function PageLayoutNew({
8472
alertMessage: '',
8573
});
8674
};
87-
const orphanNodesDeleteHandler = async (selectedEntities: string[]) => {
88-
try {
89-
setorphanDeleteAPIloading(true);
90-
const response = await deleteOrphanAPI(userCredentials as UserCredentials, selectedEntities);
91-
setorphanDeleteAPIloading(false);
92-
console.log(response);
93-
} catch (error) {
94-
console.log(error);
95-
}
96-
};
75+
9776
return (
9877
<div style={{ maxHeight: 'calc(100vh - 58px)' }} className='flex overflow-hidden'>
9978
{alertDetails.showAlert && (
@@ -107,19 +86,17 @@ export default function PageLayoutNew({
10786
<SideNav isExpanded={isLeftExpanded} position='left' toggleDrawer={toggleLeftDrawer} />
10887
<DrawerDropzone isExpanded={isLeftExpanded} />
10988
<SchemaFromTextDialog
110-
open={openTextSchemaDialog}
89+
open={showTextFromSchemaDialog}
11190
openSettingsDialog={openSettingsDialog}
112-
onClose={closeSchemaFromTextDialog}
91+
onClose={() => {
92+
setShowTextFromSchemaDialog(false);
93+
}}
11394
showAlert={showAlert}
11495
></SchemaFromTextDialog>
115-
<DeletePopUpForOrphanNodes
116-
open={showOrphanNodeDeletionModal}
117-
deleteCloseHandler={closeOrphanNodeDeletionModal}
118-
deleteHandler={orphanNodesDeleteHandler}
119-
loading={orphanDeleteAPIloading}
120-
></DeletePopUpForOrphanNodes>
12196
<SettingsModal
122-
openTextSchema={openSchemaFromTextDialog}
97+
openTextSchema={() => {
98+
setShowTextFromSchemaDialog(true);
99+
}}
123100
open={isSettingPanelExpanded}
124101
onClose={closeSettingModal}
125102
settingView='headerView'
@@ -131,8 +108,9 @@ export default function PageLayoutNew({
131108
isLeftExpanded={isLeftExpanded}
132109
isRightExpanded={isRightExpanded}
133110
showChatBot={showChatBot}
134-
openTextSchema={openSchemaFromTextDialog}
135-
openOrphanNodeDeletionModal={openOrphanNodeDeletionModal}
111+
openTextSchema={() => {
112+
setShowTextFromSchemaDialog(true);
113+
}}
136114
isSchema={isSchema}
137115
setIsSchema={setIsSchema}
138116
/>

0 commit comments

Comments
 (0)