From 790fc5513bc418b00ef9e937ed0de30e1beda211 Mon Sep 17 00:00:00 2001 From: roo hutton Date: Wed, 6 Mar 2024 08:20:26 +0000 Subject: [PATCH] Merge pull request #17392 from overleaf/rh-friendly-readonly Don't show 'add comment' button if isRestrictedTokenMember GitOrigin-RevId: da236a4f2fbe0e66a7e5999bd70f7145fd60df20 --- .../components/review-panel/current-file-container.tsx | 8 +++++++- .../review-panel/editor-widgets/editor-widgets.tsx | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/services/web/frontend/js/features/source-editor/components/review-panel/current-file-container.tsx b/services/web/frontend/js/features/source-editor/components/review-panel/current-file-container.tsx index 8306e72580..3c4f75f8a9 100644 --- a/services/web/frontend/js/features/source-editor/components/review-panel/current-file-container.tsx +++ b/services/web/frontend/js/features/source-editor/components/review-panel/current-file-container.tsx @@ -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 } diff --git a/services/web/frontend/js/features/source-editor/components/review-panel/editor-widgets/editor-widgets.tsx b/services/web/frontend/js/features/source-editor/components/review-panel/editor-widgets/editor-widgets.tsx index e3cc87fd0a..136f145c53 100644 --- a/services/web/frontend/js/features/source-editor/components/review-panel/editor-widgets/editor-widgets.tsx +++ b/services/web/frontend/js/features/source-editor/components/review-panel/editor-widgets/editor-widgets.tsx @@ -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'] && ( {t('add_comment')}