From 75e85c25c1674627ef750bf7114d3b0b7c0d15aa Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 5 Mar 2025 01:58:17 +0800 Subject: [PATCH] Refactor repo-issue.ts (#33784) And remove jQuery --- .github/workflows/pull-db-tests.yml | 6 +- options/locale/locale_en-US.ini | 2 +- .../issue/sidebar/issue_dependencies.tmpl | 47 ++-- templates/repo/issue/sidebar/wip_switch.tmpl | 8 +- templates/repo/issue/view_content/pull.tmpl | 4 +- .../view_content/pull_merge_instruction.tmpl | 98 ++++---- .../view_content/update_branch_by_merge.tmpl | 2 +- web_src/js/features/repo-issue.ts | 237 ++++++++---------- web_src/js/features/repo-legacy.ts | 6 +- web_src/js/index.ts | 14 +- 10 files changed, 191 insertions(+), 233 deletions(-) diff --git a/.github/workflows/pull-db-tests.yml b/.github/workflows/pull-db-tests.yml index 0b23de0a66..6e879053d3 100644 --- a/.github/workflows/pull-db-tests.yml +++ b/.github/workflows/pull-db-tests.yml @@ -202,12 +202,10 @@ jobs: test-mssql: if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.actions == 'true' needs: files-changed - # specifying the version of ubuntu in use as mssql fails on newer kernels - # pending resolution from vendor - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest services: mssql: - image: mcr.microsoft.com/mssql/server:2017-latest + image: mcr.microsoft.com/mssql/server:2019-latest env: ACCEPT_EULA: Y MSSQL_PID: Standard diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 1da2fb61ad..4f1db5da6a 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1938,7 +1938,7 @@ pulls.outdated_with_base_branch = This branch is out-of-date with the base branc pulls.close = Close Pull Request pulls.closed_at = `closed this pull request %[2]s` pulls.reopened_at = `reopened this pull request %[2]s` -pulls.cmd_instruction_hint = `View command line instructions.` +pulls.cmd_instruction_hint = View command line instructions pulls.cmd_instruction_checkout_title = Checkout pulls.cmd_instruction_checkout_desc = From your project repository, check out a new branch and test the changes. pulls.cmd_instruction_merge_title = Merge diff --git a/templates/repo/issue/sidebar/issue_dependencies.tmpl b/templates/repo/issue/sidebar/issue_dependencies.tmpl index 17e9738c6f..bbae011958 100644 --- a/templates/repo/issue/sidebar/issue_dependencies.tmpl +++ b/templates/repo/issue/sidebar/issue_dependencies.tmpl @@ -31,7 +31,9 @@
{{if and $.CanCreateIssueDependencies (not $.Repository.IsArchived)}} - + {{svg "octicon-trash" 16}} {{end}} @@ -63,7 +65,9 @@
{{if and $.CanCreateIssueDependencies (not $.Repository.IsArchived)}} - + {{svg "octicon-trash" 16}} {{end}} @@ -86,7 +90,9 @@
{{if and $.CanCreateIssueDependencies (not $.Repository.IsArchived)}} - + {{svg "octicon-trash" 16}} {{end}} @@ -106,7 +112,7 @@
{{$.CsrfTokenHtml}}
- {{else if .IsPullWorkInProgress}} -
+
{{svg "octicon-x"}} {{ctx.Locale.Tr "repo.pulls.cannot_merge_work_in_progress"}}
{{if or .HasIssuesOrPullsWritePermission .IsIssuePoster}} - {{end}} diff --git a/templates/repo/issue/view_content/pull_merge_instruction.tmpl b/templates/repo/issue/view_content/pull_merge_instruction.tmpl index 9a3e2cb7d7..a1cff41a3a 100644 --- a/templates/repo/issue/view_content/pull_merge_instruction.tmpl +++ b/templates/repo/issue/view_content/pull_merge_instruction.tmpl @@ -1,55 +1,57 @@
-
{{ctx.Locale.Tr "repo.pulls.cmd_instruction_hint"}}
-
-

{{ctx.Locale.Tr "repo.pulls.cmd_instruction_checkout_title"}}

{{ctx.Locale.Tr "repo.pulls.cmd_instruction_checkout_desc"}}
- {{$localBranch := .PullRequest.HeadBranch}} - {{if ne .PullRequest.HeadRepo.ID .PullRequest.BaseRepo.ID}} - {{$localBranch = print .PullRequest.HeadRepo.OwnerName "-" .PullRequest.HeadBranch}} - {{end}} -
- {{if eq .PullRequest.Flow 0}} -
git fetch -u {{if ne .PullRequest.HeadRepo.ID .PullRequest.BaseRepo.ID}}{{else}}origin{{end}} {{.PullRequest.HeadBranch}}:{{$localBranch}}
- {{else}} -
git fetch -u origin {{.PullRequest.GetGitRefName}}:{{$localBranch}}
+
+ {{ctx.Locale.Tr "repo.pulls.cmd_instruction_hint"}} +
+

{{ctx.Locale.Tr "repo.pulls.cmd_instruction_checkout_title"}}

{{ctx.Locale.Tr "repo.pulls.cmd_instruction_checkout_desc"}}
+ {{$localBranch := .PullRequest.HeadBranch}} + {{if ne .PullRequest.HeadRepo.ID .PullRequest.BaseRepo.ID}} + {{$localBranch = print .PullRequest.HeadRepo.OwnerName "-" .PullRequest.HeadBranch}} {{end}} -
git checkout {{$localBranch}}
-
- {{if .ShowMergeInstructions}} -
-

{{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_title"}}

- {{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_desc"}} - {{if not .AutodetectManualMerge}} -
{{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_warning"}}
- {{end}} -
-
-
-
git checkout {{.PullRequest.BaseBranch}}
-
git merge --no-ff {{$localBranch}}
-
-
-
git checkout {{.PullRequest.BaseBranch}}
-
git merge --ff-only {{$localBranch}}
-
-
+
+ {{if eq .PullRequest.Flow 0}} +
git fetch -u {{if ne .PullRequest.HeadRepo.ID .PullRequest.BaseRepo.ID}}{{else}}origin{{end}} {{.PullRequest.HeadBranch}}:{{$localBranch}}
+ {{else}} +
git fetch -u origin {{.PullRequest.GetGitRefName}}:{{$localBranch}}
+ {{end}}
git checkout {{$localBranch}}
-
git rebase {{.PullRequest.BaseBranch}}
-
git checkout {{.PullRequest.BaseBranch}}
-
git merge --no-ff {{$localBranch}}
-
-
-
git checkout {{.PullRequest.BaseBranch}}
-
git merge --squash {{$localBranch}}
-
-
git checkout {{.PullRequest.BaseBranch}}
-
git merge --ff-only {{$localBranch}}
+ {{if .ShowMergeInstructions}} +
+

{{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_title"}}

+ {{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_desc"}} + {{if not .AutodetectManualMerge}} +
{{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_warning"}}
+ {{end}}
-
-
git checkout {{.PullRequest.BaseBranch}}
-
git merge {{$localBranch}}
+
+
+
git checkout {{.PullRequest.BaseBranch}}
+
git merge --no-ff {{$localBranch}}
+
+
+
git checkout {{.PullRequest.BaseBranch}}
+
git merge --ff-only {{$localBranch}}
+
+
+
git checkout {{$localBranch}}
+
git rebase {{.PullRequest.BaseBranch}}
+
git checkout {{.PullRequest.BaseBranch}}
+
git merge --no-ff {{$localBranch}}
+
+
+
git checkout {{.PullRequest.BaseBranch}}
+
git merge --squash {{$localBranch}}
+
+
+
git checkout {{.PullRequest.BaseBranch}}
+
git merge --ff-only {{$localBranch}}
+
+
+
git checkout {{.PullRequest.BaseBranch}}
+
git merge {{$localBranch}}
+
+
git push origin {{.PullRequest.BaseBranch}}
-
git push origin {{.PullRequest.BaseBranch}}
+ {{end}}
- {{end}} -
+
diff --git a/templates/repo/issue/view_content/update_branch_by_merge.tmpl b/templates/repo/issue/view_content/update_branch_by_merge.tmpl index adce052dee..e0ed262f17 100644 --- a/templates/repo/issue/view_content/update_branch_by_merge.tmpl +++ b/templates/repo/issue/view_content/update_branch_by_merge.tmpl @@ -8,7 +8,7 @@
{{if and $.UpdateAllowed $.UpdateByRebaseAllowed}}
-
+