-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
WebHookEditor.js
43 lines (38 loc) · 1.06 KB
/
WebHookEditor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import $ from 'jquery';
import {hideElem, showElem, toggleElem} from '../../utils/dom.js';
const {csrfToken} = window.config;
export function initCompWebHookEditor() {
if ($('.new.webhook').length === 0) {
return;
}
$('.events.checkbox input').on('change', function () {
if ($(this).is(':checked')) {
showElem($('.events.fields'));
}
});
$('.non-events.checkbox input').on('change', function () {
if ($(this).is(':checked')) {
hideElem($('.events.fields'));
}
});
const updateContentType = function () {
const visible = $('#http_method').val() === 'POST';
toggleElem($('#content_type').parent().parent(), visible);
};
updateContentType();
$('#http_method').on('change', () => {
updateContentType();
});
// Test delivery
$('#test-delivery').on('click', function () {
const $this = $(this);
$this.addClass('loading disabled');
$.post($this.data('link'), {
_csrf: csrfToken
}).done(
setTimeout(() => {
window.location.href = $this.data('redirect');
}, 5000)
);
});
}