summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Cacqueray <tdecacqu@redhat.com>2019-03-08 15:00:23 +0000
committerTristan Cacqueray <tdecacqu@redhat.com>2019-03-08 23:45:40 +0000
commit12eee030995a2f151757f1f2a71660e03476b678 (patch)
tree8492a562e6cc7c7cb86e3f527faa6ade2c45d053
parent0999d5d8404667d98bd0c7cbaee954a6cceb3b1a (diff)
web: add flatten checkbox
This change adds a checkbox to display the jobs as a flat list. Change-Id: Iaf7c8f9de356661c9ab24c83c409c59f866ffaaf
Notes
Notes (review): Code-Review+2: Monty Taylor <mordred@inaugust.com> Code-Review+2: James E. Blair <corvus@inaugust.com> Workflow+1: James E. Blair <corvus@inaugust.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Tue, 12 Mar 2019 10:15:08 +0000 Reviewed-on: https://review.openstack.org/642047 Project: openstack-infra/zuul Branch: refs/heads/master
-rw-r--r--web/src/containers/jobs/Jobs.jsx44
1 files changed, 28 insertions, 16 deletions
diff --git a/web/src/containers/jobs/Jobs.jsx b/web/src/containers/jobs/Jobs.jsx
index 6a83d9b..fd7cd8d 100644
--- a/web/src/containers/jobs/Jobs.jsx
+++ b/web/src/containers/jobs/Jobs.jsx
@@ -17,6 +17,7 @@ import PropTypes from 'prop-types'
17import { connect } from 'react-redux' 17import { connect } from 'react-redux'
18import { Link } from 'react-router-dom' 18import { Link } from 'react-router-dom'
19import { 19import {
20 Checkbox,
20 Form, 21 Form,
21 FormGroup, 22 FormGroup,
22 FormControl, 23 FormControl,
@@ -32,7 +33,8 @@ class JobsList extends React.Component {
32 } 33 }
33 34
34 state = { 35 state = {
35 filter: null 36 filter: null,
37 flatten: false,
36 } 38 }
37 39
38 handleKeyPress = (e) => { 40 handleKeyPress = (e) => {
@@ -45,7 +47,7 @@ class JobsList extends React.Component {
45 47
46 render () { 48 render () {
47 const { jobs } = this.props 49 const { jobs } = this.props
48 const { filter } = this.state 50 const { filter, flatten } = this.state
49 51
50 const linkPrefix = this.props.tenant.linkPrefix + '/job/' 52 const linkPrefix = this.props.tenant.linkPrefix + '/job/'
51 53
@@ -84,8 +86,10 @@ class JobsList extends React.Component {
84 filtered: filtered, 86 filtered: filtered,
85 } 87 }
86 // Visit parent recursively 88 // Visit parent recursively
87 for (let parent of parents) { 89 if (!flatten) {
88 getNode(jobMap[parent], filtered) 90 for (let parent of parents) {
91 getNode(jobMap[parent], filtered)
92 }
89 } 93 }
90 } 94 }
91 return visited[job.name] 95 return visited[job.name]
@@ -110,19 +114,21 @@ class JobsList extends React.Component {
110 const jobNode = getNode(job, filtered) 114 const jobNode = getNode(job, filtered)
111 if (!jobNode.filtered) { 115 if (!jobNode.filtered) {
112 let attached = false 116 let attached = false
113 // add tree node to each parent and expand the parent 117 if (!flatten) {
114 for (let parent of jobNode.parents) { 118 // add tree node to each parent and expand the parent
115 const parentNode = visited[parent] 119 for (let parent of jobNode.parents) {
116 if (!parentNode) { 120 const parentNode = visited[parent]
117 console.log( 121 if (!parentNode) {
118 'Job ', job.name, ' parent ', parent, ' does not exist!') 122 console.log(
119 continue 123 'Job ', job.name, ' parent ', parent, ' does not exist!')
120 } 124 continue
121 if (!parentNode.nodes) { 125 }
122 parentNode.nodes = [] 126 if (!parentNode.nodes) {
127 parentNode.nodes = []
128 }
129 parentNode.nodes.push(jobNode)
130 attached = true
123 } 131 }
124 parentNode.nodes.push(jobNode)
125 attached = true
126 } 132 }
127 // else add node at the tree root 133 // else add node at the tree root
128 if (!attached || jobNode.parents.length === 0) { 134 if (!attached || jobNode.parents.length === 0) {
@@ -153,6 +159,12 @@ class JobsList extends React.Component {
153 </FormControl.Feedback> 159 </FormControl.Feedback>
154 )} 160 )}
155 </FormGroup> 161 </FormGroup>
162 <FormGroup controlId='jobs-flatten'>
163 &nbsp; Flatten list &nbsp;
164 <Checkbox
165 defaultChecked={flatten}
166 onChange={(e) => this.setState({flatten: e.target.checked})} />
167 </FormGroup>
156 </Form> 168 </Form>
157 <TreeView nodes={nodes} /> 169 <TreeView nodes={nodes} />
158 </div> 170 </div>