-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Show detail of recipient groups
- Loading branch information
Showing
9 changed files
with
297 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
packages/cozy-sharing/src/components/Recipient/GroupRecipientDetail.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from 'react' | ||
|
||
import { Dialog } from 'cozy-ui/transpiled/react/CozyDialogs' | ||
import Typography from 'cozy-ui/transpiled/react/Typography' | ||
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n' | ||
|
||
import { GroupRecipientDetailWithAccess } from './GroupRecipientDetailWithAccess' | ||
import { GroupRecipientDetailWithoutAccess } from './GroupRecipientDetailWithoutAccess' | ||
|
||
const GroupRecipientDetail = ({ name, owner, members, onClose }) => { | ||
const { t } = useI18n() | ||
const withAccess = members.filter( | ||
member => !['revoked', 'mail-not-sent'].includes(member.status) | ||
) | ||
const withoutAccess = members.filter(member => | ||
['revoked', 'mail-not-sent'].includes(member.status) | ||
) | ||
|
||
const ownerName = owner.public_name | ||
|
||
return ( | ||
<Dialog | ||
open | ||
size="small" | ||
onClose={onClose} | ||
title={ | ||
<> | ||
{name} | ||
{ownerName ? ( | ||
<Typography variant="caption"> | ||
{t('GroupRecipientDetail.subtitle', { ownerName })} | ||
</Typography> | ||
) : null} | ||
</> | ||
} | ||
content={ | ||
<div className="u-flex u-stack-xs u-flex-column"> | ||
{withAccess.length > 0 ? ( | ||
<GroupRecipientDetailWithAccess withAccess={withAccess} /> | ||
) : null} | ||
{withoutAccess.length > 0 ? ( | ||
<GroupRecipientDetailWithoutAccess withoutAccess={withoutAccess} /> | ||
) : null} | ||
</div> | ||
} | ||
/> | ||
) | ||
} | ||
|
||
export { GroupRecipientDetail } |
53 changes: 53 additions & 0 deletions
53
packages/cozy-sharing/src/components/Recipient/GroupRecipientDetail.stories.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { GroupRecipientDetail } from './GroupRecipientDetail' | ||
|
||
const meta = { | ||
component: GroupRecipientDetail, | ||
args: { | ||
name: 'Family', | ||
owner: { | ||
public_name: 'Alice' | ||
} | ||
} | ||
} | ||
|
||
export default meta | ||
|
||
export const Default = { | ||
name: 'Default', | ||
args: { | ||
members: [ | ||
{ | ||
name: 'Alice', | ||
instance: 'http://alice.cozy.localhost:8080', | ||
status: 'ready' | ||
}, | ||
{ name: 'marine@google.com', status: 'mail-not-sent' }, | ||
{ email: 'Martin', status: 'pending' }, | ||
{ name: 'Paul', status: 'revoked' } | ||
] | ||
} | ||
} | ||
|
||
export const OnlyWithAccess = { | ||
name: 'OnlyWithAccess', | ||
args: { | ||
members: [ | ||
{ | ||
name: 'Alice', | ||
instance: 'http://alice.cozy.localhost:8080', | ||
status: 'ready' | ||
}, | ||
{ name: 'Martin', status: 'pending' } | ||
] | ||
} | ||
} | ||
|
||
export const OnlyWithoutAccess = { | ||
name: 'OnlyWithoutAccess', | ||
args: { | ||
members: [ | ||
{ name: 'marine@google.com', status: 'mail-not-sent' }, | ||
{ name: 'Paul', status: 'revoked' } | ||
] | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
packages/cozy-sharing/src/components/Recipient/GroupRecipientDetailWithAccess.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React from 'react' | ||
|
||
import Avatar from 'cozy-ui/transpiled/react/Avatar' | ||
import Icon from 'cozy-ui/transpiled/react/Icon' | ||
import ToTheCloudIcon from 'cozy-ui/transpiled/react/Icons/ToTheCloud' | ||
import List from 'cozy-ui/transpiled/react/List' | ||
import ListItem from 'cozy-ui/transpiled/react/ListItem' | ||
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon' | ||
import ListItemText from 'cozy-ui/transpiled/react/ListItemText' | ||
import Typography from 'cozy-ui/transpiled/react/Typography' | ||
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n' | ||
|
||
import { getInitials, getDisplayName } from '../../models' | ||
|
||
const GroupRecipientDetailWithAccess = ({ withAccess }) => { | ||
const { t } = useI18n() | ||
|
||
return ( | ||
<div> | ||
<Typography variant="subtitle2"> | ||
{t('GroupRecipientDetail.withAccess.title')} | ||
</Typography> | ||
<List> | ||
{withAccess.map(recipient => { | ||
const name = getDisplayName(recipient) | ||
|
||
return ( | ||
<ListItem disableGutters key={recipient.index}> | ||
<ListItemIcon> | ||
<Avatar text={getInitials(recipient)} textId={name} /> | ||
</ListItemIcon> | ||
<ListItemText | ||
primary={name} | ||
secondary={ | ||
recipient.instance ? ( | ||
<div className="u-flex u-flex-items-center"> | ||
<Icon | ||
icon={ToTheCloudIcon} | ||
size={10} | ||
style={{ | ||
marginRight: '0.25rem' | ||
}} | ||
/> | ||
{recipient.instance} | ||
</div> | ||
) : null | ||
} | ||
/> | ||
</ListItem> | ||
) | ||
})} | ||
</List> | ||
</div> | ||
) | ||
} | ||
|
||
export { GroupRecipientDetailWithAccess } |
60 changes: 60 additions & 0 deletions
60
packages/cozy-sharing/src/components/Recipient/GroupRecipientDetailWithoutAccess.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React from 'react' | ||
|
||
import Avatar from 'cozy-ui/transpiled/react/Avatar' | ||
import Icon from 'cozy-ui/transpiled/react/Icon' | ||
import ForbiddenIcon from 'cozy-ui/transpiled/react/Icons/Forbidden' | ||
import List from 'cozy-ui/transpiled/react/List' | ||
import ListItem from 'cozy-ui/transpiled/react/ListItem' | ||
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon' | ||
import ListItemText from 'cozy-ui/transpiled/react/ListItemText' | ||
import Typography from 'cozy-ui/transpiled/react/Typography' | ||
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n' | ||
|
||
import { getInitials, getDisplayName } from '../../models' | ||
|
||
const GroupRecipientDetailWithoutAccess = ({ withoutAccess }) => { | ||
const { t } = useI18n() | ||
|
||
return ( | ||
<div> | ||
<Typography variant="subtitle2"> | ||
{t('GroupRecipientDetail.withoutAccess.title')} | ||
</Typography> | ||
<List> | ||
{withoutAccess.map(recipient => { | ||
const icon = recipient.status === 'revoked' ? ForbiddenIcon : null | ||
const name = getDisplayName(recipient) | ||
|
||
return ( | ||
<ListItem disableGutters key={recipient.index}> | ||
<ListItemIcon> | ||
<Avatar text={getInitials(recipient)} textId={name} /> | ||
</ListItemIcon> | ||
<ListItemText | ||
primary={name} | ||
secondary={ | ||
<div className="u-flex u-flex-items-center"> | ||
{icon ? ( | ||
<Icon | ||
icon={icon} | ||
size={10} | ||
style={{ | ||
marginRight: '0.25rem' | ||
}} | ||
/> | ||
) : null} | ||
{t( | ||
`GroupRecipientDetail.withoutAccess.status.${recipient.status}` | ||
)} | ||
</div> | ||
} | ||
/> | ||
</ListItem> | ||
) | ||
})} | ||
</List> | ||
</div> | ||
) | ||
} | ||
|
||
export { GroupRecipientDetailWithoutAccess } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters