Skip to content

Commit

Permalink
feat: SharedStatus shows avatars instead of text
Browse files Browse the repository at this point in the history
- onClick added to be able to display sharing modal in Drive
- showMeAsOwner added to follow the new RecipientsAvatars behavior
  • Loading branch information
JF-Cozy committed Nov 3, 2020
1 parent f083ab6 commit 0f7bf9b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/cozy-sharing/src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import EditableSharingModal from './components/EditableSharingModal'
import { SharingDetailsModal } from './SharingDetailsModal'
import { default as RecipientsList } from './components/WhoHasAccessLight'
import { RecipientsAvatars, RecipientAvatar } from './components/Recipient'
import { default as DumbSharedStatus } from './components/SharedStatus'
import { withClient } from 'cozy-client'

import withLocales from './withLocales'
Expand Down Expand Up @@ -389,17 +388,20 @@ export const SharedDocument = ({ docId, children }) => (
)

export const SharedStatus = withLocales(
({ docId, className, noSharedClassName }) => (
({ docId, className, noSharedClassName, onClick, showMeAsOwner }) => (
<SharingContext.Consumer>
{({ byDocId, getRecipients, getSharingLink } = {}) =>
{({ byDocId, getRecipients, getSharingLink, isOwner } = {}) =>
!byDocId || !byDocId[docId] ? (
<span className={className + ' ' + noSharedClassName}></span>
) : (
<DumbSharedStatus
<RecipientsAvatars
className={className}
recipients={getRecipients(docId)}
docId={docId}
link={getSharingLink(docId) !== null}
onClick={onClick}
isOwner={isOwner(docId)}
size="small"
showMeAsOwner={showMeAsOwner}
/>
)
}
Expand Down Expand Up @@ -429,12 +431,13 @@ export const SharingOwnerAvatar = withLocales(({ docId, ...rest }) => (

export const SharedRecipients = withLocales(({ docId, onClick, ...rest }) => (
<SharingContext.Consumer>
{({ byDocId, getRecipients, getSharingLink } = {}) =>
{({ byDocId, getRecipients, getSharingLink, isOwner } = {}) =>
!byDocId || !byDocId[docId] ? null : (
<RecipientsAvatars
recipients={getRecipients(docId)}
link={getSharingLink(docId) !== null}
onClick={onClick}
isOwner={isOwner(docId)}
{...rest}
/>
)
Expand Down

0 comments on commit 0f7bf9b

Please sign in to comment.