Skip to content

Commit 75a9f61

Browse files
authored
Remove jQuery AJAX from the issue branch reference selection (#29722)
- Replaced a single jQuery AJAX instance with our fetch wrapper - Tested the issue branch reference selection and it works as before # Demo using `fetch` instead of jQuery AJAX ![demo](https://github.com/go-gitea/gitea/assets/20454870/7e195632-41f8-494b-b599-f6291860f330) Signed-off-by: Yarden Shoham <[email protected]>
1 parent e84e5db commit 75a9f61

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

web_src/js/features/repo-legacy.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {initRepoPullRequestCommitStatus} from './repo-issue-pr-status.js';
2424
import {hideElem, showElem} from '../utils/dom.js';
2525
import {getComboMarkdownEditor, initComboMarkdownEditor} from './comp/ComboMarkdownEditor.js';
2626
import {attachRefIssueContextPopup} from './contextpopup.js';
27+
import {POST} from '../modules/fetch.js';
2728

2829
const {csrfToken} = window.config;
2930

@@ -65,7 +66,7 @@ export function initRepoCommentForm() {
6566
const $selectBranch = $('.ui.select-branch');
6667
const $branchMenu = $selectBranch.find('.reference-list-menu');
6768
const $isNewIssue = $branchMenu.hasClass('new-issue');
68-
$branchMenu.find('.item:not(.no-select)').on('click', function () {
69+
$branchMenu.find('.item:not(.no-select)').on('click', async function () {
6970
const selectedValue = $(this).data('id');
7071
const editMode = $('#editing_mode').val();
7172
$($(this).data('id-selector')).val(selectedValue);
@@ -76,7 +77,14 @@ export function initRepoCommentForm() {
7677

7778
if (editMode === 'true') {
7879
const form = $('#update_issueref_form');
79-
$.post(form.attr('action'), {_csrf: csrfToken, ref: selectedValue}, () => window.location.reload());
80+
const params = new URLSearchParams();
81+
params.append('ref', selectedValue);
82+
try {
83+
await POST(form.attr('action'), {data: params});
84+
window.location.reload();
85+
} catch (error) {
86+
console.error('Error:', error);
87+
}
8088
} else if (editMode === '') {
8189
$selectBranch.find('.ui .branch-name').text(selectedValue);
8290
}

0 commit comments

Comments
 (0)