Add comment threads, reactions, notifications and page watching
Comments are now threads: replies hang off a thread's first comment, which alone points at text and can be resolved. Authors can edit their own comments, and anyone who can comment can react with an emoji. Resolved threads stop lighting text in the editor and fold away in the panel. Comments can @mention people. People watch the pages they create or comment on, and can watch or mute a page from its menu. Muting is remembered. The inbox collects comments on watched pages, replies in your threads, mentions (in comments and in page text), pages shared with you and resolved threads. It shows an unread badge in the sidebar, polled every minute, and links straight to the thread. Nobody hears about their own actions or about pages they cannot open, and a notification hides its text once access is lost. Unread notifications are emailed as a digest every few minutes unless the person turns that off. Read ones are pruned after 90 days. The jobs registry can now run jobs on a timer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7968e82cc2
commit
2b78c167e2
31 files changed
+3083
-166
No files matched your search
@@ -8,6 +8,7 @@ import { useFormErrors } from "../composables/useFormErrors";
|
||||
import { SIDEBAR_DEFAULT, clampWidth, useSidebar } from "../composables/useSidebar";
|
||||
import { useAuthStore } from "../stores/auth";
|
||||
import { useFavoritesStore } from "../stores/favorites";
|
||||
import { useNotificationsStore } from "../stores/notifications";
|
||||
import { useSpacesStore } from "../stores/spaces";
|
||||
import { atLeast, useWorkspacesStore } from "../stores/workspaces";
|
||||
import PageTreeNode from "./PageTreeNode.vue";
|
||||
@@ -22,6 +23,7 @@ const auth = useAuthStore();
|
||||
const workspaces = useWorkspacesStore();
|
||||
const spaces = useSpacesStore();
|
||||
const favorites = useFavoritesStore();
|
||||
const notifications = useNotificationsStore();
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const { mode } = useTheme();
|
||||
@@ -37,6 +39,8 @@ function showError(e: unknown) {
|
||||
}
|
||||
|
||||
onMounted(() => workspaces.load().catch(showError));
|
||||
onMounted(() => notifications.start());
|
||||
onBeforeUnmount(() => notifications.stop());
|
||||
watch(
|
||||
() => workspaces.current?.id,
|
||||
(id) => {
|
||||
@@ -192,6 +196,15 @@ function signOut() {
|
||||
<RouterLink to="/" :class="[navRow, 'mt-1.5']" :exact-active-class="navActive">
|
||||
<DwIcon name="home" :size="16" />{{ $t("sidebar.home") }}
|
||||
</RouterLink>
|
||||
<RouterLink :to="{ name: 'notifications' }" :class="navRow" :active-class="navActive" data-testid="nav-inbox">
|
||||
<DwIcon name="bell" :size="16" />{{ $t("notifications.title") }}
|
||||
<span
|
||||
v-if="notifications.unread"
|
||||
class="ml-auto rounded-full bg-primary px-1.5 text-ui-xs font-semibold tabular-nums text-on-primary"
|
||||
:aria-label="$t('notifications.unreadCount', { n: notifications.unread }, notifications.unread)"
|
||||
>{{ notifications.unread > 99 ? "99+" : notifications.unread }}</span
|
||||
>
|
||||
</RouterLink>
|
||||
<RouterLink
|
||||
v-if="ws"
|
||||
:to="{ name: 'workspace-settings', params: { id: ws.id } }"
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
<!-- SPDX-License-Identifier: AGPL-3.0-or-later -->
|
||||
<script setup lang="ts">
|
||||
import type { MemberUser } from "@docwell/api-client";
|
||||
import { DwButton } from "@docwell/ui";
|
||||
import { computed, nextTick, ref, watch } from "vue";
|
||||
import { useApi } from "../api";
|
||||
|
||||
// A comment text box with "@" mentions: typing @ and a few letters lists the
|
||||
// workspace's people; picking one inserts "@Name" and remembers their id, so
|
||||
// the server can notify them. Ctrl/Cmd+Enter sends, Esc cancels.
|
||||
const props = defineProps<{
|
||||
workspace: string;
|
||||
placeholder: string;
|
||||
submitLabel: string;
|
||||
busy: boolean;
|
||||
initial?: string;
|
||||
autofocus?: boolean;
|
||||
}>();
|
||||
const emit = defineEmits<{ submit: [body: string, mentions: string[]]; cancel: [] }>();
|
||||
const api = useApi();
|
||||
|
||||
const body = ref(props.initial ?? "");
|
||||
const box = ref<HTMLTextAreaElement | null>(null);
|
||||
const picked = ref<MemberUser[]>([]);
|
||||
const matches = ref<MemberUser[]>([]);
|
||||
const highlighted = ref(0);
|
||||
// Where the "@" being completed starts, or -1.
|
||||
const at = ref(-1);
|
||||
let lookup = 0;
|
||||
|
||||
watch(
|
||||
() => props.autofocus,
|
||||
async (v) => {
|
||||
if (!v) return;
|
||||
await nextTick();
|
||||
box.value?.focus();
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
const label = (u: MemberUser) => u.name || u.email;
|
||||
|
||||
async function onInput() {
|
||||
const el = box.value;
|
||||
if (!el) return;
|
||||
const before = body.value.slice(0, el.selectionStart);
|
||||
const m = /(?:^|\s)@([^\s@]{0,30})$/.exec(before);
|
||||
if (!m || !props.workspace) {
|
||||
at.value = -1;
|
||||
matches.value = [];
|
||||
return;
|
||||
}
|
||||
at.value = before.length - m[1]!.length - 1;
|
||||
const id = ++lookup;
|
||||
const found = await api.workspaces.people(props.workspace, m[1]!, 6).catch(() => []);
|
||||
if (id === lookup) {
|
||||
matches.value = found;
|
||||
highlighted.value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
async function pick(u: MemberUser) {
|
||||
const el = box.value;
|
||||
if (!el || at.value < 0) return;
|
||||
const end = el.selectionStart;
|
||||
const text = `@${label(u)} `;
|
||||
body.value = body.value.slice(0, at.value) + text + body.value.slice(end);
|
||||
if (!picked.value.some((p) => p.id === u.id)) picked.value.push(u);
|
||||
const caret = at.value + text.length;
|
||||
at.value = -1;
|
||||
matches.value = [];
|
||||
await nextTick();
|
||||
el.focus();
|
||||
el.setSelectionRange(caret, caret);
|
||||
}
|
||||
|
||||
function onKeydown(e: KeyboardEvent) {
|
||||
if (matches.value.length) {
|
||||
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
||||
e.preventDefault();
|
||||
const n = matches.value.length;
|
||||
highlighted.value = (highlighted.value + (e.key === "ArrowDown" ? 1 : n - 1)) % n;
|
||||
return;
|
||||
}
|
||||
if (e.key === "Enter" || e.key === "Tab") {
|
||||
e.preventDefault();
|
||||
void pick(matches.value[highlighted.value]!);
|
||||
return;
|
||||
}
|
||||
if (e.key === "Escape") {
|
||||
e.preventDefault();
|
||||
matches.value = [];
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
|
||||
e.preventDefault();
|
||||
submit();
|
||||
} else if (e.key === "Escape") {
|
||||
e.preventDefault();
|
||||
emit("cancel");
|
||||
}
|
||||
}
|
||||
|
||||
// Only people whose "@Name" is still in the text count as mentioned.
|
||||
const mentions = computed(() => picked.value.filter((u) => body.value.includes(`@${label(u)}`)).map((u) => u.id));
|
||||
|
||||
function submit() {
|
||||
if (!body.value.trim() || props.busy) return;
|
||||
emit("submit", body.value, mentions.value);
|
||||
}
|
||||
|
||||
/** Clears the box after the comment was saved. */
|
||||
function reset() {
|
||||
body.value = "";
|
||||
picked.value = [];
|
||||
}
|
||||
defineExpose({ reset });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<form @submit.prevent="submit">
|
||||
<div class="relative">
|
||||
<textarea
|
||||
ref="box"
|
||||
v-model="body"
|
||||
rows="2"
|
||||
maxlength="5000"
|
||||
class="dw-input w-full"
|
||||
:aria-label="placeholder"
|
||||
:placeholder="placeholder"
|
||||
data-testid="comment-body"
|
||||
@input="onInput"
|
||||
@keydown="onKeydown"
|
||||
@blur="matches = []"
|
||||
/>
|
||||
<ul
|
||||
v-if="matches.length"
|
||||
class="absolute left-0 top-full z-20 mt-1 w-64 rounded-sm border border-line bg-surface-raised py-1 shadow-dialog"
|
||||
role="listbox"
|
||||
:aria-label="$t('editor.mentions')"
|
||||
>
|
||||
<li v-for="(u, i) in matches" :key="u.id" role="option" :aria-selected="i === highlighted">
|
||||
<button
|
||||
type="button"
|
||||
class="flex w-full flex-col px-3 py-1 text-left"
|
||||
:class="i === highlighted ? 'bg-surface-hover' : ''"
|
||||
@mousedown.prevent="pick(u)"
|
||||
>
|
||||
<span class="text-ui-md">{{ label(u) }}</span>
|
||||
<span v-if="u.name" class="text-ui-xs text-ink-muted">{{ u.email }}</span>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="mt-2 flex justify-end gap-2">
|
||||
<DwButton size="sm" variant="ghost" @click="emit('cancel')">{{ $t("comments.cancel") }}</DwButton>
|
||||
<DwButton size="sm" type="submit" variant="primary" :disabled="busy || !body.trim()" data-testid="comment-send">
|
||||
{{ submitLabel }}
|
||||
</DwButton>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
@@ -1,16 +1,19 @@
|
||||
<!-- SPDX-License-Identifier: AGPL-3.0-or-later -->
|
||||
<script setup lang="ts">
|
||||
import type { Comment } from "@docwell/api-client";
|
||||
import { DwButton, DwCallout } from "@docwell/ui";
|
||||
import { nextTick, ref, watch } from "vue";
|
||||
import { DwButton, DwCallout, DwIcon } from "@docwell/ui";
|
||||
import { computed, nextTick, ref, watch } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useApi } from "../api";
|
||||
import { useFormErrors } from "../composables/useFormErrors";
|
||||
import CommentBox from "./CommentBox.vue";
|
||||
|
||||
// The page's comments beside the text. A new comment starts from a text
|
||||
// selection in the editor (draft); active is the comment whose text is lit.
|
||||
// The page's comment threads beside the text. A new thread starts from a
|
||||
// text selection in the editor (draft); active is the thread whose text is
|
||||
// lit. Resolved threads fold away under their own heading.
|
||||
const props = defineProps<{
|
||||
page: string;
|
||||
workspace: string;
|
||||
comments: Comment[];
|
||||
draft: { quote: string; anchor: Record<string, unknown> | null } | null;
|
||||
active: string;
|
||||
@@ -21,60 +24,82 @@ const api = useApi();
|
||||
const { locale } = useI18n();
|
||||
const errors = useFormErrors();
|
||||
|
||||
const body = ref("");
|
||||
const QUICK = ["👍", "❤️", "🎉", "😄", "👀", "✅"];
|
||||
|
||||
const busy = ref(false);
|
||||
const box = ref<HTMLTextAreaElement | null>(null);
|
||||
const list = ref<HTMLElement | null>(null);
|
||||
const replyTo = ref("");
|
||||
const editing = ref("");
|
||||
const picker = ref("");
|
||||
const showResolved = ref(false);
|
||||
const newBox = ref<InstanceType<typeof CommentBox> | null>(null);
|
||||
|
||||
interface Thread {
|
||||
root: Comment;
|
||||
replies: Comment[];
|
||||
}
|
||||
const threads = computed(() => {
|
||||
const byRoot = new Map<string, Thread>();
|
||||
for (const c of props.comments) if (!c.parent) byRoot.set(c.id, { root: c, replies: [] });
|
||||
for (const c of props.comments) if (c.parent) byRoot.get(c.parent)?.replies.push(c);
|
||||
return [...byRoot.values()];
|
||||
});
|
||||
const open = computed(() => threads.value.filter((t) => !t.root.resolvedAt));
|
||||
const resolved = computed(() => threads.value.filter((t) => t.root.resolvedAt));
|
||||
|
||||
watch(
|
||||
() => props.draft,
|
||||
async (v) => {
|
||||
body.value = "";
|
||||
errors.reset();
|
||||
if (v) {
|
||||
await nextTick();
|
||||
box.value?.focus();
|
||||
}
|
||||
},
|
||||
() => errors.reset(),
|
||||
);
|
||||
|
||||
// Bring the active comment into view when its text is clicked.
|
||||
// Bring the active thread into view (and out of the resolved fold).
|
||||
watch(
|
||||
() => props.active,
|
||||
async (id) => {
|
||||
if (!id) return;
|
||||
if (resolved.value.some((t) => t.root.id === id || t.replies.some((r) => r.id === id))) showResolved.value = true;
|
||||
await nextTick();
|
||||
list.value?.querySelector(`[data-id="${id}"]`)?.scrollIntoView({ block: "nearest" });
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
async function submit() {
|
||||
if (!props.draft || !body.value.trim()) return;
|
||||
async function run(action: () => Promise<unknown>) {
|
||||
busy.value = true;
|
||||
errors.reset();
|
||||
try {
|
||||
await api.pages.addComment(props.page, { body: body.value, quote: props.draft.quote, anchor: props.draft.anchor });
|
||||
body.value = "";
|
||||
await action();
|
||||
emit("changed");
|
||||
return true;
|
||||
} catch (e) {
|
||||
errors.show(e);
|
||||
return false;
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function remove(c: Comment) {
|
||||
busy.value = true;
|
||||
errors.reset();
|
||||
try {
|
||||
await api.comments.remove(c.id);
|
||||
emit("changed");
|
||||
} catch (e) {
|
||||
errors.show(e);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
async function startThread(body: string, mentions: string[]) {
|
||||
if (!props.draft) return;
|
||||
const d = props.draft;
|
||||
if (await run(() => api.pages.addComment(props.page, { body, quote: d.quote, anchor: d.anchor, mentions })))
|
||||
newBox.value?.reset();
|
||||
}
|
||||
async function reply(t: Thread, body: string, mentions: string[]) {
|
||||
if (await run(() => api.pages.addComment(props.page, { body, parent: t.root.id, mentions }))) replyTo.value = "";
|
||||
}
|
||||
async function saveEdit(c: Comment, body: string) {
|
||||
if (await run(() => api.comments.update(c.id, body))) editing.value = "";
|
||||
}
|
||||
const remove = (c: Comment) => run(() => api.comments.remove(c.id));
|
||||
const setResolved = (t: Thread, on: boolean) => run(() => api.comments.resolve(t.root.id, on));
|
||||
function react(c: Comment, emoji: string) {
|
||||
picker.value = "";
|
||||
const mine = c.reactions.find((r) => r.emoji === emoji)?.mine ?? false;
|
||||
return run(() => api.comments.react(c.id, emoji, !mine));
|
||||
}
|
||||
|
||||
const who = (c: Comment) => c.author.name || c.author.email || "";
|
||||
const when = (s: string) =>
|
||||
new Date(s.replace(" ", "T")).toLocaleString(locale.value, { dateStyle: "medium", timeStyle: "short" });
|
||||
</script>
|
||||
@@ -87,60 +112,187 @@ const when = (s: string) =>
|
||||
</div>
|
||||
<DwCallout v-if="errors.message.value" tone="danger" size="ui">{{ errors.message.value }}</DwCallout>
|
||||
|
||||
<form v-if="draft" class="rounded-md border border-line-strong bg-surface-raised p-3" @submit.prevent="submit">
|
||||
<div v-if="draft" class="rounded-md border border-line-strong bg-surface-raised p-3">
|
||||
<p v-if="draft.quote" class="mb-2 line-clamp-3 border-l-2 border-warning pl-2 text-ui-sm text-ink-muted">
|
||||
{{ draft.quote }}
|
||||
</p>
|
||||
<textarea
|
||||
ref="box"
|
||||
v-model="body"
|
||||
rows="3"
|
||||
maxlength="5000"
|
||||
class="dw-input w-full"
|
||||
:aria-label="$t('comments.write')"
|
||||
<CommentBox
|
||||
ref="newBox"
|
||||
:workspace="workspace"
|
||||
:placeholder="$t('comments.write')"
|
||||
data-testid="comment-body"
|
||||
@keydown.ctrl.enter.prevent="submit"
|
||||
@keydown.meta.enter.prevent="submit"
|
||||
@keydown.esc.prevent="emit('cancel')"
|
||||
:submit-label="$t('comments.send')"
|
||||
:busy="busy"
|
||||
autofocus
|
||||
@submit="startThread"
|
||||
@cancel="emit('cancel')"
|
||||
/>
|
||||
<p v-if="errors.fields.value.body" class="text-ui-sm text-danger">{{ errors.fields.value.body }}</p>
|
||||
<div class="mt-2 flex justify-end gap-2">
|
||||
<DwButton size="sm" variant="ghost" @click="emit('cancel')">{{ $t("comments.cancel") }}</DwButton>
|
||||
<DwButton size="sm" type="submit" variant="primary" :disabled="busy || !body.trim()" data-testid="comment-send">
|
||||
{{ $t("comments.send") }}
|
||||
</DwButton>
|
||||
</div>
|
||||
</form>
|
||||
<p v-else-if="canComment && !comments.length" class="text-ui-sm text-ink-muted">{{ $t("comments.hint") }}</p>
|
||||
</div>
|
||||
<p v-else-if="canComment && !threads.length" class="text-ui-sm text-ink-muted">{{ $t("comments.hint") }}</p>
|
||||
|
||||
<ul ref="list" class="flex flex-col gap-2">
|
||||
<li
|
||||
v-for="c in comments"
|
||||
:key="c.id"
|
||||
:data-id="c.id"
|
||||
class="cursor-pointer rounded-md border p-3"
|
||||
:class="c.id === active ? 'border-warning bg-warning-soft/40' : 'border-line bg-surface-raised'"
|
||||
data-testid="comment"
|
||||
@click="emit('select', c.id)"
|
||||
>
|
||||
<p v-if="c.quote" class="mb-1 line-clamp-2 border-l-2 border-warning pl-2 text-ui-sm text-ink-muted">
|
||||
{{ c.quote }}
|
||||
</p>
|
||||
<p class="text-ui-sm">
|
||||
<span class="font-semibold">{{ c.author.name || c.author.email || $t("page.someone") }}</span>
|
||||
<span class="text-ink-muted"> · {{ when(c.created) }}</span>
|
||||
</p>
|
||||
<p class="mt-1 text-ui-md whitespace-pre-wrap">{{ c.body }}</p>
|
||||
<button
|
||||
v-if="c.canDelete"
|
||||
class="mt-1 text-ui-sm text-danger hover:underline"
|
||||
:disabled="busy"
|
||||
@click.stop="remove(c)"
|
||||
<div ref="list" class="flex flex-col gap-2">
|
||||
<template v-for="group in [open, showResolved ? resolved : []]" :key="group === open ? 'open' : 'resolved'">
|
||||
<article
|
||||
v-for="t in group"
|
||||
:key="t.root.id"
|
||||
:data-id="t.root.id"
|
||||
class="relative rounded-md border p-3"
|
||||
:class="[
|
||||
t.root.id === active ? 'border-warning bg-warning-soft/40' : 'border-line bg-surface-raised',
|
||||
t.root.resolvedAt ? 'opacity-80' : '',
|
||||
t.root.canResolve ? 'pr-9' : '',
|
||||
]"
|
||||
data-testid="comment-thread"
|
||||
@click="emit('select', t.root.id)"
|
||||
>
|
||||
{{ $t("comments.delete") }}
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
<DwButton
|
||||
v-if="t.root.canResolve"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
:icon="t.root.resolvedAt ? 'restore' : 'check'"
|
||||
class="absolute top-2 right-2 !size-6"
|
||||
:aria-label="t.root.resolvedAt ? $t('comments.reopen') : $t('comments.resolve')"
|
||||
:title="t.root.resolvedAt ? $t('comments.reopen') : $t('comments.resolve')"
|
||||
:disabled="busy"
|
||||
data-testid="comment-resolve"
|
||||
@click.stop="setResolved(t, !t.root.resolvedAt)"
|
||||
/>
|
||||
<p v-if="t.root.quote" class="mb-1 line-clamp-2 border-l-2 border-warning pl-2 text-ui-sm text-ink-muted">
|
||||
{{ t.root.quote }}
|
||||
</p>
|
||||
<p v-if="t.root.resolvedAt" class="mb-1 text-ui-xs text-ink-muted">
|
||||
{{
|
||||
$t("comments.resolvedBy", {
|
||||
name: t.root.resolvedBy?.name || t.root.resolvedBy?.email || $t("page.someone"),
|
||||
})
|
||||
}}
|
||||
</p>
|
||||
|
||||
<div
|
||||
v-for="c in [t.root, ...t.replies]"
|
||||
:key="c.id"
|
||||
:data-id="c.id"
|
||||
class="group mt-2 first:mt-0"
|
||||
:class="c.parent ? 'border-t border-line pt-2' : ''"
|
||||
data-testid="comment"
|
||||
>
|
||||
<p class="text-ui-sm">
|
||||
<span class="font-semibold">{{ who(c) || $t("page.someone") }}</span>
|
||||
<span class="text-ink-muted"> · {{ when(c.created) }}</span>
|
||||
<span v-if="c.editedAt" class="text-ink-muted"> · {{ $t("comments.edited") }}</span>
|
||||
</p>
|
||||
<CommentBox
|
||||
v-if="editing === c.id"
|
||||
class="mt-1"
|
||||
:workspace="workspace"
|
||||
:placeholder="$t('comments.write')"
|
||||
:submit-label="$t('comments.save')"
|
||||
:busy="busy"
|
||||
:initial="c.body"
|
||||
autofocus
|
||||
@click.stop
|
||||
@submit="(body) => saveEdit(c, body)"
|
||||
@cancel="editing = ''"
|
||||
/>
|
||||
<p v-else class="mt-1 text-ui-md whitespace-pre-wrap">{{ c.body }}</p>
|
||||
|
||||
<div class="mt-1 flex flex-wrap items-center gap-1">
|
||||
<button
|
||||
v-for="r in c.reactions"
|
||||
:key="r.emoji"
|
||||
class="flex h-6 items-center gap-1 rounded-full border px-2 text-ui-sm"
|
||||
:class="r.mine ? 'border-primary bg-accent-soft' : 'border-line hover:border-line-strong'"
|
||||
:title="r.people.join(', ')"
|
||||
:aria-pressed="r.mine"
|
||||
:disabled="busy || !canComment"
|
||||
@click.stop="react(c, r.emoji)"
|
||||
>
|
||||
{{ r.emoji }}<span class="tabular-nums">{{ r.count }}</span>
|
||||
</button>
|
||||
<span v-if="canComment" class="relative">
|
||||
<DwButton
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
icon="smile"
|
||||
class="!size-6 opacity-60 group-hover:opacity-100 focus-visible:opacity-100"
|
||||
:aria-label="$t('comments.react')"
|
||||
:title="$t('comments.react')"
|
||||
:aria-expanded="picker === c.id"
|
||||
@click.stop="picker = picker === c.id ? '' : c.id"
|
||||
/>
|
||||
<span
|
||||
v-if="picker === c.id"
|
||||
class="absolute left-0 top-full z-10 mt-1 flex gap-0.5 rounded-sm border border-line bg-surface-raised p-1 shadow-dialog"
|
||||
role="menu"
|
||||
>
|
||||
<button
|
||||
v-for="e in QUICK"
|
||||
:key="e"
|
||||
role="menuitem"
|
||||
class="grid size-7 place-items-center rounded-xs text-ui-lg hover:bg-surface-hover"
|
||||
:aria-label="e"
|
||||
@click.stop="react(c, e)"
|
||||
>
|
||||
{{ e }}
|
||||
</button>
|
||||
</span>
|
||||
</span>
|
||||
<span class="flex-1" />
|
||||
<button
|
||||
v-if="c.canEdit && editing !== c.id"
|
||||
class="text-ui-sm text-ink-muted hover:underline"
|
||||
:disabled="busy"
|
||||
@click.stop="editing = c.id"
|
||||
>
|
||||
{{ $t("comments.edit") }}
|
||||
</button>
|
||||
<button
|
||||
v-if="c.canDelete"
|
||||
class="text-ui-sm text-danger hover:underline"
|
||||
:disabled="busy"
|
||||
@click.stop="remove(c)"
|
||||
>
|
||||
{{ $t("comments.delete") }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="canComment" class="mt-2 border-t border-line pt-2" @click.stop>
|
||||
<CommentBox
|
||||
v-if="replyTo === t.root.id"
|
||||
:workspace="workspace"
|
||||
:placeholder="$t('comments.reply')"
|
||||
:submit-label="$t('comments.send')"
|
||||
:busy="busy"
|
||||
autofocus
|
||||
@submit="(body, mentions) => reply(t, body, mentions)"
|
||||
@cancel="replyTo = ''"
|
||||
/>
|
||||
<button
|
||||
v-else
|
||||
class="flex items-center gap-1 text-ui-sm text-ink-muted hover:text-ink"
|
||||
data-testid="comment-reply"
|
||||
@click="replyTo = t.root.id"
|
||||
>
|
||||
<DwIcon name="reply" :size="14" />{{ $t("comments.reply") }}
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
</template>
|
||||
|
||||
<button
|
||||
v-if="resolved.length"
|
||||
class="flex items-center gap-1 self-start text-ui-sm text-ink-muted hover:text-ink"
|
||||
:aria-expanded="showResolved"
|
||||
data-testid="comments-resolved"
|
||||
@click="showResolved = !showResolved"
|
||||
>
|
||||
<DwIcon name="check" :size="14" />
|
||||
{{
|
||||
showResolved
|
||||
? $t("comments.hideResolved")
|
||||
: $t("comments.showResolved", { n: resolved.length }, resolved.length)
|
||||
}}
|
||||
</button>
|
||||
</div>
|
||||
</aside>
|
||||
</template>
|
||||
Reference in new issue
Block a user