1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-22 12:54:53 -05:00

Project: show referenced PRs in issue cards (#14183)

Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
Roberto Santalla 2021-01-20 20:53:48 +01:00 committed by GitHub
parent 172229966c
commit ef85bf84ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 4 deletions

View file

@ -256,6 +256,10 @@ func (b *ProjectBoard) LoadIssues() (IssueList, error) {
issueList = append(issueList, issues...)
}
if err := IssueList(issueList).LoadComments(); err != nil {
return nil, err
}
b.Issues = issueList
return issueList, nil
}

View file

@ -280,10 +280,32 @@ func ViewProject(ctx *context.Context) {
boards[0].Title = ctx.Tr("repo.projects.type.uncategorized")
}
if ctx.Data["Issues"], err = boards.LoadIssues(); err != nil {
issueList, err := boards.LoadIssues()
if err != nil {
ctx.ServerError("LoadIssuesOfBoards", err)
return
}
ctx.Data["Issues"] = issueList
linkedPrsMap := make(map[int64][]*models.Issue)
for _, issue := range issueList {
var referencedIds []int64
for _, comment := range issue.Comments {
if comment.RefIssueID != 0 && comment.RefIsPull {
referencedIds = append(referencedIds, comment.RefIssueID)
}
}
if len(referencedIds) > 0 {
if linkedPrs, err := models.Issues(&models.IssuesOptions{
IssueIDs: referencedIds,
IsPull: util.OptionalBoolTrue,
}); err == nil {
linkedPrsMap[issue.ID] = linkedPrs
}
}
}
ctx.Data["LinkedPRs"] = linkedPrsMap
project.RenderedContent = string(markdown.Render([]byte(project.Description), ctx.Repo.RepoLink, ctx.Repo.Repository.ComposeMetas()))

View file

@ -166,13 +166,21 @@
</span>
<a class="project-board-title" href="{{$.RepoLink}}/issues/{{.Index}}">#{{.Index}} {{.Title}}</a>
</div>
{{- if .MilestoneID }}
<div class="meta">
{{ if .MilestoneID }}
<a class="milestone" href="{{$.RepoLink}}/milestone/{{ .MilestoneID}}">
{{svg "octicon-milestone"}} {{ .Milestone.Name }}
</a>
{{ end }}
</div>
{{- end }}
{{- range index $.LinkedPRs .ID }}
<div class="meta">
<a href="{{$.RepoLink}}/pulls/{{ .ID }}">
<span class="{{if .PullRequest.HasMerged}}purple{{else if .IsClosed}}red{{else}}green{{end}}">{{svg "octicon-git-merge"}}</span>
{{ .Title}} (#{{ .ID }})
</a>
</div>
{{- end }}
</div>
<div class="extra content">
{{ range .Labels }}

View file

@ -2921,7 +2921,7 @@ tbody.commit-list {
}
.board-card .content {
padding: 5px 8px !important;
padding: 8px 8px 5px !important;
}
.board-card .extra.content {