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
@@ -40,42 +40,38 @@ describe('allLoaded', function () {
40
40
  it('Change to True when all data is loaded', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
41
41
  var component;
42
42
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
43
- while (1) {
44
- switch (_context2.prev = _context2.next) {
45
- case 0:
46
- component = mount( /*#__PURE__*/React.createElement(AppWrapper, {
47
- client: client
48
- }, /*#__PURE__*/React.createElement(SharingContext.Consumer, null, function (_ref3) {
49
- var allLoaded = _ref3.allLoaded;
50
- return /*#__PURE__*/React.createElement("div", null, "allLoaded: ".concat(allLoaded));
51
- })));
52
- expect(component.find('div').text()).toBe('allLoaded: false');
53
- _context2.next = 4;
54
- return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
55
- return _regeneratorRuntime.wrap(function _callee$(_context) {
56
- while (1) {
57
- switch (_context.prev = _context.next) {
58
- case 0:
59
- _context.next = 2;
60
- return new Promise(function (resolve) {
61
- return setTimeout(resolve, 100);
62
- });
43
+ while (1) switch (_context2.prev = _context2.next) {
44
+ case 0:
45
+ component = mount( /*#__PURE__*/React.createElement(AppWrapper, {
46
+ client: client
47
+ }, /*#__PURE__*/React.createElement(SharingContext.Consumer, null, function (_ref3) {
48
+ var allLoaded = _ref3.allLoaded;
49
+ return /*#__PURE__*/React.createElement("div", null, "allLoaded: ".concat(allLoaded));
50
+ })));
51
+ expect(component.find('div').text()).toBe('allLoaded: false');
52
+ _context2.next = 4;
53
+ return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
54
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
55
+ while (1) switch (_context.prev = _context.next) {
56
+ case 0:
57
+ _context.next = 2;
58
+ return new Promise(function (resolve) {
59
+ return setTimeout(resolve, 100);
60
+ });
63
61
 
64
- case 2:
65
- case "end":
66
- return _context.stop();
67
- }
68
- }
69
- }, _callee);
70
- })));
62
+ case 2:
63
+ case "end":
64
+ return _context.stop();
65
+ }
66
+ }, _callee);
67
+ })));
71
68
 
72
- case 4:
73
- expect(component.find('div').text()).toBe('allLoaded: true');
69
+ case 4:
70
+ expect(component.find('div').text()).toBe('allLoaded: true');
74
71
 
75
- case 5:
76
- case "end":
77
- return _context2.stop();
78
- }
72
+ case 5:
73
+ case "end":
74
+ return _context2.stop();
79
75
  }
80
76
  }, _callee2);
81
77
  })));
@@ -21,23 +21,21 @@ describe('CozyPassFingerprintDialogContent', function () {
21
21
  var props, _setup, getByText;
22
22
 
23
23
  return _regeneratorRuntime.wrap(function _callee$(_context) {
24
- while (1) {
25
- switch (_context.prev = _context.next) {
26
- case 0:
27
- props = {
28
- recipientConfirmationData: {
29
- name: 'SOME_NAME',
30
- email: 'SOME_EMAIL',
31
- fingerprintPhrase: 'SOME_FINGERPRINT'
32
- }
33
- };
34
- _setup = setup(props), getByText = _setup.getByText;
35
- expect(getByText('SOME_FINGERPRINT')).toBeTruthy();
24
+ while (1) switch (_context.prev = _context.next) {
25
+ case 0:
26
+ props = {
27
+ recipientConfirmationData: {
28
+ name: 'SOME_NAME',
29
+ email: 'SOME_EMAIL',
30
+ fingerprintPhrase: 'SOME_FINGERPRINT'
31
+ }
32
+ };
33
+ _setup = setup(props), getByText = _setup.getByText;
34
+ expect(getByText('SOME_FINGERPRINT')).toBeTruthy();
36
35
 
37
- case 3:
38
- case "end":
39
- return _context.stop();
40
- }
36
+ case 3:
37
+ case "end":
38
+ return _context.stop();
41
39
  }
42
40
  }, _callee);
43
41
  })));
@@ -46,33 +46,31 @@ var LinkRecipientPermissions = function LinkRecipientPermissions(_ref) {
46
46
  var deleteShareLink = /*#__PURE__*/function () {
47
47
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
48
48
  return _regeneratorRuntime.wrap(function _callee$(_context) {
49
- while (1) {
50
- switch (_context.prev = _context.next) {
51
- case 0:
52
- _context.prev = 0;
53
- setLoading(true);
54
- _context.next = 4;
55
- return onDisable(document);
56
-
57
- case 4:
58
- _context.next = 10;
59
- break;
60
-
61
- case 6:
62
- _context.prev = 6;
63
- _context.t0 = _context["catch"](0);
64
- Alerter.error(t("".concat(documentType, ".share.error.revoke")));
65
- logger.log(_context.t0);
66
-
67
- case 10:
68
- _context.prev = 10;
69
- setLoading(false);
70
- return _context.finish(10);
71
-
72
- case 13:
73
- case "end":
74
- return _context.stop();
75
- }
49
+ while (1) switch (_context.prev = _context.next) {
50
+ case 0:
51
+ _context.prev = 0;
52
+ setLoading(true);
53
+ _context.next = 4;
54
+ return onDisable(document);
55
+
56
+ case 4:
57
+ _context.next = 10;
58
+ break;
59
+
60
+ case 6:
61
+ _context.prev = 6;
62
+ _context.t0 = _context["catch"](0);
63
+ Alerter.error(t("".concat(documentType, ".share.error.revoke")));
64
+ logger.log(_context.t0);
65
+
66
+ case 10:
67
+ _context.prev = 10;
68
+ setLoading(false);
69
+ return _context.finish(10);
70
+
71
+ case 13:
72
+ case "end":
73
+ return _context.stop();
76
74
  }
77
75
  }, _callee, null, [[0, 6, 10, 13]]);
78
76
  }));
@@ -61,28 +61,26 @@ describe('Recipient component', function () {
61
61
  var onRevoke, onRevokeSelf, _setup3, getByText;
62
62
 
63
63
  return _regeneratorRuntime.wrap(function _callee$(_context) {
64
- while (1) {
65
- switch (_context.prev = _context.next) {
66
- case 0:
67
- onRevoke = jest.fn();
68
- onRevokeSelf = jest.fn();
69
- _setup3 = setup({
70
- instance: 'foo.mycozy.cloud',
71
- status: 'ready',
72
- type: 'two-way',
73
- documentType: 'Files',
74
- onRevoke: onRevoke,
75
- onRevokeSelf: onRevokeSelf
76
- }), getByText = _setup3.getByText;
77
- fireEvent.click(getByText('can change'));
78
- fireEvent.click(getByText('Remove me from sharing'));
79
- expect(onRevoke).not.toBeCalled();
80
- expect(onRevokeSelf).toBeCalled();
64
+ while (1) switch (_context.prev = _context.next) {
65
+ case 0:
66
+ onRevoke = jest.fn();
67
+ onRevokeSelf = jest.fn();
68
+ _setup3 = setup({
69
+ instance: 'foo.mycozy.cloud',
70
+ status: 'ready',
71
+ type: 'two-way',
72
+ documentType: 'Files',
73
+ onRevoke: onRevoke,
74
+ onRevokeSelf: onRevokeSelf
75
+ }), getByText = _setup3.getByText;
76
+ fireEvent.click(getByText('can change'));
77
+ fireEvent.click(getByText('Remove me from sharing'));
78
+ expect(onRevoke).not.toBeCalled();
79
+ expect(onRevokeSelf).toBeCalled();
81
80
 
82
- case 7:
83
- case "end":
84
- return _context.stop();
85
- }
81
+ case 7:
82
+ case "end":
83
+ return _context.stop();
86
84
  }
87
85
  }, _callee);
88
86
  })));
@@ -90,29 +88,27 @@ describe('Recipient component', function () {
90
88
  var onRevoke, onRevokeSelf, _setup4, getByText;
91
89
 
92
90
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
93
- while (1) {
94
- switch (_context2.prev = _context2.next) {
95
- case 0:
96
- onRevoke = jest.fn();
97
- onRevokeSelf = jest.fn();
98
- _setup4 = setup({
99
- instance: 'foo.mycozy.cloud',
100
- status: 'ready',
101
- type: 'two-way',
102
- isOwner: true,
103
- documentType: 'Files',
104
- onRevoke: onRevoke,
105
- onRevokeSelf: onRevokeSelf
106
- }), getByText = _setup4.getByText;
107
- fireEvent.click(getByText('can change'));
108
- fireEvent.click(getByText('Remove from sharing'));
109
- expect(onRevoke).toBeCalled();
110
- expect(onRevokeSelf).not.toBeCalled();
91
+ while (1) switch (_context2.prev = _context2.next) {
92
+ case 0:
93
+ onRevoke = jest.fn();
94
+ onRevokeSelf = jest.fn();
95
+ _setup4 = setup({
96
+ instance: 'foo.mycozy.cloud',
97
+ status: 'ready',
98
+ type: 'two-way',
99
+ isOwner: true,
100
+ documentType: 'Files',
101
+ onRevoke: onRevoke,
102
+ onRevokeSelf: onRevokeSelf
103
+ }), getByText = _setup4.getByText;
104
+ fireEvent.click(getByText('can change'));
105
+ fireEvent.click(getByText('Remove from sharing'));
106
+ expect(onRevoke).toBeCalled();
107
+ expect(onRevokeSelf).not.toBeCalled();
111
108
 
112
- case 7:
113
- case "end":
114
- return _context2.stop();
115
- }
109
+ case 7:
110
+ case "end":
111
+ return _context2.stop();
116
112
  }
117
113
  }, _callee2);
118
114
  })));
@@ -56,34 +56,32 @@ var RecipientPermissions = function RecipientPermissions(_ref) {
56
56
 
57
57
  var onRevokeClick = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
58
58
  return _regeneratorRuntime.wrap(function _callee$(_context) {
59
- while (1) {
60
- switch (_context.prev = _context.next) {
61
- case 0:
62
- setRevoking(true);
59
+ while (1) switch (_context.prev = _context.next) {
60
+ case 0:
61
+ setRevoking(true);
63
62
 
64
- if (!isOwner) {
65
- _context.next = 6;
66
- break;
67
- }
63
+ if (!isOwner) {
64
+ _context.next = 6;
65
+ break;
66
+ }
68
67
 
69
- _context.next = 4;
70
- return onRevoke(document, sharingId, index);
68
+ _context.next = 4;
69
+ return onRevoke(document, sharingId, index);
71
70
 
72
- case 4:
73
- _context.next = 8;
74
- break;
71
+ case 4:
72
+ _context.next = 8;
73
+ break;
75
74
 
76
- case 6:
77
- _context.next = 8;
78
- return onRevokeSelf(document);
75
+ case 6:
76
+ _context.next = 8;
77
+ return onRevokeSelf(document);
79
78
 
80
- case 8:
81
- setRevoking(false);
79
+ case 8:
80
+ setRevoking(false);
82
81
 
83
- case 9:
84
- case "end":
85
- return _context.stop();
86
- }
82
+ case 9:
83
+ case "end":
84
+ return _context.stop();
87
85
  }
88
86
  }, _callee);
89
87
  })), [isOwner, onRevoke, onRevokeSelf, document, sharingId, index]);
@@ -7,8 +7,6 @@ import React from 'react';
7
7
  import classNames from 'classnames';
8
8
  import { Button } from 'cozy-ui/transpiled/react/Button';
9
9
  var styles = {
10
- "CozyTheme--inverted": "button__CozyTheme--inverted___3s3RR",
11
- "CozyTheme--normal": "button__CozyTheme--normal___OteWq",
12
10
  "coz-btn-shared": "button__coz-btn-shared___2BoMk",
13
11
  "coz-btn-sharedWithMe": "button__coz-btn-sharedWithMe___2Vjfh"
14
12
  };
@@ -119,62 +119,60 @@ export var ShareByEmail = function ShareByEmail(_ref) {
119
119
  var recipientsBefore, _contacts, readWriteRecipients, readOnlyRecipients;
120
120
 
121
121
  return _regeneratorRuntime.wrap(function _callee$(_context) {
122
- while (1) {
123
- switch (_context.prev = _context.next) {
124
- case 0:
125
- if (!(recipients.length === 0)) {
126
- _context.next = 2;
127
- break;
128
- }
129
-
130
- return _context.abrupt("return");
131
-
132
- case 2:
133
- // we can't use currentRecipients prop in getSuccessMessage because it may use
134
- // the updated prop to count the new recipients
135
- recipientsBefore = currentRecipients;
136
- setLoading(true);
137
- _context.prev = 4;
138
- _context.next = 7;
139
- return getOrCreateFromArray(client, recipients, createContact);
140
-
141
- case 7:
142
- _contacts = _context.sent;
143
- readWriteRecipients = [];
144
- readOnlyRecipients = [];
145
-
146
- if (selectedOption === 'readOnly') {
147
- readOnlyRecipients = _contacts;
148
- } else {
149
- readWriteRecipients = _contacts;
150
- }
151
-
152
- _context.next = 13;
153
- return onShare({
154
- document: document,
155
- recipients: readWriteRecipients,
156
- readOnlyRecipients: readOnlyRecipients,
157
- description: sharingDesc,
158
- openSharing: readWriteRecipients.length > 0
159
- });
160
-
161
- case 13:
162
- Alerter.success(t.apply(void 0, _toConsumableArray(getSuccessMessage(recipientsBefore, _contacts, documentType))));
163
- reset();
164
- _context.next = 22;
122
+ while (1) switch (_context.prev = _context.next) {
123
+ case 0:
124
+ if (!(recipients.length === 0)) {
125
+ _context.next = 2;
165
126
  break;
166
-
167
- case 17:
168
- _context.prev = 17;
169
- _context.t0 = _context["catch"](4);
170
- Alerter.error('Error.generic');
171
- reset();
172
- throw _context.t0;
173
-
174
- case 22:
175
- case "end":
176
- return _context.stop();
177
- }
127
+ }
128
+
129
+ return _context.abrupt("return");
130
+
131
+ case 2:
132
+ // we can't use currentRecipients prop in getSuccessMessage because it may use
133
+ // the updated prop to count the new recipients
134
+ recipientsBefore = currentRecipients;
135
+ setLoading(true);
136
+ _context.prev = 4;
137
+ _context.next = 7;
138
+ return getOrCreateFromArray(client, recipients, createContact);
139
+
140
+ case 7:
141
+ _contacts = _context.sent;
142
+ readWriteRecipients = [];
143
+ readOnlyRecipients = [];
144
+
145
+ if (selectedOption === 'readOnly') {
146
+ readOnlyRecipients = _contacts;
147
+ } else {
148
+ readWriteRecipients = _contacts;
149
+ }
150
+
151
+ _context.next = 13;
152
+ return onShare({
153
+ document: document,
154
+ recipients: readWriteRecipients,
155
+ readOnlyRecipients: readOnlyRecipients,
156
+ description: sharingDesc,
157
+ openSharing: readWriteRecipients.length > 0
158
+ });
159
+
160
+ case 13:
161
+ Alerter.success(t.apply(void 0, _toConsumableArray(getSuccessMessage(recipientsBefore, _contacts, documentType))));
162
+ reset();
163
+ _context.next = 22;
164
+ break;
165
+
166
+ case 17:
167
+ _context.prev = 17;
168
+ _context.t0 = _context["catch"](4);
169
+ Alerter.error('Error.generic');
170
+ reset();
171
+ throw _context.t0;
172
+
173
+ case 22:
174
+ case "end":
175
+ return _context.stop();
178
176
  }
179
177
  }, _callee, null, [[4, 17]]);
180
178
  }));
@@ -16,62 +16,60 @@ describe('ShareByEmailComponent', function () {
16
16
  it('shoud call share if submited', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
17
17
  var onShare, props, root;
18
18
  return _regeneratorRuntime.wrap(function _callee$(_context) {
19
- while (1) {
20
- switch (_context.prev = _context.next) {
21
- case 0:
22
- onShare = jest.fn();
23
- props = {
24
- contacts: {
25
- data: []
26
- },
27
- groups: {
28
- data: []
29
- },
30
- documentType: 'Files',
31
- onShare: onShare,
32
- document: {
33
- id: 'doc_id'
34
- },
35
- sharingDesc: 'test',
36
- createContact: jest.fn()
37
- };
38
- root = render( /*#__PURE__*/React.createElement(AppLike, null, /*#__PURE__*/React.createElement(ShareByEmail, props)));
39
- act(function () {
40
- fireEvent.change(root.getByPlaceholderText('Add contacts or groups'), {
41
- target: {
42
- value: 'quentin@cozycloud.cc'
43
- }
44
- });
19
+ while (1) switch (_context.prev = _context.next) {
20
+ case 0:
21
+ onShare = jest.fn();
22
+ props = {
23
+ contacts: {
24
+ data: []
25
+ },
26
+ groups: {
27
+ data: []
28
+ },
29
+ documentType: 'Files',
30
+ onShare: onShare,
31
+ document: {
32
+ id: 'doc_id'
33
+ },
34
+ sharingDesc: 'test',
35
+ createContact: jest.fn()
36
+ };
37
+ root = render( /*#__PURE__*/React.createElement(AppLike, null, /*#__PURE__*/React.createElement(ShareByEmail, props)));
38
+ act(function () {
39
+ fireEvent.change(root.getByPlaceholderText('Add contacts or groups'), {
40
+ target: {
41
+ value: 'quentin@cozycloud.cc'
42
+ }
45
43
  });
46
- act(function () {
47
- fireEvent.keyPress(root.getByPlaceholderText('Add contacts or groups'), {
48
- key: 'Enter',
49
- code: 'Enter',
50
- charCode: 13
51
- });
44
+ });
45
+ act(function () {
46
+ fireEvent.keyPress(root.getByPlaceholderText('Add contacts or groups'), {
47
+ key: 'Enter',
48
+ code: 'Enter',
49
+ charCode: 13
52
50
  });
53
- act(function () {
54
- fireEvent.click(root.getByRole('button', {
55
- name: 'Send'
56
- }));
57
- });
58
- _context.next = 8;
59
- return waitFor(function () {
60
- expect(onShare).toHaveBeenCalledWith({
61
- description: props.sharingDesc,
62
- document: props.document,
63
- openSharing: true,
64
- readOnlyRecipients: [],
65
- recipients: [{
66
- email: 'quentin@cozycloud.cc'
67
- }]
68
- });
51
+ });
52
+ act(function () {
53
+ fireEvent.click(root.getByRole('button', {
54
+ name: 'Send'
55
+ }));
56
+ });
57
+ _context.next = 8;
58
+ return waitFor(function () {
59
+ expect(onShare).toHaveBeenCalledWith({
60
+ description: props.sharingDesc,
61
+ document: props.document,
62
+ openSharing: true,
63
+ readOnlyRecipients: [],
64
+ recipients: [{
65
+ email: 'quentin@cozycloud.cc'
66
+ }]
69
67
  });
68
+ });
70
69
 
71
- case 8:
72
- case "end":
73
- return _context.stop();
74
- }
70
+ case 8:
71
+ case "end":
72
+ return _context.stop();
75
73
  }
76
74
  }, _callee);
77
75
  })));