Don't overwrite builds when retrieving the buildset

Currently, when retrieving a buildset from the API we also store the
builds that are contained in the buildset's API result in the redux
store. In case those builds were already present (because e.g. the
build page was visited before) they are overwritten but with less
information. This results in missing links and properties on the build
depending on how the page was accessed.

Since the buildset page is anyways using the builds that are contained
in the buildset directly and the build page fetches the necessary build
by itself in case it's not present already, we could simply remove the
relevant part in the fetchBuildset() action and avoid weird behaviour in
the UI.

Change-Id: I90ffd7f8b3fbd13d623ac94ddfd63b5b58cbffe6
This commit is contained in:
Felix Edel 2020-09-29 15:33:13 +02:00
parent 116b7e9b8e
commit 812ee02594
No known key found for this signature in database
GPG Key ID: E95717A102DD3030
2 changed files with 13 additions and 19 deletions

View File

@ -376,18 +376,16 @@ const failedBuildset = error => ({
error
})
const fetchBuildset = (tenant, buildset) => dispatch => {
dispatch(requestBuildset())
return API.fetchBuildset(tenant.apiPrefix, buildset)
.then(response => {
if (response.data.builds) {
response.data.builds.forEach(build => {
dispatch(receiveBuild(build.uuid, build))
})
}
dispatch(receiveBuildset(buildset, response.data))
})
.catch(error => dispatch(failedBuildset(error)))
export function fetchBuildset(tenant, buildsetId) {
return async function(dispatch) {
dispatch(requestBuildset())
try {
const response = await API.fetchBuildset(tenant.apiPrefix, buildsetId)
dispatch(receiveBuildset(buildsetId, response.data))
} catch (error) {
dispatch(failedBuildset(error))
}
}
}
const shouldFetchBuildset = (buildsetId, state) => {

View File

@ -25,7 +25,7 @@ import {
} from '@patternfly/react-core'
import { BuildIcon } from '@patternfly/react-icons'
import { fetchBuildsetIfNeeded } from '../actions/build'
import { fetchBuildset } from '../actions/build'
import { EmptyPage } from '../containers/Errors'
import { Fetchable, Fetching } from '../containers/Fetching'
import BuildList from '../containers/build/BuildList'
@ -39,13 +39,9 @@ class BuildsetPage extends React.Component {
dispatch: PropTypes.func,
}
updateData = (force) => {
updateData = () => {
this.props.dispatch(
fetchBuildsetIfNeeded(
this.props.tenant,
this.props.match.params.buildsetId,
force
)
fetchBuildset(this.props.tenant, this.props.match.params.buildsetId)
)
}