Hide archived labels by default from the suggestions when assigning labels for an issue (#27451)
Followup of #27115 Finally closes #25237 ## Screenshots ### Issue Sidebar <img width="513" alt="image" src="9f7fda2f
-5a03-4684-8619-fd3498a95b41"> ### PR sidebar <img width="367" alt="image" src="53db9b64
-faec-4a67-91d6-76945596a469"> ### PR sidebar with archived labels shown <img width="352" alt="image" src="9dc5050f
-4e69-4f76-bb83-582480a2281e"> --------- Signed-off-by: puni9869 <punitinani1@hotmail.com> Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
parent
d98c863884
commit
4adc2a828d
6 changed files with 35 additions and 10 deletions
|
@ -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';
|
||||
|
@ -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
|
||||
|
|
|
@ -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() {
|
||||
if (!document.querySelector('.archived-label-hint')) return;
|
||||
for (const label of document.querySelectorAll('[data-is-archived]')) {
|
||||
toggleElem(label, label.classList.contains('checked'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ import {
|
|||
initRepoIssueWipTitle,
|
||||
initRepoPullRequestMergeInstruction,
|
||||
initRepoPullRequestAllowMaintainerEdit,
|
||||
initRepoPullRequestReview, initRepoIssueSidebarList
|
||||
initRepoPullRequestReview, initRepoIssueSidebarList, initArchivedLabelHandler,
|
||||
} from './features/repo-issue.js';
|
||||
import {
|
||||
initRepoEllipsisButton,
|
||||
|
@ -152,6 +152,7 @@ onDomReady(() => {
|
|||
initRepoIssueDue();
|
||||
initRepoIssueList();
|
||||
initRepoIssueSidebarList();
|
||||
initArchivedLabelHandler();
|
||||
initRepoIssueReferenceRepositorySearch();
|
||||
initRepoIssueTimeTracking();
|
||||
initRepoIssueWipTitle();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue