Merge branch 'forgejo' into upload_with_path_structure

This commit is contained in:
David Rotermund 2025-04-05 16:38:05 +00:00
commit 8073343f1d
2347 changed files with 22045 additions and 17196 deletions

View file

@ -175,7 +175,7 @@ export function initAdminCommon() {
onUsePagedSearchChange();
}
});
$('#auth_type').trigger('change');
document.getElementById('auth_type').dispatchEvent(new Event('change'));
document.getElementById('security_protocol')?.addEventListener('change', onSecurityProtocolChange);
document.getElementById('use_paged_search')?.addEventListener('change', onUsePagedSearchChange);
document.getElementById('oauth2_provider')?.addEventListener('change', () => onOAuth2Change(true));
@ -200,10 +200,12 @@ export function initAdminCommon() {
}
if (document.querySelector('.admin.authentication')) {
$('#auth_name').on('input', function () {
const authNameEl = document.getElementById('auth_name');
authNameEl.addEventListener('input', (el) => {
// appSubUrl is either empty or is a path that starts with `/` and doesn't have a trailing slash.
document.getElementById('oauth2-callback-url').textContent = `${window.location.origin}${appSubUrl}/user/oauth2/${encodeURIComponent(this.value)}/callback`;
}).trigger('input');
document.getElementById('oauth2-callback-url').textContent = `${window.location.origin}${appSubUrl}/user/oauth2/${encodeURIComponent(el.target.value)}/callback`;
});
authNameEl.dispatchEvent(new Event('input'));
}
// Notice

View file

@ -57,7 +57,7 @@ export function initGlobalEnterQuickSubmit() {
export function initGlobalButtonClickOnEnter() {
$(document).on('keypress', 'div.ui.button,span.ui.button', (e) => {
if (e.code === ' ' || e.code === 'Enter') {
$(e.target).trigger('click');
e.target.click();
e.preventDefault();
}
});
@ -320,7 +320,7 @@ export function initGlobalLinkActions() {
closable: false,
onApprove: async () => {
if ($this.data('type') === 'form') {
$($this.data('form')).trigger('submit');
document.querySelector($this.data('form')).requestSubmit();
return;
}
if ($this[0].getAttribute('hx-confirm')) {

View file

@ -38,7 +38,7 @@ export function initCompLabelEdit(selector) {
form.reportValidity();
return false;
}
$('.new-label.form').trigger('submit');
document.querySelector('.new-label.form').requestSubmit();
},
}).modal('show');
return false;
@ -75,7 +75,7 @@ export function initCompLabelEdit(selector) {
form.reportValidity();
return false;
}
$('.edit-label.form').trigger('submit');
document.querySelector('.edit-label.form').requestSubmit();
},
}).modal('show');
return false;

View file

@ -23,7 +23,7 @@ export function initCompReactionSelector($parent) {
$react.remove();
}
if (!data.empty) {
const $attachments = $content.find('.segment.bottom:first');
const $attachments = $content.find('.segment.bottom').first();
$react = $(data.html);
if ($attachments.length > 0) {
$react.insertBefore($attachments);

View file

@ -10,13 +10,12 @@ export function initOrgTeamSearchRepoBox() {
url: `${appSubUrl}/repo/search?q={query}&uid=${$searchRepoBox.data('uid')}`,
onResponse(response) {
const items = [];
$.each(response.data, (_i, item) => {
for (const item of response.data) {
items.push({
title: item.repository.full_name.split('/')[1],
description: item.repository.full_name,
});
});
}
return {results: items};
},
},

View file

@ -184,7 +184,8 @@ export function initRepoCodeView() {
$('html, body').scrollTop($first.offset().top - 200);
}
}
}).trigger('hashchange');
});
window.dispatchEvent(new Event('hashchange'));
}
$(document).on('click', '.fold-file', ({currentTarget}) => {
invertFileFolding(currentTarget.closest('.file-content'), currentTarget);

View file

@ -33,25 +33,25 @@ export function initRepoArchiveLinks() {
}
export function initRepoCloneLink() {
const $repoCloneSsh = $('#repo-clone-ssh');
const $repoCloneHttps = $('#repo-clone-https');
const $inputLink = $('#repo-clone-url');
const repoCloneSSH = document.getElementById('repo-clone-ssh');
const repoCloneHTTPS = document.getElementById('repo-clone-https');
const inputLink = document.getElementById('repo-clone-url');
if ((!$repoCloneSsh.length && !$repoCloneHttps.length) || !$inputLink.length) {
if ((!repoCloneSSH && !repoCloneHTTPS) || !inputLink) {
return;
}
$repoCloneSsh.on('click', () => {
repoCloneSSH?.addEventListener('click', () => {
localStorage.setItem('repo-clone-protocol', 'ssh');
window.updateCloneStates();
});
$repoCloneHttps.on('click', () => {
repoCloneHTTPS?.addEventListener('click', () => {
localStorage.setItem('repo-clone-protocol', 'https');
window.updateCloneStates();
});
$inputLink.on('focus', () => {
$inputLink.trigger('select');
inputLink.addEventListener('focus', () => {
inputLink.select();
});
}

View file

@ -185,7 +185,7 @@ export function initRepoEditor() {
$('#edit-empty-content-modal')
.modal({
onApprove() {
$('.edit.form').trigger('submit');
document.querySelector('.edit.form').requestSubmit();
},
})
.modal('show');

View file

@ -37,27 +37,27 @@ export function initRepoIssueTimeTracking() {
$('.issue-start-time-modal').modal({
duration: 200,
onApprove() {
$('#add_time_manual_form').trigger('submit');
document.getElementById('add_time_manual_form').requestSubmit();
},
}).modal('show');
$('.issue-start-time-modal input').on('keydown', (e) => {
if ((e.keyCode || e.key) === 13) {
$('#add_time_manual_form').trigger('submit');
document.getElementById('add_time_manual_form').requestSubmit();
}
});
});
$(document).on('click', '.issue-start-time, .issue-stop-time', () => {
$('#toggle_stopwatch_form').trigger('submit');
document.getElementById('toggle_stopwatch_form').requestSubmit();
});
$(document).on('click', '.issue-cancel-time', () => {
$('#cancel_stopwatch_form').trigger('submit');
document.getElementById('cancel_stopwatch_form').requestSubmit();
});
$(document).on('click', 'button.issue-delete-time', function () {
const sel = `.issue-delete-time-modal[data-id="${$(this).data('id')}"]`;
$(sel).modal({
duration: 200,
onApprove() {
$(`${sel} form`).trigger('submit');
document.getElementById(`${sel} form`).requestSubmit();
},
}).modal('show');
});
@ -139,7 +139,7 @@ export function initRepoIssueSidebarList() {
const filteredResponse = {success: true, results: []};
const currIssueId = $('#new-dependency-drop-list').data('issue-id');
// Parse the response from the api to work with our dropdown
$.each(response, (_i, issue) => {
for (const [_, issue] of Object.entries(response)) {
// Don't list current issue in the dependency list.
if (issue.id === currIssueId) {
return;
@ -149,7 +149,7 @@ export function initRepoIssueSidebarList() {
}<div class="text small tw-break-anywhere">${htmlEscape(issue.repository.full_name)}</div>`,
value: issue.id,
});
});
}
return filteredResponse;
},
cache: false,
@ -247,7 +247,7 @@ export function initRepoIssueDependencyDelete() {
onApprove: () => {
$('#removeDependencyID').val(id);
$('#dependencyType').val(type);
$('#removeDependencyForm').trigger('submit');
document.getElementById('removeDependencyForm').requestSubmit();
},
}).modal('show');
});
@ -345,12 +345,12 @@ export function initRepoIssueReferenceRepositorySearch() {
url: `${appSubUrl}/repo/search?q={query}&limit=20`,
onResponse(response) {
const filteredResponse = {success: true, results: []};
$.each(response.data, (_r, repo) => {
for (const repo of response.data) {
filteredResponse.results.push({
name: htmlEscape(repo.repository.full_name),
value: repo.repository.full_name,
});
});
}
return filteredResponse;
},
cache: false,
@ -369,9 +369,9 @@ export function initRepoIssueWipTitle() {
$('.title_wip_desc > a').on('click', (e) => {
e.preventDefault();
const $issueTitle = $('#issue_title');
$issueTitle.trigger('focus');
const value = $issueTitle.val().trim().toUpperCase();
const issueTitleEl = document.getElementById('issue_title');
issueTitleEl.focus();
const value = issueTitleEl.value.trim().toUpperCase();
const wipPrefixes = $('.title_wip_desc').data('wip-prefixes');
for (const prefix of wipPrefixes) {
@ -380,7 +380,7 @@ export function initRepoIssueWipTitle() {
}
}
$issueTitle.val(`${wipPrefixes[0]} ${$issueTitle.val()}`);
issueTitleEl.value = `${wipPrefixes[0]} ${issueTitleEl.value}`;
});
}

View file

@ -29,7 +29,7 @@ export function initRepoMigration() {
cloneAddr?.addEventListener('change', () => {
const repoName = document.getElementById('repo_name');
if (cloneAddr.value && !repoName?.value) { // Only modify if repo_name input is blank
repoName.value = cloneAddr.value.match(/^(.*\/)?((.+?)(\.git)?)$/)[3];
repoName.value = cloneAddr.value.match(/^(.*\/)?((.+?)(\.git)?\/?)$/)[3];
}
});
}

View file

@ -55,13 +55,12 @@ export function initRepoSettingSearchTeamBox() {
headers: {'X-Csrf-Token': csrfToken},
onResponse(response) {
const items = [];
$.each(response.data, (_i, item) => {
for (const item of response.data) {
items.push({
title: item.name,
description: `${item.permission} access`, // TODO: translate this string
});
});
}
return {results: items};
},
},

View file

@ -32,12 +32,12 @@ export function initRepoTemplateSearch() {
value: '',
});
// Parse the response from the api to work with our dropdown
$.each(response.data, (_r, repo) => {
for (const repo of response.data) {
filteredResponse.results.push({
name: htmlEscape(repo.repository.full_name),
value: repo.repository.id,
});
});
}
return filteredResponse;
},
cache: false,