diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 081e4a2db4b..88ae98db8df 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -642,7 +642,7 @@ rules: no-this-before-super: [2] no-throw-literal: [2] no-undef-init: [2] - no-undef: [2, {typeof: true}] + no-undef: [2, {typeof: true}] # TODO: disable this rule after tsc passes no-undefined: [0] no-underscore-dangle: [0] no-unexpected-multiline: [2] diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go index bb814eab6e7..cd20c0b18e8 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -348,6 +348,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C } if !baseGitRepo.IsBranchExist(pull.BaseBranch) { + ctx.Data["BaseBranchNotExist"] = true ctx.Data["IsPullRequestBroken"] = true ctx.Data["BaseTarget"] = pull.BaseBranch ctx.Data["HeadTarget"] = pull.HeadBranch diff --git a/templates/repo/issue/sidebar/milestone_list.tmpl b/templates/repo/issue/sidebar/milestone_list.tmpl index a5ed0eef55a..4a7f3f8ad88 100644 --- a/templates/repo/issue/sidebar/milestone_list.tmpl +++ b/templates/repo/issue/sidebar/milestone_list.tmpl @@ -38,8 +38,8 @@ {{end}} {{end}} + {{end}} - diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index 477b6b33c6a..47551c86e47 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -231,7 +231,8 @@ {{template "shared/user/avatarlink" dict "user" .Poster}} {{template "shared/user/authorlink" .Poster}} - {{ctx.Locale.Tr "repo.issues.delete_branch_at" .OldRef $createdStr}} + {{$oldRef := HTMLFormat `%s` .OldRef}} + {{ctx.Locale.Tr "repo.issues.delete_branch_at" $oldRef $createdStr}} {{else if eq .Type 12}} diff --git a/templates/repo/issue/view_title.tmpl b/templates/repo/issue/view_title.tmpl index 26b36d6ffcf..cf775f22b57 100644 --- a/templates/repo/issue/view_title.tmpl +++ b/templates/repo/issue/view_title.tmpl @@ -61,12 +61,16 @@ {{if .Issue.PullRequest.IsAgitFlow}} {{$headHref = HTMLFormat `%s AGit` $headHref "https://docs.gitea.com/usage/agit" (ctx.Locale.Tr "repo.pull.agit_documentation")}} {{else}} - {{$headHref = HTMLFormat `%s` (ctx.Locale.Tr "form.target_branch_not_exist") $headHref}} + {{$headHref = HTMLFormat `%s` (ctx.Locale.Tr "form.target_branch_not_exist") $headHref}} {{end}} {{end}} {{$baseHref := .BaseTarget}} {{if .BaseBranchLink}} - {{$baseHref = HTMLFormat `%s` .BaseBranchLink $baseHref}} + {{if .BaseBranchNotExist}} + {{$baseHref = HTMLFormat `%s` (ctx.Locale.Tr "form.target_branch_not_exist") $baseHref}} + {{else}} + {{$baseHref = HTMLFormat `%s` .BaseBranchLink $baseHref}} + {{end}} {{end}} {{if .Issue.PullRequest.HasMerged}} {{$mergedStr:= DateUtils.TimeSince .Issue.PullRequest.MergedUnix}} diff --git a/tests/integration/pull_merge_test.go b/tests/integration/pull_merge_test.go index 2351e169bc5..bbd99f7aab0 100644 --- a/tests/integration/pull_merge_test.go +++ b/tests/integration/pull_merge_test.go @@ -589,7 +589,8 @@ func TestPullDontRetargetChildOnWrongRepo(t *testing.T) { resp := session.MakeRequest(t, req, http.StatusOK) htmlDoc := NewHTMLParser(t, resp.Body) - targetBranch := htmlDoc.doc.Find("#branch_target>a").Text() + // the branch has been deleted, so there is no a html tag instead of span + targetBranch := htmlDoc.doc.Find("#branch_target>span").Text() prStatus := strings.TrimSpace(htmlDoc.doc.Find(".issue-title-meta>.issue-state-label").Text()) assert.EqualValues(t, "base-pr", targetBranch) diff --git a/web_src/js/features/autofocus-end.ts b/web_src/js/features/autofocus-end.ts index da71ce9536d..53e475b543d 100644 --- a/web_src/js/features/autofocus-end.ts +++ b/web_src/js/features/autofocus-end.ts @@ -1,5 +1,5 @@ export function initAutoFocusEnd() { - for (const el of document.querySelectorAll('.js-autofocus-end')) { + for (const el of document.querySelectorAll('.js-autofocus-end')) { el.focus(); // expects only one such element on one page. If there are many, then the last one gets the focus. el.setSelectionRange(el.value.length, el.value.length); } diff --git a/web_src/js/features/captcha.ts b/web_src/js/features/captcha.ts index 23dbae37406..69b4aa6852f 100644 --- a/web_src/js/features/captcha.ts +++ b/web_src/js/features/captcha.ts @@ -35,9 +35,11 @@ export async function initCaptcha() { } case 'm-captcha': { const {default: mCaptcha} = await import(/* webpackChunkName: "mcaptcha-vanilla-glue" */'@mcaptcha/vanilla-glue'); + // @ts-expect-error mCaptcha.INPUT_NAME = 'm-captcha-response'; const instanceURL = captchaEl.getAttribute('data-instance-url'); + // @ts-expect-error mCaptcha.default({ siteKey: { instanceUrl: new URL(instanceURL), diff --git a/web_src/js/features/citation.ts b/web_src/js/features/citation.ts index c9b07efe778..8fc6beabfb2 100644 --- a/web_src/js/features/citation.ts +++ b/web_src/js/features/citation.ts @@ -3,7 +3,7 @@ import {fomanticQuery} from '../modules/fomantic/base.ts'; const {pageData} = window.config; -async function initInputCitationValue(citationCopyApa, citationCopyBibtex) { +async function initInputCitationValue(citationCopyApa: HTMLButtonElement, citationCopyBibtex: HTMLButtonElement) { const [{Cite, plugins}] = await Promise.all([ import(/* webpackChunkName: "citation-js-core" */'@citation-js/core'), import(/* webpackChunkName: "citation-js-formats" */'@citation-js/plugin-software-formats'), @@ -27,9 +27,9 @@ export async function initCitationFileCopyContent() { if (!pageData.citationFileContent) return; - const citationCopyApa = document.querySelector('#citation-copy-apa'); - const citationCopyBibtex = document.querySelector('#citation-copy-bibtex'); - const inputContent = document.querySelector('#citation-copy-content'); + const citationCopyApa = document.querySelector('#citation-copy-apa'); + const citationCopyBibtex = document.querySelector('#citation-copy-bibtex'); + const inputContent = document.querySelector('#citation-copy-content'); if ((!citationCopyApa && !citationCopyBibtex) || !inputContent) return; @@ -41,7 +41,7 @@ export async function initCitationFileCopyContent() { citationCopyApa.classList.toggle('primary', !isBibtex); }; - document.querySelector('#cite-repo-button')?.addEventListener('click', async (e) => { + document.querySelector('#cite-repo-button')?.addEventListener('click', async (e: MouseEvent & {target: HTMLAnchorElement}) => { const dropdownBtn = e.target.closest('.ui.dropdown.button'); dropdownBtn.classList.add('is-loading'); diff --git a/web_src/js/features/clipboard.ts b/web_src/js/features/clipboard.ts index 8de150d0f98..8f40f34f741 100644 --- a/web_src/js/features/clipboard.ts +++ b/web_src/js/features/clipboard.ts @@ -9,7 +9,7 @@ const {copy_success, copy_error} = window.config.i18n; // - data-clipboard-target: Holds a selector for a or