mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-24 08:57:03 -05:00
Merge pull request '[v7.0/forgejo] Fix an incorrect form submission in repo-issue.js' (#3677) from bp-v7.0/forgejo-f4dd53d into v7.0/forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3677 Reviewed-by: Gergely Nagy <algernon@noreply.codeberg.org>
This commit is contained in:
commit
283b678146
2 changed files with 8 additions and 7 deletions
1
release-notes/8.0.0/fix/3675.md
Normal file
1
release-notes/8.0.0/fix/3675.md
Normal file
|
@ -0,0 +1 @@
|
|||
Fixed an issue that rendered the "Allow edits from maintainers" checkbox disfunctional, preventing people from turning it on.
|
|
@ -284,23 +284,23 @@ export function initRepoPullRequestMergeInstruction() {
|
|||
export function initRepoPullRequestAllowMaintainerEdit() {
|
||||
const wrapper = document.getElementById('allow-edits-from-maintainers');
|
||||
if (!wrapper) return;
|
||||
|
||||
wrapper.querySelector('input[type="checkbox"]')?.addEventListener('change', async (e) => {
|
||||
const checked = e.target.checked;
|
||||
const checkbox = wrapper.querySelector('input[type="checkbox"]');
|
||||
checkbox.addEventListener('input', async () => {
|
||||
const url = `${wrapper.getAttribute('data-url')}/set_allow_maintainer_edit`;
|
||||
wrapper.classList.add('is-loading');
|
||||
e.target.disabled = true;
|
||||
try {
|
||||
const response = await POST(url, {data: {allow_maintainer_edit: checked}});
|
||||
if (!response.ok) {
|
||||
const resp = await POST(url, {data: new URLSearchParams({allow_maintainer_edit: checkbox.checked})});
|
||||
if (!resp.ok) {
|
||||
throw new Error('Failed to update maintainer edit permission');
|
||||
}
|
||||
const data = await resp.json();
|
||||
checkbox.checked = data.allow_maintainer_edit;
|
||||
} catch (error) {
|
||||
checkbox.checked = !checkbox.checked;
|
||||
console.error(error);
|
||||
showTemporaryTooltip(wrapper, wrapper.getAttribute('data-prompt-error'));
|
||||
} finally {
|
||||
wrapper.classList.remove('is-loading');
|
||||
e.target.disabled = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue