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