Skip to content

Commit 1dc7f53

Browse files
Fix WebHookEditor regression from jQuery removal (#29692)
Make these calls optional --------- Signed-off-by: Yarden Shoham <[email protected]> Co-authored-by: wxiaoguang <[email protected]>
1 parent 7fdc048 commit 1dc7f53

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

web_src/js/features/comp/WebHookEditor.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@ export function initCompWebHookEditor() {
2222
});
2323
}
2424

25-
const updateContentType = function () {
26-
const visible = document.getElementById('http_method').value === 'POST';
27-
toggleElem(document.getElementById('content_type').parentNode.parentNode, visible);
28-
};
29-
updateContentType();
30-
31-
document.getElementById('http_method').addEventListener('change', updateContentType);
25+
// some webhooks (like Gitea) allow to set the request method (GET/POST), and it would toggle the "Content Type" field
26+
const httpMethodInput = document.getElementById('http_method');
27+
if (httpMethodInput) {
28+
const updateContentType = function () {
29+
const visible = httpMethodInput.value === 'POST';
30+
toggleElem(document.getElementById('content_type').closest('.field'), visible);
31+
};
32+
updateContentType();
33+
httpMethodInput.addEventListener('change', updateContentType);
34+
}
3235

3336
// Test delivery
3437
document.getElementById('test-delivery')?.addEventListener('click', async function () {

0 commit comments

Comments
 (0)