feat: "assign to me" button on PRs and issues
includes: Tests for assignees on issues Move assignees selector of new Issue to assignees.tmpl
This commit is contained in:
parent
b5b9cc1c38
commit
2feb3d03d7
8 changed files with 172 additions and 68 deletions
|
@ -12,6 +12,26 @@ import {emojiHTML} from './emoji.js';
|
|||
|
||||
const {appSubUrl} = window.config;
|
||||
|
||||
// if there are draft comments, confirm before reloading, to avoid losing comments
|
||||
export function reloadConfirmDraftComment() {
|
||||
const commentTextareas = [
|
||||
document.querySelector('.edit-content-zone:not(.tw-hidden) textarea'),
|
||||
document.querySelector('#comment-form textarea'),
|
||||
];
|
||||
for (const textarea of commentTextareas) {
|
||||
// Most users won't feel too sad if they lose a comment with 10 chars, they can re-type these in seconds.
|
||||
// But if they have typed more (like 50) chars and the comment is lost, they will be very unhappy.
|
||||
if (textarea && textarea.value.trim().length > 10) {
|
||||
textarea.parentElement.scrollIntoView();
|
||||
if (!window.confirm('Page will be reloaded, but there are draft comments. Continuing to reload will discard the comments. Continue?')) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
export function initRepoIssueTimeTracking() {
|
||||
$(document).on('click', '.issue-add-time', () => {
|
||||
$('.issue-start-time-modal').modal({
|
||||
|
@ -668,6 +688,40 @@ export function initRepoIssueBranchSelect() {
|
|||
});
|
||||
}
|
||||
|
||||
export function initRepoIssueAssignMe() {
|
||||
// Assign to me button
|
||||
document.querySelector('.ui.assignees.list .item.no-select .select-assign-me')
|
||||
?.addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
const selectMe = e.target;
|
||||
const noSelect = selectMe.parentElement;
|
||||
const selectorList = document.querySelector('.ui.select-assignees .menu');
|
||||
|
||||
if (selectMe.getAttribute('data-action') === 'update') {
|
||||
(async () => {
|
||||
await updateIssuesMeta(
|
||||
selectMe.getAttribute('data-update-url'),
|
||||
selectMe.getAttribute('data-action'),
|
||||
selectMe.getAttribute('data-issue-id'),
|
||||
selectMe.getAttribute('data-id'),
|
||||
);
|
||||
reloadConfirmDraftComment();
|
||||
})();
|
||||
} else {
|
||||
for (const item of selectorList.querySelectorAll('.item')) {
|
||||
if (item.getAttribute('data-id') === selectMe.getAttribute('data-id')) {
|
||||
item.classList.add('checked');
|
||||
item.querySelector('.octicon-check').classList.remove('tw-invisible');
|
||||
}
|
||||
}
|
||||
document.querySelector(selectMe.getAttribute('data-id-selector')).classList.remove('tw-hidden');
|
||||
noSelect.classList.add('tw-hidden');
|
||||
document.querySelector(selectorList.getAttribute('data-id')).value = selectMe.getAttribute('data-id');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function initSingleCommentEditor($commentForm) {
|
||||
// pages:
|
||||
// * normal new issue/pr page, no status-button
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue