Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow filtering issues by any assignee #33343

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
5 changes: 5 additions & 0 deletions models/db/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ const (
// eg: "milestone_id=-1" means "find the items without any milestone.
const NoConditionID int64 = -1

// AnyConditionID means a condition to filter the records which match any id.
// The inverse of the above NoConditionID
// eg: "assignee_id=-2" means "find the issues with an assignee"
const AnyConditionID int64 = -2

// NonExistingID means a condition to match no result (eg: a non-existing user)
// It doesn't use -1 or -2 because they are used as builtin users.
const NonExistingID int64 = -1000000
2 changes: 2 additions & 0 deletions models/issues/issue_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,8 @@ func applyAssigneeCondition(sess *xorm.Session, assigneeID optional.Option[int64
}
if assigneeID.Value() == db.NoConditionID {
sess.Where("issue.id NOT IN (SELECT issue_id FROM issue_assignees)")
} else if assigneeID.Value() == db.AnyConditionID {
sess.Where("issue.id IN (SELECT issue_id FROM issue_assignees)")
} else {
sess.Join("INNER", "issue_assignees", "issue.id = issue_assignees.issue_id").
And("issue_assignees.assignee_id = ?", assigneeID.Value())
Expand Down
1 change: 1 addition & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1531,6 +1531,7 @@ issues.filter_project_none = No project
issues.filter_assignee = Assignee
issues.filter_assginee_no_select = All assignees
issues.filter_assginee_no_assignee = No assignee
issues.filter_assignee_any_assignee = Any assignee
issues.filter_poster = Author
issues.filter_user_placeholder = Search users
issues.filter_user_no_select = All users
Expand Down
4 changes: 4 additions & 0 deletions templates/repo/issue/filter_item_user_assign.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* TextFilterTitle
* TextZeroValue: the text for "all issues"
* TextNegativeOne: the text for "issues with no assignee"
* TextNegativeTwo: the text for "issues with any assignee"
*/}}
{{$queryLink := .QueryLink}}
<div class="item ui dropdown jump {{if not .UserSearchList}}disabled{{end}}">
Expand All @@ -21,6 +22,9 @@
{{if $.TextNegativeOne}}
<a class="item {{if eq .SelectedUserId -1}}selected{{end}}" href="{{QueryBuild $queryLink $.QueryParamKey -1}}">{{$.TextNegativeOne}}</a>
{{end}}
{{if $.TextNegativeTwo}}
<a class="item {{if eq .SelectedUserId -2}}selected{{end}}" href="{{QueryBuild $queryLink $.QueryParamKey -2}}">{{$.TextNegativeTwo}}</a>
{{end}}
<div class="divider"></div>
{{range .UserSearchList}}
<a class="item {{if eq $.SelectedUserId .ID}}selected{{end}}" href="{{QueryBuild $queryLink $.QueryParamKey .ID}}">
Expand Down
1 change: 1 addition & 0 deletions templates/repo/issue/filter_list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
"TextFilterTitle" (ctx.Locale.Tr "repo.issues.filter_assignee")
"TextZeroValue" (ctx.Locale.Tr "repo.issues.filter_assginee_no_select")
"TextNegativeOne" (ctx.Locale.Tr "repo.issues.filter_assginee_no_assignee")
"TextNegativeTwo" (ctx.Locale.Tr "repo.issues.filter_assignee_any_assignee")
}}

{{if .IsSigned}}
Expand Down
Loading