diff options
author | Nick Kipling <nkipling@gitlab.com> | 2019-07-18 10:10:41 +0100 |
---|---|---|
committer | Nathan Friend <nathan@gitlab.com> | 2019-07-30 13:49:48 -0300 |
commit | 71f2d4bb8944fff33f511a9687468c87dc329cc5 (patch) | |
tree | 9aaf923cc33f54567848486a5b8d2f1258afbea5 | |
parent | 0426d15c080255a97297a2d45fbc4e8c5d119124 (diff) | |
download | gitlab-ce-71f2d4bb8944fff33f511a9687468c87dc329cc5.tar.gz |
Updating FE to use new bulk_destroy endpoint
-rw-r--r-- | app/assets/javascripts/registry/components/table_registry.vue | 27 | ||||
-rw-r--r-- | app/assets/javascripts/registry/stores/actions.js | 1 |
2 files changed, 15 insertions, 13 deletions
diff --git a/app/assets/javascripts/registry/components/table_registry.vue b/app/assets/javascripts/registry/components/table_registry.vue index a241db13e5a..cf1ee0e06a6 100644 --- a/app/assets/javascripts/registry/components/table_registry.vue +++ b/app/assets/javascripts/registry/components/table_registry.vue @@ -45,6 +45,9 @@ export default { }; }, computed: { + bulkDeletePath() { + return this.repo.tagsPath ? this.repo.tagsPath.replace('?format=json', '/bulk_destroy') : ''; + }, shouldRenderPagination() { return this.repo.pagination.total > this.repo.pagination.perPage; }, @@ -78,7 +81,7 @@ export default { }, }, methods: { - ...mapActions(['fetchList', 'deleteItem']), + ...mapActions(['fetchList', 'deleteItems']), layers(item) { return item.layers ? n__('%d layer', '%d layers', item.layers) : ''; }, @@ -101,18 +104,16 @@ export default { itemsToBeDeleted = [singleItemToBeDeleted]; } - const deleteActions = itemsToBeDeleted.map( - x => - new Promise((resolve, reject) => { - this.deleteItem(this.repo.list[x]) - .then(resolve) - .catch(reject); - }), - ); - - Promise.all(deleteActions) - .then(() => this.fetchList({ repo: this.repo })) - .catch(() => this.showError(errorMessagesTypes.DELETE_REGISTRY)); + if (this.bulkDeletePath) { + this.deleteItems({ + path: this.bulkDeletePath, + items: itemsToBeDeleted.map(x => this.repo.list[x].tag), + }) + .then(() => this.fetchList({ repo: this.repo })) + .catch(() => this.showError(errorMessagesTypes.DELETE_REGISTRY)); + } else { + this.showError(errorMessagesTypes.DELETE_REGISTRY); + } }, onPageChange(pageNumber) { this.fetchList({ repo: this.repo, page: pageNumber }).catch(() => diff --git a/app/assets/javascripts/registry/stores/actions.js b/app/assets/javascripts/registry/stores/actions.js index 0f5e9cc73a0..4c20c003c5a 100644 --- a/app/assets/javascripts/registry/stores/actions.js +++ b/app/assets/javascripts/registry/stores/actions.js @@ -36,6 +36,7 @@ export const fetchList = ({ commit }, { repo, page }) => { }; export const deleteItem = (_, item) => axios.delete(item.destroyPath); +export const deleteItems = (_, { path, items }) => axios.delete(path, { params: { ids: items } }); export const setMainEndpoint = ({ commit }, data) => commit(types.SET_MAIN_ENDPOINT, data); export const toggleLoading = ({ commit }) => commit(types.TOGGLE_MAIN_LOADING); |