Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show source/target branches on PR's list #19747

Merged
merged 16 commits into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions custom/conf/app.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,9 @@ PATH =
;; Whether to enable a Service Worker to cache frontend assets
;USE_SERVICE_WORKER = false

;; Whether the source/target branches on pull requests list shown
;SHOW_BRANCHES_ON_PR_LIST = true

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;[ui.admin]
Expand Down
1 change: 1 addition & 0 deletions docs/content/doc/advanced/config-cheat-sheet.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a
- `DEFAULT_SHOW_FULL_NAME`: **false**: Whether the full name of the users should be shown where possible. If the full name isn't set, the username will be used.
- `SEARCH_REPO_DESCRIPTION`: **true**: Whether to search within description at repository search on explore page.
- `USE_SERVICE_WORKER`: **false**: Whether to enable a Service Worker to cache frontend assets.
- `SHOW_BRANCHES_ON_PR_LIST`: **true**: Whether the source/target branches on pull requests list shown.

### UI - Admin (`ui.admin`)

Expand Down
23 changes: 17 additions & 6 deletions models/issue_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,17 @@ const (
func (issues IssueList) getRepoIDs() []int64 {
repoIDs := make(map[int64]struct{}, len(issues))
for _, issue := range issues {
if issue.Repo != nil {
continue
// Check if Repo not initialized
if issue.Repo == nil {
if _, ok := repoIDs[issue.RepoID]; !ok {
repoIDs[issue.RepoID] = struct{}{}
}
}
if _, ok := repoIDs[issue.RepoID]; !ok {
repoIDs[issue.RepoID] = struct{}{}
// Add Head repo for Pull Request (only if different)
if (issue.PullRequest != nil) && (issue.PullRequest.HeadRepoID != issue.RepoID) {
if _, ok := repoIDs[issue.PullRequest.HeadRepoID]; !ok {
repoIDs[issue.PullRequest.HeadRepoID] = struct{}{}
}
}
}
return container.KeysInt64(repoIDs)
Expand Down Expand Up @@ -66,8 +72,13 @@ func (issues IssueList) loadRepositories(e db.Engine) ([]*repo_model.Repository,
} else {
repoMaps[issue.RepoID] = issue.Repo
}
if issue.PullRequest != nil && issue.PullRequest.BaseRepo == nil {
issue.PullRequest.BaseRepo = issue.Repo
if issue.PullRequest != nil {
if issue.PullRequest.BaseRepo == nil {
issue.PullRequest.BaseRepo = issue.Repo
}
if issue.PullRequest.HeadRepo == nil {
issue.PullRequest.HeadRepo = repoMaps[issue.PullRequest.HeadRepoID]
}
}
}
return valuesRepository(repoMaps), nil
Expand Down
2 changes: 2 additions & 0 deletions modules/setting/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ var (
CustomEmojisMap map[string]string `ini:"-"`
SearchRepoDescription bool
UseServiceWorker bool
ShowBranchesOnPrList bool
IT-AlexKor marked this conversation as resolved.
Show resolved Hide resolved

Notification struct {
MinTimeout time.Duration
Expand Down Expand Up @@ -1069,6 +1070,7 @@ func loadFromConf(allowEmpty bool, extraConfig string) {
UI.DefaultShowFullName = Cfg.Section("ui").Key("DEFAULT_SHOW_FULL_NAME").MustBool(false)
UI.SearchRepoDescription = Cfg.Section("ui").Key("SEARCH_REPO_DESCRIPTION").MustBool(true)
UI.UseServiceWorker = Cfg.Section("ui").Key("USE_SERVICE_WORKER").MustBool(false)
UI.ShowBranchesOnPrList = Cfg.Section("ui").Key("SHOW_BRANCHES_ON_PR_LIST").MustBool(true)

HasRobotsTxt, err = util.IsFile(path.Join(CustomPath, "robots.txt"))
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions routers/web/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ func Issues(ctx *context.Context) {
}
ctx.Data["Title"] = ctx.Tr("repo.pulls")
ctx.Data["PageIsPullList"] = true
ctx.Data["ShowBranchesOnPrList"] = setting.UI.ShowBranchesOnPrList
} else {
MustEnableIssues(ctx)
if ctx.Written() {
Expand Down
2 changes: 2 additions & 0 deletions routers/web/user/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,8 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {

ctx.Data["Issues"] = issues

ctx.Data["ShowBranchesOnPrList"] = setting.UI.ShowBranchesOnPrList

approvalCounts, err := models.IssueList(issues).GetApprovalCounts()
if err != nil {
ctx.ServerError("ApprovalCounts", err)
Expand Down
23 changes: 23 additions & 0 deletions templates/shared/issuelist.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,29 @@
{{else}}
{{$.i18n.Tr .GetLastEventLabelFake $timeStr (.Poster.GetDisplayName | Escape) | Safe}}
{{end}}
{{if and .IsPull $.ShowBranchesOnPrList}}
<div class="branches">
<div class="branch">
<a style="font-weight: bold;" href="/{{if .PullRequest.BaseRepo}}{{.PullRequest.BaseRepo.OwnerName}}/{{.PullRequest.BaseRepo.LowerName}}{{end}}/src/branch/{{.PullRequest.BaseBranch}}">
IT-AlexKor marked this conversation as resolved.
Show resolved Hide resolved
{{if ne .RepoID .PullRequest.BaseRepoID}}
<div class="truncated-name dib vb">{{.PullRequest.BaseRepo.OwnerName}}</div><div class="truncated-name dib vb">:</div>
{{end}}
<div class="truncated-name dib vb">{{.PullRequest.BaseBranch}}</div>
</a>
</div>
<div class="pointer">
{{svg "gitea-double-chevron-left" 13 }}
IT-AlexKor marked this conversation as resolved.
Show resolved Hide resolved
</div>
<div class="branch">
<a style="font-weight: bold;" href="/{{if .PullRequest.HeadRepo}}{{.PullRequest.HeadRepo.OwnerName}}/{{.PullRequest.HeadRepo.LowerName}}{{end}}/src/branch/{{.PullRequest.HeadBranch}}">
{{if ne .RepoID .PullRequest.HeadRepoID}}
<div class="truncated-name dib vb">{{.PullRequest.HeadRepo.OwnerName}}</div><div class="truncated-name dib vb">:</div>
{{end}}
<div class="truncated-name dib vb">{{.PullRequest.HeadBranch}}</div>
</a>
</div>
</div>
{{end}}
{{if and .Milestone (ne $.listType "milestone")}}
<a class="milestone" {{if $.RepoLink}}href="{{$.RepoLink}}/milestone/{{.Milestone.ID}}"{{else}}href="{{.Repo.Link}}/milestone/{{.Milestone.ID}}"{{end}}>
{{svg "octicon-milestone" 14 "mr-2"}}{{.Milestone.Name}}
Expand Down
2 changes: 2 additions & 0 deletions web_src/less/_base.less
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@
--color-info-border: #a9d5de;
--color-info-bg: #f8ffff;
--color-info-text: #276f86;
--color-pull-request-list-branch-bg: #e8e8e8;
--color-pull-request-arrow-svg: #00000057;
IT-AlexKor marked this conversation as resolved.
Show resolved Hide resolved
/* target-based colors */
--color-body: #ffffff;
--color-text-dark: #080808;
Expand Down
1 change: 1 addition & 0 deletions web_src/less/helpers.less
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
.f1 { flex: 1 !important; }
.fw { flex-wrap: wrap !important; }
.vm { vertical-align: middle !important; }
.vb { vertical-align: bottom !important; }
.w-100 { width: 100% !important; }
.h-100 { height: 100% !important; }

Expand Down
28 changes: 28 additions & 0 deletions web_src/less/shared/issuelist.less
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,34 @@
}
}

.branches {
display: inline-flex;
padding: 0 6px;

.branch {
background-color: var(--color-pull-request-list-branch-bg);
border-radius: 3px;
}

.pointer {
display: flex;
justify-content: center;
align-items: center;
padding: 0 3px;

svg {
color: var(--color-pull-request-arrow-svg);
}
}

.truncated-name {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 10em;
}
}

> .item + .item {
border-top: 1px solid var(--color-secondary);
}
Expand Down
2 changes: 2 additions & 0 deletions web_src/less/themes/theme-arc-green.less
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@
--color-info-border: #306090;
--color-info-bg: #26354c;
--color-info-text: #38a8e8;
--color-pull-request-list-branch-bg: var(--color-secondary);
--color-pull-request-arrow-svg: var(--color-caret);
/* target-based colors */
--color-body: #383c4a;
--color-box-header: #404652;
Expand Down