Skip to content

Commit 0dcb4a1

Browse files
committed
fix
1 parent 5675efb commit 0dcb4a1

File tree

15 files changed

+242
-266
lines changed

15 files changed

+242
-266
lines changed

modules/templates/helper.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func NewFuncMap() template.FuncMap {
4242
"HTMLFormat": htmlutil.HTMLFormat,
4343
"HTMLEscape": htmlEscape,
4444
"QueryEscape": queryEscape,
45-
"QueryBuild": queryBuild,
45+
"QueryBuild": QueryBuild,
4646
"JSEscape": jsEscapeSafe,
4747
"SanitizeHTML": SanitizeHTML,
4848
"URLJoin": util.URLJoin,
@@ -294,24 +294,24 @@ func timeEstimateString(timeSec any) string {
294294
return util.TimeEstimateString(v)
295295
}
296296

297-
func queryBuild(a ...any) template.URL {
297+
func QueryBuild(a ...any) template.URL {
298298
var s string
299299
if len(a)%2 == 1 {
300300
if v, ok := a[0].(string); ok {
301301
if v == "" || (v[0] != '?' && v[0] != '&') {
302-
panic("queryBuild: invalid argument")
302+
panic("QueryBuild: invalid argument")
303303
}
304304
s = v
305305
} else if v, ok := a[0].(template.URL); ok {
306306
s = string(v)
307307
} else {
308-
panic("queryBuild: invalid argument")
308+
panic("QueryBuild: invalid argument")
309309
}
310310
}
311311
for i := len(a) % 2; i < len(a); i += 2 {
312312
k, ok := a[i].(string)
313313
if !ok {
314-
panic("queryBuild: invalid argument")
314+
panic("QueryBuild: invalid argument")
315315
}
316316
var v string
317317
if va, ok := a[i+1].(string); ok {

options/locale/locale_en-US.ini

+3-2
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,7 @@ delete_preexisting_success = Deleted unadopted files in %s
11091109
blame_prior = View blame prior to this change
11101110
blame.ignore_revs = Ignoring revisions in <a href="%s">.git-blame-ignore-revs</a>. Click <a href="%s">here to bypass</a> and see the normal blame view.
11111111
blame.ignore_revs.failed = Failed to ignore revisions in <a href="%s">.git-blame-ignore-revs</a>.
1112-
author_search_tooltip = Shows a maximum of 30 users
1112+
user_search_tooltip = Shows a maximum of 30 users
11131113
11141114
tree_path_not_found_commit = Path %[1]s doesn't exist in commit %[2]s
11151115
tree_path_not_found_branch = Path %[1]s doesn't exist in branch %[2]s
@@ -1529,7 +1529,8 @@ issues.filter_assignee = Assignee
15291529
issues.filter_assginee_no_select = All assignees
15301530
issues.filter_assginee_no_assignee = No assignee
15311531
issues.filter_poster = Author
1532-
issues.filter_poster_no_select = All authors
1532+
issues.filter_user_placeholder = Search users
1533+
issues.filter_user_no_select = All users
15331534
issues.filter_type = Type
15341535
issues.filter_type.all_issues = All issues
15351536
issues.filter_type.assigned_to_you = Assigned to you

routers/web/org/projects.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -339,12 +339,7 @@ func ViewProject(ctx *context.Context) {
339339
// 0 means issues with no label
340340
// blank means labels will not be filtered for issues
341341
selectLabels := ctx.FormString("labels")
342-
if selectLabels == "" {
343-
ctx.Data["AllLabels"] = true
344-
} else if selectLabels == "0" {
345-
ctx.Data["NoLabel"] = true
346-
}
347-
if len(selectLabels) > 0 {
342+
if selectLabels != "" {
348343
labelIDs, err = base.StringsToInt64s(strings.Split(selectLabels, ","))
349344
if err != nil {
350345
ctx.Flash.Error(ctx.Tr("invalid_data", selectLabels), true)

routers/web/repo/issue_list.go

+22-22
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"bytes"
88
"fmt"
99
"net/http"
10-
"net/url"
1110
"strconv"
1211
"strings"
1312

@@ -23,6 +22,7 @@ import (
2322
"code.gitea.io/gitea/modules/log"
2423
"code.gitea.io/gitea/modules/optional"
2524
"code.gitea.io/gitea/modules/setting"
25+
"code.gitea.io/gitea/modules/templates"
2626
"code.gitea.io/gitea/modules/util"
2727
shared_user "code.gitea.io/gitea/routers/web/shared/user"
2828
"code.gitea.io/gitea/services/context"
@@ -531,12 +531,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption opt
531531
// 0 means issues with no label
532532
// blank means labels will not be filtered for issues
533533
selectLabels := ctx.FormString("labels")
534-
if selectLabels == "" {
535-
ctx.Data["AllLabels"] = true
536-
} else if selectLabels == "0" {
537-
ctx.Data["NoLabel"] = true
538-
}
539-
if len(selectLabels) > 0 {
534+
if selectLabels != "" {
540535
labelIDs, err = base.StringsToInt64s(strings.Split(selectLabels, ","))
541536
if err != nil {
542537
ctx.Flash.Error(ctx.Tr("invalid_data", selectLabels), true)
@@ -616,8 +611,6 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption opt
616611
ctx.Data["TotalTrackedTime"] = totalTrackedTime
617612
}
618613

619-
archived := ctx.FormBool("archived")
620-
621614
page := ctx.FormInt("page")
622615
if page <= 1 {
623616
page = 1
@@ -792,21 +785,28 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption opt
792785
return
793786
}
794787

788+
showArchivedLabels := ctx.FormBool("archived_labels")
789+
ctx.Data["ShowArchivedLabels"] = showArchivedLabels
795790
ctx.Data["PinnedIssues"] = pinned
796791
ctx.Data["IsRepoAdmin"] = ctx.IsSigned && (ctx.Repo.IsAdmin() || ctx.Doer.IsAdmin)
797792
ctx.Data["IssueStats"] = issueStats
798793
ctx.Data["OpenCount"] = issueStats.OpenCount
799794
ctx.Data["ClosedCount"] = issueStats.ClosedCount
800-
linkStr := "%s?q=%s&type=%s&sort=%s&state=%s&labels=%s&milestone=%d&project=%d&assignee=%d&poster=%v&archived=%t"
801-
ctx.Data["AllStatesLink"] = fmt.Sprintf(linkStr, ctx.Link,
802-
url.QueryEscape(keyword), url.QueryEscape(viewType), url.QueryEscape(sortType), "all", url.QueryEscape(selectLabels),
803-
milestoneID, projectID, assigneeID, url.QueryEscape(posterUsername), archived)
804-
ctx.Data["OpenLink"] = fmt.Sprintf(linkStr, ctx.Link,
805-
url.QueryEscape(keyword), url.QueryEscape(viewType), url.QueryEscape(sortType), "open", url.QueryEscape(selectLabels),
806-
milestoneID, projectID, assigneeID, url.QueryEscape(posterUsername), archived)
807-
ctx.Data["ClosedLink"] = fmt.Sprintf(linkStr, ctx.Link,
808-
url.QueryEscape(keyword), url.QueryEscape(viewType), url.QueryEscape(sortType), "closed", url.QueryEscape(selectLabels),
809-
milestoneID, projectID, assigneeID, url.QueryEscape(posterUsername), archived)
795+
linkStrQuery := templates.QueryBuild("?",
796+
"q", keyword,
797+
"type", viewType,
798+
"sort", sortType,
799+
"state", ctx.FormString("state"),
800+
"labels", selectLabels,
801+
"milestone", milestoneID,
802+
"project", projectID,
803+
"assignee", assigneeID,
804+
"poster", posterUsername,
805+
"archived_labels", util.Iif(showArchivedLabels, "true", ""),
806+
)
807+
ctx.Data["AllStatesLink"] = ctx.Link + string(templates.QueryBuild(linkStrQuery, "state", "all"))
808+
ctx.Data["OpenLink"] = ctx.Link + string(templates.QueryBuild(linkStrQuery, "state", "open"))
809+
ctx.Data["ClosedLink"] = ctx.Link + string(templates.QueryBuild(linkStrQuery, "state", "closed"))
810810
ctx.Data["SelLabelIDs"] = labelIDs
811811
ctx.Data["SelectLabels"] = selectLabels
812812
ctx.Data["ViewType"] = viewType
@@ -825,7 +825,6 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption opt
825825
default:
826826
ctx.Data["State"] = "open"
827827
}
828-
ctx.Data["ShowArchivedLabels"] = archived
829828

830829
pager.AddParamString("q", keyword)
831830
pager.AddParamString("type", viewType)
@@ -836,8 +835,9 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption opt
836835
pager.AddParamString("project", fmt.Sprint(projectID))
837836
pager.AddParamString("assignee", fmt.Sprint(assigneeID))
838837
pager.AddParamString("poster", posterUsername)
839-
pager.AddParamString("archived", fmt.Sprint(archived))
840-
838+
if showArchivedLabels {
839+
pager.AddParamString("archived_labels", "true")
840+
}
841841
ctx.Data["Page"] = pager
842842
}
843843

routers/web/repo/projects.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,7 @@ func ViewProject(ctx *context.Context) {
312312
// 0 means issues with no label
313313
// blank means labels will not be filtered for issues
314314
selectLabels := ctx.FormString("labels")
315-
if selectLabels == "" {
316-
ctx.Data["AllLabels"] = true
317-
} else if selectLabels == "0" {
318-
ctx.Data["NoLabel"] = true
319-
}
320-
if len(selectLabels) > 0 {
315+
if selectLabels != "" {
321316
labelIDs, err = base.StringsToInt64s(strings.Split(selectLabels, ","))
322317
if err != nil {
323318
ctx.Flash.Error(ctx.Tr("invalid_data", selectLabels), true)

templates/projects/view.tmpl

+5-54
Original file line numberDiff line numberDiff line change
@@ -5,57 +5,8 @@
55
<h2 class="tw-mb-0 tw-flex-1 tw-break-anywhere">{{.Project.Title}}</h2>
66
<div class="project-toolbar-right">
77
<div class="ui secondary filter menu labels">
8-
<!-- Label -->
9-
<div class="ui {{if not .Labels}}disabled{{end}} dropdown jump item label-filter">
10-
<span class="text">
11-
{{ctx.Locale.Tr "repo.issues.filter_label"}}
12-
</span>
13-
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
14-
<div class="menu">
15-
<div class="ui icon search input">
16-
<i class="icon">{{svg "octicon-search" 16}}</i>
17-
<input type="text" placeholder="{{ctx.Locale.Tr "repo.issues.filter_label"}}">
18-
</div>
19-
<div class="ui checkbox compact archived-label-filter">
20-
<input name="archived" type="checkbox"
21-
id="archived-filter-checkbox"
22-
{{if .ShowArchivedLabels}}checked{{end}}
23-
>
24-
<label for="archived-filter-checkbox">
25-
{{ctx.Locale.Tr "repo.issues.label_archived_filter"}}
26-
<i class="tw-ml-1" data-tooltip-content={{ctx.Locale.Tr "repo.issues.label_archive_tooltip"}}>
27-
{{svg "octicon-info"}}
28-
</i>
29-
</label>
30-
</div>
31-
<span class="info">{{ctx.Locale.Tr "repo.issues.filter_label_exclude"}}</span>
32-
<div class="divider"></div>
33-
<a class="{{if .AllLabels}}active selected {{end}}item" href="?assignee={{$.AssigneeID}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_label_no_select"}}</a>
34-
<a class="{{if .NoLabel}}active selected {{end}}item" href="?assignee={{$.AssigneeID}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_label_select_no_label"}}</a>
35-
{{$previousExclusiveScope := "_no_scope"}}
36-
{{range .Labels}}
37-
{{$exclusiveScope := .ExclusiveScope}}
38-
{{if and (ne $previousExclusiveScope $exclusiveScope)}}
39-
<div class="divider" data-scope="{{.ExclusiveScope}}"></div>
40-
{{end}}
41-
{{$previousExclusiveScope = $exclusiveScope}}
42-
<a class="item label-filter-item tw-flex tw-items-center" data-label-id="{{.ID}}" data-scope="{{.ExclusiveScope}}" {{if .IsArchived}}data-is-archived{{end}}
43-
href="?labels={{.QueryString}}&assignee={{$.AssigneeID}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">
44-
{{if .IsExcluded}}
45-
{{svg "octicon-circle-slash"}}
46-
{{else if .IsSelected}}
47-
{{if $exclusiveScope}}
48-
{{svg "octicon-dot-fill"}}
49-
{{else}}
50-
{{svg "octicon-check"}}
51-
{{end}}
52-
{{end}}
53-
{{ctx.RenderUtils.RenderLabel .}}
54-
<p class="tw-ml-auto">{{template "repo/issue/labels/label_archived" .}}</p>
55-
</a>
56-
{{end}}
57-
</div>
58-
</div>
8+
{{$queryLink := QueryBuild "?" "labels" .SelectLabels "assignee" (Iif $.AssigneeID $.AssigneeID) "archived_labels" (Iif $.ShowArchivedLabels NIL)}}
9+
{{template "repo/issue/filter_item_label" dict "Labels" .Labels "QueryLink" $queryLink "SupportArchivedLabel" true}}
5910

6011
<!-- Assignee -->
6112
<div class="ui {{if not .Assignees}}disabled{{end}} dropdown jump item">
@@ -68,11 +19,11 @@
6819
<i class="icon">{{svg "octicon-search" 16}}</i>
6920
<input type="text" placeholder="{{ctx.Locale.Tr "repo.issues.filter_assignee"}}">
7021
</div>
71-
<a class="{{if not .AssigneeID}}active selected {{end}}item" href="?labels={{.SelectLabels}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_assginee_no_select"}}</a>
72-
<a class="{{if eq .AssigneeID -1}}active selected {{end}}item" href="?labels={{.SelectLabels}}&assignee=-1{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_assginee_no_assignee"}}</a>
22+
<a class="{{if not .AssigneeID}}selected {{end}}item" href="{{QueryBuild $queryLink "assignee" NIL}}">{{ctx.Locale.Tr "repo.issues.filter_assginee_no_select"}}</a>
23+
<a class="{{if eq .AssigneeID -1}}selected {{end}}item" href="{{QueryBuild $queryLink "assignee" -1}}">{{ctx.Locale.Tr "repo.issues.filter_assginee_no_assignee"}}</a>
7324
<div class="divider"></div>
7425
{{range .Assignees}}
75-
<a class="{{if eq $.AssigneeID .ID}}active selected{{end}} item tw-flex" href="?labels={{$.SelectLabels}}&assignee={{.ID}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">
26+
<a class="{{if eq $.AssigneeID .ID}}selected{{end}} item tw-flex" href="{{QueryBuild $queryLink "assignee" .ID}}">
7627
{{ctx.AvatarUtils.Avatar . 20}}{{template "repo/search_name" .}}
7728
</a>
7829
{{end}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{{/*
2+
* "labels" from query string
3+
* QueryLink
4+
* Labels
5+
* SupportArchivedLabel, if true, then it needs "archived_labes" from query string
6+
*/}}
7+
{{$queryLink := .QueryLink}}
8+
<div class="item ui {{if not .Labels}}disabled{{end}} dropdown jump label-filter">
9+
<span class="text">{{ctx.Locale.Tr "repo.issues.filter_label"}}</span>
10+
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
11+
<div class="menu flex-items-menu">
12+
<div class="ui icon search input">
13+
<i class="icon">{{svg "octicon-search" 16}}</i>
14+
<input type="text" placeholder="{{ctx.Locale.Tr "repo.issues.filter_label"}}">
15+
</div>
16+
{{if .SupportArchivedLabel}}{{/* this checkbox has a hard dependency with the "labels" and "archived_label" query parameter */}}
17+
<label class="label-filter-archived-toggle flex-text-block">
18+
<input type="checkbox"> {{ctx.Locale.Tr "repo.issues.label_archived_filter"}}
19+
<span data-tooltip-content={{ctx.Locale.Tr "repo.issues.label_archive_tooltip"}}>{{svg "octicon-info"}}</span>
20+
</label>
21+
{{end}}
22+
<span class="info">{{ctx.Locale.Tr "repo.issues.filter_label_exclude"}}</span>
23+
<div class="divider"></div>
24+
<a class="item label-filter-query-default" href="{{QueryBuild $queryLink "labels" NIL}}">{{ctx.Locale.Tr "repo.issues.filter_label_no_select"}}</a>
25+
<a class="item label-filter-query-not-set" href="{{QueryBuild $queryLink "labels" 0}}">{{ctx.Locale.Tr "repo.issues.filter_label_select_no_label"}}</a>
26+
{{$previousExclusiveScope := "_no_scope"}}
27+
{{range .Labels}}
28+
{{$exclusiveScope := .ExclusiveScope}}
29+
{{if and (ne $previousExclusiveScope $exclusiveScope)}}
30+
<div class="divider" data-scope="{{.ExclusiveScope}}"></div>
31+
{{end}}
32+
{{$previousExclusiveScope = $exclusiveScope}}
33+
<a class="item label-filter-query-item" data-label-id="{{.ID}}" data-scope="{{.ExclusiveScope}}" {{if .IsArchived}}data-is-archived{{end}}
34+
href="{{QueryBuild $queryLink "labels" .QueryString}}">
35+
{{if .IsExcluded}}
36+
{{svg "octicon-circle-slash"}}
37+
{{else if .IsSelected}}
38+
{{Iif $exclusiveScope (svg "octicon-dot-fill") (svg "octicon-check")}}
39+
{{end}}
40+
{{ctx.RenderUtils.RenderLabel .}}
41+
<p class="tw-ml-auto">{{template "repo/issue/labels/label_archived" .}}</p>
42+
</a>
43+
{{end}}
44+
</div>
45+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{{/*
2+
* QueryLink
3+
* UserSearchUrl
4+
* SelectedUserId
5+
* TextFilterTitle
6+
* QueryParamKey: eg: "poster", "assignee"
7+
*/}}
8+
{{$queryLink := .QueryLink}}
9+
<div class="item ui dropdown custom user-remote-search" data-tooltip-content="{{ctx.Locale.Tr "repo.user_search_tooltip"}}"
10+
data-search-url="{{$.UserSearchUrl}}"
11+
data-selected-user-id="{{$.SelectedUserId}}"
12+
data-action-jump-url="{{QueryBuild $queryLink $.QueryParamKey NIL}}&{{$.QueryParamKey}}={username}"
13+
>
14+
{{$.TextFilterTitle}} {{svg "octicon-triangle-down" 14 "dropdown icon"}}
15+
<div class="menu">
16+
<div class="ui icon search input">
17+
<i class="icon">{{svg "octicon-search" 16}}</i>
18+
<input type="text" placeholder="{{ctx.Locale.Tr "repo.issues.filter_user_placeholder"}}">
19+
</div>
20+
<a class="item" data-value="">{{ctx.Locale.Tr "repo.issues.filter_user_no_select"}}</a>
21+
<a class="item item-from-input tw-hidden"></a>
22+
</div>
23+
</div>

0 commit comments

Comments
 (0)