Skip to content

Commit 8abc1aa

Browse files
yp05327puni9869
andauthored
Improve the list header in milestone page (go-gitea#27302)
The ui of list header in milestone page is not same as issue and pr list page. And they are using different template codes which can be merged into one. Before: ![image](https://github.com/go-gitea/gitea/assets/18380374/29eb426c-2dd6-4cf2-96e0-82339fb631bb) ![image](https://github.com/go-gitea/gitea/assets/18380374/b36c4dff-469a-4395-8a02-a8c54e17ab21) ![image](https://github.com/go-gitea/gitea/assets/18380374/d882c74a-451b-431d-b58e-3635a15d9718) ![image](https://github.com/go-gitea/gitea/assets/18380374/292cd38d-1b50-47f1-b32c-9b5de90ce5fb) After: ![image](https://github.com/go-gitea/gitea/assets/18380374/4529234e-67dc-4e17-9440-e638be4fbc41) ![image](https://github.com/go-gitea/gitea/assets/18380374/c15b4d86-0762-497b-b28d-72d09443d629) --------- Co-authored-by: puni9869 <80308335+puni9869@users.noreply.github.com>
1 parent eeb1e02 commit 8abc1aa

File tree

8 files changed

+264
-261
lines changed

8 files changed

+264
-261
lines changed

routers/web/repo/issue.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
246246
isShowClosed = true
247247
}
248248

249+
archived := ctx.FormBool("archived")
250+
249251
page := ctx.FormInt("page")
250252
if page <= 1 {
251253
page = 1
@@ -417,6 +419,15 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
417419
ctx.Data["PinnedIssues"] = pinned
418420
ctx.Data["IsRepoAdmin"] = ctx.IsSigned && (ctx.Repo.IsAdmin() || ctx.Doer.IsAdmin)
419421
ctx.Data["IssueStats"] = issueStats
422+
ctx.Data["OpenCount"] = issueStats.OpenCount
423+
ctx.Data["ClosedCount"] = issueStats.ClosedCount
424+
linkStr := "%s?q=%s&type=%s&sort=%s&state=%s&labels=%s&milestone=%d&project=%d&assignee=%d&poster=%d&archived=%t"
425+
ctx.Data["OpenLink"] = fmt.Sprintf(linkStr, ctx.Link,
426+
url.QueryEscape(keyword), url.QueryEscape(viewType), url.QueryEscape(sortType), "open", url.QueryEscape(selectLabels),
427+
mentionedID, projectID, assigneeID, posterID, archived)
428+
ctx.Data["ClosedLink"] = fmt.Sprintf(linkStr, ctx.Link,
429+
url.QueryEscape(keyword), url.QueryEscape(viewType), url.QueryEscape(sortType), "closed", url.QueryEscape(selectLabels),
430+
mentionedID, projectID, assigneeID, posterID, archived)
420431
ctx.Data["SelLabelIDs"] = labelIDs
421432
ctx.Data["SelectLabels"] = selectLabels
422433
ctx.Data["ViewType"] = viewType
@@ -432,6 +443,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
432443
} else {
433444
ctx.Data["State"] = "open"
434445
}
446+
ctx.Data["ShowArchivedLabels"] = archived
435447

436448
pager.AddParam(ctx, "q", "Keyword")
437449
pager.AddParam(ctx, "type", "ViewType")
@@ -442,11 +454,8 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
442454
pager.AddParam(ctx, "project", "ProjectID")
443455
pager.AddParam(ctx, "assignee", "AssigneeID")
444456
pager.AddParam(ctx, "poster", "PosterID")
457+
pager.AddParam(ctx, "archived", "ShowArchivedLabels")
445458

446-
if ctx.FormBool("archived") {
447-
ctx.Data["ShowArchivedLabels"] = true
448-
pager.AddParam(ctx, "archived", "ShowArchivedLabels")
449-
}
450459
ctx.Data["Page"] = pager
451460
}
452461

routers/web/repo/milestone.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package repo
55

66
import (
7+
"fmt"
78
"net/http"
89
"net/url"
910
"time"
@@ -72,6 +73,11 @@ func Milestones(ctx *context.Context) {
7273
}
7374
ctx.Data["OpenCount"] = stats.OpenCount
7475
ctx.Data["ClosedCount"] = stats.ClosedCount
76+
linkStr := "%s/milestones?state=%s&q=%s&sort=%s"
77+
ctx.Data["OpenLink"] = fmt.Sprintf(linkStr, ctx.Repo.RepoLink, "open",
78+
url.QueryEscape(keyword), url.QueryEscape(sortType))
79+
ctx.Data["ClosedLink"] = fmt.Sprintf(linkStr, ctx.Repo.RepoLink, "closed",
80+
url.QueryEscape(keyword), url.QueryEscape(sortType))
7581

7682
if ctx.Repo.Repository.IsTimetrackerEnabled(ctx) {
7783
if err := miles.LoadTotalTrackedTimes(ctx); err != nil {

templates/repo/issue/filter_list.tmpl

Lines changed: 206 additions & 0 deletions
Large diffs are not rendered by default.

templates/repo/issue/filters.tmpl

Lines changed: 4 additions & 205 deletions
Large diffs are not rendered by default.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!-- Sort -->
2+
<div class="list-header-sort ui small dropdown type jump item">
3+
<span class="text">
4+
{{ctx.Locale.Tr "repo.issues.filter_sort"}}
5+
</span>
6+
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
7+
<div class="menu">
8+
<a class="{{if or (eq .SortType "closestduedate") (not .SortType)}}active {{end}}item" href="{{$.Link}}?sort=closestduedate&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.milestones.filter_sort.earliest_due_data"}}</a>
9+
<a class="{{if eq .SortType "furthestduedate"}}active {{end}}item" href="{{$.Link}}?sort=furthestduedate&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.milestones.filter_sort.latest_due_date"}}</a>
10+
<a class="{{if eq .SortType "leastcomplete"}}active {{end}}item" href="{{$.Link}}?sort=leastcomplete&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.milestones.filter_sort.least_complete"}}</a>
11+
<a class="{{if eq .SortType "mostcomplete"}}active {{end}}item" href="{{$.Link}}?sort=mostcomplete&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.milestones.filter_sort.most_complete"}}</a>
12+
<a class="{{if eq .SortType "mostissues"}}active {{end}}item" href="{{$.Link}}?sort=mostissues&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.milestones.filter_sort.most_issues"}}</a>
13+
<a class="{{if eq .SortType "leastissues"}}active {{end}}item" href="{{$.Link}}?sort=leastissues&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.milestones.filter_sort.least_issues"}}</a>
14+
</div>
15+
</div>

templates/repo/issue/milestones.tmpl

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,17 @@
22
<div role="main" aria-label="{{.Title}}" class="page-content repository milestones">
33
{{template "repo/header" .}}
44
<div class="ui container">
5-
<div class="navbar gt-mb-4">
5+
{{template "base/alert" .}}
6+
7+
<div class="list-header">
68
{{template "repo/issue/navbar" .}}
9+
{{template "repo/issue/search" .}}
710
{{if and (or .CanWriteIssues .CanWritePulls) (not .Repository.IsArchived)}}
811
<a class="ui small primary button" href="{{$.Link}}/new">{{ctx.Locale.Tr "repo.milestones.new"}}</a>
912
{{end}}
1013
</div>
11-
{{template "base/alert" .}}
1214

13-
<div class="list-header">
14-
<div class="small-menu-items ui compact tiny menu list-header-toggle">
15-
<a class="item{{if not .IsShowClosed}} active{{end}}" href="{{.RepoLink}}/milestones?state=open&q={{$.Keyword}}">
16-
{{svg "octicon-milestone" 16 "gt-mr-3"}}
17-
{{ctx.Locale.PrettyNumber .OpenCount}}&nbsp;{{ctx.Locale.Tr "repo.issues.open_title"}}
18-
</a>
19-
<a class="item{{if .IsShowClosed}} active{{end}}" href="{{.RepoLink}}/milestones?state=closed&q={{$.Keyword}}">
20-
{{svg "octicon-check" 16 "gt-mr-3"}}
21-
{{ctx.Locale.PrettyNumber .ClosedCount}}&nbsp;{{ctx.Locale.Tr "repo.issues.closed_title"}}
22-
</a>
23-
</div>
24-
25-
<!-- Search -->
26-
<form class="list-header-search ui form ignore-dirty">
27-
<div class="ui small search fluid action input">
28-
<input type="hidden" name="state" value="{{$.State}}">
29-
{{template "shared/searchinput" dict "Value" .Keyword}}
30-
<button class="ui small icon button" type="submit" aria-label="{{ctx.Locale.Tr "explore.search"}}">
31-
{{svg "octicon-search"}}
32-
</button>
33-
</div>
34-
</form>
35-
36-
<!-- Sort -->
37-
<div class="list-header-sort ui small dropdown type jump item">
38-
<span class="text">
39-
{{ctx.Locale.Tr "repo.issues.filter_sort"}}
40-
</span>
41-
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
42-
<div class="menu">
43-
<a class="{{if or (eq .SortType "closestduedate") (not .SortType)}}active {{end}}item" href="{{$.Link}}?sort=closestduedate&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.milestones.filter_sort.earliest_due_data"}}</a>
44-
<a class="{{if eq .SortType "furthestduedate"}}active {{end}}item" href="{{$.Link}}?sort=furthestduedate&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.milestones.filter_sort.latest_due_date"}}</a>
45-
<a class="{{if eq .SortType "leastcomplete"}}active {{end}}item" href="{{$.Link}}?sort=leastcomplete&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.milestones.filter_sort.least_complete"}}</a>
46-
<a class="{{if eq .SortType "mostcomplete"}}active {{end}}item" href="{{$.Link}}?sort=mostcomplete&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.milestones.filter_sort.most_complete"}}</a>
47-
<a class="{{if eq .SortType "mostissues"}}active {{end}}item" href="{{$.Link}}?sort=mostissues&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.milestones.filter_sort.most_issues"}}</a>
48-
<a class="{{if eq .SortType "leastissues"}}active {{end}}item" href="{{$.Link}}?sort=leastissues&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.milestones.filter_sort.least_issues"}}</a>
49-
</div>
50-
</div>
51-
</div>
15+
{{template "repo/issue/filters" .}}
5216

5317
<!-- milestone list -->
5418
<div class="milestone-list">
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
<div class="small-menu-items ui compact tiny menu">
2-
<a class="{{if not .IsShowClosed}}active {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state=open&labels={{.SelectLabels}}&milestone={{.MilestoneID}}&project={{.ProjectID}}&assignee={{.AssigneeID}}&poster={{.PosterID}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">
3-
{{if .PageIsPullList}}
2+
<a class="{{if not .IsShowClosed}}active {{end}}item" href="{{.OpenLink}}">
3+
{{if .PageIsMilestones}}
4+
{{svg "octicon-milestone" 16 "gt-mr-3"}}
5+
{{else if .PageIsPullList}}
46
{{svg "octicon-git-pull-request" 16 "gt-mr-3"}}
57
{{else}}
68
{{svg "octicon-issue-opened" 16 "gt-mr-3"}}
79
{{end}}
8-
{{ctx.Locale.PrettyNumber .IssueStats.OpenCount}}&nbsp;{{ctx.Locale.Tr "repo.issues.open_title"}}
10+
{{ctx.Locale.PrettyNumber .OpenCount}}&nbsp;{{ctx.Locale.Tr "repo.issues.open_title"}}
911
</a>
10-
<a class="{{if .IsShowClosed}}active {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type={{.ViewType}}&sort={{$.SortType}}&state=closed&labels={{.SelectLabels}}&milestone={{.MilestoneID}}&project={{.ProjectID}}&assignee={{.AssigneeID}}&poster={{.PosterID}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">
12+
<a class="{{if .IsShowClosed}}active {{end}}item" href="{{.ClosedLink}}">
1113
{{svg "octicon-check" 16 "gt-mr-3"}}
12-
{{ctx.Locale.PrettyNumber .IssueStats.ClosedCount}}&nbsp;{{ctx.Locale.Tr "repo.issues.closed_title"}}
14+
{{ctx.Locale.PrettyNumber .ClosedCount}}&nbsp;{{ctx.Locale.Tr "repo.issues.closed_title"}}
1315
</a>
1416
</div>

templates/repo/issue/search.tmpl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<form class="list-header-search ui form ignore-dirty issue-list-search">
22
<div class="ui small search fluid action input">
3-
<input type="hidden" name="type" value="{{$.ViewType}}">
43
<input type="hidden" name="state" value="{{$.State}}">
5-
<input type="hidden" name="labels" value="{{.SelectLabels}}">
6-
<input type="hidden" name="milestone" value="{{$.MilestoneID}}">
7-
<input type="hidden" name="project" value="{{$.ProjectID}}">
8-
<input type="hidden" name="assignee" value="{{$.AssigneeID}}">
9-
<input type="hidden" name="poster" value="{{$.PosterID}}">
4+
{{if not .PageIsMilestones}}
5+
<input type="hidden" name="type" value="{{$.ViewType}}">
6+
<input type="hidden" name="labels" value="{{.SelectLabels}}">
7+
<input type="hidden" name="milestone" value="{{$.MilestoneID}}">
8+
<input type="hidden" name="project" value="{{$.ProjectID}}">
9+
<input type="hidden" name="assignee" value="{{$.AssigneeID}}">
10+
<input type="hidden" name="poster" value="{{$.PosterID}}">
11+
{{end}}
1012
{{template "shared/searchinput" dict "Value" .Keyword}}
1113
{{if .PageIsIssueList}}
1214
<button id="issue-list-quick-goto" class="ui small icon button gt-hidden" data-tooltip-content="{{ctx.Locale.Tr "explore.go_to"}}" data-repo-link="{{.RepoLink}}">{{svg "octicon-hash"}}</button>

0 commit comments

Comments
 (0)