File tree 1 file changed +10
-7
lines changed 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -22,13 +22,16 @@ export function initCompWebHookEditor() {
22
22
} ) ;
23
23
}
24
24
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
+ }
32
35
33
36
// Test delivery
34
37
document . getElementById ( 'test-delivery' ) ?. addEventListener ( 'click' , async function ( ) {
You can’t perform that action at this time.
0 commit comments