-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathEditableSharingModal.jsx
53 lines (46 loc) · 1.42 KB
/
EditableSharingModal.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import PropTypes from 'prop-types'
import React from 'react'
import { useClient } from 'cozy-client'
import { useFetchDocumentPath } from '../../hooks/useFetchDocumentPath'
import { useSharingContext } from '../../hooks/useSharingContext'
import { Contact } from '../../models'
import { ShareModal } from '../ShareModal'
export const EditableSharingModal = ({ document, ...rest }) => {
const client = useClient()
const documentPath = useFetchDocumentPath(client, document)
const {
documentType,
getDocumentPermissions,
getRecipients,
getSharingForSelf,
getSharingLink,
hasSharedChild,
hasSharedParent,
isOwner,
revoke,
revokeSelf,
share
} = useSharingContext()
return (
<ShareModal
createContact={contact => client.create(Contact.doctype, contact)}
document={document}
documentType={documentType}
hasSharedChild={documentPath && hasSharedChild(documentPath)}
hasSharedParent={documentPath && hasSharedParent(documentPath)}
isOwner={isOwner(document._id)}
link={getSharingLink(document._id)}
onRevoke={revoke}
onRevokeSelf={revokeSelf}
onShare={share}
permissions={getDocumentPermissions(document._id)}
recipients={getRecipients(document._id)}
sharing={getSharingForSelf(document._id)}
{...rest}
/>
)
}
EditableSharingModal.propTypes = {
document: PropTypes.object
}
export default EditableSharingModal