From 4af858f844f12c58a585cdf295efa58297505baf Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Sat, 9 Mar 2024 11:36:04 +0000 Subject: [PATCH 1/3] Fix WebHookEditor regression from jQuery removal Make these calls optional Signed-off-by: Yarden Shoham --- web_src/js/features/comp/WebHookEditor.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web_src/js/features/comp/WebHookEditor.js b/web_src/js/features/comp/WebHookEditor.js index 86d21dc8152b1..65d030caad67a 100644 --- a/web_src/js/features/comp/WebHookEditor.js +++ b/web_src/js/features/comp/WebHookEditor.js @@ -23,12 +23,12 @@ export function initCompWebHookEditor() { } const updateContentType = function () { - const visible = document.getElementById('http_method').value === 'POST'; - toggleElem(document.getElementById('content_type').parentNode.parentNode, visible); + const visible = document.getElementById('http_method')?.value === 'POST'; + toggleElem(document.getElementById('content_type')?.parentNode.parentNode, visible); }; updateContentType(); - document.getElementById('http_method').addEventListener('change', updateContentType); + document.getElementById('http_method')?.addEventListener('change', updateContentType); // Test delivery document.getElementById('test-delivery')?.addEventListener('click', async function () { From 4d1ffdaef16e52fa21c35eb3315e14e92023ab1e Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Sat, 9 Mar 2024 11:45:32 +0000 Subject: [PATCH 2/3] Reorder per review comment Signed-off-by: Yarden Shoham --- web_src/js/features/comp/WebHookEditor.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/web_src/js/features/comp/WebHookEditor.js b/web_src/js/features/comp/WebHookEditor.js index 65d030caad67a..a3dca03caae96 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(); + const httpMethodInput = document.getElementById('http_method'); + if (httpMethodInput) { + const updateContentType = function () { + const visible = httpMethodInput.value === 'POST'; + toggleElem(document.getElementById('content_type')?.parentNode.parentNode, visible); + }; + updateContentType(); - document.getElementById('http_method')?.addEventListener('change', updateContentType); + httpMethodInput.addEventListener('change', updateContentType); + } // Test delivery document.getElementById('test-delivery')?.addEventListener('click', async function () { From 86f07a5d3f09a6089e6eca0a9edf3dc98d5d2c3e Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Sat, 9 Mar 2024 19:53:45 +0800 Subject: [PATCH 3/3] add comment --- web_src/js/features/comp/WebHookEditor.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web_src/js/features/comp/WebHookEditor.js b/web_src/js/features/comp/WebHookEditor.js index a3dca03caae96..b7ca5a0fcf345 100644 --- a/web_src/js/features/comp/WebHookEditor.js +++ b/web_src/js/features/comp/WebHookEditor.js @@ -22,14 +22,14 @@ export function initCompWebHookEditor() { }); } + // 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')?.parentNode.parentNode, visible); + toggleElem(document.getElementById('content_type').closest('.field'), visible); }; updateContentType(); - httpMethodInput.addEventListener('change', updateContentType); }