Skip to content
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

Merged
merged 16 commits into from
Oct 18, 2023

Conversation

yp05327
Copy link
Contributor

@yp05327 yp05327 commented Sep 27, 2023

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
image

image
image

After:
image
image

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Sep 27, 2023
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 27, 2023
@lunny
Copy link
Member

lunny commented Sep 27, 2023

Why should we move the search bar ?

@yp05327
Copy link
Contributor Author

yp05327 commented Sep 27, 2023

Why should the search bar in different places?

Comment on lines 11 to 25
<!-- 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>
Copy link
Member

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.

Copy link
Member

@silverwind silverwind Oct 3, 2023

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.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Sep 30, 2023
@lunny lunny added the topic/ui Change the appearance of the Gitea UI label Sep 30, 2023
@lunny lunny added this to the 1.22.0 milestone Sep 30, 2023
@silverwind
Copy link
Member

Change is good for consistency.

@yp05327
Copy link
Contributor Author

yp05327 commented Oct 4, 2023

And in the projects list page, the search bar is also in the below.
I'm a little busy these days. I will take some times to improve this PR later.

@pull-request-size pull-request-size bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 5, 2023
@github-actions github-actions bot removed the topic/ui Change the appearance of the Gitea UI label Oct 5, 2023
@pull-request-size pull-request-size bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 5, 2023
@yp05327 yp05327 requested a review from puni9869 October 5, 2023 00:53
@yp05327
Copy link
Contributor Author

yp05327 commented Oct 5, 2023

@puni9869
It seems that there's a bug from #27115.
When an archived label is selected, if you disabled showing archived labels, the selected archived labels will keep showing in the page.
image
Is this by design?

@@ -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)
Copy link
Contributor Author

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. 🤔

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

@silverwind silverwind Oct 5, 2023

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)

Copy link
Member

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>
@puni9869
Copy link
Member

puni9869 commented Oct 5, 2023

@yp05327 I appreciate this change 💯 , give me 1 hr or so for deep reivew.

@puni9869 It seems that there's a bug from #27115. When an archived label is selected, if you disabled showing archived labels, the selected archived labels will keep showing in the page. image Is this by design?

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.

@puni9869
Copy link
Member

puni9869 commented Oct 5, 2023

@puni9869 It seems that there's a bug from #27115. When an archived label is selected, if you disabled showing archived labels, the selected archived labels will keep showing in the page. image Is this by design?

@yp05327
// @delvh

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.
image

This will completes the archived label feature base functionality.

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Copy link
Member

@puni9869 puni9869 Oct 5, 2023

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);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@yp05327 yp05327 force-pushed the improve-milestone-issue-header branch from 50a0ee9 to d7416ed Compare October 6, 2023 00:23
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Oct 6, 2023
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)
Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Contributor

@wxiaoguang wxiaoguang left a 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.

@GiteaBot GiteaBot added lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged and removed lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. labels Oct 6, 2023
@puni9869
Copy link
Member

puni9869 commented Oct 6, 2023

Please always encode parameters correctly.

sry, we missed that.

Comment on lines +425 to +430
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -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)
Copy link
Contributor

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.

@wxiaoguang wxiaoguang dismissed their stale review October 12, 2023 00:33

dismiss change request

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged labels Oct 12, 2023
Copy link
Member

@silverwind silverwind left a 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.

@silverwind silverwind added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Oct 17, 2023
@silverwind silverwind enabled auto-merge (squash) October 17, 2023 23:32
@silverwind silverwind merged commit 8abc1aa into go-gitea:main Oct 18, 2023
25 checks passed
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Oct 18, 2023
zjjhot added a commit to zjjhot/gitea that referenced this pull request Oct 18, 2023
* 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)
@yp05327 yp05327 deleted the improve-milestone-issue-header branch October 18, 2023 06:03
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Jan 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants