summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-12-24 20:14:42 +0800
committerGitHub <noreply@github.com>2021-12-24 12:14:42 +0000
commitd7770539f6497e9181d6293700099ac742b03a81 (patch)
treed7ccf5e37bf40cbb4e36887319469181e80884ee
parent7cc44491fae1e5f00616a5b8d8da2934a8a619f8 (diff)
downloadgitea-d7770539f6497e9181d6293700099ac742b03a81.tar.gz
gitea-d7770539f6497e9181d6293700099ac742b03a81.zip
Improve interface when comparing a branch which has created a pull request (#17911)
* Improve interface when comparing a branch which has created a pull request * Take the note back
-rw-r--r--options/locale/locale_en-US.ini1
-rw-r--r--routers/web/repo/compare.go4
-rw-r--r--templates/repo/diff/compare.tmpl18
-rw-r--r--web_src/less/_repository.less9
4 files changed, 30 insertions, 2 deletions
diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini
index f1171df08d..5248f98069 100644
--- a/options/locale/locale_en-US.ini
+++ b/options/locale/locale_en-US.ini
@@ -1429,6 +1429,7 @@ compare.compare_head = compare
pulls.desc = Enable pull requests and code reviews.
pulls.new = New Pull Request
+pulls.view = View Pull Request
pulls.compare_changes = New Pull Request
pulls.compare_changes_desc = Select the branch to merge into and the branch to pull from.
pulls.compare_base = merge into
diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go
index c540cbc08a..3b016b15fb 100644
--- a/routers/web/repo/compare.go
+++ b/routers/web/repo/compare.go
@@ -735,6 +735,10 @@ func CompareDiff(ctx *context.Context) {
}
} else {
ctx.Data["HasPullRequest"] = true
+ if err := pr.LoadIssue(); err != nil {
+ ctx.ServerError("LoadIssue", err)
+ return
+ }
ctx.Data["PullRequest"] = pr
ctx.HTML(http.StatusOK, tplCompareDiff)
return
diff --git a/templates/repo/diff/compare.tmpl b/templates/repo/diff/compare.tmpl
index 51198f4ebf..4517f0029c 100644
--- a/templates/repo/diff/compare.tmpl
+++ b/templates/repo/diff/compare.tmpl
@@ -187,8 +187,22 @@
{{end}}
{{else if and .PageIsComparePull (gt .CommitCount 0)}}
{{if .HasPullRequest}}
- <div class="ui segment">
- {{.i18n.Tr "repo.pulls.has_pull_request" (Escape $.RepoLink) (Escape $.RepoRelPath) .PullRequest.Index | Safe}}
+ <div class="ui segment grid title">
+ <div class="twelve wide column issue-title">
+ {{.i18n.Tr "repo.pulls.has_pull_request" (Escape $.RepoLink) (Escape $.RepoRelPath) .PullRequest.Index | Safe}}
+ <h1>
+ <span id="issue-title">{{RenderIssueTitle .PullRequest.Issue.Title $.RepoLink $.Repository.ComposeMetas}}</span>
+ <span class="index">#{{.PullRequest.Issue.Index}}</span>
+ </h1>
+ </div>
+ <div class="four wide right middle aligned column">
+ {{- if .PullRequest.HasMerged -}}
+ <a href="{{Escape $.RepoLink}}/pulls/{{.PullRequest.Issue.Index}}" class="ui button purple show-form">{{svg "octicon-git-merge" 16}} {{.i18n.Tr "repo.pulls.view"}}</a>
+ {{else if .Issue.IsClosed}}
+ <a href="{{Escape $.RepoLink}}/pulls/{{.PullRequest.Issue.Index}}" class="ui button red show-form">{{svg "octicon-issue-closed" 16}} {{.i18n.Tr "repo.pulls.view"}}</a>
+ {{else}}
+ <a href="{{Escape $.RepoLink}}/pulls/{{.PullRequest.Issue.Index}}" class="ui button green show-form">{{svg "octicon-git-pull-request" 16}} {{.i18n.Tr "repo.pulls.view"}}</a>
+ {{end}}</div>
</div>
{{else}}
{{if and $.IsSigned (not .Repository.IsArchived)}}
diff --git a/web_src/less/_repository.less b/web_src/less/_repository.less
index bb4bee2805..7320f3e302 100644
--- a/web_src/less/_repository.less
+++ b/web_src/less/_repository.less
@@ -1298,6 +1298,15 @@
.markup {
font-size: 14px;
}
+
+ .title {
+ .issue-title {
+ margin-bottom: .5rem;
+ .index {
+ color: var(--color-text-light-2);
+ }
+ }
+ }
}
.filter.dropdown .menu {