gitlab-org--gitlab-foss/app/assets/javascripts/registry/stores/mutations.js
2017-09-19 17:55:25 +01:00

38 lines
1 KiB
JavaScript

import * as types from './mutation_types';
export default {
[types.SET_REPOS_LIST](state, list) {
Object.assign(state, {
repos: list.map(el => ({
name: el.name,
isLoading: false,
canDelete: !!el.destroy_path,
destroyPath: el.destroy_path,
list: [],
})),
});
},
[types.TOGGLE_MAIN_LOADING](state) {
Object.assign(state, { isLoading: !state.isLoading });
},
[types.SET_IMAGES_LIST](state, image, list) {
const listToUpdate = state.repos.find(el => el.name === image.name);
listToUpdate.list = list.map(element => ({
tag: element.name,
revision: element.revision,
shortRevision: element.short_revision,
size: element.size,
layers: element.layers,
createdAt: element.created_at,
destroyPath: element.destroy_path,
canDelete: !!element.destroy_path,
}));
},
[types.TOGGLE_IMAGE_LOADING](state, image) {
const listToUpdate = state.repos.find(el => el.name === image.name);
listToUpdate.isLoading = !listToUpdate.isLoading;
},
};