Commit 71f2d4bb authored by Nick Kipling's avatar Nick Kipling Committed by Nathan Friend

Updating FE to use new bulk_destroy endpoint

parent 0426d15c
......@@ -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(() =>
......
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment