@ -140,7 +140,7 @@ func MustAllowPulls(ctx *context.Context) {
}
}
}
}
func issues ( ctx * context . Context , milestoneID , projectID int64 , isPullOption util . OptionalBool ) {
func issues ( ctx * context . Context , milestoneID , projectID int64 , isPullOption optional . Option [ bool ] ) {
var err error
var err error
viewType := ctx . FormString ( "type" )
viewType := ctx . FormString ( "type" )
sortType := ctx . FormString ( "sort" )
sortType := ctx . FormString ( "sort" )
@ -241,18 +241,18 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
}
}
}
}
var isShowClosed util . OptionalBool
var isShowClosed optional . Option [ bool ]
switch ctx . FormString ( "state" ) {
switch ctx . FormString ( "state" ) {
case "closed" :
case "closed" :
isShowClosed = util . OptionalBoolTrue
isShowClosed = optional . Some ( true )
case "all" :
case "all" :
isShowClosed = util . OptionalBoolNone
isShowClosed = optional . None [ bool ] ( )
default :
default :
isShowClosed = util . OptionalBoolFalse
isShowClosed = optional . Some ( false )
}
}
// if there are closed issues and no open issues, default to showing all issues
// 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 {
if len ( ctx . FormString ( "state" ) ) == 0 && issueStats . OpenCount == 0 && issueStats . ClosedCount != 0 {
isShowClosed = util . OptionalBoolNone
isShowClosed = optional . None [ bool ] ( )
}
}
if repo . IsTimetrackerEnabled ( ctx ) {
if repo . IsTimetrackerEnabled ( ctx ) {
@ -272,10 +272,10 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
}
}
var total int
var total int
switch isShowClosed {
switch {
case util . OptionalBoolTrue :
case isShowClosed . Value ( ) :
total = int ( issueStats . ClosedCount )
total = int ( issueStats . ClosedCount )
case util . OptionalBoolNone :
case ! isShowClosed . Has ( ) :
total = int ( issueStats . OpenCount + issueStats . ClosedCount )
total = int ( issueStats . OpenCount + issueStats . ClosedCount )
default :
default :
total = int ( issueStats . OpenCount )
total = int ( issueStats . OpenCount )
@ -431,7 +431,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
return
return
}
}
pinned , err := issues_model . GetPinnedIssues ( ctx , repo . ID , isPullOption . IsTr ue( ) )
pinned , err := issues_model . GetPinnedIssues ( ctx , repo . ID , isPullOption . Val ue( ) )
if err != nil {
if err != nil {
ctx . ServerError ( "GetPinnedIssues" , err )
ctx . ServerError ( "GetPinnedIssues" , err )
return
return
@ -461,10 +461,10 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
ctx . Data [ "AssigneeID" ] = assigneeID
ctx . Data [ "AssigneeID" ] = assigneeID
ctx . Data [ "PosterID" ] = posterID
ctx . Data [ "PosterID" ] = posterID
ctx . Data [ "Keyword" ] = keyword
ctx . Data [ "Keyword" ] = keyword
switch isShowClosed {
switch {
case util . OptionalBoolTrue :
case isShowClosed . Value ( ) :
ctx . Data [ "State" ] = "closed"
ctx . Data [ "State" ] = "closed"
case util . OptionalBoolNone :
case ! isShowClosed . Has ( ) :
ctx . Data [ "State" ] = "all"
ctx . Data [ "State" ] = "all"
default :
default :
ctx . Data [ "State" ] = "open"
ctx . Data [ "State" ] = "open"
@ -513,7 +513,7 @@ func Issues(ctx *context.Context) {
ctx . Data [ "NewIssueChooseTemplate" ] = issue_service . HasTemplatesOrContactLinks ( ctx . Repo . Repository , ctx . Repo . GitRepo )
ctx . Data [ "NewIssueChooseTemplate" ] = issue_service . HasTemplatesOrContactLinks ( ctx . Repo . Repository , ctx . Repo . GitRepo )
}
}
issues ( ctx , ctx . FormInt64 ( "milestone" ) , ctx . FormInt64 ( "project" ) , util . OptionalBoolOf ( isPullList ) )
issues ( ctx , ctx . FormInt64 ( "milestone" ) , ctx . FormInt64 ( "project" ) , optional . Some ( isPullList ) )
if ctx . Written ( ) {
if ctx . Written ( ) {
return
return
}
}
@ -555,7 +555,7 @@ func RetrieveRepoMilestonesAndAssignees(ctx *context.Context, repo *repo_model.R
var err error
var err error
ctx . Data [ "OpenMilestones" ] , err = db . Find [ issues_model . Milestone ] ( ctx , issues_model . FindMilestoneOptions {
ctx . Data [ "OpenMilestones" ] , err = db . Find [ issues_model . Milestone ] ( ctx , issues_model . FindMilestoneOptions {
RepoID : repo . ID ,
RepoID : repo . ID ,
IsClosed : util . OptionalBoolFalse ,
IsClosed : optional . Some ( false ) ,
} )
} )
if err != nil {
if err != nil {
ctx . ServerError ( "GetMilestones" , err )
ctx . ServerError ( "GetMilestones" , err )
@ -563,7 +563,7 @@ func RetrieveRepoMilestonesAndAssignees(ctx *context.Context, repo *repo_model.R
}
}
ctx . Data [ "ClosedMilestones" ] , err = db . Find [ issues_model . Milestone ] ( ctx , issues_model . FindMilestoneOptions {
ctx . Data [ "ClosedMilestones" ] , err = db . Find [ issues_model . Milestone ] ( ctx , issues_model . FindMilestoneOptions {
RepoID : repo . ID ,
RepoID : repo . ID ,
IsClosed : util . OptionalBoolTrue ,
IsClosed : optional . Some ( true ) ,
} )
} )
if err != nil {
if err != nil {
ctx . ServerError ( "GetMilestones" , err )
ctx . ServerError ( "GetMilestones" , err )
@ -591,7 +591,7 @@ func retrieveProjects(ctx *context.Context, repo *repo_model.Repository) {
projects , err := db . Find [ project_model . Project ] ( ctx , project_model . SearchOptions {
projects , err := db . Find [ project_model . Project ] ( ctx , project_model . SearchOptions {
ListOptions : db . ListOptionsAll ,
ListOptions : db . ListOptionsAll ,
RepoID : repo . ID ,
RepoID : repo . ID ,
IsClosed : util . OptionalBoolFalse ,
IsClosed : optional . Some ( false ) ,
Type : project_model . TypeRepository ,
Type : project_model . TypeRepository ,
} )
} )
if err != nil {
if err != nil {
@ -601,7 +601,7 @@ func retrieveProjects(ctx *context.Context, repo *repo_model.Repository) {
projects2 , err := db . Find [ project_model . Project ] ( ctx , project_model . SearchOptions {
projects2 , err := db . Find [ project_model . Project ] ( ctx , project_model . SearchOptions {
ListOptions : db . ListOptionsAll ,
ListOptions : db . ListOptionsAll ,
OwnerID : repo . OwnerID ,
OwnerID : repo . OwnerID ,
IsClosed : util . OptionalBoolFalse ,
IsClosed : optional . Some ( false ) ,
Type : repoOwnerType ,
Type : repoOwnerType ,
} )
} )
if err != nil {
if err != nil {
@ -614,7 +614,7 @@ func retrieveProjects(ctx *context.Context, repo *repo_model.Repository) {
projects , err = db . Find [ project_model . Project ] ( ctx , project_model . SearchOptions {
projects , err = db . Find [ project_model . Project ] ( ctx , project_model . SearchOptions {
ListOptions : db . ListOptionsAll ,
ListOptions : db . ListOptionsAll ,
RepoID : repo . ID ,
RepoID : repo . ID ,
IsClosed : util . OptionalBoolTrue ,
IsClosed : optional . Some ( true ) ,
Type : project_model . TypeRepository ,
Type : project_model . TypeRepository ,
} )
} )
if err != nil {
if err != nil {
@ -624,7 +624,7 @@ func retrieveProjects(ctx *context.Context, repo *repo_model.Repository) {
projects2 , err = db . Find [ project_model . Project ] ( ctx , project_model . SearchOptions {
projects2 , err = db . Find [ project_model . Project ] ( ctx , project_model . SearchOptions {
ListOptions : db . ListOptionsAll ,
ListOptions : db . ListOptionsAll ,
OwnerID : repo . OwnerID ,
OwnerID : repo . OwnerID ,
IsClosed : util . OptionalBoolTrue ,
IsClosed : optional . Some ( true ) ,
Type : repoOwnerType ,
Type : repoOwnerType ,
} )
} )
if err != nil {
if err != nil {
@ -2502,14 +2502,14 @@ func SearchIssues(ctx *context.Context) {
return
return
}
}
var isClosed util . OptionalBool
var isClosed optional . Option [ bool ]
switch ctx . FormString ( "state" ) {
switch ctx . FormString ( "state" ) {
case "closed" :
case "closed" :
isClosed = util . OptionalBoolTrue
isClosed = optional . Some ( true )
case "all" :
case "all" :
isClosed = util . OptionalBoolNone
isClosed = optional . None [ bool ] ( )
default :
default :
isClosed = util . OptionalBoolFalse
isClosed = optional . Some ( false )
}
}
var (
var (
@ -2584,14 +2584,12 @@ func SearchIssues(ctx *context.Context) {
keyword = ""
keyword = ""
}
}
var isPull util . OptionalBool
isPull := optional . None [ bool ] ( )
switch ctx . FormString ( "type" ) {
switch ctx . FormString ( "type" ) {
case "pulls" :
case "pulls" :
isPull = util . OptionalBoolTrue
isPull = optional . Some ( true )
case "issues" :
case "issues" :
isPull = util . OptionalBoolFalse
isPull = optional . Some ( false )
default :
isPull = util . OptionalBoolNone
}
}
var includedAnyLabels [ ] int64
var includedAnyLabels [ ] int64
@ -2726,14 +2724,14 @@ func ListIssues(ctx *context.Context) {
return
return
}
}
var isClosed util . OptionalBool
var isClosed optional . Option [ bool ]
switch ctx . FormString ( "state" ) {
switch ctx . FormString ( "state" ) {
case "closed" :
case "closed" :
isClosed = util . OptionalBoolTrue
isClosed = optional . Some ( true )
case "all" :
case "all" :
isClosed = util . OptionalBoolNone
isClosed = optional . None [ bool ] ( )
default :
default :
isClosed = util . OptionalBoolFalse
isClosed = optional . Some ( false )
}
}
keyword := ctx . FormTrim ( "q" )
keyword := ctx . FormTrim ( "q" )
@ -2785,14 +2783,12 @@ func ListIssues(ctx *context.Context) {
projectID = & v
projectID = & v
}
}
var isPull util . OptionalBool
isPull := optional . None [ bool ] ( )
switch ctx . FormString ( "type" ) {
switch ctx . FormString ( "type" ) {
case "pulls" :
case "pulls" :
isPull = util . OptionalBoolTrue
isPull = optional . Some ( true )
case "issues" :
case "issues" :
isPull = util . OptionalBoolFalse
isPull = optional . Some ( false )
default :
isPull = util . OptionalBoolNone
}
}
// FIXME: we should be more efficient here
// FIXME: we should be more efficient here