@@ -14,12 +14,12 @@ import {fetchSemanticConceptInfo} from "@api/queries";
1414import { FileEarmarkBinary , FileEarmarkText } from "react-bootstrap-icons" ;
1515
1616type Props = {
17- onCloseSidePanel :( ) => void ;
18- graphView : boolean ,
17+ onCloseSidePanel : ( ) => void ;
18+ graphView : boolean ,
1919} ;
2020
2121const DEFAULT_TAB = "instance" ;
22- const INSTANCE_TITLE = < span aria-label = "instanceTab" > < i > < FontAwesomeIcon icon = { faThList } size = "sm" /> </ i > Instance</ span > ;
22+ const INSTANCE_TITLE = < span aria-label = "instanceTab" > < i > < FontAwesomeIcon icon = { faThList } size = "sm" /> </ i > Instance</ span > ;
2323
2424const GraphExploreSidePanel : React . FC < Props > = ( props ) => {
2525 const { onCloseSidePanel, graphView} = props ;
@@ -28,22 +28,21 @@ const GraphExploreSidePanel: React.FC<Props> = (props) => {
2828 searchOptions,
2929 savedNode
3030 } = useContext ( SearchContext ) ;
31- const { database, entityTypeIds, selectedFacets, query, sortOrder} = searchOptions ;
31+ const { database, entityTypeIds, selectedFacets, query, sortOrder} = searchOptions ;
3232 const { entityName, group, primaryKey, sources, entityInstance, label, isConcept, id} = savedNode ;
3333 const docUri = savedNode [ "docURI" ] || savedNode [ "docUri" ] || savedNode [ "uri" ] ;
3434 const [ currentTab , setCurrentTab ] = useState ( DEFAULT_TAB ) ;
3535 const [ details , setDetails ] = useState < any > ( null ) ;
3636 const entityInstanceTitle = group ? group . split ( "/" ) . pop ( ) : entityName ;
3737 const conceptTitle = id ?. split ( "/" ) . pop ( ) ;
38- const [ currentLabel , setCurrentLabel ] = useState < string > ( "" ) ;
3938
4039 //To view record info on graph instance view side panel
4140 const [ content , setContent ] = useState < any > ( null ) ;
4241 const [ contentType , setContentType ] = useState < string > ( "" ) ;
4342 const [ xml , setXml ] = useState ( ) ;
4443 const data = useRef < any [ ] > ( ) ;
45- const [ semanticConceptInfo , setSemanticConceptInfo ] = useState < any [ ] > ( [ ] ) ;
46- const [ semanticConceptDescription , setSemanticConceptDescription ] = useState < any | null > ( null ) ;
44+ const [ semanticConceptInfo , setSemanticConceptInfo ] = useState < any [ ] > ( [ ] ) ;
45+ const [ semanticConceptDescription , setSemanticConceptDescription ] = useState < any | null > ( null ) ;
4746
4847 const iconContenType = {
4948 unknown : < span className = { "mlcf mlcf-blank fs-2" } aria-label = { "icon: filetype-unknown" } /> ,
@@ -53,24 +52,17 @@ const GraphExploreSidePanel: React.FC<Props> = (props) => {
5352 bin : < FileEarmarkBinary className = { "d-inline-block fs-2" } aria-label = { "icon: filetype-bin" } /> ,
5453 csv : < span className = { "mlcf mlcf-csv fs-2" } aria-label = { "icon: filetype-csv" } />
5554 } ;
56- const RECORD_TITLE = < span aria-label = "recordTab" className = "d-flex align-items-center" >
55+ const RECORD_TITLE = < span aria-label = "recordTab" className = "d-flex align-items-center" >
5756 { iconContenType [ contentType . toLowerCase ( ) ] || iconContenType . unknown }
5857 { contentType ? contentType . toUpperCase ( ) : "" }
5958 </ span > ;
6059
6160
6261 useEffect ( ( ) => {
63- let uri ;
64- if ( savedNode && ! docUri ) { // case where exploring from table/snippet
65- uri = savedNode [ "docIRI" ] ;
62+ if ( isConcept ) {
63+ getSemanticConceptsInfo ( ) ;
6664 } else {
67- uri = docUri ;
68- }
69- if ( uri && label !== currentLabel ) {
70- if ( isConcept ) {
71- getSemanticConceptsInfo ( ) ;
72- } else {
73- setCurrentLabel ( label ) ;
65+ if ( docUri ) {
7466 const getNodeData = async ( uri , database ) => {
7567 try {
7668 const result = await getDetails ( uri , database ) ;
@@ -84,11 +76,11 @@ const GraphExploreSidePanel: React.FC<Props> = (props) => {
8476 console . error ( "Unable to fetch document details." , err , JSON . stringify ( savedNode ) ) ;
8577 }
8678 } ;
87- getNodeData ( uri , database ) ;
79+ getNodeData ( docUri , database ) ;
8880 }
8981 }
9082
91- } , [ details , label , currentLabel ] ) ;
83+ } , [ id ] ) ;
9284
9385 const getSemanticConceptsInfo = async ( ) => {
9486 try {
@@ -125,13 +117,13 @@ const GraphExploreSidePanel: React.FC<Props> = (props) => {
125117 //To set the respective record type data(json, xml and text)
126118 const setContentData = ( ) => {
127119 const info = data . current ! ;
128- let recordType = info [ "recordType" ] ;
120+ let recordType = info [ "recordType" ] ;
129121 if ( recordType === "json" ) {
130122 setContentType ( "json" ) ;
131123 setContent ( info ) ;
132124 } else if ( recordType === "xml" ) {
133125 setContentType ( "xml" ) ;
134- let xmlData = info [ "data" ] ;
126+ let xmlData = info [ "data" ] ;
135127 const decodedXml = xmlDecoder ( xmlData ) ;
136128 const document = xmlParser ( decodedXml ) ;
137129 setContent ( document ) ;
@@ -147,7 +139,7 @@ const GraphExploreSidePanel: React.FC<Props> = (props) => {
147139 if ( currentTab === DEFAULT_TAB ) {
148140 return (
149141 < div aria-label = "instance-view" >
150- < TableView document = { details } contentType = "json" location = { { } } isEntityInstance = { true } isSidePanel = { true } />
142+ < TableView document = { details } contentType = "json" location = { { } } isEntityInstance = { true } isSidePanel = { true } />
151143 </ div >
152144 ) ;
153145 } else {
@@ -163,7 +155,7 @@ const GraphExploreSidePanel: React.FC<Props> = (props) => {
163155 } ;
164156
165157 const pathname = "/tiles/explore/detail"
166- ;
158+ ;
167159 let primaryKeyValue ;
168160 if ( primaryKey && Object . keys ( primaryKey ) . length ) {
169161 primaryKeyValue = primaryKey . propertyValue ;
@@ -234,9 +226,9 @@ const GraphExploreSidePanel: React.FC<Props> = (props) => {
234226 < div className = { styles . headingContainer } >
235227 < span >
236228 {
237- ! isConcept ? < span className = { styles . selectedEntityHeading } data-testid = "entityHeading" >
229+ ! isConcept ? < span className = { styles . selectedEntityHeading } data-testid = "entityHeading" >
238230 { entityInstanceTitle }
239- { < ChevronRight className = { styles . arrowRight } /> }
231+ { < ChevronRight className = { styles . arrowRight } /> }
240232 { entityInstanceLabel }
241233 </ span > :
242234 < div >
@@ -246,7 +238,7 @@ const GraphExploreSidePanel: React.FC<Props> = (props) => {
246238 }
247239 { ! isConcept && < HCTooltip text = "View full details" id = "processed-data-tooltip" placement = "top-end" >
248240 < Link to = { { pathname, state} } id = "instance" data-cy = "instance" >
249- < ArrowRightSquare className = { styles . arrowRightSquare } aria-label = "graphViewRightArrow" />
241+ < ArrowRightSquare className = { styles . arrowRightSquare } aria-label = "graphViewRightArrow" />
250242 </ Link >
251243 </ HCTooltip > }
252244 </ span >
@@ -266,15 +258,15 @@ const GraphExploreSidePanel: React.FC<Props> = (props) => {
266258 aria-label = "instanceTabInSidePanel"
267259 id = "instanceTabInSidePanel"
268260 title = { INSTANCE_TITLE }
269- className = { styles . instanceTabContainer } />
261+ className = { styles . instanceTabContainer } />
270262 < Tab
271263 eventKey = "record"
272264 aria-label = "recordTabInSidePanel"
273265 id = "recordTabInSidePanel"
274- title = { RECORD_TITLE } />
266+ title = { RECORD_TITLE } />
275267 </ Tabs >
276268 { displayPanelContent ( ) } </ > : < > { conceptInstanceInfo } { semanticConceptDescription && < div aria-label = "instance-view" >
277- < TableView document = { semanticConceptDescription } contentType = "json" location = { { } } isEntityInstance = { false } isSidePanel = { true } />
269+ < TableView document = { semanticConceptDescription } contentType = "json" location = { { } } isEntityInstance = { false } isSidePanel = { true } />
278270 </ div > } </ >
279271 }
280272 </ div >
0 commit comments