summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorJimmy Praet <jimmy.praet@telenet.be>2021-01-17 17:34:19 +0100
committerGitHub <noreply@github.com>2021-01-17 17:34:19 +0100
commitacb1ceb1f426e87e7f821c01ab5b60dad7abc03d (patch)
treedda60238b70b45f7d1bb2f815862c67e82feb048 /routers
parent872d3088920f8da2070f497f40d89d35fff9679f (diff)
downloadgitea-acb1ceb1f426e87e7f821c01ab5b60dad7abc03d.tar.gz
gitea-acb1ceb1f426e87e7f821c01ab5b60dad7abc03d.zip
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
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/repo/issue.go9
-rw-r--r--routers/repo/issue.go53
-rw-r--r--routers/user/home.go6
3 files changed, 42 insertions, 26 deletions
diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go
index 25153ad507..bab8f373ce 100644
--- a/routers/api/v1/repo/issue.go
+++ b/routers/api/v1/repo/issue.go
@@ -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)
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index 478baf8d86..7b4044ac7b 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -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)
diff --git a/routers/user/home.go b/routers/user/home.go
index 3c27bbe2a8..a8a8a5f3d7 100644
--- a/routers/user/home.go
+++ b/routers/user/home.go
@@ -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() {