diff options
author | Clark Boylan <clark.boylan@gmail.com> | 2020-09-25 09:50:33 -0700 |
---|---|---|
committer | Clark Boylan <clark.boylan@gmail.com> | 2020-09-26 15:52:36 -0700 |
commit | f15c357f6edf6a66a978a2caeaf4218d4e89b60f (patch) | |
tree | 9847296a0434df9962eba5a158ea946d205f713f /web/src/Misc.jsx | |
parent | fab274c68b900ac3c713682df950b239281a619c (diff) | |
download | zuul-f15c357f6edf6a66a978a2caeaf4218d4e89b60f.tar.gz |
Render links for ref_url if build.change isnt' set
The web ui would only properly render ref_url links if build.change was
set. Set up conditions to check if build.change is set and fallback to
the build.newrev value if not. This way we render a clickable link using
the commit sha1.
Change-Id: I5eb9cb1c7cc0f64d6d7504347c01a6450ffb1507
Diffstat (limited to 'web/src/Misc.jsx')
-rw-r--r-- | web/src/Misc.jsx | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/web/src/Misc.jsx b/web/src/Misc.jsx index a2e9eb0c0..1633b897b 100644 --- a/web/src/Misc.jsx +++ b/web/src/Misc.jsx @@ -43,4 +43,48 @@ ExternalLink.propTypes = { children: PropTypes.node, } -export { ExternalLink } +function buildExternalLink(buildish) { + /* TODO (felix): What should we show for periodic builds + here? They don't provide a change, but the ref_url is + also not usable */ + if (buildish.ref_url && buildish.change) { + return ( + <ExternalLink target={buildish.ref_url}> + <strong>Change </strong> + {buildish.change},{buildish.patchset} + </ExternalLink> + ) + } else if (buildish.ref_url && buildish.newrev) { + return ( + <ExternalLink target={buildish.ref_url}> + <strong>Revision </strong> + {buildish.newrev.slice(0,7)} + </ExternalLink> + ) + } + + return null +} + +function buildExternalTableLink(buildish) { + /* TODO (felix): What should we show for periodic builds + here? They don't provide a change, but the ref_url is + also not usable */ + if (buildish.ref_url && buildish.change) { + return ( + <ExternalLink target={buildish.ref_url}> + {buildish.change},{buildish.patchset} + </ExternalLink> + ) + } else if (buildish.ref_url && buildish.newrev) { + return ( + <ExternalLink target={buildish.ref_url}> + {buildish.newrev.slice(0,7)} + </ExternalLink> + ) + } + + return null +} + +export { ExternalLink, buildExternalLink, buildExternalTableLink } |