Skip to content

Commit 8ec241c

Browse files
committed
Expose fuzzy search for issues/pulls
1 parent 7525ce0 commit 8ec241c

File tree

3 files changed

+32
-21
lines changed

3 files changed

+32
-21
lines changed

options/locale/locale_en-US.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ project_kind = Search projects...
177177
branch_kind = Search branches...
178178
commit_kind = Search commits...
179179
runner_kind = Search runners...
180+
issue_kind = Search issues...
181+
pull_kind = Search pulls...
180182
keyword_search_unavailable = Searching by keyword is currently not available. Please contact your site administrator.
181183

182184
[aria]

routers/web/user/home.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,8 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
447447
User: ctx.Doer,
448448
}
449449

450+
isFuzzy := ctx.FormBool("fuzzy")
451+
450452
// Search all repositories which
451453
//
452454
// As user:
@@ -549,7 +551,9 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
549551
// USING FINAL STATE OF opts FOR A QUERY.
550552
var issues issues_model.IssueList
551553
{
552-
issueIDs, _, err := issue_indexer.SearchIssues(ctx, issue_indexer.ToSearchOptions(keyword, opts))
554+
issueSearchOptions := issue_indexer.ToSearchOptions(keyword, opts)
555+
issueSearchOptions.IsFuzzyKeyword = isFuzzy
556+
issueIDs, _, err := issue_indexer.SearchIssues(ctx, issueSearchOptions)
553557
if err != nil {
554558
ctx.ServerError("issueIDsFromSearch", err)
555559
return
@@ -570,7 +574,9 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
570574
// -------------------------------
571575
// Fill stats to post to ctx.Data.
572576
// -------------------------------
573-
issueStats, err := getUserIssueStats(ctx, ctxUser, filterMode, issue_indexer.ToSearchOptions(keyword, opts))
577+
issueSearchOptions := issue_indexer.ToSearchOptions(keyword, opts)
578+
issueSearchOptions.IsFuzzyKeyword = isFuzzy
579+
issueStats, err := getUserIssueStats(ctx, ctxUser, filterMode, issueSearchOptions)
574580
if err != nil {
575581
ctx.ServerError("getUserIssueStats", err)
576582
return
@@ -624,6 +630,7 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
624630
ctx.Data["SortType"] = sortType
625631
ctx.Data["IsShowClosed"] = isShowClosed
626632
ctx.Data["SelectLabels"] = selectedLabels
633+
ctx.Data["IsFuzzy"] = isFuzzy
627634

628635
if isShowClosed {
629636
ctx.Data["State"] = "closed"

templates/user/dashboard/issues.tmpl

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,29 @@
55
<div class="flex-container">
66
<div class="flex-container-nav">
77
<div class="ui secondary vertical filter menu tw-bg-transparent">
8-
<a class="{{if eq .ViewType "your_repositories"}}active{{end}} item" href="{{.Link}}?type=your_repositories&sort={{$.SortType}}&state={{.State}}&q={{$.Keyword}}">
8+
<a class="{{if eq .ViewType "your_repositories"}}active{{end}} item" href="{{.Link}}?type=your_repositories&sort={{$.SortType}}&state={{.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">
99
{{ctx.Locale.Tr "home.issues.in_your_repos"}}
1010
<strong>{{CountFmt .IssueStats.YourRepositoriesCount}}</strong>
1111
</a>
12-
<a class="{{if eq .ViewType "assigned"}}active{{end}} item" href="{{.Link}}?type=assigned&sort={{$.SortType}}&state={{.State}}&q={{$.Keyword}}">
12+
<a class="{{if eq .ViewType "assigned"}}active{{end}} item" href="{{.Link}}?type=assigned&sort={{$.SortType}}&state={{.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">
1313
{{ctx.Locale.Tr "repo.issues.filter_type.assigned_to_you"}}
1414
<strong>{{CountFmt .IssueStats.AssignCount}}</strong>
1515
</a>
16-
<a class="{{if eq .ViewType "created_by"}}active{{end}} item" href="{{.Link}}?type=created_by&sort={{$.SortType}}&state={{.State}}&q={{$.Keyword}}">
16+
<a class="{{if eq .ViewType "created_by"}}active{{end}} item" href="{{.Link}}?type=created_by&sort={{$.SortType}}&state={{.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">
1717
{{ctx.Locale.Tr "repo.issues.filter_type.created_by_you"}}
1818
<strong>{{CountFmt .IssueStats.CreateCount}}</strong>
1919
</a>
2020
{{if .PageIsPulls}}
21-
<a class="{{if eq .ViewType "review_requested"}}active{{end}} item" href="{{.Link}}?type=review_requested&sort={{$.SortType}}&state={{.State}}&q={{$.Keyword}}">
21+
<a class="{{if eq .ViewType "review_requested"}}active{{end}} item" href="{{.Link}}?type=review_requested&sort={{$.SortType}}&state={{.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">
2222
{{ctx.Locale.Tr "repo.issues.filter_type.review_requested"}}
2323
<strong>{{CountFmt .IssueStats.ReviewRequestedCount}}</strong>
2424
</a>
25-
<a class="{{if eq .ViewType "reviewed_by"}}active{{end}} item" href="{{.Link}}?type=reviewed_by&sort={{$.SortType}}&state={{.State}}&q={{$.Keyword}}">
25+
<a class="{{if eq .ViewType "reviewed_by"}}active{{end}} item" href="{{.Link}}?type=reviewed_by&sort={{$.SortType}}&state={{.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">
2626
{{ctx.Locale.Tr "repo.issues.filter_type.reviewed_by_you"}}
2727
<strong>{{CountFmt .IssueStats.ReviewedCount}}</strong>
2828
</a>
2929
{{end}}
30-
<a class="{{if eq .ViewType "mentioned"}}active{{end}} item" href="{{.Link}}?type=mentioned&sort={{$.SortType}}&state={{.State}}&q={{$.Keyword}}">
30+
<a class="{{if eq .ViewType "mentioned"}}active{{end}} item" href="{{.Link}}?type=mentioned&sort={{$.SortType}}&state={{.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">
3131
{{ctx.Locale.Tr "repo.issues.filter_type.mentioning_you"}}
3232
<strong>{{CountFmt .IssueStats.MentionCount}}</strong>
3333
</a>
@@ -36,11 +36,11 @@
3636
<div class="flex-container-main content">
3737
<div class="list-header">
3838
<div class="small-menu-items ui compact tiny menu list-header-toggle">
39-
<a class="item{{if not .IsShowClosed}} active{{end}}" href="{{.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state=open&q={{$.Keyword}}">
39+
<a class="item{{if not .IsShowClosed}} active{{end}}" href="{{.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state=open&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">
4040
{{svg "octicon-issue-opened" 16 "gt-mr-3"}}
4141
{{ctx.Locale.PrettyNumber .IssueStats.OpenCount}}&nbsp;{{ctx.Locale.Tr "repo.issues.open_title"}}
4242
</a>
43-
<a class="item{{if .IsShowClosed}} active{{end}}" href="{{.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state=closed&q={{$.Keyword}}">
43+
<a class="item{{if .IsShowClosed}} active{{end}}" href="{{.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state=closed&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">
4444
{{svg "octicon-issue-closed" 16 "gt-mr-3"}}
4545
{{ctx.Locale.PrettyNumber .IssueStats.ClosedCount}}&nbsp;{{ctx.Locale.Tr "repo.issues.closed_title"}}
4646
</a>
@@ -50,9 +50,11 @@
5050
<input type="hidden" name="type" value="{{$.ViewType}}">
5151
<input type="hidden" name="sort" value="{{$.SortType}}">
5252
<input type="hidden" name="state" value="{{$.State}}">
53-
{{template "shared/search/input" dict "Value" $.Keyword}}
54-
<button id="issue-list-quick-goto" class="ui small icon button gt-hidden" data-tooltip-content="{{ctx.Locale.Tr "explore.go_to"}}">{{svg "octicon-hash"}}</button>
55-
{{template "shared/search/button"}}
53+
{{if .PageIsPulls}}
54+
{{template "shared/search/combo_fuzzy" dict "Value" $.Keyword "IsFuzzy" $.IsFuzzy "Placeholder" (ctx.Locale.Tr "search.pull_kind") "Tooltip" (ctx.Locale.Tr "explorer.go")}}
55+
{{else}}
56+
{{te "Tooltip" (ctx.Locale.Tr "explorer.go")mplate "shared/search/combo_fuzzy" dict "Value" $.Keyword "IsFuzzy" $.IsFuzzy "Placeholder" (ctx.Locale.Tr "search.issue_kind") "Tooltip" (ctx.Locale.Tr "explorer.go")}}
57+
{{end}}
5658
</div>
5759
</form>
5860
<!-- Sort -->
@@ -62,14 +64,14 @@
6264
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
6365
</span>
6466
<div class="menu">
65-
<a class="{{if eq .SortType "recentupdate"}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=recentupdate&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.issues.filter_sort.recentupdate"}}</a>
66-
<a class="{{if eq .SortType "leastupdate"}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=leastupdate&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.issues.filter_sort.leastupdate"}}</a>
67-
<a class="{{if or (eq .SortType "latest") (not .SortType)}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=latest&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.issues.filter_sort.latest"}}</a>
68-
<a class="{{if eq .SortType "oldest"}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=oldest&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.issues.filter_sort.oldest"}}</a>
69-
<a class="{{if eq .SortType "mostcomment"}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=mostcomment&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.issues.filter_sort.mostcomment"}}</a>
70-
<a class="{{if eq .SortType "leastcomment"}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=leastcomment&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.issues.filter_sort.leastcomment"}}</a>
71-
<a class="{{if eq .SortType "nearduedate"}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=nearduedate&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.issues.filter_sort.nearduedate"}}</a>
72-
<a class="{{if eq .SortType "farduedate"}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=farduedate&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.issues.filter_sort.farduedate"}}</a>
67+
<a class="{{if eq .SortType "recentupdate"}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=recentupdate&state={{$.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">{{ctx.Locale.Tr "repo.issues.filter_sort.recentupdate"}}</a>
68+
<a class="{{if eq .SortType "leastupdate"}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=leastupdate&state={{$.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">{{ctx.Locale.Tr "repo.issues.filter_sort.leastupdate"}}</a>
69+
<a class="{{if or (eq .SortType "latest") (not .SortType)}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=latest&state={{$.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">{{ctx.Locale.Tr "repo.issues.filter_sort.latest"}}</a>
70+
<a class="{{if eq .SortType "oldest"}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=oldest&state={{$.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">{{ctx.Locale.Tr "repo.issues.filter_sort.oldest"}}</a>
71+
<a class="{{if eq .SortType "mostcomment"}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=mostcomment&state={{$.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">{{ctx.Locale.Tr "repo.issues.filter_sort.mostcomment"}}</a>
72+
<a class="{{if eq .SortType "leastcomment"}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=leastcomment&state={{$.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">{{ctx.Locale.Tr "repo.issues.filter_sort.leastcomment"}}</a>
73+
<a class="{{if eq .SortType "nearduedate"}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=nearduedate&state={{$.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">{{ctx.Locale.Tr "repo.issues.filter_sort.nearduedate"}}</a>
74+
<a class="{{if eq .SortType "farduedate"}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=farduedate&state={{$.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">{{ctx.Locale.Tr "repo.issues.filter_sort.farduedate"}}</a>
7375
</div>
7476
</div>
7577
</div>

0 commit comments

Comments
 (0)