cozy-sharing 33.5.1 → 33.6.1
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 +17 -0
- package/dist/SharingProvider.spec.js +242 -113
- package/dist/components/FederatedFolder/FederatedFolderModal.js +1 -4
- package/dist/components/Recipient/LinkRecipient.js +40 -17
- package/dist/components/Recipient/LinkRecipientPermissions.js +7 -6
- package/dist/components/Recipient/MemberRecipient.js +1 -4
- package/dist/components/Recipient/MemberRecipientPermissions.js +4 -6
- package/dist/components/Recipient/RecipientConfirm.js +1 -4
- package/dist/components/Recipient/RecipientList.js +2 -0
- package/dist/components/ShareByEmail.js +1 -4
- package/dist/components/ShareDialogCozyToCozy.js +1 -4
- package/dist/components/ShareModal/ShareModal.js +1 -5
- package/dist/components/ShareModal/SharingDetailsModal.js +6 -38
- package/dist/components/SharedDrive/EditSharedDriveModal.js +1 -4
- package/dist/components/WhoHasAccess.js +4 -0
- package/dist/state.js +5 -4
- package/dist/state.spec.js +44 -27
- package/dist/styles/share.styl +0 -21
- package/dist/stylesheet.css +0 -22
- package/locales/en.json +1 -2
- package/locales/fr.json +1 -2
- package/locales/ru.json +1 -2
- package/locales/vi.json +1 -2
- package/package.json +2 -2
- package/src/SharingProvider.spec.jsx +115 -1
- package/src/components/Recipient/LinkRecipient.jsx +50 -15
- package/src/components/Recipient/LinkRecipientPermissions.jsx +27 -20
- package/src/components/Recipient/MemberRecipient.jsx +1 -1
- package/src/components/Recipient/MemberRecipientPermissions.jsx +10 -5
- package/src/components/Recipient/RecipientList.jsx +2 -0
- package/src/components/ShareModal/ShareModal.jsx +1 -5
- package/src/components/ShareModal/SharingDetailsModal.jsx +3 -47
- package/src/components/WhoHasAccess.jsx +3 -0
- package/src/state.js +5 -13
- package/src/state.spec.js +63 -29
- package/src/styles/share.styl +0 -21
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,23 @@
|
|
|
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
|
+
## [33.6.1](https://github.com/cozy/cozy-libs/compare/cozy-sharing@33.6.0...cozy-sharing@33.6.1) (2026-06-22)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- Forget owner-only shared drive sharings ([795eff2](https://github.com/cozy/cozy-libs/commit/795eff246218780d6315ae49d4b55dbe732c450b))
|
|
11
|
+
|
|
12
|
+
# [33.6.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@33.5.1...cozy-sharing@33.6.0) (2026-06-17)
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
- Add prop to enable a readonly list in WhoHasAccess ([9643520](https://github.com/cozy/cozy-libs/commit/9643520bfbd9d1da425176efec5e361bf5ef1498))
|
|
17
|
+
- Display read only modal (details modal) for B2B shared drive ([9960588](https://github.com/cozy/cozy-libs/commit/9960588289d67555f0a3cf3e0b24fd7c8fe222fc))
|
|
18
|
+
- Enable readonly display of link recipient ([c5146b0](https://github.com/cozy/cozy-libs/commit/c5146b094b17c7956419dd50b47b113b929daa29))
|
|
19
|
+
- Remove unwanted details from sharing details modal ([b067718](https://github.com/cozy/cozy-libs/commit/b0677189eeebe258177187ea98ce2f48b6af8777))
|
|
20
|
+
- Show "Owner" if owner or type otherwise when no menu in member ([b4ef094](https://github.com/cozy/cozy-libs/commit/b4ef0942ecba54a21f4ed0ed16ccc480a1e1525d))
|
|
21
|
+
- Show type instead of status when no menu in member ([ba87489](https://github.com/cozy/cozy-libs/commit/ba874890418899aeecdba41b792724dbae0ce7c9))
|
|
22
|
+
|
|
6
23
|
## [33.5.1](https://github.com/cozy/cozy-libs/compare/cozy-sharing@33.5.0...cozy-sharing@33.5.1) (2026-06-17)
|
|
7
24
|
|
|
8
25
|
### Bug Fixes
|
|
@@ -11,7 +11,7 @@ import React from 'react';
|
|
|
11
11
|
import { createMockClient } from 'cozy-client';
|
|
12
12
|
import { SharingProvider } from './SharingProvider';
|
|
13
13
|
import SharingContext from './context';
|
|
14
|
-
import reducer, { addSharingLink, getDocumentPermissions } from './state';
|
|
14
|
+
import reducer, { addSharingLink, getDocumentPermissions, getDocumentSharing, receiveSharings } from './state';
|
|
15
15
|
import AppLike from '../test/AppLike';
|
|
16
16
|
|
|
17
17
|
var AppWrapper = function AppWrapper(_ref) {
|
|
@@ -411,6 +411,135 @@ describe('updateDocumentPermissions', function () {
|
|
|
411
411
|
}, _callee7);
|
|
412
412
|
})));
|
|
413
413
|
});
|
|
414
|
+
describe('shared drive recipient revocation', function () {
|
|
415
|
+
var SHARED_DRIVE = {
|
|
416
|
+
_id: 'sharing_123',
|
|
417
|
+
id: 'sharing_123',
|
|
418
|
+
type: 'io.cozy.sharings',
|
|
419
|
+
attributes: {
|
|
420
|
+
drive: true,
|
|
421
|
+
owner: true,
|
|
422
|
+
description: 'Shared folder',
|
|
423
|
+
rules: [{
|
|
424
|
+
title: 'Shared folder',
|
|
425
|
+
doctype: 'io.cozy.files',
|
|
426
|
+
values: ['folder_123'],
|
|
427
|
+
add: 'none',
|
|
428
|
+
update: 'none',
|
|
429
|
+
remove: 'none'
|
|
430
|
+
}],
|
|
431
|
+
members: [{
|
|
432
|
+
status: 'owner',
|
|
433
|
+
email: 'owner@cozy.local',
|
|
434
|
+
instance: 'http://cozy.local'
|
|
435
|
+
}, {
|
|
436
|
+
status: 'pending',
|
|
437
|
+
email: 'recipient@cozy.local',
|
|
438
|
+
instance: 'http://recipient.cozy.local'
|
|
439
|
+
}]
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
var NEW_SHARING = _objectSpread(_objectSpread({}, SHARED_DRIVE), {}, {
|
|
444
|
+
_id: 'sharing_456',
|
|
445
|
+
id: 'sharing_456'
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
var document = {
|
|
449
|
+
_id: 'folder_123',
|
|
450
|
+
id: 'folder_123',
|
|
451
|
+
path: '/Shared folder'
|
|
452
|
+
};
|
|
453
|
+
var recipient = {
|
|
454
|
+
_id: 'contact_123',
|
|
455
|
+
id: 'contact_123',
|
|
456
|
+
_type: 'io.cozy.contacts',
|
|
457
|
+
email: 'recipient@cozy.local'
|
|
458
|
+
};
|
|
459
|
+
var provider;
|
|
460
|
+
var sharingCol;
|
|
461
|
+
beforeEach(function () {
|
|
462
|
+
var mockClient = createMockClient({});
|
|
463
|
+
|
|
464
|
+
mockClient.getStackClient = function () {
|
|
465
|
+
return {
|
|
466
|
+
uri: 'http://cozy.local'
|
|
467
|
+
};
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
mockClient.collection = jest.fn().mockReturnValue({});
|
|
471
|
+
provider = new SharingProvider({
|
|
472
|
+
client: mockClient
|
|
473
|
+
});
|
|
474
|
+
provider.state = _objectSpread(_objectSpread({}, provider.state), reducer(undefined, receiveSharings({
|
|
475
|
+
sharings: [SHARED_DRIVE]
|
|
476
|
+
})));
|
|
477
|
+
provider.dispatch = jest.fn(function (action) {
|
|
478
|
+
provider.state = _objectSpread(_objectSpread({}, provider.state), reducer(provider.state, action));
|
|
479
|
+
});
|
|
480
|
+
sharingCol = {
|
|
481
|
+
addRecipients: jest.fn(),
|
|
482
|
+
create: jest.fn().mockResolvedValue({
|
|
483
|
+
data: NEW_SHARING
|
|
484
|
+
}),
|
|
485
|
+
revokeRecipient: jest.fn().mockResolvedValue({})
|
|
486
|
+
};
|
|
487
|
+
provider.sharingCol = sharingCol;
|
|
488
|
+
});
|
|
489
|
+
it('forgets the shared drive when revoking its last recipient', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
490
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
491
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
492
|
+
case 0:
|
|
493
|
+
_context8.next = 2;
|
|
494
|
+
return provider.revoke(document, SHARED_DRIVE.id, 1);
|
|
495
|
+
|
|
496
|
+
case 2:
|
|
497
|
+
expect(sharingCol.revokeRecipient).toHaveBeenCalledWith(SHARED_DRIVE, 1);
|
|
498
|
+
expect(getDocumentSharing(provider.state, document.id)).toBeNull();
|
|
499
|
+
|
|
500
|
+
case 4:
|
|
501
|
+
case "end":
|
|
502
|
+
return _context8.stop();
|
|
503
|
+
}
|
|
504
|
+
}, _callee8);
|
|
505
|
+
})));
|
|
506
|
+
it('creates a new sharing when re-adding after the last recipient was revoked', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
|
|
507
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
508
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
509
|
+
case 0:
|
|
510
|
+
_context9.next = 2;
|
|
511
|
+
return provider.revoke(document, SHARED_DRIVE.id, 1);
|
|
512
|
+
|
|
513
|
+
case 2:
|
|
514
|
+
_context9.next = 4;
|
|
515
|
+
return provider.share({
|
|
516
|
+
document: document,
|
|
517
|
+
recipients: [recipient],
|
|
518
|
+
readOnlyRecipients: [],
|
|
519
|
+
description: 'Shared folder',
|
|
520
|
+
openSharing: true,
|
|
521
|
+
sharedDrive: true
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
case 4:
|
|
525
|
+
expect(sharingCol.addRecipients).not.toHaveBeenCalled();
|
|
526
|
+
expect(sharingCol.create).toHaveBeenCalledWith({
|
|
527
|
+
document: document,
|
|
528
|
+
recipients: [recipient],
|
|
529
|
+
readOnlyRecipients: [],
|
|
530
|
+
description: 'Shared folder',
|
|
531
|
+
previewPath: '/preview',
|
|
532
|
+
openSharing: true,
|
|
533
|
+
sharedDrive: true
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
case 6:
|
|
537
|
+
case "end":
|
|
538
|
+
return _context9.stop();
|
|
539
|
+
}
|
|
540
|
+
}, _callee9);
|
|
541
|
+
})));
|
|
542
|
+
});
|
|
414
543
|
describe('fetchSharedDriveSharingLinks', function () {
|
|
415
544
|
var PERM_DRIVE_FILE = {
|
|
416
545
|
type: 'io.cozy.permissions',
|
|
@@ -434,10 +563,10 @@ describe('fetchSharedDriveSharingLinks', function () {
|
|
|
434
563
|
id: 'file_in_drive',
|
|
435
564
|
driveId: 'drive_123'
|
|
436
565
|
};
|
|
437
|
-
it('fetches shared drive sharing links by file id', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
566
|
+
it('fetches shared drive sharing links by file id', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
|
|
438
567
|
var mockFindLinksByIds, mockClient, provider, result, permissions;
|
|
439
|
-
return _regeneratorRuntime.wrap(function
|
|
440
|
-
while (1) switch (
|
|
568
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
569
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
441
570
|
case 0:
|
|
442
571
|
mockFindLinksByIds = jest.fn().mockResolvedValue({
|
|
443
572
|
data: [PERM_DRIVE_FILE]
|
|
@@ -453,11 +582,11 @@ describe('fetchSharedDriveSharingLinks', function () {
|
|
|
453
582
|
provider.dispatch = jest.fn(function (action) {
|
|
454
583
|
provider.state = reducer(provider.state, action);
|
|
455
584
|
});
|
|
456
|
-
|
|
585
|
+
_context10.next = 8;
|
|
457
586
|
return provider.fetchSharedDriveSharingLinks(driveFile);
|
|
458
587
|
|
|
459
588
|
case 8:
|
|
460
|
-
result =
|
|
589
|
+
result = _context10.sent;
|
|
461
590
|
expect(mockClient.collection).toHaveBeenCalledWith('io.cozy.permissions', {
|
|
462
591
|
driveId: 'drive_123'
|
|
463
592
|
});
|
|
@@ -470,14 +599,14 @@ describe('fetchSharedDriveSharingLinks', function () {
|
|
|
470
599
|
|
|
471
600
|
case 16:
|
|
472
601
|
case "end":
|
|
473
|
-
return
|
|
602
|
+
return _context10.stop();
|
|
474
603
|
}
|
|
475
|
-
},
|
|
604
|
+
}, _callee10);
|
|
476
605
|
})));
|
|
477
|
-
it('returns an empty array and skips the API call for non-shared-drive documents', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
606
|
+
it('returns an empty array and skips the API call for non-shared-drive documents', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
|
|
478
607
|
var mockClient, findLinksByIds, provider, result;
|
|
479
|
-
return _regeneratorRuntime.wrap(function
|
|
480
|
-
while (1) switch (
|
|
608
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
609
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
481
610
|
case 0:
|
|
482
611
|
mockClient = createMockClient({});
|
|
483
612
|
findLinksByIds = jest.fn();
|
|
@@ -488,27 +617,27 @@ describe('fetchSharedDriveSharingLinks', function () {
|
|
|
488
617
|
client: mockClient
|
|
489
618
|
});
|
|
490
619
|
provider.dispatch = jest.fn();
|
|
491
|
-
|
|
620
|
+
_context11.next = 7;
|
|
492
621
|
return provider.fetchSharedDriveSharingLinks({
|
|
493
622
|
_id: 'regular_file'
|
|
494
623
|
});
|
|
495
624
|
|
|
496
625
|
case 7:
|
|
497
|
-
result =
|
|
626
|
+
result = _context11.sent;
|
|
498
627
|
expect(result).toEqual([]);
|
|
499
628
|
expect(findLinksByIds).not.toHaveBeenCalled();
|
|
500
629
|
expect(provider.dispatch).not.toHaveBeenCalled();
|
|
501
630
|
|
|
502
631
|
case 11:
|
|
503
632
|
case "end":
|
|
504
|
-
return
|
|
633
|
+
return _context11.stop();
|
|
505
634
|
}
|
|
506
|
-
},
|
|
635
|
+
}, _callee11);
|
|
507
636
|
})));
|
|
508
|
-
it('uses document.id as a fallback when _id is missing', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
637
|
+
it('uses document.id as a fallback when _id is missing', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
|
|
509
638
|
var mockFindLinksByIds, mockClient, provider;
|
|
510
|
-
return _regeneratorRuntime.wrap(function
|
|
511
|
-
while (1) switch (
|
|
639
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
640
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
512
641
|
case 0:
|
|
513
642
|
mockFindLinksByIds = jest.fn().mockResolvedValue({
|
|
514
643
|
data: [PERM_DRIVE_FILE]
|
|
@@ -524,7 +653,7 @@ describe('fetchSharedDriveSharingLinks', function () {
|
|
|
524
653
|
provider.dispatch = jest.fn(function (action) {
|
|
525
654
|
provider.state = reducer(provider.state, action);
|
|
526
655
|
});
|
|
527
|
-
|
|
656
|
+
_context12.next = 8;
|
|
528
657
|
return provider.fetchSharedDriveSharingLinks({
|
|
529
658
|
id: 'file_in_drive',
|
|
530
659
|
driveId: 'drive_123'
|
|
@@ -535,14 +664,14 @@ describe('fetchSharedDriveSharingLinks', function () {
|
|
|
535
664
|
|
|
536
665
|
case 9:
|
|
537
666
|
case "end":
|
|
538
|
-
return
|
|
667
|
+
return _context12.stop();
|
|
539
668
|
}
|
|
540
|
-
},
|
|
669
|
+
}, _callee12);
|
|
541
670
|
})));
|
|
542
|
-
it('does not dispatch when the response has no data', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
671
|
+
it('does not dispatch when the response has no data', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
|
|
543
672
|
var mockFindLinksByIds, mockClient, provider, result;
|
|
544
|
-
return _regeneratorRuntime.wrap(function
|
|
545
|
-
while (1) switch (
|
|
673
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
674
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
546
675
|
case 0:
|
|
547
676
|
mockFindLinksByIds = jest.fn().mockResolvedValue({
|
|
548
677
|
data: []
|
|
@@ -555,19 +684,19 @@ describe('fetchSharedDriveSharingLinks', function () {
|
|
|
555
684
|
client: mockClient
|
|
556
685
|
});
|
|
557
686
|
provider.dispatch = jest.fn();
|
|
558
|
-
|
|
687
|
+
_context13.next = 7;
|
|
559
688
|
return provider.fetchSharedDriveSharingLinks(driveFile);
|
|
560
689
|
|
|
561
690
|
case 7:
|
|
562
|
-
result =
|
|
691
|
+
result = _context13.sent;
|
|
563
692
|
expect(result).toEqual([]);
|
|
564
693
|
expect(provider.dispatch).not.toHaveBeenCalled();
|
|
565
694
|
|
|
566
695
|
case 10:
|
|
567
696
|
case "end":
|
|
568
|
-
return
|
|
697
|
+
return _context13.stop();
|
|
569
698
|
}
|
|
570
|
-
},
|
|
699
|
+
}, _callee13);
|
|
571
700
|
})));
|
|
572
701
|
});
|
|
573
702
|
describe('shareByLink shared drive 409 recovery', function () {
|
|
@@ -593,10 +722,10 @@ describe('shareByLink shared drive 409 recovery', function () {
|
|
|
593
722
|
id: 'file_in_drive',
|
|
594
723
|
driveId: 'drive_123'
|
|
595
724
|
};
|
|
596
|
-
it('falls back to fetching existing links when create returns 409', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
725
|
+
it('falls back to fetching existing links when create returns 409', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
|
|
597
726
|
var conflict, mockCreateSharingLink, mockFindLinksByIds, mockClient, provider, resp;
|
|
598
|
-
return _regeneratorRuntime.wrap(function
|
|
599
|
-
while (1) switch (
|
|
727
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
728
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
600
729
|
case 0:
|
|
601
730
|
conflict = Object.assign(new Error('Conflict'), {
|
|
602
731
|
status: 409
|
|
@@ -617,27 +746,27 @@ describe('shareByLink shared drive 409 recovery', function () {
|
|
|
617
746
|
provider.dispatch = jest.fn(function (action) {
|
|
618
747
|
provider.state = reducer(provider.state, action);
|
|
619
748
|
});
|
|
620
|
-
|
|
749
|
+
_context14.next = 10;
|
|
621
750
|
return provider.shareByLink(driveFile, {
|
|
622
751
|
verbs: ['GET']
|
|
623
752
|
});
|
|
624
753
|
|
|
625
754
|
case 10:
|
|
626
|
-
resp =
|
|
755
|
+
resp = _context14.sent;
|
|
627
756
|
expect(mockCreateSharingLink).toHaveBeenCalled();
|
|
628
757
|
expect(mockFindLinksByIds).toHaveBeenCalledWith(['file_in_drive']);
|
|
629
758
|
expect(resp.data.id).toBe(PERM_DRIVE_FILE.id);
|
|
630
759
|
|
|
631
760
|
case 14:
|
|
632
761
|
case "end":
|
|
633
|
-
return
|
|
762
|
+
return _context14.stop();
|
|
634
763
|
}
|
|
635
|
-
},
|
|
764
|
+
}, _callee14);
|
|
636
765
|
})));
|
|
637
|
-
it('does not duplicate existing links when 409 recovery refetches them', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
766
|
+
it('does not duplicate existing links when 409 recovery refetches them', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15() {
|
|
638
767
|
var conflict, mockCreateSharingLink, mockFindLinksByIds, mockClient, provider, resp, permissions;
|
|
639
|
-
return _regeneratorRuntime.wrap(function
|
|
640
|
-
while (1) switch (
|
|
768
|
+
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
769
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
641
770
|
case 0:
|
|
642
771
|
conflict = Object.assign(new Error('Conflict'), {
|
|
643
772
|
status: 409
|
|
@@ -658,13 +787,13 @@ describe('shareByLink shared drive 409 recovery', function () {
|
|
|
658
787
|
provider.dispatch = jest.fn(function (action) {
|
|
659
788
|
provider.state = reducer(provider.state, action);
|
|
660
789
|
});
|
|
661
|
-
|
|
790
|
+
_context15.next = 10;
|
|
662
791
|
return provider.shareByLink(driveFile, {
|
|
663
792
|
verbs: ['GET']
|
|
664
793
|
});
|
|
665
794
|
|
|
666
795
|
case 10:
|
|
667
|
-
resp =
|
|
796
|
+
resp = _context15.sent;
|
|
668
797
|
permissions = getDocumentPermissions(provider.state, 'file_in_drive');
|
|
669
798
|
expect(resp.data.id).toBe(PERM_DRIVE_FILE.id);
|
|
670
799
|
expect(provider.dispatch).not.toHaveBeenCalled();
|
|
@@ -672,14 +801,14 @@ describe('shareByLink shared drive 409 recovery', function () {
|
|
|
672
801
|
|
|
673
802
|
case 15:
|
|
674
803
|
case "end":
|
|
675
|
-
return
|
|
804
|
+
return _context15.stop();
|
|
676
805
|
}
|
|
677
|
-
},
|
|
806
|
+
}, _callee15);
|
|
678
807
|
})));
|
|
679
|
-
it('rethrows the original error when 409 happens and no link is found', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
808
|
+
it('rethrows the original error when 409 happens and no link is found', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16() {
|
|
680
809
|
var conflict, mockCreateSharingLink, mockFindLinksByIds, mockClient, provider;
|
|
681
|
-
return _regeneratorRuntime.wrap(function
|
|
682
|
-
while (1) switch (
|
|
810
|
+
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
811
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
683
812
|
case 0:
|
|
684
813
|
conflict = Object.assign(new Error('Conflict'), {
|
|
685
814
|
status: 409
|
|
@@ -698,16 +827,16 @@ describe('shareByLink shared drive 409 recovery', function () {
|
|
|
698
827
|
});
|
|
699
828
|
provider.state = reducer();
|
|
700
829
|
provider.dispatch = jest.fn();
|
|
701
|
-
|
|
830
|
+
_context16.next = 10;
|
|
702
831
|
return expect(provider.shareByLink(driveFile, {
|
|
703
832
|
verbs: ['GET']
|
|
704
833
|
})).rejects.toBe(conflict);
|
|
705
834
|
|
|
706
835
|
case 10:
|
|
707
836
|
case "end":
|
|
708
|
-
return
|
|
837
|
+
return _context16.stop();
|
|
709
838
|
}
|
|
710
|
-
},
|
|
839
|
+
}, _callee16);
|
|
711
840
|
})));
|
|
712
841
|
});
|
|
713
842
|
describe('updateSharingMemberType', function () {
|
|
@@ -748,37 +877,37 @@ describe('updateSharingMemberType', function () {
|
|
|
748
877
|
instance.state = _objectSpread(_objectSpread({}, instance.state), reducer(instance.state, action));
|
|
749
878
|
});
|
|
750
879
|
});
|
|
751
|
-
it('should throw when sharing is not found', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
752
|
-
return _regeneratorRuntime.wrap(function
|
|
753
|
-
while (1) switch (
|
|
880
|
+
it('should throw when sharing is not found', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17() {
|
|
881
|
+
return _regeneratorRuntime.wrap(function _callee17$(_context17) {
|
|
882
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
754
883
|
case 0:
|
|
755
|
-
|
|
884
|
+
_context17.next = 2;
|
|
756
885
|
return expect(instance.updateSharingMemberType('unknown-id', 1, 'one-way')).rejects.toThrow('Sharing not found');
|
|
757
886
|
|
|
758
887
|
case 2:
|
|
759
888
|
case "end":
|
|
760
|
-
return
|
|
889
|
+
return _context17.stop();
|
|
761
890
|
}
|
|
762
|
-
},
|
|
891
|
+
}, _callee17);
|
|
763
892
|
})));
|
|
764
|
-
it('should throw when member is not found', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
765
|
-
return _regeneratorRuntime.wrap(function
|
|
766
|
-
while (1) switch (
|
|
893
|
+
it('should throw when member is not found', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18() {
|
|
894
|
+
return _regeneratorRuntime.wrap(function _callee18$(_context18) {
|
|
895
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
767
896
|
case 0:
|
|
768
|
-
|
|
897
|
+
_context18.next = 2;
|
|
769
898
|
return expect(instance.updateSharingMemberType('sharing-123', 99, 'one-way')).rejects.toThrow('Member not found');
|
|
770
899
|
|
|
771
900
|
case 2:
|
|
772
901
|
case "end":
|
|
773
|
-
return
|
|
902
|
+
return _context18.stop();
|
|
774
903
|
}
|
|
775
|
-
},
|
|
904
|
+
}, _callee18);
|
|
776
905
|
})));
|
|
777
|
-
it('should call setReadOnly when switching to one-way', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
778
|
-
return _regeneratorRuntime.wrap(function
|
|
779
|
-
while (1) switch (
|
|
906
|
+
it('should call setReadOnly when switching to one-way', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19() {
|
|
907
|
+
return _regeneratorRuntime.wrap(function _callee19$(_context19) {
|
|
908
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
780
909
|
case 0:
|
|
781
|
-
|
|
910
|
+
_context19.next = 2;
|
|
782
911
|
return instance.updateSharingMemberType('sharing-123', 1, 'one-way');
|
|
783
912
|
|
|
784
913
|
case 2:
|
|
@@ -787,15 +916,15 @@ describe('updateSharingMemberType', function () {
|
|
|
787
916
|
|
|
788
917
|
case 4:
|
|
789
918
|
case "end":
|
|
790
|
-
return
|
|
919
|
+
return _context19.stop();
|
|
791
920
|
}
|
|
792
|
-
},
|
|
921
|
+
}, _callee19);
|
|
793
922
|
})));
|
|
794
|
-
it('should call setReadWrite when switching to two-way', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
795
|
-
return _regeneratorRuntime.wrap(function
|
|
796
|
-
while (1) switch (
|
|
923
|
+
it('should call setReadWrite when switching to two-way', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20() {
|
|
924
|
+
return _regeneratorRuntime.wrap(function _callee20$(_context20) {
|
|
925
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
797
926
|
case 0:
|
|
798
|
-
|
|
927
|
+
_context20.next = 2;
|
|
799
928
|
return instance.updateSharingMemberType('sharing-123', 1, 'two-way');
|
|
800
929
|
|
|
801
930
|
case 2:
|
|
@@ -804,15 +933,15 @@ describe('updateSharingMemberType', function () {
|
|
|
804
933
|
|
|
805
934
|
case 4:
|
|
806
935
|
case "end":
|
|
807
|
-
return
|
|
936
|
+
return _context20.stop();
|
|
808
937
|
}
|
|
809
|
-
},
|
|
938
|
+
}, _callee20);
|
|
810
939
|
})));
|
|
811
|
-
it('should optimistically dispatch a state update when switching to one-way', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
812
|
-
return _regeneratorRuntime.wrap(function
|
|
813
|
-
while (1) switch (
|
|
940
|
+
it('should optimistically dispatch a state update when switching to one-way', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21() {
|
|
941
|
+
return _regeneratorRuntime.wrap(function _callee21$(_context21) {
|
|
942
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
814
943
|
case 0:
|
|
815
|
-
|
|
944
|
+
_context21.next = 2;
|
|
816
945
|
return instance.updateSharingMemberType('sharing-123', 1, 'one-way');
|
|
817
946
|
|
|
818
947
|
case 2:
|
|
@@ -829,15 +958,15 @@ describe('updateSharingMemberType', function () {
|
|
|
829
958
|
|
|
830
959
|
case 3:
|
|
831
960
|
case "end":
|
|
832
|
-
return
|
|
961
|
+
return _context21.stop();
|
|
833
962
|
}
|
|
834
|
-
},
|
|
963
|
+
}, _callee21);
|
|
835
964
|
})));
|
|
836
|
-
it('should optimistically dispatch a state update when switching to two-way', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
837
|
-
return _regeneratorRuntime.wrap(function
|
|
838
|
-
while (1) switch (
|
|
965
|
+
it('should optimistically dispatch a state update when switching to two-way', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22() {
|
|
966
|
+
return _regeneratorRuntime.wrap(function _callee22$(_context22) {
|
|
967
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
839
968
|
case 0:
|
|
840
|
-
|
|
969
|
+
_context22.next = 2;
|
|
841
970
|
return instance.updateSharingMemberType('sharing-123', 1, 'two-way');
|
|
842
971
|
|
|
843
972
|
case 2:
|
|
@@ -854,44 +983,44 @@ describe('updateSharingMemberType', function () {
|
|
|
854
983
|
|
|
855
984
|
case 3:
|
|
856
985
|
case "end":
|
|
857
|
-
return
|
|
986
|
+
return _context22.stop();
|
|
858
987
|
}
|
|
859
|
-
},
|
|
988
|
+
}, _callee22);
|
|
860
989
|
})));
|
|
861
|
-
it('should rethrow error if setReadOnly fails', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
862
|
-
return _regeneratorRuntime.wrap(function
|
|
863
|
-
while (1) switch (
|
|
990
|
+
it('should rethrow error if setReadOnly fails', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23() {
|
|
991
|
+
return _regeneratorRuntime.wrap(function _callee23$(_context23) {
|
|
992
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
864
993
|
case 0:
|
|
865
994
|
instance.sharingCol.setReadOnly.mockRejectedValue(new Error('Network error'));
|
|
866
|
-
|
|
995
|
+
_context23.next = 3;
|
|
867
996
|
return expect(instance.updateSharingMemberType('sharing-123', 1, 'one-way')).rejects.toThrow('Network error');
|
|
868
997
|
|
|
869
998
|
case 3:
|
|
870
999
|
case "end":
|
|
871
|
-
return
|
|
1000
|
+
return _context23.stop();
|
|
872
1001
|
}
|
|
873
|
-
},
|
|
1002
|
+
}, _callee23);
|
|
874
1003
|
})));
|
|
875
|
-
it('should rethrow error if setReadWrite fails', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
876
|
-
return _regeneratorRuntime.wrap(function
|
|
877
|
-
while (1) switch (
|
|
1004
|
+
it('should rethrow error if setReadWrite fails', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24() {
|
|
1005
|
+
return _regeneratorRuntime.wrap(function _callee24$(_context24) {
|
|
1006
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
878
1007
|
case 0:
|
|
879
1008
|
instance.sharingCol.setReadWrite.mockRejectedValue(new Error('Network error'));
|
|
880
|
-
|
|
1009
|
+
_context24.next = 3;
|
|
881
1010
|
return expect(instance.updateSharingMemberType('sharing-123', 1, 'two-way')).rejects.toThrow('Network error');
|
|
882
1011
|
|
|
883
1012
|
case 3:
|
|
884
1013
|
case "end":
|
|
885
|
-
return
|
|
1014
|
+
return _context24.stop();
|
|
886
1015
|
}
|
|
887
|
-
},
|
|
1016
|
+
}, _callee24);
|
|
888
1017
|
})));
|
|
889
|
-
it('should rollback optimistic state update if API call fails', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
890
|
-
return _regeneratorRuntime.wrap(function
|
|
891
|
-
while (1) switch (
|
|
1018
|
+
it('should rollback optimistic state update if API call fails', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25() {
|
|
1019
|
+
return _regeneratorRuntime.wrap(function _callee25$(_context25) {
|
|
1020
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
892
1021
|
case 0:
|
|
893
1022
|
instance.sharingCol.setReadOnly.mockRejectedValue(new Error('Network error'));
|
|
894
|
-
|
|
1023
|
+
_context25.next = 3;
|
|
895
1024
|
return expect(instance.updateSharingMemberType('sharing-123', 1, 'one-way')).rejects.toThrow('Network error');
|
|
896
1025
|
|
|
897
1026
|
case 3:
|
|
@@ -918,14 +1047,14 @@ describe('updateSharingMemberType', function () {
|
|
|
918
1047
|
|
|
919
1048
|
case 5:
|
|
920
1049
|
case "end":
|
|
921
|
-
return
|
|
1050
|
+
return _context25.stop();
|
|
922
1051
|
}
|
|
923
|
-
},
|
|
1052
|
+
}, _callee25);
|
|
924
1053
|
})));
|
|
925
|
-
it('should preserve realtime changes when rolling back an API failure', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1054
|
+
it('should preserve realtime changes when rolling back an API failure', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27() {
|
|
926
1055
|
var realtimeSharing;
|
|
927
|
-
return _regeneratorRuntime.wrap(function
|
|
928
|
-
while (1) switch (
|
|
1056
|
+
return _regeneratorRuntime.wrap(function _callee27$(_context27) {
|
|
1057
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
929
1058
|
case 0:
|
|
930
1059
|
realtimeSharing = _objectSpread(_objectSpread({}, mockSharing), {}, {
|
|
931
1060
|
attributes: _objectSpread(_objectSpread({}, mockSharing.attributes), {}, {
|
|
@@ -937,9 +1066,9 @@ describe('updateSharingMemberType', function () {
|
|
|
937
1066
|
})]
|
|
938
1067
|
})
|
|
939
1068
|
});
|
|
940
|
-
instance.sharingCol.setReadOnly.mockImplementation( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
941
|
-
return _regeneratorRuntime.wrap(function
|
|
942
|
-
while (1) switch (
|
|
1069
|
+
instance.sharingCol.setReadOnly.mockImplementation( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26() {
|
|
1070
|
+
return _regeneratorRuntime.wrap(function _callee26$(_context26) {
|
|
1071
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
943
1072
|
case 0:
|
|
944
1073
|
instance.state = _objectSpread(_objectSpread({}, instance.state), {}, {
|
|
945
1074
|
sharings: instance.state.sharings.map(function (sharing) {
|
|
@@ -950,11 +1079,11 @@ describe('updateSharingMemberType', function () {
|
|
|
950
1079
|
|
|
951
1080
|
case 2:
|
|
952
1081
|
case "end":
|
|
953
|
-
return
|
|
1082
|
+
return _context26.stop();
|
|
954
1083
|
}
|
|
955
|
-
},
|
|
1084
|
+
}, _callee26);
|
|
956
1085
|
})));
|
|
957
|
-
|
|
1086
|
+
_context27.next = 4;
|
|
958
1087
|
return expect(instance.updateSharingMemberType('sharing-123', 1, 'one-way')).rejects.toThrow('Network error');
|
|
959
1088
|
|
|
960
1089
|
case 4:
|
|
@@ -971,9 +1100,9 @@ describe('updateSharingMemberType', function () {
|
|
|
971
1100
|
|
|
972
1101
|
case 5:
|
|
973
1102
|
case "end":
|
|
974
|
-
return
|
|
1103
|
+
return _context27.stop();
|
|
975
1104
|
}
|
|
976
|
-
},
|
|
1105
|
+
}, _callee27);
|
|
977
1106
|
})));
|
|
978
1107
|
}); // TODO Convert with react-testing-library
|
|
979
1108
|
// describe('hasWriteAccess', () => {
|
|
@@ -31,10 +31,7 @@ var styles = {
|
|
|
31
31
|
"share-dialog-scrollable-body": "share__share-dialog-scrollable-body___2O5UT",
|
|
32
32
|
"share-dialog-members": "share__share-dialog-members___CNHKJ",
|
|
33
33
|
"share-byemail-onlybylink": "share__share-byemail-onlybylink___29W-t",
|
|
34
|
-
"aligned-dropdown-button": "share__aligned-dropdown-button___3crgG"
|
|
35
|
-
"share-details-created": "share__share-details-created___z3nvO",
|
|
36
|
-
"share-details-perm": "share__share-details-perm___3HjxK",
|
|
37
|
-
"share-details-perm-desc": "share__share-details-perm-desc___3HyHu"
|
|
34
|
+
"aligned-dropdown-button": "share__aligned-dropdown-button___3crgG"
|
|
38
35
|
};
|
|
39
36
|
import AntivirusAlert from '../AntivirusAlert';
|
|
40
37
|
import { default as DumbShareByEmail } from '../ShareByEmail';
|