aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js/features/comp/WebHookEditor.js
diff options
context:
space:
mode:
authorYarden Shoham <git@yardenshoham.com>2024-03-09 13:59:16 +0200
committerGitHub <noreply@github.com>2024-03-09 19:59:16 +0800
commit1dc7f5338623ec97d9ea395380270470847a0066 (patch)
treeab474626a2dbcb38820fc6d15c9214e1d8ba9c6e /web_src/js/features/comp/WebHookEditor.js
parent7fdc0481538151d8a5ed3ec2a32639950f5d8ac6 (diff)
downloadgitea-1dc7f5338623ec97d9ea395380270470847a0066.tar.gz
gitea-1dc7f5338623ec97d9ea395380270470847a0066.zip
Fix WebHookEditor regression from jQuery removal (#29692)
Make these calls optional --------- Signed-off-by: Yarden Shoham <git@yardenshoham.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'web_src/js/features/comp/WebHookEditor.js')
-rw-r--r--web_src/js/features/comp/WebHookEditor.js17
1 files changed, 10 insertions, 7 deletions
diff --git a/web_src/js/features/comp/WebHookEditor.js b/web_src/js/features/comp/WebHookEditor.js
index 86d21dc815..b7ca5a0fcf 100644
--- a/web_src/js/features/comp/WebHookEditor.js
+++ b/web_src/js/features/comp/WebHookEditor.js
@@ -22,13 +22,16 @@ export function initCompWebHookEditor() {
});
}
- const updateContentType = function () {
- const visible = document.getElementById('http_method').value === 'POST';
- toggleElem(document.getElementById('content_type').parentNode.parentNode, visible);
- };
- updateContentType();
-
- document.getElementById('http_method').addEventListener('change', updateContentType);
+ // some webhooks (like Gitea) allow to set the request method (GET/POST), and it would toggle the "Content Type" field
+ const httpMethodInput = document.getElementById('http_method');
+ if (httpMethodInput) {
+ const updateContentType = function () {
+ const visible = httpMethodInput.value === 'POST';
+ toggleElem(document.getElementById('content_type').closest('.field'), visible);
+ };
+ updateContentType();
+ httpMethodInput.addEventListener('change', updateContentType);
+ }
// Test delivery
document.getElementById('test-delivery')?.addEventListener('click', async function () {