File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff 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 ( ) {
You can’t perform that action at this time.
0 commit comments