aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authortechknowlogick <techknowlogick@gitea.io>2023-01-28 22:45:29 -0500
committerGitHub <noreply@github.com>2023-01-29 11:45:29 +0800
commite88b529b31696331393e29561bab3c60bf876ee7 (patch)
tree156c65aa2843b8b933da5611fdc32eb82d8e2c56 /routers
parent2b1e47e2a2a5a31a0fc5039ed7dbb192a4a51dd7 (diff)
downloadgitea-e88b529b31696331393e29561bab3c60bf876ee7.tar.gz
gitea-e88b529b31696331393e29561bab3c60bf876ee7.zip
Issues: add Project filter to issues list and search (#22544)
Currently only a single project like milestone, not multiple like labels. Implements #14298 Code by @brechtvl --------- Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Diffstat (limited to 'routers')
-rw-r--r--routers/web/repo/issue.go29
1 files changed, 18 insertions, 11 deletions
diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go
index edd9821ac7..ed7461bbc6 100644
--- a/routers/web/repo/issue.go
+++ b/routers/web/repo/issue.go
@@ -203,6 +203,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
RepoID: repo.ID,
Labels: selectLabels,
MilestoneID: milestoneID,
+ ProjectID: projectID,
AssigneeID: assigneeID,
MentionedID: mentionedID,
PosterID: posterID,
@@ -362,18 +363,16 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
return 0
}
- if ctx.Repo.CanWriteIssuesOrPulls(ctx.Params(":type") == "pulls") {
- projects, _, err := project_model.FindProjects(ctx, project_model.SearchOptions{
- RepoID: repo.ID,
- Type: project_model.TypeRepository,
- IsClosed: util.OptionalBoolOf(isShowClosed),
- })
- if err != nil {
- ctx.ServerError("GetProjects", err)
- return
- }
- ctx.Data["Projects"] = projects
+ projects, _, err := project_model.FindProjects(ctx, project_model.SearchOptions{
+ RepoID: repo.ID,
+ Type: project_model.TypeRepository,
+ IsClosed: util.OptionalBoolOf(isShowClosed),
+ })
+ if err != nil {
+ ctx.ServerError("FindProjects", err)
+ return
}
+ ctx.Data["Projects"] = projects
ctx.Data["IssueStats"] = issueStats
ctx.Data["SelLabelIDs"] = labelIDs
@@ -381,6 +380,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
ctx.Data["ViewType"] = viewType
ctx.Data["SortType"] = sortType
ctx.Data["MilestoneID"] = milestoneID
+ ctx.Data["ProjectID"] = projectID
ctx.Data["AssigneeID"] = assigneeID
ctx.Data["PosterID"] = posterID
ctx.Data["IsShowClosed"] = isShowClosed
@@ -397,6 +397,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
pager.AddParam(ctx, "state", "State")
pager.AddParam(ctx, "labels", "SelectLabels")
pager.AddParam(ctx, "milestone", "MilestoneID")
+ pager.AddParam(ctx, "project", "ProjectID")
pager.AddParam(ctx, "assignee", "AssigneeID")
pager.AddParam(ctx, "poster", "PosterID")
ctx.Data["Page"] = pager
@@ -2352,6 +2353,8 @@ func SearchIssues(ctx *context.Context) {
includedMilestones = strings.Split(milestones, ",")
}
+ projectID := ctx.FormInt64("project")
+
// this api is also used in UI,
// so the default limit is set to fit UI needs
limit := ctx.FormInt("limit")
@@ -2374,6 +2377,7 @@ func SearchIssues(ctx *context.Context) {
IssueIDs: issueIDs,
IncludedLabelNames: includedLabelNames,
IncludeMilestones: includedMilestones,
+ ProjectID: projectID,
SortType: "priorityrepo",
PriorityRepoID: ctx.FormInt64("priority_repo_id"),
IsPull: isPull,
@@ -2511,6 +2515,8 @@ func ListIssues(ctx *context.Context) {
}
}
+ projectID := ctx.FormInt64("project")
+
listOptions := db.ListOptions{
Page: ctx.FormInt("page"),
PageSize: convert.ToCorrectPageSize(ctx.FormInt("limit")),
@@ -2550,6 +2556,7 @@ func ListIssues(ctx *context.Context) {
IssueIDs: issueIDs,
LabelIDs: labelIDs,
MilestoneIDs: mileIDs,
+ ProjectID: projectID,
IsPull: isPull,
UpdatedBeforeUnix: before,
UpdatedAfterUnix: since,