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

View file

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

View file

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

View file

@ -14,7 +14,7 @@ import types from '../types';
export function composes(state = { }, action) { export function composes(state = { }, action) {
switch (action.type) { switch (action.type) {
case types.UPDATE_COMPOSE: case types.COMPOSE_UPDATED:
return Object.assign({}, state, action.compose); return Object.assign({}, state, action.compose);
default: default:
return state; 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_RELEASE = 'SET_RELEASE';
const SET_UPLOAD_DESTINATIONS = 'SET_UPLOAD_DESTINATIONS'; const SET_UPLOAD_DESTINATIONS = 'SET_UPLOAD_DESTINATIONS';
const SET_UPLOAD_AWS = 'SET_UPLOAD_AWS'; const SET_UPLOAD_AWS = 'SET_UPLOAD_AWS';
@ -9,7 +9,7 @@ const SET_SUBSCRIPTION = 'SET_SUBSCRIPTION';
const SET_SUBSCRIBE_NOW = 'SET_SUBSCRIBE_NOW'; const SET_SUBSCRIBE_NOW = 'SET_SUBSCRIBE_NOW';
export default { export default {
UPDATE_COMPOSE, COMPOSE_UPDATED,
SET_RELEASE, SET_RELEASE,
SET_UPLOAD_DESTINATIONS, SET_UPLOAD_DESTINATIONS,
SET_UPLOAD_AWS, SET_UPLOAD_AWS,

View file

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

View file

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