cozy-sharing 4.8.1 → 4.9.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 +23 -0
- package/dist/SharingBanner/components/PublicBanner.js +2 -2
- package/dist/SharingProvider.js +27 -49
- package/dist/components/ShareModal.js +5 -5
- package/dist/components/ShareModal.spec.js +54 -0
- package/package.json +2 -2
- package/src/SharingBanner/components/PublicBanner.jsx +3 -2
- package/src/SharingProvider.jsx +0 -17
- package/src/components/ShareModal.jsx +43 -53
- package/src/components/ShareModal.spec.js +49 -0
- package/dist/SharingBanner/components/getHomeLinkHref.js +0 -5
- package/dist/SharingBanner/components/getHomeLinkHref.spec.js +0 -9
- package/src/SharingBanner/components/getHomeLinkHref.jsx +0 -6
- package/src/SharingBanner/components/getHomeLinkHref.spec.js +0 -14
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,29 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [4.9.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@4.8.2...cozy-sharing@4.9.0) (2022-12-20)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Remove getHomeLinkHref ([57bf707](https://github.com/cozy/cozy-libs/commit/57bf707de15c2db76964c115e50481f1204c1ca1))
|
|
12
|
+
* Remove tracker calls for cozy-sharing ([46728c2](https://github.com/cozy/cozy-libs/commit/46728c259e4bd1a93913d5d30fb3a78b23a2aab4))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## [4.8.2](https://github.com/cozy/cozy-libs/compare/cozy-sharing@4.8.1...cozy-sharing@4.8.2) (2022-12-20)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* Reactive share modal for all apps ([7ff734b](https://github.com/cozy/cozy-libs/commit/7ff734b7506fc74aa3740de6bec7b1f89b21f505))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
6
29
|
## [4.8.1](https://github.com/cozy/cozy-libs/compare/cozy-sharing@4.8.0...cozy-sharing@4.8.1) (2022-12-09)
|
|
7
30
|
|
|
8
31
|
**Note:** Version bump only for package cozy-sharing
|
|
@@ -6,10 +6,10 @@ import Banner from 'cozy-ui/transpiled/react/Banner';
|
|
|
6
6
|
import Button, { ButtonLink } from 'cozy-ui/transpiled/react/Button';
|
|
7
7
|
import { useI18n } from 'cozy-ui/transpiled/react/I18n';
|
|
8
8
|
import CozyHomeLinkIcon from './CozyHomeLinkIcon';
|
|
9
|
-
import getHomeLinkHref from './getHomeLinkHref';
|
|
10
9
|
var styles = {
|
|
11
10
|
"bannermarkdown": "publicBanner__bannermarkdown___1EMSa"
|
|
12
11
|
};
|
|
12
|
+
var HOME_LINK_HREF = 'https://manager.cozycloud.cc/cozy/create';
|
|
13
13
|
|
|
14
14
|
var getPublicNameFromSharing = function getPublicNameFromSharing(sharing) {
|
|
15
15
|
return sharing.attributes.members[0].public_name;
|
|
@@ -129,7 +129,7 @@ var SharingBannerByLink = function SharingBannerByLink(_ref3) {
|
|
|
129
129
|
theme: "text",
|
|
130
130
|
label: t('Share.create-cozy'),
|
|
131
131
|
icon: CozyHomeLinkIcon,
|
|
132
|
-
href:
|
|
132
|
+
href: HOME_LINK_HREF
|
|
133
133
|
}),
|
|
134
134
|
buttonTwo: /*#__PURE__*/React.createElement(Button, {
|
|
135
135
|
theme: "text",
|
package/dist/SharingProvider.js
CHANGED
|
@@ -20,32 +20,11 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
20
20
|
|
|
21
21
|
import React, { Component } from 'react';
|
|
22
22
|
import { withClient } from 'cozy-client';
|
|
23
|
-
import { getTracker } from 'cozy-ui/transpiled/react/helpers/tracker';
|
|
24
23
|
import SharingContext from './context';
|
|
25
24
|
import reducer, { receiveSharings, addSharing, updateSharing, addSharingLink, updateSharingLink, revokeSharingLink, revokeRecipient, revokeSelf, receivePaths, isOwner as _isOwner, canReshare as _canReshare, getOwner as _getOwner, getRecipients as _getRecipients, getSharingById, getSharingDocIds, getSharingForSelf as _getSharingForSelf, getSharingType as _getSharingType, getSharingLink as _getSharingLink, getSharedDocIdsBySharings, getDocumentSharing, getDocumentPermissions as _getDocumentPermissions, hasSharedParent as _hasSharedParent, hasSharedChild as _hasSharedChild } from './state';
|
|
26
25
|
import { fetchNextPermissions } from './fetchNextPermissions';
|
|
27
26
|
import { fetchFilesPaths } from './helpers/files';
|
|
28
27
|
import { getSharingObject, createSharingInStore, updateSharingInStore } from './helpers/sharings';
|
|
29
|
-
|
|
30
|
-
var isFile = function isFile(_ref) {
|
|
31
|
-
var _type = _ref._type;
|
|
32
|
-
return _type === 'io.cozy.files';
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
var track = function track(document, action) {
|
|
36
|
-
var tracker = getTracker();
|
|
37
|
-
|
|
38
|
-
if (!tracker) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
tracker.push(['trackEvent', isFile(document) ? 'Drive' : 'Photos', action, "".concat(action).concat(isFile(document) ? 'File' : 'Album')]);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
var trackSharingByLink = function trackSharingByLink(document) {
|
|
46
|
-
return track(document, 'shareByLink');
|
|
47
|
-
};
|
|
48
|
-
|
|
49
28
|
var SHARING_DOCTYPE = 'io.cozy.sharings';
|
|
50
29
|
var PERMISSION_DOCTYPE = 'io.cozy.permissions';
|
|
51
30
|
export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
@@ -87,7 +66,7 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
87
66
|
});
|
|
88
67
|
|
|
89
68
|
_defineProperty(_assertThisInitialized(_this), "handleCreateOrUpdateSharings", /*#__PURE__*/function () {
|
|
90
|
-
var
|
|
69
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(sharing) {
|
|
91
70
|
var _this$props, client, doctype, internalSharing, newSharing, docsId;
|
|
92
71
|
|
|
93
72
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
@@ -114,12 +93,12 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
114
93
|
}));
|
|
115
94
|
|
|
116
95
|
return function (_x) {
|
|
117
|
-
return
|
|
96
|
+
return _ref.apply(this, arguments);
|
|
118
97
|
};
|
|
119
98
|
}());
|
|
120
99
|
|
|
121
100
|
_defineProperty(_assertThisInitialized(_this), "share", /*#__PURE__*/function () {
|
|
122
|
-
var
|
|
101
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref2) {
|
|
123
102
|
var _this$props$previewPa;
|
|
124
103
|
|
|
125
104
|
var document, recipients, readOnlyRecipients, description, openSharing, _this$props2, client, doctype, sharing, sharingResult, previewPath, _yield$_this$sharingC, data;
|
|
@@ -128,7 +107,7 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
128
107
|
while (1) {
|
|
129
108
|
switch (_context2.prev = _context2.next) {
|
|
130
109
|
case 0:
|
|
131
|
-
document =
|
|
110
|
+
document = _ref2.document, recipients = _ref2.recipients, readOnlyRecipients = _ref2.readOnlyRecipients, description = _ref2.description, openSharing = _ref2.openSharing;
|
|
132
111
|
_this$props2 = _this.props, client = _this$props2.client, doctype = _this$props2.doctype;
|
|
133
112
|
sharing = getDocumentSharing(_this.state, document.id);
|
|
134
113
|
|
|
@@ -212,18 +191,18 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
212
191
|
}));
|
|
213
192
|
|
|
214
193
|
return function (_x2) {
|
|
215
|
-
return
|
|
194
|
+
return _ref3.apply(this, arguments);
|
|
216
195
|
};
|
|
217
196
|
}());
|
|
218
197
|
|
|
219
198
|
_defineProperty(_assertThisInitialized(_this), "addRecipients", /*#__PURE__*/function () {
|
|
220
|
-
var
|
|
199
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref4) {
|
|
221
200
|
var document, recipients, readOnlyRecipients, resp;
|
|
222
201
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
223
202
|
while (1) {
|
|
224
203
|
switch (_context3.prev = _context3.next) {
|
|
225
204
|
case 0:
|
|
226
|
-
document =
|
|
205
|
+
document = _ref4.document, recipients = _ref4.recipients, readOnlyRecipients = _ref4.readOnlyRecipients;
|
|
227
206
|
_context3.next = 3;
|
|
228
207
|
return _this.sharingCol.addRecipients({
|
|
229
208
|
document: document,
|
|
@@ -245,12 +224,12 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
245
224
|
}));
|
|
246
225
|
|
|
247
226
|
return function (_x3) {
|
|
248
|
-
return
|
|
227
|
+
return _ref5.apply(this, arguments);
|
|
249
228
|
};
|
|
250
229
|
}());
|
|
251
230
|
|
|
252
231
|
_defineProperty(_assertThisInitialized(_this), "revokeAllRecipients", /*#__PURE__*/function () {
|
|
253
|
-
var
|
|
232
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(document) {
|
|
254
233
|
var _this$props3, client, doctype, recipients, sharing;
|
|
255
234
|
|
|
256
235
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
@@ -265,7 +244,7 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
265
244
|
|
|
266
245
|
case 5:
|
|
267
246
|
recipients.map( /*#__PURE__*/function () {
|
|
268
|
-
var
|
|
247
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(recipient, recipientIndex) {
|
|
269
248
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
270
249
|
while (1) {
|
|
271
250
|
switch (_context4.prev = _context4.next) {
|
|
@@ -302,7 +281,7 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
302
281
|
}));
|
|
303
282
|
|
|
304
283
|
return function (_x5, _x6) {
|
|
305
|
-
return
|
|
284
|
+
return _ref7.apply(this, arguments);
|
|
306
285
|
};
|
|
307
286
|
}());
|
|
308
287
|
|
|
@@ -315,12 +294,12 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
315
294
|
}));
|
|
316
295
|
|
|
317
296
|
return function (_x4) {
|
|
318
|
-
return
|
|
297
|
+
return _ref6.apply(this, arguments);
|
|
319
298
|
};
|
|
320
299
|
}());
|
|
321
300
|
|
|
322
301
|
_defineProperty(_assertThisInitialized(_this), "revoke", /*#__PURE__*/function () {
|
|
323
|
-
var
|
|
302
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(document, sharingId, recipientIndex) {
|
|
324
303
|
var _this$props4, client, doctype, sharing;
|
|
325
304
|
|
|
326
305
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
@@ -365,12 +344,12 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
365
344
|
}));
|
|
366
345
|
|
|
367
346
|
return function (_x7, _x8, _x9) {
|
|
368
|
-
return
|
|
347
|
+
return _ref8.apply(this, arguments);
|
|
369
348
|
};
|
|
370
349
|
}());
|
|
371
350
|
|
|
372
351
|
_defineProperty(_assertThisInitialized(_this), "revokeSelf", /*#__PURE__*/function () {
|
|
373
|
-
var
|
|
352
|
+
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(document) {
|
|
374
353
|
var sharing;
|
|
375
354
|
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
376
355
|
while (1) {
|
|
@@ -392,29 +371,28 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
392
371
|
}));
|
|
393
372
|
|
|
394
373
|
return function (_x10) {
|
|
395
|
-
return
|
|
374
|
+
return _ref9.apply(this, arguments);
|
|
396
375
|
};
|
|
397
376
|
}());
|
|
398
377
|
|
|
399
378
|
_defineProperty(_assertThisInitialized(_this), "shareByLink", /*#__PURE__*/function () {
|
|
400
|
-
var
|
|
379
|
+
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(document) {
|
|
401
380
|
var resp;
|
|
402
381
|
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
403
382
|
while (1) {
|
|
404
383
|
switch (_context8.prev = _context8.next) {
|
|
405
384
|
case 0:
|
|
406
|
-
|
|
407
|
-
_context8.next = 3;
|
|
385
|
+
_context8.next = 2;
|
|
408
386
|
return _this.permissionCol.createSharingLink(document);
|
|
409
387
|
|
|
410
|
-
case
|
|
388
|
+
case 2:
|
|
411
389
|
resp = _context8.sent;
|
|
412
390
|
|
|
413
391
|
_this.dispatch(addSharingLink(resp.data));
|
|
414
392
|
|
|
415
393
|
return _context8.abrupt("return", resp);
|
|
416
394
|
|
|
417
|
-
case
|
|
395
|
+
case 5:
|
|
418
396
|
case "end":
|
|
419
397
|
return _context8.stop();
|
|
420
398
|
}
|
|
@@ -423,12 +401,12 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
423
401
|
}));
|
|
424
402
|
|
|
425
403
|
return function (_x11) {
|
|
426
|
-
return
|
|
404
|
+
return _ref10.apply(this, arguments);
|
|
427
405
|
};
|
|
428
406
|
}());
|
|
429
407
|
|
|
430
408
|
_defineProperty(_assertThisInitialized(_this), "updateDocumentPermissions", /*#__PURE__*/function () {
|
|
431
|
-
var
|
|
409
|
+
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(document, newVerbs) {
|
|
432
410
|
var permissions, responses;
|
|
433
411
|
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
434
412
|
while (1) {
|
|
@@ -437,7 +415,7 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
437
415
|
permissions = _getDocumentPermissions(_this.state, document.id);
|
|
438
416
|
_context10.next = 3;
|
|
439
417
|
return Promise.all(permissions.map( /*#__PURE__*/function () {
|
|
440
|
-
var
|
|
418
|
+
var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(permissionDocument) {
|
|
441
419
|
var updatedPermissions, resp;
|
|
442
420
|
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
443
421
|
while (1) {
|
|
@@ -466,7 +444,7 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
466
444
|
}));
|
|
467
445
|
|
|
468
446
|
return function (_x14) {
|
|
469
|
-
return
|
|
447
|
+
return _ref12.apply(this, arguments);
|
|
470
448
|
};
|
|
471
449
|
}()));
|
|
472
450
|
|
|
@@ -483,12 +461,12 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
483
461
|
}));
|
|
484
462
|
|
|
485
463
|
return function (_x12, _x13) {
|
|
486
|
-
return
|
|
464
|
+
return _ref11.apply(this, arguments);
|
|
487
465
|
};
|
|
488
466
|
}());
|
|
489
467
|
|
|
490
468
|
_defineProperty(_assertThisInitialized(_this), "revokeSharingLink", /*#__PURE__*/function () {
|
|
491
|
-
var
|
|
469
|
+
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(document) {
|
|
492
470
|
var perms;
|
|
493
471
|
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
494
472
|
while (1) {
|
|
@@ -514,7 +492,7 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
514
492
|
}));
|
|
515
493
|
|
|
516
494
|
return function (_x15) {
|
|
517
|
-
return
|
|
495
|
+
return _ref13.apply(this, arguments);
|
|
518
496
|
};
|
|
519
497
|
}());
|
|
520
498
|
|
|
@@ -28,12 +28,12 @@ export var ShareModal = function ShareModal(_ref) {
|
|
|
28
28
|
sharing = _ref.sharing,
|
|
29
29
|
sharingDesc = _ref.sharingDesc,
|
|
30
30
|
twoStepsConfirmationMethods = _ref.twoStepsConfirmationMethods;
|
|
31
|
-
var
|
|
32
|
-
var showShareByEmail =
|
|
31
|
+
var shareDialogOnlyByLink = documentType === 'Notes' && !flag('notes.sharing-cozy-to-cozy') || documentType === 'Albums';
|
|
32
|
+
var showShareByEmail = !hasSharedParent && !hasSharedChild;
|
|
33
33
|
var showShareByLink = documentType !== 'Organizations';
|
|
34
34
|
var showShareOnlyByLink = hasSharedParent || hasSharedChild;
|
|
35
35
|
var showWhoHasAccess = documentType !== 'Albums';
|
|
36
|
-
return
|
|
36
|
+
return shareDialogOnlyByLink ? /*#__PURE__*/React.createElement(ShareDialogOnlyByLink, {
|
|
37
37
|
document: document,
|
|
38
38
|
documentType: documentType,
|
|
39
39
|
link: link,
|
|
@@ -42,7 +42,7 @@ export var ShareModal = function ShareModal(_ref) {
|
|
|
42
42
|
onShareByLink: onShareByLink,
|
|
43
43
|
onUpdateShareLinkPermissions: onUpdateShareLinkPermissions,
|
|
44
44
|
permissions: permissions
|
|
45
|
-
})
|
|
45
|
+
}) : /*#__PURE__*/React.createElement(ShareDialogCozyToCozy, {
|
|
46
46
|
contacts: contacts,
|
|
47
47
|
createContact: createContact,
|
|
48
48
|
document: document,
|
|
@@ -68,7 +68,7 @@ export var ShareModal = function ShareModal(_ref) {
|
|
|
68
68
|
showShareOnlyByLink: showShareOnlyByLink,
|
|
69
69
|
showWhoHasAccess: showWhoHasAccess,
|
|
70
70
|
twoStepsConfirmationMethods: twoStepsConfirmationMethods
|
|
71
|
-
})
|
|
71
|
+
});
|
|
72
72
|
};
|
|
73
73
|
export default ShareModal;
|
|
74
74
|
ShareModal.propTypes = {
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import { ShareModal } from './ShareModal';
|
|
4
|
+
import AppLike from '../../test/AppLike';
|
|
5
|
+
import flag from 'cozy-flags';
|
|
6
|
+
jest.mock('./ShareDialogCozyToCozy', function () {
|
|
7
|
+
return function () {
|
|
8
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, "ShareDialogCozyToCozy");
|
|
9
|
+
};
|
|
10
|
+
});
|
|
11
|
+
jest.mock('./ShareDialogOnlyByLink', function () {
|
|
12
|
+
return function () {
|
|
13
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, "ShareDialogOnlyByLink");
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
jest.mock('cozy-flags');
|
|
17
|
+
describe('ShareModal component', function () {
|
|
18
|
+
var setup = function setup(props) {
|
|
19
|
+
return render( /*#__PURE__*/React.createElement(AppLike, null, /*#__PURE__*/React.createElement(ShareModal, props)));
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
beforeEach(function () {
|
|
23
|
+
flag.mockImplementation(function () {
|
|
24
|
+
return null;
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
it('should render ShareDialogCozyToCozy if type is Document', function () {
|
|
28
|
+
var root = setup({
|
|
29
|
+
documentType: 'Document'
|
|
30
|
+
});
|
|
31
|
+
expect(root.getByText('ShareDialogCozyToCozy'));
|
|
32
|
+
});
|
|
33
|
+
it('should render ShareDialogOnlyByLink if type is Albums', function () {
|
|
34
|
+
var root = setup({
|
|
35
|
+
documentType: 'Albums'
|
|
36
|
+
});
|
|
37
|
+
expect(root.getByText('ShareDialogOnlyByLink'));
|
|
38
|
+
});
|
|
39
|
+
it('should render ShareDialogCozyToCozy if type is Notes and notes.sharing-cozy-to-cozy flag enabled', function () {
|
|
40
|
+
flag.mockImplementation(function () {
|
|
41
|
+
return true;
|
|
42
|
+
});
|
|
43
|
+
var root = setup({
|
|
44
|
+
documentType: 'Notes'
|
|
45
|
+
});
|
|
46
|
+
expect(root.getByText('ShareDialogCozyToCozy'));
|
|
47
|
+
});
|
|
48
|
+
it('should render ShareDialogOnlyByLink if type is Notes and notes.sharing-cozy-to-cozy flag disabled', function () {
|
|
49
|
+
var root = setup({
|
|
50
|
+
documentType: 'Notes'
|
|
51
|
+
});
|
|
52
|
+
expect(root.getByText('ShareDialogOnlyByLink'));
|
|
53
|
+
});
|
|
54
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-sharing",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.9.0",
|
|
4
4
|
"description": "Provides sharing login for React applications.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "Cozy",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"sideEffects": [
|
|
62
62
|
"*.css"
|
|
63
63
|
],
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "b6086a71114cba6b924c52736614ed8d99f130ca"
|
|
65
65
|
}
|
|
@@ -8,10 +8,11 @@ import Button, { ButtonLink } from 'cozy-ui/transpiled/react/Button'
|
|
|
8
8
|
import { useI18n } from 'cozy-ui/transpiled/react/I18n'
|
|
9
9
|
|
|
10
10
|
import CozyHomeLinkIcon from './CozyHomeLinkIcon'
|
|
11
|
-
import getHomeLinkHref from './getHomeLinkHref'
|
|
12
11
|
|
|
13
12
|
import styles from './publicBanner.styl'
|
|
14
13
|
|
|
14
|
+
const HOME_LINK_HREF = 'https://manager.cozycloud.cc/cozy/create'
|
|
15
|
+
|
|
15
16
|
const getPublicNameFromSharing = sharing =>
|
|
16
17
|
sharing.attributes.members[0].public_name
|
|
17
18
|
|
|
@@ -146,7 +147,7 @@ const SharingBannerByLink = ({ onClose }) => {
|
|
|
146
147
|
theme="text"
|
|
147
148
|
label={t('Share.create-cozy')}
|
|
148
149
|
icon={CozyHomeLinkIcon}
|
|
149
|
-
href={
|
|
150
|
+
href={HOME_LINK_HREF}
|
|
150
151
|
/>
|
|
151
152
|
}
|
|
152
153
|
buttonTwo={
|
package/src/SharingProvider.jsx
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { Component } from 'react'
|
|
2
2
|
|
|
3
3
|
import { withClient } from 'cozy-client'
|
|
4
|
-
import { getTracker } from 'cozy-ui/transpiled/react/helpers/tracker'
|
|
5
4
|
|
|
6
5
|
import SharingContext from './context'
|
|
7
6
|
import reducer, {
|
|
@@ -37,21 +36,6 @@ import {
|
|
|
37
36
|
updateSharingInStore
|
|
38
37
|
} from './helpers/sharings'
|
|
39
38
|
|
|
40
|
-
const isFile = ({ _type }) => _type === 'io.cozy.files'
|
|
41
|
-
const track = (document, action) => {
|
|
42
|
-
const tracker = getTracker()
|
|
43
|
-
if (!tracker) {
|
|
44
|
-
return
|
|
45
|
-
}
|
|
46
|
-
tracker.push([
|
|
47
|
-
'trackEvent',
|
|
48
|
-
isFile(document) ? 'Drive' : 'Photos',
|
|
49
|
-
action,
|
|
50
|
-
`${action}${isFile(document) ? 'File' : 'Album'}`
|
|
51
|
-
])
|
|
52
|
-
}
|
|
53
|
-
const trackSharingByLink = document => track(document, 'shareByLink')
|
|
54
|
-
|
|
55
39
|
const SHARING_DOCTYPE = 'io.cozy.sharings'
|
|
56
40
|
const PERMISSION_DOCTYPE = 'io.cozy.permissions'
|
|
57
41
|
|
|
@@ -295,7 +279,6 @@ export class SharingProvider extends Component {
|
|
|
295
279
|
}
|
|
296
280
|
|
|
297
281
|
shareByLink = async document => {
|
|
298
|
-
trackSharingByLink(document)
|
|
299
282
|
const resp = await this.permissionCol.createSharingLink(document)
|
|
300
283
|
this.dispatch(addSharingLink(resp.data))
|
|
301
284
|
return resp
|
|
@@ -30,64 +30,54 @@ export const ShareModal = ({
|
|
|
30
30
|
sharingDesc,
|
|
31
31
|
twoStepsConfirmationMethods
|
|
32
32
|
}) => {
|
|
33
|
-
const
|
|
34
|
-
flag('notes.sharing-cozy-to-cozy')
|
|
35
|
-
|
|
36
|
-
documentType === 'Notes'
|
|
33
|
+
const shareDialogOnlyByLink =
|
|
34
|
+
(documentType === 'Notes' && !flag('notes.sharing-cozy-to-cozy')) ||
|
|
35
|
+
documentType === 'Albums'
|
|
37
36
|
|
|
38
|
-
const showShareByEmail =
|
|
39
|
-
showShareCozyToCozyForNotes &&
|
|
40
|
-
documentType !== 'Albums' &&
|
|
41
|
-
!hasSharedParent &&
|
|
42
|
-
!hasSharedChild
|
|
37
|
+
const showShareByEmail = !hasSharedParent && !hasSharedChild
|
|
43
38
|
const showShareByLink = documentType !== 'Organizations'
|
|
44
39
|
const showShareOnlyByLink = hasSharedParent || hasSharedChild
|
|
45
40
|
const showWhoHasAccess = documentType !== 'Albums'
|
|
46
41
|
|
|
47
|
-
return (
|
|
48
|
-
|
|
49
|
-
{
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
showWhoHasAccess={showWhoHasAccess}
|
|
87
|
-
twoStepsConfirmationMethods={twoStepsConfirmationMethods}
|
|
88
|
-
/>
|
|
89
|
-
)}
|
|
90
|
-
</>
|
|
42
|
+
return shareDialogOnlyByLink ? (
|
|
43
|
+
<ShareDialogOnlyByLink
|
|
44
|
+
document={document}
|
|
45
|
+
documentType={documentType}
|
|
46
|
+
link={link}
|
|
47
|
+
onClose={onClose}
|
|
48
|
+
onRevokeLink={onRevokeLink}
|
|
49
|
+
onShareByLink={onShareByLink}
|
|
50
|
+
onUpdateShareLinkPermissions={onUpdateShareLinkPermissions}
|
|
51
|
+
permissions={permissions}
|
|
52
|
+
/>
|
|
53
|
+
) : (
|
|
54
|
+
<ShareDialogCozyToCozy
|
|
55
|
+
contacts={contacts}
|
|
56
|
+
createContact={createContact}
|
|
57
|
+
document={document}
|
|
58
|
+
documentType={documentType}
|
|
59
|
+
groups={groups}
|
|
60
|
+
hasSharedParent={hasSharedParent}
|
|
61
|
+
isOwner={isOwner}
|
|
62
|
+
link={link}
|
|
63
|
+
needsContactsPermission={needsContactsPermission}
|
|
64
|
+
onClose={onClose}
|
|
65
|
+
onRevoke={onRevoke}
|
|
66
|
+
onRevokeLink={onRevokeLink}
|
|
67
|
+
onRevokeSelf={onRevokeSelf}
|
|
68
|
+
onShare={onShare}
|
|
69
|
+
onShareByLink={onShareByLink}
|
|
70
|
+
onUpdateShareLinkPermissions={onUpdateShareLinkPermissions}
|
|
71
|
+
permissions={permissions}
|
|
72
|
+
recipients={recipients}
|
|
73
|
+
sharing={sharing}
|
|
74
|
+
sharingDesc={sharingDesc}
|
|
75
|
+
showShareByEmail={showShareByEmail}
|
|
76
|
+
showShareByLink={showShareByLink}
|
|
77
|
+
showShareOnlyByLink={showShareOnlyByLink}
|
|
78
|
+
showWhoHasAccess={showWhoHasAccess}
|
|
79
|
+
twoStepsConfirmationMethods={twoStepsConfirmationMethods}
|
|
80
|
+
/>
|
|
91
81
|
)
|
|
92
82
|
}
|
|
93
83
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { render } from '@testing-library/react'
|
|
3
|
+
import { ShareModal } from './ShareModal'
|
|
4
|
+
import AppLike from '../../test/AppLike'
|
|
5
|
+
import flag from 'cozy-flags'
|
|
6
|
+
|
|
7
|
+
jest.mock('./ShareDialogCozyToCozy', () => () => <>ShareDialogCozyToCozy</>)
|
|
8
|
+
jest.mock('./ShareDialogOnlyByLink', () => () => <>ShareDialogOnlyByLink</>)
|
|
9
|
+
|
|
10
|
+
jest.mock('cozy-flags')
|
|
11
|
+
|
|
12
|
+
describe('ShareModal component', () => {
|
|
13
|
+
const setup = props => {
|
|
14
|
+
return render(
|
|
15
|
+
<AppLike>
|
|
16
|
+
<ShareModal {...props} />
|
|
17
|
+
</AppLike>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
flag.mockImplementation(() => null)
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('should render ShareDialogCozyToCozy if type is Document', () => {
|
|
26
|
+
const root = setup({ documentType: 'Document' })
|
|
27
|
+
|
|
28
|
+
expect(root.getByText('ShareDialogCozyToCozy'))
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('should render ShareDialogOnlyByLink if type is Albums', () => {
|
|
32
|
+
const root = setup({ documentType: 'Albums' })
|
|
33
|
+
|
|
34
|
+
expect(root.getByText('ShareDialogOnlyByLink'))
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
it('should render ShareDialogCozyToCozy if type is Notes and notes.sharing-cozy-to-cozy flag enabled', () => {
|
|
38
|
+
flag.mockImplementation(() => true)
|
|
39
|
+
const root = setup({ documentType: 'Notes' })
|
|
40
|
+
|
|
41
|
+
expect(root.getByText('ShareDialogCozyToCozy'))
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it('should render ShareDialogOnlyByLink if type is Notes and notes.sharing-cozy-to-cozy flag disabled', () => {
|
|
45
|
+
const root = setup({ documentType: 'Notes' })
|
|
46
|
+
|
|
47
|
+
expect(root.getByText('ShareDialogOnlyByLink'))
|
|
48
|
+
})
|
|
49
|
+
})
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import getHomeLinkHref from './getHomeLinkHref';
|
|
2
|
-
describe('getHomeLinkHref', function () {
|
|
3
|
-
it('Should add the origin parameter', function () {
|
|
4
|
-
expect(getHomeLinkHref('cozy.io')).toEqual('https://manager.cozycloud.cc/cozy/create?pk_campaign=cozy.io&pk_kwd=cozy');
|
|
5
|
-
});
|
|
6
|
-
it('Should not add the origin parameter', function () {
|
|
7
|
-
expect(getHomeLinkHref('')).toEqual('https://manager.cozycloud.cc/cozy/create?&pk_kwd=cozy');
|
|
8
|
-
});
|
|
9
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import getHomeLinkHref from './getHomeLinkHref'
|
|
2
|
-
|
|
3
|
-
describe('getHomeLinkHref', () => {
|
|
4
|
-
it('Should add the origin parameter', () => {
|
|
5
|
-
expect(getHomeLinkHref('cozy.io')).toEqual(
|
|
6
|
-
'https://manager.cozycloud.cc/cozy/create?pk_campaign=cozy.io&pk_kwd=cozy'
|
|
7
|
-
)
|
|
8
|
-
})
|
|
9
|
-
it('Should not add the origin parameter', () => {
|
|
10
|
-
expect(getHomeLinkHref('')).toEqual(
|
|
11
|
-
'https://manager.cozycloud.cc/cozy/create?&pk_kwd=cozy'
|
|
12
|
-
)
|
|
13
|
-
})
|
|
14
|
-
})
|