diff options
author | James E. Blair <jim@acmegating.com> | 2022-09-05 08:50:43 -0700 |
---|---|---|
committer | James E. Blair <jim@acmegating.com> | 2022-09-05 08:51:08 -0700 |
commit | 39e734ebcb879d2f0c96a48b21217164a8b9272b (patch) | |
tree | 50f3c9a248d33369557cf1ffed3a862753cc7100 | |
parent | df8874a560631d38f988f27c2c4aad731ad96178 (diff) | |
download | zuul-39e734ebcb879d2f0c96a48b21217164a8b9272b.tar.gz |
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
-rw-r--r-- | web/src/containers/build/Artifact.jsx | 13 |
1 files changed, 12 insertions, 1 deletions
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 => ( <tr key={key}> <td>{key}</td> - <td style={{width:'100%'}}>{artifact.metadata[key]}</td> + <td style={{width:'100%'}}> + {typeof(artifact.metadata[key]) === 'object'? + <ReactJson + src={artifact.metadata[key]} + name={null} + collapsed={true} + sortKeys={true} + enableClipboard={false} + displayDataTypes={false}/> + :artifact.metadata[key].toString()} + </td> </tr> ))} </tbody> |