From 39e734ebcb879d2f0c96a48b21217164a8b9272b Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Mon, 5 Sep 2022 08:50:43 -0700 Subject: Use json view for complex artifact metadata If a job returns nested metadata (ie, a value that is a dict or list), the build page will crash when attempting to display this because it expects metadata values to only be scalars. The docs and code both say that values can be "anything". Update the build page so that if the metadata value is an object (ie, not a primitive scalar), we use a JSON view to display it. Also, if the value is not an object, use toString so that we will display boolean values. Change-Id: I609f70ec60399c69b5f8715b97c43f513c7360a1 --- web/src/containers/build/Artifact.jsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/web/src/containers/build/Artifact.jsx b/web/src/containers/build/Artifact.jsx index 4d4259440..3793222d9 100644 --- a/web/src/containers/build/Artifact.jsx +++ b/web/src/containers/build/Artifact.jsx @@ -17,6 +17,7 @@ import PropTypes from 'prop-types' import { TreeView, } from 'patternfly-react' +import ReactJson from 'react-json-view' class Artifact extends React.Component { @@ -32,7 +33,17 @@ class Artifact extends React.Component { {Object.keys(artifact.metadata).map(key => ( {key} - {artifact.metadata[key]} + + {typeof(artifact.metadata[key]) === 'object'? + + :artifact.metadata[key].toString()} + ))} -- cgit v1.2.1