mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
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:
parent
a2ea76f19f
commit
af7e388c41
2 changed files with 15 additions and 7 deletions
|
@ -28,7 +28,8 @@ const ReviewPanelCommentOptions: FC<{
|
||||||
onEdit: () => void
|
onEdit: () => void
|
||||||
onDelete: () => void
|
onDelete: () => void
|
||||||
id: string
|
id: string
|
||||||
}> = ({ onEdit, onDelete, id }) => {
|
belongsToCurrentUser: boolean
|
||||||
|
}> = ({ onEdit, onDelete, id, belongsToCurrentUser }) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -43,7 +44,9 @@ const ReviewPanelCommentOptions: FC<{
|
||||||
/>
|
/>
|
||||||
</BS3Dropdown.Toggle>
|
</BS3Dropdown.Toggle>
|
||||||
<BS3Dropdown.Menu>
|
<BS3Dropdown.Menu>
|
||||||
<BS3MenuItem onClick={onEdit}>{t('edit')}</BS3MenuItem>
|
{belongsToCurrentUser && (
|
||||||
|
<BS3MenuItem onClick={onEdit}>{t('edit')}</BS3MenuItem>
|
||||||
|
)}
|
||||||
<BS3MenuItem onClick={onDelete}>{t('delete')}</BS3MenuItem>
|
<BS3MenuItem onClick={onDelete}>{t('delete')}</BS3MenuItem>
|
||||||
</BS3Dropdown.Menu>
|
</BS3Dropdown.Menu>
|
||||||
</ControlledDropdown>
|
</ControlledDropdown>
|
||||||
|
@ -61,11 +64,13 @@ const ReviewPanelCommentOptions: FC<{
|
||||||
/>
|
/>
|
||||||
</DropdownToggle>
|
</DropdownToggle>
|
||||||
<DropdownMenu flip={false}>
|
<DropdownMenu flip={false}>
|
||||||
<li role="none">
|
{belongsToCurrentUser && (
|
||||||
<DropdownItem as="button" onClick={onEdit}>
|
<li role="none">
|
||||||
{t('edit')}
|
<DropdownItem as="button" onClick={onEdit}>
|
||||||
</DropdownItem>
|
{t('edit')}
|
||||||
</li>
|
</DropdownItem>
|
||||||
|
</li>
|
||||||
|
)}
|
||||||
<li role="none">
|
<li role="none">
|
||||||
<DropdownItem as="button" onClick={onDelete}>
|
<DropdownItem as="button" onClick={onDelete}>
|
||||||
{t('delete')}
|
{t('delete')}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import { buildName } from '../utils/build-name'
|
||||||
import ReviewPanelCommentOptions from './review-panel-comment-options'
|
import ReviewPanelCommentOptions from './review-panel-comment-options'
|
||||||
import { ExpandableContent } from './review-panel-expandable-content'
|
import { ExpandableContent } from './review-panel-expandable-content'
|
||||||
import ReviewPanelDeleteCommentModal from './review-panel-delete-comment-modal'
|
import ReviewPanelDeleteCommentModal from './review-panel-delete-comment-modal'
|
||||||
|
import { useUserContext } from '@/shared/context/user-context'
|
||||||
|
|
||||||
export const ReviewPanelMessage: FC<{
|
export const ReviewPanelMessage: FC<{
|
||||||
message: ReviewPanelCommentThreadMessage
|
message: ReviewPanelCommentThreadMessage
|
||||||
|
@ -34,6 +35,7 @@ export const ReviewPanelMessage: FC<{
|
||||||
const [editing, setEditing] = useState(false)
|
const [editing, setEditing] = useState(false)
|
||||||
const [deleting, setDeleting] = useState(false)
|
const [deleting, setDeleting] = useState(false)
|
||||||
const [content, setContent] = useState(message.content)
|
const [content, setContent] = useState(message.content)
|
||||||
|
const user = useUserContext()
|
||||||
|
|
||||||
const handleEditOption = useCallback(() => setEditing(true), [])
|
const handleEditOption = useCallback(() => setEditing(true), [])
|
||||||
const showDeleteModal = useCallback(() => setDeleting(true), [])
|
const showDeleteModal = useCallback(() => setDeleting(true), [])
|
||||||
|
@ -107,6 +109,7 @@ export const ReviewPanelMessage: FC<{
|
||||||
|
|
||||||
{!isThreadResolved && (
|
{!isThreadResolved && (
|
||||||
<ReviewPanelCommentOptions
|
<ReviewPanelCommentOptions
|
||||||
|
belongsToCurrentUser={user.id === message.user.id}
|
||||||
onEdit={handleEditOption}
|
onEdit={handleEditOption}
|
||||||
onDelete={showDeleteModal}
|
onDelete={showDeleteModal}
|
||||||
id={message.id}
|
id={message.id}
|
||||||
|
|
Loading…
Reference in a new issue