Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/registry/explorer/stores/actions.js')
-rw-r--r--app/assets/javascripts/registry/explorer/stores/actions.js43
1 files changed, 29 insertions, 14 deletions
diff --git a/app/assets/javascripts/registry/explorer/stores/actions.js b/app/assets/javascripts/registry/explorer/stores/actions.js
index 9125f573aa4..c1883095097 100644
--- a/app/assets/javascripts/registry/explorer/stores/actions.js
+++ b/app/assets/javascripts/registry/explorer/stores/actions.js
@@ -1,13 +1,15 @@
import axios from '~/lib/utils/axios_utils';
-import { deprecatedCreateFlash as createFlash } from '~/flash';
+import createFlash from '~/flash';
+import Api from '~/api';
import * as types from './mutation_types';
import {
FETCH_IMAGES_LIST_ERROR_MESSAGE,
DEFAULT_PAGE,
DEFAULT_PAGE_SIZE,
FETCH_TAGS_LIST_ERROR_MESSAGE,
+ FETCH_IMAGE_DETAILS_ERROR_MESSAGE,
} from '../constants/index';
-import { decodeAndParse } from '../utils';
+import { pathGenerator } from '../utils';
export const setInitialState = ({ commit }, data) => commit(types.SET_INITIAL_STATE, data);
export const setShowGarbageCollectionTip = ({ commit }, data) =>
@@ -36,55 +38,68 @@ export const requestImagesList = (
dispatch('receiveImagesListSuccess', { data, headers });
})
.catch(() => {
- createFlash(FETCH_IMAGES_LIST_ERROR_MESSAGE);
+ createFlash({ message: FETCH_IMAGES_LIST_ERROR_MESSAGE });
})
.finally(() => {
commit(types.SET_MAIN_LOADING, false);
});
};
-export const requestTagsList = ({ commit, dispatch }, { pagination = {}, params }) => {
+export const requestTagsList = ({ commit, dispatch, state: { imageDetails } }, pagination = {}) => {
commit(types.SET_MAIN_LOADING, true);
- const { tags_path } = decodeAndParse(params);
+ const tagsPath = pathGenerator(imageDetails);
const { page = DEFAULT_PAGE, perPage = DEFAULT_PAGE_SIZE } = pagination;
return axios
- .get(tags_path, { params: { page, per_page: perPage } })
+ .get(tagsPath, { params: { page, per_page: perPage } })
.then(({ data, headers }) => {
dispatch('receiveTagsListSuccess', { data, headers });
})
.catch(() => {
- createFlash(FETCH_TAGS_LIST_ERROR_MESSAGE);
+ createFlash({ message: FETCH_TAGS_LIST_ERROR_MESSAGE });
})
.finally(() => {
commit(types.SET_MAIN_LOADING, false);
});
};
-export const requestDeleteTag = ({ commit, dispatch, state }, { tag, params }) => {
+export const requestImageDetailsAndTagsList = ({ dispatch, commit }, id) => {
+ commit(types.SET_MAIN_LOADING, true);
+ return Api.containerRegistryDetails(id)
+ .then(({ data }) => {
+ commit(types.SET_IMAGE_DETAILS, data);
+ dispatch('requestTagsList');
+ })
+ .catch(() => {
+ createFlash({ message: FETCH_IMAGE_DETAILS_ERROR_MESSAGE });
+ commit(types.SET_MAIN_LOADING, false);
+ });
+};
+
+export const requestDeleteTag = ({ commit, dispatch, state }, { tag }) => {
commit(types.SET_MAIN_LOADING, true);
return axios
.delete(tag.destroy_path)
.then(() => {
dispatch('setShowGarbageCollectionTip', true);
- return dispatch('requestTagsList', { pagination: state.tagsPagination, params });
+
+ return dispatch('requestTagsList', state.tagsPagination);
})
.finally(() => {
commit(types.SET_MAIN_LOADING, false);
});
};
-export const requestDeleteTags = ({ commit, dispatch, state }, { ids, params }) => {
+export const requestDeleteTags = ({ commit, dispatch, state }, { ids }) => {
commit(types.SET_MAIN_LOADING, true);
- const { tags_path } = decodeAndParse(params);
- const url = tags_path.replace('?format=json', '/bulk_destroy');
+ const tagsPath = pathGenerator(state.imageDetails, '/bulk_destroy');
return axios
- .delete(url, { params: { ids } })
+ .delete(tagsPath, { params: { ids } })
.then(() => {
dispatch('setShowGarbageCollectionTip', true);
- return dispatch('requestTagsList', { pagination: state.tagsPagination, params });
+ return dispatch('requestTagsList', state.tagsPagination);
})
.finally(() => {
commit(types.SET_MAIN_LOADING, false);