feat: mention teammates from Today updates (Closes #1064)
This commit is contained in:
1 parent
a65aed5862
commit
a6c769901d
8 files changed
+104
-27
No files matched your search
+13
-16
@@ -497,22 +497,19 @@
|
||||
{headers:{Accept:'application/json'}},
|
||||
);
|
||||
}
|
||||
const issueMentions = createMentionComposer({
|
||||
textarea:qs('#issue-comment'), listbox:qs('#issue-comment-mentions'),
|
||||
status:qs('#issue-comment-mention-status'), getRepository:()=>selectedIssue?.repository,
|
||||
loadCandidates:loadMentionCandidates,
|
||||
const [issueMentions, pullMentions, updateMentions, todayProgressMentions] = [
|
||||
['issue-comment',()=>selectedIssue?.repository],
|
||||
['pull-comment',()=>selectedPull?.repository],
|
||||
['update-reply',()=>selectedUpdate?.repository],
|
||||
['today-progress-body',()=>currentTodayProgressTarget()?.repository],
|
||||
].map(([id,getRepository]) => {
|
||||
const controller = createMentionComposer({
|
||||
textarea:qs('#'+id), listbox:qs('#'+id+'-mentions'),
|
||||
status:qs('#'+id+'-mention-status'), getRepository, loadCandidates:loadMentionCandidates,
|
||||
});
|
||||
controller.start();
|
||||
return controller;
|
||||
});
|
||||
const pullMentions = createMentionComposer({
|
||||
textarea:qs('#pull-comment'), listbox:qs('#pull-comment-mentions'),
|
||||
status:qs('#pull-comment-mention-status'), getRepository:()=>selectedPull?.repository,
|
||||
loadCandidates:loadMentionCandidates,
|
||||
});
|
||||
const updateMentions = createMentionComposer({
|
||||
textarea:qs('#update-reply'), listbox:qs('#update-reply-mentions'),
|
||||
status:qs('#update-reply-mention-status'), getRepository:()=>selectedUpdate?.repository,
|
||||
loadCandidates:loadMentionCandidates,
|
||||
});
|
||||
[issueMentions, pullMentions, updateMentions].forEach(controller => controller.start());
|
||||
|
||||
async function api(url) {
|
||||
const response = await fetch(url, { headers: { Accept: 'application/json' } });
|
||||
@@ -1967,7 +1964,7 @@
|
||||
}
|
||||
const todayProgressView = createTodayProgressView({
|
||||
progress:todayProgress, currentTarget:currentTodayProgressTarget, qs, photos:todayProgressPhotos,
|
||||
voice:todayProgressVoice,
|
||||
voice:todayProgressVoice, mentions:todayProgressMentions,
|
||||
activity:mountTodayProgressActivity(qs,fetchReviewJson,actionHydrator,renderMarkdown),
|
||||
announce:message => { qs('#my-work-action-status').textContent = message; },
|
||||
onAdmitted:() => refreshMyWorkView(),
|
||||
|
||||
@@ -1558,6 +1558,8 @@
|
||||
</section>
|
||||
<label for="today-progress-body">Update</label>
|
||||
<textarea id="today-progress-body" rows="5" maxlength="2000" placeholder="What changed, what you learned, or what comes next"></textarea>
|
||||
<div class="mention-options" id="today-progress-body-mentions" role="listbox" aria-label="Teammates" hidden></div>
|
||||
<div class="mention-status small" id="today-progress-body-mention-status" aria-live="polite"></div>
|
||||
<section class="voice-conversation" id="voice-today-progress" data-draft-label="progress update" aria-label="Dictate Today progress update" hidden>
|
||||
<div class="voice-conversation-controls">
|
||||
<button id="start-voice-today-progress" type="button">Dictate update</button>
|
||||
|
||||
@@ -247,14 +247,18 @@ function mountTodayProgressActivity(qs, fetchJson, actionSource = {}, render) {
|
||||
return activity;
|
||||
}
|
||||
|
||||
function createTodayProgressView({ progress, currentTarget, qs, photos, voice, activity, announce = () => {}, onAdmitted = () => {} }) {
|
||||
function createTodayProgressView({ progress, currentTarget, qs, photos, voice, activity, mentions, announce = () => {}, onAdmitted = () => {} }) {
|
||||
const sheet = qs('#today-progress-sheet');
|
||||
const body = qs('#today-progress-body');
|
||||
const status = qs('#today-progress-status');
|
||||
const launcher = qs('[data-mobile-today-update]');
|
||||
let openedTarget = null;
|
||||
|
||||
const update = () => { launcher.hidden = !currentTarget(); };
|
||||
const update = () => {
|
||||
const target = currentTarget();
|
||||
launcher.hidden = !target;
|
||||
if (openedTarget && target?.identity !== openedTarget.identity) mentions?.dismiss?.();
|
||||
};
|
||||
const checkpoint = async () => {
|
||||
if (!openedTarget) return false;
|
||||
try {
|
||||
@@ -271,6 +275,7 @@ function createTodayProgressView({ progress, currentTarget, qs, photos, voice, a
|
||||
const close = () => {
|
||||
voice?.cancel?.();
|
||||
activity?.close?.();
|
||||
mentions?.dismiss?.();
|
||||
if (sheet.open) sheet.close();
|
||||
openedTarget = null;
|
||||
};
|
||||
@@ -278,6 +283,7 @@ function createTodayProgressView({ progress, currentTarget, qs, photos, voice, a
|
||||
launcher.addEventListener('click', async () => {
|
||||
const target = currentTarget();
|
||||
if (!target) return;
|
||||
mentions?.dismiss?.();
|
||||
openedTarget = target;
|
||||
qs('#today-progress-target').textContent = target.label + (target.title ? ' · ' + target.title : '');
|
||||
body.value = progress.load(target.identity);
|
||||
|
||||
Reference in new issue
Block a user