cozy-sharing 40.1.6 → 40.1.7

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 (86) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/components/FederatedFolder/FederatedFolderModal.js +10 -12
  3. package/dist/components/Recipient/DowngradePermissionConfirmDialog.js +3 -12
  4. package/dist/components/Recipient/GroupRecipient.js +1 -4
  5. package/dist/components/Recipient/GroupRecipient.stories.js +3 -1
  6. package/dist/components/Recipient/GroupRecipientDetailWithAccess.js +1 -4
  7. package/dist/components/Recipient/GroupRecipientPermissions.js +5 -8
  8. package/dist/components/Recipient/GroupRecipientPermissions.stories.js +2 -0
  9. package/dist/components/Recipient/LinkRecipient.js +2 -6
  10. package/dist/components/Recipient/LinkRecipient.stories.js +4 -0
  11. package/dist/components/Recipient/LinkRecipientPermissions.js +13 -12
  12. package/dist/components/Recipient/LinkRecipientPermissions.stories.js +5 -1
  13. package/dist/components/Recipient/MemberRecipient.js +7 -6
  14. package/dist/components/Recipient/MemberRecipient.spec.js +7 -12
  15. package/dist/components/Recipient/MemberRecipientPermissions.js +28 -13
  16. package/dist/components/Recipient/MemberRecipientPermissions.spec.js +5 -14
  17. package/dist/components/Recipient/MemberRecipientPermissions.stories.js +2 -1
  18. package/dist/components/Recipient/OwnerRecipient.js +4 -17
  19. package/dist/components/Recipient/OwnerRecipient.stories.js +3 -1
  20. package/dist/components/Recipient/OwnerRecipientDefaultLite.js +1 -1
  21. package/dist/components/Recipient/PermissionTypeMenu.js +32 -155
  22. package/dist/components/Recipient/PermissionTypeMenuWrapper.js +37 -0
  23. package/dist/components/Recipient/{PermissionTypeMenu.spec.js → PermissionTypeMenuWrapper.spec.js} +2 -2
  24. package/dist/components/Recipient/RecipientList.js +10 -0
  25. package/dist/components/Recipient/RecipientList.stories.js +3 -0
  26. package/dist/components/ShareDialogCozyToCozy.js +20 -19
  27. package/dist/components/ShareDialogCozyToCozy.spec.js +3 -0
  28. package/dist/components/ShareDialogOnlyByLink.js +3 -5
  29. package/dist/components/ShareDialogOnlyByLink.spec.js +0 -1
  30. package/dist/components/ShareModal/SharingDetailsModal.js +2 -2
  31. package/dist/components/SharedDrive/EditSharedDriveModal.js +11 -10
  32. package/dist/components/SharedDrive/useSharedDrive.js +8 -11
  33. package/dist/components/SharingContent.js +3 -5
  34. package/dist/components/WhoHasAccess.js +27 -11
  35. package/dist/components/WhoHasAccessWrapper.js +122 -0
  36. package/dist/helpers/recipients.js +46 -0
  37. package/dist/helpers/recipients.spec.js +89 -0
  38. package/dist/hooks/useMemberPermissionType.js +191 -0
  39. package/dist/hooks/useResolveRecipients.js +53 -0
  40. package/dist/hooks/useResolveRecipients.spec.js +140 -0
  41. package/dist/index.js +1 -1
  42. package/package.json +3 -3
  43. package/src/components/FederatedFolder/FederatedFolderModal.jsx +6 -12
  44. package/src/components/Recipient/DowngradePermissionConfirmDialog.jsx +3 -10
  45. package/src/components/Recipient/GroupRecipient.jsx +1 -5
  46. package/src/components/Recipient/GroupRecipient.stories.jsx +3 -1
  47. package/src/components/Recipient/GroupRecipientDetailWithAccess.jsx +1 -4
  48. package/src/components/Recipient/GroupRecipientPermissions.jsx +5 -5
  49. package/src/components/Recipient/GroupRecipientPermissions.stories.jsx +2 -0
  50. package/src/components/Recipient/LinkRecipient.jsx +2 -4
  51. package/src/components/Recipient/LinkRecipient.stories.jsx +4 -0
  52. package/src/components/Recipient/LinkRecipientPermissions.jsx +16 -12
  53. package/src/components/Recipient/LinkRecipientPermissions.stories.jsx +5 -1
  54. package/src/components/Recipient/MemberRecipient.jsx +4 -4
  55. package/src/components/Recipient/MemberRecipient.spec.jsx +7 -10
  56. package/src/components/Recipient/MemberRecipientPermissions.jsx +29 -13
  57. package/src/components/Recipient/MemberRecipientPermissions.spec.jsx +5 -11
  58. package/src/components/Recipient/MemberRecipientPermissions.stories.jsx +2 -1
  59. package/src/components/Recipient/OwnerRecipient.jsx +4 -17
  60. package/src/components/Recipient/OwnerRecipient.stories.jsx +1 -1
  61. package/src/components/Recipient/OwnerRecipientDefaultLite.jsx +1 -1
  62. package/src/components/Recipient/PermissionTypeMenu.jsx +21 -81
  63. package/src/components/Recipient/PermissionTypeMenuWrapper.jsx +32 -0
  64. package/src/components/Recipient/{PermissionTypeMenu.spec.jsx → PermissionTypeMenuWrapper.spec.jsx} +2 -2
  65. package/src/components/Recipient/RecipientList.jsx +10 -0
  66. package/src/components/Recipient/RecipientList.stories.jsx +3 -0
  67. package/src/components/ShareDialogCozyToCozy.jsx +10 -11
  68. package/src/components/ShareDialogCozyToCozy.spec.jsx +1 -0
  69. package/src/components/ShareDialogOnlyByLink.jsx +2 -4
  70. package/src/components/ShareDialogOnlyByLink.spec.jsx +0 -1
  71. package/src/components/ShareModal/SharingDetailsModal.jsx +2 -2
  72. package/src/components/SharedDrive/EditSharedDriveModal.jsx +6 -11
  73. package/src/components/SharedDrive/useSharedDrive.js +4 -11
  74. package/src/components/SharingContent.jsx +2 -4
  75. package/src/components/WhoHasAccess.jsx +26 -12
  76. package/src/components/WhoHasAccessWrapper.jsx +117 -0
  77. package/src/helpers/recipients.js +44 -0
  78. package/src/helpers/recipients.spec.js +82 -0
  79. package/src/hooks/useMemberPermissionType.js +110 -0
  80. package/src/hooks/useResolveRecipients.js +38 -0
  81. package/src/hooks/useResolveRecipients.spec.js +70 -0
  82. package/src/index.jsx +1 -1
  83. package/dist/components/Recipient/OwnerRecipientDefault.js +0 -27
  84. package/dist/components/Recipient/OwnerRecipientDefault.stories.js +0 -10
  85. package/src/components/Recipient/OwnerRecipientDefault.jsx +0 -37
  86. package/src/components/Recipient/OwnerRecipientDefault.stories.jsx +0 -13
@@ -4,6 +4,7 @@ var meta = {
4
4
  args: {
5
5
  onRevoke: function onRevoke() {},
6
6
  onRevokeSelf: function onRevokeSelf() {},
7
+ onSetMemberType: function onSetMemberType() {},
7
8
  type: 'two-way',
8
9
  status: 'ready'
9
10
  },
@@ -31,6 +32,6 @@ export var Self = {
31
32
  name: 'Self',
32
33
  args: {
33
34
  isOwner: false,
34
- instance: 'http://alice.cozy.localhost:8080'
35
+ isCurrentUser: true
35
36
  }
36
37
  };
@@ -1,27 +1,14 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
1
  import PropTypes from 'prop-types';
3
2
  import React from 'react';
4
3
  import MemberRecipient from './MemberRecipient';
5
- import OwnerRecipientDefault from './OwnerRecipientDefault';
6
4
 
7
5
  var OwnerRecipient = function OwnerRecipient(_ref) {
8
- var recipients = _ref.recipients,
9
- isOrgSharedDrive = _ref.isOrgSharedDrive;
10
- var ownerRecipient = recipients.find(function (recipient) {
11
- return recipient.status === 'owner';
12
- });
13
-
14
- if (ownerRecipient) {
15
- return /*#__PURE__*/React.createElement(MemberRecipient, _extends({}, ownerRecipient, {
16
- isOrgSharedDrive: isOrgSharedDrive
17
- }));
18
- }
19
-
20
- return /*#__PURE__*/React.createElement(OwnerRecipientDefault, null);
6
+ var owner = _ref.owner;
7
+ if (!owner) return null;
8
+ return /*#__PURE__*/React.createElement(MemberRecipient, owner);
21
9
  };
22
10
 
23
11
  OwnerRecipient.propTypes = {
24
- recipients: PropTypes.array.isRequired,
25
- isOrgSharedDrive: PropTypes.bool
12
+ owner: PropTypes.object
26
13
  };
27
14
  export default OwnerRecipient;
@@ -3,7 +3,9 @@ import { recipients } from '../../../.storybook/fixtures/recipients';
3
3
  var meta = {
4
4
  component: OwnerRecipient,
5
5
  args: {
6
- recipients: recipients
6
+ owner: recipients.find(function (recipient) {
7
+ return recipient.status === 'owner';
8
+ })
7
9
  }
8
10
  };
9
11
  export default meta;
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { useClient, useQuery, hasQueryBeenLoaded } from 'cozy-client';
3
3
  import MemberRecipientLite from './MemberRecipientLite';
4
4
  import withLocales from '../../hoc/withLocales';
5
- import { buildInstanceSettingsQuery } from '../../queries/queries'; // See OwnerRecipientDefault: show the instance public avatar (with an initials
5
+ import { buildInstanceSettingsQuery } from '../../queries/queries'; // See containers/WhoHasAccess: show the instance public avatar (with an initials
6
6
  // fallback) when the owner has no per-sharing avatar to reference.
7
7
 
8
8
  var OWNER_PUBLIC_AVATAR_PATH = '/public/avatar?fallback=initials';
@@ -1,21 +1,8 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
5
-
6
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7
-
8
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
9
-
10
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
11
-
12
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
13
-
14
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
15
-
4
+ import PropTypes from 'prop-types';
16
5
  import React, { useCallback, useRef, useState } from 'react';
17
- import { useClient } from 'cozy-client';
18
- import flag from 'cozy-flags';
19
6
  import minilog from 'cozy-minilog';
20
7
  import ActionsMenu from 'cozy-ui/transpiled/react/ActionsMenu';
21
8
  import { makeActions } from 'cozy-ui/transpiled/react/ActionsMenu/Actions';
@@ -25,32 +12,21 @@ import { useI18n } from 'twake-i18n';
25
12
  import DowngradePermissionConfirmDialog from './DowngradePermissionConfirmDialog';
26
13
  import { setReadOnlySharedPermission } from './actions/setReadOnlySharedPermission';
27
14
  import { setReadWriteSharedPermission } from './actions/setReadWriteSharedPermission';
28
- import { getOrCreateFromArray } from '../../helpers/contacts';
29
- import withLocales from '../../hoc/withLocales';
30
- import { useFetchDocumentPath } from '../../hooks/useFetchDocumentPath';
31
- import { useSharingContext } from '../../hooks/useSharingContext';
32
- import { getSharingDocIds } from '../../state';
33
15
  var log = minilog('PermissionTypeMenu');
34
16
 
35
- var PermissionTypeMenuComponent = function PermissionTypeMenuComponent(_ref) {
36
- var sharingId = _ref.sharingId,
37
- memberIndex = _ref.memberIndex,
38
- type = _ref.type,
17
+ var PermissionTypeMenu = function PermissionTypeMenu(_ref) {
18
+ var type = _ref.type,
39
19
  document = _ref.document,
40
- recipient = _ref.recipient;
20
+ recipient = _ref.recipient,
21
+ isInsideSharedParent = _ref.isInsideSharedParent,
22
+ sharedParentName = _ref.sharedParentName,
23
+ onSetType = _ref.onSetType;
41
24
 
42
25
  var _useI18n = useI18n(),
43
26
  t = _useI18n.t;
44
27
 
45
- var client = useClient();
46
28
  var buttonRef = useRef();
47
29
 
48
- var _useSharingContext = useSharingContext(),
49
- hasSharedParent = _useSharingContext.hasSharedParent,
50
- updateSharingMemberType = _useSharingContext.updateSharingMemberType,
51
- getSharingById = _useSharingContext.getSharingById,
52
- share = _useSharingContext.share;
53
-
54
30
  var _useAlert = useAlert(),
55
31
  showAlert = _useAlert.showAlert;
56
32
 
@@ -64,154 +40,46 @@ var PermissionTypeMenuComponent = function PermissionTypeMenuComponent(_ref) {
64
40
  pendingType = _useState4[0],
65
41
  setPendingType = _useState4[1];
66
42
 
67
- var documentPath = useFetchDocumentPath(client, document);
68
43
  var hideMenu = useCallback(function () {
69
44
  setMenuDisplayed(false);
70
45
  }, []);
71
46
  var applyType = useCallback( /*#__PURE__*/function () {
72
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(newType) {
73
- var _ref3,
74
- _ref3$withAncestors,
75
- withAncestors,
76
- ancestors,
77
- _iterator,
78
- _step,
79
- ancestor,
80
- documentId,
81
- sourceSharing,
82
- contacts,
83
- _args = arguments;
84
-
47
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(newType, options) {
85
48
  return _regeneratorRuntime.wrap(function _callee$(_context) {
86
49
  while (1) switch (_context.prev = _context.next) {
87
50
  case 0:
88
- _ref3 = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}, _ref3$withAncestors = _ref3.withAncestors, withAncestors = _ref3$withAncestors === void 0 ? false : _ref3$withAncestors;
89
- _context.prev = 1;
90
-
91
- if (!withAncestors) {
92
- _context.next = 21;
93
- break;
94
- }
95
-
96
- // Ancestors first: only the target's own update refetches its
97
- // effective recipients, which must already see them downgraded.
98
- ancestors = ((recipient === null || recipient === void 0 ? void 0 : recipient.sources) || []).filter(function (s) {
99
- return s.kind === 'ancestor' && !s.read_only;
100
- });
101
- _iterator = _createForOfIteratorHelper(ancestors);
102
- _context.prev = 5;
103
-
104
- _iterator.s();
105
-
106
- case 7:
107
- if ((_step = _iterator.n()).done) {
108
- _context.next = 13;
109
- break;
110
- }
111
-
112
- ancestor = _step.value;
113
- _context.next = 11;
114
- return updateSharingMemberType(ancestor.sharing_id, ancestor.member_index, newType);
51
+ _context.prev = 0;
52
+ _context.next = 3;
53
+ return onSetType(newType, options);
115
54
 
116
- case 11:
117
- _context.next = 7;
55
+ case 3:
56
+ _context.next = 9;
118
57
  break;
119
58
 
120
- case 13:
121
- _context.next = 18;
122
- break;
123
-
124
- case 15:
125
- _context.prev = 15;
126
- _context.t0 = _context["catch"](5);
127
-
128
- _iterator.e(_context.t0);
129
-
130
- case 18:
131
- _context.prev = 18;
132
-
133
- _iterator.f();
134
-
135
- return _context.finish(18);
136
-
137
- case 21:
138
- documentId = (document === null || document === void 0 ? void 0 : document._id) || (document === null || document === void 0 ? void 0 : document.id);
139
-
140
- if (!(flag('drive.federated-shared-folder.enabled') && type === 'one-way' && newType === 'two-way' && documentId)) {
141
- _context.next = 33;
142
- break;
143
- }
144
-
145
- sourceSharing = getSharingById(sharingId);
146
-
147
- if (!(sourceSharing && !getSharingDocIds(sourceSharing).includes(documentId))) {
148
- _context.next = 33;
149
- break;
150
- }
151
-
152
- _context.next = 27;
153
- return getOrCreateFromArray(client, [recipient], function (contact) {
154
- return client.create('io.cozy.contacts', contact);
155
- });
156
-
157
- case 27:
158
- contacts = _context.sent;
159
-
160
- if (contacts[0]) {
161
- _context.next = 30;
162
- break;
163
- }
164
-
165
- throw new Error('Recipient contact not found');
166
-
167
- case 30:
168
- _context.next = 32;
169
- return share({
170
- document: _objectSpread(_objectSpread({}, document), {}, {
171
- id: documentId
172
- }),
173
- description: document.name,
174
- recipients: contacts,
175
- readOnlyRecipients: [],
176
- sharedDrive: true,
177
- openSharing: false
178
- });
179
-
180
- case 32:
181
- return _context.abrupt("return");
182
-
183
- case 33:
184
- _context.next = 35;
185
- return updateSharingMemberType(sharingId, memberIndex, newType, document);
186
-
187
- case 35:
188
- _context.next = 41;
189
- break;
190
-
191
- case 37:
192
- _context.prev = 37;
193
- _context.t1 = _context["catch"](1);
194
- log.error('Failed to change member permission type', _context.t1);
59
+ case 5:
60
+ _context.prev = 5;
61
+ _context.t0 = _context["catch"](0);
62
+ log.error('Failed to change member permission type', _context.t0);
195
63
  showAlert({
196
64
  message: t('Share.members.error.changePermission'),
197
65
  severity: 'error',
198
66
  variant: 'filled'
199
67
  });
200
68
 
201
- case 41:
69
+ case 9:
202
70
  case "end":
203
71
  return _context.stop();
204
72
  }
205
- }, _callee, null, [[1, 37], [5, 15, 18, 21]]);
73
+ }, _callee, null, [[0, 5]]);
206
74
  }));
207
75
 
208
- return function (_x) {
76
+ return function (_x, _x2) {
209
77
  return _ref2.apply(this, arguments);
210
78
  };
211
- }(), [client, document, getSharingById, memberIndex, recipient, share, sharingId, showAlert, t, type, updateSharingMemberType]); // Downgrading to viewer on a folder inside a shared parent also reduces
79
+ }(), [onSetType, showAlert, t]); // Downgrading to viewer on a folder inside a shared parent also reduces
212
80
  // the member's rights on the parent: require explicit confirmation first.
213
81
 
214
- var shouldConfirmDowngrade = type === 'two-way' && Boolean(documentPath) && (hasSharedParent === null || hasSharedParent === void 0 ? void 0 : hasSharedParent(documentPath));
82
+ var shouldConfirmDowngrade = type === 'two-way' && isInsideSharedParent;
215
83
  var setType = useCallback(function (newType) {
216
84
  hideMenu();
217
85
  if (newType === type) return;
@@ -255,9 +123,18 @@ var PermissionTypeMenuComponent = function PermissionTypeMenuComponent(_ref) {
255
123
  }), pendingType && /*#__PURE__*/React.createElement(DowngradePermissionConfirmDialog, {
256
124
  document: document,
257
125
  recipient: recipient,
126
+ sharedParentName: sharedParentName,
258
127
  onCancel: handleCancelDowngrade,
259
128
  onConfirm: handleConfirmDowngrade
260
129
  }));
261
130
  };
262
131
 
263
- export var PermissionTypeMenu = withLocales(PermissionTypeMenuComponent);
132
+ PermissionTypeMenu.propTypes = {
133
+ type: PropTypes.oneOf(['one-way', 'two-way']),
134
+ document: PropTypes.object,
135
+ recipient: PropTypes.object,
136
+ isInsideSharedParent: PropTypes.bool,
137
+ sharedParentName: PropTypes.string,
138
+ onSetType: PropTypes.func.isRequired
139
+ };
140
+ export default PermissionTypeMenu;
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import PermissionTypeMenu from './PermissionTypeMenu';
3
+ import withLocales from '../../hoc/withLocales';
4
+ import { useMemberPermissionType } from '../../hooks/useMemberPermissionType';
5
+
6
+ var PermissionTypeMenuWrapper = function PermissionTypeMenuWrapper(_ref) {
7
+ var sharingId = _ref.sharingId,
8
+ memberIndex = _ref.memberIndex,
9
+ type = _ref.type,
10
+ document = _ref.document,
11
+ recipient = _ref.recipient;
12
+
13
+ var _useMemberPermissionT = useMemberPermissionType(document),
14
+ isInsideSharedParent = _useMemberPermissionT.isInsideSharedParent,
15
+ sharedParentName = _useMemberPermissionT.sharedParentName,
16
+ setMemberType = _useMemberPermissionT.setMemberType;
17
+
18
+ var handleSetType = function handleSetType(newType, options) {
19
+ return setMemberType({
20
+ sharingId: sharingId,
21
+ memberIndex: memberIndex,
22
+ type: type,
23
+ recipient: recipient
24
+ }, newType, options);
25
+ };
26
+
27
+ return /*#__PURE__*/React.createElement(PermissionTypeMenu, {
28
+ type: type,
29
+ document: document,
30
+ recipient: recipient,
31
+ isInsideSharedParent: isInsideSharedParent,
32
+ sharedParentName: sharedParentName,
33
+ onSetType: handleSetType
34
+ });
35
+ };
36
+
37
+ export default withLocales(PermissionTypeMenuWrapper);
@@ -5,7 +5,7 @@ import { render, fireEvent, screen, waitFor } from '@testing-library/react';
5
5
  import React from 'react';
6
6
  import { createMockClient } from 'cozy-client';
7
7
  import flag from 'cozy-flags';
8
- import { PermissionTypeMenu } from './PermissionTypeMenu';
8
+ import PermissionTypeMenuWrapper from './PermissionTypeMenuWrapper';
9
9
  import AppLike from '../../../test/AppLike';
10
10
  var mockUpdateSharingMemberType = jest.fn();
11
11
  var mockHasSharedParent = jest.fn();
@@ -63,7 +63,7 @@ describe('PermissionTypeMenu component', function () {
63
63
  var setup = function setup(props) {
64
64
  return render( /*#__PURE__*/React.createElement(AppLike, {
65
65
  client: client
66
- }, /*#__PURE__*/React.createElement(PermissionTypeMenu, _extends({}, defaultProps, props))));
66
+ }, /*#__PURE__*/React.createElement(PermissionTypeMenuWrapper, _extends({}, defaultProps, props))));
67
67
  };
68
68
 
69
69
  var createRangeBackup;
@@ -14,8 +14,13 @@ var RecipientList = function RecipientList(_ref) {
14
14
  isSharedDrive = _ref.isSharedDrive,
15
15
  document = _ref.document,
16
16
  documentType = _ref.documentType,
17
+ isInsideSharedParent = _ref.isInsideSharedParent,
18
+ sharedParentName = _ref.sharedParentName,
17
19
  onRevoke = _ref.onRevoke,
18
20
  onRevokeSelf = _ref.onRevokeSelf,
21
+ onRevokeGroup = _ref.onRevokeGroup,
22
+ onLeaveGroup = _ref.onLeaveGroup,
23
+ onSetMemberType = _ref.onSetMemberType,
19
24
  verifyRecipient = _ref.verifyRecipient;
20
25
  var previousRecipients = usePrevious(recipients);
21
26
  var recipientsToDisplay = filterAndReworkRecipients(recipients, previousRecipients);
@@ -34,6 +39,8 @@ var RecipientList = function RecipientList(_ref) {
34
39
  documentType: documentType,
35
40
  onRevoke: onRevoke,
36
41
  onRevokeSelf: onRevokeSelf,
42
+ onRevokeGroup: onRevokeGroup,
43
+ onLeaveGroup: onLeaveGroup,
37
44
  fadeIn: recipient.hasBeenJustAdded
38
45
  }));
39
46
  }
@@ -46,8 +53,11 @@ var RecipientList = function RecipientList(_ref) {
46
53
  isSharedDrive: isSharedDrive,
47
54
  document: document,
48
55
  documentType: documentType,
56
+ isInsideSharedParent: isInsideSharedParent,
57
+ sharedParentName: sharedParentName,
49
58
  onRevoke: onRevoke,
50
59
  onRevokeSelf: onRevokeSelf,
60
+ onSetMemberType: onSetMemberType,
51
61
  recipientConfirmationData: recipientConfirmationData,
52
62
  verifyRecipient: verifyRecipient,
53
63
  fadeIn: recipient.hasBeenJustAdded
@@ -9,6 +9,9 @@ var meta = {
9
9
  isOwner: false,
10
10
  onRevoke: function onRevoke() {},
11
11
  onRevokeSelf: function onRevokeSelf() {},
12
+ onRevokeGroup: function onRevokeGroup() {},
13
+ onLeaveGroup: function onLeaveGroup() {},
14
+ onSetMemberType: function onSetMemberType() {},
12
15
  verifyRecipient: function verifyRecipient() {
13
16
  return true;
14
17
  }
@@ -7,7 +7,6 @@ var _excluded = ["showShareByLink", "showGenerateLinkButton", "autoOpenShareRest
7
7
  import _regeneratorRuntime from "@babel/runtime/regenerator";
8
8
  import PropTypes from 'prop-types';
9
9
  import React, { useCallback, useMemo, useState } from 'react';
10
- import { useClient } from 'cozy-client';
11
10
  import Button from 'cozy-ui/transpiled/react/Buttons';
12
11
  import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert';
13
12
  import { useI18n } from 'twake-i18n';
@@ -15,10 +14,10 @@ import { default as DumbShareByLink } from './ShareByLink';
15
14
  import ShareDialogTwoStepsConfirmationContainer from './ShareDialogTwoStepsConfirmationContainer';
16
15
  import { ShareRecipientsLimitModal } from './ShareRecipientsLimitModal';
17
16
  import SharingContent from './SharingContent';
18
- import { getOrCreateFromArray } from '../helpers/contacts';
19
17
  import { hasReachRecipientsLimit } from '../helpers/recipients';
20
18
  import { getErrorMessage, getSuccessMessage } from '../helpers/share';
21
19
  import { usePendingRecipients } from '../hooks/usePendingRecipients';
20
+ import { useResolveRecipients } from '../hooks/useResolveRecipients';
22
21
  import { useSharingContext } from '../hooks/useSharingContext';
23
22
 
24
23
  var SharingTitleFunction = function SharingTitleFunction(_ref) {
@@ -53,7 +52,7 @@ var ShareDialogCozyToCozy = function ShareDialogCozyToCozy(_ref2) {
53
52
  var _useI18n2 = useI18n(),
54
53
  t = _useI18n2.t;
55
54
 
56
- var client = useClient();
55
+ var resolveRecipients = useResolveRecipients();
57
56
 
58
57
  var _useAlert = useAlert(),
59
58
  showAlert = _useAlert.showAlert;
@@ -79,7 +78,8 @@ var ShareDialogCozyToCozy = function ShareDialogCozyToCozy(_ref2) {
79
78
 
80
79
  var displayedLink = getSharingLink(document._id || document.id);
81
80
  var handleShare = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
82
- var contacts, readWriteRecipients, readOnlyRecipients;
81
+ var _yield$resolveRecipie2, readWriteRecipients, readOnlyRecipients, contacts;
82
+
83
83
  return _regeneratorRuntime.wrap(function _callee$(_context) {
84
84
  while (1) switch (_context.prev = _context.next) {
85
85
  case 0:
@@ -104,13 +104,14 @@ var ShareDialogCozyToCozy = function ShareDialogCozyToCozy(_ref2) {
104
104
  setSubmitting(true);
105
105
  _context.prev = 7;
106
106
  _context.next = 10;
107
- return getOrCreateFromArray(client, pendingRecipients, createContact);
107
+ return resolveRecipients(pendingRecipients, selectedOption, createContact);
108
108
 
109
109
  case 10:
110
- contacts = _context.sent;
111
- readWriteRecipients = selectedOption === 'readOnly' ? [] : contacts;
112
- readOnlyRecipients = selectedOption === 'readOnly' ? contacts : [];
113
- _context.next = 15;
110
+ _yield$resolveRecipie2 = _context.sent;
111
+ readWriteRecipients = _yield$resolveRecipie2.recipients;
112
+ readOnlyRecipients = _yield$resolveRecipie2.readOnlyRecipients;
113
+ contacts = [].concat(_toConsumableArray(readWriteRecipients), _toConsumableArray(readOnlyRecipients));
114
+ _context.next = 16;
114
115
  return onShare({
115
116
  document: document,
116
117
  recipients: readWriteRecipients,
@@ -119,18 +120,18 @@ var ShareDialogCozyToCozy = function ShareDialogCozyToCozy(_ref2) {
119
120
  openSharing: readWriteRecipients.length > 0
120
121
  });
121
122
 
122
- case 15:
123
+ case 16:
123
124
  showAlert({
124
125
  message: t.apply(void 0, _toConsumableArray(getSuccessMessage(recipients, contacts, documentType))),
125
126
  severity: 'success',
126
127
  variant: 'filled'
127
128
  });
128
129
  onClose();
129
- _context.next = 22;
130
+ _context.next = 23;
130
131
  break;
131
132
 
132
- case 19:
133
- _context.prev = 19;
133
+ case 20:
134
+ _context.prev = 20;
134
135
  _context.t0 = _context["catch"](7);
135
136
  showAlert({
136
137
  message: t.apply(void 0, _toConsumableArray(getErrorMessage({
@@ -144,17 +145,17 @@ var ShareDialogCozyToCozy = function ShareDialogCozyToCozy(_ref2) {
144
145
  variant: 'filled'
145
146
  });
146
147
 
147
- case 22:
148
- _context.prev = 22;
148
+ case 23:
149
+ _context.prev = 23;
149
150
  setSubmitting(false);
150
- return _context.finish(22);
151
+ return _context.finish(23);
151
152
 
152
- case 25:
153
+ case 26:
153
154
  case "end":
154
155
  return _context.stop();
155
156
  }
156
- }, _callee, null, [[7, 19, 22, 25]]);
157
- })), [pendingRecipients, selectedOption, client, showAlert, t, recipients, onShare, onClose, createContact, document, documentType, sharingDesc]);
157
+ }, _callee, null, [[7, 20, 23, 26]]);
158
+ })), [pendingRecipients, selectedOption, resolveRecipients, showAlert, t, recipients, onShare, onClose, createContact, document, documentType, sharingDesc]);
158
159
  var dialogActionsOnShare = useMemo(function () {
159
160
  var Actions = function Actions(dialogActionProps) {
160
161
  return /*#__PURE__*/React.createElement(React.Fragment, null, showShareByLink && /*#__PURE__*/React.createElement(DumbShareByLink, _extends({}, dialogActionProps, {
@@ -36,6 +36,9 @@ jest.mock('../hooks/useSharingContext', function () {
36
36
  getSharingLink: jest.fn(function () {
37
37
  return null;
38
38
  }),
39
+ getDocumentPermissions: jest.fn(function () {
40
+ return [];
41
+ }),
39
42
  updateSharingMemberType: jest.fn(),
40
43
  isOrgSharedDrive: jest.fn(function () {
41
44
  return false;
@@ -6,7 +6,7 @@ import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints';
6
6
  import { useI18n } from 'twake-i18n';
7
7
  import AntivirusAlert from './AntivirusAlert';
8
8
  import { default as DumbShareByLink } from './ShareByLink';
9
- import WhoHasAccess from './WhoHasAccess';
9
+ import WhoHasAccessWrapper from './WhoHasAccessWrapper';
10
10
  import { useSharingContext } from '../hooks/useSharingContext';
11
11
 
12
12
  var ShareDialogOnlyByLink = function ShareDialogOnlyByLink(_ref) {
@@ -17,7 +17,6 @@ var ShareDialogOnlyByLink = function ShareDialogOnlyByLink(_ref) {
17
17
  document = _ref.document,
18
18
  documentType = _ref.documentType,
19
19
  onClose = _ref.onClose,
20
- permissions = _ref.permissions,
21
20
  showGenerateLinkButton = _ref.showGenerateLinkButton,
22
21
  autoOpenShareRestriction = _ref.autoOpenShareRestriction;
23
22
 
@@ -44,15 +43,14 @@ var ShareDialogOnlyByLink = function ShareDialogOnlyByLink(_ref) {
44
43
  }), /*#__PURE__*/React.createElement(Typography, {
45
44
  variant: "h6",
46
45
  className: cx(isMobile ? 'u-ph-1 u-mt-1' : 'u-ph-2 u-mt-1-half')
47
- }, t('Share.contacts.whoHasAccess')), /*#__PURE__*/React.createElement(WhoHasAccess, {
46
+ }, t('Share.contacts.whoHasAccess')), /*#__PURE__*/React.createElement(WhoHasAccessWrapper, {
48
47
  document: document,
49
48
  documentType: documentType,
50
49
  isOwner: isOwner,
51
50
  onRevoke: onRevoke,
52
51
  onRevokeSelf: onRevokeSelf,
53
52
  recipients: recipients,
54
- link: displayedLink,
55
- permissions: permissions
53
+ link: displayedLink
56
54
  }), /*#__PURE__*/React.createElement("div", {
57
55
  className: cx('u-mt-half', isMobile ? 'u-ph-1 u-mb-1' : 'u-ph-2 u-mb-1-half')
58
56
  }, /*#__PURE__*/React.createElement(DumbShareByLink, {
@@ -46,7 +46,6 @@ describe('ShareDialogOnlyByLink', function () {
46
46
  onClose: jest.fn(),
47
47
  onRevoke: jest.fn(),
48
48
  onRevokeSelf: jest.fn(),
49
- permissions: [],
50
49
  recipients: []
51
50
  }));
52
51
  };
@@ -22,7 +22,7 @@ var styles = {
22
22
  "aligned-dropdown-button": "share__aligned-dropdown-button___3crgG"
23
23
  };
24
24
  import ShareByLink from '../ShareByLink';
25
- import WhoHasAccess from '../WhoHasAccess';
25
+ import WhoHasAccessWrapper from '../WhoHasAccessWrapper';
26
26
  export var SharingDetailsModal = function SharingDetailsModal(_ref) {
27
27
  var recipients = _ref.recipients,
28
28
  document = _ref.document,
@@ -49,7 +49,7 @@ export var SharingDetailsModal = function SharingDetailsModal(_ref) {
49
49
  title: t("".concat(documentType, ".share.details.title")),
50
50
  content: /*#__PURE__*/React.createElement("div", {
51
51
  className: styles['share-modal-content']
52
- }, /*#__PURE__*/React.createElement(WhoHasAccess, {
52
+ }, /*#__PURE__*/React.createElement(WhoHasAccessWrapper, {
53
53
  canManageMembers: false,
54
54
  canManageLink: isSharedDrive,
55
55
  isSharedDrive: isSharedDrive,