Skip to content

Commit d6a3891

Browse files
authoredMar 21, 2024··
fix(comments): drop permission check (#6110)
1 parent eca9c30 commit d6a3891

File tree

4 files changed

+2
-35
lines changed

4 files changed

+2
-35
lines changed
 

‎packages/sanity/src/structure/comments/plugin/field/CommentsField.tsx

-6
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ function CommentFieldInner(
9292

9393
const {
9494
comments,
95-
hasPermission,
9695
isCommentsOpen,
9796
isCreatingDataset,
9897
mentionOptions,
@@ -317,11 +316,6 @@ function CommentFieldInner(
317316
],
318317
)
319318

320-
// Render the default field component if the user doesn't have permission
321-
if (!hasPermission) {
322-
return props.renderDefault(props)
323-
}
324-
325319
return (
326320
<FieldStack {...applyCommentsFieldAttr(PathUtils.toString(props.path))} ref={rootRef}>
327321
{props.renderDefault({

‎packages/sanity/src/structure/comments/plugin/input/components/CommentsPortableTextInput.tsx

+2-15
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,8 @@ export const CommentsPortableTextInputInner = React.memo(function CommentsPortab
6363
const currentUser = useCurrentUser()
6464
const portal = usePortal()
6565

66-
const {
67-
comments,
68-
getComment,
69-
hasPermission,
70-
mentionOptions,
71-
onCommentsOpen,
72-
operation,
73-
setStatus,
74-
status,
75-
} = useComments()
66+
const {comments, getComment, mentionOptions, onCommentsOpen, operation, setStatus, status} =
67+
useComments()
7668
const {setSelectedPath, selectedPath} = useCommentsSelectedPath()
7769
const {scrollToComment, scrollToGroup} = useCommentsScroll()
7870
const {handleOpenDialog} = useCommentsUpsell()
@@ -510,11 +502,6 @@ export const CommentsPortableTextInputInner = React.memo(function CommentsPortab
510502
)
511503
const showFloatingInput = Boolean(nextCommentSelection && popoverAuthoringReferenceElement)
512504

513-
// Render the default input if the user doesn't have permission
514-
if (!hasPermission) {
515-
return props.renderDefault(props)
516-
}
517-
518505
return (
519506
<>
520507
<BoundaryElementProvider element={boundaryElement}>

‎packages/sanity/src/structure/comments/src/context/comments/CommentsProvider.tsx

-12
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
getPublishedId,
55
useAddonDataset,
66
useCurrentUser,
7-
useDocumentValuePermissions,
87
useEditState,
98
useSchema,
109
useUserListWithPermissions,
@@ -83,14 +82,6 @@ export const CommentsProvider = memo(function CommentsProvider(props: CommentsPr
8382
// A map to keep track of the latest transaction ID for each comment document.
8483
const transactionsIdMap = useMemo(() => new Map<DocumentId, TransactionId>(), [])
8584

86-
// We only need to check for read permission on the document since users with
87-
// read permission on the document can both read and write comments.
88-
// This is how permission work for the comments add-on dataset.
89-
const [readPermission] = useDocumentValuePermissions({
90-
document: documentValue || {_type: documentType, _id: publishedId},
91-
permission: 'read',
92-
})
93-
9485
// When the latest transaction ID is received, we remove the transaction id from the map.
9586
const handleOnLatestTransactionIdReceived = useCallback(
9687
(commentDocumentId: string) => {
@@ -276,8 +267,6 @@ export const CommentsProvider = memo(function CommentsProvider(props: CommentsPr
276267
isCommentsOpen,
277268
onCommentsOpen,
278269

279-
hasPermission: Boolean(readPermission?.granted),
280-
281270
comments: {
282271
data: threadItemsByStatus,
283272
error,
@@ -299,7 +288,6 @@ export const CommentsProvider = memo(function CommentsProvider(props: CommentsPr
299288
getComment,
300289
isCommentsOpen,
301290
onCommentsOpen,
302-
readPermission?.granted,
303291
threadItemsByStatus,
304292
error,
305293
loading,

‎packages/sanity/src/structure/comments/src/context/comments/types.ts

-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ export interface CommentsContextValue {
1919
isCommentsOpen?: boolean
2020
onCommentsOpen?: () => void
2121

22-
hasPermission: boolean
23-
2422
comments: {
2523
data: {
2624
open: CommentThreadItem[]

0 commit comments

Comments
 (0)
Please sign in to comment.