commit 812ee02594687ab69f21d8724ea643943b1d3de2 Author: Felix Edel Date: Tue Sep 29 15:33:13 2020 +0200 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 diff --git a/web/src/actions/build.js b/web/src/actions/build.js index 9b810e6..488f330 100644 --- a/web/src/actions/build.js +++ b/web/src/actions/build.js @@ -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) => { diff --git a/web/src/pages/Buildset.jsx b/web/src/pages/Buildset.jsx index b3a188e..9069a43 100644 --- a/web/src/pages/Buildset.jsx +++ b/web/src/pages/Buildset.jsx @@ -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) ) }