Commit b698e4ce authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'registry-fix-multi-delete-modal' into 'master'

Set unique modal IDs

See merge request gitlab-org/gitlab-ce!30532
parents 46ec439c a076d1d8
...@@ -31,6 +31,7 @@ export default { ...@@ -31,6 +31,7 @@ export default {
data() { data() {
return { return {
isOpen: false, isOpen: false,
modalId: `confirm-repo-deletion-modal-${this.repo.id}`,
}; };
}, },
computed: { computed: {
...@@ -80,7 +81,7 @@ export default { ...@@ -80,7 +81,7 @@ export default {
<gl-button <gl-button
v-if="repo.canDelete" v-if="repo.canDelete"
v-gl-tooltip v-gl-tooltip
v-gl-modal="'confirm-repo-deletion-modal'" v-gl-modal="modalId"
:title="s__('ContainerRegistry|Remove repository')" :title="s__('ContainerRegistry|Remove repository')"
:aria-label="s__('ContainerRegistry|Remove repository')" :aria-label="s__('ContainerRegistry|Remove repository')"
class="js-remove-repo" class="js-remove-repo"
...@@ -100,12 +101,7 @@ export default { ...@@ -100,12 +101,7 @@ export default {
{{ s__('ContainerRegistry|No tags in Container Registry for this container image.') }} {{ s__('ContainerRegistry|No tags in Container Registry for this container image.') }}
</div> </div>
</div> </div>
<gl-modal :modal-id="modalId" ok-variant="danger" @ok="handleDeleteRepository">
<gl-modal
modal-id="confirm-repo-deletion-modal"
ok-variant="danger"
@ok="handleDeleteRepository"
>
<template v-slot:modal-title>{{ s__('ContainerRegistry|Remove repository') }}</template> <template v-slot:modal-title>{{ s__('ContainerRegistry|Remove repository') }}</template>
<p <p
v-html=" v-html="
......
...@@ -32,6 +32,7 @@ export default { ...@@ -32,6 +32,7 @@ export default {
data() { data() {
return { return {
itemToBeDeleted: null, itemToBeDeleted: null,
modalId: `confirm-image-deletion-modal-${this.repo.id}`,
}; };
}, },
computed: { computed: {
...@@ -114,7 +115,7 @@ export default { ...@@ -114,7 +115,7 @@ export default {
<gl-button <gl-button
v-if="item.canDelete" v-if="item.canDelete"
v-gl-tooltip v-gl-tooltip
v-gl-modal="'confirm-image-deletion-modal'" v-gl-modal="modalId"
:title="s__('ContainerRegistry|Remove image')" :title="s__('ContainerRegistry|Remove image')"
:aria-label="s__('ContainerRegistry|Remove image')" :aria-label="s__('ContainerRegistry|Remove image')"
variant="danger" variant="danger"
...@@ -134,11 +135,7 @@ export default { ...@@ -134,11 +135,7 @@ export default {
:page-info="repo.pagination" :page-info="repo.pagination"
/> />
<gl-modal <gl-modal :modal-id="modalId" ok-variant="danger" @ok="handleDeleteRegistry">
modal-id="confirm-image-deletion-modal"
ok-variant="danger"
@ok="handleDeleteRegistry"
>
<template v-slot:modal-title>{{ s__('ContainerRegistry|Remove image') }}</template> <template v-slot:modal-title>{{ s__('ContainerRegistry|Remove image') }}</template>
<template v-slot:modal-ok>{{ s__('ContainerRegistry|Remove image and tags') }}</template> <template v-slot:modal-ok>{{ s__('ContainerRegistry|Remove image and tags') }}</template>
<p <p
......
---
title: Prevent multiple confirmation modals from opening when deleting a repository
merge_request: 30532
author:
type: fixed
...@@ -77,7 +77,7 @@ describe('collapsible registry container', () => { ...@@ -77,7 +77,7 @@ describe('collapsible registry container', () => {
spyOn(vm, 'deleteItem').and.returnValue(Promise.resolve()); spyOn(vm, 'deleteItem').and.returnValue(Promise.resolve());
Vue.nextTick(() => { Vue.nextTick(() => {
document.querySelector('#confirm-repo-deletion-modal .btn-danger').click(); document.querySelector(`#${vm.modalId} .btn-danger`).click();
expect(vm.deleteItem).toHaveBeenCalledWith(vm.repo); expect(vm.deleteItem).toHaveBeenCalledWith(vm.repo);
done(); done();
......
...@@ -51,7 +51,7 @@ describe('table registry', () => { ...@@ -51,7 +51,7 @@ describe('table registry', () => {
spyOn(vm, 'deleteItem').and.returnValue(Promise.resolve()); spyOn(vm, 'deleteItem').and.returnValue(Promise.resolve());
Vue.nextTick(() => { Vue.nextTick(() => {
document.querySelector('#confirm-image-deletion-modal .btn-danger').click(); document.querySelector(`#${vm.modalId} .btn-danger`).click();
expect(vm.deleteItem).toHaveBeenCalledWith(firstImage); expect(vm.deleteItem).toHaveBeenCalledWith(firstImage);
expect(vm.itemToBeDeleted).toBeNull(); expect(vm.itemToBeDeleted).toBeNull();
......
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