store: rename updatecompose to compose updated

Our compose actions will follow the naming convention of *name*_*event*.
Therefore, when we receive an updated compose from the api, the action
should be called COMPOSE_UPDATED.
This commit is contained in:
Jacob Kozol 2021-04-13 17:51:00 +02:00 committed by Sanne Raymaekers
parent 04aac0d7f0
commit fbada9d990
7 changed files with 18 additions and 18 deletions

View file

@ -222,7 +222,7 @@ class CreateImageWizard extends Component {
image_type: request.image_requests[0].image_type,
upload_type: request.image_requests[0].upload_request.type,
};
this.props.updateCompose(compose);
this.props.composeUpdated(compose);
});
composeRequests.push(composeRequest);
});
@ -348,13 +348,13 @@ function mapStateToProps(state) {
function mapDispatchToProps(dispatch) {
return {
updateCompose: (compose) => dispatch(actions.updateCompose(compose)),
composeUpdated: (compose) => dispatch(actions.composeUpdated(compose)),
addNotification: (not) => dispatch(addNotification(not)),
};
}
CreateImageWizard.propTypes = {
updateCompose: PropTypes.func,
composeUpdated: PropTypes.func,
addNotification: PropTypes.func,
history: PropTypes.object,
release: PropTypes.object,

View file

@ -51,7 +51,7 @@ class ImagesTable extends Component {
}
pollComposeStatuses() {
let { updateCompose, composes } = this.props;
let { composeUpdated, composes } = this.props;
Object.entries(composes).map(([ id, compose ]) => {
/* Skip composes that have been complete */
if (compose.image_status.status === 'success' || compose.image_status.status === 'failure') {
@ -61,7 +61,7 @@ class ImagesTable extends Component {
api.getComposeStatus(id).then(response => {
let newCompose = {};
newCompose[id] = Object.assign({}, compose, { image_status: response.image_status });
updateCompose(newCompose);
composeUpdated(newCompose);
});
});
}
@ -131,13 +131,13 @@ function mapStateToProps(state) {
function mapDispatchToProps(dispatch) {
return {
updateCompose: (compose) => dispatch(actions.updateCompose(compose)),
composeUpdated: (compose) => dispatch(actions.composeUpdated(compose)),
};
}
ImagesTable.propTypes = {
composes: PropTypes.object,
updateCompose: PropTypes.func,
composeUpdated: PropTypes.func,
};
export default connect(mapStateToProps, mapDispatchToProps)(ImagesTable);

View file

@ -1,8 +1,8 @@
import types from '../types';
function updateCompose(compose) {
function composeUpdated(compose) {
return {
type: types.UPDATE_COMPOSE,
type: types.COMPOSE_UPDATED,
compose
};
}
@ -84,7 +84,7 @@ function setSubscribeNow(subscribeNow) {
}
export default {
updateCompose,
composeUpdated,
setRelease,
setUploadDestinations,
setUploadAWS,

View file

@ -14,7 +14,7 @@ import types from '../types';
export function composes(state = { }, action) {
switch (action.type) {
case types.UPDATE_COMPOSE:
case types.COMPOSE_UPDATED:
return Object.assign({}, state, action.compose);
default:
return state;

View file

@ -1,4 +1,4 @@
const UPDATE_COMPOSE = 'UPDATE_COMPOSE';
const COMPOSE_UPDATED = 'COMPOSE_UPDATED';
const SET_RELEASE = 'SET_RELEASE';
const SET_UPLOAD_DESTINATIONS = 'SET_UPLOAD_DESTINATIONS';
const SET_UPLOAD_AWS = 'SET_UPLOAD_AWS';
@ -9,7 +9,7 @@ const SET_SUBSCRIPTION = 'SET_SUBSCRIPTION';
const SET_SUBSCRIBE_NOW = 'SET_SUBSCRIBE_NOW';
export default {
UPDATE_COMPOSE,
COMPOSE_UPDATED,
SET_RELEASE,
SET_UPLOAD_DESTINATIONS,
SET_UPLOAD_AWS,

View file

@ -10,13 +10,13 @@ const compose = {
}
};
describe('updateCompose', () => {
describe('composeUpdated', () => {
test('returns dict', () => {
const result = actions.updateCompose(compose);
const result = actions.composeUpdated(compose);
// this function updates the type attribute and
// returns everything else unchanged
expect(result.type).toBe(types.UPDATE_COMPOSE);
expect(result.type).toBe(types.COMPOSE_UPDATED);
expect(result.compose).toBe(compose);
});
});

View file

@ -19,12 +19,12 @@ describe('composes', () => {
expect(result).toEqual({});
});
test('returns updates state for types.UPDATE_COMPOSE', () => {
test('returns updates state for types.COMPOSE_UPDATED', () => {
const state = {
testAttr: 'test-me'
};
const result = composes(state, {
type: types.UPDATE_COMPOSE,
type: types.COMPOSE_UPDATED,
compose
});