diff options
author | Gwyneth Morgan <gwymor@tilde.club> | 2024-01-15 07:07:22 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-15 15:07:22 +0000 |
commit | 2c3da59e275b69ebf984bb70954f42a7bcb0b49d (patch) | |
tree | 7c4f4eabdcee9cff60abace2e4c36a1484277ee0 /routers/web | |
parent | 2d343f8987025015f5b61e328cc9e45082e6d3f2 (diff) | |
download | gitea-2c3da59e275b69ebf984bb70954f42a7bcb0b49d.tar.gz gitea-2c3da59e275b69ebf984bb70954f42a7bcb0b49d.zip |
Add ability to see open and closed issues at the same time (#28757)
By clicking the currently active "Open" or "Closed" filter button in the
issue list, the user can toggle that filter off in order to see all
issues regardless of state. The URL "state" parameter will be set to
"all" and the "Open"/"Closed" button will not show as active.
Diffstat (limited to 'routers/web')
-rw-r--r-- | routers/web/repo/issue.go | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index 0d660e3b89..c8c9924a9e 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -237,10 +237,18 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti } } - isShowClosed := ctx.FormString("state") == "closed" - // if open issues are zero and close don't, use closed as default + var isShowClosed util.OptionalBool + switch ctx.FormString("state") { + case "closed": + isShowClosed = util.OptionalBoolTrue + case "all": + isShowClosed = util.OptionalBoolNone + default: + isShowClosed = util.OptionalBoolFalse + } + // if there are closed issues and no open issues, default to showing all issues if len(ctx.FormString("state")) == 0 && issueStats.OpenCount == 0 && issueStats.ClosedCount != 0 { - isShowClosed = true + isShowClosed = util.OptionalBoolNone } if repo.IsTimetrackerEnabled(ctx) { @@ -260,10 +268,13 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti } var total int - if !isShowClosed { - total = int(issueStats.OpenCount) - } else { + switch isShowClosed { + case util.OptionalBoolTrue: total = int(issueStats.ClosedCount) + case util.OptionalBoolNone: + total = int(issueStats.OpenCount + issueStats.ClosedCount) + default: + total = int(issueStats.OpenCount) } pager := context.NewPagination(total, setting.UI.IssuePagingNum, page, 5) @@ -282,7 +293,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti ReviewedID: reviewedID, MilestoneIDs: mileIDs, ProjectID: projectID, - IsClosed: util.OptionalBoolOf(isShowClosed), + IsClosed: isShowClosed, IsPull: isPullOption, LabelIDs: labelIDs, SortType: sortType, @@ -428,6 +439,9 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti ctx.Data["OpenCount"] = issueStats.OpenCount ctx.Data["ClosedCount"] = issueStats.ClosedCount linkStr := "%s?q=%s&type=%s&sort=%s&state=%s&labels=%s&milestone=%d&project=%d&assignee=%d&poster=%d&archived=%t" + ctx.Data["AllStatesLink"] = fmt.Sprintf(linkStr, ctx.Link, + url.QueryEscape(keyword), url.QueryEscape(viewType), url.QueryEscape(sortType), "all", url.QueryEscape(selectLabels), + mentionedID, projectID, assigneeID, posterID, archived) ctx.Data["OpenLink"] = fmt.Sprintf(linkStr, ctx.Link, url.QueryEscape(keyword), url.QueryEscape(viewType), url.QueryEscape(sortType), "open", url.QueryEscape(selectLabels), mentionedID, projectID, assigneeID, posterID, archived) @@ -442,11 +456,13 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti ctx.Data["ProjectID"] = projectID ctx.Data["AssigneeID"] = assigneeID ctx.Data["PosterID"] = posterID - ctx.Data["IsShowClosed"] = isShowClosed ctx.Data["Keyword"] = keyword - if isShowClosed { + switch isShowClosed { + case util.OptionalBoolTrue: ctx.Data["State"] = "closed" - } else { + case util.OptionalBoolNone: + ctx.Data["State"] = "all" + default: ctx.Data["State"] = "open" } ctx.Data["ShowArchivedLabels"] = archived |