Skip to content

Commit 661e78b

Browse files
authored
Allow both fullname and username search when DEFAULT_SHOW_FULL_NAME is true (#23463)
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` <img width="1220" alt="截屏2023-03-14 14 28 06" src="https://user-images.githubusercontent.com/17645053/224914546-80ef2837-ab72-4d66-9f00-6eb77ed4baaa.png"> When `DEFAULT_SHOW_FULL_NAME = false` (default value) <img width="1243" alt="截屏2023-03-14 14 29 37" src="https://user-images.githubusercontent.com/17645053/224914798-f69ec8a2-0929-4330-827c-3e30188f9b47.png"> The specific search boxes that adapts these changes include: 1. Author, Assignee search boxes in pull requests tab and issues tab in repository <img width="1283" alt="截屏2023-03-14 14 35 01" src="https://user-images.githubusercontent.com/17645053/224916250-8e452525-71d6-4b48-bf1c-bf7a176abaaa.png"> 2. Assigee and Author on milestones issue page (Added missing search box for author here) <img width="1261" alt="截屏2023-03-14 14 38 20" src="https://user-images.githubusercontent.com/17645053/224916569-d3105619-7824-4bb8-a6d0-1a600eaa9963.png"> 3. Assignee on issues and PR Sidebar, Reviewer on PR Sidebar <img width="976" alt="截屏2023-03-14 14 41 06" src="https://user-images.githubusercontent.com/17645053/224917431-c45d821e-9660-4f58-a196-5979a0bb64ce.png"> <img width="1027" alt="截屏2023-03-14 14 41 58" src="https://user-images.githubusercontent.com/17645053/224917290-ad4dbc52-0c20-45c4-9fce-9dcd59ad7d47.png"> 4. Assignee when creating new issue <img width="961" alt="截屏2023-03-14 14 44 33" src="https://user-images.githubusercontent.com/17645053/224917694-34bee5a7-e975-4f37-8862-56ebc2556808.png"> 5. Whitelisted users for pushing, Whitelisted users for merging and Whitelisted reviewers in Protected branch settings <img width="920" alt="截屏2023-03-14 14 48 56" src="https://user-images.githubusercontent.com/17645053/224918551-9b46b44e-b075-4895-8d33-1aafc7d3c8e5.png"> <img width="901" alt="截屏2023-03-14 14 49 02" src="https://user-images.githubusercontent.com/17645053/224918584-efa66f23-a593-4e26-a3eb-bb1fbc5516ae.png"> <img width="944" alt="截屏2023-03-14 14 49 21" src="https://user-images.githubusercontent.com/17645053/224918591-be60455d-0513-4f66-84f6-b5e1bc40ff91.png"> 6. "Allowed users" in tags settings <img width="935" alt="截屏2023-03-14 14 50 11" src="https://user-images.githubusercontent.com/17645053/224918701-797699aa-c7e5-4290-b3fe-27dcead1c6c7.png">
1 parent 4938945 commit 661e78b

File tree

9 files changed

+23
-18
lines changed

9 files changed

+23
-18
lines changed

modules/templates/helper.go

+3
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ func NewFuncMap() []template.FuncMap {
109109
"CustomEmojis": func() map[string]string {
110110
return setting.UI.CustomEmojisMap
111111
},
112+
"IsShowFullName": func() bool {
113+
return setting.UI.DefaultShowFullName
114+
},
112115
"Safe": Safe,
113116
"SafeJS": SafeJS,
114117
"JSEscape": JSEscape,

templates/repo/issue/list.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
<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>
135135
{{range .Posters}}
136136
<a class="{{if eq $.PosterID .ID}}active selected{{end}} item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{.ID}}">
137-
{{avatar $.Context .}} {{.GetDisplayName}}
137+
{{avatar $.Context .}}{{template "repo/search_name" .}}
138138
</a>
139139
{{end}}
140140
</div>
@@ -154,7 +154,7 @@
154154
<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>
155155
{{range .Assignees}}
156156
<a class="{{if eq $.AssigneeID .ID}}active selected{{end}} item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{.ID}}&poster={{$.PosterID}}">
157-
{{avatar $.Context .}} {{.GetDisplayName}}
157+
{{avatar $.Context .}}{{template "repo/search_name" .}}
158158
</a>
159159
{{end}}
160160
</div>

templates/repo/issue/milestone_issues.tmpl

+6-3
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,14 @@
7070
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
7171
</span>
7272
<div class="menu">
73+
<div class="ui icon search input">
74+
<i class="icon gt-df gt-ac gt-jc">{{svg "octicon-search" 16}}</i>
75+
<input type="text" placeholder="{{.locale.Tr "repo.issues.filter_poster"}}">
76+
</div>
7377
<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>
7478
{{range .Posters}}
7579
<a class="{{if eq $.PosterID .ID}}active selected{{end}} item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&assignee={{$.AssigneeID}}&poster={{.ID}}">
76-
{{avatar $.Context .}} {{.GetDisplayName}}
80+
{{avatar $.Context .}}{{template "repo/search_name" .}}
7781
</a>
7882
{{end}}
7983
</div>
@@ -93,8 +97,7 @@
9397
<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>
9498
{{range .Assignees}}
9599
<a class="{{if eq $.AssigneeID .ID}}active selected{{end}} item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&assignee={{.ID}}&poster={{$.PosterID}}">
96-
{{avatar $.Context . 28 "gt-mr-2"}}
97-
{{.GetDisplayName}}
100+
{{avatar $.Context . 28 "gt-mr-2"}}{{template "repo/search_name" .}}
98101
</a>
99102
{{end}}
100103
</div>

templates/repo/issue/new_form.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
<a class="item muted" href="#" data-id="{{.ID}}" data-id-selector="#assignee_{{.ID}}">
187187
<span class="octicon-check invisible">{{svg "octicon-check"}}</span>
188188
<span class="text">
189-
{{avatar $.Context . 28 "gt-mr-3"}}{{.GetDisplayName}}
189+
{{avatar $.Context . 28 "gt-mr-3"}}{{template "repo/search_name" .}}
190190
</span>
191191
</a>
192192
{{end}}

templates/repo/issue/view_content/sidebar.tmpl

+2-4
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
<a class="{{if not .CanChange}}ui tooltip{{end}} item {{if .Checked}} checked {{end}} {{if not .CanChange}}ban-change{{end}}" href="#" data-id="{{.ItemID}}" data-id-selector="#review_request_{{.ItemID}}" {{if not .CanChange}} data-content="{{$.locale.Tr "repo.issues.remove_request_review_block"}}"{{end}}>
2727
<span class="octicon-check {{if not .Checked}}invisible{{end}}">{{svg "octicon-check"}}</span>
2828
<span class="text">
29-
{{avatar $.Context .User 28 "gt-mr-3"}}
30-
{{.User.GetDisplayName}}
29+
{{avatar $.Context .User 28 "gt-mr-3"}}{{template "repo/search_name" .User}}
3130
</span>
3231
</a>
3332
{{end}}
@@ -258,8 +257,7 @@
258257
{{end}}
259258
<span class="octicon-check {{if not $checked}}invisible{{end}}">{{svg "octicon-check"}}</span>
260259
<span class="text">
261-
{{avatar $.Context . 28 "gt-mr-3"}}
262-
{{.GetDisplayName}}
260+
{{avatar $.Context . 28 "gt-mr-3"}}{{template "repo/search_name" .}}
263261
</span>
264262
</a>
265263
{{end}}

templates/repo/search_name.tmpl

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{.Name}}{{if IsShowFullName}}<span class="search-fullname"> {{.FullName}}</span>{{end}}

templates/repo/settings/protected_branch.tmpl

+3-6
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@
4949
<div class="menu">
5050
{{range .Users}}
5151
<div class="item" data-value="{{.ID}}">
52-
{{avatar $.Context . 28 "mini"}}
53-
{{.GetDisplayName}}
52+
{{avatar $.Context . 28 "mini"}}{{template "repo/search_name" .}}
5453
</div>
5554
{{end}}
5655
</div>
@@ -101,8 +100,7 @@
101100
<div class="menu">
102101
{{range .Users}}
103102
<div class="item" data-value="{{.ID}}">
104-
{{avatar $.Context . 28 "mini"}}
105-
{{.GetDisplayName}}
103+
{{avatar $.Context . 28 "mini"}}{{template "repo/search_name" .}}
106104
</div>
107105
{{end}}
108106
</div>
@@ -181,8 +179,7 @@
181179
<div class="menu">
182180
{{range .Users}}
183181
<div class="item" data-value="{{.ID}}">
184-
{{avatar $.Context . 28 "mini"}}
185-
{{.GetDisplayName}}
182+
{{avatar $.Context . 28 "mini"}}{{template "repo/search_name" .}}
186183
</div>
187184
{{end}}
188185
</div>

templates/repo/settings/tags.tmpl

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@
3636
<div class="menu">
3737
{{range .Users}}
3838
<div class="item" data-value="{{.ID}}">
39-
{{avatar $.Context . 28 "mini"}}
40-
{{.GetDisplayName}}
39+
{{avatar $.Context . 28 "mini"}}{{template "repo/search_name" .}}
4140
</div>
4241
{{end}}
4342
</div>

web_src/css/repository.css

+4
Original file line numberDiff line numberDiff line change
@@ -3627,3 +3627,7 @@ td.blob-excerpt {
36273627
.pr-status .status-details > span {
36283628
padding-right: 0.5em; /* To match the alignment with the "required" label */
36293629
}
3630+
3631+
.search-fullname {
3632+
color: var(--color-text-light-2);
3633+
}

0 commit comments

Comments
 (0)