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>
(cherry picked from commit 1dc7f5338623ec97d9ea395380270470847a0066)
This commit is contained in:
Yarden Shoham 2024-03-09 13:59:16 +02:00 committed by Earl Warren
parent 38c3cc4eb7
commit 249e26fdae
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00

View file

@ -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 () {