web ui: fix buildset display when no builds
This corrects a problem in the error handler when some request variables are undefined. This also handles the case of a buildset with no builds; currently the REST API omits the builds value in that case, so this updates usages to handle it. Change-Id: Ifa09990d08257244f17e77e5c8141bfd8c1cc4d7
This commit is contained in:
parent
a25bab2f3c
commit
48040f229a
|
@ -332,9 +332,11 @@ const fetchBuildset = (tenant, buildset) => dispatch => {
|
||||||
dispatch(requestBuildset())
|
dispatch(requestBuildset())
|
||||||
return API.fetchBuildset(tenant.apiPrefix, buildset)
|
return API.fetchBuildset(tenant.apiPrefix, buildset)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
response.data.builds.forEach(build => {
|
if (response.data.builds) {
|
||||||
dispatch(receiveBuild(build.uuid, build))
|
response.data.builds.forEach(build => {
|
||||||
})
|
dispatch(receiveBuild(build.uuid, build))
|
||||||
|
})
|
||||||
|
}
|
||||||
dispatch(receiveBuildset(buildset, response.data))
|
dispatch(receiveBuildset(buildset, response.data))
|
||||||
})
|
})
|
||||||
.catch(error => dispatch(failedBuildset(error)))
|
.catch(error => dispatch(failedBuildset(error)))
|
||||||
|
|
|
@ -26,7 +26,7 @@ export const addError = error => ({
|
||||||
|
|
||||||
export const addApiError = error => {
|
export const addApiError = error => {
|
||||||
const d = {
|
const d = {
|
||||||
url: error.request.responseURL || error.url
|
url: (error && error.request && error.request.responseURL) || error.url
|
||||||
}
|
}
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
d.text = error.response.statusText
|
d.text = error.response.statusText
|
||||||
|
|
|
@ -56,27 +56,29 @@ class Buildset extends React.Component {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
buildset.builds.forEach(build => {
|
if (buildset.builds) {
|
||||||
const row = []
|
buildset.builds.forEach(build => {
|
||||||
buildColumns.forEach(column => {
|
const row = []
|
||||||
if (column === 'job') {
|
buildColumns.forEach(column => {
|
||||||
row.push(build.job_name)
|
if (column === 'job') {
|
||||||
} else if (column === 'duration') {
|
row.push(build.job_name)
|
||||||
row.push(moment.duration(build.duration, 'seconds')
|
} else if (column === 'duration') {
|
||||||
.format('h [hr] m [min] s [sec]'))
|
row.push(moment.duration(build.duration, 'seconds')
|
||||||
} else if (column === 'voting') {
|
.format('h [hr] m [min] s [sec]'))
|
||||||
row.push(build.voting ? 'true' : 'false')
|
} else if (column === 'voting') {
|
||||||
} else if (column === 'result') {
|
row.push(build.voting ? 'true' : 'false')
|
||||||
row.push(<Link
|
} else if (column === 'result') {
|
||||||
to={this.props.tenant.linkPrefix + '/build/' + build.uuid}>
|
row.push(<Link
|
||||||
{build.result}
|
to={this.props.tenant.linkPrefix + '/build/' + build.uuid}>
|
||||||
</Link>)
|
{build.result}
|
||||||
} else {
|
</Link>)
|
||||||
row.push(build[column])
|
} else {
|
||||||
}
|
row.push(build[column])
|
||||||
|
}
|
||||||
|
})
|
||||||
|
buildRows.push(row)
|
||||||
})
|
})
|
||||||
buildRows.push(row)
|
}
|
||||||
})
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
|
@ -95,30 +97,31 @@ class Buildset extends React.Component {
|
||||||
</table>
|
</table>
|
||||||
</Panel.Body>
|
</Panel.Body>
|
||||||
</Panel>
|
</Panel>
|
||||||
<Panel>
|
{buildset.builds &&
|
||||||
<Panel.Heading>Builds</Panel.Heading>
|
<Panel>
|
||||||
<Panel.Body>
|
<Panel.Heading>Builds</Panel.Heading>
|
||||||
<table className="table table-striped table-bordered">
|
<Panel.Body>
|
||||||
<thead>
|
<table className="table table-striped table-bordered">
|
||||||
<tr>
|
<thead>
|
||||||
{buildColumns.map(item => (
|
<tr>
|
||||||
<td key={item}>{item}</td>
|
{buildColumns.map(item => (
|
||||||
))}
|
<td key={item}>{item}</td>
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{buildset.builds.map((item, idx) => (
|
|
||||||
<tr key={idx} className={item.result === 'SUCCESS' ? 'success': 'warning'}>
|
|
||||||
{buildRows[idx].map((item, idx) => (
|
|
||||||
<td key={idx}>{item}</td>
|
|
||||||
))}
|
))}
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
</thead>
|
||||||
</tbody>
|
<tbody>
|
||||||
</table>
|
{buildset.builds.map((item, idx) => (
|
||||||
</Panel.Body>
|
<tr key={idx} className={item.result === 'SUCCESS' ? 'success': 'warning'}>
|
||||||
</Panel>
|
{buildRows[idx].map((item, idx) => (
|
||||||
|
<td key={idx}>{item}</td>
|
||||||
|
))}
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</Panel.Body>
|
||||||
|
</Panel>
|
||||||
|
}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue