11import { FC , useContext , useState } from 'react' ;
22import { ChunkProps , UserCredentials } from '../../types' ;
33import { Box , LoadingSpinner , TextLink , Typography } from '@neo4j-ndl/react' ;
4- import { DocumentTextIconOutline , GlobeAltIconOutline , MagnifyingGlassCircleIconSolid } from '@neo4j-ndl/react/icons' ;
4+ import { DocumentTextIconOutline , GlobeAltIconOutline } from '@neo4j-ndl/react/icons' ;
55import wikipedialogo from '../../assets/images/wikipedia.svg' ;
66import youtubelogo from '../../assets/images/youtube.svg' ;
77import gcslogo from '../../assets/images/gcs.webp' ;
@@ -13,7 +13,6 @@ import { chatModeLables } from '../../utils/Constants';
1313import { useCredentials } from '../../context/UserCredentials' ;
1414import GraphViewModal from '../Graph/GraphViewModal' ;
1515import { handleGraphNodeClick } from './chatInfo' ;
16- import { IconButtonWithToolTip } from '../UI/IconButtonToolTip' ;
1716
1817const ChunkInfo : FC < ChunkProps > = ( { loading, chunks, mode } ) => {
1918 const themeUtils = useContext ( ThemeWrapperContext ) ;
@@ -24,7 +23,7 @@ const ChunkInfo: FC<ChunkProps> = ({ loading, chunks, mode }) => {
2423 const [ viewPoint , setViewPoint ] = useState ( '' ) ;
2524 const [ _ , setLoadingGraphView ] = useState ( false ) ;
2625
27- const handleChunkClick = ( elementId : string , viewMode : string ) => {
26+ const handleChunkClick = ( elementId : string , viewMode : string ) => {
2827 handleGraphNodeClick (
2928 userCredentials as UserCredentials ,
3029 elementId ,
@@ -52,16 +51,6 @@ const ChunkInfo: FC<ChunkProps> = ({ loading, chunks, mode }) => {
5251 < >
5352 < div className = 'flex flex-row inline-block items-center' >
5453 < >
55- < IconButtonWithToolTip
56- placement = 'left'
57- text = 'Graph'
58- size = 'large'
59- label = 'Graph view'
60- clean
61- onClick = { ( ) => handleChunkClick ( chunk . element_id , 'Chunk' ) }
62- >
63- < MagnifyingGlassCircleIconSolid />
64- </ IconButtonWithToolTip >
6554 < DocumentTextIconOutline className = 'w-4 h-4 inline-block mr-2' />
6655 < Typography
6756 variant = 'body-medium'
@@ -80,20 +69,19 @@ const ChunkInfo: FC<ChunkProps> = ({ loading, chunks, mode }) => {
8069 < div >
8170 < Typography variant = 'subheading-small' > Page: { chunk ?. page_number } </ Typography >
8271 </ div >
72+ < div >
73+ < TextLink
74+ as = 'medium'
75+ label = 'Graph view'
76+ className = 'cursor-pointer'
77+ onClick = { ( ) => handleChunkClick ( chunk . element_id , 'Chunk' ) }
78+ > { 'Graph' }
79+ </ TextLink >
80+ </ div >
8381 </ >
8482 ) : chunk ?. url && chunk ?. start_time ? (
8583 < >
8684 < div className = 'flex flex-row inline-block justiy-between items-center' >
87- < IconButtonWithToolTip
88- placement = 'left'
89- text = 'Graph'
90- size = 'large'
91- label = 'Graph view'
92- clean
93- onClick = { ( ) => handleChunkClick ( chunk . element_id , 'Chunk' ) }
94- >
95- < MagnifyingGlassCircleIconSolid />
96- </ IconButtonWithToolTip >
9785 < img src = { youtubelogo } width = { 20 } height = { 20 } className = 'mr-2' />
9886 < TextLink href = { generateYouTubeLink ( chunk ?. url , chunk ?. start_time ) } externalLink = { true } >
9987 < Typography
@@ -107,90 +95,94 @@ const ChunkInfo: FC<ChunkProps> = ({ loading, chunks, mode }) => {
10795 { mode !== chatModeLables . global_vector &&
10896 mode !== chatModeLables . entity_vector &&
10997 mode !== chatModeLables . graph && (
110- < Typography variant = 'subheading-small' > Similarity Score: { chunk ?. score } </ Typography >
98+ < >
99+ < Typography variant = 'subheading-small' > Similarity Score: { chunk ?. score } </ Typography >
100+ < div >
101+ < TextLink
102+ as = 'medium'
103+ className = 'cursor-pointer'
104+ label = 'Graph view'
105+ onClick = { ( ) => handleChunkClick ( chunk . element_id , 'Chunk' ) }
106+ > { 'Graph' }
107+ </ TextLink >
108+ </ div >
109+ </ >
111110 ) }
112111 </ >
113112 ) : chunk ?. url && new URL ( chunk . url ) . host === 'wikipedia.org' ? (
114113 < >
115114 < div className = 'flex flex-row inline-block justiy-between items-center' >
116- < IconButtonWithToolTip
117- placement = 'left'
118- text = 'Graph'
119- size = 'large'
120- label = 'Graph view'
121- clean
122- onClick = { ( ) => handleChunkClick ( chunk . element_id , 'Chunk' ) }
123- >
124- < MagnifyingGlassCircleIconSolid />
125- </ IconButtonWithToolTip >
126115 < img src = { wikipedialogo } width = { 20 } height = { 20 } className = 'mr-2' />
127116 < Typography variant = 'subheading-medium' > { chunk ?. fileName } </ Typography >
128117 </ div >
129118 { mode !== chatModeLables . global_vector &&
130119 mode !== chatModeLables . entity_vector &&
131120 mode !== chatModeLables . graph && (
132- < Typography variant = 'subheading-small' > Similarity Score: { chunk ?. score } </ Typography >
121+ < >
122+ < Typography variant = 'subheading-small' > Similarity Score: { chunk ?. score } </ Typography >
123+ < div >
124+ < TextLink
125+ as = 'medium'
126+ className = 'cursor-pointer'
127+ label = 'Graph view'
128+ onClick = { ( ) => handleChunkClick ( chunk . element_id , 'Chunk' ) }
129+ > { 'Graph' }
130+ </ TextLink >
131+ </ div >
132+ </ >
133133 ) }
134134 </ >
135135 ) : chunk ?. url && new URL ( chunk . url ) . host === 'storage.googleapis.com' ? (
136136 < >
137137 < div className = 'flex flex-row inline-block justiy-between items-center' >
138- < IconButtonWithToolTip
139- placement = 'left'
140- text = 'Graph'
141- size = 'large'
142- label = 'Graph view'
143- clean
144- onClick = { ( ) => handleChunkClick ( chunk . element_id , 'Chunk' ) }
145- >
146- < MagnifyingGlassCircleIconSolid />
147- </ IconButtonWithToolTip >
148138 < img src = { gcslogo } width = { 20 } height = { 20 } className = 'mr-2' />
149139 < Typography variant = 'subheading-medium' > { chunk ?. fileName } </ Typography >
150140 </ div >
151141 { mode !== chatModeLables . global_vector &&
152142 mode !== chatModeLables . entity_vector &&
153143 mode !== chatModeLables . graph && (
154- < Typography variant = 'subheading-small' > Similarity Score: { chunk ?. score } </ Typography >
144+ < >
145+ < Typography variant = 'subheading-small' > Similarity Score: { chunk ?. score } </ Typography >
146+ < div >
147+ < TextLink
148+ as = 'medium'
149+ className = 'cursor-pointer'
150+ label = 'Graph view'
151+ onClick = { ( ) => handleChunkClick ( chunk . element_id , 'Chunk' ) }
152+ > { 'Graph' }
153+ </ TextLink >
154+ </ div >
155+ </ >
155156 ) }
156157 </ >
157158 ) : chunk ?. url && chunk ?. url . startsWith ( 's3://' ) ? (
158159 < >
159160 < div className = 'flex flex-row inline-block justiy-between items-center' >
160- < IconButtonWithToolTip
161- placement = 'left'
162- text = 'Graph'
163- size = 'large'
164- label = 'Graph view'
165- clean
166- onClick = { ( ) => handleChunkClick ( chunk . element_id , 'Chunk' ) }
167- >
168- < MagnifyingGlassCircleIconSolid />
169- </ IconButtonWithToolTip >
170161 < img src = { s3logo } width = { 20 } height = { 20 } className = 'mr-2' />
171162 < Typography variant = 'subheading-medium' > { chunk ?. fileName } </ Typography >
172163 </ div >
173164 { mode !== chatModeLables . global_vector &&
174165 mode !== chatModeLables . entity_vector &&
175166 mode !== chatModeLables . graph && (
176- < Typography variant = 'subheading-small' > Similarity Score: { chunk ?. score } </ Typography >
167+ < >
168+ < Typography variant = 'subheading-small' > Similarity Score: { chunk ?. score } </ Typography >
169+ < div >
170+ < TextLink
171+ as = 'medium'
172+ className = 'cursor-pointer'
173+ label = 'Graph view'
174+ onClick = { ( ) => handleChunkClick ( chunk . element_id , 'Chunk' ) }
175+ > { 'Graph' }
176+ </ TextLink >
177+ </ div >
178+ </ >
177179 ) }
178180 </ >
179181 ) : chunk ?. url &&
180182 ! chunk ?. url . startsWith ( 's3://' ) &&
181183 ! isAllowedHost ( chunk ?. url , [ 'storage.googleapis.com' , 'wikipedia.org' , 'youtube.com' ] ) ? (
182184 < >
183185 < div className = 'flex flex-row inline-block items-center' >
184- < IconButtonWithToolTip
185- placement = 'left'
186- text = 'Graph'
187- size = 'large'
188- label = 'Graph view'
189- clean
190- onClick = { ( ) => handleChunkClick ( chunk . element_id , 'Chunk' ) }
191- >
192- < MagnifyingGlassCircleIconSolid />
193- </ IconButtonWithToolTip >
194186 < GlobeAltIconOutline className = 'n-size-token-7' />
195187 < TextLink href = { chunk ?. url } externalLink = { true } >
196188 < Typography variant = 'body-medium' > { chunk ?. url } </ Typography >
@@ -199,22 +191,23 @@ const ChunkInfo: FC<ChunkProps> = ({ loading, chunks, mode }) => {
199191 { mode !== chatModeLables . global_vector &&
200192 mode !== chatModeLables . entity_vector &&
201193 mode !== chatModeLables . graph && (
202- < Typography variant = 'subheading-small' > Similarity Score: { chunk ?. score } </ Typography >
194+ < >
195+ < Typography variant = 'subheading-small' > Similarity Score: { chunk ?. score } </ Typography >
196+ < div >
197+ < TextLink
198+ as = 'medium'
199+ className = 'cursor-pointer'
200+ label = 'Graph view'
201+ onClick = { ( ) => handleChunkClick ( chunk . element_id , 'Chunk' ) }
202+ > { 'Graph' }
203+ </ TextLink >
204+ </ div >
205+ </ >
203206 ) }
204207 </ >
205208 ) : (
206209 < >
207210 < div className = 'flex flex-row inline-block items-center' >
208- < IconButtonWithToolTip
209- placement = 'left'
210- text = 'Graph'
211- size = 'large'
212- label = 'Graph view'
213- clean
214- onClick = { ( ) => handleChunkClick ( chunk . element_id , 'Chunk' ) }
215- >
216- < MagnifyingGlassCircleIconSolid />
217- </ IconButtonWithToolTip >
218211 { chunk . fileSource === 'local file' ? (
219212 < DocumentTextIconOutline className = 'n-size-token-7 mr-2' />
220213 ) : (
@@ -225,12 +218,23 @@ const ChunkInfo: FC<ChunkProps> = ({ loading, chunks, mode }) => {
225218 className = 'mr-2'
226219 />
227220 ) }
228- < Typography
229- variant = 'body-medium'
230- className = 'text-ellipsis whitespace-nowrap overflow-hidden max-w-lg'
231- >
232- { chunk . fileName }
233- </ Typography >
221+ < >
222+ < Typography
223+ variant = 'body-medium'
224+ className = 'text-ellipsis whitespace-nowrap overflow-hidden max-w-lg'
225+ >
226+ { chunk . fileName }
227+ </ Typography >
228+ < div >
229+ < TextLink
230+ as = 'medium'
231+ className = 'cursor-pointer'
232+ label = 'Graph view'
233+ onClick = { ( ) => handleChunkClick ( chunk . element_id , 'Chunk' ) }
234+ > { 'Graph' }
235+ </ TextLink >
236+ </ div >
237+ </ >
234238 </ div >
235239 </ >
236240 ) }
0 commit comments