Add fetch wrappers, ignore network errors in actions view (#26985)

1. Introduce lightweight `fetch` wrapper functions that automatically
sets csfr token, content-type and use it in `RepoActionView.vue`.
2. Fix a specific issue on `RepoActionView.vue` where a fetch network
error is shortly visible during page reload sometimes. It can be
reproduced by F5-in in quick succession on the actions view page and was
also producing a red error box on the page.

Once approved, we can replace all current `fetch` uses in UI with this
in another PR.

---------

Co-authored-by: Giteabot <teabot@gitea.io>
This commit is contained in:
silverwind 2023-09-11 10:25:10 +02:00 committed by GitHub
parent 148c9c4b05
commit 6d96f0b0d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 79 additions and 28 deletions

View file

@ -0,0 +1,11 @@
import {test, expect} from 'vitest';
import {GET, POST, PATCH, PUT, DELETE} from './fetch.js';
// tests here are only to satisfy the linter for unused functions
test('exports', () => {
expect(GET).toBeTruthy();
expect(POST).toBeTruthy();
expect(PATCH).toBeTruthy();
expect(PUT).toBeTruthy();
expect(DELETE).toBeTruthy();
});