mirror of https://github.com/go-gitea/gitea
Git with a cup of tea, painless self-hosted git service
Mirror for internal git.with.parts use
https://git.with.parts
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
2.2 KiB
70 lines
2.2 KiB
5 months ago
|
import {hideElem, showElem, toggleElem} from '../utils/dom.ts';
|
||
3 years ago
|
|
||
6 months ago
|
const service = document.querySelector('#service_type');
|
||
|
const user = document.querySelector('#auth_username');
|
||
|
const pass = document.querySelector('#auth_password');
|
||
|
const token = document.querySelector('#auth_token');
|
||
|
const mirror = document.querySelector('#mirror');
|
||
|
const lfs = document.querySelector('#lfs');
|
||
|
const lfsSettings = document.querySelector('#lfs_settings');
|
||
|
const lfsEndpoint = document.querySelector('#lfs_endpoint');
|
||
9 months ago
|
const items = document.querySelectorAll('#migrate_items input[type=checkbox]');
|
||
4 years ago
|
|
||
2 years ago
|
export function initRepoMigration() {
|
||
4 years ago
|
checkAuth();
|
||
4 years ago
|
setLFSSettingsVisibility();
|
||
4 years ago
|
|
||
9 months ago
|
user?.addEventListener('input', () => {checkItems(false)});
|
||
|
pass?.addEventListener('input', () => {checkItems(false)});
|
||
|
token?.addEventListener('input', () => {checkItems(true)});
|
||
|
mirror?.addEventListener('change', () => {checkItems(true)});
|
||
6 months ago
|
document.querySelector('#lfs_settings_show')?.addEventListener('click', (e) => {
|
||
9 months ago
|
e.preventDefault();
|
||
|
e.stopPropagation();
|
||
|
showElem(lfsEndpoint);
|
||
|
});
|
||
|
lfs?.addEventListener('change', setLFSSettingsVisibility);
|
||
|
|
||
6 months ago
|
const cloneAddr = document.querySelector('#clone_addr');
|
||
9 months ago
|
cloneAddr?.addEventListener('change', () => {
|
||
6 months ago
|
const repoName = document.querySelector('#repo_name');
|
||
9 months ago
|
if (cloneAddr.value && !repoName?.value) { // Only modify if repo_name input is blank
|
||
|
repoName.value = cloneAddr.value.match(/^(.*\/)?((.+?)(\.git)?)$/)[3];
|
||
4 years ago
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function checkAuth() {
|
||
9 months ago
|
if (!service) return;
|
||
|
const serviceType = Number(service.value);
|
||
4 years ago
|
|
||
4 years ago
|
checkItems(serviceType !== 1);
|
||
4 years ago
|
}
|
||
|
|
||
|
function checkItems(tokenAuth) {
|
||
|
let enableItems;
|
||
|
if (tokenAuth) {
|
||
9 months ago
|
enableItems = token?.value !== '';
|
||
4 years ago
|
} else {
|
||
9 months ago
|
enableItems = user?.value !== '' || pass?.value !== '';
|
||
4 years ago
|
}
|
||
9 months ago
|
if (enableItems && Number(service?.value) > 1) {
|
||
|
if (mirror?.checked) {
|
||
|
for (const item of items) {
|
||
|
item.disabled = item.name !== 'wiki';
|
||
|
}
|
||
4 years ago
|
return;
|
||
|
}
|
||
9 months ago
|
for (const item of items) item.disabled = false;
|
||
4 years ago
|
} else {
|
||
9 months ago
|
for (const item of items) item.disabled = true;
|
||
4 years ago
|
}
|
||
|
}
|
||
4 years ago
|
|
||
|
function setLFSSettingsVisibility() {
|
||
9 months ago
|
if (!lfs) return;
|
||
|
const visible = lfs.checked;
|
||
|
toggleElem(lfsSettings, visible);
|
||
|
hideElem(lfsEndpoint);
|
||
4 years ago
|
}
|