Merge pull request #17392 from overleaf/rh-friendly-readonly

Don't show 'add comment' button if isRestrictedTokenMember

GitOrigin-RevId: da236a4f2fbe0e66a7e5999bd70f7145fd60df20
This commit is contained in:
roo hutton 2024-03-06 08:20:26 +00:00 committed by Copybot
parent 9444372883
commit 790fc5513b
2 changed files with 10 additions and 1 deletions

View file

@ -10,6 +10,7 @@ import AddCommentEntry from './entries/add-comment-entry'
import BulkActionsEntry from './entries/bulk-actions-entry/bulk-actions-entry'
import PositionedEntries from './positioned-entries'
import { useReviewPanelValueContext } from '../../context/review-panel/review-panel-context'
import { useEditorContext } from '../../../../shared/context/editor-context'
import useCodeMirrorContentHeight from '../../hooks/use-codemirror-content-height'
import { ReviewPanelEntry } from '../../../../../../types/review-panel/entry'
import {
@ -32,6 +33,7 @@ function CurrentFileContainer() {
nVisibleSelectedChanges: nChanges,
} = useReviewPanelValueContext()
const contentHeight = useCodeMirrorContentHeight()
const { isRestrictedTokenMember } = useEditorContext()
const currentDocEntries =
openDocId && openDocId in entries ? entries[openDocId] : undefined
@ -123,7 +125,11 @@ function CurrentFileContainer() {
)
}
if (entry.type === 'add-comment' && permissions.comment) {
if (
entry.type === 'add-comment' &&
permissions.comment &&
!isRestrictedTokenMember
) {
return <AddCommentEntry key={id} />
}

View file

@ -9,6 +9,7 @@ import {
useReviewPanelValueContext,
} from '../../../context/review-panel/review-panel-context'
import { useIdeContext } from '@/shared/context/ide-context'
import { useEditorContext } from '@/shared/context/editor-context'
import { useCodeMirrorViewContext } from '../../codemirror-editor'
import Modal, { useBulkActionsModal } from '../entries/bulk-actions-entry/modal'
import getMeta from '../../../../../utils/meta'
@ -38,6 +39,7 @@ function EditorWidgets() {
)
const view = useCodeMirrorViewContext()
const { reviewPanelOpen } = useLayoutContext()
const { isRestrictedTokenMember } = useEditorContext()
const {
entries,
@ -99,6 +101,7 @@ function EditorWidgets() {
)}
{hasTrackChangesFeature &&
permissions.comment &&
!isRestrictedTokenMember &&
currentDocEntries?.['add-comment'] && (
<AddCommentButton onClick={handleAddNewCommentClick}>
<Icon type="comment" /> {t('add_comment')}