forked from NYANDEV/forgejo
e153cf07c3
* Add a migrat service type switch page * Improve translations * remove images * Fix images * remove extra create repo button on dashboard * Follow reviewers' opinions * Fix frontend lint * Remove wrong submit file * Fix tests * Adjust the size of image * Apply suggestions from code review Co-authored-by: 赵智超 <1012112796@qq.com> * Remove username and password from migration of github/gitlab * Improve docs * Improve interface docs Co-authored-by: 赵智超 <1012112796@qq.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
const $service = $('#service_type');
|
|
const $user = $('#auth_username');
|
|
const $pass = $('#auth_password');
|
|
const $token = $('#auth_token');
|
|
const $items = $('#migrate_items').find('.field');
|
|
|
|
export default function initMigration() {
|
|
checkAuth();
|
|
|
|
$user.on('keyup', () => {checkItems(false)});
|
|
$pass.on('keyup', () => {checkItems(false)});
|
|
$token.on('keyup', () => {checkItems(true)});
|
|
|
|
const $cloneAddr = $('#clone_addr');
|
|
$cloneAddr.on('change', () => {
|
|
const $repoName = $('#repo_name');
|
|
if ($cloneAddr.val().length > 0 && $repoName.val().length === 0) { // Only modify if repo_name input is blank
|
|
$repoName.val($cloneAddr.val().match(/^(.*\/)?((.+?)(\.git)?)$/)[3]);
|
|
}
|
|
});
|
|
}
|
|
|
|
function checkAuth() {
|
|
const serviceType = $service.val();
|
|
|
|
checkItems(serviceType !== 1);
|
|
}
|
|
|
|
function checkItems(tokenAuth) {
|
|
let enableItems;
|
|
if (tokenAuth) {
|
|
enableItems = $token.val() !== '';
|
|
} else {
|
|
enableItems = $user.val() !== '' || $pass.val() !== '';
|
|
}
|
|
if (enableItems && $service.val() > 1) {
|
|
$items.removeClass('disabled');
|
|
} else {
|
|
$items.addClass('disabled');
|
|
}
|
|
}
|