summaryrefslogtreecommitdiff
path: root/web/src/containers/jobs/Jobs.jsx
diff options
context:
space:
mode:
authorTristan Cacqueray <tdecacqu@redhat.com>2019-11-21 15:47:43 +0000
committerTristan Cacqueray <tdecacqu@redhat.com>2019-11-21 15:55:06 +0000
commit925071d8fd76744ff482337a5263d6c623f8a197 (patch)
tree3e1eeff52aee7fda9b49c7657c705d8ab50744f2 /web/src/containers/jobs/Jobs.jsx
parent463d2c77fd45662687767619ed92c974fe6d2cf0 (diff)
downloadzuul-925071d8fd76744ff482337a5263d6c623f8a197.tar.gz
web: handle jobs that have multiple parent
This change prevent issue when the tree component is not able to render a child attached to multiple parents. Change-Id: Iec0de04bc91deb8642afa3a7d0ba023b3eadf8b4
Diffstat (limited to 'web/src/containers/jobs/Jobs.jsx')
-rw-r--r--web/src/containers/jobs/Jobs.jsx52
1 files changed, 30 insertions, 22 deletions
diff --git a/web/src/containers/jobs/Jobs.jsx b/web/src/containers/jobs/Jobs.jsx
index aa670f7cd..b4835cd14 100644
--- a/web/src/containers/jobs/Jobs.jsx
+++ b/web/src/containers/jobs/Jobs.jsx
@@ -58,6 +58,27 @@ class JobsList extends React.Component {
const nodes = []
// visited contains individual node
const visited = {}
+ // createNode returns the actual node needed by the tree view component
+ const createNode = (job, extra) => ({
+ text: (
+ <React.Fragment>
+ <Link to={linkPrefix + job.name}>{job.name}</Link>
+ {extra && (<span> ({extra})</span>)}
+ {job.description && (
+ <span style={{marginLeft: '10px'}}>{job.description}</span>
+ )}
+ {job.tags && job.tags.map((tag, idx) => (
+ <Badge
+ key={idx}
+ pullRight>
+ {tag}
+ </Badge>))}
+ </React.Fragment>),
+ icon: 'fa fa-cube',
+ state: {
+ expanded: true,
+ },
+ })
// getNode returns the tree node and visit each parents
const getNode = function (job, filtered) {
if (!visited[job.name]) {
@@ -71,27 +92,9 @@ class JobsList extends React.Component {
}
}
}
- visited[job.name] = {
- text: (
- <React.Fragment>
- <Link to={linkPrefix + job.name}>{job.name}</Link>
- {job.description && (
- <span style={{marginLeft: '10px'}}>{job.description}</span>
- )}
- {job.tags && job.tags.map((tag, idx) => (
- <Badge
- key={idx}
- pullRight>
- {tag}
- </Badge>))}
- </React.Fragment>),
- icon: 'fa fa-cube',
- state: {
- expanded: true,
- },
- parents: parents,
- filtered: filtered,
- }
+ visited[job.name] = createNode(job, null)
+ visited[job.name].parents = parents
+ visited[job.name].filtered = filtered
// Visit parent recursively
if (!flatten) {
for (let parent of parents) {
@@ -139,7 +142,12 @@ class JobsList extends React.Component {
if (!parentNode.nodes) {
parentNode.nodes = []
}
- parentNode.nodes.push(jobNode)
+ if (attached) {
+ // We need to create a duplicate node to satisfy TreeView constrains for multi parent
+ parentNode.nodes.push(createNode(job, 'branched'))
+ } else {
+ parentNode.nodes.push(jobNode)
+ }
attached = true
}
}