summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2019-03-12 10:15:08 +0000
committerGerrit Code Review <review@openstack.org>2019-03-12 10:15:08 +0000
commit2edb8418660fb5625721b3e64db54534897227aa (patch)
treed4ec1782e5803f478855e633f90e9266a2205958
parent958163d1f6f08f38e5a80a09ea1fe9c7278f7c45 (diff)
parent12eee030995a2f151757f1f2a71660e03476b678 (diff)
Merge "web: add flatten checkbox"
-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>