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>
pull/29686/head^2
Yarden Shoham 8 months ago committed by GitHub
parent 7fdc048153
commit 1dc7f53386
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 17
      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 () {

Loading…
Cancel
Save