debian-mirror-gitlab/app/assets/javascripts/registry/stores/mutations.js

58 lines
1.6 KiB
JavaScript
Raw Normal View History

2018-03-17 18:26:18 +05:30
import * as types from './mutation_types';
2019-12-26 22:10:19 +05:30
import { parseIntPagination, normalizeHeaders } from '~/lib/utils/common_utils';
2018-03-17 18:26:18 +05:30
export default {
[types.SET_MAIN_ENDPOINT](state, endpoint) {
2019-12-26 22:10:19 +05:30
state.endpoint = endpoint;
2018-03-17 18:26:18 +05:30
},
2019-12-21 20:55:43 +05:30
[types.SET_IS_DELETE_DISABLED](state, isDeleteDisabled) {
2019-12-26 22:10:19 +05:30
state.isDeleteDisabled = isDeleteDisabled;
2019-12-21 20:55:43 +05:30
},
2018-03-17 18:26:18 +05:30
[types.SET_REPOS_LIST](state, list) {
2019-12-26 22:10:19 +05:30
state.repos = list.map(el => ({
canDelete: Boolean(el.destroy_path),
destroyPath: el.destroy_path,
id: el.id,
isLoading: false,
list: [],
location: el.location,
name: el.path,
tagsPath: el.tags_path,
projectId: el.project_id,
}));
2018-03-17 18:26:18 +05:30
},
[types.TOGGLE_MAIN_LOADING](state) {
2019-12-26 22:10:19 +05:30
state.isLoading = !state.isLoading;
2018-03-17 18:26:18 +05:30
},
[types.SET_REGISTRY_LIST](state, { repo, resp, headers }) {
const listToUpdate = state.repos.find(el => el.id === repo.id);
const normalizedHeaders = normalizeHeaders(headers);
const pagination = parseIntPagination(normalizedHeaders);
listToUpdate.pagination = pagination;
listToUpdate.list = resp.map(element => ({
tag: element.name,
revision: element.revision,
shortRevision: element.short_revision,
size: element.total_size,
layers: element.layers,
location: element.location,
createdAt: element.created_at,
destroyPath: element.destroy_path,
2019-09-04 21:01:54 +05:30
canDelete: Boolean(element.destroy_path),
2018-03-17 18:26:18 +05:30
}));
},
[types.TOGGLE_REGISTRY_LIST_LOADING](state, list) {
const listToUpdate = state.repos.find(el => el.id === list.id);
2019-02-15 15:39:39 +05:30
2018-03-17 18:26:18 +05:30
listToUpdate.isLoading = !listToUpdate.isLoading;
},
};