Skip to content

Commit 112ba42

Browse files
committed
feat(sharing): Add shared drive edit modal
This modal is opened when we open the usual sharing modal in a shared drive. So it should work as is directly in drive. For the moment, shared drive modal is a lot different than cozy to cozy sharing modal that's why I decided to create a new one inside ShareModal.
1 parent d78eb48 commit 112ba42

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

packages/cozy-sharing/src/components/ShareModal.jsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import flag from 'cozy-flags'
55

66
import ShareDialogCozyToCozy from './ShareDialogCozyToCozy'
77
import ShareDialogOnlyByLink from './ShareDialogOnlyByLink'
8+
import { SharedDriveEditModal } from './SharedDrive/SharedDriveEditModal'
89

910
export const ShareModal = ({
1011
createContact,
@@ -13,6 +14,7 @@ export const ShareModal = ({
1314
hasSharedChild,
1415
hasSharedParent,
1516
isOwner,
17+
isSharedDrive,
1618
link,
1719
onClose,
1820
onRevoke,
@@ -24,6 +26,19 @@ export const ShareModal = ({
2426
sharingDesc,
2527
twoStepsConfirmationMethods
2628
}) => {
29+
if (isSharedDrive) {
30+
return (
31+
<SharedDriveEditModal
32+
document={document}
33+
sharing={sharing}
34+
recipients={recipients}
35+
onShare={onShare}
36+
onRevoke={onRevoke}
37+
onClose={onClose}
38+
/>
39+
)
40+
}
41+
2742
const shareDialogOnlyByLink =
2843
flag('cozy.hide-sharing-cozy-to-cozy') || documentType === 'Albums'
2944

packages/cozy-sharing/src/components/ShareModal/EditableSharingModal.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const EditableSharingModal = ({ document, ...rest }) => {
2121
hasSharedChild,
2222
hasSharedParent,
2323
isOwner,
24+
isSharedDrive,
2425
revoke,
2526
revokeSelf,
2627
share
@@ -34,6 +35,7 @@ export const EditableSharingModal = ({ document, ...rest }) => {
3435
hasSharedChild={documentPath && hasSharedChild(documentPath)}
3536
hasSharedParent={documentPath && hasSharedParent(documentPath)}
3637
isOwner={isOwner(document._id)}
38+
isSharedDrive={isSharedDrive(document._id)}
3739
link={getSharingLink(document._id)}
3840
onRevoke={revoke}
3941
onRevokeSelf={revokeSelf}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import PropTypes from 'prop-types'
2+
import React from 'react'
3+
4+
import { useClient } from 'cozy-client'
5+
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
6+
7+
import { DumbSharedDriveModal } from './DumbSharedDriveModal'
8+
import withLocales from '../../hoc/withLocales'
9+
import { Contact } from '../../models'
10+
11+
export const SharedDriveEditModal = withLocales(
12+
({ document, sharing, recipients, onShare, onRevoke, onClose }) => {
13+
const client = useClient()
14+
const { t } = useI18n()
15+
16+
const createContact = contact => client.create(Contact.doctype, contact)
17+
18+
return (
19+
<DumbSharedDriveModal
20+
title={t('Files.share.title', { name: sharing?.description })}
21+
document={document}
22+
createContact={createContact}
23+
recipients={recipients}
24+
onRevoke={onRevoke}
25+
onClose={onClose}
26+
onShare={onShare}
27+
/>
28+
)
29+
}
30+
)
31+
32+
SharedDriveEditModal.propTypes = {
33+
onClose: PropTypes.func.isRequired
34+
}

0 commit comments

Comments
 (0)