Skip to content

Commit c1e3094

Browse files
puni9869silverwind
authored andcommitted
Hide archived labels by default from the suggestions when assigning labels for an issue (go-gitea#27451)
Followup of go-gitea#27115 Finally closes go-gitea#25237 ## Screenshots ### Issue Sidebar <img width="513" alt="image" src="https://github.com/go-gitea/gitea/assets/80308335/9f7fda2f-5a03-4684-8619-fd3498a95b41"> ### PR sidebar <img width="367" alt="image" src="https://github.com/go-gitea/gitea/assets/80308335/53db9b64-faec-4a67-91d6-76945596a469"> ### PR sidebar with archived labels shown <img width="352" alt="image" src="https://github.com/go-gitea/gitea/assets/80308335/9dc5050f-4e69-4f76-bb83-582480a2281e"> --------- Signed-off-by: puni9869 <punitinani1@hotmail.com> Co-authored-by: silverwind <me@silverwind.io>
1 parent 21c3513 commit c1e3094

File tree

6 files changed

+35
-10
lines changed

6 files changed

+35
-10
lines changed

templates/repo/issue/filter_actions.tmpl

+2-4
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@
2929
<div class="divider"></div>
3030
{{end}}
3131
{{$previousExclusiveScope = $exclusiveScope}}
32-
<div class="item issue-action gt-df gt-items-start" data-action="toggle" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/labels">
32+
<div class="item issue-action gt-df gt-sb" data-action="toggle" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/labels">
3333
{{if SliceUtils.Contains $.SelLabelIDs .ID}}{{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}{{end}} {{RenderLabel $.Context .}}
34-
{{if .IsArchived}}
35-
<i data-tooltip-content={{ctx.Locale.Tr "archived"}}>{{svg "octicon-info"}}</i>
36-
{{end}}
34+
{{template "repo/issue/labels/label_archived" .}}
3735
</div>
3836
{{end}}
3937
</div>

templates/repo/issue/labels/labels_selector_field.tmpl

+8-4
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121
<div class="divider"></div>
2222
{{end}}
2323
{{$previousExclusiveScope = $exclusiveScope}}
24-
<a class="{{if .IsChecked}}checked{{end}} item" href="#" data-id="{{.ID}}" data-id-selector="#label_{{.ID}}" data-scope="{{$exclusiveScope}}"><span class="octicon-check {{if not .IsChecked}}gt-invisible{{end}}">{{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}</span>&nbsp;&nbsp;{{RenderLabel $.Context .}}
25-
{{if .Description}}<br><small class="desc">{{.Description | RenderEmoji $.Context}}</small>{{end}}</a>
24+
<a class="{{if .IsChecked}}checked{{end}} item" href="#" data-id="{{.ID}}" {{if .IsArchived}}data-is-archived{{end}} data-id-selector="#label_{{.ID}}" data-scope="{{$exclusiveScope}}"><span class="octicon-check {{if not .IsChecked}}gt-invisible{{end}}">{{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}</span>&nbsp;&nbsp;{{RenderLabel $.Context .}}
25+
{{if .Description}}<br><small class="desc">{{.Description | RenderEmoji $.Context}}</small>{{end}}
26+
<p class="archived-label-hint">{{template "repo/issue/labels/label_archived" .}}</p>
27+
</a>
2628
{{end}}
2729
<div class="divider"></div>
2830
{{$previousExclusiveScope = "_no_scope"}}
@@ -32,8 +34,10 @@
3234
<div class="divider"></div>
3335
{{end}}
3436
{{$previousExclusiveScope = $exclusiveScope}}
35-
<a class="{{if .IsChecked}}checked{{end}} item" href="#" data-id="{{.ID}}" data-id-selector="#label_{{.ID}}" data-scope="{{$exclusiveScope}}"><span class="octicon-check {{if not .IsChecked}}gt-invisible{{end}}">{{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}</span>&nbsp;&nbsp;{{RenderLabel $.Context .}}
36-
{{if .Description}}<br><small class="desc">{{.Description | RenderEmoji $.Context}}</small>{{end}}</a>
37+
<a class="{{if .IsChecked}}checked{{end}} item" href="#" data-id="{{.ID}}" {{if .IsArchived}}data-is-archived{{end}} data-id-selector="#label_{{.ID}}" data-scope="{{$exclusiveScope}}"><span class="octicon-check {{if not .IsChecked}}gt-invisible{{end}}">{{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}</span>&nbsp;&nbsp;{{RenderLabel $.Context .}}
38+
{{if .Description}}<br><small class="desc">{{.Description | RenderEmoji $.Context}}</small>{{end}}
39+
<p class="archived-label-hint">{{template "repo/issue/labels/label_archived" .}}</p>
40+
</a>
3741
{{end}}
3842
{{else}}
3943
<div class="disabled item">{{ctx.Locale.Tr "repo.issues.new.no_items"}}</div>

web_src/css/repo/issue-label.css

+5
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,8 @@
4545
.label-operation .label {
4646
height: fit-content;
4747
}
48+
49+
.archived-label-hint {
50+
float: right;
51+
margin: -12px;
52+
}

web_src/js/features/repo-issue-list.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import $ from 'jquery';
22
import {updateIssuesMeta} from './repo-issue.js';
3-
import {toggleElem} from '../utils/dom.js';
3+
import {toggleElem, hideElem} from '../utils/dom.js';
44
import {htmlEscape} from 'escape-goat';
55
import {confirmModal} from './comp/ConfirmModal.js';
66
import {showErrorToast} from '../modules/toast.js';
@@ -194,6 +194,10 @@ function initArchivedLabelFilter() {
194194
const url = new URL(window.location.href);
195195
const archivedLabels = document.querySelectorAll('[data-is-archived]');
196196

197+
if (!archivedLabels.length) {
198+
hideElem('.archived-label-filter');
199+
return;
200+
}
197201
const selectedLabels = (url.searchParams.get('labels') || '')
198202
.split(',')
199203
.map((id) => id < 0 ? `${~id + 1}` : id); // selectedLabels contains -ve ids, which are excluded so convert any -ve value id to +ve

web_src/js/features/repo-issue.js

+13
Original file line numberDiff line numberDiff line change
@@ -680,3 +680,16 @@ export function initIssueTemplateCommentEditors($commentForm) {
680680
initCombo($(el));
681681
}
682682
}
683+
684+
// This function used to show and hide archived label on issue/pr
685+
// page in the sidebar where we select the labels
686+
// If we have any archived label tagged to issue and pr. We will show that
687+
// archived label with checked classed otherwise we will hide it
688+
// with the help of this function.
689+
// This function runs globally.
690+
export function initArchivedLabelHandler() {
691+
if (!document.querySelector('.archived-label-hint')) return;
692+
for (const label of document.querySelectorAll('[data-is-archived]')) {
693+
toggleElem(label, label.classList.contains('checked'));
694+
}
695+
}

web_src/js/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import {
3131
initRepoIssueWipTitle,
3232
initRepoPullRequestMergeInstruction,
3333
initRepoPullRequestAllowMaintainerEdit,
34-
initRepoPullRequestReview, initRepoIssueSidebarList
34+
initRepoPullRequestReview, initRepoIssueSidebarList, initArchivedLabelHandler,
3535
} from './features/repo-issue.js';
3636
import {
3737
initRepoEllipsisButton,
@@ -152,6 +152,7 @@ onDomReady(() => {
152152
initRepoIssueDue();
153153
initRepoIssueList();
154154
initRepoIssueSidebarList();
155+
initArchivedLabelHandler();
155156
initRepoIssueReferenceRepositorySearch();
156157
initRepoIssueTimeTracking();
157158
initRepoIssueWipTitle();

0 commit comments

Comments
 (0)