@@ -237,10 +237,18 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
237237 }
238238 }
239239
240- isShowClosed := ctx .FormString ("state" ) == "closed"
241- // if open issues are zero and close don't, use closed as default
240+ var isShowClosed util.OptionalBool
241+ switch ctx .FormString ("state" ) {
242+ case "closed" :
243+ isShowClosed = util .OptionalBoolTrue
244+ case "all" :
245+ isShowClosed = util .OptionalBoolNone
246+ default :
247+ isShowClosed = util .OptionalBoolFalse
248+ }
249+ // if there are closed issues and no open issues, default to showing all issues
242250 if len (ctx .FormString ("state" )) == 0 && issueStats .OpenCount == 0 && issueStats .ClosedCount != 0 {
243- isShowClosed = true
251+ isShowClosed = util . OptionalBoolNone
244252 }
245253
246254 if repo .IsTimetrackerEnabled (ctx ) {
@@ -260,10 +268,13 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
260268 }
261269
262270 var total int
263- if ! isShowClosed {
264- total = int (issueStats .OpenCount )
265- } else {
271+ switch isShowClosed {
272+ case util .OptionalBoolTrue :
266273 total = int (issueStats .ClosedCount )
274+ case util .OptionalBoolNone :
275+ total = int (issueStats .OpenCount + issueStats .ClosedCount )
276+ default :
277+ total = int (issueStats .OpenCount )
267278 }
268279 pager := context .NewPagination (total , setting .UI .IssuePagingNum , page , 5 )
269280
@@ -282,7 +293,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
282293 ReviewedID : reviewedID ,
283294 MilestoneIDs : mileIDs ,
284295 ProjectID : projectID ,
285- IsClosed : util . OptionalBoolOf ( isShowClosed ) ,
296+ IsClosed : isShowClosed ,
286297 IsPull : isPullOption ,
287298 LabelIDs : labelIDs ,
288299 SortType : sortType ,
@@ -428,6 +439,9 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
428439 ctx .Data ["OpenCount" ] = issueStats .OpenCount
429440 ctx .Data ["ClosedCount" ] = issueStats .ClosedCount
430441 linkStr := "%s?q=%s&type=%s&sort=%s&state=%s&labels=%s&milestone=%d&project=%d&assignee=%d&poster=%d&archived=%t"
442+ ctx .Data ["AllStatesLink" ] = fmt .Sprintf (linkStr , ctx .Link ,
443+ url .QueryEscape (keyword ), url .QueryEscape (viewType ), url .QueryEscape (sortType ), "all" , url .QueryEscape (selectLabels ),
444+ mentionedID , projectID , assigneeID , posterID , archived )
431445 ctx .Data ["OpenLink" ] = fmt .Sprintf (linkStr , ctx .Link ,
432446 url .QueryEscape (keyword ), url .QueryEscape (viewType ), url .QueryEscape (sortType ), "open" , url .QueryEscape (selectLabels ),
433447 mentionedID , projectID , assigneeID , posterID , archived )
@@ -442,11 +456,13 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
442456 ctx .Data ["ProjectID" ] = projectID
443457 ctx .Data ["AssigneeID" ] = assigneeID
444458 ctx .Data ["PosterID" ] = posterID
445- ctx .Data ["IsShowClosed" ] = isShowClosed
446459 ctx .Data ["Keyword" ] = keyword
447- if isShowClosed {
460+ switch isShowClosed {
461+ case util .OptionalBoolTrue :
448462 ctx .Data ["State" ] = "closed"
449- } else {
463+ case util .OptionalBoolNone :
464+ ctx .Data ["State" ] = "all"
465+ default :
450466 ctx .Data ["State" ] = "open"
451467 }
452468 ctx .Data ["ShowArchivedLabels" ] = archived
0 commit comments