mirror of
https://github.com/go-gitea/gitea.git
synced 2026-06-21 23:17:38 +02:00
proper style
This commit is contained in:
parent
5a7a5511d6
commit
babd3da49b
@ -1123,7 +1123,8 @@
|
||||
"repo.migrate.ssh_helper_desc": "Upload your SSH mirror keys to the remote SSH server for authentication.",
|
||||
"repo.migrate.ssh_helper_link": "View your SSH keys (if migrating to an organization, you may need to upload the organization's SSH keys).",
|
||||
"repo.migrate.ssh_key_owner_label": "Authenticate with",
|
||||
"repo.migrate.ssh_key_owner_repo_default": "Repository owner's managed SSH key (default)",
|
||||
"repo.migrate.ssh_key_owner_org_default": "This organization's managed SSH key (default)",
|
||||
"repo.migrate.ssh_key_owner_personal": "Your personal managed SSH key (%s)",
|
||||
"repo.migrate.permission_denied": "You are not allowed to import local repositories.",
|
||||
"repo.migrate.permission_denied_blocked": "You cannot import from disallowed hosts. Please ask the admin to check ALLOWED_DOMAINS/ALLOW_LOCALNETWORKS/BLOCKED_DOMAINS settings.",
|
||||
"repo.migrate.invalid_local_path": "The local path is invalid. It doesn't exist or is not a directory.",
|
||||
|
||||
@ -30,12 +30,17 @@
|
||||
<label for="auth_password">{{ctx.Locale.Tr "password"}}</label>
|
||||
<input id="auth_password" name="auth_password" type="password" value="{{.auth_password}}">
|
||||
</div>
|
||||
<div class="inline field ssh-key-owner-selector tw-hidden" data-signed-user-id="{{.SignedUser.ID}}" data-signed-user-name="{{.SignedUser.Name}}">
|
||||
<label for="ssh_key_owner_select">{{ctx.Locale.Tr "repo.migrate.ssh_key_owner_label"}}</label>
|
||||
<select id="ssh_key_owner_select" name="ssh_key_owner_id_select">
|
||||
<option value="0">{{ctx.Locale.Tr "repo.migrate.ssh_key_owner_repo_default"}}</option>
|
||||
</select>
|
||||
<input id="ssh_key_owner_id" name="ssh_key_owner_id" type="hidden" value="0">
|
||||
<div class="inline field ssh-key-owner-selector tw-hidden" data-signed-user-id="{{.SignedUser.ID}}">
|
||||
<label>{{ctx.Locale.Tr "repo.migrate.ssh_key_owner_label"}}</label>
|
||||
<div class="ui selection dropdown">
|
||||
<input id="ssh_key_owner_id" name="ssh_key_owner_id" type="hidden" value="0">
|
||||
<div class="default text">{{ctx.Locale.Tr "repo.migrate.ssh_key_owner_org_default"}}</div>
|
||||
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
|
||||
<div class="menu">
|
||||
<div class="item" data-value="0">{{ctx.Locale.Tr "repo.migrate.ssh_key_owner_org_default"}}</div>
|
||||
<div class="item" data-value="{{.SignedUser.ID}}">{{ctx.Locale.Tr "repo.migrate.ssh_key_owner_personal" .SignedUser.Name}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{template "repo/migrate/options" .}}
|
||||
|
||||
@ -109,21 +109,11 @@ export function initRepoMigrationForm() {
|
||||
// managed key. The hidden #ssh_key_owner_id field is submitted with the form.
|
||||
function initSSHKeyOwnerSelector(cloneAddrInput: HTMLInputElement) {
|
||||
const container = document.querySelector<HTMLElement>('.ssh-key-owner-selector');
|
||||
const select = document.querySelector<HTMLSelectElement>('#ssh_key_owner_select');
|
||||
const hiddenId = document.querySelector<HTMLInputElement>('#ssh_key_owner_id');
|
||||
const uidInput = document.querySelector<HTMLInputElement>('#uid');
|
||||
if (!container || !select || !hiddenId || !uidInput) return;
|
||||
if (!container || !hiddenId || !uidInput) return;
|
||||
|
||||
const signedUserID = container.getAttribute('data-signed-user-id') ?? '';
|
||||
const signedUserName = container.getAttribute('data-signed-user-name') ?? '';
|
||||
|
||||
// Build {ownerID -> name} from the owner dropdown menu items
|
||||
const ownerNameById = new Map<string, string>();
|
||||
for (const item of document.querySelectorAll<HTMLElement>('.owner.dropdown .menu .item')) {
|
||||
const id = item.getAttribute('data-value');
|
||||
const name = item.getAttribute('title') ?? item.textContent?.trim() ?? '';
|
||||
if (id) ownerNameById.set(id, name);
|
||||
}
|
||||
|
||||
function update() {
|
||||
const isSSH = isSSHURL(cloneAddrInput.value.trim());
|
||||
@ -136,20 +126,10 @@ function initSSHKeyOwnerSelector(cloneAddrInput: HTMLInputElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Target is an organisation — offer both keys
|
||||
const orgName = ownerNameById.get(targetUid) ?? `#${targetUid}`;
|
||||
select!.innerHTML = '';
|
||||
select!.add(new Option(`Use ${orgName}'s managed SSH key (default)`, '0'));
|
||||
select!.add(new Option(`Use your personal managed SSH key (${signedUserName})`, signedUserID));
|
||||
select!.value = hiddenId!.value || '0';
|
||||
hiddenId!.value = select!.value;
|
||||
// Target is an organisation — show selector (Fomantic dropdown wires the hidden input itself)
|
||||
showElem(container!);
|
||||
}
|
||||
|
||||
select.addEventListener('change', () => {
|
||||
hiddenId.value = select.value;
|
||||
});
|
||||
|
||||
// Semantic UI updates the #uid hidden input via menu item clicks
|
||||
for (const item of document.querySelectorAll<HTMLElement>('.owner.dropdown .menu .item')) {
|
||||
item.addEventListener('click', () => setTimeout(update, 0));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user