Merge "Refactor task result detection"
This commit is contained in:
commit
a2018c599a
|
@ -23,19 +23,10 @@ import {
|
||||||
Modal,
|
Modal,
|
||||||
} from 'patternfly-react'
|
} from 'patternfly-react'
|
||||||
|
|
||||||
import { didTaskFail } from '../../actions/build'
|
|
||||||
|
|
||||||
|
|
||||||
const INTERESTING_KEYS = ['msg', 'stdout', 'stderr']
|
const INTERESTING_KEYS = ['msg', 'stdout', 'stderr']
|
||||||
|
|
||||||
|
|
||||||
function hostTaskStats (state, host) {
|
|
||||||
if (didTaskFail(host)) { state.failed += 1}
|
|
||||||
else if (host.changed) { state.changed += 1}
|
|
||||||
else if (host.skip_reason) { state.skipped += 1}
|
|
||||||
else { state.ok += 1}
|
|
||||||
}
|
|
||||||
|
|
||||||
function hasInterestingKeys (obj, keys) {
|
function hasInterestingKeys (obj, keys) {
|
||||||
let ret = false
|
let ret = false
|
||||||
|
|
||||||
|
@ -189,10 +180,10 @@ class HostTask extends React.Component {
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
showModal: false,
|
showModal: false,
|
||||||
failed: 0,
|
failed: false,
|
||||||
changed: 0,
|
changed: false,
|
||||||
skipped: 0,
|
skipped: false,
|
||||||
ok: 0
|
ok: false
|
||||||
}
|
}
|
||||||
|
|
||||||
open = () => {
|
open = () => {
|
||||||
|
@ -206,9 +197,17 @@ class HostTask extends React.Component {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
|
||||||
const { host, taskPath, displayPath } = this.props
|
const { host, task, taskPath, displayPath, errorIds } = this.props
|
||||||
|
|
||||||
hostTaskStats(this.state, host)
|
if (errorIds.has(task.task.id)) {
|
||||||
|
this.state.failed = true
|
||||||
|
} else if (host.changed) {
|
||||||
|
this.state.changed = true
|
||||||
|
} else if (host.skip_reason) {
|
||||||
|
this.state.skipped = true
|
||||||
|
} else {
|
||||||
|
this.state.ok = true
|
||||||
|
}
|
||||||
|
|
||||||
if (taskPathMatches(taskPath, displayPath))
|
if (taskPathMatches(taskPath, displayPath))
|
||||||
this.state.showModal = true
|
this.state.showModal = true
|
||||||
|
@ -218,25 +217,22 @@ class HostTask extends React.Component {
|
||||||
const { hostname, task, host, taskPath, errorIds } = this.props
|
const { hostname, task, host, taskPath, errorIds } = this.props
|
||||||
|
|
||||||
const ai = []
|
const ai = []
|
||||||
if (this.state.skipped) {
|
|
||||||
ai.push(
|
|
||||||
<ListView.InfoItem key="skipped" title="Click for details">
|
|
||||||
<span className="task-skipped" onClick={this.open}>SKIPPED</span>
|
|
||||||
</ListView.InfoItem>)
|
|
||||||
}
|
|
||||||
if (this.state.changed) {
|
|
||||||
ai.push(
|
|
||||||
<ListView.InfoItem key="changed" title="Click for details">
|
|
||||||
<span className="task-changed" onClick={this.open}>CHANGED</span>
|
|
||||||
</ListView.InfoItem>)
|
|
||||||
}
|
|
||||||
if (this.state.failed) {
|
if (this.state.failed) {
|
||||||
ai.push(
|
ai.push(
|
||||||
<ListView.InfoItem key="failed" title="Click for details">
|
<ListView.InfoItem key="failed" title="Click for details">
|
||||||
<span className="task-failed" onClick={this.open}>FAILED</span>
|
<span className="task-failed" onClick={this.open}>FAILED</span>
|
||||||
</ListView.InfoItem>)
|
</ListView.InfoItem>)
|
||||||
}
|
} else if (this.state.changed) {
|
||||||
if (this.state.ok) {
|
ai.push(
|
||||||
|
<ListView.InfoItem key="changed" title="Click for details">
|
||||||
|
<span className="task-changed" onClick={this.open}>CHANGED</span>
|
||||||
|
</ListView.InfoItem>)
|
||||||
|
} else if (this.state.skipped) {
|
||||||
|
ai.push(
|
||||||
|
<ListView.InfoItem key="skipped" title="Click for details">
|
||||||
|
<span className="task-skipped" onClick={this.open}>SKIPPED</span>
|
||||||
|
</ListView.InfoItem>)
|
||||||
|
} else if (this.state.ok) {
|
||||||
ai.push(
|
ai.push(
|
||||||
<ListView.InfoItem key="ok" title="Click for details">
|
<ListView.InfoItem key="ok" title="Click for details">
|
||||||
<span className="task-ok" onClick={this.open}>OK</span>
|
<span className="task-ok" onClick={this.open}>OK</span>
|
||||||
|
|
Loading…
Reference in New Issue