cozy-sharing 33.6.0 → 34.0.0

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 (54) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/OpenSharingLinkButton.js +1 -1
  3. package/dist/SharingProvider.spec.js +242 -113
  4. package/dist/actions/addToCozySharingLink.js +2 -3
  5. package/dist/actions/createCozySharingLink.js +2 -3
  6. package/dist/actions/shareNative.js +2 -3
  7. package/dist/actions/syncToCozySharingLink.js +2 -3
  8. package/dist/components/Avatar/AvatarList.js +2 -3
  9. package/dist/components/Avatar/GroupAvatar.js +2 -3
  10. package/dist/components/Recipient/GroupRecipientDetailWithoutAccess.js +2 -3
  11. package/dist/components/Recipient/GroupRecipientPermissions.js +2 -3
  12. package/dist/components/Recipient/LinkRecipient.js +2 -4
  13. package/dist/components/Recipient/LinkRecipientLite.js +2 -3
  14. package/dist/components/Recipient/MemberRecipientPermissions.js +2 -3
  15. package/dist/components/Recipient/actions/revokeLink.js +3 -4
  16. package/dist/components/ShareButton.js +4 -5
  17. package/dist/components/ShareByLink.js +5 -7
  18. package/dist/components/ShareRestrictionModal/BoxDate.js +2 -3
  19. package/dist/components/ShareRestrictionModal/BoxEditingRights.js +3 -5
  20. package/dist/components/ShareRestrictionModal/BoxPassword.js +3 -5
  21. package/dist/components/ShareRestrictionModal/ShareRestrictionModal.js +2 -3
  22. package/dist/components/SharedBadge.js +2 -3
  23. package/dist/components/SharedDrive/SharedDriveHeader.js +1 -1
  24. package/dist/helpers/sharings.js +4 -6
  25. package/dist/state.js +4 -3
  26. package/dist/state.spec.js +44 -27
  27. package/jest.config.js +3 -2
  28. package/jestHelpers/mocks/twake-icons.js +23 -0
  29. package/package.json +4 -2
  30. package/src/OpenSharingLinkButton.jsx +1 -1
  31. package/src/SharingProvider.spec.jsx +115 -1
  32. package/src/actions/addToCozySharingLink.js +2 -3
  33. package/src/actions/createCozySharingLink.js +2 -3
  34. package/src/actions/shareNative.js +2 -3
  35. package/src/actions/syncToCozySharingLink.js +2 -3
  36. package/src/components/Avatar/AvatarList.jsx +2 -3
  37. package/src/components/Avatar/GroupAvatar.jsx +2 -3
  38. package/src/components/Recipient/GroupRecipientDetailWithoutAccess.jsx +2 -3
  39. package/src/components/Recipient/GroupRecipientPermissions.jsx +2 -3
  40. package/src/components/Recipient/LinkRecipient.jsx +2 -4
  41. package/src/components/Recipient/LinkRecipientLite.jsx +2 -3
  42. package/src/components/Recipient/MemberRecipientPermissions.jsx +2 -3
  43. package/src/components/Recipient/actions/revokeLink.js +3 -4
  44. package/src/components/ShareButton.jsx +4 -5
  45. package/src/components/ShareByLink.jsx +5 -7
  46. package/src/components/ShareRestrictionModal/BoxDate.jsx +2 -3
  47. package/src/components/ShareRestrictionModal/BoxEditingRights.jsx +3 -5
  48. package/src/components/ShareRestrictionModal/BoxPassword.jsx +3 -5
  49. package/src/components/ShareRestrictionModal/ShareRestrictionModal.jsx +2 -3
  50. package/src/components/SharedBadge.jsx +2 -4
  51. package/src/components/SharedDrive/SharedDriveHeader.jsx +1 -1
  52. package/src/helpers/sharings.js +5 -6
  53. package/src/state.js +4 -12
  54. package/src/state.spec.js +63 -29
@@ -1,11 +1,10 @@
1
+ import { Icon, Calendar } from '@linagora/twake-icons'
1
2
  import { format } from 'date-fns'
2
3
  import PropTypes from 'prop-types'
3
4
  import React from 'react'
4
5
 
5
6
  import Box from 'cozy-ui/transpiled/react/Box'
6
7
  import DatePicker from 'cozy-ui/transpiled/react/DatePicker'
7
- import Icon from 'cozy-ui/transpiled/react/Icon'
8
- import CalendarIcon from 'cozy-ui/transpiled/react/Icons/Calendar'
9
8
  import List from 'cozy-ui/transpiled/react/List'
10
9
  import ListItem from 'cozy-ui/transpiled/react/ListItem'
11
10
  import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
@@ -33,7 +32,7 @@ export const BoxDate = ({ onChange, date, toggle, onToggle }) => {
33
32
  onClick={() => handleDateToggle(!toggle)}
34
33
  >
35
34
  <ListItemIcon>
36
- <Icon icon={CalendarIcon} />
35
+ <Icon icon={Calendar} />
37
36
  </ListItemIcon>
38
37
  <ListItemText primary={t('BoxDate.text')} />
39
38
  <ListItemSecondaryAction>
@@ -1,3 +1,4 @@
1
+ import { Icon, Bottom, People } from '@linagora/twake-icons'
1
2
  import PropTypes from 'prop-types'
2
3
  import React, { useReducer, useRef } from 'react'
3
4
 
@@ -7,9 +8,6 @@ import flag from 'cozy-flags'
7
8
  import ActionsMenu from 'cozy-ui/transpiled/react/ActionsMenu'
8
9
  import { makeActions } from 'cozy-ui/transpiled/react/ActionsMenu/Actions'
9
10
  import Box from 'cozy-ui/transpiled/react/Box'
10
- import Icon from 'cozy-ui/transpiled/react/Icon'
11
- import BottomIcon from 'cozy-ui/transpiled/react/Icons/Bottom'
12
- import PeopleIcon from 'cozy-ui/transpiled/react/Icons/People'
13
11
  import List from 'cozy-ui/transpiled/react/List'
14
12
  import ListItem from 'cozy-ui/transpiled/react/ListItem'
15
13
  import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
@@ -67,11 +65,11 @@ export const BoxEditingRights = ({ file, editingRights, setEditingRights }) => {
67
65
  onClick={toggleMenuDisplayed}
68
66
  >
69
67
  <ListItemIcon>
70
- <Icon icon={PeopleIcon} />
68
+ <Icon icon={People} />
71
69
  </ListItemIcon>
72
70
  <ListItemText primary={textPrimary} secondary={textSecondary} />
73
71
  <ListItemIcon className="u-mr-half">
74
- <Icon icon={BottomIcon} />
72
+ <Icon icon={Bottom} />
75
73
  </ListItemIcon>
76
74
  </ListItem>
77
75
  </List>
@@ -1,11 +1,9 @@
1
+ import { Icon, Copy, Password } from '@linagora/twake-icons'
1
2
  import PropTypes from 'prop-types'
2
3
  import React, { useState } from 'react'
3
4
 
4
5
  import Box from 'cozy-ui/transpiled/react/Box'
5
- import Icon from 'cozy-ui/transpiled/react/Icon'
6
6
  import IconButton from 'cozy-ui/transpiled/react/IconButton'
7
- import CopyIcon from 'cozy-ui/transpiled/react/Icons/Copy'
8
- import PasswordIcon from 'cozy-ui/transpiled/react/Icons/Password'
9
7
  import List from 'cozy-ui/transpiled/react/List'
10
8
  import ListItem from 'cozy-ui/transpiled/react/ListItem'
11
9
  import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
@@ -69,7 +67,7 @@ export const BoxPassword = ({
69
67
  onClick={() => handlePasswordToggle(!toggle)}
70
68
  >
71
69
  <ListItemIcon>
72
- <Icon icon={PasswordIcon} />
70
+ <Icon icon={Password} />
73
71
  </ListItemIcon>
74
72
  <ListItemText primary={t('BoxPassword.text')} />
75
73
  <ListItemSecondaryAction>
@@ -106,7 +104,7 @@ export const BoxPassword = ({
106
104
  InputProps={{
107
105
  endAdornment: (
108
106
  <IconButton onClick={handleCopy}>
109
- <Icon icon={CopyIcon} />
107
+ <Icon icon={Copy} />
110
108
  </IconButton>
111
109
  )
112
110
  }}
@@ -1,3 +1,4 @@
1
+ import { Icon, Trash } from '@linagora/twake-icons'
1
2
  import { addDays } from 'date-fns'
2
3
  import PropTypes from 'prop-types'
3
4
  import React, { useState } from 'react'
@@ -6,8 +7,6 @@ import { generateWebLink, useClient } from 'cozy-client'
6
7
  import flag from 'cozy-flags'
7
8
  import Button from 'cozy-ui/transpiled/react/Buttons'
8
9
  import { ConfirmDialog } from 'cozy-ui/transpiled/react/CozyDialogs'
9
- import Icon from 'cozy-ui/transpiled/react/Icon'
10
- import TrashIcon from 'cozy-ui/transpiled/react/Icons/Trash'
11
10
  import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert'
12
11
  import { useI18n } from 'twake-i18n'
13
12
 
@@ -172,7 +171,7 @@ export const ShareRestrictionModal = ({ file, onClose }) => {
172
171
  label={t('Share.permissionLink.deactivate')}
173
172
  variant="secondary"
174
173
  color="error"
175
- startIcon={<Icon icon={TrashIcon} />}
174
+ startIcon={<Icon icon={Trash} />}
176
175
  onClick={handleRevokeLink}
177
176
  busy={loading}
178
177
  />
@@ -1,9 +1,7 @@
1
+ import { Icon, Share } from '@linagora/twake-icons'
1
2
  import classNames from 'classnames'
2
3
  import React from 'react'
3
4
 
4
- import Icon from 'cozy-ui/transpiled/react/Icon'
5
- import ShareIcon from 'cozy-ui/transpiled/react/Icons/Share'
6
-
7
5
  import styles from '../styles/badge.styl'
8
6
 
9
7
  const SharedBadge = ({ byMe, className, small, xsmall }) => (
@@ -17,7 +15,7 @@ const SharedBadge = ({ byMe, className, small, xsmall }) => (
17
15
  )}
18
16
  >
19
17
  <Icon
20
- icon={ShareIcon}
18
+ icon={Share}
21
19
  color="var(--primaryContrastTextColor)"
22
20
  className={styles['shared-badge-icon']}
23
21
  />
@@ -1,6 +1,6 @@
1
+ import { Icon } from '@linagora/twake-icons'
1
2
  import React from 'react'
2
3
 
3
- import Icon from 'cozy-ui/transpiled/react/Icon'
4
4
  import Typography from 'cozy-ui/transpiled/react/Typography'
5
5
 
6
6
  import SharedDriveIcon from '../../assets/icons/shared-drive.svg'
@@ -1,7 +1,6 @@
1
+ import { CloudPlusOutlined, Sync, ToTheCloud } from '@linagora/twake-icons'
2
+
1
3
  import { Q } from 'cozy-client'
2
- import CloudPlusOutlinedIcon from 'cozy-ui/transpiled/react/Icons/CloudPlusOutlined'
3
- import SyncIcon from 'cozy-ui/transpiled/react/Icons/Sync'
4
- import ToTheCloudIcon from 'cozy-ui/transpiled/react/Icons/ToTheCloud'
5
4
 
6
5
  import { fetchFilesPaths } from './files'
7
6
  import {
@@ -78,20 +77,20 @@ export const getIconWithlabel = ({
78
77
  }) => {
79
78
  if (link === CREATE_COZY_HREF) {
80
79
  return {
81
- icon: ToTheCloudIcon,
80
+ icon: ToTheCloud,
82
81
  label: t('Share.create-cozy', { smart_count: isShortLabel ? 1 : 2 })
83
82
  }
84
83
  }
85
84
  if (!isSharingShortcutCreated) {
86
85
  return {
87
- icon: CloudPlusOutlinedIcon,
86
+ icon: CloudPlusOutlined,
88
87
  label: t('Share.banner.add_to_mine', {
89
88
  smart_count: isShortLabel ? 1 : 2
90
89
  })
91
90
  }
92
91
  }
93
92
  return {
94
- icon: SyncIcon,
93
+ icon: Sync,
95
94
  label: t('Share.banner.sync_to_mine', { smart_count: isShortLabel ? 1 : 2 })
96
95
  }
97
96
  }
package/src/state.js CHANGED
@@ -184,10 +184,7 @@ const byDocId = (state = {}, action) => {
184
184
  case REVOKE_GROUP:
185
185
  case REVOKE_RECIPIENT:
186
186
  case UPDATE_SHARING:
187
- if (
188
- !isSharingADrive(action.sharing) &&
189
- areAllRecipientsRevoked(action.sharing)
190
- ) {
187
+ if (areAllRecipientsRevoked(action.sharing)) {
191
188
  return forgetSharing(state, action.sharing)
192
189
  }
193
190
  return state
@@ -258,10 +255,7 @@ const sharings = (state = [], action) => {
258
255
  case UPDATE_SHARING:
259
256
  case REVOKE_GROUP:
260
257
  case REVOKE_RECIPIENT:
261
- if (
262
- !isSharingADrive(action.sharing) &&
263
- areAllRecipientsRevoked(action.sharing)
264
- ) {
258
+ if (areAllRecipientsRevoked(action.sharing)) {
265
259
  return state.filter(s => s.id !== action.sharing.id)
266
260
  }
267
261
  return state.map(s => {
@@ -287,10 +281,8 @@ const sharedPaths = (state = [], action) => {
287
281
  return newState
288
282
  case REVOKE_GROUP:
289
283
  case REVOKE_RECIPIENT:
290
- if (
291
- !isSharingADrive(action.sharing) &&
292
- areAllRecipientsRevoked(action.sharing)
293
- ) {
284
+ case UPDATE_SHARING:
285
+ if (areAllRecipientsRevoked(action.sharing)) {
294
286
  return state.filter(p => p !== action.path)
295
287
  }
296
288
  return state
package/src/state.spec.js CHANGED
@@ -6,6 +6,7 @@ import reducer, {
6
6
  revokeSharingLink,
7
7
  getRecipients,
8
8
  getRecipientsFromSharing,
9
+ revokeGroup,
9
10
  revokeRecipient,
10
11
  revokeSelf,
11
12
  updateSharing,
@@ -143,7 +144,7 @@ describe('Sharing state', () => {
143
144
  expect(state.sharings).toEqual([SHARING_1, SHARED_DRIVE_WITHOUT_RECIPIENTS])
144
145
  })
145
146
 
146
- it('should not forget shared drives without recipients when updating', () => {
147
+ it('should forget shared drives without recipients when updating', () => {
147
148
  const SHARED_DRIVE_WITHOUT_RECIPIENTS = {
148
149
  ...SHARING_1,
149
150
  id: 'shared_drive_no_recipients',
@@ -184,16 +185,65 @@ describe('Sharing state', () => {
184
185
  }
185
186
  }
186
187
  const state = reducer(initialState, updateSharing(updatedSharing))
187
- expect(state.byDocId).toEqual({
188
- shared_drive_folder: {
189
- sharings: [SHARED_DRIVE_WITHOUT_RECIPIENTS.id],
190
- permissions: []
188
+
189
+ expect(state.byDocId).toEqual({})
190
+ expect(state.sharings).toEqual([])
191
+ })
192
+
193
+ it('should forget a shared drive when revoking its last group', () => {
194
+ const SHARED_DRIVE_WITH_GROUP = {
195
+ ...SHARING_1,
196
+ id: 'shared_drive_group',
197
+ attributes: {
198
+ ...SHARING_1.attributes,
199
+ drive: true,
200
+ members: [
201
+ {
202
+ status: 'owner',
203
+ name: 'Jane Doe',
204
+ email: 'jane@doe.com',
205
+ instance: 'http://cozy.tools:8080'
206
+ }
207
+ ],
208
+ groups: [
209
+ {
210
+ name: 'Last group',
211
+ addedBy: 0
212
+ }
213
+ ],
214
+ rules: [
215
+ {
216
+ title: 'My Shared Drive',
217
+ doctype: 'io.cozy.files',
218
+ values: ['shared_drive_group_folder'],
219
+ add: 'sync',
220
+ update: 'sync',
221
+ remove: 'sync'
222
+ }
223
+ ]
191
224
  }
192
- })
193
- expect(state.sharings).toEqual([updatedSharing])
225
+ }
226
+ const sharedDrivePath = '/shared_drive_group_folder'
227
+ const initialState = reducer(
228
+ reducer(
229
+ undefined,
230
+ receiveSharings({
231
+ sharings: [SHARED_DRIVE_WITH_GROUP]
232
+ })
233
+ ),
234
+ addSharing(SHARED_DRIVE_WITH_GROUP, sharedDrivePath)
235
+ )
236
+ const state = reducer(
237
+ initialState,
238
+ revokeGroup(SHARED_DRIVE_WITH_GROUP, 0, sharedDrivePath)
239
+ )
240
+
241
+ expect(state.byDocId).toEqual({})
242
+ expect(state.sharings).toEqual([])
243
+ expect(state.sharedPaths).toEqual([])
194
244
  })
195
245
 
196
- it('should not remove shared drive path when revoking last recipient', () => {
246
+ it('should forget a shared drive when revoking last recipient', () => {
197
247
  const SHARED_DRIVE_WITH_ONE_RECIPIENT = {
198
248
  ...SHARING_1,
199
249
  id: 'shared_drive_one_recipient',
@@ -236,30 +286,14 @@ describe('Sharing state', () => {
236
286
  ),
237
287
  addSharing(SHARED_DRIVE_WITH_ONE_RECIPIENT, sharedDrivePath)
238
288
  )
239
- const sharingAfterRevoke = {
240
- ...SHARED_DRIVE_WITH_ONE_RECIPIENT,
241
- attributes: {
242
- ...SHARED_DRIVE_WITH_ONE_RECIPIENT.attributes,
243
- members: [
244
- SHARED_DRIVE_WITH_ONE_RECIPIENT.attributes.members[0],
245
- {
246
- ...SHARED_DRIVE_WITH_ONE_RECIPIENT.attributes.members[1],
247
- status: 'revoked'
248
- }
249
- ]
250
- }
251
- }
252
289
  const state = reducer(
253
290
  initialState,
254
- revokeRecipient(sharingAfterRevoke, 1, sharedDrivePath)
291
+ revokeRecipient(SHARED_DRIVE_WITH_ONE_RECIPIENT, 1, sharedDrivePath)
255
292
  )
256
- expect(state.sharedPaths).toContain(sharedDrivePath)
257
- expect(state.byDocId).toEqual({
258
- shared_drive_folder: {
259
- sharings: [SHARED_DRIVE_WITH_ONE_RECIPIENT.id],
260
- permissions: []
261
- }
262
- })
293
+
294
+ expect(state.byDocId).toEqual({})
295
+ expect(state.sharings).toEqual([])
296
+ expect(state.sharedPaths).toEqual([])
263
297
  })
264
298
 
265
299
  it('should index received permissions', () => {