Add review requested filter on pull request overview (#13701)
* Add review requested filter on pull request overview #13682 fix formatting * add review_requested filter to /repos/issues/search API endpoint * only Approve and Reject status should supersede Request status * add support for team reviews * refactor: remove duplication of issue filtering conditions
This commit is contained in:
parent
872d308892
commit
acb1ceb1f4
9 changed files with 156 additions and 88 deletions
|
@ -79,6 +79,10 @@ func SearchIssues(ctx *context.APIContext) {
|
|||
// in: query
|
||||
// description: filter (issues / pulls) mentioning you, default is false
|
||||
// type: boolean
|
||||
// - name: review_requested
|
||||
// in: query
|
||||
// description: filter pulls requesting your review, default is false
|
||||
// type: boolean
|
||||
// - name: page
|
||||
// in: query
|
||||
// description: page number of results to return (1-based)
|
||||
|
@ -204,7 +208,7 @@ func SearchIssues(ctx *context.APIContext) {
|
|||
UpdatedAfterUnix: since,
|
||||
}
|
||||
|
||||
// Filter for: Created by User, Assigned to User, Mentioning User
|
||||
// Filter for: Created by User, Assigned to User, Mentioning User, Review of User Requested
|
||||
if ctx.QueryBool("created") {
|
||||
issuesOpt.PosterID = ctx.User.ID
|
||||
}
|
||||
|
@ -214,6 +218,9 @@ func SearchIssues(ctx *context.APIContext) {
|
|||
if ctx.QueryBool("mentioned") {
|
||||
issuesOpt.MentionedID = ctx.User.ID
|
||||
}
|
||||
if ctx.QueryBool("review_requested") {
|
||||
issuesOpt.ReviewRequestedID = ctx.User.ID
|
||||
}
|
||||
|
||||
if issues, err = models.Issues(issuesOpt); err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "Issues", err)
|
||||
|
|
|
@ -113,16 +113,17 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
|
|||
var err error
|
||||
viewType := ctx.Query("type")
|
||||
sortType := ctx.Query("sort")
|
||||
types := []string{"all", "your_repositories", "assigned", "created_by", "mentioned"}
|
||||
types := []string{"all", "your_repositories", "assigned", "created_by", "mentioned", "review_requested"}
|
||||
if !util.IsStringInSlice(viewType, types, true) {
|
||||
viewType = "all"
|
||||
}
|
||||
|
||||
var (
|
||||
assigneeID = ctx.QueryInt64("assignee")
|
||||
posterID int64
|
||||
mentionedID int64
|
||||
forceEmpty bool
|
||||
assigneeID = ctx.QueryInt64("assignee")
|
||||
posterID int64
|
||||
mentionedID int64
|
||||
reviewRequestedID int64
|
||||
forceEmpty bool
|
||||
)
|
||||
|
||||
if ctx.IsSigned {
|
||||
|
@ -133,6 +134,8 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
|
|||
mentionedID = ctx.User.ID
|
||||
case "assigned":
|
||||
assigneeID = ctx.User.ID
|
||||
case "review_requested":
|
||||
reviewRequestedID = ctx.User.ID
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,14 +172,15 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
|
|||
issueStats = &models.IssueStats{}
|
||||
} else {
|
||||
issueStats, err = models.GetIssueStats(&models.IssueStatsOptions{
|
||||
RepoID: repo.ID,
|
||||
Labels: selectLabels,
|
||||
MilestoneID: milestoneID,
|
||||
AssigneeID: assigneeID,
|
||||
MentionedID: mentionedID,
|
||||
PosterID: posterID,
|
||||
IsPull: isPullOption,
|
||||
IssueIDs: issueIDs,
|
||||
RepoID: repo.ID,
|
||||
Labels: selectLabels,
|
||||
MilestoneID: milestoneID,
|
||||
AssigneeID: assigneeID,
|
||||
MentionedID: mentionedID,
|
||||
PosterID: posterID,
|
||||
ReviewRequestedID: reviewRequestedID,
|
||||
IsPull: isPullOption,
|
||||
IssueIDs: issueIDs,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("GetIssueStats", err)
|
||||
|
@ -217,17 +221,18 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
|
|||
Page: pager.Paginater.Current(),
|
||||
PageSize: setting.UI.IssuePagingNum,
|
||||
},
|
||||
RepoIDs: []int64{repo.ID},
|
||||
AssigneeID: assigneeID,
|
||||
PosterID: posterID,
|
||||
MentionedID: mentionedID,
|
||||
MilestoneIDs: mileIDs,
|
||||
ProjectID: projectID,
|
||||
IsClosed: util.OptionalBoolOf(isShowClosed),
|
||||
IsPull: isPullOption,
|
||||
LabelIDs: labelIDs,
|
||||
SortType: sortType,
|
||||
IssueIDs: issueIDs,
|
||||
RepoIDs: []int64{repo.ID},
|
||||
AssigneeID: assigneeID,
|
||||
PosterID: posterID,
|
||||
MentionedID: mentionedID,
|
||||
ReviewRequestedID: reviewRequestedID,
|
||||
MilestoneIDs: mileIDs,
|
||||
ProjectID: projectID,
|
||||
IsClosed: util.OptionalBoolOf(isShowClosed),
|
||||
IsPull: isPullOption,
|
||||
LabelIDs: labelIDs,
|
||||
SortType: sortType,
|
||||
IssueIDs: issueIDs,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("Issues", err)
|
||||
|
|
|
@ -392,6 +392,8 @@ func buildIssueOverview(ctx *context.Context, unitType models.UnitType) {
|
|||
filterMode = models.FilterModeCreate
|
||||
case "mentioned":
|
||||
filterMode = models.FilterModeMention
|
||||
case "review_requested":
|
||||
filterMode = models.FilterModeReviewRequested
|
||||
case "your_repositories": // filterMode already set to All
|
||||
default:
|
||||
viewType = "your_repositories"
|
||||
|
@ -431,7 +433,9 @@ func buildIssueOverview(ctx *context.Context, unitType models.UnitType) {
|
|||
case models.FilterModeCreate:
|
||||
opts.PosterID = ctx.User.ID
|
||||
case models.FilterModeMention:
|
||||
opts.MentionedID = ctx.User.ID
|
||||
opts.MentionedID = ctxUser.ID
|
||||
case models.FilterModeReviewRequested:
|
||||
opts.ReviewRequestedID = ctxUser.ID
|
||||
}
|
||||
|
||||
if ctxUser.IsOrganization() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue