Skip to content

Commit eec45b4

Browse files
denyskon6543
andauthored
move issue filters to shared template (#25729)
Issue filters are being used on repo list page and on milestone issues page, and the code is mostly duplicated. This PR does the following changes: - move issue filters into a shared template - allow filtering milestone issues by project, so no need to hide this filter on milestone issues page - remove some dead code (e. g. issue actions in milestone issues template) - fix label filter dropdown width --------- Co-authored-by: 6543 <[email protected]>
1 parent ef90fdb commit eec45b4

File tree

6 files changed

+203
-347
lines changed

6 files changed

+203
-347
lines changed

routers/web/repo/milestone.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ func DeleteMilestone(ctx *context.Context) {
264264
// MilestoneIssuesAndPulls lists all the issues and pull requests of the milestone
265265
func MilestoneIssuesAndPulls(ctx *context.Context) {
266266
milestoneID := ctx.ParamsInt64(":id")
267+
projectID := ctx.FormInt64("project")
267268
milestone, err := issues_model.GetMilestoneByRepoID(ctx, ctx.Repo.Repository.ID, milestoneID)
268269
if err != nil {
269270
if issues_model.IsErrMilestoneNotExist(err) {
@@ -289,7 +290,7 @@ func MilestoneIssuesAndPulls(ctx *context.Context) {
289290
ctx.Data["Title"] = milestone.Name
290291
ctx.Data["Milestone"] = milestone
291292

292-
issues(ctx, milestoneID, 0, util.OptionalBoolNone)
293+
issues(ctx, milestoneID, projectID, util.OptionalBoolNone)
293294

294295
ret, _ := issue.GetTemplatesFromDefaultBranch(ctx.Repo.Repository, ctx.Repo.GitRepo)
295296
ctx.Data["NewIssueChooseTemplate"] = len(ret) > 0

templates/repo/issue/filters.tmpl

+194
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
<div id="issue-filters" class="issue-list-toolbar">
2+
<div class="issue-list-toolbar-left">
3+
{{if and ($.CanWriteIssuesOrPulls) (gt (len .Issues) 0)}}
4+
<input type="checkbox" autocomplete="off" class="issue-checkbox-all gt-mr-4" title="{{.locale.Tr "repo.issues.action_check_all"}}">
5+
{{end}}
6+
{{template "repo/issue/openclose" .}}
7+
</div>
8+
<div class="issue-list-toolbar-right">
9+
<div class="ui secondary filter menu labels">
10+
<!-- Label -->
11+
<div class="ui {{if not .Labels}}disabled{{end}} dropdown jump item label-filter">
12+
<span class="text">
13+
{{.locale.Tr "repo.issues.filter_label"}}
14+
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
15+
</span>
16+
<div class="menu">
17+
<div class="ui icon search input">
18+
<i class="icon gt-df gt-ac gt-jc">{{svg "octicon-search" 16}}</i>
19+
<input type="text" placeholder="{{.locale.Tr "repo.issues.filter_label"}}">
20+
</div>
21+
<span class="info">{{.locale.Tr "repo.issues.filter_label_exclude" | Safe}}</span>
22+
<div class="divider"></div>
23+
<a class="item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels=0&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_label_select_no_label"}}</a>
24+
<a class="item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_label_no_select"}}</a>
25+
{{$previousExclusiveScope := "_no_scope"}}
26+
{{range .Labels}}
27+
{{$exclusiveScope := .ExclusiveScope}}
28+
{{if and (ne $previousExclusiveScope $exclusiveScope)}}
29+
<div class="divider"></div>
30+
{{end}}
31+
{{$previousExclusiveScope = $exclusiveScope}}
32+
<a class="item label-filter-item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.QueryString}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}" data-label-id="{{.ID}}">{{if .IsExcluded}}{{svg "octicon-circle-slash"}}{{else if .IsSelected}}{{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}{{end}} {{RenderLabel $.Context .}}</a>
33+
{{end}}
34+
</div>
35+
</div>
36+
37+
{{if not .Milestone}}
38+
<!-- Milestone -->
39+
<div class="ui {{if not (or .OpenMilestones .ClosedMilestones)}}disabled{{end}} dropdown jump item">
40+
<span class="text">
41+
{{.locale.Tr "repo.issues.filter_milestone"}}
42+
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
43+
</span>
44+
<div class="menu">
45+
<div class="ui icon search input">
46+
<i class="icon gt-df gt-ac gt-jc">{{svg "octicon-search" 16}}</i>
47+
<input type="text" placeholder="{{.locale.Tr "repo.issues.filter_milestone"}}">
48+
</div>
49+
<div class="divider"></div>
50+
<a class="{{if not $.MilestoneID}}active selected {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone=0&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_milestone_all"}}</a>
51+
<a class="{{if $.MilestoneID}}{{if eq $.MilestoneID -1}}active selected {{end}}{{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone=-1&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_milestone_none"}}</a>
52+
{{if .OpenMilestones}}
53+
<div class="divider"></div>
54+
<div class="header">{{.locale.Tr "repo.issues.filter_milestone_open"}}</div>
55+
{{range .OpenMilestones}}
56+
<a class="{{if $.MilestoneID}}{{if eq $.MilestoneID .ID}}active selected {{end}}{{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{.ID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">
57+
{{svg "octicon-milestone" 16 "mr-2"}}
58+
{{.Name}}
59+
</a>
60+
{{end}}
61+
{{end}}
62+
{{if .ClosedMilestones}}
63+
<div class="divider"></div>
64+
<div class="header">{{.locale.Tr "repo.issues.filter_milestone_closed"}}</div>
65+
{{range .ClosedMilestones}}
66+
<a class="{{if $.MilestoneID}}{{if eq $.MilestoneID .ID}}active selected {{end}}{{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{.ID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">
67+
{{svg "octicon-milestone" 16 "mr-2"}}
68+
{{.Name}}
69+
</a>
70+
{{end}}
71+
{{end}}
72+
</div>
73+
</div>
74+
{{end}}
75+
76+
<!-- Project -->
77+
<div class="ui{{if not (or .OpenProjects .ClosedProjects)}} disabled{{end}} dropdown jump item">
78+
<span class="text">
79+
{{.locale.Tr "repo.issues.filter_project"}}
80+
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
81+
</span>
82+
<div class="menu">
83+
<div class="ui icon search input">
84+
<i class="icon gt-df gt-ac gt-jc">{{svg "octicon-search" 16}}</i>
85+
<input type="text" placeholder="{{.locale.Tr "repo.issues.filter_project"}}">
86+
</div>
87+
<a class="item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_project_all"}}</a>
88+
<a class="item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&project=-1&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_project_none"}}</a>
89+
{{if .OpenProjects}}
90+
<div class="divider"></div>
91+
<div class="header">
92+
{{.locale.Tr "repo.issues.new.open_projects"}}
93+
</div>
94+
{{range .OpenProjects}}
95+
<a class="{{if $.ProjectID}}{{if eq $.ProjectID .ID}}active selected{{end}}{{end}} item gt-df" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{$.MilestoneID}}&project={{.ID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">
96+
{{svg .IconName 18 "gt-mr-3 gt-shrink-0"}}<span class="gt-ellipsis">{{.Title}}</span>
97+
</a>
98+
{{end}}
99+
{{end}}
100+
{{if .ClosedProjects}}
101+
<div class="divider"></div>
102+
<div class="header">
103+
{{.locale.Tr "repo.issues.new.closed_projects"}}
104+
</div>
105+
{{range .ClosedProjects}}
106+
<a class="{{if $.ProjectID}}{{if eq $.ProjectID .ID}}active selected{{end}}{{end}} item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{$.MilestoneID}}&project={{.ID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">
107+
{{svg .IconName 18 "gt-mr-3"}}{{.Title}}
108+
</a>
109+
{{end}}
110+
{{end}}
111+
</div>
112+
</div>
113+
114+
<!-- Author -->
115+
<div class="ui dropdown jump item user-remote-search" data-tooltip-content="{{.locale.Tr "repo.author_search_tooltip"}}"
116+
data-search-url="{{if .Milestone}}{{$.RepoLink}}/issues/posters{{else}}{{$.Link}}/posters{{end}}"
117+
data-selected-user-id="{{$.PosterID}}"
118+
data-action-jump-url="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={user_id}"
119+
>
120+
<span class="text">
121+
{{.locale.Tr "repo.issues.filter_poster"}}
122+
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
123+
</span>
124+
<div class="menu">
125+
<div class="ui icon search input">
126+
<i class="icon gt-df gt-ac gt-jc">{{svg "octicon-search" 16}}</i>
127+
<input type="text" placeholder="{{.locale.Tr "repo.issues.filter_poster"}}">
128+
</div>
129+
<a class="item" data-value="0">{{.locale.Tr "repo.issues.filter_poster_no_select"}}</a>
130+
</div>
131+
</div>
132+
133+
<!-- Assignee -->
134+
<div class="ui {{if not .Assignees}}disabled{{end}} dropdown jump item">
135+
<span class="text">
136+
{{.locale.Tr "repo.issues.filter_assignee"}}
137+
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
138+
</span>
139+
<div class="menu">
140+
<div class="ui icon search input">
141+
<i class="icon gt-df gt-ac gt-jc">{{svg "octicon-search" 16}}</i>
142+
<input type="text" placeholder="{{.locale.Tr "repo.issues.filter_assignee"}}">
143+
</div>
144+
<a class="item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee=-1&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_assginee_no_assignee"}}</a>
145+
<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>
146+
<div class="divider"></div>
147+
{{range .Assignees}}
148+
<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}}">
149+
{{avatar $.Context . 20}}{{template "repo/search_name" .}}
150+
</a>
151+
{{end}}
152+
</div>
153+
</div>
154+
155+
{{if .IsSigned}}
156+
<!-- Type -->
157+
<div class="ui dropdown type jump item">
158+
<span class="text">
159+
{{.locale.Tr "repo.issues.filter_type"}}
160+
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
161+
</span>
162+
<div class="menu">
163+
<a class="{{if eq .ViewType "all"}}active {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type=all&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_type.all_issues"}}</a>
164+
<a class="{{if eq .ViewType "assigned"}}active {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type=assigned&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_type.assigned_to_you"}}</a>
165+
<a class="{{if eq .ViewType "created_by"}}active {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type=created_by&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_type.created_by_you"}}</a>
166+
{{if .PageIsPullList}}
167+
<a class="{{if eq .ViewType "review_requested"}}active {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type=review_requested&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_type.review_requested"}}</a>
168+
<a class="{{if eq .ViewType "reviewed_by"}}active {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type=reviewed_by&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_type.reviewed_by_you"}}</a>
169+
{{end}}
170+
<a class="{{if eq .ViewType "mentioned"}}active {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type=mentioned&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_type.mentioning_you"}}</a>
171+
</div>
172+
</div>
173+
{{end}}
174+
175+
<!-- Sort -->
176+
<div class="list-header-sort ui small dropdown downward type jump item">
177+
<span class="text">
178+
{{.locale.Tr "repo.issues.filter_sort"}}
179+
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
180+
</span>
181+
<div class="menu">
182+
<a class="{{if or (eq .SortType "latest") (not .SortType)}}active {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort=latest&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_sort.latest"}}</a>
183+
<a class="{{if eq .SortType "oldest"}}active {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort=oldest&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_sort.oldest"}}</a>
184+
<a class="{{if eq .SortType "recentupdate"}}active {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort=recentupdate&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_sort.recentupdate"}}</a>
185+
<a class="{{if eq .SortType "leastupdate"}}active {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort=leastupdate&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_sort.leastupdate"}}</a>
186+
<a class="{{if eq .SortType "mostcomment"}}active {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort=mostcomment&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_sort.mostcomment"}}</a>
187+
<a class="{{if eq .SortType "leastcomment"}}active {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort=leastcomment&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_sort.leastcomment"}}</a>
188+
<a class="{{if eq .SortType "nearduedate"}}active {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort=nearduedate&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_sort.nearduedate"}}</a>
189+
<a class="{{if eq .SortType "farduedate"}}active {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort=farduedate&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_sort.farduedate"}}</a>
190+
</div>
191+
</div>
192+
</div>
193+
</div>
194+
</div>

0 commit comments

Comments
 (0)