From 661e78bed5c0879c32c53eb60f3d6898b93e1f08 Mon Sep 17 00:00:00 2001 From: Hester Gong Date: Fri, 17 Mar 2023 00:32:25 +0800 Subject: [PATCH] Allow both fullname and username search when `DEFAULT_SHOW_FULL_NAME` is true (#23463) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR adds the ability to search both fullname and username for assignees, reviewers and author search boxes when the config [`DEFAULT_SHOW_FULL_NAME`](https://github.com/go-gitea/gitea/blob/6ff5400af91aefb02cbc7dd59f6be23cc2bf7865/custom/conf/app.example.ini#L1238) in `app.ini` is set to `true`. Which is originally raised [here](https://projects.blender.org/infrastructure/blender-projects-platform/issues/14) And if `DEFAULT_SHOW_FULL_NAME` is set to `false`(default value), these search boxes will only show username. Example: When `DEFAULT_SHOW_FULL_NAME = true` 截屏2023-03-14 14 28 06 When `DEFAULT_SHOW_FULL_NAME = false` (default value) 截屏2023-03-14 14 29 37 The specific search boxes that adapts these changes include: 1. Author, Assignee search boxes in pull requests tab and issues tab in repository 截屏2023-03-14 14 35 01 2. Assigee and Author on milestones issue page (Added missing search box for author here) 截屏2023-03-14 14 38 20 3. Assignee on issues and PR Sidebar, Reviewer on PR Sidebar 截屏2023-03-14 14 41 06 截屏2023-03-14 14 41 58 4. Assignee when creating new issue 截屏2023-03-14 14 44 33 5. Whitelisted users for pushing, Whitelisted users for merging and Whitelisted reviewers in Protected branch settings 截屏2023-03-14 14 48 56 截屏2023-03-14 14 49 02 截屏2023-03-14 14 49 21 6. "Allowed users" in tags settings 截屏2023-03-14 14 50 11 --- modules/templates/helper.go | 3 +++ templates/repo/issue/list.tmpl | 4 ++-- templates/repo/issue/milestone_issues.tmpl | 9 ++++++--- templates/repo/issue/new_form.tmpl | 2 +- templates/repo/issue/view_content/sidebar.tmpl | 6 ++---- templates/repo/search_name.tmpl | 1 + templates/repo/settings/protected_branch.tmpl | 9 +++------ templates/repo/settings/tags.tmpl | 3 +-- web_src/css/repository.css | 4 ++++ 9 files changed, 23 insertions(+), 18 deletions(-) create mode 100644 templates/repo/search_name.tmpl diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 822bbbd9b1..a8343428dc 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -109,6 +109,9 @@ func NewFuncMap() []template.FuncMap { "CustomEmojis": func() map[string]string { return setting.UI.CustomEmojisMap }, + "IsShowFullName": func() bool { + return setting.UI.DefaultShowFullName + }, "Safe": Safe, "SafeJS": SafeJS, "JSEscape": JSEscape, diff --git a/templates/repo/issue/list.tmpl b/templates/repo/issue/list.tmpl index 36faf86113..975d659470 100644 --- a/templates/repo/issue/list.tmpl +++ b/templates/repo/issue/list.tmpl @@ -134,7 +134,7 @@ {{.locale.Tr "repo.issues.filter_poster_no_select"}} {{range .Posters}} - {{avatar $.Context .}} {{.GetDisplayName}} + {{avatar $.Context .}}{{template "repo/search_name" .}} {{end}} @@ -154,7 +154,7 @@ {{.locale.Tr "repo.issues.filter_assginee_no_select"}} {{range .Assignees}} - {{avatar $.Context .}} {{.GetDisplayName}} + {{avatar $.Context .}}{{template "repo/search_name" .}} {{end}} diff --git a/templates/repo/issue/milestone_issues.tmpl b/templates/repo/issue/milestone_issues.tmpl index b4f036d32a..cb20fb0c56 100644 --- a/templates/repo/issue/milestone_issues.tmpl +++ b/templates/repo/issue/milestone_issues.tmpl @@ -70,10 +70,14 @@ {{svg "octicon-triangle-down" 14 "dropdown icon"}} @@ -93,8 +97,7 @@ {{.locale.Tr "repo.issues.filter_assginee_no_select"}} {{range .Assignees}} - {{avatar $.Context . 28 "gt-mr-2"}} - {{.GetDisplayName}} + {{avatar $.Context . 28 "gt-mr-2"}}{{template "repo/search_name" .}} {{end}} diff --git a/templates/repo/issue/new_form.tmpl b/templates/repo/issue/new_form.tmpl index a99ceb0451..b45a00f781 100644 --- a/templates/repo/issue/new_form.tmpl +++ b/templates/repo/issue/new_form.tmpl @@ -186,7 +186,7 @@ - {{avatar $.Context . 28 "gt-mr-3"}}{{.GetDisplayName}} + {{avatar $.Context . 28 "gt-mr-3"}}{{template "repo/search_name" .}} {{end}} diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl index 165dca7e0c..40d87b4178 100644 --- a/templates/repo/issue/view_content/sidebar.tmpl +++ b/templates/repo/issue/view_content/sidebar.tmpl @@ -26,8 +26,7 @@ {{svg "octicon-check"}} - {{avatar $.Context .User 28 "gt-mr-3"}} - {{.User.GetDisplayName}} + {{avatar $.Context .User 28 "gt-mr-3"}}{{template "repo/search_name" .User}} {{end}} @@ -258,8 +257,7 @@ {{end}} {{svg "octicon-check"}} - {{avatar $.Context . 28 "gt-mr-3"}} - {{.GetDisplayName}} + {{avatar $.Context . 28 "gt-mr-3"}}{{template "repo/search_name" .}} {{end}} diff --git a/templates/repo/search_name.tmpl b/templates/repo/search_name.tmpl new file mode 100644 index 0000000000..468f6c394c --- /dev/null +++ b/templates/repo/search_name.tmpl @@ -0,0 +1 @@ +{{.Name}}{{if IsShowFullName}} {{.FullName}}{{end}} diff --git a/templates/repo/settings/protected_branch.tmpl b/templates/repo/settings/protected_branch.tmpl index 88350c5999..d63fed46bc 100644 --- a/templates/repo/settings/protected_branch.tmpl +++ b/templates/repo/settings/protected_branch.tmpl @@ -49,8 +49,7 @@ @@ -101,8 +100,7 @@ @@ -181,8 +179,7 @@ diff --git a/templates/repo/settings/tags.tmpl b/templates/repo/settings/tags.tmpl index 7b318955ec..aa23c6a57d 100644 --- a/templates/repo/settings/tags.tmpl +++ b/templates/repo/settings/tags.tmpl @@ -36,8 +36,7 @@ diff --git a/web_src/css/repository.css b/web_src/css/repository.css index ad2ac49b99..bebe3ff8f4 100644 --- a/web_src/css/repository.css +++ b/web_src/css/repository.css @@ -3627,3 +3627,7 @@ td.blob-excerpt { .pr-status .status-details > span { padding-right: 0.5em; /* To match the alignment with the "required" label */ } + +.search-fullname { + color: var(--color-text-light-2); +}