@@ -2,22 +2,22 @@ import { useEffect, useState } from 'react';
22import ConnectionModal from './ConnectionModal' ;
33import LlmDropdown from './Dropdown' ;
44import FileTable from './FileTable' ;
5- import { Button , Label , Typography , Flex } from '@neo4j-ndl/react' ;
5+ import { Button , Typography , Flex , StatusIndicator } from '@neo4j-ndl/react' ;
66import { setDriver , disconnect } from '../utils/Driver' ;
77import { useCredentials } from '../context/UserCredentials' ;
88import { useFileContext } from '../context/UsersFiles' ;
99import CustomAlert from './Alert' ;
1010import { extractAPI } from '../services/FileAPI' ;
11+ import { ContentProps } from '../types' ;
1112
12- export default function Content ( ) {
13+ const Content : React . FC < ContentProps > = ( { isExpanded } ) => {
1314 const [ init , setInit ] = useState < boolean > ( false ) ;
1415 const [ openConnection , setOpenConnection ] = useState < boolean > ( false ) ;
1516 const [ connectionStatus , setConnectionStatus ] = useState < boolean > ( false ) ;
1617 const { setUserCredentials, userCredentials } = useCredentials ( ) ;
1718 const { filesData, files, setFilesData, setModel, model } = useFileContext ( ) ;
1819 const [ errorMessage , setErrorMessage ] = useState < string > ( '' ) ;
1920 const [ showAlert , setShowAlert ] = useState < boolean > ( false ) ;
20- const [ isLoading , setIsLoading ] = useState < boolean > ( false ) ;
2121
2222 useEffect ( ( ) => {
2323 if ( ! init ) {
@@ -135,16 +135,11 @@ export default function Content() {
135135 return curfile ;
136136 } )
137137 ) ;
138- setIsLoading ( false ) ;
139- } finally {
140- setIsLoading ( false ) ;
141138 }
142139 }
143140 } ;
144141
145142 const handleGenerateGraph = ( ) => {
146- setIsLoading ( true ) ;
147-
148143 if ( files . length > 0 ) {
149144 for ( let i = 0 ; i < files . length ; i ++ ) {
150145 if ( filesData [ i ] . status === 'New' ) {
@@ -157,37 +152,26 @@ export default function Content() {
157152 const handleClose = ( ) => {
158153 setShowAlert ( false ) ;
159154 } ;
155+
156+ const classNameCheck = isExpanded ? 'contentWithExpansion' : 'contentWithNoExpansion' ;
160157 return (
161158 < >
162159 < CustomAlert open = { showAlert } handleClose = { handleClose } alertMessage = { errorMessage } />
163- < div
164- className = 'n-bg-palette-neutral-bg-default'
165- style = { {
166- width : 'calc(-342px + 100dvw)' ,
167- height : 'calc(100dvh - 70px)' ,
168- padding : 3 ,
169- display : 'flex' ,
170- flexDirection : 'column' ,
171- alignItems : 'center' ,
172- gap : '5px' ,
173- position : 'relative' ,
174- } }
175- >
160+ < div className = { `n-bg-palette-neutral-bg-default ${ classNameCheck } ` } >
176161 < Flex className = 'w-full' alignItems = 'center' justifyContent = 'space-between' style = { { flexFlow : 'row' } } >
177162 < ConnectionModal
178163 open = { openConnection }
179164 setOpenConnection = { setOpenConnection }
180165 setConnectionStatus = { setConnectionStatus }
181166 />
182- < Typography variant = 'body-medium' style = { { display : 'flex' , padding : '20px' } } >
183- Neo4j connection Status:
184- < Typography variant = 'body-medium' style = { { marginLeft : '10px' } } >
185- { ! connectionStatus ? (
186- < Label color = 'danger' > Not connected</ Label >
187- ) : (
188- < Label color = 'success' > Connected</ Label >
189- ) }
167+ < Typography
168+ variant = 'body-medium'
169+ style = { { display : 'flex' , padding : '20px' , alignItems : 'center' , justifyContent : 'center' } }
170+ >
171+ < Typography variant = 'body-medium' >
172+ { ! connectionStatus ? < StatusIndicator type = 'danger' /> : < StatusIndicator type = 'success' /> }
190173 </ Typography >
174+ Neo4j connection
191175 </ Typography >
192176 { ! connectionStatus ? (
193177 < Button className = 'mr-2.5' onClick = { ( ) => setOpenConnection ( true ) } >
@@ -199,18 +183,25 @@ export default function Content() {
199183 </ Button >
200184 ) }
201185 </ Flex >
202- < FileTable > </ FileTable >
186+ < FileTable isExpanded = { isExpanded } > </ FileTable >
203187 < Flex
204188 className = 'w-full p-2.5 absolute bottom-4'
205189 justifyContent = 'space-between'
206190 style = { { flexFlow : 'row' , marginTop : '5px' } }
207191 >
208192 < LlmDropdown onSelect = { handleDropdownChange } isDisabled = { disableCheck } />
209- < Button loading = { isLoading } disabled = { disableCheck } onClick = { handleGenerateGraph } className = 'mr-0.5' >
193+ < Button
194+ loading = { filesData . some ( ( f ) => f . status === 'Processing' ) }
195+ disabled = { disableCheck }
196+ onClick = { handleGenerateGraph }
197+ className = 'mr-0.5'
198+ >
210199 Generate Graph
211200 </ Button >
212201 </ Flex >
213202 </ div >
214203 </ >
215204 ) ;
216- }
205+ } ;
206+
207+ export default Content ;
0 commit comments