cozy-sharing 5.0.0 → 6.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +80 -0
- package/dist/SharedRecipients.js +1 -1
- package/dist/SharedStatus.js +1 -1
- package/dist/SharingBanner/hooks/useSharingInfos.js +1 -1
- package/dist/SharingDetailsModal.js +1 -1
- package/dist/SharingOwnerAvatar.js +1 -1
- package/dist/SharingProvider.js +21 -8
- package/dist/components/ConfirmTrustedRecipientsDialog.js +1 -1
- package/dist/components/ContactSuggestion.js +15 -27
- package/dist/components/EditLinkPermissionDialog.js +72 -0
- package/dist/components/EditLinkPermissionDialog.spec.js +48 -0
- package/dist/components/EditableSharingModal.js +15 -62
- package/dist/components/{AvatarPlusX.js → Recipient/AvatarPlusX.js} +1 -1
- package/dist/components/{Identity.js → Recipient/Identity.js} +17 -16
- package/dist/components/Recipient/LinkRecipient.js +72 -0
- package/dist/components/Recipient/LinkRecipientPermissions.js +159 -0
- package/dist/components/Recipient/OwnerIdentity.js +44 -0
- package/dist/components/Recipient/Recipient.js +72 -0
- package/dist/components/{Recipient.spec.js → Recipient/Recipient.spec.js} +4 -45
- package/dist/components/Recipient/RecipientAvatar.js +33 -0
- package/dist/components/Recipient/RecipientConfirm.js +63 -0
- package/dist/components/Recipient/RecipientPermissions.js +126 -0
- package/dist/components/Recipient/RecipientPlusX.js +45 -0
- package/dist/components/Recipient/RecipientStatus.js +64 -0
- package/dist/components/Recipient/RecipientWithoutStatus.js +45 -0
- package/dist/components/Recipient/RecipientsAvatars.js +100 -0
- package/dist/components/{RecipientsAvatars.spec.js → Recipient/RecipientsAvatars.spec.js} +43 -2
- package/dist/components/{recipient.styl → Recipient/recipient.styl} +6 -2
- package/dist/components/ShareAutosuggest.js +176 -252
- package/dist/components/ShareAutosuggest.spec.js +3 -2
- package/dist/components/ShareByEmail.js +142 -193
- package/dist/components/ShareByEmail.spec.js +42 -23
- package/dist/components/ShareByLink.js +251 -357
- package/dist/components/ShareDialogCozyToCozy.js +16 -4
- package/dist/components/ShareDialogCozyToCozy.spec.js +12 -1
- package/dist/components/ShareDialogOnlyByLink.js +23 -10
- package/dist/components/ShareDialogTwoStepsConfirmationContainer.js +7 -7
- package/dist/components/ShareModal.js +5 -1
- package/dist/components/ShareRecipientsInput.js +44 -128
- package/dist/components/WhoHasAccess.js +43 -5
- package/dist/components/WhoHasAccessLight.js +3 -19
- package/dist/components/autosuggest.styl +21 -36
- package/dist/helpers/documentType.js +6 -0
- package/dist/helpers/hooks.js +8 -1
- package/dist/helpers/link.js +5 -0
- package/dist/helpers/permissions.js +8 -0
- package/dist/helpers/recipients.js +24 -0
- package/dist/helpers/sharings.js +72 -53
- package/dist/helpers/synchronousJobQueue.js +67 -0
- package/dist/helpers/synchronousJobQueue.spec.js +97 -0
- package/dist/index.js +2 -1
- package/dist/queries/queries.js +72 -0
- package/dist/share.styl +0 -15
- package/dist/stylesheet.css +67 -92
- package/locales/en.json +29 -41
- package/locales/fr.json +26 -39
- package/package.json +10 -10
- package/src/SharedRecipients.jsx +1 -1
- package/src/SharedStatus.jsx +1 -1
- package/src/SharingBanner/hooks/useSharingInfos.jsx +1 -1
- package/src/SharingDetailsModal.jsx +1 -1
- package/src/SharingOwnerAvatar.jsx +1 -1
- package/src/SharingProvider.jsx +17 -4
- package/src/components/ConfirmTrustedRecipientsDialog.jsx +1 -1
- package/src/components/ContactSuggestion.jsx +25 -10
- package/src/components/EditLinkPermissionDialog.jsx +89 -0
- package/src/components/EditLinkPermissionDialog.spec.jsx +52 -0
- package/src/components/EditableSharingModal.jsx +58 -100
- package/src/components/{AvatarPlusX.jsx → Recipient/AvatarPlusX.jsx} +1 -1
- package/src/components/{Identity.jsx → Recipient/Identity.jsx} +0 -0
- package/src/components/Recipient/LinkRecipient.jsx +59 -0
- package/src/components/Recipient/LinkRecipientPermissions.jsx +157 -0
- package/src/components/Recipient/OwnerIdentity.jsx +20 -0
- package/src/components/Recipient/Recipient.jsx +79 -0
- package/src/components/{Recipient.spec.jsx → Recipient/Recipient.spec.jsx} +4 -42
- package/src/components/Recipient/RecipientAvatar.jsx +38 -0
- package/src/components/Recipient/RecipientConfirm.jsx +37 -0
- package/src/components/Recipient/RecipientPermissions.jsx +114 -0
- package/src/components/Recipient/RecipientPlusX.jsx +28 -0
- package/src/components/Recipient/RecipientStatus.jsx +48 -0
- package/src/components/Recipient/RecipientWithoutStatus.jsx +21 -0
- package/src/components/Recipient/RecipientsAvatars.jsx +108 -0
- package/src/components/{RecipientsAvatars.spec.jsx → Recipient/RecipientsAvatars.spec.jsx} +43 -2
- package/src/components/{recipient.styl → Recipient/recipient.styl} +6 -2
- package/src/components/ShareAutosuggest.jsx +136 -127
- package/src/components/ShareAutosuggest.spec.jsx +12 -8
- package/src/components/ShareByEmail.jsx +65 -90
- package/src/components/ShareByEmail.spec.jsx +39 -11
- package/src/components/ShareByLink.jsx +146 -238
- package/src/components/ShareDialogCozyToCozy.jsx +14 -2
- package/src/components/ShareDialogCozyToCozy.spec.jsx +8 -1
- package/src/components/ShareDialogOnlyByLink.jsx +30 -13
- package/src/components/ShareDialogTwoStepsConfirmationContainer.jsx +5 -5
- package/src/components/ShareModal.jsx +5 -1
- package/src/components/ShareRecipientsInput.jsx +30 -44
- package/src/components/WhoHasAccess.jsx +85 -27
- package/src/components/WhoHasAccessLight.jsx +2 -1
- package/src/components/__snapshots__/ContactSuggestion.spec.jsx.snap +915 -132
- package/src/components/__snapshots__/ShareRecipientsInput.spec.jsx.snap +86 -102
- package/src/components/autosuggest.styl +21 -36
- package/src/helpers/documentType.js +6 -0
- package/src/helpers/hooks.js +11 -1
- package/src/helpers/link.js +4 -0
- package/src/helpers/permissions.js +15 -0
- package/src/helpers/recipients.js +21 -0
- package/src/helpers/sharings.js +15 -12
- package/src/helpers/synchronousJobQueue.js +22 -0
- package/src/helpers/synchronousJobQueue.spec.js +75 -0
- package/src/index.jsx +1 -0
- package/src/queries/queries.js +75 -0
- package/src/share.styl +0 -15
- package/dist/SharingBanner/helpers/queries.js +0 -12
- package/dist/components/ContactsAndGroupsDataLoader.js +0 -50
- package/dist/components/Recipient.js +0 -450
- package/src/SharingBanner/helpers/queries.js +0 -14
- package/src/components/ContactsAndGroupsDataLoader.jsx +0 -30
- package/src/components/Recipient.jsx +0 -415
package/src/SharedRecipients.jsx
CHANGED
|
@@ -2,7 +2,7 @@ import React from 'react'
|
|
|
2
2
|
|
|
3
3
|
import SharingContext from './context'
|
|
4
4
|
import withLocales from './withLocales'
|
|
5
|
-
import
|
|
5
|
+
import RecipientsAvatars from './components/Recipient/RecipientsAvatars'
|
|
6
6
|
|
|
7
7
|
export const SharedRecipients = withLocales(({ docId, onClick, ...rest }) => (
|
|
8
8
|
<SharingContext.Consumer>
|
package/src/SharedStatus.jsx
CHANGED
|
@@ -2,7 +2,7 @@ import React from 'react'
|
|
|
2
2
|
|
|
3
3
|
import SharingContext from './context'
|
|
4
4
|
import withLocales from './withLocales'
|
|
5
|
-
import
|
|
5
|
+
import RecipientsAvatars from './components/Recipient/RecipientsAvatars'
|
|
6
6
|
|
|
7
7
|
export const SharedStatus = withLocales(
|
|
8
8
|
({ docId, className, noSharedClassName, onClick, showMeAsOwner }) => (
|
|
@@ -4,7 +4,7 @@ import { useClient, models } from 'cozy-client'
|
|
|
4
4
|
|
|
5
5
|
import getQueryParameter from '../helpers/QueryParameter'
|
|
6
6
|
import logger from '../../logger'
|
|
7
|
-
import { buildSharingsByIdQuery } from '
|
|
7
|
+
import { buildSharingsByIdQuery } from '../../queries/queries'
|
|
8
8
|
|
|
9
9
|
const getSharingId = permission => {
|
|
10
10
|
const sourceId = permission.data.attributes.source_id
|
|
@@ -6,7 +6,7 @@ import { useI18n } from 'cozy-ui/transpiled/react/I18n'
|
|
|
6
6
|
import { Dialog } from 'cozy-ui/transpiled/react/CozyDialogs'
|
|
7
7
|
import Divider from 'cozy-ui/transpiled/react/MuiCozyTheme/Divider'
|
|
8
8
|
|
|
9
|
-
import
|
|
9
|
+
import OwnerIdentity from './components/Recipient/OwnerIdentity'
|
|
10
10
|
import WhoHasAccess from './components/WhoHasAccess'
|
|
11
11
|
import { getDisplayName } from './models'
|
|
12
12
|
|
|
@@ -2,7 +2,7 @@ import React from 'react'
|
|
|
2
2
|
|
|
3
3
|
import SharingContext from './context'
|
|
4
4
|
import withLocales from './withLocales'
|
|
5
|
-
import
|
|
5
|
+
import RecipientAvatar from './components/Recipient/RecipientAvatar'
|
|
6
6
|
|
|
7
7
|
export const SharingOwnerAvatar = withLocales(({ docId, ...rest }) => (
|
|
8
8
|
<SharingContext.Consumer>
|
package/src/SharingProvider.jsx
CHANGED
|
@@ -30,11 +30,13 @@ import reducer, {
|
|
|
30
30
|
} from './state'
|
|
31
31
|
import { fetchNextPermissions } from './fetchNextPermissions'
|
|
32
32
|
import { fetchFilesPaths } from './helpers/files'
|
|
33
|
+
import { SynchronousJobQueue } from './helpers/synchronousJobQueue'
|
|
33
34
|
import {
|
|
34
35
|
getSharingObject,
|
|
35
36
|
createSharingInStore,
|
|
36
37
|
updateSharingInStore
|
|
37
38
|
} from './helpers/sharings'
|
|
39
|
+
import { fetchApps } from './queries/queries'
|
|
38
40
|
|
|
39
41
|
const SHARING_DOCTYPE = 'io.cozy.sharings'
|
|
40
42
|
const PERMISSION_DOCTYPE = 'io.cozy.permissions'
|
|
@@ -79,6 +81,8 @@ export class SharingProvider extends Component {
|
|
|
79
81
|
this.realtime = null
|
|
80
82
|
this.isInitialized = false
|
|
81
83
|
|
|
84
|
+
this.synchronousJobQueue = new SynchronousJobQueue()
|
|
85
|
+
|
|
82
86
|
const { client } = props
|
|
83
87
|
this.sharingCol = client.collection(SHARING_DOCTYPE)
|
|
84
88
|
this.permissionCol = client.collection(PERMISSION_DOCTYPE)
|
|
@@ -149,7 +153,16 @@ export class SharingProvider extends Component {
|
|
|
149
153
|
updateSharingInStore(this.dispatch, newSharing)
|
|
150
154
|
} else {
|
|
151
155
|
const docsId = getSharingDocIds(newSharing)
|
|
152
|
-
|
|
156
|
+
this.synchronousJobQueue.push({
|
|
157
|
+
function: createSharingInStore,
|
|
158
|
+
arguments: {
|
|
159
|
+
client,
|
|
160
|
+
doctype,
|
|
161
|
+
dispatch: this.dispatch,
|
|
162
|
+
docsId,
|
|
163
|
+
sharing: newSharing
|
|
164
|
+
}
|
|
165
|
+
})
|
|
153
166
|
}
|
|
154
167
|
}
|
|
155
168
|
|
|
@@ -158,7 +171,7 @@ export class SharingProvider extends Component {
|
|
|
158
171
|
const [sharings, permissions, apps] = await Promise.all([
|
|
159
172
|
this.sharingCol.findByDoctype(doctype),
|
|
160
173
|
this.permissionCol.findLinksByDoctype(doctype),
|
|
161
|
-
|
|
174
|
+
client.query(fetchApps().definition, fetchApps().options)
|
|
162
175
|
])
|
|
163
176
|
this.dispatch(
|
|
164
177
|
receiveSharings({
|
|
@@ -278,8 +291,8 @@ export class SharingProvider extends Component {
|
|
|
278
291
|
this.dispatch(revokeSelf(sharing))
|
|
279
292
|
}
|
|
280
293
|
|
|
281
|
-
shareByLink = async document => {
|
|
282
|
-
const resp = await this.permissionCol.createSharingLink(document)
|
|
294
|
+
shareByLink = async (document, options) => {
|
|
295
|
+
const resp = await this.permissionCol.createSharingLink(document, options)
|
|
283
296
|
this.dispatch(addSharingLink(resp.data))
|
|
284
297
|
return resp
|
|
285
298
|
}
|
|
@@ -2,7 +2,7 @@ import React from 'react'
|
|
|
2
2
|
import { useI18n } from 'cozy-ui/transpiled/react/I18n'
|
|
3
3
|
import Typography from 'cozy-ui/transpiled/react/Typography'
|
|
4
4
|
|
|
5
|
-
import Recipient from './Recipient'
|
|
5
|
+
import Recipient from './Recipient/Recipient'
|
|
6
6
|
|
|
7
7
|
import ShareDialogTwoStepsConfirmationContainer from './ShareDialogTwoStepsConfirmationContainer'
|
|
8
8
|
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import get from 'lodash/get'
|
|
4
|
+
|
|
4
5
|
import { models } from 'cozy-client'
|
|
5
|
-
const ContactModel = models.contact
|
|
6
6
|
import { useI18n } from 'cozy-ui/transpiled/react/I18n'
|
|
7
7
|
import Avatar from 'cozy-ui/transpiled/react/Avatar'
|
|
8
|
-
|
|
9
|
-
import
|
|
8
|
+
import ListItem from 'cozy-ui/transpiled/react/MuiCozyTheme/ListItem'
|
|
9
|
+
import ListItemIcon from 'cozy-ui/transpiled/react/MuiCozyTheme/ListItemIcon'
|
|
10
|
+
import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
|
|
10
11
|
|
|
11
12
|
import { Contact, Group, getDisplayName, getInitials } from '../models'
|
|
12
|
-
|
|
13
|
+
|
|
14
|
+
const ContactModel = models.contact
|
|
13
15
|
|
|
14
16
|
export const ContactSuggestion = ({ contactOrGroup, contacts }) => {
|
|
15
17
|
const { t } = useI18n()
|
|
@@ -40,16 +42,29 @@ export const ContactSuggestion = ({ contactOrGroup, contacts }) => {
|
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
return (
|
|
43
|
-
<
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
<ListItem button>
|
|
46
|
+
<ListItemIcon>
|
|
47
|
+
<Avatar text={avatarText} size="small" />
|
|
48
|
+
</ListItemIcon>
|
|
49
|
+
<ListItemText
|
|
50
|
+
primary={name}
|
|
51
|
+
secondary={details && details !== '' ? details : '-'}
|
|
52
|
+
/>
|
|
53
|
+
</ListItem>
|
|
47
54
|
)
|
|
48
55
|
}
|
|
49
56
|
|
|
57
|
+
const newUnknownContactProptypes = PropTypes.shape({
|
|
58
|
+
_type: PropTypes.string.isRequired,
|
|
59
|
+
email: PropTypes.string.isRequired
|
|
60
|
+
})
|
|
61
|
+
|
|
50
62
|
ContactSuggestion.propTypes = {
|
|
51
|
-
contactOrGroup: PropTypes.oneOfType([
|
|
52
|
-
.
|
|
63
|
+
contactOrGroup: PropTypes.oneOfType([
|
|
64
|
+
Contact.propType,
|
|
65
|
+
Group.propType,
|
|
66
|
+
newUnknownContactProptypes
|
|
67
|
+
]).isRequired,
|
|
53
68
|
contacts: PropTypes.arrayOf(Contact.propType)
|
|
54
69
|
}
|
|
55
70
|
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
|
|
4
|
+
import { useI18n } from 'cozy-ui/transpiled/react/I18n'
|
|
5
|
+
import { ConfirmDialog } from 'cozy-ui/transpiled/react/CozyDialogs'
|
|
6
|
+
import Button from 'cozy-ui/transpiled/react/Buttons'
|
|
7
|
+
import Radio from 'cozy-ui/transpiled/react/Radios'
|
|
8
|
+
import RadioGroup from 'cozy-ui/transpiled/react/RadioGroup'
|
|
9
|
+
import FormControlLabel from 'cozy-ui/transpiled/react/FormControlLabel'
|
|
10
|
+
|
|
11
|
+
const EditLinkPermissionDialog = ({
|
|
12
|
+
open,
|
|
13
|
+
onClose,
|
|
14
|
+
document,
|
|
15
|
+
onPermissionsSelected
|
|
16
|
+
}) => {
|
|
17
|
+
const { t } = useI18n()
|
|
18
|
+
|
|
19
|
+
const [isReadOnlyPermissions, setIsReadOnlyPermissions] = useState(true)
|
|
20
|
+
|
|
21
|
+
const onChange = event => {
|
|
22
|
+
setIsReadOnlyPermissions(event.target.value === 'true')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const onConfirm = () => {
|
|
26
|
+
const verbs = isReadOnlyPermissions
|
|
27
|
+
? ['GET']
|
|
28
|
+
: ['GET', 'POST', 'PUT', 'PATCH']
|
|
29
|
+
onPermissionsSelected({ verbs })
|
|
30
|
+
onClose()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<ConfirmDialog
|
|
35
|
+
open={open}
|
|
36
|
+
onClose={onClose}
|
|
37
|
+
title={t('Share.permissionLink.title')}
|
|
38
|
+
content={
|
|
39
|
+
<RadioGroup
|
|
40
|
+
aria-label="radio"
|
|
41
|
+
value={isReadOnlyPermissions.toString()}
|
|
42
|
+
onChange={onChange}
|
|
43
|
+
>
|
|
44
|
+
<FormControlLabel
|
|
45
|
+
value="true"
|
|
46
|
+
label={
|
|
47
|
+
document?.type === 'directory'
|
|
48
|
+
? t(`Share.permissionLink.seeFolder`)
|
|
49
|
+
: t(`Share.permissionLink.seeFile`)
|
|
50
|
+
}
|
|
51
|
+
control={<Radio />}
|
|
52
|
+
/>
|
|
53
|
+
<FormControlLabel
|
|
54
|
+
value="false"
|
|
55
|
+
label={
|
|
56
|
+
document?.type === 'directory'
|
|
57
|
+
? t(`Share.permissionLink.modifyFolder`)
|
|
58
|
+
: t(`Share.permissionLink.modifyFile`)
|
|
59
|
+
}
|
|
60
|
+
control={<Radio />}
|
|
61
|
+
/>
|
|
62
|
+
</RadioGroup>
|
|
63
|
+
}
|
|
64
|
+
actions={
|
|
65
|
+
<>
|
|
66
|
+
<Button
|
|
67
|
+
variant="secondary"
|
|
68
|
+
label={t('Share.permissionLink.cancel')}
|
|
69
|
+
onClick={onClose}
|
|
70
|
+
/>
|
|
71
|
+
<Button
|
|
72
|
+
variant="primary"
|
|
73
|
+
label={t('Share.permissionLink.confirm')}
|
|
74
|
+
onClick={onConfirm}
|
|
75
|
+
/>
|
|
76
|
+
</>
|
|
77
|
+
}
|
|
78
|
+
/>
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
EditLinkPermissionDialog.propTypes = {
|
|
83
|
+
open: PropTypes.bool.isRequired,
|
|
84
|
+
onClose: PropTypes.func.isRequired,
|
|
85
|
+
document: PropTypes.object.isRequired,
|
|
86
|
+
onPermissionsSelected: PropTypes.func.isRequired
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export default EditLinkPermissionDialog
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { render, fireEvent } from '@testing-library/react'
|
|
3
|
+
|
|
4
|
+
import { createMockClient } from 'cozy-client'
|
|
5
|
+
import AppLike from '../../test/AppLike'
|
|
6
|
+
import EditLinkPermissionDialog from './EditLinkPermissionDialog'
|
|
7
|
+
|
|
8
|
+
describe('EditLinkPermissionDialog', () => {
|
|
9
|
+
const client = createMockClient({})
|
|
10
|
+
|
|
11
|
+
const setup = props => {
|
|
12
|
+
return render(
|
|
13
|
+
<AppLike client={client}>
|
|
14
|
+
<EditLinkPermissionDialog open onClose={() => {}} {...props} />
|
|
15
|
+
</AppLike>
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
it('should select read permissions', () => {
|
|
20
|
+
const onPermissionsSelected = jest.fn()
|
|
21
|
+
|
|
22
|
+
const props = {
|
|
23
|
+
onPermissionsSelected
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const { getByText } = setup(props)
|
|
27
|
+
|
|
28
|
+
fireEvent.click(getByText('OK'))
|
|
29
|
+
|
|
30
|
+
expect(onPermissionsSelected).toHaveBeenCalledWith({
|
|
31
|
+
verbs: ['GET']
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('should select write permissions', () => {
|
|
36
|
+
const onPermissionsSelected = jest.fn()
|
|
37
|
+
|
|
38
|
+
const props = {
|
|
39
|
+
onPermissionsSelected
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const { getByText } = setup(props)
|
|
43
|
+
|
|
44
|
+
fireEvent.click(getByText('Modify file'))
|
|
45
|
+
|
|
46
|
+
fireEvent.click(getByText('OK'))
|
|
47
|
+
|
|
48
|
+
expect(onPermissionsSelected).toHaveBeenCalledWith({
|
|
49
|
+
verbs: ['GET', 'POST', 'PUT', 'PATCH']
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
})
|
|
@@ -1,116 +1,74 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
|
-
import {
|
|
3
|
+
import { useClient, useQueryAll } from 'cozy-client'
|
|
4
4
|
|
|
5
|
-
import { Contact
|
|
6
|
-
import { contactsResponseType, groupsResponseType } from '../propTypes'
|
|
5
|
+
import { Contact } from '../models'
|
|
7
6
|
import SharingContext from '../context'
|
|
8
|
-
import ContactsAndGroupsDataLoader from './ContactsAndGroupsDataLoader'
|
|
9
7
|
import { default as DumbShareModal } from './ShareModal'
|
|
10
8
|
import { useFetchDocumentPath } from './useFetchDocumentPath'
|
|
9
|
+
import { buildContactsQuery, buildGroupsQuery } from '../queries/queries'
|
|
11
10
|
|
|
12
|
-
export const EditableSharingModal = ({
|
|
13
|
-
contacts,
|
|
14
|
-
document,
|
|
15
|
-
groups,
|
|
16
|
-
...rest
|
|
17
|
-
}) => {
|
|
11
|
+
export const EditableSharingModal = ({ document, ...rest }) => {
|
|
18
12
|
const client = useClient()
|
|
19
13
|
const documentPath = useFetchDocumentPath(client, document)
|
|
14
|
+
|
|
15
|
+
const contactsQuery = buildContactsQuery()
|
|
16
|
+
const contactsResult = useQueryAll(
|
|
17
|
+
contactsQuery.definition,
|
|
18
|
+
contactsQuery.options
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
const groupsQuery = buildGroupsQuery()
|
|
22
|
+
const groupsResult = useQueryAll(groupsQuery.definition, groupsQuery.options)
|
|
23
|
+
|
|
20
24
|
return (
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
</SharingContext.Consumer>
|
|
64
|
-
</ContactsAndGroupsDataLoader>
|
|
25
|
+
<SharingContext.Consumer>
|
|
26
|
+
{({
|
|
27
|
+
documentType,
|
|
28
|
+
getDocumentPermissions,
|
|
29
|
+
getRecipients,
|
|
30
|
+
getSharingForSelf,
|
|
31
|
+
getSharingLink,
|
|
32
|
+
hasSharedChild,
|
|
33
|
+
hasSharedParent,
|
|
34
|
+
isOwner,
|
|
35
|
+
revoke,
|
|
36
|
+
revokeSelf,
|
|
37
|
+
revokeSharingLink,
|
|
38
|
+
share,
|
|
39
|
+
shareByLink,
|
|
40
|
+
updateDocumentPermissions
|
|
41
|
+
}) => {
|
|
42
|
+
return (
|
|
43
|
+
<DumbShareModal
|
|
44
|
+
contacts={contactsResult}
|
|
45
|
+
createContact={contact => client.create(Contact.doctype, contact)}
|
|
46
|
+
document={document}
|
|
47
|
+
documentType={documentType}
|
|
48
|
+
groups={groupsResult}
|
|
49
|
+
hasSharedChild={documentPath && hasSharedChild(documentPath)}
|
|
50
|
+
hasSharedParent={documentPath && hasSharedParent(documentPath)}
|
|
51
|
+
isOwner={isOwner(document.id)}
|
|
52
|
+
link={getSharingLink(document.id)}
|
|
53
|
+
onRevoke={revoke}
|
|
54
|
+
onRevokeLink={revokeSharingLink}
|
|
55
|
+
onRevokeSelf={revokeSelf}
|
|
56
|
+
onShare={share}
|
|
57
|
+
onShareByLink={shareByLink}
|
|
58
|
+
onUpdateShareLinkPermissions={updateDocumentPermissions}
|
|
59
|
+
permissions={getDocumentPermissions(document.id)}
|
|
60
|
+
recipients={getRecipients(document.id)}
|
|
61
|
+
sharing={getSharingForSelf(document.id)}
|
|
62
|
+
{...rest}
|
|
63
|
+
/>
|
|
64
|
+
)
|
|
65
|
+
}}
|
|
66
|
+
</SharingContext.Consumer>
|
|
65
67
|
)
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
EditableSharingModal.propTypes = {
|
|
69
|
-
|
|
70
|
-
document: PropTypes.object,
|
|
71
|
-
groups: groupsResponseType
|
|
71
|
+
document: PropTypes.object
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
Q(Contact.doctype)
|
|
76
|
-
.where({
|
|
77
|
-
_id: {
|
|
78
|
-
$gt: null
|
|
79
|
-
}
|
|
80
|
-
})
|
|
81
|
-
.partialIndex({
|
|
82
|
-
trashed: {
|
|
83
|
-
$or: [{ $eq: false }, { $exists: false }]
|
|
84
|
-
},
|
|
85
|
-
$or: [
|
|
86
|
-
{
|
|
87
|
-
cozy: {
|
|
88
|
-
$not: {
|
|
89
|
-
$size: 0
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
email: {
|
|
95
|
-
$not: {
|
|
96
|
-
$size: 0
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
]
|
|
101
|
-
})
|
|
102
|
-
.indexFields(['_id'])
|
|
103
|
-
.limitBy(1000)
|
|
104
|
-
|
|
105
|
-
const groupsQuery = () => Q(Group.doctype)
|
|
106
|
-
|
|
107
|
-
export default queryConnect({
|
|
108
|
-
contacts: {
|
|
109
|
-
query: contactsQuery,
|
|
110
|
-
as: 'contacts'
|
|
111
|
-
},
|
|
112
|
-
groups: {
|
|
113
|
-
query: groupsQuery,
|
|
114
|
-
as: 'groups'
|
|
115
|
-
}
|
|
116
|
-
})(EditableSharingModal)
|
|
74
|
+
export default EditableSharingModal
|
|
@@ -4,7 +4,7 @@ import uniqueId from 'lodash/uniqueId'
|
|
|
4
4
|
|
|
5
5
|
import Avatar from 'cozy-ui/transpiled/react/Avatar'
|
|
6
6
|
|
|
7
|
-
import { SharingTooltip, TooltipRecipientList } from '
|
|
7
|
+
import { SharingTooltip, TooltipRecipientList } from '../Tooltip'
|
|
8
8
|
|
|
9
9
|
const AvatarPlusX = ({ className, size, extraRecipients = [] }) => {
|
|
10
10
|
const sharingTooltipId = uniqueId('extra-recipients-avatar-')
|
|
File without changes
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
|
|
4
|
+
import { useI18n } from 'cozy-ui/transpiled/react/I18n'
|
|
5
|
+
import ListItem from 'cozy-ui/transpiled/react/MuiCozyTheme/ListItem'
|
|
6
|
+
import ListItemIcon from 'cozy-ui/transpiled/react/MuiCozyTheme/ListItemIcon'
|
|
7
|
+
import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
|
|
8
|
+
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
9
|
+
import LinkIcon from 'cozy-ui/transpiled/react/Icons/Link'
|
|
10
|
+
import Circle from 'cozy-ui/transpiled/react/Circle'
|
|
11
|
+
import Typography from 'cozy-ui/transpiled/react/Typography'
|
|
12
|
+
import Fade from 'cozy-ui/transpiled/react/Fade'
|
|
13
|
+
|
|
14
|
+
import { FADE_IN_DURATION } from '../../helpers/recipients'
|
|
15
|
+
import RecipientConfirm from './RecipientConfirm'
|
|
16
|
+
import LinkRecipientPermissions from './LinkRecipientPermissions'
|
|
17
|
+
import styles from './recipient.styl'
|
|
18
|
+
|
|
19
|
+
const LinkRecipient = props => {
|
|
20
|
+
const { t } = useI18n()
|
|
21
|
+
|
|
22
|
+
const { recipientConfirmationData, verifyRecipient, link, fadeIn } = props
|
|
23
|
+
|
|
24
|
+
const RightPart = recipientConfirmationData ? (
|
|
25
|
+
<RecipientConfirm
|
|
26
|
+
recipientConfirmationData={recipientConfirmationData}
|
|
27
|
+
verifyRecipient={verifyRecipient}
|
|
28
|
+
></RecipientConfirm>
|
|
29
|
+
) : (
|
|
30
|
+
<LinkRecipientPermissions {...props} className="u-flex-shrink-0" />
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Fade in timeout={fadeIn ? FADE_IN_DURATION : 0}>
|
|
35
|
+
<ListItem disableGutters>
|
|
36
|
+
<ListItemIcon>
|
|
37
|
+
<Circle size="small" className={styles['link-recipient-icon-circle']}>
|
|
38
|
+
<Icon icon={LinkIcon} />
|
|
39
|
+
</Circle>
|
|
40
|
+
</ListItemIcon>
|
|
41
|
+
<ListItemText
|
|
42
|
+
primary={
|
|
43
|
+
<Typography className="u-ellipsis" variant="body1">
|
|
44
|
+
{t('Share.recipients.anyoneWithTheLink')}
|
|
45
|
+
</Typography>
|
|
46
|
+
}
|
|
47
|
+
secondary={link}
|
|
48
|
+
/>
|
|
49
|
+
{RightPart}
|
|
50
|
+
</ListItem>
|
|
51
|
+
</Fade>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
LinkRecipient.propTypes = {
|
|
56
|
+
link: PropTypes.string.isRequired
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export default LinkRecipient
|