1- import { useEffect , useState , useMemo , useCallback } from 'react' ;
1+ import { useEffect , useState , useMemo } from 'react' ;
22import ConnectionModal from './Popups/ConnectionModal/ConnectionModal' ;
33import FileTable from './FileTable' ;
44import { Button , Typography , Flex , StatusIndicator } from '@neo4j-ndl/react' ;
55import { useCredentials } from '../context/UserCredentials' ;
66import { useFileContext } from '../context/UsersFiles' ;
77import CustomAlert from './UI/Alert' ;
88import { extractAPI } from '../utils/FileAPI' ;
9- import { ContentProps , CustomFile , Menuitems , OptionType , UserCredentials , alertStateType } from '../types' ;
9+ import { ContentProps , CustomFile , OptionType , UserCredentials , alertStateType } from '../types' ;
1010import deleteAPI from '../services/DeleteFiles' ;
1111import { postProcessing } from '../services/PostProcessing' ;
1212import DeletePopUp from './Popups/DeletePopUp/DeletePopUp' ;
@@ -20,15 +20,16 @@ import connectAPI from '../services/ConnectAPI';
2020import SettingModalHOC from '../HOC/SettingModalHOC' ;
2121import DropdownComponent from './Dropdown' ;
2222import 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
2527const 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 >
0 commit comments