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.
Files changed (117) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/dist/SharedRecipients.js +1 -1
  3. package/dist/SharedStatus.js +1 -1
  4. package/dist/SharingBanner/hooks/useSharingInfos.js +1 -1
  5. package/dist/SharingDetailsModal.js +1 -1
  6. package/dist/SharingOwnerAvatar.js +1 -1
  7. package/dist/SharingProvider.js +21 -8
  8. package/dist/components/ConfirmTrustedRecipientsDialog.js +1 -1
  9. package/dist/components/ContactSuggestion.js +15 -27
  10. package/dist/components/EditLinkPermissionDialog.js +72 -0
  11. package/dist/components/EditLinkPermissionDialog.spec.js +48 -0
  12. package/dist/components/EditableSharingModal.js +15 -62
  13. package/dist/components/{AvatarPlusX.js → Recipient/AvatarPlusX.js} +1 -1
  14. package/dist/components/{Identity.js → Recipient/Identity.js} +17 -16
  15. package/dist/components/Recipient/LinkRecipient.js +72 -0
  16. package/dist/components/Recipient/LinkRecipientPermissions.js +159 -0
  17. package/dist/components/Recipient/OwnerIdentity.js +44 -0
  18. package/dist/components/Recipient/Recipient.js +72 -0
  19. package/dist/components/{Recipient.spec.js → Recipient/Recipient.spec.js} +4 -45
  20. package/dist/components/Recipient/RecipientAvatar.js +33 -0
  21. package/dist/components/Recipient/RecipientConfirm.js +63 -0
  22. package/dist/components/Recipient/RecipientPermissions.js +126 -0
  23. package/dist/components/Recipient/RecipientPlusX.js +45 -0
  24. package/dist/components/Recipient/RecipientStatus.js +64 -0
  25. package/dist/components/Recipient/RecipientWithoutStatus.js +45 -0
  26. package/dist/components/Recipient/RecipientsAvatars.js +100 -0
  27. package/dist/components/{RecipientsAvatars.spec.js → Recipient/RecipientsAvatars.spec.js} +43 -2
  28. package/dist/components/{recipient.styl → Recipient/recipient.styl} +6 -2
  29. package/dist/components/ShareAutosuggest.js +176 -252
  30. package/dist/components/ShareAutosuggest.spec.js +3 -2
  31. package/dist/components/ShareByEmail.js +142 -193
  32. package/dist/components/ShareByEmail.spec.js +42 -23
  33. package/dist/components/ShareByLink.js +251 -357
  34. package/dist/components/ShareDialogCozyToCozy.js +16 -4
  35. package/dist/components/ShareDialogCozyToCozy.spec.js +12 -1
  36. package/dist/components/ShareDialogOnlyByLink.js +23 -10
  37. package/dist/components/ShareDialogTwoStepsConfirmationContainer.js +7 -7
  38. package/dist/components/ShareModal.js +5 -1
  39. package/dist/components/ShareRecipientsInput.js +44 -128
  40. package/dist/components/WhoHasAccess.js +43 -5
  41. package/dist/components/WhoHasAccessLight.js +3 -19
  42. package/dist/components/autosuggest.styl +21 -36
  43. package/dist/helpers/documentType.js +6 -0
  44. package/dist/helpers/hooks.js +8 -1
  45. package/dist/helpers/link.js +5 -0
  46. package/dist/helpers/permissions.js +8 -0
  47. package/dist/helpers/recipients.js +24 -0
  48. package/dist/helpers/sharings.js +72 -53
  49. package/dist/helpers/synchronousJobQueue.js +67 -0
  50. package/dist/helpers/synchronousJobQueue.spec.js +97 -0
  51. package/dist/index.js +2 -1
  52. package/dist/queries/queries.js +72 -0
  53. package/dist/share.styl +0 -15
  54. package/dist/stylesheet.css +67 -92
  55. package/locales/en.json +29 -41
  56. package/locales/fr.json +26 -39
  57. package/package.json +10 -10
  58. package/src/SharedRecipients.jsx +1 -1
  59. package/src/SharedStatus.jsx +1 -1
  60. package/src/SharingBanner/hooks/useSharingInfos.jsx +1 -1
  61. package/src/SharingDetailsModal.jsx +1 -1
  62. package/src/SharingOwnerAvatar.jsx +1 -1
  63. package/src/SharingProvider.jsx +17 -4
  64. package/src/components/ConfirmTrustedRecipientsDialog.jsx +1 -1
  65. package/src/components/ContactSuggestion.jsx +25 -10
  66. package/src/components/EditLinkPermissionDialog.jsx +89 -0
  67. package/src/components/EditLinkPermissionDialog.spec.jsx +52 -0
  68. package/src/components/EditableSharingModal.jsx +58 -100
  69. package/src/components/{AvatarPlusX.jsx → Recipient/AvatarPlusX.jsx} +1 -1
  70. package/src/components/{Identity.jsx → Recipient/Identity.jsx} +0 -0
  71. package/src/components/Recipient/LinkRecipient.jsx +59 -0
  72. package/src/components/Recipient/LinkRecipientPermissions.jsx +157 -0
  73. package/src/components/Recipient/OwnerIdentity.jsx +20 -0
  74. package/src/components/Recipient/Recipient.jsx +79 -0
  75. package/src/components/{Recipient.spec.jsx → Recipient/Recipient.spec.jsx} +4 -42
  76. package/src/components/Recipient/RecipientAvatar.jsx +38 -0
  77. package/src/components/Recipient/RecipientConfirm.jsx +37 -0
  78. package/src/components/Recipient/RecipientPermissions.jsx +114 -0
  79. package/src/components/Recipient/RecipientPlusX.jsx +28 -0
  80. package/src/components/Recipient/RecipientStatus.jsx +48 -0
  81. package/src/components/Recipient/RecipientWithoutStatus.jsx +21 -0
  82. package/src/components/Recipient/RecipientsAvatars.jsx +108 -0
  83. package/src/components/{RecipientsAvatars.spec.jsx → Recipient/RecipientsAvatars.spec.jsx} +43 -2
  84. package/src/components/{recipient.styl → Recipient/recipient.styl} +6 -2
  85. package/src/components/ShareAutosuggest.jsx +136 -127
  86. package/src/components/ShareAutosuggest.spec.jsx +12 -8
  87. package/src/components/ShareByEmail.jsx +65 -90
  88. package/src/components/ShareByEmail.spec.jsx +39 -11
  89. package/src/components/ShareByLink.jsx +146 -238
  90. package/src/components/ShareDialogCozyToCozy.jsx +14 -2
  91. package/src/components/ShareDialogCozyToCozy.spec.jsx +8 -1
  92. package/src/components/ShareDialogOnlyByLink.jsx +30 -13
  93. package/src/components/ShareDialogTwoStepsConfirmationContainer.jsx +5 -5
  94. package/src/components/ShareModal.jsx +5 -1
  95. package/src/components/ShareRecipientsInput.jsx +30 -44
  96. package/src/components/WhoHasAccess.jsx +85 -27
  97. package/src/components/WhoHasAccessLight.jsx +2 -1
  98. package/src/components/__snapshots__/ContactSuggestion.spec.jsx.snap +915 -132
  99. package/src/components/__snapshots__/ShareRecipientsInput.spec.jsx.snap +86 -102
  100. package/src/components/autosuggest.styl +21 -36
  101. package/src/helpers/documentType.js +6 -0
  102. package/src/helpers/hooks.js +11 -1
  103. package/src/helpers/link.js +4 -0
  104. package/src/helpers/permissions.js +15 -0
  105. package/src/helpers/recipients.js +21 -0
  106. package/src/helpers/sharings.js +15 -12
  107. package/src/helpers/synchronousJobQueue.js +22 -0
  108. package/src/helpers/synchronousJobQueue.spec.js +75 -0
  109. package/src/index.jsx +1 -0
  110. package/src/queries/queries.js +75 -0
  111. package/src/share.styl +0 -15
  112. package/dist/SharingBanner/helpers/queries.js +0 -12
  113. package/dist/components/ContactsAndGroupsDataLoader.js +0 -50
  114. package/dist/components/Recipient.js +0 -450
  115. package/src/SharingBanner/helpers/queries.js +0 -14
  116. package/src/components/ContactsAndGroupsDataLoader.jsx +0 -30
  117. package/src/components/Recipient.jsx +0 -415
@@ -2,7 +2,7 @@ import React from 'react'
2
2
 
3
3
  import SharingContext from './context'
4
4
  import withLocales from './withLocales'
5
- import { RecipientsAvatars } from './components/Recipient'
5
+ import RecipientsAvatars from './components/Recipient/RecipientsAvatars'
6
6
 
7
7
  export const SharedRecipients = withLocales(({ docId, onClick, ...rest }) => (
8
8
  <SharingContext.Consumer>
@@ -2,7 +2,7 @@ import React from 'react'
2
2
 
3
3
  import SharingContext from './context'
4
4
  import withLocales from './withLocales'
5
- import { RecipientsAvatars } from './components/Recipient'
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 '../helpers/queries'
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 { OwnerIdentity } from './components/Recipient'
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 { RecipientAvatar } from './components/Recipient'
5
+ import RecipientAvatar from './components/Recipient/RecipientAvatar'
6
6
 
7
7
  export const SharingOwnerAvatar = withLocales(({ docId, ...rest }) => (
8
8
  <SharingContext.Consumer>
@@ -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
- createSharingInStore(client, doctype, this.dispatch, docsId, newSharing)
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
- this.permissionCol.findApps()
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 styles from './recipient.styl'
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
- import Identity from './Identity'
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
- <div className={styles['recipient']}>
44
- <Avatar text={avatarText} size="small" />
45
- <Identity name={name} details={details === '' ? undefined : details} />
46
- </div>
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([Contact.propType, Group.propType])
52
- .isRequired,
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 { queryConnect, useClient, Q } from 'cozy-client'
3
+ import { useClient, useQueryAll } from 'cozy-client'
4
4
 
5
- import { Contact, Group } from '../models'
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
- <ContactsAndGroupsDataLoader contacts={contacts} groups={groups}>
22
- <SharingContext.Consumer>
23
- {({
24
- documentType,
25
- getDocumentPermissions,
26
- getRecipients,
27
- getSharingForSelf,
28
- getSharingLink,
29
- hasSharedChild,
30
- hasSharedParent,
31
- isOwner,
32
- revoke,
33
- revokeSelf,
34
- revokeSharingLink,
35
- share,
36
- shareByLink,
37
- updateDocumentPermissions
38
- }) => {
39
- return (
40
- <DumbShareModal
41
- contacts={contacts}
42
- createContact={contact => client.create(Contact.doctype, contact)}
43
- document={document}
44
- documentType={documentType}
45
- groups={groups}
46
- hasSharedChild={documentPath && hasSharedChild(documentPath)}
47
- hasSharedParent={documentPath && hasSharedParent(documentPath)}
48
- isOwner={isOwner(document.id)}
49
- link={getSharingLink(document.id)}
50
- onRevoke={revoke}
51
- onRevokeLink={revokeSharingLink}
52
- onRevokeSelf={revokeSelf}
53
- onShare={share}
54
- onShareByLink={shareByLink}
55
- onUpdateShareLinkPermissions={updateDocumentPermissions}
56
- permissions={getDocumentPermissions(document.id)}
57
- recipients={getRecipients(document.id)}
58
- sharing={getSharingForSelf(document.id)}
59
- {...rest}
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
- contacts: contactsResponseType,
70
- document: PropTypes.object,
71
- groups: groupsResponseType
71
+ document: PropTypes.object
72
72
  }
73
73
 
74
- const contactsQuery = () =>
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 './Tooltip'
7
+ import { SharingTooltip, TooltipRecipientList } from '../Tooltip'
8
8
 
9
9
  const AvatarPlusX = ({ className, size, extraRecipients = [] }) => {
10
10
  const sharingTooltipId = uniqueId('extra-recipients-avatar-')
@@ -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