cozy-sharing 31.0.2 → 31.2.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 (81) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/components/FederatedFolder/DumbFederatedFolderModal.js +15 -16
  3. package/dist/components/FederatedFolder/FederatedFolderModal.js +78 -103
  4. package/dist/components/FederatedFolder/FederatedFolderModal.spec.js +102 -292
  5. package/dist/components/Recipient/GroupRecipientPermissions.js +15 -11
  6. package/dist/components/Recipient/LinkRecipient.js +15 -11
  7. package/dist/components/Recipient/LinkRecipientLite.js +1 -1
  8. package/dist/components/Recipient/LinkRecipientPermissions.js +2 -1
  9. package/dist/components/Recipient/MemberRecipient.spec.js +8 -10
  10. package/dist/components/Recipient/MemberRecipientLite.js +1 -1
  11. package/dist/components/Recipient/MemberRecipientPermissions.js +16 -12
  12. package/dist/components/Recipient/MemberRecipientPermissions.spec.js +62 -50
  13. package/dist/components/Recipient/RecipientConfirm.js +0 -5
  14. package/dist/components/ShareAutosuggest.js +9 -4
  15. package/dist/components/ShareByEmail.js +29 -274
  16. package/dist/components/ShareByEmail.spec.js +52 -230
  17. package/dist/components/ShareByLink.js +1 -3
  18. package/dist/components/ShareDialogCozyToCozy.js +169 -35
  19. package/dist/components/ShareDialogCozyToCozy.spec.js +123 -36
  20. package/dist/components/ShareDialogTwoStepsConfirmationContainer.js +13 -3
  21. package/dist/components/ShareModal/SharingDetailsModal.js +0 -5
  22. package/dist/components/ShareRecipientsInput.js +6 -3
  23. package/dist/components/SharedDrive/SharedDriveForm.js +17 -25
  24. package/dist/components/SharedDrive/SharedDriveModal.js +1 -1
  25. package/dist/components/SharedDrive/SharedDriveRecipientPermissions.js +15 -10
  26. package/dist/components/SharedDrive/useSharedDrive.js +33 -57
  27. package/dist/components/SharedDrive/useSharedDrive.spec.js +29 -93
  28. package/dist/components/SharedFolder/DumbBatchSharedFolderModal.js +15 -26
  29. package/dist/components/Sharetypeselect.js +85 -90
  30. package/dist/hooks/usePendingRecipients.js +20 -0
  31. package/dist/hooks/usePendingRecipients.spec.js +30 -0
  32. package/dist/styles/autosuggest.styl +8 -2
  33. package/dist/styles/share.styl +0 -39
  34. package/dist/stylesheet.css +8 -36
  35. package/locales/en.json +14 -44
  36. package/locales/fr.json +14 -44
  37. package/locales/ru.json +14 -44
  38. package/locales/vi.json +14 -42
  39. package/package.json +2 -2
  40. package/src/components/FederatedFolder/DumbFederatedFolderModal.jsx +14 -15
  41. package/src/components/FederatedFolder/FederatedFolderModal.jsx +50 -67
  42. package/src/components/FederatedFolder/FederatedFolderModal.spec.jsx +63 -186
  43. package/src/components/Recipient/GroupRecipientPermissions.jsx +15 -13
  44. package/src/components/Recipient/LinkRecipient.jsx +9 -9
  45. package/src/components/Recipient/LinkRecipientLite.jsx +1 -3
  46. package/src/components/Recipient/LinkRecipientPermissions.jsx +2 -1
  47. package/src/components/Recipient/MemberRecipient.spec.jsx +4 -6
  48. package/src/components/Recipient/MemberRecipientLite.jsx +2 -2
  49. package/src/components/Recipient/MemberRecipientPermissions.jsx +16 -21
  50. package/src/components/Recipient/MemberRecipientPermissions.spec.jsx +21 -23
  51. package/src/components/ShareAutosuggest.jsx +7 -2
  52. package/src/components/ShareByEmail.jsx +35 -186
  53. package/src/components/ShareByEmail.spec.jsx +22 -173
  54. package/src/components/ShareByLink.jsx +1 -7
  55. package/src/components/ShareDialogCozyToCozy.jsx +171 -38
  56. package/src/components/ShareDialogCozyToCozy.spec.jsx +67 -1
  57. package/src/components/ShareDialogTwoStepsConfirmationContainer.jsx +11 -1
  58. package/src/components/ShareRecipientsInput.jsx +5 -2
  59. package/src/components/SharedDrive/SharedDriveForm.jsx +16 -25
  60. package/src/components/SharedDrive/SharedDriveModal.jsx +1 -1
  61. package/src/components/SharedDrive/SharedDriveRecipientPermissions.jsx +15 -17
  62. package/src/components/SharedDrive/useSharedDrive.js +24 -50
  63. package/src/components/SharedDrive/useSharedDrive.spec.js +19 -67
  64. package/src/components/SharedFolder/DumbBatchSharedFolderModal.jsx +15 -29
  65. package/src/components/Sharetypeselect.jsx +75 -58
  66. package/src/hooks/usePendingRecipients.js +13 -0
  67. package/src/hooks/usePendingRecipients.spec.js +21 -0
  68. package/src/styles/autosuggest.styl +8 -2
  69. package/src/styles/share.styl +0 -39
  70. package/dist/components/Recipient/actions/revokeGroup.js +0 -42
  71. package/dist/components/Recipient/actions/revokeMember.js +0 -42
  72. package/dist/components/Recipient/actions/revokeSharedDriveMember.js +0 -41
  73. package/dist/components/SharedDrive/helpers.js +0 -102
  74. package/dist/components/SharedDrive/helpers.spec.js +0 -227
  75. package/dist/components/Sharesubmit.js +0 -28
  76. package/src/components/Recipient/actions/revokeGroup.js +0 -42
  77. package/src/components/Recipient/actions/revokeMember.js +0 -42
  78. package/src/components/Recipient/actions/revokeSharedDriveMember.js +0 -41
  79. package/src/components/SharedDrive/helpers.js +0 -108
  80. package/src/components/SharedDrive/helpers.spec.js +0 -177
  81. package/src/components/Sharesubmit.jsx +0 -31
@@ -5,6 +5,8 @@ import { fireEvent, render, waitFor } from '@testing-library/react';
5
5
  import React from 'react';
6
6
  import { createMockClient } from 'cozy-client';
7
7
  import { FederatedFolderModal } from './FederatedFolderModal';
8
+ import { getOrCreateFromArray } from '../../helpers/contacts';
9
+ import { usePendingRecipients } from '../../hooks/usePendingRecipients';
8
10
  import AppLike from '../SharingBanner/test/AppLike';
9
11
  var mockShare = jest.fn();
10
12
  var mockRevoke = jest.fn();
@@ -39,19 +41,27 @@ jest.mock('../../hoc/withLocales', function () {
39
41
  return Component;
40
42
  };
41
43
  });
44
+ jest.mock('../../helpers/contacts', function () {
45
+ return {
46
+ getOrCreateFromArray: jest.fn()
47
+ };
48
+ });
49
+ jest.mock('../../hooks/usePendingRecipients', function () {
50
+ return {
51
+ usePendingRecipients: jest.fn()
52
+ };
53
+ });
42
54
  jest.mock('./DumbFederatedFolderModal', function () {
43
55
  return {
44
56
  DumbFederatedFolderModal: function DumbFederatedFolderModal(_ref) {
45
57
  var title = _ref.title,
46
- createContact = _ref.createContact,
47
58
  recipients = _ref.recipients,
48
- readOnlyRecipients = _ref.readOnlyRecipients,
49
59
  onRevoke = _ref.onRevoke,
50
- onSetType = _ref.onSetType,
51
60
  onSend = _ref.onSend,
52
61
  onClose = _ref.onClose,
53
- onShare = _ref.onShare,
54
- sharingLink = _ref.sharingLink;
62
+ sharingLink = _ref.sharingLink,
63
+ pendingRecipients = _ref.pendingRecipients,
64
+ selectedOption = _ref.selectedOption;
55
65
  return /*#__PURE__*/React.createElement("div", {
56
66
  "data-testid": "dumb-modal"
57
67
  }, /*#__PURE__*/React.createElement("span", {
@@ -61,75 +71,23 @@ jest.mock('./DumbFederatedFolderModal', function () {
61
71
  }, sharingLink), /*#__PURE__*/React.createElement("span", {
62
72
  "data-testid": "recipients-count"
63
73
  }, recipients.length), /*#__PURE__*/React.createElement("span", {
64
- "data-testid": "readOnly-recipients-count"
65
- }, readOnlyRecipients ? readOnlyRecipients.length : 0), /*#__PURE__*/React.createElement("button", {
66
- "data-testid": "btn-share",
67
- onClick: function onClick() {
68
- return onShare({
69
- recipients: [{
70
- _id: 'r1',
71
- id: 'r1',
72
- displayName: 'Alice'
73
- }],
74
- readOnlyRecipients: [{
75
- _id: 'r2',
76
- id: 'r2',
77
- displayName: 'Bob'
78
- }]
79
- });
80
- }
81
- }, "Share"), /*#__PURE__*/React.createElement("button", {
82
- "data-testid": "btn-share-other",
83
- onClick: function onClick() {
84
- return onShare({
85
- recipients: [{
86
- _id: 'r1',
87
- id: 'r1',
88
- displayName: 'Alice'
89
- }, {
90
- _id: 'r3',
91
- id: 'r3',
92
- displayName: 'Charlie'
93
- }],
94
- readOnlyRecipients: []
95
- });
96
- }
97
- }, "Share Other"), /*#__PURE__*/React.createElement("button", {
74
+ "data-testid": "pending-recipients-count"
75
+ }, pendingRecipients.length), /*#__PURE__*/React.createElement("span", {
76
+ "data-testid": "selected-option"
77
+ }, selectedOption), /*#__PURE__*/React.createElement("button", {
98
78
  "data-testid": "btn-send",
99
79
  onClick: onSend
100
80
  }, "Send"), /*#__PURE__*/React.createElement("button", {
101
- "data-testid": "btn-set-type-two-way",
102
- onClick: function onClick() {
103
- return onSetType('virtual-shared-drive-sharing-r2', 'two-way');
104
- }
105
- }, "Set Two-Way"), /*#__PURE__*/React.createElement("button", {
106
- "data-testid": "btn-set-type-one-way",
107
- onClick: function onClick() {
108
- return onSetType('virtual-shared-drive-sharing-r1', 'one-way');
109
- }
110
- }, "Set One-Way"), /*#__PURE__*/React.createElement("button", {
111
81
  "data-testid": "btn-revoke",
112
- onClick: function onClick() {
113
- return onRevoke('virtual-shared-drive-sharing-r1');
114
- }
115
- }, "Revoke"), /*#__PURE__*/React.createElement("button", {
116
- "data-testid": "btn-revoke-existing",
117
82
  onClick: function onClick() {
118
83
  return onRevoke({
119
84
  _id: 'folder-123'
120
85
  }, 'abc', 1);
121
86
  }
122
- }, "Revoke Existing"), /*#__PURE__*/React.createElement("button", {
87
+ }, "Revoke"), /*#__PURE__*/React.createElement("button", {
123
88
  "data-testid": "btn-close",
124
89
  onClick: onClose
125
- }, "Close"), /*#__PURE__*/React.createElement("button", {
126
- "data-testid": "btn-create-contact",
127
- onClick: function onClick() {
128
- return createContact({
129
- email: 'test@example.com'
130
- });
131
- }
132
- }, "Create Contact"));
90
+ }, "Close"));
133
91
  }
134
92
  };
135
93
  });
@@ -182,6 +140,13 @@ describe('FederatedFolderModal', function () {
182
140
  mockGetRecipients.mockReturnValue([]);
183
141
  client = createTestClient();
184
142
  sharingContextValue = createSharingContextValue();
143
+ usePendingRecipients.mockReturnValue({
144
+ pendingRecipients: [],
145
+ setPendingRecipients: jest.fn(),
146
+ selectedOption: 'readWrite',
147
+ setSelectedOption: jest.fn()
148
+ });
149
+ getOrCreateFromArray.mockResolvedValue([]);
185
150
  });
186
151
 
187
152
  var setup = function setup() {
@@ -276,9 +241,7 @@ describe('FederatedFolderModal', function () {
276
241
  }
277
242
  }, _callee4);
278
243
  })));
279
- });
280
- describe('onShare callback', function () {
281
- it('should update recipients when onShare is called', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
244
+ it('should pass selectedOption from usePendingRecipients', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
282
245
  var _setup5, getByTestId;
283
246
 
284
247
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
@@ -287,93 +250,83 @@ describe('FederatedFolderModal', function () {
287
250
  _setup5 = setup(), getByTestId = _setup5.getByTestId;
288
251
  _context5.next = 3;
289
252
  return waitFor(function () {
290
- expect(getByTestId('recipients-count').textContent).toBe('0');
253
+ expect(getByTestId('selected-option').textContent).toBe('readWrite');
291
254
  });
292
255
 
293
256
  case 3:
294
- fireEvent.click(getByTestId('btn-share'));
295
- _context5.next = 6;
296
- return waitFor(function () {
297
- expect(getByTestId('recipients-count').textContent).toBe('2');
298
- });
299
-
300
- case 6:
301
257
  case "end":
302
258
  return _context5.stop();
303
259
  }
304
260
  }, _callee5);
305
261
  })));
306
- it('should accumulate recipients when onShare is called multiple times', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
262
+ });
263
+ describe('onSend callback', function () {
264
+ var pendingRecipient = {
265
+ name: 'Alice',
266
+ email: 'alice@example.com'
267
+ };
268
+ it('should call onClose and skip share when there are no pending recipients', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
307
269
  var _setup6, getByTestId;
308
270
 
309
271
  return _regeneratorRuntime.wrap(function _callee6$(_context6) {
310
272
  while (1) switch (_context6.prev = _context6.next) {
311
273
  case 0:
274
+ // pendingRecipients defaults to [] via beforeEach
312
275
  _setup6 = setup(), getByTestId = _setup6.getByTestId;
313
276
  _context6.next = 3;
314
277
  return waitFor(function () {
315
- expect(getByTestId('recipients-count').textContent).toBe('0');
278
+ expect(getByTestId('btn-send')).toBeTruthy();
316
279
  });
317
280
 
318
281
  case 3:
319
- fireEvent.click(getByTestId('btn-share'));
282
+ fireEvent.click(getByTestId('btn-send'));
320
283
  _context6.next = 6;
321
284
  return waitFor(function () {
322
- expect(getByTestId('recipients-count').textContent).toBe('2');
285
+ expect(mockOnClose).toHaveBeenCalled();
286
+ expect(mockShare).not.toHaveBeenCalled();
323
287
  });
324
288
 
325
289
  case 6:
326
- fireEvent.click(getByTestId('btn-share-other'));
327
- _context6.next = 9;
328
- return waitFor(function () {
329
- expect(getByTestId('recipients-count').textContent).toBe('3');
330
- });
331
-
332
- case 9:
333
290
  case "end":
334
291
  return _context6.stop();
335
292
  }
336
293
  }, _callee6);
337
294
  })));
338
- });
339
- describe('onSend callback', function () {
340
295
  it('should call share with correct parameters', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
341
296
  var _setup7, getByTestId;
342
297
 
343
298
  return _regeneratorRuntime.wrap(function _callee7$(_context7) {
344
299
  while (1) switch (_context7.prev = _context7.next) {
345
300
  case 0:
301
+ usePendingRecipients.mockReturnValue({
302
+ pendingRecipients: [pendingRecipient],
303
+ setPendingRecipients: jest.fn(),
304
+ selectedOption: 'readWrite',
305
+ setSelectedOption: jest.fn()
306
+ });
307
+ getOrCreateFromArray.mockResolvedValue([pendingRecipient]);
346
308
  mockShare.mockResolvedValueOnce({});
347
309
  _setup7 = setup(), getByTestId = _setup7.getByTestId;
348
- _context7.next = 4;
310
+ _context7.next = 6;
349
311
  return waitFor(function () {
350
312
  expect(getByTestId('btn-send')).toBeTruthy();
351
313
  });
352
314
 
353
- case 4:
354
- fireEvent.click(getByTestId('btn-share'));
315
+ case 6:
355
316
  fireEvent.click(getByTestId('btn-send'));
356
- _context7.next = 8;
317
+ _context7.next = 9;
357
318
  return waitFor(function () {
358
319
  expect(mockShare).toHaveBeenCalledWith({
359
320
  description: 'My Test Folder',
360
321
  document: mockDocument,
361
- recipients: [{
362
- _id: 'r1',
363
- id: 'r1',
364
- displayName: 'Alice'
365
- }],
366
- readOnlyRecipients: [{
367
- _id: 'r2',
368
- id: 'r2',
369
- displayName: 'Bob'
370
- }],
322
+ recipients: [pendingRecipient],
323
+ readOnlyRecipients: [],
371
324
  sharedDrive: true,
372
325
  openSharing: false
373
326
  });
374
327
  });
375
328
 
376
- case 8:
329
+ case 9:
377
330
  case "end":
378
331
  return _context7.stop();
379
332
  }
@@ -385,16 +338,23 @@ describe('FederatedFolderModal', function () {
385
338
  return _regeneratorRuntime.wrap(function _callee8$(_context8) {
386
339
  while (1) switch (_context8.prev = _context8.next) {
387
340
  case 0:
341
+ usePendingRecipients.mockReturnValue({
342
+ pendingRecipients: [pendingRecipient],
343
+ setPendingRecipients: jest.fn(),
344
+ selectedOption: 'readWrite',
345
+ setSelectedOption: jest.fn()
346
+ });
347
+ getOrCreateFromArray.mockResolvedValue([pendingRecipient]);
388
348
  mockShare.mockResolvedValueOnce({});
389
349
  _setup8 = setup(), getByTestId = _setup8.getByTestId;
390
- _context8.next = 4;
350
+ _context8.next = 6;
391
351
  return waitFor(function () {
392
352
  expect(getByTestId('btn-send')).toBeTruthy();
393
353
  });
394
354
 
395
- case 4:
355
+ case 6:
396
356
  fireEvent.click(getByTestId('btn-send'));
397
- _context8.next = 7;
357
+ _context8.next = 9;
398
358
  return waitFor(function () {
399
359
  expect(mockShowAlert).toHaveBeenCalledWith({
400
360
  message: 'Folder has been shared',
@@ -404,7 +364,7 @@ describe('FederatedFolderModal', function () {
404
364
  expect(mockOnClose).toHaveBeenCalled();
405
365
  });
406
366
 
407
- case 7:
367
+ case 9:
408
368
  case "end":
409
369
  return _context8.stop();
410
370
  }
@@ -416,16 +376,23 @@ describe('FederatedFolderModal', function () {
416
376
  return _regeneratorRuntime.wrap(function _callee9$(_context9) {
417
377
  while (1) switch (_context9.prev = _context9.next) {
418
378
  case 0:
379
+ usePendingRecipients.mockReturnValue({
380
+ pendingRecipients: [pendingRecipient],
381
+ setPendingRecipients: jest.fn(),
382
+ selectedOption: 'readWrite',
383
+ setSelectedOption: jest.fn()
384
+ });
385
+ getOrCreateFromArray.mockResolvedValue([pendingRecipient]);
419
386
  mockShare.mockRejectedValueOnce(new Error('Share failed'));
420
387
  _setup9 = setup(), getByTestId = _setup9.getByTestId;
421
- _context9.next = 4;
388
+ _context9.next = 6;
422
389
  return waitFor(function () {
423
390
  expect(getByTestId('btn-send')).toBeTruthy();
424
391
  });
425
392
 
426
- case 4:
393
+ case 6:
427
394
  fireEvent.click(getByTestId('btn-send'));
428
- _context9.next = 7;
395
+ _context9.next = 9;
429
396
  return waitFor(function () {
430
397
  expect(mockShowAlert).toHaveBeenCalledWith({
431
398
  message: 'Error while sharing folder',
@@ -435,51 +402,45 @@ describe('FederatedFolderModal', function () {
435
402
  expect(mockOnClose).not.toHaveBeenCalled();
436
403
  });
437
404
 
438
- case 7:
405
+ case 9:
439
406
  case "end":
440
407
  return _context9.stop();
441
408
  }
442
409
  }, _callee9);
443
410
  })));
444
411
  });
445
- describe('onSetType callback', function () {
446
- it('should move recipient from readOnlyRecipients to recipients when setting two-way', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
412
+ describe('onRevoke callback', function () {
413
+ it('should call revoke from sharing context for existing members', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
447
414
  var _setup10, getByTestId;
448
415
 
449
416
  return _regeneratorRuntime.wrap(function _callee10$(_context10) {
450
417
  while (1) switch (_context10.prev = _context10.next) {
451
418
  case 0:
419
+ mockRevoke.mockResolvedValueOnce({});
452
420
  _setup10 = setup(), getByTestId = _setup10.getByTestId;
453
- _context10.next = 3;
454
- return waitFor(function () {
455
- expect(getByTestId('btn-share')).toBeTruthy();
456
- });
457
-
458
- case 3:
459
- fireEvent.click(getByTestId('btn-share')); // After btn-share: combined recipients = 2 (1 readWrite + 1 readOnly)
460
-
461
- _context10.next = 6;
421
+ _context10.next = 4;
462
422
  return waitFor(function () {
463
- expect(getByTestId('recipients-count').textContent).toBe('2');
464
- expect(getByTestId('readOnly-recipients-count').textContent).toBe('1');
423
+ expect(getByTestId('dumb-modal')).toBeTruthy();
465
424
  });
466
425
 
467
- case 6:
468
- fireEvent.click(getByTestId('btn-set-type-two-way')); // After setting two-way: Bob moves from readOnlyRecipients to recipients
469
-
470
- _context10.next = 9;
426
+ case 4:
427
+ fireEvent.click(getByTestId('btn-revoke'));
428
+ _context10.next = 7;
471
429
  return waitFor(function () {
472
- expect(getByTestId('recipients-count').textContent).toBe('2');
473
- expect(getByTestId('readOnly-recipients-count').textContent).toBe('0');
430
+ expect(mockRevoke).toHaveBeenCalledWith({
431
+ _id: 'folder-123'
432
+ }, 'abc', 1);
474
433
  });
475
434
 
476
- case 9:
435
+ case 7:
477
436
  case "end":
478
437
  return _context10.stop();
479
438
  }
480
439
  }, _callee10);
481
440
  })));
482
- it('should move recipient from recipients to readOnlyRecipients when setting one-way', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
441
+ });
442
+ describe('onClose callback', function () {
443
+ it('should call onClose when close button is clicked', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
483
444
  var _setup11, getByTestId;
484
445
 
485
446
  return _regeneratorRuntime.wrap(function _callee11$(_context11) {
@@ -487,79 +448,6 @@ describe('FederatedFolderModal', function () {
487
448
  case 0:
488
449
  _setup11 = setup(), getByTestId = _setup11.getByTestId;
489
450
  _context11.next = 3;
490
- return waitFor(function () {
491
- expect(getByTestId('btn-share')).toBeTruthy();
492
- });
493
-
494
- case 3:
495
- fireEvent.click(getByTestId('btn-share')); // After btn-share: combined recipients = 2 (1 readWrite + 1 readOnly)
496
-
497
- _context11.next = 6;
498
- return waitFor(function () {
499
- expect(getByTestId('recipients-count').textContent).toBe('2');
500
- expect(getByTestId('readOnly-recipients-count').textContent).toBe('1');
501
- });
502
-
503
- case 6:
504
- fireEvent.click(getByTestId('btn-set-type-one-way')); // After setting one-way: Alice moves from recipients to readOnlyRecipients
505
- // Combined count stays at 2, but readOnlyRecipients increases from 1 to 2
506
-
507
- _context11.next = 9;
508
- return waitFor(function () {
509
- expect(getByTestId('recipients-count').textContent).toBe('2');
510
- expect(getByTestId('readOnly-recipients-count').textContent).toBe('2');
511
- });
512
-
513
- case 9:
514
- case "end":
515
- return _context11.stop();
516
- }
517
- }, _callee11);
518
- })));
519
- });
520
- describe('onRevoke callback', function () {
521
- it('should remove recipient from both lists', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
522
- var _setup12, getByTestId;
523
-
524
- return _regeneratorRuntime.wrap(function _callee12$(_context12) {
525
- while (1) switch (_context12.prev = _context12.next) {
526
- case 0:
527
- _setup12 = setup(), getByTestId = _setup12.getByTestId;
528
- _context12.next = 3;
529
- return waitFor(function () {
530
- expect(getByTestId('btn-share')).toBeTruthy();
531
- });
532
-
533
- case 3:
534
- fireEvent.click(getByTestId('btn-share'));
535
- _context12.next = 6;
536
- return waitFor(function () {
537
- expect(getByTestId('recipients-count').textContent).toBe('2');
538
- });
539
-
540
- case 6:
541
- fireEvent.click(getByTestId('btn-revoke'));
542
- _context12.next = 9;
543
- return waitFor(function () {
544
- expect(getByTestId('recipients-count').textContent).toBe('1');
545
- });
546
-
547
- case 9:
548
- case "end":
549
- return _context12.stop();
550
- }
551
- }, _callee12);
552
- })));
553
- });
554
- describe('onClose callback', function () {
555
- it('should call onClose when close button is clicked', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
556
- var _setup13, getByTestId;
557
-
558
- return _regeneratorRuntime.wrap(function _callee13$(_context13) {
559
- while (1) switch (_context13.prev = _context13.next) {
560
- case 0:
561
- _setup13 = setup(), getByTestId = _setup13.getByTestId;
562
- _context13.next = 3;
563
451
  return waitFor(function () {
564
452
  expect(getByTestId('btn-close')).toBeTruthy();
565
453
  });
@@ -570,9 +458,9 @@ describe('FederatedFolderModal', function () {
570
458
 
571
459
  case 5:
572
460
  case "end":
573
- return _context13.stop();
461
+ return _context11.stop();
574
462
  }
575
- }, _callee13);
463
+ }, _callee11);
576
464
  })));
577
465
  });
578
466
  describe('existing recipients', function () {
@@ -593,102 +481,24 @@ describe('FederatedFolderModal', function () {
593
481
  sharingId: 'abc',
594
482
  memberIndex: 1
595
483
  }];
596
- it('should display existing recipients from getRecipients', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
597
- var _setup14, getByTestId;
598
-
599
- return _regeneratorRuntime.wrap(function _callee14$(_context14) {
600
- while (1) switch (_context14.prev = _context14.next) {
601
- case 0:
602
- mockGetRecipients.mockReturnValue(existingRecipients);
603
- _setup14 = setup(), getByTestId = _setup14.getByTestId;
604
- _context14.next = 4;
605
- return waitFor(function () {
606
- expect(getByTestId('recipients-count').textContent).toBe('2');
607
- });
608
-
609
- case 4:
610
- case "end":
611
- return _context14.stop();
612
- }
613
- }, _callee14);
614
- })));
615
- it('should pass existing recipients as currentRecipients', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15() {
616
- var _setup15, getByTestId;
484
+ it('should display existing recipients from getRecipients', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
485
+ var _setup12, getByTestId;
617
486
 
618
- return _regeneratorRuntime.wrap(function _callee15$(_context15) {
619
- while (1) switch (_context15.prev = _context15.next) {
487
+ return _regeneratorRuntime.wrap(function _callee12$(_context12) {
488
+ while (1) switch (_context12.prev = _context12.next) {
620
489
  case 0:
621
490
  mockGetRecipients.mockReturnValue(existingRecipients);
622
- _setup15 = setup(), getByTestId = _setup15.getByTestId;
623
- _context15.next = 4;
491
+ _setup12 = setup(), getByTestId = _setup12.getByTestId;
492
+ _context12.next = 4;
624
493
  return waitFor(function () {
625
494
  expect(getByTestId('recipients-count').textContent).toBe('2');
626
495
  });
627
496
 
628
497
  case 4:
629
498
  case "end":
630
- return _context15.stop();
631
- }
632
- }, _callee15);
633
- })));
634
- it('should call revoke for existing member', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16() {
635
- var _setup16, getByTestId;
636
-
637
- return _regeneratorRuntime.wrap(function _callee16$(_context16) {
638
- while (1) switch (_context16.prev = _context16.next) {
639
- case 0:
640
- mockGetRecipients.mockReturnValue(existingRecipients);
641
- mockRevoke.mockResolvedValueOnce({});
642
- _setup16 = setup(), getByTestId = _setup16.getByTestId;
643
- _context16.next = 5;
644
- return waitFor(function () {
645
- expect(getByTestId('dumb-modal')).toBeTruthy();
646
- });
647
-
648
- case 5:
649
- // Simulate revoke of an existing member (non-virtual-shared-drive index)
650
- fireEvent.click(getByTestId('btn-revoke-existing'));
651
- _context16.next = 8;
652
- return waitFor(function () {
653
- expect(mockRevoke).toHaveBeenCalledWith({
654
- _id: 'folder-123'
655
- }, 'abc', 1);
656
- });
657
-
658
- case 8:
659
- case "end":
660
- return _context16.stop();
661
- }
662
- }, _callee16);
663
- })));
664
- });
665
- describe('createContact callback', function () {
666
- it('should call client.create when creating a contact', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17() {
667
- var _setup17, getByTestId;
668
-
669
- return _regeneratorRuntime.wrap(function _callee17$(_context17) {
670
- while (1) switch (_context17.prev = _context17.next) {
671
- case 0:
672
- _setup17 = setup(), getByTestId = _setup17.getByTestId;
673
- _context17.next = 3;
674
- return waitFor(function () {
675
- expect(getByTestId('btn-create-contact')).toBeTruthy();
676
- });
677
-
678
- case 3:
679
- fireEvent.click(getByTestId('btn-create-contact'));
680
- _context17.next = 6;
681
- return waitFor(function () {
682
- expect(client.create).toHaveBeenCalledWith('io.cozy.contacts', {
683
- email: 'test@example.com'
684
- });
685
- });
686
-
687
- case 6:
688
- case "end":
689
- return _context17.stop();
499
+ return _context12.stop();
690
500
  }
691
- }, _callee17);
501
+ }, _callee12);
692
502
  })));
693
503
  });
694
504
  });
@@ -2,17 +2,18 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
4
4
  import React, { useState, useRef } from 'react';
5
- import { useClient } from 'cozy-client';
6
5
  import ActionsMenu from 'cozy-ui/transpiled/react/ActionsMenu';
7
- import { makeActions, divider } from 'cozy-ui/transpiled/react/ActionsMenu/Actions';
6
+ import { makeActions } from 'cozy-ui/transpiled/react/ActionsMenu/Actions';
8
7
  import ActionsMenuMobileHeader from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuMobileHeader';
9
8
  import DropdownButton from 'cozy-ui/transpiled/react/DropdownButton';
9
+ import Icon from 'cozy-ui/transpiled/react/Icon';
10
+ import IconButton from 'cozy-ui/transpiled/react/IconButton';
11
+ import CrossCircleOutlineIcon from 'cozy-ui/transpiled/react/Icons/CrossCircleOutline';
10
12
  import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
11
13
  import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
12
14
  import Spinner from 'cozy-ui/transpiled/react/Spinner';
13
15
  import { useI18n } from 'twake-i18n';
14
16
  import { permission } from './actions/permission';
15
- import { revokeGroup as revokeGroupAction } from './actions/revokeGroup';
16
17
  import { useSharingContext } from '../../hooks/useSharingContext';
17
18
  import { GroupAvatar } from '../Avatar/GroupAvatar';
18
19
 
@@ -31,7 +32,6 @@ var GroupRecipientPermissions = function GroupRecipientPermissions(_ref) {
31
32
  t = _useI18n.t;
32
33
 
33
34
  var buttonRef = useRef();
34
- var client = useClient();
35
35
 
36
36
  var _useSharingContext = useSharingContext(),
37
37
  revokeGroup = _useSharingContext.revokeGroup,
@@ -96,12 +96,9 @@ var GroupRecipientPermissions = function GroupRecipientPermissions(_ref) {
96
96
  }();
97
97
 
98
98
  var type = isReadOnly ? 'one-way' : 'two-way';
99
- var actions = makeActions([permission, divider, revokeGroupAction], {
100
- client: client,
99
+ var actions = makeActions([permission], {
101
100
  t: t,
102
- type: type,
103
- isOwner: isOwner,
104
- handleRevocation: handleRevocation
101
+ type: type
105
102
  });
106
103
  return /*#__PURE__*/React.createElement("div", {
107
104
  className: className
@@ -111,7 +108,7 @@ var GroupRecipientPermissions = function GroupRecipientPermissions(_ref) {
111
108
  "aria-haspopup": "true",
112
109
  onClick: toggleMenu,
113
110
  textVariant: "body2"
114
- }, t("Share.type.".concat(type)).toLowerCase()), /*#__PURE__*/React.createElement(ActionsMenu, {
111
+ }, t("Share.type.".concat(type))), /*#__PURE__*/React.createElement(ActionsMenu, {
115
112
  ref: buttonRef,
116
113
  open: isMenuDisplayed,
117
114
  actions: actions,
@@ -124,7 +121,14 @@ var GroupRecipientPermissions = function GroupRecipientPermissions(_ref) {
124
121
  primaryTypographyProps: {
125
122
  variant: 'h6'
126
123
  }
127
- })))));
124
+ }))), /*#__PURE__*/React.createElement(IconButton, {
125
+ onClick: handleRevocation,
126
+ size: "small",
127
+ className: "u-ml-half",
128
+ "aria-label": t('Share.members.revoke')
129
+ }, /*#__PURE__*/React.createElement(Icon, {
130
+ icon: CrossCircleOutlineIcon
131
+ }))));
128
132
  };
129
133
 
130
134
  export { GroupRecipientPermissions };