cozy-sharing 37.5.4 → 37.6.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.
- package/CHANGELOG.md +11 -0
- package/README.md +3 -2
- package/dist/SharingProvider.js +270 -196
- package/dist/SharingProvider.spec.js +34 -4
- package/dist/components/FederatedFolder/FederatedFolderModal.js +61 -82
- package/dist/components/FederatedFolder/FederatedFolderModal.spec.js +19 -8
- package/dist/components/ShareDialogCozyToCozy.js +21 -108
- package/dist/components/ShareModal/EditableSharingModal.js +44 -8
- package/dist/components/ShareModal/ShareModal.js +2 -2
- package/dist/components/ShareModal.js +2 -2
- package/dist/components/SharingContent.js +92 -0
- package/dist/helpers/effectiveRecipients.js +40 -0
- package/dist/helpers/effectiveRecipients.spec.js +134 -0
- package/dist/state.js +68 -1
- package/dist/state.spec.js +2 -1
- package/package.json +3 -3
- package/src/SharingProvider.jsx +61 -1
- package/src/SharingProvider.spec.jsx +28 -2
- package/src/components/FederatedFolder/FederatedFolderModal.jsx +50 -65
- package/src/components/FederatedFolder/FederatedFolderModal.spec.jsx +16 -8
- package/src/components/ShareDialogCozyToCozy.jsx +1 -87
- package/src/components/ShareModal/EditableSharingModal.jsx +61 -8
- package/src/components/ShareModal/ShareModal.jsx +2 -2
- package/src/components/ShareModal.jsx +2 -2
- package/src/components/SharingContent.jsx +94 -0
- package/src/helpers/effectiveRecipients.js +34 -0
- package/src/helpers/effectiveRecipients.spec.js +125 -0
- package/src/state.js +52 -1
- package/src/state.spec.js +2 -1
|
@@ -733,7 +733,10 @@ describe('shared drive recipient revocation', function () {
|
|
|
733
733
|
create: jest.fn().mockResolvedValue({
|
|
734
734
|
data: NEW_SHARING
|
|
735
735
|
}),
|
|
736
|
-
revokeRecipient: jest.fn().mockResolvedValue({})
|
|
736
|
+
revokeRecipient: jest.fn().mockResolvedValue({}),
|
|
737
|
+
fetchEffectiveRecipients: jest.fn().mockResolvedValue({
|
|
738
|
+
data: []
|
|
739
|
+
})
|
|
737
740
|
};
|
|
738
741
|
provider.sharingCol = sharingCol;
|
|
739
742
|
});
|
|
@@ -1093,7 +1096,10 @@ describe('updateSharingMemberType', function () {
|
|
|
1093
1096
|
}));
|
|
1094
1097
|
instance.sharingCol = {
|
|
1095
1098
|
setReadOnly: jest.fn().mockResolvedValue({}),
|
|
1096
|
-
setReadWrite: jest.fn().mockResolvedValue({})
|
|
1099
|
+
setReadWrite: jest.fn().mockResolvedValue({}),
|
|
1100
|
+
fetchEffectiveRecipients: jest.fn().mockResolvedValue({
|
|
1101
|
+
data: []
|
|
1102
|
+
})
|
|
1097
1103
|
};
|
|
1098
1104
|
});
|
|
1099
1105
|
it('should throw when sharing is not found', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22() {
|
|
@@ -1254,6 +1260,12 @@ describe('updateSharingMemberType', function () {
|
|
|
1254
1260
|
})
|
|
1255
1261
|
});
|
|
1256
1262
|
expect(instance.dispatch).toHaveBeenNthCalledWith(2, {
|
|
1263
|
+
type: 'UPDATE_EFFECTIVE_RECIPIENT',
|
|
1264
|
+
sharingId: 'sharing-123',
|
|
1265
|
+
memberIndex: 1,
|
|
1266
|
+
readOnly: true
|
|
1267
|
+
});
|
|
1268
|
+
expect(instance.dispatch).toHaveBeenNthCalledWith(3, {
|
|
1257
1269
|
type: 'UPDATE_SHARING',
|
|
1258
1270
|
sharing: _objectSpread(_objectSpread({}, mockSharing), {}, {
|
|
1259
1271
|
attributes: _objectSpread(_objectSpread({}, mockSharing.attributes), {}, {
|
|
@@ -1263,8 +1275,14 @@ describe('updateSharingMemberType', function () {
|
|
|
1263
1275
|
})
|
|
1264
1276
|
})
|
|
1265
1277
|
});
|
|
1278
|
+
expect(instance.dispatch).toHaveBeenNthCalledWith(4, {
|
|
1279
|
+
type: 'UPDATE_EFFECTIVE_RECIPIENT',
|
|
1280
|
+
sharingId: 'sharing-123',
|
|
1281
|
+
memberIndex: 1,
|
|
1282
|
+
readOnly: false
|
|
1283
|
+
});
|
|
1266
1284
|
|
|
1267
|
-
case
|
|
1285
|
+
case 7:
|
|
1268
1286
|
case "end":
|
|
1269
1287
|
return _context30.stop();
|
|
1270
1288
|
}
|
|
@@ -1307,6 +1325,12 @@ describe('updateSharingMemberType', function () {
|
|
|
1307
1325
|
|
|
1308
1326
|
case 4:
|
|
1309
1327
|
expect(instance.dispatch).toHaveBeenNthCalledWith(2, {
|
|
1328
|
+
type: 'UPDATE_EFFECTIVE_RECIPIENT',
|
|
1329
|
+
sharingId: 'sharing-123',
|
|
1330
|
+
memberIndex: 1,
|
|
1331
|
+
readOnly: true
|
|
1332
|
+
});
|
|
1333
|
+
expect(instance.dispatch).toHaveBeenNthCalledWith(3, {
|
|
1310
1334
|
type: 'UPDATE_SHARING',
|
|
1311
1335
|
sharing: _objectSpread(_objectSpread({}, realtimeSharing), {}, {
|
|
1312
1336
|
attributes: _objectSpread(_objectSpread({}, realtimeSharing.attributes), {}, {
|
|
@@ -1316,8 +1340,14 @@ describe('updateSharingMemberType', function () {
|
|
|
1316
1340
|
})
|
|
1317
1341
|
})
|
|
1318
1342
|
});
|
|
1343
|
+
expect(instance.dispatch).toHaveBeenNthCalledWith(4, {
|
|
1344
|
+
type: 'UPDATE_EFFECTIVE_RECIPIENT',
|
|
1345
|
+
sharingId: 'sharing-123',
|
|
1346
|
+
memberIndex: 1,
|
|
1347
|
+
readOnly: false
|
|
1348
|
+
});
|
|
1319
1349
|
|
|
1320
|
-
case
|
|
1350
|
+
case 7:
|
|
1321
1351
|
case "end":
|
|
1322
1352
|
return _context32.stop();
|
|
1323
1353
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
1
3
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
4
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
5
|
+
var _excluded = ["document"];
|
|
3
6
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
7
|
import PropTypes from 'prop-types';
|
|
5
8
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
@@ -15,7 +18,6 @@ import { getOrCreateFromArray } from '../../helpers/contacts';
|
|
|
15
18
|
import withLocales from '../../hoc/withLocales';
|
|
16
19
|
import { usePendingRecipients } from '../../hooks/usePendingRecipients';
|
|
17
20
|
import { useSharingContext } from '../../hooks/useSharingContext';
|
|
18
|
-
import { getRecipientsFromSharing } from '../../state';
|
|
19
21
|
var styles = {
|
|
20
22
|
"share-modal-content": "share__share-modal-content___1iqEq",
|
|
21
23
|
"coz-form": "share__coz-form___1ICST",
|
|
@@ -41,11 +43,12 @@ import WhoHasAccess from '../WhoHasAccess';
|
|
|
41
43
|
var log = minilog('FederatedFolderModal');
|
|
42
44
|
|
|
43
45
|
var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
|
|
44
|
-
var _sharedDriveSharing$a, _sharedDriveSharing$a2
|
|
46
|
+
var _sharedDriveSharing$a, _sharedDriveSharing$a2;
|
|
45
47
|
|
|
46
48
|
var onClose = _ref.onClose,
|
|
47
49
|
onRevokeSuccess = _ref.onRevokeSuccess,
|
|
48
50
|
existingDocument = _ref.document,
|
|
51
|
+
recipients = _ref.recipients,
|
|
49
52
|
autoOpenShareRestriction = _ref.autoOpenShareRestriction,
|
|
50
53
|
showGenerateLinkButton = _ref.showGenerateLinkButton;
|
|
51
54
|
// share from CozyProvider is wired to callbacks and realtime that
|
|
@@ -67,10 +70,6 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
|
|
|
67
70
|
getFederatedShareLink = _useSharingContext.getFederatedShareLink,
|
|
68
71
|
getDocumentPermissions = _useSharingContext.getDocumentPermissions,
|
|
69
72
|
fetchSharedDriveSharingLinks = _useSharingContext.fetchSharedDriveSharingLinks,
|
|
70
|
-
getRecipients = _useSharingContext.getRecipients,
|
|
71
|
-
getSharedParentPath = _useSharingContext.getSharedParentPath,
|
|
72
|
-
hasSharedChild = _useSharingContext.hasSharedChild,
|
|
73
|
-
hasSharedParent = _useSharingContext.hasSharedParent,
|
|
74
73
|
isOwner = _useSharingContext.isOwner,
|
|
75
74
|
revoke = _useSharingContext.revoke,
|
|
76
75
|
revokeSelf = _useSharingContext.revokeSelf;
|
|
@@ -113,35 +112,20 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
|
|
|
113
112
|
frozenRecipients = _useState10[0],
|
|
114
113
|
setFrozenRecipients = _useState10[1];
|
|
115
114
|
|
|
116
|
-
var _useState11 = useState(null),
|
|
117
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
|
118
|
-
sharedParentFolder = _useState12[0],
|
|
119
|
-
setSharedParentFolder = _useState12[1];
|
|
120
|
-
|
|
121
115
|
var documentId = (existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument._id) || (existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument.id);
|
|
122
116
|
var folderName = (existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument.name) || '';
|
|
123
|
-
var documentPath = existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument.path;
|
|
124
117
|
var sharedDriveSharing = existingDocument !== null && existingDocument !== void 0 && existingDocument.driveId ? getSharingById(existingDocument.driveId) : null;
|
|
125
118
|
var sharedDriveRootIds = (sharedDriveSharing === null || sharedDriveSharing === void 0 || (_sharedDriveSharing$a = sharedDriveSharing.attributes) === null || _sharedDriveSharing$a === void 0 || (_sharedDriveSharing$a = _sharedDriveSharing$a.rules) === null || _sharedDriveSharing$a === void 0 ? void 0 : _sharedDriveSharing$a.reduce(function (ids, rule) {
|
|
126
119
|
return ids.concat(rule.values || []);
|
|
127
|
-
}, [])) || [];
|
|
128
|
-
// find the parent shared folder to use its _id for recipient/permission lookups.
|
|
129
|
-
|
|
130
|
-
var hasSharedParentByPath = Boolean(documentPath && hasSharedParent(documentPath));
|
|
131
|
-
var sharedParentPath = !sharedDriveSharing && hasSharedParentByPath && documentPath ? getSharedParentPath(documentPath) : null;
|
|
132
|
-
var sharingReferenceId = !sharedDriveSharing && sharedParentFolder !== null && sharedParentFolder !== void 0 && sharedParentFolder._id ? sharedParentFolder._id : documentId;
|
|
133
|
-
var existingRecipients = sharedDriveSharing !== null && sharedDriveSharing !== void 0 && (_sharedDriveSharing$a2 = sharedDriveSharing.attributes) !== null && _sharedDriveSharing$a2 !== void 0 && _sharedDriveSharing$a2.members && documentId ? getRecipientsFromSharing(sharedDriveSharing, documentId) : sharingReferenceId ? getRecipients(sharingReferenceId) : [];
|
|
120
|
+
}, [])) || [];
|
|
134
121
|
var documentPermissions = documentId ? getDocumentPermissions(documentId) : [];
|
|
135
122
|
var displayedLink = existingDocument !== null && existingDocument !== void 0 && existingDocument.driveId ? getFederatedShareLink(existingDocument) : getSharingLink(existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument._id);
|
|
136
123
|
var isSharedDriveRoot = Boolean((existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument.driveId) && sharedDriveRootIds.some(function (id) {
|
|
137
124
|
return id === (existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument._id) || id === (existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument.id);
|
|
138
125
|
}));
|
|
139
126
|
var isInsideSharedDrive = Boolean((existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument.driveId) && !isSharedDriveRoot);
|
|
140
|
-
var isCurrentUserOwner = existingDocument !== null && existingDocument !== void 0 && existingDocument.driveId ? Boolean(sharedDriveSharing === null || sharedDriveSharing === void 0 || (_sharedDriveSharing$
|
|
127
|
+
var isCurrentUserOwner = existingDocument !== null && existingDocument !== void 0 && existingDocument.driveId ? Boolean(sharedDriveSharing === null || sharedDriveSharing === void 0 || (_sharedDriveSharing$a2 = sharedDriveSharing.attributes) === null || _sharedDriveSharing$a2 === void 0 ? void 0 : _sharedDriveSharing$a2.owner) : documentId ? isOwner(documentId) : false;
|
|
141
128
|
var isMemberReadOnly = isInsideSharedDrive && !isCurrentUserOwner;
|
|
142
|
-
var hasParentRestriction = isInsideSharedDrive || hasSharedParentByPath;
|
|
143
|
-
var hasChildRestriction = Boolean(documentPath && hasSharedChild(documentPath));
|
|
144
|
-
var canShareByEmail = !hasParentRestriction && !hasChildRestriction;
|
|
145
129
|
var canManageSharing = isCurrentUserOwner || (documentId ? canReshare(documentId) : false);
|
|
146
130
|
|
|
147
131
|
var handleRevokeSelf = /*#__PURE__*/function () {
|
|
@@ -209,7 +193,7 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
|
|
|
209
193
|
case 3:
|
|
210
194
|
setIsSending(true);
|
|
211
195
|
setFrozenDoc(existingDocument);
|
|
212
|
-
setFrozenRecipients(
|
|
196
|
+
setFrozenRecipients(recipients);
|
|
213
197
|
_context2.prev = 6;
|
|
214
198
|
_context2.next = 9;
|
|
215
199
|
return getOrCreateFromArray(client, pendingRecipients, function (contact) {
|
|
@@ -266,44 +250,6 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
|
|
|
266
250
|
};
|
|
267
251
|
}();
|
|
268
252
|
|
|
269
|
-
useEffect(function () {
|
|
270
|
-
if (!sharedParentPath) return;
|
|
271
|
-
|
|
272
|
-
var fetchParentFolder = /*#__PURE__*/function () {
|
|
273
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
274
|
-
var res;
|
|
275
|
-
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
276
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
277
|
-
case 0:
|
|
278
|
-
_context3.prev = 0;
|
|
279
|
-
_context3.next = 3;
|
|
280
|
-
return client.collection('io.cozy.files').statByPath(sharedParentPath);
|
|
281
|
-
|
|
282
|
-
case 3:
|
|
283
|
-
res = _context3.sent;
|
|
284
|
-
if (res.data) setSharedParentFolder(res.data);
|
|
285
|
-
_context3.next = 10;
|
|
286
|
-
break;
|
|
287
|
-
|
|
288
|
-
case 7:
|
|
289
|
-
_context3.prev = 7;
|
|
290
|
-
_context3.t0 = _context3["catch"](0);
|
|
291
|
-
log.error('Failed to fetch shared parent folder', _context3.t0);
|
|
292
|
-
|
|
293
|
-
case 10:
|
|
294
|
-
case "end":
|
|
295
|
-
return _context3.stop();
|
|
296
|
-
}
|
|
297
|
-
}, _callee3, null, [[0, 7]]);
|
|
298
|
-
}));
|
|
299
|
-
|
|
300
|
-
return function fetchParentFolder() {
|
|
301
|
-
return _ref4.apply(this, arguments);
|
|
302
|
-
};
|
|
303
|
-
}();
|
|
304
|
-
|
|
305
|
-
fetchParentFolder();
|
|
306
|
-
}, [sharedParentPath, client]);
|
|
307
253
|
useEffect(function () {
|
|
308
254
|
if (!(existingDocument !== null && existingDocument !== void 0 && existingDocument.driveId)) return;
|
|
309
255
|
if (!documentId) return;
|
|
@@ -313,39 +259,39 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
|
|
|
313
259
|
if (fetchedSharingLinksDocumentId === documentId) return;
|
|
314
260
|
|
|
315
261
|
var fetchSharingLinks = /*#__PURE__*/function () {
|
|
316
|
-
var
|
|
317
|
-
return _regeneratorRuntime.wrap(function
|
|
318
|
-
while (1) switch (
|
|
262
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
263
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
264
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
319
265
|
case 0:
|
|
320
266
|
setIsFetchingSharingLinks(true);
|
|
321
|
-
|
|
322
|
-
|
|
267
|
+
_context3.prev = 1;
|
|
268
|
+
_context3.next = 4;
|
|
323
269
|
return fetchSharedDriveSharingLinks(existingDocument);
|
|
324
270
|
|
|
325
271
|
case 4:
|
|
326
|
-
|
|
272
|
+
_context3.next = 9;
|
|
327
273
|
break;
|
|
328
274
|
|
|
329
275
|
case 6:
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
log.error('Failed to fetch shared drive sharing links',
|
|
276
|
+
_context3.prev = 6;
|
|
277
|
+
_context3.t0 = _context3["catch"](1);
|
|
278
|
+
log.error('Failed to fetch shared drive sharing links', _context3.t0);
|
|
333
279
|
|
|
334
280
|
case 9:
|
|
335
|
-
|
|
281
|
+
_context3.prev = 9;
|
|
336
282
|
setFetchedSharingLinksDocumentId(documentId);
|
|
337
283
|
setIsFetchingSharingLinks(false);
|
|
338
|
-
return
|
|
284
|
+
return _context3.finish(9);
|
|
339
285
|
|
|
340
286
|
case 13:
|
|
341
287
|
case "end":
|
|
342
|
-
return
|
|
288
|
+
return _context3.stop();
|
|
343
289
|
}
|
|
344
|
-
},
|
|
290
|
+
}, _callee3, null, [[1, 6, 9, 13]]);
|
|
345
291
|
}));
|
|
346
292
|
|
|
347
293
|
return function fetchSharingLinks() {
|
|
348
|
-
return
|
|
294
|
+
return _ref4.apply(this, arguments);
|
|
349
295
|
};
|
|
350
296
|
}();
|
|
351
297
|
|
|
@@ -372,15 +318,15 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
|
|
|
372
318
|
className: "u-ph-2"
|
|
373
319
|
}, /*#__PURE__*/React.createElement(AntivirusAlert, {
|
|
374
320
|
document: isSending ? frozenDoc : existingDocument
|
|
375
|
-
}),
|
|
321
|
+
}), isInsideSharedDrive ? /*#__PURE__*/React.createElement("div", {
|
|
376
322
|
className: styles['share-byemail-onlybylink']
|
|
377
323
|
}, t('Files.share.shareByEmail.onlyByLink', {
|
|
378
324
|
type: t("Files.share.shareByEmail.type.".concat((existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument.type) === 'file' ? 'file' : 'folder'))
|
|
379
|
-
}), ' ', /*#__PURE__*/React.createElement("strong", null, t(
|
|
325
|
+
}), ' ', /*#__PURE__*/React.createElement("strong", null, t('Files.share.shareByEmail.hasSharedParent'))) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Typography, {
|
|
380
326
|
variant: "h6",
|
|
381
327
|
className: "u-mt-1-half u-mb-half"
|
|
382
328
|
}, t('Share.contacts.addUsers')), /*#__PURE__*/React.createElement(DumbShareByEmail, {
|
|
383
|
-
currentRecipients: isSending ? frozenRecipients :
|
|
329
|
+
currentRecipients: isSending ? frozenRecipients : recipients,
|
|
384
330
|
document: isSending ? frozenDoc : existingDocument,
|
|
385
331
|
documentType: "Files",
|
|
386
332
|
pendingRecipients: pendingRecipients,
|
|
@@ -394,7 +340,7 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
|
|
|
394
340
|
isSharedDrive: true,
|
|
395
341
|
canManageMembers: !isMemberReadOnly,
|
|
396
342
|
canManageLink: true,
|
|
397
|
-
recipients: isSending ? frozenRecipients :
|
|
343
|
+
recipients: isSending ? frozenRecipients : recipients,
|
|
398
344
|
document: isSending ? frozenDoc : existingDocument,
|
|
399
345
|
documentType: "Files",
|
|
400
346
|
className: styles['share-dialog-members'],
|
|
@@ -408,7 +354,7 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
|
|
|
408
354
|
documentType: "Files",
|
|
409
355
|
showGenerateLinkButton: showGenerateLinkButton,
|
|
410
356
|
autoOpenShareRestriction: autoOpenShareRestriction
|
|
411
|
-
}),
|
|
357
|
+
}), !isInsideSharedDrive && /*#__PURE__*/React.createElement(Button, {
|
|
412
358
|
variant: "primary",
|
|
413
359
|
label: t('FederatedFolder.share'),
|
|
414
360
|
busy: isSending,
|
|
@@ -417,8 +363,41 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
|
|
|
417
363
|
});
|
|
418
364
|
};
|
|
419
365
|
|
|
366
|
+
FederatedFolderModalContent.propTypes = {
|
|
367
|
+
onClose: PropTypes.func.isRequired,
|
|
368
|
+
onRevokeSuccess: PropTypes.func,
|
|
369
|
+
document: PropTypes.object.isRequired,
|
|
370
|
+
recipients: PropTypes.array,
|
|
371
|
+
autoOpenShareRestriction: PropTypes.bool,
|
|
372
|
+
showGenerateLinkButton: PropTypes.bool
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
var FederatedFolderModalWrapper = function FederatedFolderModalWrapper(_ref5) {
|
|
376
|
+
var document = _ref5.document,
|
|
377
|
+
props = _objectWithoutProperties(_ref5, _excluded);
|
|
378
|
+
|
|
379
|
+
var fileId = document._id || document.id;
|
|
380
|
+
|
|
381
|
+
var _useSharingContext2 = useSharingContext(),
|
|
382
|
+
getEffectiveRecipients = _useSharingContext2.getEffectiveRecipients,
|
|
383
|
+
fetchEffectiveRecipients = _useSharingContext2.fetchEffectiveRecipients,
|
|
384
|
+
invalidateEffectiveRecipients = _useSharingContext2.invalidateEffectiveRecipients;
|
|
385
|
+
|
|
386
|
+
useEffect(function () {
|
|
387
|
+
fetchEffectiveRecipients(fileId, document.driveId).catch(log.error);
|
|
388
|
+
return function () {
|
|
389
|
+
invalidateEffectiveRecipients(fileId);
|
|
390
|
+
};
|
|
391
|
+
}, [fileId, document.driveId, fetchEffectiveRecipients, invalidateEffectiveRecipients]);
|
|
392
|
+
var recipients = getEffectiveRecipients(fileId);
|
|
393
|
+
return /*#__PURE__*/React.createElement(FederatedFolderModalContent, _extends({
|
|
394
|
+
document: document,
|
|
395
|
+
recipients: recipients
|
|
396
|
+
}, props));
|
|
397
|
+
};
|
|
398
|
+
|
|
420
399
|
export var FederatedFolderModal = withLocales(function (props) {
|
|
421
|
-
return /*#__PURE__*/React.createElement(ConfirmDialogProvider, null, /*#__PURE__*/React.createElement(
|
|
400
|
+
return /*#__PURE__*/React.createElement(ConfirmDialogProvider, null, /*#__PURE__*/React.createElement(FederatedFolderModalWrapper, props));
|
|
422
401
|
});
|
|
423
402
|
FederatedFolderModal.propTypes = {
|
|
424
403
|
onClose: PropTypes.func.isRequired,
|
|
@@ -22,7 +22,6 @@ var mockIsOwner = jest.fn();
|
|
|
22
22
|
var mockCanReshare = jest.fn();
|
|
23
23
|
var mockGetSharingLink = jest.fn();
|
|
24
24
|
var mockGetFederatedShareLink = jest.fn();
|
|
25
|
-
var mockGetRecipients = jest.fn().mockReturnValue([]);
|
|
26
25
|
var mockGetSharingById = jest.fn();
|
|
27
26
|
var mockHasSharedChild = jest.fn();
|
|
28
27
|
var mockHasSharedParent = jest.fn();
|
|
@@ -30,6 +29,9 @@ var mockFetchSharedDriveSharingLinks = jest.fn();
|
|
|
30
29
|
var mockGetDocumentPermissions = jest.fn().mockReturnValue([]);
|
|
31
30
|
var mockShowAlert = jest.fn();
|
|
32
31
|
var mockOnClose = jest.fn();
|
|
32
|
+
var mockGetEffectiveRecipients = jest.fn(function () {
|
|
33
|
+
return [];
|
|
34
|
+
});
|
|
33
35
|
jest.mock('../../hooks/useSharingContext', function () {
|
|
34
36
|
return {
|
|
35
37
|
useSharingContext: function useSharingContext() {
|
|
@@ -45,14 +47,18 @@ jest.mock('../../hooks/useSharingContext', function () {
|
|
|
45
47
|
getDocumentPermissions: mockGetDocumentPermissions,
|
|
46
48
|
fetchSharedDriveSharingLinks: mockFetchSharedDriveSharingLinks,
|
|
47
49
|
getOwner: jest.fn(),
|
|
48
|
-
getRecipients: mockGetRecipients,
|
|
49
50
|
getSharedParentPath: jest.fn().mockReturnValue(null),
|
|
50
51
|
getSharingById: mockGetSharingById,
|
|
51
52
|
hasSharedChild: mockHasSharedChild,
|
|
52
53
|
hasSharedParent: mockHasSharedParent,
|
|
53
54
|
isOrgSharedDrive: jest.fn(function () {
|
|
54
55
|
return false;
|
|
55
|
-
})
|
|
56
|
+
}),
|
|
57
|
+
getEffectiveRecipients: function getEffectiveRecipients() {
|
|
58
|
+
return mockGetEffectiveRecipients.apply(void 0, arguments);
|
|
59
|
+
},
|
|
60
|
+
fetchEffectiveRecipients: jest.fn().mockResolvedValue(),
|
|
61
|
+
invalidateEffectiveRecipients: jest.fn()
|
|
56
62
|
};
|
|
57
63
|
}
|
|
58
64
|
};
|
|
@@ -140,7 +146,6 @@ describe('FederatedFolderModal', function () {
|
|
|
140
146
|
mockFetchSharedDriveSharingLinks.mockResolvedValue([]);
|
|
141
147
|
mockGetSharingLink.mockReturnValue('https://example.com/share/abc123');
|
|
142
148
|
mockGetFederatedShareLink.mockReturnValue('https://example.com/share/federated-abc123');
|
|
143
|
-
mockGetRecipients.mockReturnValue([]);
|
|
144
149
|
mockGetSharingById.mockReturnValue(null);
|
|
145
150
|
mockHasSharedChild.mockReturnValue(false);
|
|
146
151
|
mockHasSharedParent.mockReturnValue(false);
|
|
@@ -694,7 +699,10 @@ describe('FederatedFolderModal', function () {
|
|
|
694
699
|
instance: 'https://me.mycozy.cloud',
|
|
695
700
|
memberIndex: 1,
|
|
696
701
|
sharingId: 'sharing-id',
|
|
697
|
-
type: 'two-way'
|
|
702
|
+
type: 'two-way',
|
|
703
|
+
status: 'ready',
|
|
704
|
+
name: 'Me',
|
|
705
|
+
email: 'me@test.com'
|
|
698
706
|
};
|
|
699
707
|
it('should call onRevokeSelf and onRevokeSuccess when the current user is revoked', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19() {
|
|
700
708
|
var onRevokeSuccess, _setup16, findByLabelText;
|
|
@@ -703,7 +711,7 @@ describe('FederatedFolderModal', function () {
|
|
|
703
711
|
while (1) switch (_context19.prev = _context19.next) {
|
|
704
712
|
case 0:
|
|
705
713
|
onRevokeSuccess = jest.fn();
|
|
706
|
-
|
|
714
|
+
mockGetEffectiveRecipients.mockReturnValue([currentUserRecipient]);
|
|
707
715
|
_setup16 = setup({
|
|
708
716
|
onRevokeSuccess: onRevokeSuccess
|
|
709
717
|
}), findByLabelText = _setup16.findByLabelText;
|
|
@@ -739,10 +747,13 @@ describe('FederatedFolderModal', function () {
|
|
|
739
747
|
instance: 'https://other.mycozy.cloud',
|
|
740
748
|
memberIndex: 2,
|
|
741
749
|
sharingId: 'sharing-id',
|
|
742
|
-
type: 'two-way'
|
|
750
|
+
type: 'two-way',
|
|
751
|
+
status: 'ready',
|
|
752
|
+
name: 'Other',
|
|
753
|
+
email: 'other@test.com'
|
|
743
754
|
};
|
|
744
755
|
mockCanReshare.mockReturnValue(true);
|
|
745
|
-
|
|
756
|
+
mockGetEffectiveRecipients.mockReturnValue([otherRecipient]);
|
|
746
757
|
_setup17 = setup(), findByLabelText = _setup17.findByLabelText;
|
|
747
758
|
_context20.t0 = fireEvent;
|
|
748
759
|
_context20.next = 7;
|
|
@@ -5,117 +5,30 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
5
5
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
6
6
|
var _excluded = ["showShareByLink", "showGenerateLinkButton", "autoOpenShareRestriction", "documentType", "document", "onShare", "recipients", "sharingDesc", "createContact", "onClose"];
|
|
7
7
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
|
-
import cx from 'classnames';
|
|
9
8
|
import PropTypes from 'prop-types';
|
|
10
9
|
import React, { useCallback, useMemo, useState } from 'react';
|
|
11
10
|
import { useClient } from 'cozy-client';
|
|
12
11
|
import Button from 'cozy-ui/transpiled/react/Buttons';
|
|
13
|
-
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
14
12
|
import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert';
|
|
15
|
-
import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints';
|
|
16
13
|
import { useI18n } from 'twake-i18n';
|
|
17
|
-
import AntivirusAlert from './AntivirusAlert';
|
|
18
|
-
import { default as DumbShareByEmail } from './ShareByEmail';
|
|
19
14
|
import { default as DumbShareByLink } from './ShareByLink';
|
|
20
15
|
import ShareDialogTwoStepsConfirmationContainer from './ShareDialogTwoStepsConfirmationContainer';
|
|
21
16
|
import { ShareRecipientsLimitModal } from './ShareRecipientsLimitModal';
|
|
22
|
-
import
|
|
17
|
+
import SharingContent from './SharingContent';
|
|
23
18
|
import { getOrCreateFromArray } from '../helpers/contacts';
|
|
24
19
|
import { hasReachRecipientsLimit } from '../helpers/recipients';
|
|
25
20
|
import { getErrorMessage, getSuccessMessage } from '../helpers/share';
|
|
26
21
|
import { usePendingRecipients } from '../hooks/usePendingRecipients';
|
|
27
22
|
import { useSharingContext } from '../hooks/useSharingContext';
|
|
28
|
-
var styles = {
|
|
29
|
-
"share-modal-content": "share__share-modal-content___1iqEq",
|
|
30
|
-
"coz-form": "share__coz-form___1ICST",
|
|
31
|
-
"coz-form-group": "share__coz-form-group___VsQp7",
|
|
32
|
-
"coz-form-desc": "share__coz-form-desc___2mYN4",
|
|
33
|
-
"coz-form-label": "share__coz-form-label___bogBw",
|
|
34
|
-
"coz-form-label--error": "share__coz-form-label--error___3YPkf",
|
|
35
|
-
"coz-form-errors": "share__coz-form-errors___2xYRz",
|
|
36
|
-
"coz-form-controls": "share__coz-form-controls___H8kGc",
|
|
37
|
-
"coz-form-controls--full": "share__coz-form-controls--full___1oQXF",
|
|
38
|
-
"coz-form-controls--dispatch": "share__coz-form-controls--dispatch___1zIxt",
|
|
39
|
-
"error": "share__error___pwqPO",
|
|
40
|
-
"share-dialog-scrollable-content": "share__share-dialog-scrollable-content___2Xyoq",
|
|
41
|
-
"share-dialog-scrollable-body": "share__share-dialog-scrollable-body___2O5UT",
|
|
42
|
-
"share-dialog-members": "share__share-dialog-members___CNHKJ",
|
|
43
|
-
"share-byemail-onlybylink": "share__share-byemail-onlybylink___29W-t",
|
|
44
|
-
"aligned-dropdown-button": "share__aligned-dropdown-button___3crgG"
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
var SharingContent = function SharingContent(_ref) {
|
|
48
|
-
var document = _ref.document,
|
|
49
|
-
documentType = _ref.documentType,
|
|
50
|
-
hasSharedParent = _ref.hasSharedParent,
|
|
51
|
-
isOwner = _ref.isOwner,
|
|
52
|
-
onRevoke = _ref.onRevoke,
|
|
53
|
-
onRevokeSelf = _ref.onRevokeSelf,
|
|
54
|
-
recipients = _ref.recipients,
|
|
55
|
-
sharing = _ref.sharing,
|
|
56
|
-
showShareByEmail = _ref.showShareByEmail,
|
|
57
|
-
showShareOnlyByLink = _ref.showShareOnlyByLink,
|
|
58
|
-
showWhoHasAccess = _ref.showWhoHasAccess,
|
|
59
|
-
recipientsToBeConfirmed = _ref.recipientsToBeConfirmed,
|
|
60
|
-
verifyRecipient = _ref.verifyRecipient,
|
|
61
|
-
link = _ref.link,
|
|
62
|
-
permissions = _ref.permissions,
|
|
63
|
-
pendingRecipients = _ref.pendingRecipients,
|
|
64
|
-
onPendingRecipientsChange = _ref.onPendingRecipientsChange,
|
|
65
|
-
selectedOption = _ref.selectedOption,
|
|
66
|
-
onSelectedOptionChange = _ref.onSelectedOptionChange;
|
|
67
|
-
|
|
68
|
-
var _useI18n = useI18n(),
|
|
69
|
-
t = _useI18n.t;
|
|
70
|
-
|
|
71
|
-
var _useBreakpoints = useBreakpoints(),
|
|
72
|
-
isMobile = _useBreakpoints.isMobile;
|
|
73
23
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
className: cx('u-pt-1-half', isMobile ? 'u-ph-1' : 'u-ph-2')
|
|
78
|
-
}, /*#__PURE__*/React.createElement(AntivirusAlert, {
|
|
79
|
-
document: document
|
|
80
|
-
}), showShareOnlyByLink && /*#__PURE__*/React.createElement("div", {
|
|
81
|
-
className: styles['share-byemail-onlybylink']
|
|
82
|
-
}, t("".concat(documentType, ".share.shareByEmail.onlyByLink"), {
|
|
83
|
-
type: t("".concat(documentType, ".share.shareByEmail.type.").concat(document.type === 'directory' ? 'folder' : 'file'))
|
|
84
|
-
}), ' ', /*#__PURE__*/React.createElement("strong", null, t("".concat(documentType, ".share.shareByEmail.").concat(hasSharedParent ? 'hasSharedParent' : 'hasSharedChild')))), /*#__PURE__*/React.createElement(Typography, {
|
|
85
|
-
variant: "h6",
|
|
86
|
-
className: "u-mb-half"
|
|
87
|
-
}, t('Share.contacts.addUsers')), showShareByEmail && /*#__PURE__*/React.createElement(DumbShareByEmail, {
|
|
88
|
-
currentRecipients: recipients,
|
|
89
|
-
document: document,
|
|
90
|
-
documentType: documentType,
|
|
91
|
-
sharing: sharing,
|
|
92
|
-
pendingRecipients: pendingRecipients,
|
|
93
|
-
onPendingRecipientsChange: onPendingRecipientsChange,
|
|
94
|
-
selectedOption: selectedOption,
|
|
95
|
-
onSelectedOptionChange: onSelectedOptionChange,
|
|
96
|
-
enableCreateContact: true
|
|
97
|
-
})), showWhoHasAccess && /*#__PURE__*/React.createElement(WhoHasAccess, {
|
|
98
|
-
document: document,
|
|
99
|
-
documentType: documentType,
|
|
100
|
-
isOwner: isOwner,
|
|
101
|
-
onRevoke: onRevoke,
|
|
102
|
-
onRevokeSelf: onRevokeSelf,
|
|
103
|
-
recipients: recipients,
|
|
104
|
-
recipientsToBeConfirmed: recipientsToBeConfirmed,
|
|
105
|
-
verifyRecipient: verifyRecipient,
|
|
106
|
-
link: link,
|
|
107
|
-
permissions: permissions
|
|
108
|
-
}));
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
var SharingTitleFunction = function SharingTitleFunction(_ref2) {
|
|
112
|
-
var documentType = _ref2.documentType,
|
|
113
|
-
document = _ref2.document;
|
|
24
|
+
var SharingTitleFunction = function SharingTitleFunction(_ref) {
|
|
25
|
+
var documentType = _ref.documentType,
|
|
26
|
+
document = _ref.document;
|
|
114
27
|
return function SharingTitle() {
|
|
115
28
|
var _document$attributes;
|
|
116
29
|
|
|
117
|
-
var
|
|
118
|
-
t =
|
|
30
|
+
var _useI18n = useI18n(),
|
|
31
|
+
t = _useI18n.t;
|
|
119
32
|
|
|
120
33
|
var title = t("".concat(documentType, ".share.title"), {
|
|
121
34
|
name: document.name || ((_document$attributes = document.attributes) === null || _document$attributes === void 0 ? void 0 : _document$attributes.name)
|
|
@@ -124,21 +37,21 @@ var SharingTitleFunction = function SharingTitleFunction(_ref2) {
|
|
|
124
37
|
};
|
|
125
38
|
};
|
|
126
39
|
|
|
127
|
-
var ShareDialogCozyToCozy = function ShareDialogCozyToCozy(
|
|
128
|
-
var showShareByLink =
|
|
129
|
-
showGenerateLinkButton =
|
|
130
|
-
autoOpenShareRestriction =
|
|
131
|
-
documentType =
|
|
132
|
-
document =
|
|
133
|
-
onShare =
|
|
134
|
-
recipients =
|
|
135
|
-
sharingDesc =
|
|
136
|
-
createContact =
|
|
137
|
-
onClose =
|
|
138
|
-
props = _objectWithoutProperties(
|
|
139
|
-
|
|
140
|
-
var
|
|
141
|
-
t =
|
|
40
|
+
var ShareDialogCozyToCozy = function ShareDialogCozyToCozy(_ref2) {
|
|
41
|
+
var showShareByLink = _ref2.showShareByLink,
|
|
42
|
+
showGenerateLinkButton = _ref2.showGenerateLinkButton,
|
|
43
|
+
autoOpenShareRestriction = _ref2.autoOpenShareRestriction,
|
|
44
|
+
documentType = _ref2.documentType,
|
|
45
|
+
document = _ref2.document,
|
|
46
|
+
onShare = _ref2.onShare,
|
|
47
|
+
recipients = _ref2.recipients,
|
|
48
|
+
sharingDesc = _ref2.sharingDesc,
|
|
49
|
+
createContact = _ref2.createContact,
|
|
50
|
+
onClose = _ref2.onClose,
|
|
51
|
+
props = _objectWithoutProperties(_ref2, _excluded);
|
|
52
|
+
|
|
53
|
+
var _useI18n2 = useI18n(),
|
|
54
|
+
t = _useI18n2.t;
|
|
142
55
|
|
|
143
56
|
var client = useClient();
|
|
144
57
|
|