Skip to content

Commit d581a20

Browse files
committed
use GetSearchNameHTML instead of passing contexts
1 parent c110521 commit d581a20

File tree

12 files changed

+19
-30
lines changed

12 files changed

+19
-30
lines changed

models/user/user.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"context"
99
"encoding/hex"
1010
"fmt"
11+
"html/template"
1112
"net/url"
1213
"os"
1314
"path/filepath"
@@ -420,6 +421,13 @@ func (u *User) GetDisplayName() string {
420421
return u.Name
421422
}
422423

424+
func (u *User) GetSearchNameHTML() template.HTML {
425+
if setting.UI.DefaultShowFullName {
426+
return template.HTML(fmt.Sprintf(`%s<span class="text search-fullname"> %s</span>`, u.Name, strings.TrimSpace(u.FullName)))
427+
}
428+
return template.HTML(u.Name)
429+
}
430+
423431
func gitSafeName(name string) string {
424432
return strings.TrimSpace(strings.NewReplacer("\n", "", "<", "", ">", "").Replace(name))
425433
}

routers/web/repo/compare.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -826,8 +826,6 @@ func CompareDiff(ctx *context.Context) {
826826
ctx.Data["AllowMaintainerEdit"] = false
827827
}
828828

829-
ctx.Data["IsShowFullName"] = setting.UI.DefaultShowFullName
830-
831829
ctx.HTML(http.StatusOK, tplCompare)
832830
}
833831

routers/web/repo/issue.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,6 @@ func Issues(ctx *context.Context) {
455455
}
456456

457457
ctx.Data["CanWriteIssuesOrPulls"] = ctx.Repo.CanWriteIssuesOrPulls(isPullList)
458-
ctx.Data["IsShowFullName"] = setting.UI.DefaultShowFullName
459458

460459
ctx.HTML(http.StatusOK, tplIssues)
461460
}
@@ -907,7 +906,6 @@ func NewIssue(ctx *context.Context) {
907906
}
908907

909908
ctx.Data["HasIssuesOrPullsWritePermission"] = ctx.Repo.CanWrite(unit.TypeIssues)
910-
ctx.Data["IsShowFullName"] = setting.UI.DefaultShowFullName
911909

912910
ctx.HTML(http.StatusOK, tplIssueNew)
913911
}
@@ -1836,7 +1834,6 @@ func ViewIssue(ctx *context.Context) {
18361834
ctx.Data["IsRepoAdmin"] = ctx.IsSigned && (ctx.Repo.IsAdmin() || ctx.Doer.IsAdmin)
18371835
ctx.Data["LockReasons"] = setting.Repository.Issue.LockReasons
18381836
ctx.Data["RefEndName"] = git.RefEndName(issue.Ref)
1839-
ctx.Data["IsShowFullName"] = setting.UI.DefaultShowFullName
18401837

18411838
var hiddenCommentTypes *big.Int
18421839
if ctx.IsSigned {

routers/web/repo/milestone.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,5 @@ func MilestoneIssuesAndPulls(ctx *context.Context) {
294294
ctx.Data["CanWriteIssues"] = ctx.Repo.CanWriteIssuesOrPulls(false)
295295
ctx.Data["CanWritePulls"] = ctx.Repo.CanWriteIssuesOrPulls(true)
296296

297-
ctx.Data["IsShowFullName"] = setting.UI.DefaultShowFullName
298-
299297
ctx.HTML(http.StatusOK, tplMilestoneIssues)
300298
}

routers/web/repo/setting_protected_branch.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ func SettingsProtectedBranch(c *context.Context) {
152152
}
153153

154154
c.Data["Rule"] = rule
155-
c.Data["IsShowFullName"] = setting.UI.DefaultShowFullName
156155
c.HTML(http.StatusOK, tplProtectedBranch)
157156
}
158157

routers/web/repo/tag.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ func Tags(ctx *context.Context) {
2424
if setTagsContext(ctx) != nil {
2525
return
2626
}
27-
ctx.Data["IsShowFullName"] = setting.UI.DefaultShowFullName
2827

2928
ctx.HTML(http.StatusOK, tplTags)
3029
}

templates/repo/issue/list.tmpl

Lines changed: 2 additions & 2 deletions
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 .}} {{.Name}} {{if $.IsShowFullName}}<span class="search-fullname">{{.FullName}}</span>{{end}}
137+
{{avatar $.Context .}}{{.GetSearchNameHTML}}
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 .}} {{.Name}} {{if $.IsShowFullName}}<span class="search-fullname">{{.FullName}}</span>{{end}}
157+
{{avatar $.Context .}}{{.GetSearchNameHTML}}
158158
</a>
159159
{{end}}
160160
</div>

templates/repo/issue/milestone_issues.tmpl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
<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>
7878
{{range .Posters}}
7979
<a class="{{if eq $.PosterID .ID}}active selected{{end}} item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&assignee={{$.AssigneeID}}&poster={{.ID}}">
80-
{{avatar $.Context .}} {{.Name}} {{if $.IsShowFullName}}<span class="search-fullname">{{.FullName}}</span>{{end}}
80+
{{avatar $.Context .}}{{.GetSearchNameHTML}}
8181
</a>
8282
{{end}}
8383
</div>
@@ -97,9 +97,7 @@
9797
<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>
9898
{{range .Assignees}}
9999
<a class="{{if eq $.AssigneeID .ID}}active selected{{end}} item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&assignee={{.ID}}&poster={{$.PosterID}}">
100-
{{avatar $.Context . 28 "gt-mr-2"}}
101-
{{.Name}}
102-
{{if $.IsShowFullName}}<span class="search-fullname">{{.FullName}}</span>{{end}}
100+
{{avatar $.Context . 28 "gt-mr-2"}}{{.GetSearchNameHTML}}
103101
</a>
104102
{{end}}
105103
</div>

templates/repo/issue/new_form.tmpl

Lines changed: 1 addition & 1 deletion
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"}}{{.Name}} {{if $.IsShowFullName}}<span class="search-fullname">{{.FullName}}</span>{{end}}
189+
{{avatar $.Context . 28 "gt-mr-3"}}{{.GetSearchNameHTML}}
190190
</span>
191191
</a>
192192
{{end}}

templates/repo/issue/view_content/sidebar.tmpl

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@
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.Name}}
29+
{{avatar $.Context .User 28 "gt-mr-3"}}{{.User.GetSearchNameHTML}}
3130
</span>
32-
{{if $.IsShowFullName}}<span class="text search-fullname">{{.User.FullName}}</span>{{end}}
3331
</a>
3432
{{end}}
3533
{{end}}
@@ -259,10 +257,8 @@
259257
{{end}}
260258
<span class="octicon-check {{if not $checked}}invisible{{end}}">{{svg "octicon-check"}}</span>
261259
<span class="text">
262-
{{avatar $.Context . 28 "gt-mr-3"}}
263-
{{.Name}}
260+
{{avatar $.Context . 28 "gt-mr-3"}}{{.GetSearchNameHTML}}
264261
</span>
265-
{{if $.IsShowFullName}}<span class="text search-fullname">{{.FullName}}</span>{{end}}
266262
</a>
267263
{{end}}
268264
</div>

templates/repo/settings/protected_branch.tmpl

Lines changed: 3 additions & 6 deletions
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-
{{.Name}} {{if $.IsShowFullName}}<span class="search-fullname">{{.FullName}}</span>{{end}}
52+
{{avatar $.Context . 28 "mini"}}{{.GetSearchNameHTML}}
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-
{{.Name}} {{if $.IsShowFullName}}<span class="search-fullname">{{.FullName}}</span>{{end}}
103+
{{avatar $.Context . 28 "mini"}}{{.GetSearchNameHTML}}
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-
{{.Name}} {{if $.IsShowFullName}}<span class="search-fullname">{{.FullName}}</span>{{end}}
182+
{{avatar $.Context . 28 "mini"}}{{.GetSearchNameHTML}}
186183
</div>
187184
{{end}}
188185
</div>

templates/repo/settings/tags.tmpl

Lines changed: 1 addition & 2 deletions
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-
{{.Name}} {{if $.IsShowFullName}}<span class="search-fullname">{{.FullName}}</span>{{end}}
39+
{{avatar $.Context . 28 "mini"}}{{.GetSearchNameHTML}}
4140
</div>
4241
{{end}}
4342
</div>

0 commit comments

Comments
 (0)