Skip to content
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

Hide archived labels by default from the suggestions when assigning labels for an issue #27451

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e25b7fc
Adding archive label functionality for label selector in issue detail…
puni9869 Oct 5, 2023
2fa6357
Merge branch 'main' into punit/update-pr-label-filter-archived-functi…
puni9869 Oct 5, 2023
8db7e06
Reverting the linted code
puni9869 Oct 5, 2023
f0be3f7
Merge branch 'main' into punit/update-pr-label-filter-archived-functi…
puni9869 Oct 5, 2023
0560ad0
Merge branch 'main' into punit/update-pr-label-filter-archived-functi…
puni9869 Oct 5, 2023
90116d8
Hiding the labels when there is no archived label is tagged in issue …
puni9869 Oct 5, 2023
33b01af
Merge branch 'main' into punit/update-pr-label-filter-archived-functi…
puni9869 Oct 5, 2023
1a55eae
using archived label template
puni9869 Oct 5, 2023
62cbe2b
Merge branch 'main' into punit/update-pr-label-filter-archived-functi…
puni9869 Oct 6, 2023
1f592c3
Merge branch 'main' into punit/update-pr-label-filter-archived-functi…
puni9869 Oct 6, 2023
009f923
Merge branch 'main' into punit/update-pr-label-filter-archived-functi…
puni9869 Oct 7, 2023
107accb
Style correction
puni9869 Oct 7, 2023
5e855a5
Merge branch 'main' into punit/update-pr-label-filter-archived-functi…
puni9869 Oct 7, 2023
d281bbe
Merge branch 'main' into punit/update-pr-label-filter-archived-functi…
puni9869 Oct 7, 2023
e9062ba
Merge branch 'main' into punit/update-pr-label-filter-archived-functi…
puni9869 Oct 8, 2023
2da88f7
Indentation for anchor tag
puni9869 Oct 9, 2023
a375801
Typo
puni9869 Oct 9, 2023
a43dd00
Similar ui for archived hint.
puni9869 Oct 9, 2023
6e70661
Merge branch 'main' into punit/update-pr-label-filter-archived-functi…
puni9869 Oct 9, 2023
9d8ed4b
Merge branch 'main' into punit/update-pr-label-filter-archived-functi…
puni9869 Oct 9, 2023
7101b32
Merge branch 'main' into punit/update-pr-label-filter-archived-functi…
puni9869 Oct 10, 2023
c4db3ad
Merge branch 'main' into punit/update-pr-label-filter-archived-functi…
puni9869 Oct 11, 2023
e3bffa7
Update web_src/js/features/repo-issue.js
silverwind Oct 13, 2023
b17d36a
Update web_src/js/features/repo-issue.js
silverwind Oct 13, 2023
013008e
Update web_src/js/features/repo-issue.js
silverwind Oct 13, 2023
c3f1a40
Merge branch 'main' into punit/update-pr-label-filter-archived-functi…
puni9869 Oct 13, 2023
f7813de
Adding comments
puni9869 Oct 15, 2023
f52da8f
Merge branch 'main' into punit/update-pr-label-filter-archived-functi…
GiteaBot Oct 17, 2023
7b84f89
Merge branch 'main' into punit/update-pr-label-filter-archived-functi…
GiteaBot Oct 17, 2023
12411af
Merge branch 'main' into punit/update-pr-label-filter-archived-functi…
GiteaBot Oct 17, 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: 2 additions & 4 deletions templates/repo/issue/filter_actions.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@
<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">
<div class="item issue-action gt-df gt-sb" 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}}
{{template "repo/issue/labels/label_archived" .}}
</div>
{{end}}
</div>
Expand Down
12 changes: 8 additions & 4 deletions templates/repo/issue/labels/labels_selector_field.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
<div class="divider"></div>
{{end}}
{{$previousExclusiveScope = $exclusiveScope}}
<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 .}}
{{if .Description}}<br><small class="desc">{{.Description | RenderEmoji $.Context}}</small>{{end}}</a>
<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 .}}
{{if .Description}}<br><small class="desc">{{.Description | RenderEmoji $.Context}}</small>{{end}}
<p class="archived-label-hint">{{template "repo/issue/labels/label_archived" .}}</p>
</a>
{{end}}
<div class="divider"></div>
{{$previousExclusiveScope = "_no_scope"}}
Expand All @@ -32,8 +34,10 @@
<div class="divider"></div>
{{end}}
{{$previousExclusiveScope = $exclusiveScope}}
<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 .}}
{{if .Description}}<br><small class="desc">{{.Description | RenderEmoji $.Context}}</small>{{end}}</a>
<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 .}}
{{if .Description}}<br><small class="desc">{{.Description | RenderEmoji $.Context}}</small>{{end}}
<p class="archived-label-hint">{{template "repo/issue/labels/label_archived" .}}</p>
</a>
{{end}}
{{else}}
<div class="disabled item">{{ctx.Locale.Tr "repo.issues.new.no_items"}}</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 @@ -45,3 +45,8 @@
.label-operation .label {
height: fit-content;
}

.archived-label-hint {
float: right;
margin: -12px;
}
6 changes: 5 additions & 1 deletion web_src/js/features/repo-issue-list.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import $ from 'jquery';
import {updateIssuesMeta} from './repo-issue.js';
import {toggleElem} from '../utils/dom.js';
import {toggleElem, hideElem} from '../utils/dom.js';
import {htmlEscape} from 'escape-goat';
import {confirmModal} from './comp/ConfirmModal.js';
import {showErrorToast} from '../modules/toast.js';
Expand Down Expand Up @@ -194,6 +194,10 @@ function initArchivedLabelFilter() {
const url = new URL(window.location.href);
const archivedLabels = document.querySelectorAll('[data-is-archived]');

if (!archivedLabels.length) {
hideElem('.archived-label-filter');
return;
}
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
Expand Down
13 changes: 13 additions & 0 deletions web_src/js/features/repo-issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -680,3 +680,16 @@ export function initIssueTemplateCommentEditors($commentForm) {
initCombo($(el));
}
}

// This function used to show and hide archived label on issue/pr
// page in the sidebar where we select the labels
// If we have any archived label tagged to issue and pr. We will show that
// archived label with checked classed otherwise we will hide it
// with the help of this function.
// This function runs globally.
export function initArchivedLabelHandler() {
puni9869 marked this conversation as resolved.
Show resolved Hide resolved
if (!document.querySelector('.archived-label-hint')) return;
Copy link
Member

@silverwind silverwind Oct 13, 2023

Choose a reason for hiding this comment

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

Why are we selecting for this hint? Seems brittle. Can the below loop stand on its own without this? If not, at least add a comment explaining the reason for this selector.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will refactor this naming a little bit.

for (const label of document.querySelectorAll('[data-is-archived]')) {
toggleElem(label, label.classList.contains('checked'));
}
}
3 changes: 2 additions & 1 deletion web_src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
initRepoIssueWipTitle,
initRepoPullRequestMergeInstruction,
initRepoPullRequestAllowMaintainerEdit,
initRepoPullRequestReview, initRepoIssueSidebarList
initRepoPullRequestReview, initRepoIssueSidebarList, initArchivedLabelHandler,
} from './features/repo-issue.js';
import {
initRepoEllipsisButton,
Expand Down Expand Up @@ -152,6 +152,7 @@ onDomReady(() => {
initRepoIssueDue();
initRepoIssueList();
initRepoIssueSidebarList();
initArchivedLabelHandler();
initRepoIssueReferenceRepositorySearch();
initRepoIssueTimeTracking();
initRepoIssueWipTitle();
Expand Down