mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-31 11:28:24 +00:00 
			
		
		
		
	1. `StatDir` was not right, fix the FIXME 2. Clarify the test cases for `IsUsableRepoName` 3. Fix regression bug in `repo-new.ts` Fix #33060
		
			
				
	
	
		
			36 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import {hideElem, showElem} from '../utils/dom.ts';
 | |
| 
 | |
| export function initRepoNew() {
 | |
|   const pageContent = document.querySelector('.page-content.repository.new-repo');
 | |
|   if (!pageContent) return;
 | |
| 
 | |
|   const form = document.querySelector('.new-repo-form');
 | |
|   const inputGitIgnores = form.querySelector<HTMLInputElement>('input[name="gitignores"]');
 | |
|   const inputLicense = form.querySelector<HTMLInputElement>('input[name="license"]');
 | |
|   const inputAutoInit = form.querySelector<HTMLInputElement>('input[name="auto_init"]');
 | |
|   const updateUiAutoInit = () => {
 | |
|     inputAutoInit.checked = Boolean(inputGitIgnores.value || inputLicense.value);
 | |
|   };
 | |
|   inputGitIgnores.addEventListener('change', updateUiAutoInit);
 | |
|   inputLicense.addEventListener('change', updateUiAutoInit);
 | |
|   updateUiAutoInit();
 | |
| 
 | |
|   const inputRepoName = form.querySelector<HTMLInputElement>('input[name="repo_name"]');
 | |
|   const inputPrivate = form.querySelector<HTMLInputElement>('input[name="private"]');
 | |
|   const updateUiRepoName = () => {
 | |
|     const helps = form.querySelectorAll(`.help[data-help-for-repo-name]`);
 | |
|     hideElem(helps);
 | |
|     let help = form.querySelector(`.help[data-help-for-repo-name="${CSS.escape(inputRepoName.value)}"]`);
 | |
|     if (!help) help = form.querySelector(`.help[data-help-for-repo-name=""]`);
 | |
|     showElem(help);
 | |
|     const repoNamePreferPrivate = {'.profile': false, '.profile-private': true};
 | |
|     const preferPrivate = repoNamePreferPrivate[inputRepoName.value];
 | |
|     // inputPrivate might be disabled because site admin "force private"
 | |
|     if (preferPrivate !== undefined && !inputPrivate.closest('.disabled, [disabled]')) {
 | |
|       inputPrivate.checked = preferPrivate;
 | |
|     }
 | |
|   };
 | |
|   inputRepoName.addEventListener('input', updateUiRepoName);
 | |
|   updateUiRepoName();
 | |
| }
 |