fix: Comment resolution control visible to non-editors
This commit is contained in:
@@ -46,7 +46,9 @@ export const resolveCommentFactory = ({
|
||||
analyticsName: "Resolve thread",
|
||||
section: DocumentSection,
|
||||
icon: <DoneIcon outline />,
|
||||
visible: () => stores.policies.abilities(comment.id).resolve,
|
||||
visible: () =>
|
||||
stores.policies.abilities(comment.id).resolve &&
|
||||
stores.policies.abilities(comment.documentId).update,
|
||||
perform: async ({ t }) => {
|
||||
await comment.resolve();
|
||||
|
||||
@@ -72,7 +74,9 @@ export const unresolveCommentFactory = ({
|
||||
analyticsName: "Unresolve thread",
|
||||
section: DocumentSection,
|
||||
icon: <DoneIcon outline />,
|
||||
visible: () => stores.policies.abilities(comment.id).unresolve,
|
||||
visible: () =>
|
||||
stores.policies.abilities(comment.id).unresolve &&
|
||||
stores.policies.abilities(comment.documentId).update,
|
||||
perform: async () => {
|
||||
await comment.unresolve();
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import Empty from "~/components/Empty";
|
||||
import Flex from "~/components/Flex";
|
||||
import Scrollable from "~/components/Scrollable";
|
||||
import Tooltip from "~/components/Tooltip";
|
||||
import useCurrentUser from "~/hooks/useCurrentUser";
|
||||
import useFocusedComment from "~/hooks/useFocusedComment";
|
||||
import useKeyDown from "~/hooks/useKeyDown";
|
||||
import usePersistedState from "~/hooks/usePersistedState";
|
||||
@@ -27,7 +26,6 @@ import Sidebar from "./SidebarLayout";
|
||||
function Comments() {
|
||||
const { ui, comments, documents } = useStores();
|
||||
const { t } = useTranslation();
|
||||
const user = useCurrentUser();
|
||||
const location = useLocation();
|
||||
const history = useHistory();
|
||||
const match = useRouteMatch<{ documentSlug: string }>();
|
||||
@@ -64,11 +62,9 @@ function Comments() {
|
||||
return null;
|
||||
}
|
||||
|
||||
const threads = (
|
||||
viewingResolved
|
||||
? resolvedThreads
|
||||
: comments.unresolvedThreadsInDocument(document.id)
|
||||
).filter((thread) => thread.createdById === user.id);
|
||||
const threads = viewingResolved
|
||||
? resolvedThreads
|
||||
: comments.unresolvedThreadsInDocument(document.id);
|
||||
const hasComments = threads.length > 0;
|
||||
|
||||
const toggleViewingResolved = () => {
|
||||
|
||||
@@ -60,7 +60,7 @@ export default class CommentsStore extends Store<Comment> {
|
||||
*/
|
||||
unresolvedThreadsInDocument(documentId: string): Comment[] {
|
||||
return this.threadsInDocument(documentId).filter(
|
||||
(comment: Comment) => comment.isResolved === false
|
||||
(comment: Comment) => comment.isResolved !== true
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user