Skip to content

Commit

Permalink
Merge pull request odpi#642 from davidradl/git737-3
Browse files Browse the repository at this point in the history
git637 fix map logic
  • Loading branch information
davidradl committed Mar 27, 2023
2 parents b1fedcd + 6c082fa commit e65160e
Showing 1 changed file with 34 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: Apache-2.0 */
/* Copyright Contributors to the ODPi Egeria project. */

import React from "react";
import React from "react";

import PropTypes from "prop-types";

Expand All @@ -10,56 +10,59 @@ import "./details-panel.scss";

export default function InstancePropertiesDisplay(props) {

const instProps = props.properties;
const instProps = props.properties;

let properties;


const switchValue = (prop) => {
let value;
switch (prop.instancePropertyCategory) {
case "PRIMITIVE" :
case "PRIMITIVE":
value = prop.primitiveValue;
break;
case "ENUM" :
case "ENUM":
value = prop.symbolicName;
break;
case "MAP" :
value = (<ul> {expandProperties(prop.mapValues)} </ul>)
case "MAP":
if (prop.mapValues !== null && prop.mapValues !== undefined) {
value = (<ul> {expandProperties(prop.mapValues.instanceProperties)} </ul>)
} else {
value = "No map values."
}
break;
case "ARRAY":
if (prop.arrayValues !== null && prop.arrayValues !== undefined) {
value = (<ul> {expandProperties(prop.arrayValues.instanceProperties)} </ul>)
} else {
value = "No Array values."
}
break;
case "ARRAY" :
console.log("DEBUG ARRAY");
if (prop.arrayValues !== null && prop.arrayValues !== undefined) {
value = (<ul> {expandProperties(prop.arrayValues.instanceProperties)} </ul>)
} else {
value = "No Array values."
}
break;
// it seems like this method can be driven with an unknown prop.instancePropertyCategory. I assume a render occurs before the prop value has been populated
// removing this alert.

// default:
// alert("Unknown instance property category: "+prop.instancePropertyCategory);
// break;
}
}
return value;
};

const expandProperties = (instanceProperties) => {

let propertyNamesUnsorted = [];
for (const [key] of Object.entries(instanceProperties))
for (const [key] of Object.entries(instanceProperties))
propertyNamesUnsorted.push(`${key}`);


let propertyNamesSorted = propertyNamesUnsorted.sort();
let propertyList = propertyNamesSorted.map( (propName) =>
<li className="details-sublist-item" key={propName}> {propName} :
{
switchValue(instanceProperties[propName])
}
</li>
let propertyNamesSorted = propertyNamesUnsorted.sort();
let propertyList = propertyNamesSorted.map((propName) =>
<li className="details-sublist-item" key={propName}> {propName} :
{
switchValue(instanceProperties[propName])
}
</li>

);

return propertyList;
Expand All @@ -73,18 +76,18 @@ export default function InstancePropertiesDisplay(props) {
)
}
else {
properties = (
<ul className="details-sublist">
{expandProperties(instProps.instanceProperties)}

properties = (
<ul className="details-sublist">
{expandProperties(instProps.instanceProperties)}
</ul>

);
}

return properties;
}

InstancePropertiesDisplay.propTypes = {
properties: PropTypes.object
properties: PropTypes.object
};

0 comments on commit e65160e

Please sign in to comment.