Merge pull request #21122 from overleaf/dp-rp-hide-edit

Hide edit option for other user's comments

GitOrigin-RevId: 317fa57402dfbe2e949fa7b196cbbe246f88257d
This commit is contained in:
David 2024-10-21 09:54:39 +01:00 committed by Copybot
parent a2ea76f19f
commit af7e388c41
2 changed files with 15 additions and 7 deletions

View file

@ -28,7 +28,8 @@ const ReviewPanelCommentOptions: FC<{
onEdit: () => void
onDelete: () => void
id: string
}> = ({ onEdit, onDelete, id }) => {
belongsToCurrentUser: boolean
}> = ({ onEdit, onDelete, id, belongsToCurrentUser }) => {
const { t } = useTranslation()
return (
@ -43,7 +44,9 @@ const ReviewPanelCommentOptions: FC<{
/>
</BS3Dropdown.Toggle>
<BS3Dropdown.Menu>
<BS3MenuItem onClick={onEdit}>{t('edit')}</BS3MenuItem>
{belongsToCurrentUser && (
<BS3MenuItem onClick={onEdit}>{t('edit')}</BS3MenuItem>
)}
<BS3MenuItem onClick={onDelete}>{t('delete')}</BS3MenuItem>
</BS3Dropdown.Menu>
</ControlledDropdown>
@ -61,11 +64,13 @@ const ReviewPanelCommentOptions: FC<{
/>
</DropdownToggle>
<DropdownMenu flip={false}>
<li role="none">
<DropdownItem as="button" onClick={onEdit}>
{t('edit')}
</DropdownItem>
</li>
{belongsToCurrentUser && (
<li role="none">
<DropdownItem as="button" onClick={onEdit}>
{t('edit')}
</DropdownItem>
</li>
)}
<li role="none">
<DropdownItem as="button" onClick={onDelete}>
{t('delete')}

View file

@ -12,6 +12,7 @@ import { buildName } from '../utils/build-name'
import ReviewPanelCommentOptions from './review-panel-comment-options'
import { ExpandableContent } from './review-panel-expandable-content'
import ReviewPanelDeleteCommentModal from './review-panel-delete-comment-modal'
import { useUserContext } from '@/shared/context/user-context'
export const ReviewPanelMessage: FC<{
message: ReviewPanelCommentThreadMessage
@ -34,6 +35,7 @@ export const ReviewPanelMessage: FC<{
const [editing, setEditing] = useState(false)
const [deleting, setDeleting] = useState(false)
const [content, setContent] = useState(message.content)
const user = useUserContext()
const handleEditOption = useCallback(() => setEditing(true), [])
const showDeleteModal = useCallback(() => setDeleting(true), [])
@ -107,6 +109,7 @@ export const ReviewPanelMessage: FC<{
{!isThreadResolved && (
<ReviewPanelCommentOptions
belongsToCurrentUser={user.id === message.user.id}
onEdit={handleEditOption}
onDelete={showDeleteModal}
id={message.id}