From d4b1ed859ce09d7662a022c6c118b65c608ac152 Mon Sep 17 00:00:00 2001 From: Mai-Lapyst Date: Mon, 20 May 2024 23:32:48 +0000 Subject: [PATCH] Port: Fix issue/PR title edit (gitea#30858) (#3797) This PR ports [gitea#30858](https://github.com/go-gitea/gitea/pull/30858) / [this commit](https://github.com/go-gitea/gitea/commit/5c236bd4c024dbe4a71516b10aa812893651983a) to forgejo. [week 2024-20 cherry pick](https://codeberg.org/forgejo/forgejo/pulls/3729) ## Tests - [ ] Click "edit" to get into edit mode, change the title and then use Alt+Enter to save the title ## Screenshots Before: ![grafik](/attachments/bb0b2562-7da0-4205-a647-3270d66f2ad7) ![grafik](/attachments/c3d05a21-659d-4616-b357-87de57232182) After: ![grafik](/attachments/d9af6966-3282-439b-a845-76618a24b9a6) ![grafik](/attachments/5acd6684-69c4-41a4-8e27-7cb75fe3c7e4) Co-authored-by: wxiaoguang Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3797 Reviewed-by: 0ko <0ko@noreply.codeberg.org> Co-authored-by: Mai-Lapyst Co-committed-by: Mai-Lapyst --- templates/repo/issue/view_title.tmpl | 42 ++++---- tests/integration/issue_test.go | 2 +- tests/integration/pull_create_test.go | 2 +- web_src/css/repo.css | 15 +-- web_src/js/features/repo-issue.js | 134 ++++++++++++-------------- 5 files changed, 93 insertions(+), 102 deletions(-) diff --git a/templates/repo/issue/view_title.tmpl b/templates/repo/issue/view_title.tmpl index 19a1d0c304..c4cad8ff4e 100644 --- a/templates/repo/issue/view_title.tmpl +++ b/templates/repo/issue/view_title.tmpl @@ -4,29 +4,35 @@ {{end}}
-
+ {{$canEditIssueTitle := and (or .HasIssuesOrPullsWritePermission .IsIssuePoster) (not .Repository.IsArchived)}} +

- {{RenderIssueTitle $.Context .Issue.Title ($.Repository.ComposeMetas ctx) | RenderCodeBlock}} #{{.Issue.Index}} - -
- -
+ {{RenderIssueTitle $.Context .Issue.Title ($.Repository.ComposeMetas ctx) | RenderCodeBlock}} + #{{.Issue.Index}}

- {{if and (or .HasIssuesOrPullsWritePermission .IsIssuePoster) (not .Repository.IsArchived)}} - + {{if $canEditIssueTitle}} + {{end}} {{if not .Issue.IsPull}} - {{ctx.Locale.Tr "repo.issues.new"}} + {{ctx.Locale.Tr "repo.issues.new"}} {{end}}
- {{if and (or .HasIssuesOrPullsWritePermission .IsIssuePoster) (not .Repository.IsArchived)}} -
- - -
- {{end}}
+ {{if $canEditIssueTitle}} +
+
+ +
+
+ + +
+
+ {{end}}
{{if .HasMerged}}
{{svg "octicon-git-merge" 16 "tw-mr-1"}} {{if eq .Issue.PullRequest.Status 3}}{{ctx.Locale.Tr "repo.pulls.manually_merged"}}{{else}}{{ctx.Locale.Tr "repo.pulls.merged"}}{{end}}
@@ -65,9 +71,9 @@ {{end}} {{else}} {{if .Issue.OriginalAuthor}} - {{.Issue.OriginalAuthor}} {{ctx.Locale.TrN .NumCommits "repo.pulls.title_desc_one" "repo.pulls.title_desc_few" .NumCommits $headHref $baseHref}} + {{.Issue.OriginalAuthor}} {{ctx.Locale.TrN .NumCommits "repo.pulls.title_desc_one" "repo.pulls.title_desc_few" .NumCommits $headHref $baseHref}} {{else}} - + {{.Issue.Poster.GetDisplayName}} {{ctx.Locale.TrN .NumCommits "repo.pulls.title_desc_one" "repo.pulls.title_desc_few" .NumCommits $headHref $baseHref}} @@ -81,7 +87,7 @@ {{end}} - +