-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Improve the list header in milestone page #27302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve the list header in milestone page #27302
Conversation
Why should we move the search bar ? |
Why should the search bar in different places? |
templates/repo/issue/filters.tmpl
Outdated
<!-- Sort --> | ||
<div class="list-header-sort ui small dropdown type jump item"> | ||
<span class="text"> | ||
{{ctx.Locale.Tr "repo.issues.filter_sort"}} | ||
</span> | ||
{{svg "octicon-triangle-down" 14 "dropdown icon"}} | ||
<div class="menu"> | ||
<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> | ||
<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> | ||
<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> | ||
<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> | ||
<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> | ||
<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> | ||
</div> | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend extracting all this into an extra subtemplate, simply to keep things readable.
At the moment, we use far too few subtemplates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, the indentation of this block seems off. it's using 6 spaces, then 4 spaces. Should just be 2 spaces and no new indentation level after the comment.
Edit: actually lint fails on it as well.
Change is good for consistency. |
And in the projects list page, the search bar is also in the below. |
routers/web/repo/issue.go
Outdated
@@ -417,6 +423,10 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti | |||
ctx.Data["PinnedIssues"] = pinned | |||
ctx.Data["IsRepoAdmin"] = ctx.IsSigned && (ctx.Repo.IsAdmin() || ctx.Doer.IsAdmin) | |||
ctx.Data["IssueStats"] = issueStats | |||
ctx.Data["OpenCount"] = issueStats.OpenCount | |||
ctx.Data["ClosedCount"] = issueStats.ClosedCount | |||
ctx.Data["OpenLink"] = fmt.Sprintf("%s?q=%s&type=%s&sort=%s&state=open&labels=%s&milestone=%d&project=%d&assignee=%d&poster=%d&archived=%s", ctx.Link, keyword, viewType, sortType, selectLabels, mentionedID, projectID, assigneeID, posterID, showArchivedLabels) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I move this into the template? This solution seems not good enough. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I move this into the template? This solution seems not good enough. 🤔
Lets move this in separat pr because there are many places where we can reduce and refactor this dedicately.
I don't want to over burder this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I notice that there are too many similar links in different places of these templates.
If they can be a shared one, it can be more maintainable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of endlessly extending these query param lists, we should instead add a template helper that just merges the specified pairs into the current query params that the backend sees: #27192 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will make a proof of concept of this helper soon.
Co-authored-by: puni9869 <80308335+puni9869@users.noreply.github.com>
@yp05327 I appreciate this change 💯 , give me 1 hr or so for deep reivew.
Yes, its by design because the label is selected, if the checkbox is unchecked then the label info will be incomplete, we want to show all labels which are selected. |
I will blog post about the full functionality on the coming weekend. There is currently work going on this functionality here #27451 I have one more enhancement in TODO: When we have some label selected after page reload we want to show all the selected labels in the top of the list, like github All the selected labels are first and then sorted way listing of label in the selector drop down. This will completes the archived label feature base functionality. |
routers/web/repo/issue.go
Outdated
ctx.Data["OpenCount"] = issueStats.OpenCount | ||
ctx.Data["ClosedCount"] = issueStats.ClosedCount | ||
ctx.Data["OpenLink"] = fmt.Sprintf("%s?q=%s&type=%s&sort=%s&state=open&labels=%s&milestone=%d&project=%d&assignee=%d&poster=%d&archived=%s", ctx.Link, keyword, viewType, sortType, selectLabels, mentionedID, projectID, assigneeID, posterID, showArchivedLabels) | ||
ctx.Data["ClosedLink"] = fmt.Sprintf("%s?q=%s&type=%s&sort=%s&state=closed&labels=%s&milestone=%d&project=%d&assignee=%d&poster=%d&archived=%s", ctx.Link, keyword, viewType, sortType, selectLabels, mentionedID, projectID, assigneeID, posterID, showArchivedLabels) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may be use can use
queryStr := "%s?q=%s&type=%s&sort=%s&state=%s&labels=%s&milestone=%d&project=%d&assignee=%d&poster=%d&archived=%s";
// take state in expression "close/open"
ctx.Data["OpenLink"] = fmt.Sprintf(queryStr, "open",all the args here);
ctx.Data["CloseLink"] = fmt.Sprintf(queryStr, "close", all the args here);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
50a0ee9
to
d7416ed
Compare
routers/web/repo/issue.go
Outdated
ctx.Data["OpenCount"] = issueStats.OpenCount | ||
ctx.Data["ClosedCount"] = issueStats.ClosedCount | ||
linkStr := "%s?q=%s&type=%s&sort=%s&state=%s&labels=%s&milestone=%d&project=%d&assignee=%d&poster=%d&archived=%t" | ||
ctx.Data["OpenLink"] = fmt.Sprintf(linkStr, ctx.Link, keyword, viewType, sortType, "open", selectLabels, mentionedID, projectID, assigneeID, posterID, archived) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not right to put a string into query parameter. You need to encode(escape) it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, needs queryEscape
for each of these params. I still suggest we make a helper like #27192 (comment) instead of this cumbersome and error-prone string concatenation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please always encode parameters correctly.
sry, we missed that. |
ctx.Data["OpenLink"] = fmt.Sprintf(linkStr, ctx.Link, | ||
url.QueryEscape(keyword), url.QueryEscape(viewType), url.QueryEscape(sortType), "open", url.QueryEscape(selectLabels), | ||
mentionedID, projectID, assigneeID, posterID, archived) | ||
ctx.Data["ClosedLink"] = fmt.Sprintf(linkStr, ctx.Link, | ||
url.QueryEscape(keyword), url.QueryEscape(viewType), url.QueryEscape(sortType), "closed", url.QueryEscape(selectLabels), | ||
mentionedID, projectID, assigneeID, posterID, archived) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
routers/web/repo/milestone.go
Outdated
@@ -72,6 +73,9 @@ func Milestones(ctx *context.Context) { | |||
} | |||
ctx.Data["OpenCount"] = stats.OpenCount | |||
ctx.Data["ClosedCount"] = stats.ClosedCount | |||
linkStr := "%s/milestones?state=%s&q=%s&sort=%s" | |||
ctx.Data["OpenLink"] = fmt.Sprintf(linkStr, ctx.Repo.RepoLink, "open", keyword, sortType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It still needs correct escaping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Escaping looks good. While I'm not a fan of the method, I guess we can always improve later with the proposed helper.
* giteaofficial/main: Improve the list header in milestone page (go-gitea#27302) Fix poster is not loaded in get default merge message (go-gitea#27657) Hide archived labels by default from the suggestions when assigning labels for an issue (go-gitea#27451) actions/setup-go use go-version-file (go-gitea#27651) Update agit-support.en-us.md (go-gitea#27652)
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:


After:

