From 28d970e4a614cf76e53768f01e42716b2aa9ae7e Mon Sep 17 00:00:00 2001 From: Giteabot <teabot@gitea.io> Date: Mon, 2 Oct 2023 10:56:48 +0800 Subject: [PATCH] Hide archived labels when filtering by labels on the issue list (#27115) (#27381) Backport #27115 by @puni9869 Followup https://github.com/go-gitea/gitea/pull/26820 ## Archived labels UI for issue filter and issue filter actions for issues/pull request pages. Changed: * Enhanced the Issue filter and Issue filter actions UI page to seamlessly incorporate a list of archived labels. * Pagination functionality is same as before. If archived label checkbox is checked then we are adding a query string`archived=true` in the url to save the state of page. * Issue filter actions menu is separated into different template. * Adding the archived flag in issue url labels. * Pull Request page is also work the same. Outsourced: * Defer the implementation of specialized handling for archived labels to upcoming pull requests. This step will be undertaken subsequent to the successful merge of this pull request. Screenshots ### Issue page <img width="1360" alt="image" src="https://github.com/go-gitea/gitea/assets/80308335/d7efb2ef-5b2b-449d-83f0-d430a32ec432"> ### Issue page with label filter on archived label checkbox when not checked --> No archived label is there in list <img width="1249" alt="image" src="https://github.com/go-gitea/gitea/assets/80308335/ceea68ef-91f2-4693-910f-2e25e236bfc9"> ### Issue page with label filter on archived label checkbox when checked --> Show archived label in the list. <img width="710" alt="image" src="https://github.com/go-gitea/gitea/assets/80308335/2414d26b-2079-4c3c-bd9e-f2f5411bcabf"> ### Issue page with label filter on issue action menu on archived label checkbox when checked --> Show archived label in the list. <img width="409" alt="image" src="https://github.com/go-gitea/gitea/assets/80308335/259cac87-3e21-4778-99a2-a6a0b8c81178"> ### Applied the archived=true in Issue labels when archived checkbox is checked. <img width="984" alt="image" src="https://github.com/go-gitea/gitea/assets/80308335/657ce3db-c0ae-402e-b12d-3b580d3c2ed0"> --- Part of https://github.com/go-gitea/gitea/issues/25237 Signed-off-by: puni9869 <punitinani1@hotmail.com> Co-authored-by: puni9869 <80308335+puni9869@users.noreply.github.com> Co-authored-by: delvh <dev.lh@web.de> --- options/locale/locale_en-US.ini | 3 +- routers/web/repo/issue.go | 5 + templates/repo/issue/filter_actions.tmpl | 130 +++++++++++++++++++++++ templates/repo/issue/filters.tmpl | 79 +++++++++----- templates/repo/issue/list.tmpl | 127 +--------------------- templates/repo/issue/openclose.tmpl | 4 +- templates/shared/issuelist.tmpl | 2 +- web_src/css/repo.css | 6 +- web_src/css/repo/issue-list.css | 8 ++ web_src/js/features/repo-issue-list.js | 35 +++++- 10 files changed, 237 insertions(+), 162 deletions(-) create mode 100644 templates/repo/issue/filter_actions.tmpl diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index fb39487a6..db8fc5bc6 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1517,7 +1517,8 @@ issues.label_description = Description issues.label_color = Color issues.label_exclusive = Exclusive issues.label_archive = Archive Label -issues.label_archive_tooltip= Archived labels are excluded from the label search when applying labels to an issue. Existing labels on issues remain unaffected, allowing you to retire obsolete labels without losing information. +issues.label_archived_filter = Show archived labels +issues.label_archive_tooltip = Archived labels are excluded by default from the suggestions when searching by label. issues.label_exclusive_desc = Name the label <code>scope/item</code> to make it mutually exclusive with other <code>scope/</code> labels. issues.label_exclusive_warning = Any conflicting scoped labels will be removed when editing the labels of an issue or pull request. issues.label_count = %d labels diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index b33c9f972..59d6fe24d 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -442,6 +442,11 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti pager.AddParam(ctx, "project", "ProjectID") pager.AddParam(ctx, "assignee", "AssigneeID") pager.AddParam(ctx, "poster", "PosterID") + + if ctx.FormBool("archived") { + ctx.Data["ShowArchivedLabels"] = true + pager.AddParam(ctx, "archived", "ShowArchivedLabels") + } ctx.Data["Page"] = pager } diff --git a/templates/repo/issue/filter_actions.tmpl b/templates/repo/issue/filter_actions.tmpl new file mode 100644 index 000000000..f84a99ff7 --- /dev/null +++ b/templates/repo/issue/filter_actions.tmpl @@ -0,0 +1,130 @@ +<div class="ui secondary filter menu"> + {{if not .Repository.IsArchived}} + <!-- Action Button --> + {{if .IsShowClosed}} + <button class="ui primary basic button issue-action" data-action="open" data-url="{{$.RepoLink}}/issues/status">{{ctx.Locale.Tr "repo.issues.action_open"}}</button> + {{else}} + <button class="ui red basic button issue-action" data-action="close" data-url="{{$.RepoLink}}/issues/status">{{ctx.Locale.Tr "repo.issues.action_close"}}</button> + {{end}} + {{if $.IsRepoAdmin}} + <button class="ui red button issue-action" + data-action="delete" data-url="{{$.RepoLink}}/issues/delete" + data-action-delete-confirm="{{ctx.Locale.Tr "confirm_delete_selected"}}" + >{{ctx.Locale.Tr "repo.issues.delete"}}</button> + {{end}} + <!-- Labels --> + <div class="ui {{if not .Labels}}disabled{{end}} dropdown jump item"> + <span class="text"> + {{ctx.Locale.Tr "repo.issues.action_label"}} + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <div class="item issue-action" data-action="clear" data-url="{{$.RepoLink}}/issues/labels"> + {{ctx.Locale.Tr "repo.issues.new.clear_labels"}} + </div> + {{$previousExclusiveScope := "_no_scope"}} + {{range .Labels}} + {{$exclusiveScope := .ExclusiveScope}} + {{if and (ne $previousExclusiveScope "_no_scope") (ne $previousExclusiveScope $exclusiveScope)}} + <div class="divider"></div> + {{end}} + {{$previousExclusiveScope = $exclusiveScope}} + <div class="item issue-action gt-df gt-items-start" data-action="toggle" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/labels"> + {{if SliceUtils.Contains $.SelLabelIDs .ID}}{{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}{{end}} {{RenderLabel $.Context .}} + {{if .IsArchived}} + <i data-tooltip-content={{ctx.Locale.Tr "archived"}}>{{svg "octicon-info"}}</i> + {{end}} + </div> + {{end}} + </div> + </div> + + <!-- Milestone --> + <div class="ui {{if not (or .OpenMilestones .ClosedMilestones)}}disabled{{end}} dropdown jump item"> + <span class="text"> + {{ctx.Locale.Tr "repo.issues.action_milestone"}} + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <div class="item issue-action" data-element-id="0" data-url="{{$.Link}}/milestone"> + {{ctx.Locale.Tr "repo.issues.action_milestone_no_select"}} + </div> + {{if .OpenMilestones}} + <div class="divider"></div> + <div class="header">{{ctx.Locale.Tr "repo.issues.filter_milestone_open"}}</div> + {{range .OpenMilestones}} + <div class="item issue-action" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/milestone"> + {{.Name}} + </div> + {{end}} + {{end}} + {{if .ClosedMilestones}} + <div class="divider"></div> + <div class="header">{{ctx.Locale.Tr "repo.issues.filter_milestone_open"}}</div> + {{range .ClosedMilestones}} + <div class="item issue-action" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/milestone"> + {{.Name}} + </div> + {{end}} + {{end}} + </div> + </div> + + <!-- Projects --> + <div class="ui{{if not (or .OpenProjects .ClosedProjects)}} disabled{{end}} dropdown jump item"> + <span class="text"> + {{ctx.Locale.Tr "repo.project_board"}} + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <div class="item issue-action" data-element-id="0" data-url="{{$.Link}}/projects"> + {{ctx.Locale.Tr "repo.issues.new.clear_projects"}} + </div> + {{if .OpenProjects}} + <div class="divider"></div> + <div class="header"> + {{ctx.Locale.Tr "repo.issues.new.open_projects"}} + </div> + {{range .OpenProjects}} + <div class="item issue-action" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/projects"> + {{svg .IconName 18 "gt-mr-3"}}{{.Title}} + </div> + {{end}} + {{end}} + {{if .ClosedProjects}} + <div class="divider"></div> + <div class="header"> + {{ctx.Locale.Tr "repo.issues.new.closed_projects"}} + </div> + {{range .ClosedProjects}} + <div class="item issue-action" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/projects"> + {{svg .IconName 18 "gt-mr-3"}}{{.Title}} + </div> + {{end}} + {{end}} + </div> + </div> + + <!-- Assignees --> + <div class="ui {{if not .Assignees}}disabled{{end}} dropdown jump item"> + <span class="text"> + {{ctx.Locale.Tr "repo.issues.action_assignee"}} + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <div class="item issue-action" data-action="clear" data-url="{{$.Link}}/assignee"> + {{ctx.Locale.Tr "repo.issues.new.clear_assignees"}} + </div> + <div class="item issue-action" data-element-id="0" data-url="{{$.Link}}/assignee"> + {{ctx.Locale.Tr "repo.issues.action_assignee_no_select"}} + </div> + {{range .Assignees}} + <div class="item issue-action" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/assignee"> + {{ctx.AvatarUtils.Avatar . 20}} {{.GetDisplayName}} + </div> + {{end}} + </div> + </div> + {{end}} +</div> + diff --git a/templates/repo/issue/filters.tmpl b/templates/repo/issue/filters.tmpl index dca2fb0db..15a90869b 100644 --- a/templates/repo/issue/filters.tmpl +++ b/templates/repo/issue/filters.tmpl @@ -18,10 +18,22 @@ <i class="icon">{{svg "octicon-search" 16}}</i> <input type="text" placeholder="{{ctx.Locale.Tr "repo.issues.filter_label"}}"> </div> + <div class="ui checkbox compact archived-label-filter"> + <input name="archived" type="checkbox" + id="archived-filter-checkbox" + {{if .ShowArchivedLabels}}checked{{end}} + > + <label for="archived-filter-checkbox"> + {{ctx.Locale.Tr "repo.issues.label_archived_filter"}} + <i class="gt-ml-2" data-tooltip-content={{ctx.Locale.Tr "repo.issues.label_archive_tooltip"}}> + {{svg "octicon-info"}} + </i> + </label> + </div> <span class="info">{{ctx.Locale.Tr "repo.issues.filter_label_exclude" | Safe}}</span> <div class="divider"></div> - <a class="{{if .AllLabels}}active selected {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">{{ctx.Locale.Tr "repo.issues.filter_label_no_select"}}</a> - <a class="{{if .NoLabel}}active selected {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels=0&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">{{ctx.Locale.Tr "repo.issues.filter_label_select_no_label"}}</a> + <a class="{{if .AllLabels}}active selected {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_label_no_select"}}</a> + <a class="{{if .NoLabel}}active selected {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels=0&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_label_select_no_label"}}</a> {{$previousExclusiveScope := "_no_scope"}} {{range .Labels}} {{$exclusiveScope := .ExclusiveScope}} @@ -29,7 +41,16 @@ <div class="divider"></div> {{end}} {{$previousExclusiveScope = $exclusiveScope}} - <a class="item label-filter-item gt-df gt-ac" {{if .IsArchived}}data-is-archived{{end}} 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}} + <a class="item label-filter-item gt-df gt-ac" {{if .IsArchived}}data-is-archived{{end}} href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.QueryString}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}{{if $.ShowArchivedLabels}}&archived=true{{end}}" 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 .}} <p class="gt-ml-auto">{{template "repo/issue/labels/label_archived" .}}</p> </a> @@ -50,13 +71,13 @@ <input type="text" placeholder="{{ctx.Locale.Tr "repo.issues.filter_milestone"}}"> </div> <div class="divider"></div> - <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}}">{{ctx.Locale.Tr "repo.issues.filter_milestone_all"}}</a> - <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}}">{{ctx.Locale.Tr "repo.issues.filter_milestone_none"}}</a> + <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}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_milestone_all"}}</a> + <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}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_milestone_none"}}</a> {{if .OpenMilestones}} <div class="divider"></div> <div class="header">{{ctx.Locale.Tr "repo.issues.filter_milestone_open"}}</div> {{range .OpenMilestones}} - <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}}"> + <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}}{{if $.ShowArchivedLabels}}&archived=true{{end}}"> {{svg "octicon-milestone" 16 "mr-2"}} {{.Name}} </a> @@ -66,7 +87,7 @@ <div class="divider"></div> <div class="header">{{ctx.Locale.Tr "repo.issues.filter_milestone_closed"}}</div> {{range .ClosedMilestones}} - <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}}"> + <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}}{{if $.ShowArchivedLabels}}&archived=true{{end}}"> {{svg "octicon-milestone" 16 "mr-2"}} {{.Name}} </a> @@ -87,15 +108,15 @@ <i class="icon">{{svg "octicon-search" 16}}</i> <input type="text" placeholder="{{ctx.Locale.Tr "repo.issues.filter_project"}}"> </div> - <a class="{{if not .ProjectID}}active selected {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">{{ctx.Locale.Tr "repo.issues.filter_project_all"}}</a> - <a class="{{if eq .ProjectID -1}}active selected {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&project=-1&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">{{ctx.Locale.Tr "repo.issues.filter_project_none"}}</a> + <a class="{{if not .ProjectID}}active selected {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_project_all"}}</a> + <a class="{{if eq .ProjectID -1}}active selected {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&project=-1&assignee={{$.AssigneeID}}&poster={{$.PosterID}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_project_none"}}</a> {{if .OpenProjects}} <div class="divider"></div> <div class="header"> {{ctx.Locale.Tr "repo.issues.new.open_projects"}} </div> {{range .OpenProjects}} - <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}}"> + <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}}{{if $.ShowArchivedLabels}}&archived=true{{end}}"> {{svg .IconName 18 "gt-mr-3 gt-shrink-0"}}<span class="gt-ellipsis">{{.Title}}</span> </a> {{end}} @@ -106,7 +127,7 @@ {{ctx.Locale.Tr "repo.issues.new.closed_projects"}} </div> {{range .ClosedProjects}} - <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}}"> + <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}}{{if $.ShowArchivedLabels}}&archived=true{{end}}"> {{svg .IconName 18 "gt-mr-3"}}{{.Title}} </a> {{end}} @@ -118,7 +139,7 @@ <div class="ui dropdown jump item user-remote-search" data-tooltip-content="{{ctx.Locale.Tr "repo.author_search_tooltip"}}" data-search-url="{{if .Milestone}}{{$.RepoLink}}/issues/posters{{else}}{{$.Link}}/posters{{end}}" data-selected-user-id="{{$.PosterID}}" - data-action-jump-url="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={user_id}" + data-action-jump-url="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={user_id}{{if $.ShowArchivedLabels}}&archived=true{{end}}" > <span class="text"> {{ctx.Locale.Tr "repo.issues.filter_poster"}} @@ -144,11 +165,11 @@ <i class="icon">{{svg "octicon-search" 16}}</i> <input type="text" placeholder="{{ctx.Locale.Tr "repo.issues.filter_assignee"}}"> </div> - <a class="{{if not .AssigneeID}}active selected {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&poster={{$.PosterID}}">{{ctx.Locale.Tr "repo.issues.filter_assginee_no_select"}}</a> - <a class="{{if eq .AssigneeID -1}}active selected {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee=-1&poster={{$.PosterID}}">{{ctx.Locale.Tr "repo.issues.filter_assginee_no_assignee"}}</a> + <a class="{{if not .AssigneeID}}active selected {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&poster={{$.PosterID}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_assginee_no_select"}}</a> + <a class="{{if eq .AssigneeID -1}}active selected {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee=-1&poster={{$.PosterID}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_assginee_no_assignee"}}</a> <div class="divider"></div> {{range .Assignees}} - <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}}"> + <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}}{{if $.ShowArchivedLabels}}&archived=true{{end}}"> {{ctx.AvatarUtils.Avatar . 20}}{{template "repo/search_name" .}} </a> {{end}} @@ -163,14 +184,14 @@ </span> {{svg "octicon-triangle-down" 14 "dropdown icon"}} <div class="menu"> - <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}}">{{ctx.Locale.Tr "repo.issues.filter_type.all_issues"}}</a> - <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}}">{{ctx.Locale.Tr "repo.issues.filter_type.assigned_to_you"}}</a> - <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}}">{{ctx.Locale.Tr "repo.issues.filter_type.created_by_you"}}</a> + <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}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_type.all_issues"}}</a> + <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}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_type.assigned_to_you"}}</a> + <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}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_type.created_by_you"}}</a> {{if .PageIsPullList}} - <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}}">{{ctx.Locale.Tr "repo.issues.filter_type.review_requested"}}</a> - <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}}">{{ctx.Locale.Tr "repo.issues.filter_type.reviewed_by_you"}}</a> + <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}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_type.review_requested"}}</a> + <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}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_type.reviewed_by_you"}}</a> {{end}} - <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}}">{{ctx.Locale.Tr "repo.issues.filter_type.mentioning_you"}}</a> + <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}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_type.mentioning_you"}}</a> </div> </div> {{end}} @@ -182,14 +203,14 @@ </span> {{svg "octicon-triangle-down" 14 "dropdown icon"}} <div class="menu"> - <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}}">{{ctx.Locale.Tr "repo.issues.filter_sort.latest"}}</a> - <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}}">{{ctx.Locale.Tr "repo.issues.filter_sort.oldest"}}</a> - <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}}">{{ctx.Locale.Tr "repo.issues.filter_sort.recentupdate"}}</a> - <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}}">{{ctx.Locale.Tr "repo.issues.filter_sort.leastupdate"}}</a> - <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}}">{{ctx.Locale.Tr "repo.issues.filter_sort.mostcomment"}}</a> - <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}}">{{ctx.Locale.Tr "repo.issues.filter_sort.leastcomment"}}</a> - <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}}">{{ctx.Locale.Tr "repo.issues.filter_sort.nearduedate"}}</a> - <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}}">{{ctx.Locale.Tr "repo.issues.filter_sort.farduedate"}}</a> + <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}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_sort.latest"}}</a> + <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}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_sort.oldest"}}</a> + <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}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_sort.recentupdate"}}</a> + <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}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_sort.leastupdate"}}</a> + <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}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_sort.mostcomment"}}</a> + <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}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_sort.leastcomment"}}</a> + <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}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_sort.nearduedate"}}</a> + <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}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_sort.farduedate"}}</a> </div> </div> </div> diff --git a/templates/repo/issue/list.tmpl b/templates/repo/issue/list.tmpl index 75d423432..038526f42 100644 --- a/templates/repo/issue/list.tmpl +++ b/templates/repo/issue/list.tmpl @@ -36,132 +36,7 @@ {{template "repo/issue/openclose" .}} </div> <div class="issue-list-toolbar-right"> - <div class="ui secondary filter menu"> - {{if not .Repository.IsArchived}} - <!-- Action Button --> - {{if .IsShowClosed}} - <button class="ui primary basic button issue-action" data-action="open" data-url="{{$.RepoLink}}/issues/status">{{ctx.Locale.Tr "repo.issues.action_open"}}</button> - {{else}} - <button class="ui red basic button issue-action" data-action="close" data-url="{{$.RepoLink}}/issues/status">{{ctx.Locale.Tr "repo.issues.action_close"}}</button> - {{end}} - {{if $.IsRepoAdmin}} - <button class="ui red button issue-action" - data-action="delete" data-url="{{$.RepoLink}}/issues/delete" - data-action-delete-confirm="{{ctx.Locale.Tr "confirm_delete_selected"}}" - >{{ctx.Locale.Tr "repo.issues.delete"}}</button> - {{end}} - <!-- Labels --> - <div class="ui {{if not .Labels}}disabled{{end}} dropdown jump item"> - <span class="text"> - {{ctx.Locale.Tr "repo.issues.action_label"}} - </span> - {{svg "octicon-triangle-down" 14 "dropdown icon"}} - <div class="menu"> - <div class="item issue-action" data-action="clear" data-url="{{$.RepoLink}}/issues/labels"> - {{ctx.Locale.Tr "repo.issues.new.clear_labels"}} - </div> - {{$previousExclusiveScope := "_no_scope"}} - {{range .Labels}} - {{$exclusiveScope := .ExclusiveScope}} - {{if and (ne $previousExclusiveScope "_no_scope") (ne $previousExclusiveScope $exclusiveScope)}} - <div class="divider"></div> - {{end}} - {{$previousExclusiveScope = $exclusiveScope}} - <div class="item issue-action" data-action="toggle" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/labels"> - {{if SliceUtils.Contains $.SelLabelIDs .ID}}{{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}{{end}} {{RenderLabel $.Context .}} - </div> - {{end}} - </div> - </div> - - <!-- Milestone --> - <div class="ui {{if not (or .OpenMilestones .ClosedMilestones)}}disabled{{end}} dropdown jump item"> - <span class="text"> - {{ctx.Locale.Tr "repo.issues.action_milestone"}} - </span> - {{svg "octicon-triangle-down" 14 "dropdown icon"}} - <div class="menu"> - <div class="item issue-action" data-element-id="0" data-url="{{$.Link}}/milestone"> - {{ctx.Locale.Tr "repo.issues.action_milestone_no_select"}} - </div> - {{if .OpenMilestones}} - <div class="divider"></div> - <div class="header">{{ctx.Locale.Tr "repo.issues.filter_milestone_open"}}</div> - {{range .OpenMilestones}} - <div class="item issue-action" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/milestone"> - {{.Name}} - </div> - {{end}} - {{end}} - {{if .ClosedMilestones}} - <div class="divider"></div> - <div class="header">{{ctx.Locale.Tr "repo.issues.filter_milestone_open"}}</div> - {{range .ClosedMilestones}} - <div class="item issue-action" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/milestone"> - {{.Name}} - </div> - {{end}} - {{end}} - </div> - </div> - - <!-- Projects --> - <div class="ui{{if not (or .OpenProjects .ClosedProjects)}} disabled{{end}} dropdown jump item"> - <span class="text"> - {{ctx.Locale.Tr "repo.project_board"}} - </span> - {{svg "octicon-triangle-down" 14 "dropdown icon"}} - <div class="menu"> - <div class="item issue-action" data-element-id="0" data-url="{{$.Link}}/projects"> - {{ctx.Locale.Tr "repo.issues.new.clear_projects"}} - </div> - {{if .OpenProjects}} - <div class="divider"></div> - <div class="header"> - {{ctx.Locale.Tr "repo.issues.new.open_projects"}} - </div> - {{range .OpenProjects}} - <div class="item issue-action" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/projects"> - {{svg .IconName 18 "gt-mr-3"}}{{.Title}} - </div> - {{end}} - {{end}} - {{if .ClosedProjects}} - <div class="divider"></div> - <div class="header"> - {{ctx.Locale.Tr "repo.issues.new.closed_projects"}} - </div> - {{range .ClosedProjects}} - <div class="item issue-action" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/projects"> - {{svg .IconName 18 "gt-mr-3"}}{{.Title}} - </div> - {{end}} - {{end}} - </div> - </div> - - <!-- Assignees --> - <div class="ui {{if not .Assignees}}disabled{{end}} dropdown jump item"> - <span class="text"> - {{ctx.Locale.Tr "repo.issues.action_assignee"}} - </span> - {{svg "octicon-triangle-down" 14 "dropdown icon"}} - <div class="menu"> - <div class="item issue-action" data-action="clear" data-url="{{$.Link}}/assignee"> - {{ctx.Locale.Tr "repo.issues.new.clear_assignees"}} - </div> - <div class="item issue-action" data-element-id="0" data-url="{{$.Link}}/assignee"> - {{ctx.Locale.Tr "repo.issues.action_assignee_no_select"}} - </div> - {{range .Assignees}} - <div class="item issue-action" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/assignee"> - {{ctx.AvatarUtils.Avatar . 20}} {{.GetDisplayName}} - </div> - {{end}} - </div> - </div> - {{end}} - </div> + {{template "repo/issue/filter_actions" .}} </div> </div> {{template "shared/issuelist" dict "." . "listType" "repo"}} diff --git a/templates/repo/issue/openclose.tmpl b/templates/repo/issue/openclose.tmpl index a215922af..ad8de4013 100644 --- a/templates/repo/issue/openclose.tmpl +++ b/templates/repo/issue/openclose.tmpl @@ -1,5 +1,5 @@ <div class="small-menu-items ui compact tiny menu"> - <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}}"> + <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}}"> {{if .PageIsPullList}} {{svg "octicon-git-pull-request" 16 "gt-mr-3"}} {{else}} @@ -7,7 +7,7 @@ {{end}} {{ctx.Locale.PrettyNumber .IssueStats.OpenCount}} {{ctx.Locale.Tr "repo.issues.open_title"}} </a> - <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}}"> + <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}}"> {{svg "octicon-check" 16 "gt-mr-3"}} {{ctx.Locale.PrettyNumber .IssueStats.ClosedCount}} {{ctx.Locale.Tr "repo.issues.closed_title"}} </a> diff --git a/templates/shared/issuelist.tmpl b/templates/shared/issuelist.tmpl index 06d333ea3..4214a03dc 100644 --- a/templates/shared/issuelist.tmpl +++ b/templates/shared/issuelist.tmpl @@ -21,7 +21,7 @@ {{end}} <span class="labels-list gt-ml-2"> {{range .Labels}} - <a href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&state={{$.State}}&labels={{.ID}}{{if ne $.listType "milestone"}}&milestone={{$.MilestoneID}}{{end}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">{{RenderLabel $.Context .}}</a> + <a href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&state={{$.State}}&labels={{.ID}}{{if ne $.listType "milestone"}}&milestone={{$.MilestoneID}}{{end}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{RenderLabel $.Context .}}</a> {{end}} </span> </div> diff --git a/web_src/css/repo.css b/web_src/css/repo.css index d0d001bf5..562fb4a34 100644 --- a/web_src/css/repo.css +++ b/web_src/css/repo.css @@ -129,11 +129,13 @@ .repository .filter.menu.labels .label-filter .menu .info { display: inline-block; - padding: 0.5rem 0.25rem; + padding: 0.5rem 0; font-size: 12px; width: 100%; white-space: nowrap; - text-align: center; + margin-left: 10px; + margin-right: 8px; + text-align: left; } .repository .filter.menu.labels .label-filter .menu .info code { diff --git a/web_src/css/repo/issue-list.css b/web_src/css/repo/issue-list.css index 17ae6ea38..d2f8e429f 100644 --- a/web_src/css/repo/issue-list.css +++ b/web_src/css/repo/issue-list.css @@ -80,3 +80,11 @@ #issue-list .flex-item-body .checklist progress::-moz-progress-bar { background-color: var(--color-secondary-dark-4); } + +.archived-label-filter { + margin-left: 10px; + font-size: 12px; + display: flex !important; + margin-bottom: 8px; + min-width: fit-content; +} diff --git a/web_src/js/features/repo-issue-list.js b/web_src/js/features/repo-issue-list.js index af4586121..a9a8628ba 100644 --- a/web_src/js/features/repo-issue-list.js +++ b/web_src/js/features/repo-issue-list.js @@ -73,7 +73,7 @@ function initRepoIssueListCheckboxes() { url, action, issueIDs, - elementId + elementId, ).then(() => { window.location.reload(); }).catch((reason) => { @@ -185,9 +185,42 @@ async function initIssuePinSort() { }); } +function initArchivedLabelFilter() { + const archivedLabelEl = document.querySelector('#archived-filter-checkbox'); + if (!archivedLabelEl) { + return; + } + + const url = new URL(window.location.href); + const archivedLabels = document.querySelectorAll('[data-is-archived]'); + + const selectedLabels = (url.searchParams.get('labels') || '') + .split(',') + .map((id) => id < 0 ? `${~id + 1}` : id); // selectedLabels contains -ve ids, which are excluded so convert any -ve value id to +ve + + const archivedElToggle = () => { + for (const label of archivedLabels) { + const id = label.getAttribute('data-label-id'); + toggleElem(label, archivedLabelEl.checked || selectedLabels.includes(id)); + } + }; + + archivedElToggle(); + archivedLabelEl.addEventListener('change', () => { + archivedElToggle(); + if (archivedLabelEl.checked) { + url.searchParams.set('archived', 'true'); + } else { + url.searchParams.delete('archived'); + } + window.location.href = url.href; + }); +} + export function initRepoIssueList() { if (!document.querySelectorAll('.page-content.repository.issue-list, .page-content.repository.milestone-issue-list').length) return; initRepoIssueListCheckboxes(); initRepoIssueListAuthorDropdown(); initIssuePinSort(); + initArchivedLabelFilter(); }