Skip to content

Commit 7ca7590

Browse files
authored
Fix duplicate modals when clicking on "remove all" repository button (#24129)
Under Team tab of an organization, click on "remove all" repositories button will trigger two modals. Because `data-modal-id` is not proerly added. Before: https://user-images.githubusercontent.com/17645053/231988545-ac690b86-e3fe-4bf5-81c6-5ef09302e849.mov After: https://user-images.githubusercontent.com/17645053/231989678-53be4f91-fdc9-4bc5-ba11-a08aa4548e37.mov
1 parent 2002584 commit 7ca7590

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

templates/org/team/repositories.tmpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
</div>
2626
<div class="inline ui field right">
2727
<form class="ui form" id="repo-multiple-form" action="{{$.OrgLink}}/teams/{{$.Team.LowerName | PathEscape}}/repositories" method="post">
28-
<button class="ui red button delete-button right" data-url="{{$.OrgLink}}/teams/{{$.Team.LowerName | PathEscape}}/action/repo/removeall">{{.locale.Tr "remove_all"}}</button>
29-
<button class="ui green button add-all-button right" data-url="{{$.OrgLink}}/teams/{{$.Team.LowerName | PathEscape}}/action/repo/addall">{{.locale.Tr "add_all"}}</button>
28+
<button class="ui red button delete-button right" data-modal-id="org-team-remove-all-repo" data-url="{{$.OrgLink}}/teams/{{$.Team.LowerName | PathEscape}}/action/repo/removeall">{{.locale.Tr "remove_all"}}</button>
29+
<button class="ui green button add-all-button right" data-modal-id="org-team-add-all-repo" data-url="{{$.OrgLink}}/teams/{{$.Team.LowerName | PathEscape}}/action/repo/addall">{{.locale.Tr "add_all"}}</button>
3030
</form>
3131
</div>
3232
</div>
@@ -64,7 +64,7 @@
6464
</div>
6565
</div>
6666

67-
<div class="ui small basic delete modal">
67+
<div class="ui small basic delete modal" id="org-team-remove-all-repo">
6868
<div class="ui icon header">
6969
{{svg "octicon-trash"}}
7070
{{.locale.Tr "org.teams.remove_all_repos_title"}}
@@ -75,7 +75,7 @@
7575
{{template "base/delete_modal_actions" .}}
7676
</div>
7777

78-
<div class="ui small basic addall modal">
78+
<div class="ui small basic addall modal" id="org-team-add-all-repo">
7979
<div class="ui icon header">
8080
{{svg "octicon-globe"}}
8181
{{.locale.Tr "org.teams.add_all_repos_title"}}

web_src/js/features/common-global.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ export function initGlobalLinkActions() {
194194
const $this = $(this);
195195
const dataArray = $this.data();
196196
let filter = '';
197-
if ($this.data('modal-id')) {
198-
filter += `#${$this.data('modal-id')}`;
197+
if ($this.attr('data-modal-id')) {
198+
filter += `#${$this.attr('data-modal-id')}`;
199199
}
200200

201201
const dialog = $(`.delete.modal${filter}`);
@@ -237,8 +237,8 @@ export function initGlobalLinkActions() {
237237
e.preventDefault();
238238
const $this = $(this);
239239
let filter = '';
240-
if ($this.attr('id')) {
241-
filter += `#${$this.attr('id')}`;
240+
if ($this.attr('data-modal-id')) {
241+
filter += `#${$this.attr('data-modal-id')}`;
242242
}
243243

244244
const dialog = $(`.addall.modal${filter}`);

0 commit comments

Comments
 (0)