summaryrefslogtreecommitdiffstats
path: root/web_src/js
diff options
context:
space:
mode:
authorKerwin Bryant <kerwin612@qq.com>2023-08-04 10:21:32 +0800
committerGitHub <noreply@github.com>2023-08-04 10:21:32 +0800
commit865d2221c0f4b2a8623ff9299930c9bab0da2c78 (patch)
treed399ccbbee5a91be67f9d955e1f2845c9341cf76 /web_src/js
parent907bedaad0301730ee2fbab1f18b54b155dad088 (diff)
downloadgitea-865d2221c0f4b2a8623ff9299930c9bab0da2c78.tar.gz
gitea-865d2221c0f4b2a8623ff9299930c9bab0da2c78.zip
Add `Retry` button when creating a mirror-repo fails (#26228)
fixed #26156 * Added a retry button in the frontend (only displayed when the status is abnormal) * After clicking Retry, the backend adds the task back to the task queue ![7UJDNM671RI})EA8~~XPL39](https://github.com/go-gitea/gitea/assets/3371163/e088fd63-5dcc-4bc6-8849-7db3086511b7) ![T83F1WL9)VGHR@MB956$VT9](https://github.com/go-gitea/gitea/assets/3371163/744425bb-dde1-4315-be2e-5c99ac3a44d4) --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'web_src/js')
-rw-r--r--web_src/js/features/repo-migrate.js16
1 files changed, 15 insertions, 1 deletions
diff --git a/web_src/js/features/repo-migrate.js b/web_src/js/features/repo-migrate.js
index e57348d31b..de9f7b023c 100644
--- a/web_src/js/features/repo-migrate.js
+++ b/web_src/js/features/repo-migrate.js
@@ -1,12 +1,14 @@
import $ from 'jquery';
import {hideElem, showElem} from '../utils/dom.js';
-const {appSubUrl} = window.config;
+const {appSubUrl, csrfToken} = window.config;
export function initRepoMigrationStatusChecker() {
const $repoMigrating = $('#repo_migrating');
if (!$repoMigrating.length) return;
+ $('#repo_migrating_retry').on('click', doMigrationRetry);
+
const task = $repoMigrating.attr('data-migrating-task-id');
// returns true if the refresh still need to be called after a while
@@ -31,6 +33,7 @@ export function initRepoMigrationStatusChecker() {
if (data.status === 3) {
hideElem('#repo_migrating_progress');
hideElem('#repo_migrating');
+ showElem('#repo_migrating_retry');
showElem('#repo_migrating_failed');
showElem('#repo_migrating_failed_image');
$('#repo_migrating_failed_error').text(data.message);
@@ -53,3 +56,14 @@ export function initRepoMigrationStatusChecker() {
syncTaskStatus(); // no await
}
+
+async function doMigrationRetry(e) {
+ await fetch($(e.target).attr('data-migrating-task-retry-url'), {
+ method: 'post',
+ headers: {
+ 'X-Csrf-Token': csrfToken,
+ 'Content-Type': 'application/json',
+ },
+ });
+ window.location.reload();
+}