Skip to content

Commit

Permalink
Fix WebHookEditor regression from jQuery removal (#29692)
Browse files Browse the repository at this point in the history
Make these calls optional

---------

Signed-off-by: Yarden Shoham <git@yardenshoham.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
  • Loading branch information
yardenshoham and wxiaoguang authored Mar 9, 2024
1 parent 7fdc048 commit 1dc7f53
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions web_src/js/features/comp/WebHookEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit 1dc7f53

Please sign in to comment.