cozy-sharing 11.1.0 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.storybook/preview.jsx +11 -5
- package/CHANGELOG.md +17 -0
- package/dist/SharingProvider.js +111 -62
- package/dist/components/Recipient/GroupRecipientPermissions.js +70 -8
- package/dist/components/Recipient/actions/permission.js +4 -7
- package/dist/state.js +27 -0
- package/package.json +5 -5
- package/src/SharingProvider.jsx +15 -0
- package/src/components/Recipient/GroupRecipientPermissions.jsx +35 -6
- package/src/components/Recipient/actions/permission.js +3 -6
- package/src/state.js +28 -0
package/.storybook/preview.jsx
CHANGED
|
@@ -10,6 +10,7 @@ import CozyTheme from 'cozy-ui/transpiled/react/providers/CozyTheme'
|
|
|
10
10
|
import { CozyProvider, createFakeClient } from 'cozy-client'
|
|
11
11
|
|
|
12
12
|
import enLocale from '../locales/en.json'
|
|
13
|
+
import SharingContext from "../src/context";
|
|
13
14
|
|
|
14
15
|
const preview = {
|
|
15
16
|
decorators: [
|
|
@@ -40,11 +41,16 @@ const preview = {
|
|
|
40
41
|
<CozyProvider client={fakeClient}>
|
|
41
42
|
<CozyTheme>
|
|
42
43
|
<BreakpointsProvider>
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
<SharingContext.Provider value={{
|
|
45
|
+
revokeGroup: () => {},
|
|
46
|
+
revokeSelf: () => {}
|
|
47
|
+
}}>
|
|
48
|
+
<I18n lang="en" dictRequire={() => enLocale}>
|
|
49
|
+
<div style={{position: "relative"}}>
|
|
50
|
+
<Story />
|
|
51
|
+
</div>
|
|
52
|
+
</I18n>
|
|
53
|
+
</SharingContext.Provider>
|
|
48
54
|
</BreakpointsProvider>
|
|
49
55
|
</CozyTheme>
|
|
50
56
|
</CozyProvider>
|
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
|
+
# [12.0.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@11.1.0...cozy-sharing@12.0.0) (2024-03-21)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Making it possible to revoke a group ([cc3e998](https://github.com/cozy/cozy-libs/commit/cc3e998d94450d0698373f217a4eea06d1a81ede))
|
|
12
|
+
* Update cozy-client from 45.14.0 to 46.1.0 ([958c55c](https://github.com/cozy/cozy-libs/commit/958c55c5d55a540d0c5b341b6780cb16b1617ff9))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### BREAKING CHANGES
|
|
16
|
+
|
|
17
|
+
* you must have `cozy-client >=46.1.0`
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
6
23
|
# [11.1.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@11.0.1...cozy-sharing@11.1.0) (2024-03-21)
|
|
7
24
|
|
|
8
25
|
|
package/dist/SharingProvider.js
CHANGED
|
@@ -39,7 +39,7 @@ import { fetchFilesPaths } from './helpers/files';
|
|
|
39
39
|
import { getSharingObject, createSharingInStore, updateSharingInStore } from './helpers/sharings';
|
|
40
40
|
import { SynchronousJobQueue } from './helpers/synchronousJobQueue';
|
|
41
41
|
import { fetchApps } from './queries/queries';
|
|
42
|
-
import reducer, { receiveSharings, addSharing, updateSharing, addSharingLink, updateSharingLink, revokeSharingLink, revokeRecipient, revokeSelf, receivePaths, isOwner as _isOwner, canReshare as _canReshare, getOwner as _getOwner, getRecipients as _getRecipients, getSharingById, getExternalSharingIds, getSharingForSelf as _getSharingForSelf, getSharingType as _getSharingType, getSharingLink as _getSharingLink, getSharedDocIdsBySharings, getDocumentSharing, getDocumentPermissions as _getDocumentPermissions, hasSharedParent as _hasSharedParent, hasSharedChild as _hasSharedChild, getSharedParentPath as _getSharedParentPath } from './state';
|
|
42
|
+
import reducer, { receiveSharings, addSharing, updateSharing, addSharingLink, updateSharingLink, revokeSharingLink, revokeRecipient, revokeGroup as revokeGroupFromState, revokeSelf, receivePaths, isOwner as _isOwner, canReshare as _canReshare, getOwner as _getOwner, getRecipients as _getRecipients, getSharingById, getExternalSharingIds, getSharingForSelf as _getSharingForSelf, getSharingType as _getSharingType, getSharingLink as _getSharingLink, getSharedDocIdsBySharings, getDocumentSharing, getDocumentPermissions as _getDocumentPermissions, hasSharedParent as _hasSharedParent, hasSharedChild as _hasSharedChild, getSharedParentPath as _getSharedParentPath } from './state';
|
|
43
43
|
var SHARING_DOCTYPE = 'io.cozy.sharings';
|
|
44
44
|
var PERMISSION_DOCTYPE = 'io.cozy.permissions';
|
|
45
45
|
export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
@@ -359,14 +359,62 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
359
359
|
};
|
|
360
360
|
}());
|
|
361
361
|
|
|
362
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
363
|
-
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(document) {
|
|
364
|
-
var sharing;
|
|
362
|
+
_defineProperty(_assertThisInitialized(_this), "revokeGroup", /*#__PURE__*/function () {
|
|
363
|
+
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(document, sharingId, recipientIndex) {
|
|
364
|
+
var _this$props5, client, doctype, sharing;
|
|
365
|
+
|
|
365
366
|
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
366
367
|
while (1) switch (_context7.prev = _context7.next) {
|
|
368
|
+
case 0:
|
|
369
|
+
_this$props5 = _this.props, client = _this$props5.client, doctype = _this$props5.doctype;
|
|
370
|
+
sharing = getSharingById(_this.state, sharingId);
|
|
371
|
+
_context7.next = 4;
|
|
372
|
+
return _this.sharingCol.revokeGroup(sharing, recipientIndex);
|
|
373
|
+
|
|
374
|
+
case 4:
|
|
375
|
+
_context7.t0 = _this;
|
|
376
|
+
_context7.t1 = revokeGroupFromState;
|
|
377
|
+
_context7.t2 = sharing;
|
|
378
|
+
_context7.t3 = recipientIndex;
|
|
379
|
+
_context7.t4 = document.path;
|
|
380
|
+
|
|
381
|
+
if (_context7.t4) {
|
|
382
|
+
_context7.next = 13;
|
|
383
|
+
break;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
_context7.next = 12;
|
|
387
|
+
return fetchFilesPaths(client, doctype, [document]);
|
|
388
|
+
|
|
389
|
+
case 12:
|
|
390
|
+
_context7.t4 = _context7.sent;
|
|
391
|
+
|
|
392
|
+
case 13:
|
|
393
|
+
_context7.t5 = _context7.t4;
|
|
394
|
+
_context7.t6 = (0, _context7.t1)(_context7.t2, _context7.t3, _context7.t5);
|
|
395
|
+
|
|
396
|
+
_context7.t0.dispatch.call(_context7.t0, _context7.t6);
|
|
397
|
+
|
|
398
|
+
case 16:
|
|
399
|
+
case "end":
|
|
400
|
+
return _context7.stop();
|
|
401
|
+
}
|
|
402
|
+
}, _callee7);
|
|
403
|
+
}));
|
|
404
|
+
|
|
405
|
+
return function (_x10, _x11, _x12) {
|
|
406
|
+
return _ref9.apply(this, arguments);
|
|
407
|
+
};
|
|
408
|
+
}());
|
|
409
|
+
|
|
410
|
+
_defineProperty(_assertThisInitialized(_this), "revokeSelf", /*#__PURE__*/function () {
|
|
411
|
+
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(document) {
|
|
412
|
+
var sharing;
|
|
413
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
414
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
367
415
|
case 0:
|
|
368
416
|
sharing = _getSharingForSelf(_this.state, document.id);
|
|
369
|
-
|
|
417
|
+
_context8.next = 3;
|
|
370
418
|
return _this.sharingCol.revokeSelf(sharing);
|
|
371
419
|
|
|
372
420
|
case 3:
|
|
@@ -374,41 +422,41 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
374
422
|
|
|
375
423
|
case 4:
|
|
376
424
|
case "end":
|
|
377
|
-
return
|
|
425
|
+
return _context8.stop();
|
|
378
426
|
}
|
|
379
|
-
},
|
|
427
|
+
}, _callee8);
|
|
380
428
|
}));
|
|
381
429
|
|
|
382
|
-
return function (
|
|
383
|
-
return
|
|
430
|
+
return function (_x13) {
|
|
431
|
+
return _ref10.apply(this, arguments);
|
|
384
432
|
};
|
|
385
433
|
}());
|
|
386
434
|
|
|
387
435
|
_defineProperty(_assertThisInitialized(_this), "shareByLink", /*#__PURE__*/function () {
|
|
388
|
-
var
|
|
436
|
+
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(document, options) {
|
|
389
437
|
var resp;
|
|
390
|
-
return _regeneratorRuntime.wrap(function
|
|
391
|
-
while (1) switch (
|
|
438
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
439
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
392
440
|
case 0:
|
|
393
|
-
|
|
441
|
+
_context9.next = 2;
|
|
394
442
|
return _this.permissionCol.createSharingLink(document, options);
|
|
395
443
|
|
|
396
444
|
case 2:
|
|
397
|
-
resp =
|
|
445
|
+
resp = _context9.sent;
|
|
398
446
|
|
|
399
447
|
_this.dispatch(addSharingLink(resp.data));
|
|
400
448
|
|
|
401
|
-
return
|
|
449
|
+
return _context9.abrupt("return", resp);
|
|
402
450
|
|
|
403
451
|
case 5:
|
|
404
452
|
case "end":
|
|
405
|
-
return
|
|
453
|
+
return _context9.stop();
|
|
406
454
|
}
|
|
407
|
-
},
|
|
455
|
+
}, _callee9);
|
|
408
456
|
}));
|
|
409
457
|
|
|
410
|
-
return function (
|
|
411
|
-
return
|
|
458
|
+
return function (_x14, _x15) {
|
|
459
|
+
return _ref11.apply(this, arguments);
|
|
412
460
|
};
|
|
413
461
|
}());
|
|
414
462
|
|
|
@@ -421,71 +469,71 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
421
469
|
* @return {Array}
|
|
422
470
|
*/
|
|
423
471
|
_defineProperty(_assertThisInitialized(_this), "updateDocumentPermissions", /*#__PURE__*/function () {
|
|
424
|
-
var
|
|
472
|
+
var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(document, newVerbs) {
|
|
425
473
|
var permissions, responses;
|
|
426
|
-
return _regeneratorRuntime.wrap(function
|
|
427
|
-
while (1) switch (
|
|
474
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
475
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
428
476
|
case 0:
|
|
429
477
|
permissions = _getDocumentPermissions(_this.state, document.id);
|
|
430
|
-
|
|
478
|
+
_context11.next = 3;
|
|
431
479
|
return Promise.all(permissions.map( /*#__PURE__*/function () {
|
|
432
|
-
var
|
|
480
|
+
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(permissionDocument) {
|
|
433
481
|
var updatedPermissions, resp;
|
|
434
|
-
return _regeneratorRuntime.wrap(function
|
|
435
|
-
while (1) switch (
|
|
482
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
483
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
436
484
|
case 0:
|
|
437
485
|
updatedPermissions = permissionDocument.attributes.permissions;
|
|
438
486
|
Object.keys(updatedPermissions).map(function (permType) {
|
|
439
487
|
updatedPermissions[permType].verbs = newVerbs;
|
|
440
488
|
});
|
|
441
|
-
|
|
489
|
+
_context10.next = 4;
|
|
442
490
|
return _this.permissionCol.add(permissionDocument, updatedPermissions);
|
|
443
491
|
|
|
444
492
|
case 4:
|
|
445
|
-
resp =
|
|
493
|
+
resp = _context10.sent;
|
|
446
494
|
|
|
447
495
|
_this.dispatch(updateSharingLink(resp));
|
|
448
496
|
|
|
449
|
-
return
|
|
497
|
+
return _context10.abrupt("return", resp);
|
|
450
498
|
|
|
451
499
|
case 7:
|
|
452
500
|
case "end":
|
|
453
|
-
return
|
|
501
|
+
return _context10.stop();
|
|
454
502
|
}
|
|
455
|
-
},
|
|
503
|
+
}, _callee10);
|
|
456
504
|
}));
|
|
457
505
|
|
|
458
|
-
return function (
|
|
459
|
-
return
|
|
506
|
+
return function (_x18) {
|
|
507
|
+
return _ref13.apply(this, arguments);
|
|
460
508
|
};
|
|
461
509
|
}()));
|
|
462
510
|
|
|
463
511
|
case 3:
|
|
464
|
-
responses =
|
|
465
|
-
return
|
|
512
|
+
responses = _context11.sent;
|
|
513
|
+
return _context11.abrupt("return", responses);
|
|
466
514
|
|
|
467
515
|
case 5:
|
|
468
516
|
case "end":
|
|
469
|
-
return
|
|
517
|
+
return _context11.stop();
|
|
470
518
|
}
|
|
471
|
-
},
|
|
519
|
+
}, _callee11);
|
|
472
520
|
}));
|
|
473
521
|
|
|
474
|
-
return function (
|
|
475
|
-
return
|
|
522
|
+
return function (_x16, _x17) {
|
|
523
|
+
return _ref12.apply(this, arguments);
|
|
476
524
|
};
|
|
477
525
|
}());
|
|
478
526
|
|
|
479
527
|
_defineProperty(_assertThisInitialized(_this), "revokeSharingLink", /*#__PURE__*/function () {
|
|
480
|
-
var
|
|
528
|
+
var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(document) {
|
|
481
529
|
var perms;
|
|
482
|
-
return _regeneratorRuntime.wrap(function
|
|
483
|
-
while (1) switch (
|
|
530
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
531
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
484
532
|
case 0:
|
|
485
533
|
// Because some duplicate links have been created in the past, we must ensure
|
|
486
534
|
// we revoke all of them
|
|
487
535
|
perms = _getDocumentPermissions(_this.state, document.id);
|
|
488
|
-
|
|
536
|
+
_context12.next = 3;
|
|
489
537
|
return Promise.all(perms.map(function (p) {
|
|
490
538
|
return _this.permissionCol.destroy(p);
|
|
491
539
|
}));
|
|
@@ -495,13 +543,13 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
495
543
|
|
|
496
544
|
case 4:
|
|
497
545
|
case "end":
|
|
498
|
-
return
|
|
546
|
+
return _context12.stop();
|
|
499
547
|
}
|
|
500
|
-
},
|
|
548
|
+
}, _callee12);
|
|
501
549
|
}));
|
|
502
550
|
|
|
503
|
-
return function (
|
|
504
|
-
return
|
|
551
|
+
return function (_x19) {
|
|
552
|
+
return _ref14.apply(this, arguments);
|
|
505
553
|
};
|
|
506
554
|
}());
|
|
507
555
|
|
|
@@ -558,6 +606,7 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
558
606
|
share: _this.share,
|
|
559
607
|
onShared: onShared,
|
|
560
608
|
revoke: _this.revoke,
|
|
609
|
+
revokeGroup: _this.revokeGroup,
|
|
561
610
|
revokeSelf: _this.revokeSelf,
|
|
562
611
|
shareByLink: _this.shareByLink,
|
|
563
612
|
updateDocumentPermissions: _this.updateDocumentPermissions,
|
|
@@ -600,18 +649,18 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
600
649
|
}, {
|
|
601
650
|
key: "fetchAllSharings",
|
|
602
651
|
value: function () {
|
|
603
|
-
var _fetchAllSharings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
604
|
-
var _this$
|
|
652
|
+
var _fetchAllSharings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
|
|
653
|
+
var _this$props6, doctype, client, _yield$Promise$all, _yield$Promise$all2, sharings, permissions, apps, sharedDocIds, resp, folderPaths, filePaths;
|
|
605
654
|
|
|
606
|
-
return _regeneratorRuntime.wrap(function
|
|
607
|
-
while (1) switch (
|
|
655
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
656
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
608
657
|
case 0:
|
|
609
|
-
_this$
|
|
610
|
-
|
|
658
|
+
_this$props6 = this.props, doctype = _this$props6.doctype, client = _this$props6.client;
|
|
659
|
+
_context13.next = 3;
|
|
611
660
|
return Promise.all([this.sharingCol.findByDoctype(doctype), this.permissionCol.findLinksByDoctype(doctype), client.fetchQueryAndGetFromState(fetchApps())]);
|
|
612
661
|
|
|
613
662
|
case 3:
|
|
614
|
-
_yield$Promise$all =
|
|
663
|
+
_yield$Promise$all = _context13.sent;
|
|
615
664
|
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
|
|
616
665
|
sharings = _yield$Promise$all2[0];
|
|
617
666
|
permissions = _yield$Promise$all2[1];
|
|
@@ -626,35 +675,35 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
626
675
|
hasLoadedAtLeastOnePage: true
|
|
627
676
|
}); // eslint-disable-next-line promise/catch-or-return
|
|
628
677
|
|
|
629
|
-
|
|
678
|
+
_context13.next = 12;
|
|
630
679
|
return fetchNextPermissions(permissions, this.dispatch, this.permissionCol);
|
|
631
680
|
|
|
632
681
|
case 12:
|
|
633
682
|
if (!(doctype === 'io.cozy.files')) {
|
|
634
|
-
|
|
683
|
+
_context13.next = 22;
|
|
635
684
|
break;
|
|
636
685
|
}
|
|
637
686
|
|
|
638
687
|
sharedDocIds = getSharedDocIdsBySharings(sharings);
|
|
639
|
-
|
|
688
|
+
_context13.next = 16;
|
|
640
689
|
return client.collection(doctype).all({
|
|
641
690
|
keys: sharedDocIds
|
|
642
691
|
});
|
|
643
692
|
|
|
644
693
|
case 16:
|
|
645
|
-
resp =
|
|
694
|
+
resp = _context13.sent;
|
|
646
695
|
folderPaths = resp.data.filter(function (f) {
|
|
647
696
|
return f.type === 'directory' && !f.trashed;
|
|
648
697
|
}).map(function (f) {
|
|
649
698
|
return f.path;
|
|
650
699
|
});
|
|
651
|
-
|
|
700
|
+
_context13.next = 20;
|
|
652
701
|
return fetchFilesPaths(client, doctype, resp.data.filter(function (f) {
|
|
653
702
|
return f.type !== 'directory' && !f.trashed;
|
|
654
703
|
}));
|
|
655
704
|
|
|
656
705
|
case 20:
|
|
657
|
-
filePaths =
|
|
706
|
+
filePaths = _context13.sent;
|
|
658
707
|
this.dispatch(receivePaths([].concat(_toConsumableArray(folderPaths), _toConsumableArray(filePaths))));
|
|
659
708
|
|
|
660
709
|
case 22:
|
|
@@ -664,9 +713,9 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
664
713
|
|
|
665
714
|
case 23:
|
|
666
715
|
case "end":
|
|
667
|
-
return
|
|
716
|
+
return _context13.stop();
|
|
668
717
|
}
|
|
669
|
-
},
|
|
718
|
+
}, _callee13, this);
|
|
670
719
|
}));
|
|
671
720
|
|
|
672
721
|
function fetchAllSharings() {
|
|
@@ -1,16 +1,27 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
1
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
4
|
import React, { useState, useRef } from 'react';
|
|
3
5
|
import { useClient } from 'cozy-client';
|
|
4
6
|
import ActionsMenu from 'cozy-ui/transpiled/react/ActionsMenu';
|
|
5
7
|
import { makeActions, divider } from 'cozy-ui/transpiled/react/ActionsMenu/Actions';
|
|
8
|
+
import ActionsMenuMobileHeader from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuMobileHeader';
|
|
6
9
|
import DropdownButton from 'cozy-ui/transpiled/react/DropdownButton';
|
|
10
|
+
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
|
|
11
|
+
import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
|
|
12
|
+
import Spinner from 'cozy-ui/transpiled/react/Spinner';
|
|
7
13
|
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
|
|
8
14
|
import { permission } from './actions/permission';
|
|
9
|
-
import { revokeGroup } from './actions/revokeGroup';
|
|
15
|
+
import { revokeGroup as revokeGroupAction } from './actions/revokeGroup';
|
|
16
|
+
import { useSharingContext } from '../../hooks/useSharingContext';
|
|
17
|
+
import { GroupAvatar } from '../Avatar/GroupAvatar';
|
|
10
18
|
|
|
11
19
|
var GroupRecipientPermissions = function GroupRecipientPermissions(_ref) {
|
|
12
|
-
var
|
|
20
|
+
var name = _ref.name,
|
|
21
|
+
isOwner = _ref.isOwner,
|
|
13
22
|
instance = _ref.instance,
|
|
23
|
+
sharingId = _ref.sharingId,
|
|
24
|
+
groupIndex = _ref.groupIndex,
|
|
14
25
|
_ref$read_only = _ref.read_only,
|
|
15
26
|
isReadOnly = _ref$read_only === void 0 ? false : _ref$read_only,
|
|
16
27
|
className = _ref.className;
|
|
@@ -21,13 +32,22 @@ var GroupRecipientPermissions = function GroupRecipientPermissions(_ref) {
|
|
|
21
32
|
var buttonRef = useRef();
|
|
22
33
|
var client = useClient();
|
|
23
34
|
|
|
35
|
+
var _useSharingContext = useSharingContext(),
|
|
36
|
+
revokeGroup = _useSharingContext.revokeGroup,
|
|
37
|
+
revokeSelf = _useSharingContext.revokeSelf;
|
|
38
|
+
|
|
24
39
|
var _useState = useState(false),
|
|
25
40
|
_useState2 = _slicedToArray(_useState, 2),
|
|
26
41
|
isMenuDisplayed = _useState2[0],
|
|
27
42
|
setMenuDisplayed = _useState2[1];
|
|
28
43
|
|
|
44
|
+
var _useState3 = useState(false),
|
|
45
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
46
|
+
revoking = _useState4[0],
|
|
47
|
+
setRevoking = _useState4[1];
|
|
48
|
+
|
|
29
49
|
var instanceMatchesClient = instance !== undefined && instance === client.options.uri;
|
|
30
|
-
var shouldShowMenu = instanceMatchesClient && !isOwner || isOwner;
|
|
50
|
+
var shouldShowMenu = !revoking && (instanceMatchesClient && !isOwner || isOwner);
|
|
31
51
|
|
|
32
52
|
var toggleMenu = function toggleMenu() {
|
|
33
53
|
return setMenuDisplayed(!isMenuDisplayed);
|
|
@@ -37,11 +57,46 @@ var GroupRecipientPermissions = function GroupRecipientPermissions(_ref) {
|
|
|
37
57
|
return setMenuDisplayed(false);
|
|
38
58
|
};
|
|
39
59
|
|
|
40
|
-
var handleRevocation = function
|
|
41
|
-
|
|
60
|
+
var handleRevocation = /*#__PURE__*/function () {
|
|
61
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
62
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
63
|
+
while (1) switch (_context.prev = _context.next) {
|
|
64
|
+
case 0:
|
|
65
|
+
setRevoking(true);
|
|
66
|
+
|
|
67
|
+
if (!isOwner) {
|
|
68
|
+
_context.next = 6;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
_context.next = 4;
|
|
73
|
+
return revokeGroup(document, sharingId, groupIndex);
|
|
74
|
+
|
|
75
|
+
case 4:
|
|
76
|
+
_context.next = 8;
|
|
77
|
+
break;
|
|
78
|
+
|
|
79
|
+
case 6:
|
|
80
|
+
_context.next = 8;
|
|
81
|
+
return revokeSelf(document);
|
|
82
|
+
|
|
83
|
+
case 8:
|
|
84
|
+
setRevoking(false);
|
|
85
|
+
|
|
86
|
+
case 9:
|
|
87
|
+
case "end":
|
|
88
|
+
return _context.stop();
|
|
89
|
+
}
|
|
90
|
+
}, _callee);
|
|
91
|
+
}));
|
|
92
|
+
|
|
93
|
+
return function handleRevocation() {
|
|
94
|
+
return _ref2.apply(this, arguments);
|
|
95
|
+
};
|
|
96
|
+
}();
|
|
42
97
|
|
|
43
98
|
var type = isReadOnly ? 'one-way' : 'two-way';
|
|
44
|
-
var actions = makeActions([permission, divider,
|
|
99
|
+
var actions = makeActions([permission, divider, revokeGroupAction], {
|
|
45
100
|
t: t,
|
|
46
101
|
type: type,
|
|
47
102
|
isOwner: isOwner,
|
|
@@ -49,7 +104,7 @@ var GroupRecipientPermissions = function GroupRecipientPermissions(_ref) {
|
|
|
49
104
|
});
|
|
50
105
|
return /*#__PURE__*/React.createElement("div", {
|
|
51
106
|
className: className
|
|
52
|
-
}, shouldShowMenu && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DropdownButton, {
|
|
107
|
+
}, revoking && /*#__PURE__*/React.createElement(Spinner, null), shouldShowMenu && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DropdownButton, {
|
|
53
108
|
ref: buttonRef,
|
|
54
109
|
"aria-controls": "simple-menu",
|
|
55
110
|
"aria-haspopup": "true",
|
|
@@ -65,7 +120,14 @@ var GroupRecipientPermissions = function GroupRecipientPermissions(_ref) {
|
|
|
65
120
|
},
|
|
66
121
|
autoClose: true,
|
|
67
122
|
onClose: hideMenu
|
|
68
|
-
}
|
|
123
|
+
}, /*#__PURE__*/React.createElement(ActionsMenuMobileHeader, null, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(GroupAvatar, {
|
|
124
|
+
size: "small"
|
|
125
|
+
})), /*#__PURE__*/React.createElement(ListItemText, {
|
|
126
|
+
primary: name,
|
|
127
|
+
primaryTypographyProps: {
|
|
128
|
+
variant: 'h6'
|
|
129
|
+
}
|
|
130
|
+
})))));
|
|
69
131
|
};
|
|
70
132
|
|
|
71
133
|
export { GroupRecipientPermissions };
|
|
@@ -1,28 +1,25 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React, { forwardRef } from 'react';
|
|
3
3
|
import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem';
|
|
4
|
-
import Icon from 'cozy-ui/transpiled/react/Icon';
|
|
5
|
-
import EyeIcon from 'cozy-ui/transpiled/react/Icons/Eye';
|
|
6
|
-
import RenameIcon from 'cozy-ui/transpiled/react/Icons/Rename';
|
|
7
4
|
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
|
|
8
5
|
import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
|
|
6
|
+
import Radios from 'cozy-ui/transpiled/react/Radios';
|
|
9
7
|
|
|
10
8
|
var permission = function permission(_ref) {
|
|
11
9
|
var t = _ref.t,
|
|
12
10
|
type = _ref.type;
|
|
13
11
|
var title = t("Share.type.".concat(type));
|
|
14
|
-
var icon = type === 'two-way' ? RenameIcon : EyeIcon;
|
|
15
12
|
return {
|
|
16
13
|
name: 'permission',
|
|
17
14
|
label: title,
|
|
18
|
-
icon:
|
|
15
|
+
icon: null,
|
|
19
16
|
action: null,
|
|
20
17
|
Component: /*#__PURE__*/forwardRef(function RevokeItem(props, ref) {
|
|
21
18
|
return /*#__PURE__*/React.createElement(ActionsMenuItem, _extends({}, props, {
|
|
22
19
|
ref: ref,
|
|
23
20
|
button: false
|
|
24
|
-
}), /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(
|
|
25
|
-
|
|
21
|
+
}), /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Radios, {
|
|
22
|
+
checked: true
|
|
26
23
|
})), /*#__PURE__*/React.createElement(ListItemText, {
|
|
27
24
|
primary: title
|
|
28
25
|
}));
|
package/dist/state.js
CHANGED
|
@@ -16,6 +16,7 @@ var RECEIVE_SHARINGS = 'RECEIVE_SHARINGS';
|
|
|
16
16
|
var ADD_SHARING = 'ADD_SHARING';
|
|
17
17
|
var UPDATE_SHARING = 'UPDATE_SHARING';
|
|
18
18
|
var REVOKE_RECIPIENT = 'REVOKE_RECIPIENT';
|
|
19
|
+
var REVOKE_GROUP = 'REVOKE_GROUP';
|
|
19
20
|
var REVOKE_SELF = 'REVOKE_SELF';
|
|
20
21
|
var ADD_SHARING_LINK = 'ADD_SHARING_LINK';
|
|
21
22
|
var UPDATE_SHARING_LINK = 'UPDATE_SHARING_LINK';
|
|
@@ -78,6 +79,29 @@ export var revokeRecipient = function revokeRecipient(sharing, index, path) {
|
|
|
78
79
|
path: path
|
|
79
80
|
};
|
|
80
81
|
};
|
|
82
|
+
export var revokeGroup = function revokeGroup(sharing, index, path) {
|
|
83
|
+
return {
|
|
84
|
+
type: REVOKE_GROUP,
|
|
85
|
+
|
|
86
|
+
/* We can't just simply remove a group,
|
|
87
|
+
because we use the index to remove the other group
|
|
88
|
+
*/
|
|
89
|
+
sharing: _objectSpread(_objectSpread({}, sharing), {}, {
|
|
90
|
+
attributes: _objectSpread(_objectSpread({}, sharing.attributes), {}, {
|
|
91
|
+
groups: sharing.attributes.groups.map(function (g, idx) {
|
|
92
|
+
if (idx === index) {
|
|
93
|
+
return _objectSpread(_objectSpread({}, g), {}, {
|
|
94
|
+
revoked: true
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return g;
|
|
99
|
+
})
|
|
100
|
+
})
|
|
101
|
+
}),
|
|
102
|
+
path: path
|
|
103
|
+
};
|
|
104
|
+
};
|
|
81
105
|
export var revokeSelf = function revokeSelf(sharing) {
|
|
82
106
|
return {
|
|
83
107
|
type: REVOKE_SELF,
|
|
@@ -204,6 +228,7 @@ var byDocId = function byDocId() {
|
|
|
204
228
|
case ADD_SHARING:
|
|
205
229
|
return indexSharing(state, action.data);
|
|
206
230
|
|
|
231
|
+
case REVOKE_GROUP:
|
|
207
232
|
case REVOKE_RECIPIENT:
|
|
208
233
|
case UPDATE_SHARING:
|
|
209
234
|
if (areAllRecipientsRevoked(action.sharing)) {
|
|
@@ -304,6 +329,7 @@ var sharings = function sharings() {
|
|
|
304
329
|
return [].concat(_toConsumableArray(filtered_state), [action.data]);
|
|
305
330
|
|
|
306
331
|
case UPDATE_SHARING:
|
|
332
|
+
case REVOKE_GROUP:
|
|
307
333
|
case REVOKE_RECIPIENT:
|
|
308
334
|
return state.map(function (s) {
|
|
309
335
|
return s.id !== action.sharing.id ? s : action.sharing;
|
|
@@ -335,6 +361,7 @@ var sharedPaths = function sharedPaths() {
|
|
|
335
361
|
var newState = [].concat(_toConsumableArray(state), [action.path]);
|
|
336
362
|
return newState;
|
|
337
363
|
|
|
364
|
+
case REVOKE_GROUP:
|
|
338
365
|
case REVOKE_RECIPIENT:
|
|
339
366
|
if (areAllRecipientsRevoked(action.sharing)) {
|
|
340
367
|
return state.filter(function (p) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-sharing",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.0",
|
|
4
4
|
"description": "Provides sharing login for React applications.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "Cozy",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@cozy/minilog": "^1.0.0",
|
|
32
32
|
"classnames": "^2.2.6",
|
|
33
33
|
"cozy-device-helper": "^3.0.0",
|
|
34
|
-
"cozy-doctypes": "^1.89.
|
|
34
|
+
"cozy-doctypes": "^1.89.5",
|
|
35
35
|
"lodash": "^4.17.19",
|
|
36
36
|
"react-autosuggest": "^10.1.0",
|
|
37
37
|
"react-tooltip": "^3.11.1",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"babel-jest": "26.6.3",
|
|
50
50
|
"babel-plugin-css-modules-transform": "1.6.2",
|
|
51
51
|
"babel-plugin-inline-react-svg": "1.1.2",
|
|
52
|
-
"cozy-client": "
|
|
52
|
+
"cozy-client": "46.1.0",
|
|
53
53
|
"cozy-ui": "^103.8.2",
|
|
54
54
|
"enzyme": "3.11.0",
|
|
55
55
|
"enzyme-adapter-react-16": "1.15.6",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"storybook": "7.6.0"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"cozy-client": ">=
|
|
64
|
+
"cozy-client": ">=46.1.0",
|
|
65
65
|
"cozy-realtime": "^3.11.0",
|
|
66
66
|
"cozy-ui": ">=103.8.1",
|
|
67
67
|
"prop-types": "^15.7.2",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"sideEffects": [
|
|
72
72
|
"*.css"
|
|
73
73
|
],
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "ebef29fe4f3f3704c967ebfd2d330d9b95d6e25b"
|
|
75
75
|
}
|
package/src/SharingProvider.jsx
CHANGED
|
@@ -20,6 +20,7 @@ import reducer, {
|
|
|
20
20
|
updateSharingLink,
|
|
21
21
|
revokeSharingLink,
|
|
22
22
|
revokeRecipient,
|
|
23
|
+
revokeGroup as revokeGroupFromState,
|
|
23
24
|
revokeSelf,
|
|
24
25
|
receivePaths,
|
|
25
26
|
isOwner,
|
|
@@ -71,6 +72,7 @@ export class SharingProvider extends Component {
|
|
|
71
72
|
share: this.share,
|
|
72
73
|
onShared: onShared,
|
|
73
74
|
revoke: this.revoke,
|
|
75
|
+
revokeGroup: this.revokeGroup,
|
|
74
76
|
revokeSelf: this.revokeSelf,
|
|
75
77
|
shareByLink: this.shareByLink,
|
|
76
78
|
updateDocumentPermissions: this.updateDocumentPermissions,
|
|
@@ -291,6 +293,19 @@ export class SharingProvider extends Component {
|
|
|
291
293
|
)
|
|
292
294
|
}
|
|
293
295
|
|
|
296
|
+
revokeGroup = async (document, sharingId, recipientIndex) => {
|
|
297
|
+
const { client, doctype } = this.props
|
|
298
|
+
const sharing = getSharingById(this.state, sharingId)
|
|
299
|
+
await this.sharingCol.revokeGroup(sharing, recipientIndex)
|
|
300
|
+
this.dispatch(
|
|
301
|
+
revokeGroupFromState(
|
|
302
|
+
sharing,
|
|
303
|
+
recipientIndex,
|
|
304
|
+
document.path || (await fetchFilesPaths(client, doctype, [document]))
|
|
305
|
+
)
|
|
306
|
+
)
|
|
307
|
+
}
|
|
308
|
+
|
|
294
309
|
revokeSelf = async document => {
|
|
295
310
|
const sharing = getSharingForSelf(this.state, document.id)
|
|
296
311
|
await this.sharingCol.revokeSelf(sharing)
|
|
@@ -6,38 +6,56 @@ import {
|
|
|
6
6
|
makeActions,
|
|
7
7
|
divider
|
|
8
8
|
} from 'cozy-ui/transpiled/react/ActionsMenu/Actions'
|
|
9
|
+
import ActionsMenuMobileHeader from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuMobileHeader'
|
|
9
10
|
import DropdownButton from 'cozy-ui/transpiled/react/DropdownButton'
|
|
11
|
+
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
|
|
12
|
+
import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
|
|
13
|
+
import Spinner from 'cozy-ui/transpiled/react/Spinner'
|
|
10
14
|
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
|
|
11
15
|
|
|
12
16
|
import { permission } from './actions/permission'
|
|
13
|
-
import { revokeGroup } from './actions/revokeGroup'
|
|
17
|
+
import { revokeGroup as revokeGroupAction } from './actions/revokeGroup'
|
|
18
|
+
import { useSharingContext } from '../../hooks/useSharingContext'
|
|
19
|
+
import { GroupAvatar } from '../Avatar/GroupAvatar'
|
|
14
20
|
|
|
15
21
|
const GroupRecipientPermissions = ({
|
|
22
|
+
name,
|
|
16
23
|
isOwner,
|
|
17
24
|
instance,
|
|
25
|
+
sharingId,
|
|
26
|
+
groupIndex,
|
|
18
27
|
read_only: isReadOnly = false,
|
|
19
28
|
className
|
|
20
29
|
}) => {
|
|
21
30
|
const { t } = useI18n()
|
|
22
31
|
const buttonRef = useRef()
|
|
23
32
|
const client = useClient()
|
|
33
|
+
const { revokeGroup, revokeSelf } = useSharingContext()
|
|
24
34
|
|
|
25
35
|
const [isMenuDisplayed, setMenuDisplayed] = useState(false)
|
|
36
|
+
const [revoking, setRevoking] = useState(false)
|
|
26
37
|
|
|
27
38
|
const instanceMatchesClient =
|
|
28
39
|
instance !== undefined && instance === client.options.uri
|
|
29
|
-
const shouldShowMenu =
|
|
40
|
+
const shouldShowMenu =
|
|
41
|
+
!revoking && ((instanceMatchesClient && !isOwner) || isOwner)
|
|
30
42
|
|
|
31
43
|
const toggleMenu = () => setMenuDisplayed(!isMenuDisplayed)
|
|
32
44
|
const hideMenu = () => setMenuDisplayed(false)
|
|
33
45
|
|
|
34
|
-
const handleRevocation = () => {
|
|
35
|
-
|
|
46
|
+
const handleRevocation = async () => {
|
|
47
|
+
setRevoking(true)
|
|
48
|
+
if (isOwner) {
|
|
49
|
+
await revokeGroup(document, sharingId, groupIndex)
|
|
50
|
+
} else {
|
|
51
|
+
await revokeSelf(document)
|
|
52
|
+
}
|
|
53
|
+
setRevoking(false)
|
|
36
54
|
}
|
|
37
55
|
|
|
38
56
|
const type = isReadOnly ? 'one-way' : 'two-way'
|
|
39
57
|
|
|
40
|
-
const actions = makeActions([permission, divider,
|
|
58
|
+
const actions = makeActions([permission, divider, revokeGroupAction], {
|
|
41
59
|
t,
|
|
42
60
|
type,
|
|
43
61
|
isOwner,
|
|
@@ -46,6 +64,7 @@ const GroupRecipientPermissions = ({
|
|
|
46
64
|
|
|
47
65
|
return (
|
|
48
66
|
<div className={className}>
|
|
67
|
+
{revoking && <Spinner />}
|
|
49
68
|
{shouldShowMenu && (
|
|
50
69
|
<>
|
|
51
70
|
<DropdownButton
|
|
@@ -67,7 +86,17 @@ const GroupRecipientPermissions = ({
|
|
|
67
86
|
}}
|
|
68
87
|
autoClose
|
|
69
88
|
onClose={hideMenu}
|
|
70
|
-
|
|
89
|
+
>
|
|
90
|
+
<ActionsMenuMobileHeader>
|
|
91
|
+
<ListItemIcon>
|
|
92
|
+
<GroupAvatar size="small" />
|
|
93
|
+
</ListItemIcon>
|
|
94
|
+
<ListItemText
|
|
95
|
+
primary={name}
|
|
96
|
+
primaryTypographyProps={{ variant: 'h6' }}
|
|
97
|
+
/>
|
|
98
|
+
</ActionsMenuMobileHeader>
|
|
99
|
+
</ActionsMenu>
|
|
71
100
|
</>
|
|
72
101
|
)}
|
|
73
102
|
</div>
|
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react'
|
|
2
2
|
|
|
3
3
|
import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem'
|
|
4
|
-
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
5
|
-
import EyeIcon from 'cozy-ui/transpiled/react/Icons/Eye'
|
|
6
|
-
import RenameIcon from 'cozy-ui/transpiled/react/Icons/Rename'
|
|
7
4
|
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
|
|
8
5
|
import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
|
|
6
|
+
import Radios from 'cozy-ui/transpiled/react/Radios'
|
|
9
7
|
|
|
10
8
|
const permission = ({ t, type }) => {
|
|
11
9
|
const title = t(`Share.type.${type}`)
|
|
12
|
-
const icon = type === 'two-way' ? RenameIcon : EyeIcon
|
|
13
10
|
|
|
14
11
|
return {
|
|
15
12
|
name: 'permission',
|
|
16
13
|
label: title,
|
|
17
|
-
icon,
|
|
14
|
+
icon: null,
|
|
18
15
|
action: null,
|
|
19
16
|
Component: forwardRef(function RevokeItem(props, ref) {
|
|
20
17
|
return (
|
|
21
18
|
<ActionsMenuItem {...props} ref={ref} button={false}>
|
|
22
19
|
<ListItemIcon>
|
|
23
|
-
<
|
|
20
|
+
<Radios checked={true} />
|
|
24
21
|
</ListItemIcon>
|
|
25
22
|
<ListItemText primary={title} />
|
|
26
23
|
</ActionsMenuItem>
|
package/src/state.js
CHANGED
|
@@ -6,6 +6,7 @@ const RECEIVE_SHARINGS = 'RECEIVE_SHARINGS'
|
|
|
6
6
|
const ADD_SHARING = 'ADD_SHARING'
|
|
7
7
|
const UPDATE_SHARING = 'UPDATE_SHARING'
|
|
8
8
|
const REVOKE_RECIPIENT = 'REVOKE_RECIPIENT'
|
|
9
|
+
const REVOKE_GROUP = 'REVOKE_GROUP'
|
|
9
10
|
const REVOKE_SELF = 'REVOKE_SELF'
|
|
10
11
|
const ADD_SHARING_LINK = 'ADD_SHARING_LINK'
|
|
11
12
|
const UPDATE_SHARING_LINK = 'UPDATE_SHARING_LINK'
|
|
@@ -62,6 +63,30 @@ export const revokeRecipient = (sharing, index, path) => {
|
|
|
62
63
|
path
|
|
63
64
|
}
|
|
64
65
|
}
|
|
66
|
+
export const revokeGroup = (sharing, index, path) => {
|
|
67
|
+
return {
|
|
68
|
+
type: REVOKE_GROUP,
|
|
69
|
+
/* We can't just simply remove a group,
|
|
70
|
+
because we use the index to remove the other group
|
|
71
|
+
*/
|
|
72
|
+
sharing: {
|
|
73
|
+
...sharing,
|
|
74
|
+
attributes: {
|
|
75
|
+
...sharing.attributes,
|
|
76
|
+
groups: sharing.attributes.groups.map((g, idx) => {
|
|
77
|
+
if (idx === index) {
|
|
78
|
+
return {
|
|
79
|
+
...g,
|
|
80
|
+
revoked: true
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return g
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
path
|
|
88
|
+
}
|
|
89
|
+
}
|
|
65
90
|
export const revokeSelf = sharing => ({ type: REVOKE_SELF, sharing })
|
|
66
91
|
export const addSharingLink = data => ({ type: ADD_SHARING_LINK, data })
|
|
67
92
|
export const updateSharingLink = data => ({ type: UPDATE_SHARING_LINK, data })
|
|
@@ -149,6 +174,7 @@ const byDocId = (state = {}, action) => {
|
|
|
149
174
|
)
|
|
150
175
|
case ADD_SHARING:
|
|
151
176
|
return indexSharing(state, action.data)
|
|
177
|
+
case REVOKE_GROUP:
|
|
152
178
|
case REVOKE_RECIPIENT:
|
|
153
179
|
case UPDATE_SHARING:
|
|
154
180
|
if (areAllRecipientsRevoked(action.sharing)) {
|
|
@@ -220,6 +246,7 @@ const sharings = (state = [], action) => {
|
|
|
220
246
|
const filtered_state = state.filter(s => s.id !== action.data.id)
|
|
221
247
|
return [...filtered_state, action.data]
|
|
222
248
|
case UPDATE_SHARING:
|
|
249
|
+
case REVOKE_GROUP:
|
|
223
250
|
case REVOKE_RECIPIENT:
|
|
224
251
|
return state.map(s => {
|
|
225
252
|
return s.id !== action.sharing.id ? s : action.sharing
|
|
@@ -242,6 +269,7 @@ const sharedPaths = (state = [], action) => {
|
|
|
242
269
|
// eslint-disable-next-line
|
|
243
270
|
const newState = [...state, action.path]
|
|
244
271
|
return newState
|
|
272
|
+
case REVOKE_GROUP:
|
|
245
273
|
case REVOKE_RECIPIENT:
|
|
246
274
|
if (areAllRecipientsRevoked(action.sharing)) {
|
|
247
275
|
return state.filter(p => p !== action.path)
|