forked from odpi/egeria-react-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#85 putting 1 node on the canvas with errors
Signed-off-by: David Radley <david_radley@uk.ibm.com>
- Loading branch information
Showing
1 changed file
with
31 additions
and
27 deletions.
There are no files selected for viewing
58 changes: 31 additions & 27 deletions
58
...lossaryAuthor/components/visualisation/components/instance-retrieval/InstanceRetrieval.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,51 @@ | ||
/* SPDX-License-Identifier: Apache-2.0 */ | ||
/* Copyright Contributors to the ODPi Egeria project. */ | ||
|
||
import React, { useContext, useState } from "react"; | ||
import React, { useContext, useState, useEffect } from "react"; | ||
|
||
import PropTypes from "prop-types"; | ||
import PropTypes from "prop-types"; | ||
import { IdentificationContext } from "../../../../../../contexts/IdentificationContext"; | ||
import { InstancesContext } from "../../contexts/InstancesContext"; | ||
import { InstancesContext } from "../../contexts/InstancesContext"; | ||
import { withRouter } from "react-router-dom"; | ||
import "./instance-retriever.scss" | ||
import "./instance-retriever.scss"; | ||
import getNodeType from "../../../properties/NodeTypes"; | ||
const InstanceRetrieval = props => { | ||
const InstanceRetrieval = (props) => { | ||
useEffect( | ||
() => { | ||
loadNodeByGUID(); | ||
}, | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
[] | ||
); | ||
|
||
const instancesContext = useContext(InstancesContext); | ||
const instancesContext = useContext(InstancesContext); | ||
const identificationContext = useContext(IdentificationContext); | ||
|
||
/* | ||
* Function to get node by GUID | ||
/* | ||
* Function to get node by GUID | ||
*/ | ||
const loadNodeByGUID = () => { | ||
const urlSegments = props.match.url.split("/") | ||
const loadNodeByGUID = () => { | ||
if (props.match.url) { | ||
const urlSegments = props.match.url.split("/"); | ||
const guidToLoad = urlSegments[urlSegments.length - 1]; | ||
const secondLastSegment = urlSegments[urlSegments.length - 2]; | ||
const secondLastSegment = urlSegments[urlSegments.length - 2]; | ||
const nodeTypeKey = secondLastSegment.substring("visualise-".length); | ||
console.log("nodeTypeKey" + nodeTypeKey); | ||
|
||
const nodeType = getNodeType(identificationContext.getRestURL("glossary-author"), nodeTypeKey); | ||
|
||
const nodeType = getNodeType( | ||
identificationContext.getRestURL("glossary-author"), | ||
nodeTypeKey | ||
); | ||
console.log("nodeType" + nodeType); | ||
//TODO pass through the onSuccess and onErrors | ||
instancesContext.loadNode(guidToLoad, nodeType); | ||
|
||
} | ||
}; | ||
|
||
return ( | ||
|
||
<div className={props.className}> | ||
{loadNodeByGUID()} | ||
|
||
</div> | ||
|
||
); | ||
|
||
} | ||
return <div className={props.className}></div>; | ||
}; | ||
|
||
InstanceRetrieval.propTypes = { | ||
className : PropTypes.string | ||
} | ||
InstanceRetrieval.propTypes = { | ||
className: PropTypes.string, | ||
}; | ||
export default withRouter(InstanceRetrieval); |