mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-26 12:27:06 +00:00 
			
		
		
		
	Rearrange Clone Panel (#31142)
Rearrange the clone panel to use less horizontal space. The following changes have been made to achieve this: - Moved everything into the dropdown menu - Moved the HTTPS/SSH Switch to a separate line - Moved the "Clone in VS Code"-Button up and added a divider - Named the dropdown button "Code", added appropriate icon --------- Co-authored-by: techknowlogick <techknowlogick@gitea.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
		| @@ -1,17 +0,0 @@ | ||||
| import {toOriginUrl} from './origin-url.ts'; | ||||
|  | ||||
| test('toOriginUrl', () => { | ||||
|   const oldLocation = String(window.location); | ||||
|   for (const origin of ['https://example.com', 'https://example.com:3000']) { | ||||
|     window.location.assign(`${origin}/`); | ||||
|     expect(toOriginUrl('/')).toEqual(`${origin}/`); | ||||
|     expect(toOriginUrl('/org/repo.git')).toEqual(`${origin}/org/repo.git`); | ||||
|     expect(toOriginUrl('https://another.com')).toEqual(`${origin}/`); | ||||
|     expect(toOriginUrl('https://another.com/')).toEqual(`${origin}/`); | ||||
|     expect(toOriginUrl('https://another.com/org/repo.git')).toEqual(`${origin}/org/repo.git`); | ||||
|     expect(toOriginUrl('https://another.com:4000')).toEqual(`${origin}/`); | ||||
|     expect(toOriginUrl('https://another.com:4000/')).toEqual(`${origin}/`); | ||||
|     expect(toOriginUrl('https://another.com:4000/org/repo.git')).toEqual(`${origin}/org/repo.git`); | ||||
|   } | ||||
|   window.location.assign(oldLocation); | ||||
| }); | ||||
| @@ -1,19 +1,4 @@ | ||||
| // Convert an absolute or relative URL to an absolute URL with the current origin. It only | ||||
| // processes absolute HTTP/HTTPS URLs or relative URLs like '/xxx' or '//host/xxx'. | ||||
| // NOTE: Keep this function in sync with clone_script.tmpl | ||||
| export function toOriginUrl(urlStr: string) { | ||||
|   try { | ||||
|     if (urlStr.startsWith('http://') || urlStr.startsWith('https://') || urlStr.startsWith('/')) { | ||||
|       const {origin, protocol, hostname, port} = window.location; | ||||
|       const url = new URL(urlStr, origin); | ||||
|       url.protocol = protocol; | ||||
|       url.hostname = hostname; | ||||
|       url.port = port || (protocol === 'https:' ? '443' : '80'); | ||||
|       return url.toString(); | ||||
|     } | ||||
|   } catch {} | ||||
|   return urlStr; | ||||
| } | ||||
| import {toOriginUrl} from '../utils/url.ts'; | ||||
|  | ||||
| window.customElements.define('origin-url', class extends HTMLElement { | ||||
|   connectedCallback() { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Blender Defender
					Blender Defender