Skip to content

Commit 28e59d8

Browse files
committed
Fix show archive method. Only change the date when it is newly archived.
Adding show archived labels checkbox in ui Added style to archived labels
1 parent ced34ba commit 28e59d8

File tree

6 files changed

+34
-10
lines changed

6 files changed

+34
-10
lines changed

models/issues/label.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,11 @@ func (l *Label) CalOpenIssues() {
113113

114114
// SetArchived set the label as archived
115115
func (l *Label) SetArchived(isArchived bool) {
116-
if isArchived && l.ArchivedUnix.IsZero() {
117-
l.ArchivedUnix = timeutil.TimeStampNow()
118-
} else {
116+
if !isArchived {
119117
l.ArchivedUnix = timeutil.TimeStamp(0)
118+
} else if isArchived && l.ArchivedUnix.IsZero() {
119+
// Only change the date when it is newly archived.
120+
l.ArchivedUnix = timeutil.TimeStampNow()
120121
}
121122
}
122123

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,6 +1496,7 @@ issues.label_archive_tooltip= Archived labels are excluded from the label search
14961496
issues.label_exclusive_desc = Name the label <code>scope/item</code> to make it mutually exclusive with other <code>scope/</code> labels.
14971497
issues.label_exclusive_warning = Any conflicting scoped labels will be removed when editing the labels of an issue or pull request.
14981498
issues.label_count = %d labels
1499+
issues.show_archived_labels = Show archived labels
14991500
issues.label_open_issues = %d open issues/pull requests
15001501
issues.label_edit = Edit
15011502
issues.label_delete = Delete

templates/repo/issue/labels/label_list.tmpl

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
<h4 class="ui top attached header">
2-
{{.locale.Tr "repo.issues.label_count" .NumLabels}}
3-
<div class="ui right">
1+
<h4 class="ui top attached header gt-df">
2+
<span class="gt-f1">{{.locale.Tr "repo.issues.label_count" .NumLabels}}</span>
3+
<label class="gt-f1" data-tooltip-content={{.locale.Tr "repo.issues.label_archive_tooltip"}}>
4+
<input type="checkbox"
5+
name="show_archived_labels"
6+
class="show-archived-labels-checkbox"
7+
>
8+
{{.locale.Tr "repo.issues.show_archived_labels"}}
9+
</label>
10+
11+
<div class="ui right gt-f1">
412
<div class="ui right floated secondary filter menu">
513
<!-- Sort -->
614
<div class="ui dropdown type jump item">
@@ -30,7 +38,7 @@
3038

3139
<ul class="issue-label-list">
3240
{{range .Labels}}
33-
<li class="item">
41+
<li class="item" {{if gt .ArchivedUnix 0}}data-archived-label{{end}}>
3442
<div class="label-title">
3543
{{RenderLabel $.Context .}}
3644
{{if .Description}}<br><small class="desc">{{.Description | RenderEmoji $.Context}}</small>{{end}}

web_src/css/repo/issue-label.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,7 @@
4242
.issue-label-list .item.org-label {
4343
opacity: 0.7;
4444
}
45+
46+
.archived-label {
47+
border-right: 4px solid var(--color-yellow-badge);
48+
}

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function initRepoIssueListCheckboxes() {
7272
url,
7373
action,
7474
issueIDs,
75-
elementId
75+
elementId,
7676
).then(() => {
7777
window.location.reload();
7878
}).catch((reason) => {
@@ -203,3 +203,12 @@ export function initRepoIssueList() {
203203
initRepoIssueListAuthorDropdown();
204204
initIssuePinSort();
205205
}
206+
207+
export function initHighlightArchivedLabels() {
208+
document.querySelector('.show-archived-labels-checkbox')
209+
.addEventListener('input', () => {
210+
for (const archivedLabel of document.querySelectorAll('[data-archived-label]')) {
211+
archivedLabel.classList.toggle('archived-label');
212+
}
213+
});
214+
}

web_src/js/index.js

Lines changed: 3 additions & 2 deletions
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,
3535
} from './features/repo-issue.js';
3636
import {
3737
initRepoEllipsisButton,
@@ -81,7 +81,7 @@ import {initRepositoryActionView} from './components/RepoActionView.vue';
8181
import {initGlobalTooltips} from './modules/tippy.js';
8282
import {initGiteaFomantic} from './modules/fomantic.js';
8383
import {onDomReady} from './utils/dom.js';
84-
import {initRepoIssueList} from './features/repo-issue-list.js';
84+
import {initRepoIssueList, initHighlightArchivedLabels} from './features/repo-issue-list.js';
8585
import {initCommonIssueListQuickGoto} from './features/common-issue-list.js';
8686
import {initRepoDiffCommitBranchesAndTags} from './features/repo-diff-commit.js';
8787

@@ -149,6 +149,7 @@ onDomReady(() => {
149149
initRepoIssueContentHistory();
150150
initRepoIssueDue();
151151
initRepoIssueList();
152+
initHighlightArchivedLabels();
152153
initRepoIssueSidebarList();
153154
initRepoIssueReferenceRepositorySearch();
154155
initRepoIssueTimeTracking();

0 commit comments

Comments
 (0)