mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-04 13:28:25 +00:00 
			
		
		
		
	Use fetch helpers instead of fetch (#27026)
WIP because: - [x] Some calls set a `content-type` but send no body, can likely remove the header - [x] Need to check whether `charset=utf-8` has any significance on the webauthn calls, I assume not as it is the default for json content. - [x] Maybe `no-restricted-globals` is better for eslint, but will require a lot of duplication in the yaml or moving eslint config to a `.js` extension. - [x] Maybe export `request` as `fetch`, shadowing the global.
This commit is contained in:
		@@ -5,6 +5,7 @@ import {htmlEscape} from 'escape-goat';
 | 
			
		||||
import {confirmModal} from './comp/ConfirmModal.js';
 | 
			
		||||
import {showErrorToast} from '../modules/toast.js';
 | 
			
		||||
import {createSortable} from '../modules/sortable.js';
 | 
			
		||||
import {DELETE, POST} from '../modules/fetch.js';
 | 
			
		||||
 | 
			
		||||
function initRepoIssueListCheckboxes() {
 | 
			
		||||
  const $issueSelectAll = $('.issue-checkbox-all');
 | 
			
		||||
@@ -146,13 +147,7 @@ function initPinRemoveButton() {
 | 
			
		||||
      const id = Number(el.getAttribute('data-issue-id'));
 | 
			
		||||
 | 
			
		||||
      // Send the unpin request
 | 
			
		||||
      const response = await fetch(el.getAttribute('data-unpin-url'), {
 | 
			
		||||
        method: 'delete',
 | 
			
		||||
        headers: {
 | 
			
		||||
          'X-Csrf-Token': window.config.csrfToken,
 | 
			
		||||
          'Content-Type': 'application/json',
 | 
			
		||||
        },
 | 
			
		||||
      });
 | 
			
		||||
      const response = await DELETE(el.getAttribute('data-unpin-url'));
 | 
			
		||||
      if (response.ok) {
 | 
			
		||||
        // Delete the tooltip
 | 
			
		||||
        el._tippy.destroy();
 | 
			
		||||
@@ -166,14 +161,7 @@ function initPinRemoveButton() {
 | 
			
		||||
async function pinMoveEnd(e) {
 | 
			
		||||
  const url = e.item.getAttribute('data-move-url');
 | 
			
		||||
  const id = Number(e.item.getAttribute('data-issue-id'));
 | 
			
		||||
  await fetch(url, {
 | 
			
		||||
    method: 'post',
 | 
			
		||||
    body: JSON.stringify({id, position: e.newIndex + 1}),
 | 
			
		||||
    headers: {
 | 
			
		||||
      'X-Csrf-Token': window.config.csrfToken,
 | 
			
		||||
      'Content-Type': 'application/json',
 | 
			
		||||
    },
 | 
			
		||||
  });
 | 
			
		||||
  await POST(url, {data: {id, position: e.newIndex + 1}});
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
async function initIssuePinSort() {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user