Skip to content

Commit

Permalink
fix: Show permissions when the current user is inside members
Browse files Browse the repository at this point in the history
  • Loading branch information
cballevre committed Apr 8, 2024
1 parent d747f9c commit d28d4b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ const GroupRecipient = props => {
})}
/>
<ListItemSecondaryAction className={isMobile ? 'u-mr-1' : 'u-mr-2'}>
<GroupRecipientPermissions {...props} />
<GroupRecipientPermissions
isUserInsideMembers={isUserInsideMembers}
{...props}
/>
</ListItemSecondaryAction>
</ListItem>
</Fade>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useState, useRef } from 'react'

import { useClient } from 'cozy-client'
import ActionsMenu from 'cozy-ui/transpiled/react/ActionsMenu'
import {
makeActions,
Expand All @@ -21,24 +20,20 @@ import { GroupAvatar } from '../Avatar/GroupAvatar'
const GroupRecipientPermissions = ({
name,
isOwner,
instance,
sharingId,
groupIndex,
read_only: isReadOnly = false,
className
className,
isUserInsideMembers
}) => {
const { t } = useI18n()
const buttonRef = useRef()
const client = useClient()
const { revokeGroup, revokeSelf } = useSharingContext()

const [isMenuDisplayed, setMenuDisplayed] = useState(false)
const [revoking, setRevoking] = useState(false)

const instanceMatchesClient =
instance !== undefined && instance === client.options.uri
const shouldShowMenu =
!revoking && ((instanceMatchesClient && !isOwner) || isOwner)
const shouldShowMenu = !revoking && (isOwner || isUserInsideMembers)

const toggleMenu = () => setMenuDisplayed(!isMenuDisplayed)
const hideMenu = () => setMenuDisplayed(false)
Expand Down

0 comments on commit d28d4b4

Please sign in to comment.