From 81450313dc8470cbd1a1538b1469d511848807c1 Mon Sep 17 00:00:00 2001 From: "m.huber" Date: Sun, 10 Mar 2024 02:42:49 +0100 Subject: [PATCH 1/7] Expose fuzzy search for issues/pulls Signed-off-by: 6543 <6543@obermui.de> --- options/locale/locale_en-US.ini | 2 ++ routers/web/user/home.go | 12 +++++++-- templates/user/dashboard/issues.tmpl | 40 +++++++++++++++------------- 3 files changed, 33 insertions(+), 21 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index dc16d78fc7e6e..baba6ddfc9635 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -177,6 +177,8 @@ branch_kind = Search branches... commit_kind = Search commits... runner_kind = Search runners... no_results = No matching results found. +issue_kind = Search issues... +pull_kind = Search pulls... keyword_search_unavailable = Searching by keyword is currently not available. Please contact the site administrator. [aria] diff --git a/routers/web/user/home.go b/routers/web/user/home.go index 4ec6f6be3f36e..6f0fae6f63bc5 100644 --- a/routers/web/user/home.go +++ b/routers/web/user/home.go @@ -447,6 +447,8 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) { User: ctx.Doer, } + isFuzzy := ctx.FormBool("fuzzy") + // Search all repositories which // // As user: @@ -549,7 +551,9 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) { // USING FINAL STATE OF opts FOR A QUERY. var issues issues_model.IssueList { - issueIDs, _, err := issue_indexer.SearchIssues(ctx, issue_indexer.ToSearchOptions(keyword, opts)) + issueSearchOptions := issue_indexer.ToSearchOptions(keyword, opts) + issueSearchOptions.IsFuzzyKeyword = isFuzzy + issueIDs, _, err := issue_indexer.SearchIssues(ctx, issueSearchOptions) if err != nil { ctx.ServerError("issueIDsFromSearch", err) return @@ -570,7 +574,9 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) { // ------------------------------- // Fill stats to post to ctx.Data. // ------------------------------- - issueStats, err := getUserIssueStats(ctx, ctxUser, filterMode, issue_indexer.ToSearchOptions(keyword, opts)) + issueSearchOptions := issue_indexer.ToSearchOptions(keyword, opts) + issueSearchOptions.IsFuzzyKeyword = isFuzzy + issueStats, err := getUserIssueStats(ctx, ctxUser, filterMode, issueSearchOptions) if err != nil { ctx.ServerError("getUserIssueStats", err) return @@ -624,6 +630,7 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) { ctx.Data["SortType"] = sortType ctx.Data["IsShowClosed"] = isShowClosed ctx.Data["SelectLabels"] = selectedLabels + ctx.Data["IsFuzzy"] = isFuzzy if isShowClosed { ctx.Data["State"] = "closed" @@ -639,6 +646,7 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) { pager.AddParam(ctx, "labels", "SelectLabels") pager.AddParam(ctx, "milestone", "MilestoneID") pager.AddParam(ctx, "assignee", "AssigneeID") + pager.AddParam(ctx, "fuzzy", "IsFuzzy") ctx.Data["Page"] = pager ctx.HTML(http.StatusOK, tplIssues) diff --git a/templates/user/dashboard/issues.tmpl b/templates/user/dashboard/issues.tmpl index 0fbf9a7361b4f..ba575e04abbbb 100644 --- a/templates/user/dashboard/issues.tmpl +++ b/templates/user/dashboard/issues.tmpl @@ -5,29 +5,29 @@
diff --git a/templates/user/dashboard/issues.tmpl b/templates/user/dashboard/issues.tmpl index 7387b59002460..e650ce2e29a95 100644 --- a/templates/user/dashboard/issues.tmpl +++ b/templates/user/dashboard/issues.tmpl @@ -65,25 +65,14 @@ {{svg "octicon-triangle-down" 14 "dropdown icon"}}
From 4b91eab4b45802892421cebdd59bf9c870aaea95 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sat, 23 Mar 2024 20:01:47 +0100 Subject: [PATCH 7/7] Revert "normal issue search too" This reverts commit d0e03af0802ab7f2a5fdd7d7af19c792e205cbe6. --- templates/repo/issue/search.tmpl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/repo/issue/search.tmpl b/templates/repo/issue/search.tmpl index 1ea3c7e021a99..4727b26154fb7 100644 --- a/templates/repo/issue/search.tmpl +++ b/templates/repo/issue/search.tmpl @@ -9,9 +9,10 @@ {{end}} - {{template "shared/search/combo_fuzzy" dict "Value" .Keyword "IsFuzzy" .IsFuzzy "Placeholder" (ctx.Locale.Tr "explore.go_to")}} + {{template "shared/search/input" dict "Value" .Keyword}} {{if .PageIsIssueList}} {{end}} + {{template "shared/search/button"}}