mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-26 13:29:12 -05:00
83d2b3b7fa
UX/Translation changes: - new teams: remove redundant tooltips that don't add meaningful information - move general information to table fieldset - new teams: rename "general" to "custom" access for clarity - new teams: show labels beside options on mobile Accessibility: - semantic form elements allow easier navigation (fieldset, mostly) - improve better labelling of new teams table - fix accessibility scan issues - TODO: the parts that "disable" form elements were not yet touched and are not really accessible to screenreaders Technical: - replace two JavaScript solutions with one CSS standard - implement a simpler grid (.simple-grid) - simplify markup - remove some webhook settings specific CSS Testing: - check more form content for accessibility issues - but exclude tooltips from the scan :( - reuse existing form tests from previous PR
28 lines
1 KiB
JavaScript
28 lines
1 KiB
JavaScript
import {POST} from '../../modules/fetch.js';
|
|
import {toggleElem} from '../../utils/dom.js';
|
|
|
|
export function initCompWebHookEditor() {
|
|
if (!document.querySelectorAll('.new.webhook').length) {
|
|
return;
|
|
}
|
|
|
|
// 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 () {
|
|
this.classList.add('is-loading', 'disabled');
|
|
await POST(this.getAttribute('data-link'));
|
|
setTimeout(() => {
|
|
window.location.href = this.getAttribute('data-redirect');
|
|
}, 5000);
|
|
});
|
|
}
|