cozy-sharing 6.0.2 → 6.0.4

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 (34) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/SharingBanner/hooks/useSharingInfos.js +35 -37
  3. package/dist/SharingBanner/hooks/useSharingInfos.spec.js +40 -44
  4. package/dist/SharingProvider.js +351 -375
  5. package/dist/SharingProvider.spec.js +29 -33
  6. package/dist/components/CozyPassFingerprintDialogContent.spec.js +14 -16
  7. package/dist/components/Recipient/LinkRecipientPermissions.js +25 -27
  8. package/dist/components/Recipient/Recipient.spec.js +39 -43
  9. package/dist/components/Recipient/RecipientPermissions.js +20 -22
  10. package/dist/components/ShareButton.js +0 -2
  11. package/dist/components/ShareByEmail.js +53 -55
  12. package/dist/components/ShareByEmail.spec.js +50 -52
  13. package/dist/components/ShareByLink.js +73 -79
  14. package/dist/components/ShareDialogCozyToCozy.spec.js +238 -264
  15. package/dist/components/ShareDialogTwoStepsConfirmationContainer.js +33 -35
  16. package/dist/components/ShareDialogTwoStepsConfirmationContainer.spec.js +240 -266
  17. package/dist/components/SharedBadge.js +0 -2
  18. package/dist/components/badge.styl +7 -5
  19. package/dist/components/button.styl +11 -12
  20. package/dist/components/useFetchDocumentPath.js +16 -18
  21. package/dist/fetchNextPermissions.js +15 -17
  22. package/dist/getSharedDocument.js +13 -15
  23. package/dist/getSharedDocument.spec.js +10 -12
  24. package/dist/helpers/contacts.js +65 -69
  25. package/dist/helpers/contacts.spec.js +30 -32
  26. package/dist/helpers/files.js +26 -28
  27. package/dist/helpers/files.spec.js +54 -58
  28. package/dist/helpers/sharings.js +56 -60
  29. package/dist/helpers/synchronousJobQueue.js +19 -21
  30. package/dist/helpers/synchronousJobQueue.spec.js +39 -43
  31. package/dist/stylesheet.css +28 -820
  32. package/package.json +3 -3
  33. package/src/components/badge.styl +7 -5
  34. package/src/components/button.styl +11 -12
@@ -15,28 +15,26 @@ export var useFetchDocumentPath = function useFetchDocumentPath(client, document
15
15
  _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
16
16
  var path;
17
17
  return _regeneratorRuntime.wrap(function _callee$(_context) {
18
- while (1) {
19
- switch (_context.prev = _context.next) {
20
- case 0:
21
- _context.prev = 0;
22
- _context.next = 3;
23
- return fetchFilesPaths(client, document._type, [document]);
18
+ while (1) switch (_context.prev = _context.next) {
19
+ case 0:
20
+ _context.prev = 0;
21
+ _context.next = 3;
22
+ return fetchFilesPaths(client, document._type, [document]);
24
23
 
25
- case 3:
26
- path = _context.sent;
27
- setDocumentPath(path[0]); // eslint-disable-next-line
24
+ case 3:
25
+ path = _context.sent;
26
+ setDocumentPath(path[0]); // eslint-disable-next-line
28
27
 
29
- _context.next = 9;
30
- break;
28
+ _context.next = 9;
29
+ break;
31
30
 
32
- case 7:
33
- _context.prev = 7;
34
- _context.t0 = _context["catch"](0);
31
+ case 7:
32
+ _context.prev = 7;
33
+ _context.t0 = _context["catch"](0);
35
34
 
36
- case 9:
37
- case "end":
38
- return _context.stop();
39
- }
35
+ case 9:
36
+ case "end":
37
+ return _context.stop();
40
38
  }
41
39
  }, _callee, null, [[0, 7]]);
42
40
  }))();
@@ -13,26 +13,24 @@ export var fetchNextPermissions = /*#__PURE__*/function () {
13
13
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(permissions, dispatch, permissionCol) {
14
14
  var resp;
15
15
  return _regeneratorRuntime.wrap(function _callee$(_context) {
16
- while (1) {
17
- switch (_context.prev = _context.next) {
18
- case 0:
19
- if (!(permissions.links && permissions.links.next)) {
20
- _context.next = 6;
21
- break;
22
- }
16
+ while (1) switch (_context.prev = _context.next) {
17
+ case 0:
18
+ if (!(permissions.links && permissions.links.next)) {
19
+ _context.next = 6;
20
+ break;
21
+ }
23
22
 
24
- _context.next = 3;
25
- return permissionCol.fetchPermissionsByLink(permissions);
23
+ _context.next = 3;
24
+ return permissionCol.fetchPermissionsByLink(permissions);
26
25
 
27
- case 3:
28
- resp = _context.sent;
29
- dispatch(addSharingLink(resp.data));
30
- return _context.abrupt("return", fetchNextPermissions(resp, dispatch, permissionCol));
26
+ case 3:
27
+ resp = _context.sent;
28
+ dispatch(addSharingLink(resp.data));
29
+ return _context.abrupt("return", fetchNextPermissions(resp, dispatch, permissionCol));
31
30
 
32
- case 6:
33
- case "end":
34
- return _context.stop();
35
- }
31
+ case 6:
32
+ case "end":
33
+ return _context.stop();
36
34
  }
37
35
  }, _callee);
38
36
  }));
@@ -7,24 +7,22 @@ var getSharedDocument = /*#__PURE__*/function () {
7
7
  var _yield$client$collect, permissionsData, permissions, sharedDocumentId;
8
8
 
9
9
  return _regeneratorRuntime.wrap(function _callee$(_context) {
10
- while (1) {
11
- switch (_context.prev = _context.next) {
12
- case 0:
13
- _context.next = 2;
14
- return client.collection('io.cozy.permissions').getOwnPermissions();
10
+ while (1) switch (_context.prev = _context.next) {
11
+ case 0:
12
+ _context.next = 2;
13
+ return client.collection('io.cozy.permissions').getOwnPermissions();
15
14
 
16
- case 2:
17
- _yield$client$collect = _context.sent;
18
- permissionsData = _yield$client$collect.data;
19
- permissions = permissionsData.attributes.permissions; // permissions contains several named keys, but the one to use depends on the situation. Using the first one is what we want in all known cases.
15
+ case 2:
16
+ _yield$client$collect = _context.sent;
17
+ permissionsData = _yield$client$collect.data;
18
+ permissions = permissionsData.attributes.permissions; // permissions contains several named keys, but the one to use depends on the situation. Using the first one is what we want in all known cases.
20
19
 
21
- sharedDocumentId = get(Object.values(permissions), '0.values.0');
22
- return _context.abrupt("return", sharedDocumentId);
20
+ sharedDocumentId = get(Object.values(permissions), '0.values.0');
21
+ return _context.abrupt("return", sharedDocumentId);
23
22
 
24
- case 7:
25
- case "end":
26
- return _context.stop();
27
- }
23
+ case 7:
24
+ case "end":
25
+ return _context.stop();
28
26
  }
29
27
  }, _callee);
30
28
  }));
@@ -30,20 +30,18 @@ describe('Getting the shared document id', function () {
30
30
  it('should get the id', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
31
31
  var id;
32
32
  return _regeneratorRuntime.wrap(function _callee$(_context) {
33
- while (1) {
34
- switch (_context.prev = _context.next) {
35
- case 0:
36
- _context.next = 2;
37
- return getSharedDocument(mockClient);
33
+ while (1) switch (_context.prev = _context.next) {
34
+ case 0:
35
+ _context.next = 2;
36
+ return getSharedDocument(mockClient);
38
37
 
39
- case 2:
40
- id = _context.sent;
41
- expect(id).toEqual('myshareid');
38
+ case 2:
39
+ id = _context.sent;
40
+ expect(id).toEqual('myshareid');
42
41
 
43
- case 4:
44
- case "end":
45
- return _context.stop();
46
- }
42
+ case 4:
43
+ case "end":
44
+ return _context.stop();
47
45
  }
48
46
  }, _callee);
49
47
  })));
@@ -7,87 +7,83 @@ import { validateEmail } from '../helpers/email'; // Return the contact object i
7
7
  export var getOrCreateFromArray = /*#__PURE__*/function () {
8
8
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(client, contacts, createContact) {
9
9
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
10
- while (1) {
11
- switch (_context2.prev = _context2.next) {
12
- case 0:
13
- _context2.next = 2;
14
- return Promise.all(contacts.map( /*#__PURE__*/function () {
15
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(contact) {
16
- var matchedContact, resp;
17
- return _regeneratorRuntime.wrap(function _callee$(_context) {
18
- while (1) {
19
- switch (_context.prev = _context.next) {
20
- case 0:
21
- if (!contact.id) {
22
- _context.next = 4;
23
- break;
24
- }
10
+ while (1) switch (_context2.prev = _context2.next) {
11
+ case 0:
12
+ _context2.next = 2;
13
+ return Promise.all(contacts.map( /*#__PURE__*/function () {
14
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(contact) {
15
+ var matchedContact, resp;
16
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
17
+ while (1) switch (_context.prev = _context.next) {
18
+ case 0:
19
+ if (!contact.id) {
20
+ _context.next = 4;
21
+ break;
22
+ }
25
23
 
26
- return _context.abrupt("return", contact);
24
+ return _context.abrupt("return", contact);
27
25
 
28
- case 4:
29
- if (!validateEmail(contact.email)) {
30
- _context.next = 16;
31
- break;
32
- }
26
+ case 4:
27
+ if (!validateEmail(contact.email)) {
28
+ _context.next = 16;
29
+ break;
30
+ }
33
31
 
34
- _context.next = 7;
35
- return client.collection('io.cozy.contacts').find({
36
- email: {
37
- $elemMatch: {
38
- address: contact.email
39
- }
40
- },
41
- _id: {
42
- $gt: null
43
- }
44
- }, {
45
- indexedFields: ['_id']
46
- });
32
+ _context.next = 7;
33
+ return client.collection('io.cozy.contacts').find({
34
+ email: {
35
+ $elemMatch: {
36
+ address: contact.email
37
+ }
38
+ },
39
+ _id: {
40
+ $gt: null
41
+ }
42
+ }, {
43
+ indexedFields: ['_id']
44
+ });
47
45
 
48
- case 7:
49
- matchedContact = _context.sent;
46
+ case 7:
47
+ matchedContact = _context.sent;
50
48
 
51
- if (!(matchedContact.data.length > 0)) {
52
- _context.next = 12;
53
- break;
54
- }
49
+ if (!(matchedContact.data.length > 0)) {
50
+ _context.next = 12;
51
+ break;
52
+ }
55
53
 
56
- return _context.abrupt("return", matchedContact.data[0]);
54
+ return _context.abrupt("return", matchedContact.data[0]);
57
55
 
58
- case 12:
59
- _context.next = 14;
60
- return createContact({
61
- email: [{
62
- address: contact.email,
63
- primary: true
64
- }]
65
- });
56
+ case 12:
57
+ _context.next = 14;
58
+ return createContact({
59
+ email: [{
60
+ address: contact.email,
61
+ primary: true
62
+ }]
63
+ });
66
64
 
67
- case 14:
68
- resp = _context.sent;
69
- return _context.abrupt("return", resp.data);
65
+ case 14:
66
+ resp = _context.sent;
67
+ return _context.abrupt("return", resp.data);
70
68
 
71
- case 16:
72
- case "end":
73
- return _context.stop();
74
- }
75
- }
76
- }, _callee);
77
- }));
69
+ case 16:
70
+ case "end":
71
+ return _context.stop();
72
+ }
73
+ }, _callee);
74
+ }));
78
75
 
79
- return function (_x4) {
80
- return _ref2.apply(this, arguments);
81
- };
82
- }()));
76
+ return function (_x4) {
77
+ return _ref2.apply(this, arguments);
78
+ };
79
+ }()));
83
80
 
84
- case 2:
85
- return _context2.abrupt("return", _context2.sent);
81
+ case 2:
82
+ return _context2.abrupt("return", _context2.sent);
86
83
 
87
- case 3:
88
- case "end":
89
- return _context2.stop();
90
- }
84
+ case 3:
85
+ case "end":
86
+ return _context2.stop();
91
87
  }
92
88
  }, _callee2);
93
89
  }));
@@ -26,42 +26,40 @@ describe('getOrCreateFromArray', function () {
26
26
  it('test getOrCreateFromArray', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
27
27
  var wantedContacts, createContacts, contacts;
28
28
  return _regeneratorRuntime.wrap(function _callee$(_context) {
29
- while (1) {
30
- switch (_context.prev = _context.next) {
31
- case 0:
32
- wantedContacts = [{
33
- id: 1,
34
- email: '1@cozycloud.cc'
35
- }, {
36
- email: 'exists@cozycloud.cc'
37
- }, {
38
- email: 'doesntexist@cozycloud.cc'
39
- }];
29
+ while (1) switch (_context.prev = _context.next) {
30
+ case 0:
31
+ wantedContacts = [{
32
+ id: 1,
33
+ email: '1@cozycloud.cc'
34
+ }, {
35
+ email: 'exists@cozycloud.cc'
36
+ }, {
37
+ email: 'doesntexist@cozycloud.cc'
38
+ }];
40
39
 
41
- createContacts = function createContacts(contact) {
42
- return mockClient.create('io.cozy.contact', contact);
43
- };
40
+ createContacts = function createContacts(contact) {
41
+ return mockClient.create('io.cozy.contact', contact);
42
+ };
44
43
 
45
- _context.next = 4;
46
- return getOrCreateFromArray(mockClient, wantedContacts, createContacts);
44
+ _context.next = 4;
45
+ return getOrCreateFromArray(mockClient, wantedContacts, createContacts);
47
46
 
48
- case 4:
49
- contacts = _context.sent;
50
- expect(contacts).toEqual([{
51
- id: 1,
52
- email: '1@cozycloud.cc'
53
- }, {
54
- id: 2,
55
- email: 'exists@cozycloud.cc'
56
- }, {
57
- id: 3,
58
- email: 'doesntexist@cozycloud.cc'
59
- }]);
47
+ case 4:
48
+ contacts = _context.sent;
49
+ expect(contacts).toEqual([{
50
+ id: 1,
51
+ email: '1@cozycloud.cc'
52
+ }, {
53
+ id: 2,
54
+ email: 'exists@cozycloud.cc'
55
+ }, {
56
+ id: 3,
57
+ email: 'doesntexist@cozycloud.cc'
58
+ }]);
60
59
 
61
- case 6:
62
- case "end":
63
- return _context.stop();
64
- }
60
+ case 6:
61
+ case "end":
62
+ return _context.stop();
65
63
  }
66
64
  }, _callee);
67
65
  })));
@@ -4,37 +4,35 @@ export var fetchFilesPaths = /*#__PURE__*/function () {
4
4
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(client, doctype, files) {
5
5
  var parentDirIds, parentDirs, filePaths;
6
6
  return _regeneratorRuntime.wrap(function _callee$(_context) {
7
- while (1) {
8
- switch (_context.prev = _context.next) {
9
- case 0:
10
- parentDirIds = files.map(function (f) {
11
- return f.dir_id;
12
- }).filter(function (f, idx, arr) {
13
- return arr.indexOf(f) === idx;
14
- });
15
- _context.next = 3;
16
- return client.collection(doctype).all({
17
- keys: parentDirIds
18
- });
7
+ while (1) switch (_context.prev = _context.next) {
8
+ case 0:
9
+ parentDirIds = files.map(function (f) {
10
+ return f.dir_id;
11
+ }).filter(function (f, idx, arr) {
12
+ return arr.indexOf(f) === idx;
13
+ });
14
+ _context.next = 3;
15
+ return client.collection(doctype).all({
16
+ keys: parentDirIds
17
+ });
19
18
 
20
- case 3:
21
- parentDirs = _context.sent;
22
- filePaths = files.map(function (f) {
23
- return parentDirs.data.find(function (d) {
24
- return d.id === f.dir_id;
25
- });
26
- }).filter(function (parentDir) {
27
- return parentDir !== undefined;
28
- }).map(function (parentDir) {
29
- var parentDirPath = parentDir.path;
30
- return parentDirPath === '/' ? "/".concat(parentDir.name) : "".concat(parentDirPath, "/").concat(parentDir.name);
19
+ case 3:
20
+ parentDirs = _context.sent;
21
+ filePaths = files.map(function (f) {
22
+ return parentDirs.data.find(function (d) {
23
+ return d.id === f.dir_id;
31
24
  });
32
- return _context.abrupt("return", filePaths);
25
+ }).filter(function (parentDir) {
26
+ return parentDir !== undefined;
27
+ }).map(function (parentDir) {
28
+ var parentDirPath = parentDir.path;
29
+ return parentDirPath === '/' ? "/".concat(parentDir.name) : "".concat(parentDirPath, "/").concat(parentDir.name);
30
+ });
31
+ return _context.abrupt("return", filePaths);
33
32
 
34
- case 6:
35
- case "end":
36
- return _context.stop();
37
- }
33
+ case 6:
34
+ case "end":
35
+ return _context.stop();
38
36
  }
39
37
  }, _callee);
40
38
  }));
@@ -5,74 +5,70 @@ describe('fetchFilesPaths', function () {
5
5
  it('should handle document without path', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
6
6
  var mockClient, documents, filePaths;
7
7
  return _regeneratorRuntime.wrap(function _callee$(_context) {
8
- while (1) {
9
- switch (_context.prev = _context.next) {
10
- case 0:
11
- mockClient = {
12
- collection: function collection() {
13
- return {
14
- all: jest.fn().mockReturnValueOnce({
15
- data: []
16
- })
17
- };
18
- }
19
- };
20
- documents = [{
21
- id: 'SOME_ORGANIZATION_ID',
22
- name: 'SOME_ORGANISATION',
23
- _type: 'com.bitwarden.organizations',
24
- _id: 'SOME_ORGANIZATION_ID'
25
- }];
26
- _context.next = 4;
27
- return fetchFilesPaths(mockClient, 'com.bitwarden.organizations', documents);
8
+ while (1) switch (_context.prev = _context.next) {
9
+ case 0:
10
+ mockClient = {
11
+ collection: function collection() {
12
+ return {
13
+ all: jest.fn().mockReturnValueOnce({
14
+ data: []
15
+ })
16
+ };
17
+ }
18
+ };
19
+ documents = [{
20
+ id: 'SOME_ORGANIZATION_ID',
21
+ name: 'SOME_ORGANISATION',
22
+ _type: 'com.bitwarden.organizations',
23
+ _id: 'SOME_ORGANIZATION_ID'
24
+ }];
25
+ _context.next = 4;
26
+ return fetchFilesPaths(mockClient, 'com.bitwarden.organizations', documents);
28
27
 
29
- case 4:
30
- filePaths = _context.sent;
31
- expect(filePaths).toEqual([]);
28
+ case 4:
29
+ filePaths = _context.sent;
30
+ expect(filePaths).toEqual([]);
32
31
 
33
- case 6:
34
- case "end":
35
- return _context.stop();
36
- }
32
+ case 6:
33
+ case "end":
34
+ return _context.stop();
37
35
  }
38
36
  }, _callee);
39
37
  })));
40
38
  it('should handle a document with a path', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
41
39
  var mockClient, documents, filePaths;
42
40
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
43
- while (1) {
44
- switch (_context2.prev = _context2.next) {
45
- case 0:
46
- mockClient = {
47
- collection: function collection() {
48
- return {
49
- all: jest.fn().mockReturnValueOnce({
50
- data: [{
51
- id: 'SOME_PARENT_DIR_ID',
52
- name: 'SOME_PARENT_DIR',
53
- path: '/some_parent_dir'
54
- }]
55
- })
56
- };
57
- }
58
- };
59
- documents = [{
60
- id: 'SOME_DOCUMENT_ID',
61
- name: 'test',
62
- type: 'io.cozy.files',
63
- dir_id: 'SOME_PARENT_DIR_ID'
64
- }];
65
- _context2.next = 4;
66
- return fetchFilesPaths(mockClient, 'io.cozy.files', documents);
41
+ while (1) switch (_context2.prev = _context2.next) {
42
+ case 0:
43
+ mockClient = {
44
+ collection: function collection() {
45
+ return {
46
+ all: jest.fn().mockReturnValueOnce({
47
+ data: [{
48
+ id: 'SOME_PARENT_DIR_ID',
49
+ name: 'SOME_PARENT_DIR',
50
+ path: '/some_parent_dir'
51
+ }]
52
+ })
53
+ };
54
+ }
55
+ };
56
+ documents = [{
57
+ id: 'SOME_DOCUMENT_ID',
58
+ name: 'test',
59
+ type: 'io.cozy.files',
60
+ dir_id: 'SOME_PARENT_DIR_ID'
61
+ }];
62
+ _context2.next = 4;
63
+ return fetchFilesPaths(mockClient, 'io.cozy.files', documents);
67
64
 
68
- case 4:
69
- filePaths = _context2.sent;
70
- expect(filePaths).toEqual(['/some_parent_dir/SOME_PARENT_DIR']);
65
+ case 4:
66
+ filePaths = _context2.sent;
67
+ expect(filePaths).toEqual(['/some_parent_dir/SOME_PARENT_DIR']);
71
68
 
72
- case 6:
73
- case "end":
74
- return _context2.stop();
75
- }
69
+ case 6:
70
+ case "end":
71
+ return _context2.stop();
76
72
  }
77
73
  }, _callee2);
78
74
  })));