Browse Source

Merge "Refactor task result detection"

tags/3.10.0
Zuul 1 week ago
parent
commit
a2018c599a
1 changed files with 22 additions and 26 deletions
  1. 22
    26
      web/src/containers/build/Console.jsx

+ 22
- 26
web/src/containers/build/Console.jsx View File

@@ -23,19 +23,10 @@ import {
23 23
   Modal,
24 24
 } from 'patternfly-react'
25 25
 
26
-import { didTaskFail } from '../../actions/build'
27
-
28 26
 
29 27
 const INTERESTING_KEYS = ['msg', 'stdout', 'stderr']
30 28
 
31 29
 
32
-function hostTaskStats (state, host) {
33
-  if (didTaskFail(host)) { state.failed += 1}
34
-  else if (host.changed) { state.changed += 1}
35
-  else if (host.skip_reason) { state.skipped += 1}
36
-  else { state.ok += 1}
37
-}
38
-
39 30
 function hasInterestingKeys (obj, keys) {
40 31
   let ret = false
41 32
 
@@ -189,10 +180,10 @@ class HostTask extends React.Component {
189 180
 
190 181
   state = {
191 182
     showModal: false,
192
-    failed: 0,
193
-    changed: 0,
194
-    skipped: 0,
195
-    ok: 0
183
+    failed: false,
184
+    changed: false,
185
+    skipped: false,
186
+    ok: false
196 187
   }
197 188
 
198 189
   open = () => {
@@ -206,9 +197,17 @@ class HostTask extends React.Component {
206 197
   constructor (props) {
207 198
     super(props)
208 199
 
209
-    const { host, taskPath, displayPath } = this.props
200
+    const { host, task, taskPath, displayPath, errorIds } = this.props
210 201
 
211
-    hostTaskStats(this.state, host)
202
+    if (errorIds.has(task.task.id)) {
203
+      this.state.failed = true
204
+    } else if (host.changed) {
205
+      this.state.changed = true
206
+    } else if (host.skip_reason) {
207
+      this.state.skipped = true
208
+    } else {
209
+      this.state.ok = true
210
+    }
212 211
 
213 212
     if (taskPathMatches(taskPath, displayPath))
214 213
       this.state.showModal = true
@@ -218,25 +217,22 @@ class HostTask extends React.Component {
218 217
     const { hostname, task, host, taskPath, errorIds } = this.props
219 218
 
220 219
     const ai = []
221
-    if (this.state.skipped) {
220
+    if (this.state.failed) {
222 221
       ai.push(
223
-        <ListView.InfoItem key="skipped" title="Click for details">
224
-          <span className="task-skipped" onClick={this.open}>SKIPPED</span>
222
+        <ListView.InfoItem key="failed" title="Click for details">
223
+          <span className="task-failed" onClick={this.open}>FAILED</span>
225 224
         </ListView.InfoItem>)
226
-    }
227
-    if (this.state.changed) {
225
+    } else if (this.state.changed) {
228 226
       ai.push(
229 227
         <ListView.InfoItem key="changed" title="Click for details">
230 228
           <span className="task-changed" onClick={this.open}>CHANGED</span>
231 229
         </ListView.InfoItem>)
232
-    }
233
-    if (this.state.failed) {
230
+    } else if (this.state.skipped) {
234 231
       ai.push(
235
-        <ListView.InfoItem key="failed" title="Click for details">
236
-          <span className="task-failed" onClick={this.open}>FAILED</span>
232
+        <ListView.InfoItem key="skipped" title="Click for details">
233
+          <span className="task-skipped" onClick={this.open}>SKIPPED</span>
237 234
         </ListView.InfoItem>)
238
-    }
239
-    if (this.state.ok) {
235
+    } else if (this.state.ok) {
240 236
       ai.push(
241 237
         <ListView.InfoItem key="ok" title="Click for details">
242 238
           <span className="task-ok" onClick={this.open}>OK</span>

Loading…
Cancel
Save