From 4d900c3b55b41c12a6af189dbed4e834bbab7ce5 Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Mon, 11 Mar 2024 20:34:38 +0000 Subject: [PATCH] Remove jQuery AJAX from the issue branch selection - Removed a single jQuery AJAX instance - Tested the issue branch reference selection and it works as before Signed-off-by: Yarden Shoham --- web_src/js/features/repo-legacy.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/web_src/js/features/repo-legacy.js b/web_src/js/features/repo-legacy.js index 8fcc78c177c6c..60950fd1717c6 100644 --- a/web_src/js/features/repo-legacy.js +++ b/web_src/js/features/repo-legacy.js @@ -24,6 +24,7 @@ import {initRepoPullRequestCommitStatus} from './repo-issue-pr-status.js'; import {hideElem, showElem} from '../utils/dom.js'; import {getComboMarkdownEditor, initComboMarkdownEditor} from './comp/ComboMarkdownEditor.js'; import {attachRefIssueContextPopup} from './contextpopup.js'; +import {POST} from '../modules/fetch.js'; const {csrfToken} = window.config; @@ -65,7 +66,7 @@ export function initRepoCommentForm() { const $selectBranch = $('.ui.select-branch'); const $branchMenu = $selectBranch.find('.reference-list-menu'); const $isNewIssue = $branchMenu.hasClass('new-issue'); - $branchMenu.find('.item:not(.no-select)').on('click', function () { + $branchMenu.find('.item:not(.no-select)').on('click', async function () { const selectedValue = $(this).data('id'); const editMode = $('#editing_mode').val(); $($(this).data('id-selector')).val(selectedValue); @@ -76,7 +77,14 @@ export function initRepoCommentForm() { if (editMode === 'true') { const form = $('#update_issueref_form'); - $.post(form.attr('action'), {_csrf: csrfToken, ref: selectedValue}, () => window.location.reload()); + const params = new URLSearchParams(); + params.append('ref', selectedValue); + try { + await POST(form.attr('action'), {data: params}); + window.location.reload(); + } catch (error) { + console.error('Error:', error); + } } else if (editMode === '') { $selectBranch.find('.ui .branch-name').text(selectedValue); }