diff options
author | Hester Gong <hestergong@gmail.com> | 2023-04-07 08:11:02 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-07 08:11:02 +0800 |
commit | 6eb678374b583079a0a08b7ed0c9ca220c0c0434 (patch) | |
tree | 9b06ba9c77a39b611b3e5ade32d77081449d0058 /templates | |
parent | 08f4a9cca22d2c092760fb83dbaa1bf0c9dbb49e (diff) | |
download | gitea-6eb678374b583079a0a08b7ed0c9ca220c0c0434.tar.gz gitea-6eb678374b583079a0a08b7ed0c9ca220c0c0434.zip |
Refactor authors dropdown (send get request from frontend to avoid long wait time) (#23890)
Right now the authors search dropdown might take a long time to load if
amount of authors is huge.
Example: (In the video below, there are about 10000 authors, and it
takes about 10 seconds to open the author dropdown)
https://user-images.githubusercontent.com/17645053/229422229-98aa9656-3439-4f8c-9f4e-83bd8e2a2557.mov
Possible improvements can be made, which will take 2 steps (Thanks to
@wolfogre for advice):
Step 1:
Backend: Add a new api, which returns a limit of 30 posters with matched
prefix.
Frontend: Change the search behavior from frontend search(fomantic
search) to backend search(when input is changed, send a request to get
authors matching the current search prefix)
Step 2:
Backend: Optimize the api in step 1 using indexer to support fuzzy
search.
This PR is implements the first step. The main changes:
1. Added api: `GET /{type:issues|pulls}/posters` , which return a limit
of 30 users with matched prefix (prefix sent as query). If
`DEFAULT_SHOW_FULL_NAME` in `custom/conf/app.ini` is set to true, will
also include fullnames fuzzy search.
2. Added a tooltip saying "Shows a maximum of 30 users" to the author
search dropdown
3. Change the search behavior from frontend search to backend search
After:
https://user-images.githubusercontent.com/17645053/229430960-f88fafd8-fd5d-4f84-9df2-2677539d5d08.mov
Fixes: https://github.com/go-gitea/gitea/issues/22586
---------
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
Diffstat (limited to 'templates')
-rw-r--r-- | templates/repo/issue/list.tmpl | 19 | ||||
-rw-r--r-- | templates/repo/issue/milestone_issues.tmpl | 19 | ||||
-rw-r--r-- | templates/repo/issue/view_content/sidebar.tmpl | 2 |
3 files changed, 19 insertions, 21 deletions
diff --git a/templates/repo/issue/list.tmpl b/templates/repo/issue/list.tmpl index cfc9a93048..06cc3aba91 100644 --- a/templates/repo/issue/list.tmpl +++ b/templates/repo/issue/list.tmpl @@ -1,5 +1,5 @@ {{template "base/head" .}} -<div role="main" aria-label="{{.Title}}" class="page-content repository"> +<div role="main" aria-label="{{.Title}}" class="page-content repository issue-list"> {{template "repo/header" .}} <div class="ui container"> <div class="ui three column grid issue-list-headers"> @@ -117,7 +117,11 @@ </div> <!-- Author --> - <div class="ui {{if not .Posters}}disabled{{end}} dropdown jump item"> + <div class="ui dropdown jump item user-remote-search" data-tooltip-content="{{.locale.Tr "repo.author_search_tooltip"}}" + data-search-url="{{$.Link}}/posters" + data-selected-user-id="{{$.PosterID}}" + data-action-jump-url="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={user_id}" + > <span class="text"> {{.locale.Tr "repo.issues.filter_poster"}} {{svg "octicon-triangle-down" 14 "dropdown icon"}} @@ -127,12 +131,7 @@ <i class="icon gt-df gt-ac gt-jc">{{svg "octicon-search" 16}}</i> <input type="text" placeholder="{{.locale.Tr "repo.issues.filter_poster"}}"> </div> - <a class="item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}">{{.locale.Tr "repo.issues.filter_poster_no_select"}}</a> - {{range .Posters}} - <a class="{{if eq $.PosterID .ID}}active selected{{end}} item gt-df" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{.ID}}"> - {{avatar $.Context .}}{{template "repo/search_name" .}} - </a> - {{end}} + <a class="item" data-value="0">{{.locale.Tr "repo.issues.filter_poster_no_select"}}</a> </div> </div> @@ -150,7 +149,7 @@ <a class="item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_assginee_no_select"}}</a> {{range .Assignees}} <a class="{{if eq $.AssigneeID .ID}}active selected{{end}} item gt-df" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{.ID}}&poster={{$.PosterID}}"> - {{avatar $.Context .}}{{template "repo/search_name" .}} + {{avatar $.Context . 20}}{{template "repo/search_name" .}} </a> {{end}} </div> @@ -299,7 +298,7 @@ </div> {{range .Assignees}} <div class="item issue-action" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/assignee"> - {{avatar $.Context .}} {{.GetDisplayName}} + {{avatar $.Context . 20}} {{.GetDisplayName}} </div> {{end}} </div> diff --git a/templates/repo/issue/milestone_issues.tmpl b/templates/repo/issue/milestone_issues.tmpl index 2ca2fa2bce..148a23db66 100644 --- a/templates/repo/issue/milestone_issues.tmpl +++ b/templates/repo/issue/milestone_issues.tmpl @@ -1,5 +1,5 @@ {{template "base/head" .}} -<div role="main" aria-label="{{.Title}}" class="page-content repository"> +<div role="main" aria-label="{{.Title}}" class="page-content repository milestone-issue-list"> {{template "repo/header" .}} <div class="ui container"> <div class="ui two column stackable grid"> @@ -71,7 +71,11 @@ </div> <!-- Author --> - <div class="ui {{if not .Posters}}disabled{{end}} dropdown jump item"> + <div class="ui dropdown jump item user-remote-search" data-tooltip-content="{{.locale.Tr "repo.author_search_tooltip"}}" + data-search-url="{{$.RepoLink}}/issues/posters" + data-selected-user-id="{{$.PosterID}}" + data-action-jump-url="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&assignee={{$.AssigneeID}}&poster={user_id}" + > <span class="text"> {{.locale.Tr "repo.issues.filter_poster"}} {{svg "octicon-triangle-down" 14 "dropdown icon"}} @@ -81,12 +85,7 @@ <i class="icon gt-df gt-ac gt-jc">{{svg "octicon-search" 16}}</i> <input type="text" placeholder="{{.locale.Tr "repo.issues.filter_poster"}}"> </div> - <a class="item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&assignee={{$.AssigneeID}}">{{.locale.Tr "repo.issues.filter_poster_no_select"}}</a> - {{range .Posters}} - <a class="{{if eq $.PosterID .ID}}active selected{{end}} item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&assignee={{$.AssigneeID}}&poster={{.ID}}"> - {{avatar $.Context .}}{{template "repo/search_name" .}} - </a> - {{end}} + <a class="item" data-value="0">{{.locale.Tr "repo.issues.filter_poster_no_select"}}</a> </div> </div> @@ -104,7 +103,7 @@ <a class="item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_assginee_no_select"}}</a> {{range .Assignees}} <a class="{{if eq $.AssigneeID .ID}}active selected{{end}} item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&assignee={{.ID}}&poster={{$.PosterID}}"> - {{avatar $.Context . 28 "gt-mr-2"}}{{template "repo/search_name" .}} + {{avatar $.Context . 20}}{{template "repo/search_name" .}} </a> {{end}} </div> @@ -190,7 +189,7 @@ </div> {{range .Assignees}} <div class="item issue-action" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/assignee"> - {{avatar $.Context . 28 "gt-mr-2"}} + {{avatar $.Context . 20}} {{.GetDisplayName}} </div> {{end}} diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl index 25df29e5fb..521d6ba1d3 100644 --- a/templates/repo/issue/view_content/sidebar.tmpl +++ b/templates/repo/issue/view_content/sidebar.tmpl @@ -254,7 +254,7 @@ {{end}} <span class="octicon-check {{if not $checked}}invisible{{end}}">{{svg "octicon-check"}}</span> <span class="text"> - {{avatar $.Context . 28 "gt-mr-3"}}{{template "repo/search_name" .}} + {{avatar $.Context . 20 "gt-mr-3"}}{{template "repo/search_name" .}} </span> </a> {{end}} |