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 10 commits
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
23 changes: 17 additions & 6 deletions models/issue_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,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 @@ -67,8 +73,13 @@ func (issues IssueList) loadRepositories(ctx context.Context) ([]*repo_model.Rep
} 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
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}}
<div class="branches">
<div class="branch">
<a 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 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 @@ -110,6 +110,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
32 changes: 32 additions & 0 deletions web_src/less/shared/issuelist.less
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,38 @@
}
}

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

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

a {
font-weight: bold;
}
}

.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