From 6adb632eac5deda490940f1eda82a5ed3f1b3589 Mon Sep 17 00:00:00 2001
From: a1012112796 <1012112796@qq.com>
Date: Tue, 15 Jun 2021 11:59:48 +0800
Subject: [PATCH 1/5] prevent double click new issue/pull/comment button
when network is not good, these button maybe
double clicked, then more than one same issues
pulls or comments will be created. this pull
request will fix this bug.
Signed-off-by: a1012112796 <1012112796@qq.com>
---
templates/repo/issue/new_form.tmpl | 2 +-
templates/repo/issue/view_content.tmpl | 4 ++--
web_src/js/index.js | 11 +++++++++++
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/templates/repo/issue/new_form.tmpl b/templates/repo/issue/new_form.tmpl
index f208416261c6a..e54add8f1f525 100644
--- a/templates/repo/issue/new_form.tmpl
+++ b/templates/repo/issue/new_form.tmpl
@@ -20,7 +20,7 @@
{{template "repo/issue/comment_tab" .}}
-
{{end}}
{{end}}
-
+
{{.i18n.Tr "repo.issues.create_comment"}}
@@ -159,7 +159,7 @@
{{end}}
{{end}}
-
+
{{.i18n.Tr "repo.issues.create_comment"}}
diff --git a/web_src/js/index.js b/web_src/js/index.js
index e42a6640151ab..eb92ca7fbb9a1 100644
--- a/web_src/js/index.js
+++ b/web_src/js/index.js
@@ -3959,3 +3959,14 @@ $(document).on('click', '.oauth-login-image', () => {
oauthNav.show();
}, 5000);
});
+
+// once-button is the button which can be clicked only one time
+$(document).on('click', '.button.once-button', function () {
+ const $btn = $(this);
+ $btn.addClass('loading clicked');
+});
+
+$(document).on('click', '.button.once-button.clicked', (e) => {
+ e.preventDefault();
+ return false;
+});
From f68a50f0ddd9a51c50877ca0a5e832e34e4db1a1 Mon Sep 17 00:00:00 2001
From: a1012112796 <1012112796@qq.com>
Date: Tue, 15 Jun 2021 21:49:42 +0800
Subject: [PATCH 2/5] Apply suggestions from code review
Co-authored-by: silverwind
---
web_src/js/index.js | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/web_src/js/index.js b/web_src/js/index.js
index eb92ca7fbb9a1..4c42ec24a0633 100644
--- a/web_src/js/index.js
+++ b/web_src/js/index.js
@@ -3963,10 +3963,9 @@ $(document).on('click', '.oauth-login-image', () => {
// once-button is the button which can be clicked only one time
$(document).on('click', '.button.once-button', function () {
const $btn = $(this);
- $btn.addClass('loading clicked');
+ $btn.addClass('loading');
});
-$(document).on('click', '.button.once-button.clicked', (e) => {
+$(document).on('click', '.button.once-button.loading', (e) => {
e.preventDefault();
- return false;
});
From b12a87efb044befe629b5911fbdff6c825bd79f0 Mon Sep 17 00:00:00 2001
From: a1012112796 <1012112796@qq.com>
Date: Tue, 15 Jun 2021 22:23:26 +0800
Subject: [PATCH 3/5] rename and comment
---
templates/repo/issue/new_form.tmpl | 2 +-
templates/repo/issue/view_content.tmpl | 4 ++--
web_src/js/index.js | 6 +++---
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/templates/repo/issue/new_form.tmpl b/templates/repo/issue/new_form.tmpl
index e54add8f1f525..ab49c74db34c8 100644
--- a/templates/repo/issue/new_form.tmpl
+++ b/templates/repo/issue/new_form.tmpl
@@ -20,7 +20,7 @@
{{template "repo/issue/comment_tab" .}}
-
+
{{if .PageIsComparePull}}
{{.i18n.Tr "repo.pulls.create"}}
{{else}}
diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl
index f4331ac9a36ee..bf1b9f4e0e13d 100644
--- a/templates/repo/issue/view_content.tmpl
+++ b/templates/repo/issue/view_content.tmpl
@@ -108,7 +108,7 @@
{{end}}
{{end}}
-
+
{{.i18n.Tr "repo.issues.create_comment"}}
@@ -159,7 +159,7 @@
{{end}}
{{end}}
-
+
{{.i18n.Tr "repo.issues.create_comment"}}
diff --git a/web_src/js/index.js b/web_src/js/index.js
index 4c42ec24a0633..6ed5a36e618a1 100644
--- a/web_src/js/index.js
+++ b/web_src/js/index.js
@@ -3960,12 +3960,12 @@ $(document).on('click', '.oauth-login-image', () => {
}, 5000);
});
-// once-button is the button which can be clicked only one time
-$(document).on('click', '.button.once-button', function () {
+// loading-button this logic used to prevent push one form more than one time
+$(document).on('click', '.button.loading-button', function () {
const $btn = $(this);
$btn.addClass('loading');
});
-$(document).on('click', '.button.once-button.loading', (e) => {
+$(document).on('click', '.button.loading-button.loading', (e) => {
e.preventDefault();
});
From da2252101c4591847d7972399049967a81f71b29 Mon Sep 17 00:00:00 2001
From: a1012112796 <1012112796@qq.com>
Date: Thu, 5 May 2022 11:00:14 +0000
Subject: [PATCH 4/5] apply suggeston from code review @lafriks
Signed-off-by: a1012112796 <1012112796@qq.com>
---
web_src/js/features/common-global.js | 9 +++++++++
web_src/js/index.js | 10 ----------
2 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/web_src/js/features/common-global.js b/web_src/js/features/common-global.js
index dda803ae8de31..6b18249cf3e72 100644
--- a/web_src/js/features/common-global.js
+++ b/web_src/js/features/common-global.js
@@ -142,6 +142,15 @@ export function initGlobalCommon() {
window.location = href;
}
});
+
+ // loading-button this logic used to prevent push one form more than one time
+ $(document).on('click', '.button.loading-button', function () {
+ const $btn = $(this);
+
+ if ($btn.hasClass('loading')) return false;
+
+ $btn.addClass('loading disabled');
+ });
}
export function initGlobalDropzone() {
diff --git a/web_src/js/index.js b/web_src/js/index.js
index 02bd229376d63..5b95a0d8efa88 100644
--- a/web_src/js/index.js
+++ b/web_src/js/index.js
@@ -181,13 +181,3 @@ $(document).ready(() => {
checkAppUrl();
});
-
-// loading-button this logic used to prevent push one form more than one time
-$(document).on('click', '.button.loading-button', function () {
- const $btn = $(this);
- $btn.addClass('loading');
-});
-
-$(document).on('click', '.button.loading-button.loading', (e) => {
- e.preventDefault();
-});
From 9fd3b094b4846cac5037f196da37e04088b39065 Mon Sep 17 00:00:00 2001
From: a1012112796 <1012112796@qq.com>
Date: Fri, 6 May 2022 14:41:15 +0000
Subject: [PATCH 5/5] preventDefault
Signed-off-by: a1012112796 <1012112796@qq.com>
---
web_src/js/features/common-global.js | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/web_src/js/features/common-global.js b/web_src/js/features/common-global.js
index 6b18249cf3e72..eb21a4bb9313a 100644
--- a/web_src/js/features/common-global.js
+++ b/web_src/js/features/common-global.js
@@ -144,10 +144,13 @@ export function initGlobalCommon() {
});
// loading-button this logic used to prevent push one form more than one time
- $(document).on('click', '.button.loading-button', function () {
+ $(document).on('click', '.button.loading-button', function (e) {
const $btn = $(this);
- if ($btn.hasClass('loading')) return false;
+ if ($btn.hasClass('loading')) {
+ e.preventDefault();
+ return false;
+ }
$btn.addClass('loading disabled');
});