cozy-sharing 5.0.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/dist/SharedRecipients.js +1 -1
  3. package/dist/SharedStatus.js +1 -1
  4. package/dist/SharingBanner/hooks/useSharingInfos.js +1 -1
  5. package/dist/SharingDetailsModal.js +1 -1
  6. package/dist/SharingOwnerAvatar.js +1 -1
  7. package/dist/SharingProvider.js +21 -8
  8. package/dist/components/ContactSuggestion.js +15 -27
  9. package/dist/components/EditLinkPermissionDialog.js +72 -0
  10. package/dist/components/EditLinkPermissionDialog.spec.js +48 -0
  11. package/dist/components/EditableSharingModal.js +15 -62
  12. package/dist/components/{AvatarPlusX.js → Recipient/AvatarPlusX.js} +1 -1
  13. package/dist/components/{Identity.js → Recipient/Identity.js} +17 -16
  14. package/dist/components/Recipient/LinkRecipient.js +72 -0
  15. package/dist/components/Recipient/LinkRecipientPermissions.js +159 -0
  16. package/dist/components/Recipient/OwnerIdentity.js +44 -0
  17. package/dist/components/Recipient/Recipient.js +72 -0
  18. package/dist/components/{Recipient.spec.js → Recipient/Recipient.spec.js} +4 -45
  19. package/dist/components/Recipient/RecipientAvatar.js +33 -0
  20. package/dist/components/Recipient/RecipientConfirm.js +63 -0
  21. package/dist/components/Recipient/RecipientPermissions.js +126 -0
  22. package/dist/components/Recipient/RecipientPlusX.js +45 -0
  23. package/dist/components/Recipient/RecipientStatus.js +64 -0
  24. package/dist/components/Recipient/RecipientWithoutStatus.js +45 -0
  25. package/dist/components/Recipient/RecipientsAvatars.js +100 -0
  26. package/dist/components/{RecipientsAvatars.spec.js → Recipient/RecipientsAvatars.spec.js} +43 -2
  27. package/dist/components/{recipient.styl → Recipient/recipient.styl} +6 -2
  28. package/dist/components/ShareAutosuggest.js +176 -252
  29. package/dist/components/ShareAutosuggest.spec.js +3 -2
  30. package/dist/components/ShareByEmail.js +142 -193
  31. package/dist/components/ShareByEmail.spec.js +42 -23
  32. package/dist/components/ShareByLink.js +251 -357
  33. package/dist/components/ShareDialogCozyToCozy.js +16 -4
  34. package/dist/components/ShareDialogCozyToCozy.spec.js +12 -1
  35. package/dist/components/ShareDialogOnlyByLink.js +23 -10
  36. package/dist/components/ShareDialogTwoStepsConfirmationContainer.js +7 -7
  37. package/dist/components/ShareModal.js +5 -1
  38. package/dist/components/ShareRecipientsInput.js +44 -128
  39. package/dist/components/WhoHasAccess.js +43 -5
  40. package/dist/components/WhoHasAccessLight.js +3 -19
  41. package/dist/components/autosuggest.styl +21 -36
  42. package/dist/helpers/documentType.js +6 -0
  43. package/dist/helpers/hooks.js +8 -1
  44. package/dist/helpers/link.js +5 -0
  45. package/dist/helpers/permissions.js +8 -0
  46. package/dist/helpers/recipients.js +24 -0
  47. package/dist/helpers/sharings.js +72 -53
  48. package/dist/helpers/synchronousJobQueue.js +67 -0
  49. package/dist/helpers/synchronousJobQueue.spec.js +97 -0
  50. package/dist/index.js +2 -1
  51. package/dist/queries/queries.js +72 -0
  52. package/dist/share.styl +0 -15
  53. package/dist/stylesheet.css +67 -92
  54. package/locales/en.json +29 -41
  55. package/locales/fr.json +26 -39
  56. package/package.json +10 -10
  57. package/src/SharedRecipients.jsx +1 -1
  58. package/src/SharedStatus.jsx +1 -1
  59. package/src/SharingBanner/hooks/useSharingInfos.jsx +1 -1
  60. package/src/SharingDetailsModal.jsx +1 -1
  61. package/src/SharingOwnerAvatar.jsx +1 -1
  62. package/src/SharingProvider.jsx +17 -4
  63. package/src/components/ContactSuggestion.jsx +25 -10
  64. package/src/components/EditLinkPermissionDialog.jsx +89 -0
  65. package/src/components/EditLinkPermissionDialog.spec.jsx +52 -0
  66. package/src/components/EditableSharingModal.jsx +58 -100
  67. package/src/components/{AvatarPlusX.jsx → Recipient/AvatarPlusX.jsx} +1 -1
  68. package/src/components/{Identity.jsx → Recipient/Identity.jsx} +0 -0
  69. package/src/components/Recipient/LinkRecipient.jsx +59 -0
  70. package/src/components/Recipient/LinkRecipientPermissions.jsx +157 -0
  71. package/src/components/Recipient/OwnerIdentity.jsx +20 -0
  72. package/src/components/Recipient/Recipient.jsx +79 -0
  73. package/src/components/{Recipient.spec.jsx → Recipient/Recipient.spec.jsx} +4 -42
  74. package/src/components/Recipient/RecipientAvatar.jsx +38 -0
  75. package/src/components/Recipient/RecipientConfirm.jsx +37 -0
  76. package/src/components/Recipient/RecipientPermissions.jsx +114 -0
  77. package/src/components/Recipient/RecipientPlusX.jsx +28 -0
  78. package/src/components/Recipient/RecipientStatus.jsx +48 -0
  79. package/src/components/Recipient/RecipientWithoutStatus.jsx +21 -0
  80. package/src/components/Recipient/RecipientsAvatars.jsx +108 -0
  81. package/src/components/{RecipientsAvatars.spec.jsx → Recipient/RecipientsAvatars.spec.jsx} +43 -2
  82. package/src/components/{recipient.styl → Recipient/recipient.styl} +6 -2
  83. package/src/components/ShareAutosuggest.jsx +136 -127
  84. package/src/components/ShareAutosuggest.spec.jsx +12 -8
  85. package/src/components/ShareByEmail.jsx +65 -90
  86. package/src/components/ShareByEmail.spec.jsx +39 -11
  87. package/src/components/ShareByLink.jsx +146 -238
  88. package/src/components/ShareDialogCozyToCozy.jsx +14 -2
  89. package/src/components/ShareDialogCozyToCozy.spec.jsx +8 -1
  90. package/src/components/ShareDialogOnlyByLink.jsx +30 -13
  91. package/src/components/ShareDialogTwoStepsConfirmationContainer.jsx +5 -5
  92. package/src/components/ShareModal.jsx +5 -1
  93. package/src/components/ShareRecipientsInput.jsx +30 -44
  94. package/src/components/WhoHasAccess.jsx +85 -27
  95. package/src/components/WhoHasAccessLight.jsx +2 -1
  96. package/src/components/__snapshots__/ContactSuggestion.spec.jsx.snap +915 -132
  97. package/src/components/__snapshots__/ShareRecipientsInput.spec.jsx.snap +86 -102
  98. package/src/components/autosuggest.styl +21 -36
  99. package/src/helpers/documentType.js +6 -0
  100. package/src/helpers/hooks.js +11 -1
  101. package/src/helpers/link.js +4 -0
  102. package/src/helpers/permissions.js +15 -0
  103. package/src/helpers/recipients.js +21 -0
  104. package/src/helpers/sharings.js +15 -12
  105. package/src/helpers/synchronousJobQueue.js +22 -0
  106. package/src/helpers/synchronousJobQueue.spec.js +75 -0
  107. package/src/index.jsx +1 -0
  108. package/src/queries/queries.js +75 -0
  109. package/src/share.styl +0 -15
  110. package/dist/SharingBanner/helpers/queries.js +0 -12
  111. package/dist/components/ContactsAndGroupsDataLoader.js +0 -50
  112. package/dist/components/Recipient.js +0 -450
  113. package/src/SharingBanner/helpers/queries.js +0 -14
  114. package/src/components/ContactsAndGroupsDataLoader.jsx +0 -30
  115. package/src/components/Recipient.jsx +0 -415
@@ -11,73 +11,92 @@ export var getSharingObject = function getSharingObject(internalSharing, sharing
11
11
  return normalizeDocFromRealtime(sharing, 'io.cozy.sharings');
12
12
  }
13
13
  };
14
- export var createSharingInStore = function createSharingInStore(client, doctype, dispatch, docsId, sharing) {
15
- // TODO Check if we can getByIds to avoid query in map
16
- docsId.map( /*#__PURE__*/function () {
17
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(id) {
18
- var file, path;
19
- return _regeneratorRuntime.wrap(function _callee$(_context) {
20
- while (1) {
21
- switch (_context.prev = _context.next) {
22
- case 0:
23
- if (!(doctype === 'io.cozy.files')) {
24
- _context.next = 6;
25
- break;
26
- }
14
+ export var createSharingInStore = /*#__PURE__*/function () {
15
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref) {
16
+ var client, doctype, dispatch, docsId, sharing;
17
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
18
+ while (1) {
19
+ switch (_context2.prev = _context2.next) {
20
+ case 0:
21
+ client = _ref.client, doctype = _ref.doctype, dispatch = _ref.dispatch, docsId = _ref.docsId, sharing = _ref.sharing;
22
+ _context2.next = 3;
23
+ return Promise.all(docsId.map( /*#__PURE__*/function () {
24
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(id) {
25
+ var file, path;
26
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
27
+ while (1) {
28
+ switch (_context.prev = _context.next) {
29
+ case 0:
30
+ if (!(doctype === 'io.cozy.files')) {
31
+ _context.next = 6;
32
+ break;
33
+ }
27
34
 
28
- _context.next = 3;
29
- return client.query(Q(doctype).getById(id));
35
+ _context.next = 3;
36
+ return client.query(Q(doctype).getById(id));
30
37
 
31
- case 3:
32
- _context.t0 = _context.sent;
33
- _context.next = 7;
34
- break;
38
+ case 3:
39
+ _context.t0 = _context.sent;
40
+ _context.next = 7;
41
+ break;
35
42
 
36
- case 6:
37
- _context.t0 = undefined;
43
+ case 6:
44
+ _context.t0 = undefined;
38
45
 
39
- case 7:
40
- file = _context.t0;
41
- _context.t1 = file;
46
+ case 7:
47
+ file = _context.t0;
48
+ _context.t1 = file;
42
49
 
43
- if (!_context.t1) {
44
- _context.next = 16;
45
- break;
46
- }
50
+ if (!_context.t1) {
51
+ _context.next = 16;
52
+ break;
53
+ }
47
54
 
48
- _context.t2 = file.data.path;
55
+ _context.t2 = file.data.path;
49
56
 
50
- if (_context.t2) {
51
- _context.next = 15;
52
- break;
53
- }
57
+ if (_context.t2) {
58
+ _context.next = 15;
59
+ break;
60
+ }
54
61
 
55
- _context.next = 14;
56
- return fetchFilesPaths(client, doctype, [file.data]);
62
+ _context.next = 14;
63
+ return fetchFilesPaths(client, doctype, [file.data]);
57
64
 
58
- case 14:
59
- _context.t2 = _context.sent;
65
+ case 14:
66
+ _context.t2 = _context.sent;
60
67
 
61
- case 15:
62
- _context.t1 = _context.t2;
68
+ case 15:
69
+ _context.t1 = _context.t2;
63
70
 
64
- case 16:
65
- path = _context.t1;
66
- dispatch(addSharing(sharing, path));
71
+ case 16:
72
+ path = _context.t1;
73
+ dispatch(addSharing(sharing, path));
67
74
 
68
- case 18:
69
- case "end":
70
- return _context.stop();
71
- }
75
+ case 18:
76
+ case "end":
77
+ return _context.stop();
78
+ }
79
+ }
80
+ }, _callee);
81
+ }));
82
+
83
+ return function (_x2) {
84
+ return _ref3.apply(this, arguments);
85
+ };
86
+ }()));
87
+
88
+ case 3:
89
+ case "end":
90
+ return _context2.stop();
72
91
  }
73
- }, _callee);
74
- }));
92
+ }
93
+ }, _callee2);
94
+ }));
75
95
 
76
- return function (_x) {
77
- return _ref.apply(this, arguments);
78
- };
79
- }());
80
- };
96
+ return function createSharingInStore(_x) {
97
+ return _ref2.apply(this, arguments);
98
+ };
99
+ }();
81
100
  export var updateSharingInStore = function updateSharingInStore(dispatch, sharing) {
82
101
  dispatch(updateSharing(sharing));
83
102
  };
@@ -0,0 +1,67 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
+ import _createClass from "@babel/runtime/helpers/createClass";
4
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
5
+ export var SynchronousJobQueue = /*#__PURE__*/function () {
6
+ function SynchronousJobQueue() {
7
+ _classCallCheck(this, SynchronousJobQueue);
8
+
9
+ this.isRunning = false;
10
+ this.queue = [];
11
+ }
12
+
13
+ _createClass(SynchronousJobQueue, [{
14
+ key: "push",
15
+ value: function push(job) {
16
+ this.queue.push(job);
17
+
18
+ if (!this.isRunning) {
19
+ this.run();
20
+ }
21
+ }
22
+ }, {
23
+ key: "run",
24
+ value: function () {
25
+ var _run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
26
+ var job;
27
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
28
+ while (1) {
29
+ switch (_context.prev = _context.next) {
30
+ case 0:
31
+ this.isRunning = true;
32
+
33
+ case 1:
34
+ if (!(this.queue.length > 0)) {
35
+ _context.next = 7;
36
+ break;
37
+ }
38
+
39
+ job = this.queue.shift();
40
+ _context.next = 5;
41
+ return job.function(job.arguments);
42
+
43
+ case 5:
44
+ _context.next = 1;
45
+ break;
46
+
47
+ case 7:
48
+ this.isRunning = false;
49
+
50
+ case 8:
51
+ case "end":
52
+ return _context.stop();
53
+ }
54
+ }
55
+ }, _callee, this);
56
+ }));
57
+
58
+ function run() {
59
+ return _run.apply(this, arguments);
60
+ }
61
+
62
+ return run;
63
+ }()
64
+ }]);
65
+
66
+ return SynchronousJobQueue;
67
+ }();
@@ -0,0 +1,97 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
+ import { SynchronousJobQueue } from './synchronousJobQueue';
4
+
5
+ var flushPromises = function flushPromises() {
6
+ return new Promise(process.nextTick);
7
+ };
8
+
9
+ var callback = jest.fn();
10
+ var resolveAfter100Ms = jest.fn().mockImplementation(function () {
11
+ callback('100Ms start');
12
+ return new Promise(function (resolve) {
13
+ setTimeout(function () {
14
+ callback('100Ms end');
15
+ resolve();
16
+ }, 100);
17
+ });
18
+ });
19
+ var resolveAfter500Ms = jest.fn().mockImplementation(function () {
20
+ callback('500Ms start');
21
+ return new Promise(function (resolve) {
22
+ setTimeout(function () {
23
+ callback('500Ms end');
24
+ resolve();
25
+ }, 500);
26
+ });
27
+ });
28
+ describe('SynchronousJobQueue', function () {
29
+ beforeEach(function () {
30
+ jest.useFakeTimers();
31
+ });
32
+ afterEach(function () {
33
+ jest.useRealTimers();
34
+ jest.clearAllMocks();
35
+ });
36
+ it('should execute job synchronously with SynchronousJobQueue', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
37
+ var synchronousJobQueue, expectedCallbackOrder;
38
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
39
+ while (1) {
40
+ switch (_context.prev = _context.next) {
41
+ case 0:
42
+ synchronousJobQueue = new SynchronousJobQueue();
43
+ synchronousJobQueue.push({
44
+ function: resolveAfter500Ms
45
+ });
46
+ synchronousJobQueue.push({
47
+ function: resolveAfter100Ms
48
+ });
49
+ jest.runAllTimers();
50
+ _context.next = 6;
51
+ return flushPromises();
52
+
53
+ case 6:
54
+ jest.runAllTimers();
55
+ _context.next = 9;
56
+ return flushPromises();
57
+
58
+ case 9:
59
+ expectedCallbackOrder = [['500Ms start'], ['500Ms end'], ['100Ms start'], ['100Ms end']];
60
+ expect(callback.mock.calls).toEqual(expectedCallbackOrder);
61
+
62
+ case 11:
63
+ case "end":
64
+ return _context.stop();
65
+ }
66
+ }
67
+ }, _callee);
68
+ })));
69
+ it('should execute job asynchronously without SynchronousJobQueue', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
70
+ var expectedCallbackOrder;
71
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
72
+ while (1) {
73
+ switch (_context2.prev = _context2.next) {
74
+ case 0:
75
+ resolveAfter500Ms();
76
+ resolveAfter100Ms();
77
+ jest.runAllTimers();
78
+ _context2.next = 5;
79
+ return flushPromises();
80
+
81
+ case 5:
82
+ jest.runAllTimers();
83
+ _context2.next = 8;
84
+ return flushPromises();
85
+
86
+ case 8:
87
+ expectedCallbackOrder = [['500Ms start'], ['100Ms start'], ['100Ms end'], ['500Ms end']];
88
+ expect(callback.mock.calls).toEqual(expectedCallbackOrder);
89
+
90
+ case 10:
91
+ case "end":
92
+ return _context2.stop();
93
+ }
94
+ }
95
+ }, _callee2);
96
+ })));
97
+ });
package/dist/index.js CHANGED
@@ -17,4 +17,5 @@ export { CozyPassFingerprintDialogContent } from './components/CozyPassFingerpri
17
17
  export { SharingBannerPlugin } from './SharingBanner';
18
18
  export { useSharingInfos } from './SharingBanner/hooks/useSharingInfos';
19
19
  export { ConfirmTrustedRecipientsDialog } from './ConfirmTrustedRecipientsDialog';
20
- export { ShareButtonWithRecipients } from './ShareButtonWithRecipients';
20
+ export { ShareButtonWithRecipients } from './ShareButtonWithRecipients';
21
+ export { DOCUMENT_TYPE } from './helpers/documentType';
@@ -0,0 +1,72 @@
1
+ import { Q, fetchPolicies } from 'cozy-client';
2
+ import { Contact, Group } from '../models';
3
+ var DEFAULT_CACHE_TIMEOUT_QUERIES = 9 * 60 * 1000;
4
+ var defaultFetchPolicy = fetchPolicies.olderThan(DEFAULT_CACHE_TIMEOUT_QUERIES);
5
+ export var fetchApps = function fetchApps() {
6
+ return {
7
+ definition: Q('io.cozy.apps'),
8
+ options: {
9
+ as: 'io.cozy.apps',
10
+ fetchPolicy: defaultFetchPolicy
11
+ }
12
+ };
13
+ };
14
+ export var buildSharingsByIdQuery = function buildSharingsByIdQuery(sharingId) {
15
+ return {
16
+ definition: Q('io.cozy.sharings').getById(sharingId),
17
+ options: {
18
+ as: "io.cozy.sharings/".concat(sharingId),
19
+ fetchPolicy: defaultFetchPolicy
20
+ }
21
+ };
22
+ };
23
+ export var buildContactsQuery = function buildContactsQuery() {
24
+ return {
25
+ definition: Q(Contact.doctype).where({
26
+ _id: {
27
+ $gt: null
28
+ }
29
+ }).partialIndex({
30
+ trashed: {
31
+ $or: [{
32
+ $eq: false
33
+ }, {
34
+ $exists: false
35
+ }]
36
+ },
37
+ $or: [{
38
+ cozy: {
39
+ $not: {
40
+ $size: 0
41
+ }
42
+ }
43
+ }, {
44
+ email: {
45
+ $not: {
46
+ $size: 0
47
+ }
48
+ }
49
+ }]
50
+ }).indexFields(['_id']).limitBy(1000),
51
+ options: {
52
+ as: 'io.cozy.contacts'
53
+ }
54
+ };
55
+ };
56
+ export var buildGroupsQuery = function buildGroupsQuery() {
57
+ return {
58
+ definition: Q(Group.doctype),
59
+ options: {
60
+ as: 'io.cozy.contacts.groups'
61
+ }
62
+ };
63
+ };
64
+ export var buildInstanceSettingsQuery = function buildInstanceSettingsQuery() {
65
+ return {
66
+ definition: Q('io.cozy.settings').getById('instance'),
67
+ options: {
68
+ as: 'io.cozy.settings/instance',
69
+ singleDocData: true
70
+ }
71
+ };
72
+ };
package/dist/share.styl CHANGED
@@ -21,10 +21,6 @@
21
21
  .coz-form-group
22
22
  flex-shrink 0
23
23
 
24
- .coz-form-label
25
- padding-top 0
26
- margin-top 0
27
-
28
24
  .aligned-dropdown-button
29
25
  margin-right: -1rem
30
26
 
@@ -82,17 +78,6 @@
82
78
  .react-select__option:active
83
79
  background-color var(--paleGrey) !important
84
80
 
85
- @media (max-width 32em)
86
- .react-select__menu
87
- width 100% !important
88
-
89
- @media (max-width 32em)
90
- .share-type-control
91
- flex-direction column
92
-
93
- .select-wrapper
94
- margin-bottom .5rem
95
-
96
81
  input[type=text]
97
82
  width 100%
98
83