diff --git a/models/issues/label.go b/models/issues/label.go index 70906efb47d75..60a5836dd3818 100644 --- a/models/issues/label.go +++ b/models/issues/label.go @@ -113,10 +113,10 @@ func (l *Label) CalOpenIssues() { // SetArchived set the label as archived func (l *Label) SetArchived(isArchived bool) { - if isArchived && l.ArchivedUnix.IsZero() { - l.ArchivedUnix = timeutil.TimeStampNow() - } else { + if !isArchived { l.ArchivedUnix = timeutil.TimeStamp(0) + } else if isArchived && l.ArchivedUnix.IsZero() { + l.ArchivedUnix = timeutil.TimeStampNow() } } diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 2f32a9df7000a..13e090db30b6b 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1491,11 +1491,15 @@ issues.label_title = Name issues.label_description = Description issues.label_color = Color issues.label_exclusive = Exclusive +issues.active_labels = Active Labels +issues.archived_labels = Archived Labels 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_exclusive_desc = Name the label scope/item to make it mutually exclusive with other scope/ 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 +issues.active_label_count = %d active labels +issues.archived_label_count = %d archived issues.label_open_issues = %d open issues/pull requests issues.label_edit = Edit issues.label_delete = Delete diff --git a/routers/web/repo/issue_label.go b/routers/web/repo/issue_label.go index 257610d3af54b..68659351294ab 100644 --- a/routers/web/repo/issue_label.go +++ b/routers/web/repo/issue_label.go @@ -61,12 +61,32 @@ func RetrieveLabels(ctx *context.Context) { ctx.ServerError("RetrieveLabels.GetLabels", err) return } + // total number of labels + ctx.Data["NumLabels"] = len(labels) + var archivedLabels []*issues_model.Label + var nonArchivedLabels []*issues_model.Label for _, l := range labels { l.CalOpenIssues() + if l.IsArchived() { + archivedLabels = append(archivedLabels, l) + } else { + nonArchivedLabels = append(nonArchivedLabels, l) + } } + // archivedLabels + ctx.Data["NumArchivedLabels"] = len(archivedLabels) - ctx.Data["Labels"] = labels + // non archived label a.k.a. active labels + ctx.Data["NumNonArchivedLabels"] = len(nonArchivedLabels) + + includeArchivedLabel := ctx.FormOptionalBool("archived_label") + if includeArchivedLabel.IsTrue() { + ctx.Data["IsPageArchivedLabels"] = true + ctx.Data["Labels"] = archivedLabels + } else { + ctx.Data["Labels"] = nonArchivedLabels + } if ctx.Repo.Owner.IsOrganization() { orgLabels, err := issues_model.GetLabelsByOrgID(ctx, ctx.Repo.Owner.ID, ctx.FormString("sort"), db.ListOptions{}) @@ -95,7 +115,6 @@ func RetrieveLabels(ctx *context.Context) { ctx.Data["OrganizationLink"] = ctx.Org.OrgLink } } - ctx.Data["NumLabels"] = len(labels) ctx.Data["SortType"] = ctx.FormString("sort") } diff --git a/templates/repo/issue/labels/label_list.tmpl b/templates/repo/issue/labels/label_list.tmpl index c15833d952d9a..14b9c65cfca01 100644 --- a/templates/repo/issue/labels/label_list.tmpl +++ b/templates/repo/issue/labels/label_list.tmpl @@ -1,5 +1,28 @@

- {{.locale.Tr "repo.issues.label_count" .NumLabels}} + {{if eq .NumLabels 0}} + {{.locale.Tr "repo.issues.label_count" .NumLabels}} + {{else}} + + {{.locale.Tr "repo.issues.active_label_count" .NumNonArchivedLabels}} + + {{if gt .NumArchivedLabels 0}} + + {{.locale.Tr "repo.issues.archived_label_count" .NumArchivedLabels}} + + + {{svg "octicon-info" 12}} + + {{end}} + {{end}} + +
+ {{if not .IsPageArchivedLabels}} + {{.locale.Tr "repo.issues.active_labels"}} + {{else}} + {{.locale.Tr "repo.issues.archived_labels"}} + {{end}} +
+
diff --git a/web_src/css/repo/issue-label.css b/web_src/css/repo/issue-label.css index a2eb0344a5013..bd1723943e48b 100644 --- a/web_src/css/repo/issue-label.css +++ b/web_src/css/repo/issue-label.css @@ -42,3 +42,8 @@ .issue-label-list .item.org-label { opacity: 0.7; } + +.label-category { + width: 55%; + margin-left: auto; +}