Skip to content
Snippets Groups Projects
Verified Commit 128a04ef authored by Nick Kipling's avatar Nick Kipling Committed by Nathan Friend
Browse files

Adjustments to event removal and modal description

parent 918e7d43
No related branches found
No related tags found
Loading
Pipeline #73779509 passed with warnings
......@@ -59,14 +59,17 @@ export default {
);
},
},
mounted() {
this.$refs.deleteModal.$refs.modal.$on('hide', this.removeModalEvents);
},
methods: {
...mapActions(['fetchList', 'deleteItem', 'multiDeleteItems']),
setModalDescription(itemsToDeleteLength, itemIndex) {
if (itemsToDeleteLength) {
setModalDescription(itemIndex = -1) {
if (itemIndex === -1) {
this.modalDescription = sprintf(
s__(`ContainerRegistry|You are about to delete <b>%{count}</b> images. This will
delete the images and all tags pointing to them.`),
{ count: itemsToDeleteLength },
{ count: this.itemsToBeDeleted.length },
);
} else {
const { tag } = this.repo.list[itemIndex];
......@@ -86,25 +89,26 @@ export default {
},
removeModalEvents() {
this.$refs.deleteModal.$refs.modal.$off('ok');
this.$refs.deleteModal.$refs.modal.$off('hide');
},
deleteSingleItem(index) {
this.setModalDescription(0, index);
this.setModalDescription(index);
this.$refs.deleteModal.$refs.modal.$once('ok', () => {
this.removeModalEvents();
this.handleSingleDelete(this.repo.list[index]);
});
this.$refs.deleteModal.$refs.modal.$once('hide', this.removeModalEvents);
},
deleteMultipleItems() {
if (this.itemsToBeDeleted.length === 1) {
this.setModalDescription(this.itemsToBeDeleted[0]);
} else if (this.itemsToBeDeleted.length > 1) {
this.setModalDescription();
}
this.$refs.deleteModal.$refs.modal.$once('ok', () => {
this.removeModalEvents();
this.handleMultipleDelete();
});
this.$refs.deleteModal.$refs.modal.$once('hide', this.removeModalEvents);
},
handleSingleDelete(itemToDelete) {
this.deleteItem(itemToDelete)
......@@ -144,7 +148,6 @@ export default {
selectAll() {
this.itemsToBeDeleted = this.repo.list.map((x, index) => index);
this.selectAllChecked = true;
this.setModalDescription(this.itemsToBeDeleted.length);
},
deselectAll() {
this.itemsToBeDeleted = [];
......@@ -163,12 +166,6 @@ export default {
this.selectAllChecked = true;
}
}
if (this.itemsToBeDeleted.length === 1) {
this.setModalDescription(0, this.itemsToBeDeleted[0]);
} else if (this.itemsToBeDeleted.length > 1) {
this.setModalDescription(this.itemsToBeDeleted.length);
}
},
},
};
......
......@@ -177,6 +177,7 @@ describe('table registry', () => {
it('should show the plural title and image count when deleting more than one image', done => {
selectAllCheckboxes();
vm.setModalDescription();
Vue.nextTick(() => {
expect(vm.modalTitle).toBe('Remove images');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment