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   --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
907bedaad0
commit
865d2221c0
6 changed files with 57 additions and 4 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue