mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Git migration UX (#12619)
* Initial work Signed-off-by: jolheiser <john.olheiser@gmail.com> * Implementation Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix gitlab and token cloning Signed-off-by: jolheiser <john.olheiser@gmail.com> * Imports and JS Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix test Signed-off-by: jolheiser <john.olheiser@gmail.com> * Linting Signed-off-by: jolheiser <john.olheiser@gmail.com> * Generate swagger Signed-off-by: jolheiser <john.olheiser@gmail.com> * Move mirror toggle and rename options Signed-off-by: jolheiser <john.olheiser@gmail.com> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
		
							
								
								
									
										53
									
								
								web_src/js/features/migration.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								web_src/js/features/migration.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,53 @@
 | 
			
		||||
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();
 | 
			
		||||
 | 
			
		||||
  $service.on('change', 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();
 | 
			
		||||
  const tokenAuth = $(`#service-${serviceType}`).data('token');
 | 
			
		||||
 | 
			
		||||
  if (tokenAuth) {
 | 
			
		||||
    $user.parent().addClass('disabled');
 | 
			
		||||
    $pass.parent().addClass('disabled');
 | 
			
		||||
    $token.parent().removeClass('disabled');
 | 
			
		||||
  } else {
 | 
			
		||||
    $user.parent().removeClass('disabled');
 | 
			
		||||
    $pass.parent().removeClass('disabled');
 | 
			
		||||
    $token.parent().addClass('disabled');
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  checkItems(tokenAuth);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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');
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user