Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Improve share wording into confirm delete modal #2980

Merged
merged 1 commit into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/drive/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@
"title": "Delete this element? |||| Delete these elements?",
"trash": "It will be moved to the Trash. |||| They will be moved to the Trash.",
"restore": "You can still restore it whenever you want. |||| You can still restore them whenever you want.",
"shared": "The following contacts whom you shared it with will keep a copy but your changes won't be synchronized anymore. |||| The following contacts whom you shared them with will keep a copy but your changes won't be synchronized anymore",
"share_accepted": "Sharing will be stopped. The following contacts will keep a copy, but your changes will no longer be synchronised:",
"share_waiting": "Sharing will be stopped. The following contacts will no longer be able to accept sharing and will no longer be able to access shared content:",
"share_both": "Sharing will be stopped. This means that contacts who have stored files in their Cozy will keep a copy, while other contacts will no longer be able to access shared content:",
"link": "Link sharing will no longer be active",
"referenced": "Some of the files within the selection are related to a photo album. They will be removed from it if you proceed to trash them.",
"cancel": "Cancel",
Expand Down
42 changes: 29 additions & 13 deletions src/drive/web/modules/drive/DeleteConfirm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,35 @@ const DeleteConfirmWithSharingContext = ({ files, ...rest }) =>
<DeleteConfirm files={files} {...rest} />
) : (
<SharedDocument docId={files[0].id}>
{({ isSharedByMe, link, recipients }) => (
<DeleteConfirm files={files} {...rest}>
{isSharedByMe && link && (
<Message type="link" fileCount={files.length} />
)}
{isSharedByMe && recipients.length > 0 && (
<Message type="shared" fileCount={files.length} />
)}
{isSharedByMe && recipients.length > 0 && (
<SharedRecipientsList className={'u-ml-1'} docId={files[0].id} />
)}
</DeleteConfirm>
)}
{({ isSharedByMe, link, recipients }) => {
const statuses = recipients
.map(recipient => recipient.status)
.filter(status => status !== 'owner')

const isStatusesEqual = statuses.reduce((acc, current) => {
return acc && current === statuses[0]
}, true)

let shareMessageType = !isStatusesEqual
Copy link
Contributor

@zatteo zatteo Sep 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a point of view: I find nested ternary difficult to read. But do not change.

? 'share_both'
: statuses[0] === 'ready'
? 'share_accepted'
: 'share_waiting'

return (
<DeleteConfirm files={files} {...rest}>
{isSharedByMe && link ? (
<Message type="link" fileCount={files.length} />
) : null}
{isSharedByMe && statuses.length > 0 ? (
<Message type={shareMessageType} fileCount={files.length} />
) : null}
{isSharedByMe && recipients.length > 0 ? (
<SharedRecipientsList className={'u-ml-1'} docId={files[0].id} />
) : null}
</DeleteConfirm>
)
}}
</SharedDocument>
)

Expand Down
Loading