diff --git a/models/repo/user_repo.go b/models/repo/user_repo.go index 71e0c57550..6c0a241dc5 100644 --- a/models/repo/user_repo.go +++ b/models/repo/user_repo.go @@ -170,3 +170,15 @@ func GetReviewers(ctx context.Context, repo *Repository, doerID, posterID int64) users := make([]*user_model.User, 0, 8) return users, db.GetEngine(ctx).Where(cond).OrderBy(user_model.GetOrderByName()).Find(&users) } + +// GetIssuePosters returns all users that have authored an issue/pull request for the given repository +func GetIssuePosters(ctx context.Context, repo *Repository, isPull bool) ([]*user_model.User, error) { + users := make([]*user_model.User, 0, 8) + cond := builder.In("`user`.id", + builder.Select("poster_id").From("issue").Where( + builder.Eq{"repo_id": repo.ID}. + And(builder.Eq{"is_pull": isPull}), + ).GroupBy("poster_id"), + ) + return users, db.GetEngine(ctx).Where(cond).OrderBy(user_model.GetOrderByName()).Find(&users) +} diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 783783617b..426521e4ee 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1269,6 +1269,8 @@ issues.filter_milestone = Milestone issues.filter_milestone_no_select = All milestones issues.filter_assignee = Assignee issues.filter_assginee_no_select = All assignees +issues.filter_poster = Author +issues.filter_poster_no_select = All authors issues.filter_type = Type issues.filter_type.all_issues = All issues issues.filter_type.assigned_to_you = Assigned to you diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index e6f9529e31..ad25a94e13 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -133,7 +133,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti var ( assigneeID = ctx.FormInt64("assignee") - posterID int64 + posterID = ctx.FormInt64("poster") mentionedID int64 reviewRequestedID int64 forceEmpty bool @@ -291,6 +291,12 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti return } + ctx.Data["Posters"], err = repo_model.GetIssuePosters(ctx, repo, isPullOption.IsTrue()) + if err != nil { + ctx.ServerError("GetIssuePosters", err) + return + } + handleTeamMentions(ctx) if ctx.Written() { return @@ -364,6 +370,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti ctx.Data["SortType"] = sortType ctx.Data["MilestoneID"] = milestoneID ctx.Data["AssigneeID"] = assigneeID + ctx.Data["PosterID"] = posterID ctx.Data["IsShowClosed"] = isShowClosed ctx.Data["Keyword"] = keyword if isShowClosed { @@ -379,6 +386,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti pager.AddParam(ctx, "labels", "SelectLabels") pager.AddParam(ctx, "milestone", "MilestoneID") pager.AddParam(ctx, "assignee", "AssigneeID") + pager.AddParam(ctx, "poster", "PosterID") ctx.Data["Page"] = pager } diff --git a/templates/repo/issue/list.tmpl b/templates/repo/issue/list.tmpl index 2a53239f1c..8e8c256c59 100644 --- a/templates/repo/issue/list.tmpl +++ b/templates/repo/issue/list.tmpl @@ -46,9 +46,9 @@ @@ -60,9 +60,25 @@ {{svg "octicon-triangle-down" 14 "dropdown icon"}} + + + + @@ -74,9 +90,9 @@ {{svg "octicon-triangle-down" 14 "dropdown icon"}} @@ -109,14 +125,14 @@ {{svg "octicon-triangle-down" 14 "dropdown icon"}} diff --git a/templates/repo/issue/milestone_issues.tmpl b/templates/repo/issue/milestone_issues.tmpl index 484d0a8110..0f00e9284a 100644 --- a/templates/repo/issue/milestone_issues.tmpl +++ b/templates/repo/issue/milestone_issues.tmpl @@ -52,9 +52,25 @@ + + + + @@ -66,9 +82,9 @@ {{svg "octicon-triangle-down" 14 "dropdown icon"}} {{end}} @@ -100,12 +116,12 @@ {{svg "octicon-triangle-down" 14 "dropdown icon"}} diff --git a/templates/repo/issue/openclose.tmpl b/templates/repo/issue/openclose.tmpl index 9242d0c5ca..ccfb40684c 100644 --- a/templates/repo/issue/openclose.tmpl +++ b/templates/repo/issue/openclose.tmpl @@ -1,5 +1,5 @@ diff --git a/templates/shared/issuelist.tmpl b/templates/shared/issuelist.tmpl index d1555c16c5..f4e0674be4 100644 --- a/templates/shared/issuelist.tmpl +++ b/templates/shared/issuelist.tmpl @@ -43,7 +43,7 @@ {{end}} {{range .Labels}} - {{.Name | RenderEmoji}} + {{.Name | RenderEmoji}} {{end}}