Skip to content

Archive labels UI #26502

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

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
c4b1cd1
Adding in ui archive labels
puni9869 Aug 2, 2023
3a87634
Merge branch 'main' into punit/Archive-labels
puni9869 Aug 2, 2023
f6684fc
Merge branch 'go-gitea:main' into punit/Archive-labels
puni9869 Aug 4, 2023
1cb8b30
Merge branch 'go-gitea:main' into punit/Archive-labels
puni9869 Aug 4, 2023
9cf9b5d
Merge branch 'go-gitea:main' into punit/Archive-labels
puni9869 Aug 4, 2023
99fadb9
init label archive
puni9869 Aug 4, 2023
197a603
Adding archive unix in api and repo and org level labels
puni9869 Aug 4, 2023
c5447e5
Linting files
puni9869 Aug 4, 2023
f0752e0
Adding to fixtures
puni9869 Aug 4, 2023
44d24ac
Adding archived check in templates
puni9869 Aug 4, 2023
903a794
Fixing fixture for labels
puni9869 Aug 4, 2023
fe05e02
Merge branch 'go-gitea:main' into punit/Archive-labels
puni9869 Aug 6, 2023
b2cc90c
Merge branch 'go-gitea:main' into punit/Archive-labels
puni9869 Aug 9, 2023
ce44b9a
Merge branch 'go-gitea:main' into punit/Archive-labels
puni9869 Aug 12, 2023
5a78bd9
Updating migrations
puni9869 Aug 13, 2023
2008377
Wrapping the archived function
puni9869 Aug 13, 2023
1957b88
Merge branch 'go-gitea:main' into punit/Archive-labels
puni9869 Aug 13, 2023
39b135b
Fixing migration
puni9869 Aug 13, 2023
0786a6f
Suggestions addressed
puni9869 Aug 13, 2023
24fb5c8
Linting the migration file
puni9869 Aug 13, 2023
1418372
Merge branch 'main' into punit/Archive-labels
puni9869 Aug 13, 2023
d97c86e
Adding archived labels route
puni9869 Aug 13, 2023
fe2c4da
Merge branch 'main' into punit/Archive-labels
puni9869 Aug 13, 2023
af7db84
Merge remote-tracking branch 'origin/punit/Archive-labels' into punit…
puni9869 Aug 14, 2023
7fa50dd
Merge branch 'main' into punit/Archive-labels
puni9869 Aug 14, 2023
9502271
Update templates/repo/issue/labels/edit_delete_label.tmpl
puni9869 Aug 14, 2023
c9e2b53
Reverting original size of svg info
puni9869 Aug 14, 2023
129c231
Merge branch 'punit/Archive-labels' into punit/Archive-labels-ui
puni9869 Aug 14, 2023
9f59b74
Adding archive ui on label page
puni9869 Aug 14, 2023
35f1025
Merge branch 'go-gitea:main' into punit/Archive-labels-ui
puni9869 Aug 14, 2023
6576804
Adding translations and filtering the unarchived and archived labels …
puni9869 Aug 14, 2023
6cea026
Adding translations
puni9869 Aug 14, 2023
0edd269
Linting
puni9869 Aug 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions models/issues/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Comment on lines -116 to -118
Copy link
Member

Choose a reason for hiding this comment

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

Yep, you're absolutely right.
I missed that edge case.

if !isArchived {
l.ArchivedUnix = timeutil.TimeStamp(0)
} else if isArchived && l.ArchivedUnix.IsZero() {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
} else if isArchived && l.ArchivedUnix.IsZero() {
} else if l.ArchivedUnix.IsZero() { // Only change the date when it is newly archived.

l.ArchivedUnix = timeutil.TimeStampNow()
}
}

Expand Down
4 changes: 4 additions & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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 <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
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
Expand Down
23 changes: 21 additions & 2 deletions routers/web/repo/issue_label.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
Expand Down Expand Up @@ -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")
}

Expand Down
34 changes: 29 additions & 5 deletions templates/repo/issue/labels/label_list.tmpl
Copy link
Member

Choose a reason for hiding this comment

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

Hmm… I've thought about what the best design for it is.
I think the winner is the following design:
grafik
(That can be created with the following changes:

<h4 class="ui top attached header gt-df">
  <span class="gt-f1">18 labels</span>
  <label class="gt-f1"><input type="checkbox" class="show-archived-labels-checkbox"> Show archived labels</label>
  <div class="gt-f1"></h4>

)
Where we only show the middle checkbox if there are archived labels.
It needs the following JS pseudocode:

document.querySelector('.show-archived-labels-checkbox').addEventListener('input',
  e => for(const archivedLabel of document.querySelectorAll('.archived-label'))
    toggleElem(archivedLabel, e.target.checked)
  )
);

We should highlight the archived labels, i.e. by using a different background for them.
Other than that, archived labels should not be treated differently on this page.

Copy link
Member

Choose a reason for hiding this comment

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

That way, we don't need a separate page, hide unnecessary information by default, add no technical debt but still allow configuring anything the user wants to configure.

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct, this UI is good and easy to use. here is the implementation https://github.com/go-gitea/gitea/pull/26511/files

Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
<h4 class="ui top attached header">
{{.locale.Tr "repo.issues.label_count" .NumLabels}}
{{if eq .NumLabels 0}}
{{.locale.Tr "repo.issues.label_count" .NumLabels}}
{{else}}
<span>
<a class="text light" href="{{.Link}}">{{.locale.Tr "repo.issues.active_label_count" .NumNonArchivedLabels}}</a>
</span>
{{if gt .NumArchivedLabels 0}}
<span class="gt-ml-2">
<a class="text light" href="{{.Link}}?archived_label=true">{{.locale.Tr "repo.issues.archived_label_count" .NumArchivedLabels}}</a>
</span>
<i class="gt-dif gt-ml-1 gt-mt-3" data-tooltip-content={{.locale.Tr "repo.issues.label_archive_tooltip"}}>
{{svg "octicon-info" 12}}
</i>
{{end}}
{{end}}

<div class="gt-dif gt-jc label-category">
{{if not .IsPageArchivedLabels}}
{{.locale.Tr "repo.issues.active_labels"}}
{{else}}
{{.locale.Tr "repo.issues.archived_labels"}}
{{end}}
</div>

<div class="ui right">
<div class="ui right floated secondary filter menu">
<!-- Sort -->
Expand All @@ -9,10 +32,11 @@
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
</span>
<div class="menu">
<a class="{{if or (eq .SortType "alphabetically") (not .SortType)}}active {{end}}item" href="{{$.Link}}?sort=alphabetically&state={{$.State}}">{{.locale.Tr "repo.issues.label.filter_sort.alphabetically"}}</a>
<a class="{{if eq .SortType "reversealphabetically"}}active {{end}}item" href="{{$.Link}}?sort=reversealphabetically&state={{$.State}}">{{.locale.Tr "repo.issues.label.filter_sort.reverse_alphabetically"}}</a>
<a class="{{if eq .SortType "leastissues"}}active {{end}}item" href="{{$.Link}}?sort=leastissues&state={{$.State}}">{{.locale.Tr "repo.milestones.filter_sort.least_issues"}}</a>
<a class="{{if eq .SortType "mostissues"}}active {{end}}item" href="{{$.Link}}?sort=mostissues&state={{$.State}}">{{.locale.Tr "repo.milestones.filter_sort.most_issues"}}</a>

<a class="{{if or (eq .SortType "alphabetically") (not .SortType)}}active {{end}}item" href="{{$.Link}}?sort=alphabetically&state={{$.State}}&archived_label={{if .IsPageArchivedLabels}}true{{end}}">{{.locale.Tr "repo.issues.label.filter_sort.alphabetically"}}</a>
<a class="{{if eq .SortType "reversealphabetically"}}active {{end}}item" href="{{$.Link}}?sort=reversealphabetically&state={{$.State}}&archived_label={{if .IsPageArchivedLabels}}true{{end}}">{{.locale.Tr "repo.issues.label.filter_sort.reverse_alphabetically"}}</a>
<a class="{{if eq .SortType "leastissues"}}active {{end}}item" href="{{$.Link}}?sort=leastissues&state={{$.State}}&archived_label={{if .IsPageArchivedLabels}}true{{end}}">{{.locale.Tr "repo.milestones.filter_sort.least_issues"}}</a>
<a class="{{if eq .SortType "mostissues"}}active {{end}}item" href="{{$.Link}}?sort=mostissues&state={{$.State}}&archived_label={{if .IsPageArchivedLabels}}true{{end}}">{{.locale.Tr "repo.milestones.filter_sort.most_issues"}}</a>
Comment on lines +36 to +39
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<a class="{{if or (eq .SortType "alphabetically") (not .SortType)}}active {{end}}item" href="{{$.Link}}?sort=alphabetically&state={{$.State}}&archived_label={{if .IsPageArchivedLabels}}true{{end}}">{{.locale.Tr "repo.issues.label.filter_sort.alphabetically"}}</a>
<a class="{{if eq .SortType "reversealphabetically"}}active {{end}}item" href="{{$.Link}}?sort=reversealphabetically&state={{$.State}}&archived_label={{if .IsPageArchivedLabels}}true{{end}}">{{.locale.Tr "repo.issues.label.filter_sort.reverse_alphabetically"}}</a>
<a class="{{if eq .SortType "leastissues"}}active {{end}}item" href="{{$.Link}}?sort=leastissues&state={{$.State}}&archived_label={{if .IsPageArchivedLabels}}true{{end}}">{{.locale.Tr "repo.milestones.filter_sort.least_issues"}}</a>
<a class="{{if eq .SortType "mostissues"}}active {{end}}item" href="{{$.Link}}?sort=mostissues&state={{$.State}}&archived_label={{if .IsPageArchivedLabels}}true{{end}}">{{.locale.Tr "repo.milestones.filter_sort.most_issues"}}</a>
<a class="{{if or (eq .SortType "alphabetically") (not .SortType)}}active {{end}}item" href="{{$.Link}}?sort=alphabetically&state={{$.State}}{{if .IsPageArchivedLabels}}&archived_label=true{{end}}">{{.locale.Tr "repo.issues.label.filter_sort.alphabetically"}}</a>
<a class="{{if eq .SortType "reversealphabetically"}}active {{end}}item" href="{{$.Link}}?sort=reversealphabetically&state={{$.State}}{{if .IsPageArchivedLabels}}&archived_label=true{{end}}">{{.locale.Tr "repo.issues.label.filter_sort.reverse_alphabetically"}}</a>
<a class="{{if eq .SortType "leastissues"}}active {{end}}item" href="{{$.Link}}?sort=leastissues&state={{$.State}}{{if .IsPageArchivedLabels}}&archived_label=true{{end}}">{{.locale.Tr "repo.milestones.filter_sort.least_issues"}}</a>
<a class="{{if eq .SortType "mostissues"}}active {{end}}item" href="{{$.Link}}?sort=mostissues&state={{$.State}}{{if .IsPageArchivedLabels}}&archived_label=true{{end}}">{{.locale.Tr "repo.milestones.filter_sort.most_issues"}}</a>

</div>
</div>
</div>
Expand Down
5 changes: 5 additions & 0 deletions web_src/css/repo/issue-label.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@
.issue-label-list .item.org-label {
opacity: 0.7;
}

.label-category {
width: 55%;
margin-left: auto;
}