Browse Source

web: add flatten checkbox

This change adds a checkbox to display the jobs as a flat list.

Change-Id: Iaf7c8f9de356661c9ab24c83c409c59f866ffaaf
tags/3.7.0
Tristan Cacqueray 2 months ago
parent
commit
12eee03099
1 changed files with 28 additions and 16 deletions
  1. 28
    16
      web/src/containers/jobs/Jobs.jsx

+ 28
- 16
web/src/containers/jobs/Jobs.jsx View File

@@ -17,6 +17,7 @@ import PropTypes from 'prop-types'
17 17
 import { connect } from 'react-redux'
18 18
 import { Link } from 'react-router-dom'
19 19
 import {
20
+  Checkbox,
20 21
   Form,
21 22
   FormGroup,
22 23
   FormControl,
@@ -32,7 +33,8 @@ class JobsList extends React.Component {
32 33
   }
33 34
 
34 35
   state = {
35
-    filter: null
36
+    filter: null,
37
+    flatten: false,
36 38
   }
37 39
 
38 40
   handleKeyPress = (e) => {
@@ -45,7 +47,7 @@ class JobsList extends React.Component {
45 47
 
46 48
   render () {
47 49
     const { jobs } = this.props
48
-    const { filter } = this.state
50
+    const { filter, flatten } = this.state
49 51
 
50 52
     const linkPrefix = this.props.tenant.linkPrefix + '/job/'
51 53
 
@@ -84,8 +86,10 @@ class JobsList extends React.Component {
84 86
           filtered: filtered,
85 87
         }
86 88
         // Visit parent recursively
87
-        for (let parent of parents) {
88
-          getNode(jobMap[parent], filtered)
89
+        if (!flatten) {
90
+          for (let parent of parents) {
91
+            getNode(jobMap[parent], filtered)
92
+          }
89 93
         }
90 94
       }
91 95
       return visited[job.name]
@@ -110,19 +114,21 @@ class JobsList extends React.Component {
110 114
       const jobNode = getNode(job, filtered)
111 115
       if (!jobNode.filtered) {
112 116
         let attached = false
113
-        // add tree node to each parent and expand the parent
114
-        for (let parent of jobNode.parents) {
115
-          const parentNode = visited[parent]
116
-          if (!parentNode) {
117
-            console.log(
118
-              'Job ', job.name, ' parent ', parent, ' does not exist!')
119
-            continue
120
-          }
121
-          if (!parentNode.nodes) {
122
-            parentNode.nodes = []
117
+        if (!flatten) {
118
+          // add tree node to each parent and expand the parent
119
+          for (let parent of jobNode.parents) {
120
+            const parentNode = visited[parent]
121
+            if (!parentNode) {
122
+              console.log(
123
+                'Job ', job.name, ' parent ', parent, ' does not exist!')
124
+              continue
125
+            }
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 133
         // else add node at the tree root
128 134
         if (!attached || jobNode.parents.length === 0) {
@@ -153,6 +159,12 @@ class JobsList extends React.Component {
153 159
               </FormControl.Feedback>
154 160
             )}
155 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 168
         </Form>
157 169
         <TreeView nodes={nodes} />
158 170
       </div>

Loading…
Cancel
Save