cozy-sharing 37.1.0 → 37.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.
- package/CHANGELOG.md +14 -0
- package/dist/OpenSharingLinkButton.js +1 -1
- package/dist/SharingProvider.js +315 -138
- package/dist/SharingProvider.spec.js +454 -240
- package/dist/actions/addToCozySharingLink.js +1 -1
- package/dist/actions/createCozySharingLink.js +1 -1
- package/dist/actions/shareNative.js +1 -1
- package/dist/actions/syncToCozySharingLink.js +1 -1
- package/dist/components/Avatar/AvatarList.js +1 -1
- package/dist/components/Recipient/GroupRecipient.js +0 -2
- package/dist/components/Recipient/GroupRecipientDetail.js +2 -25
- package/dist/components/Recipient/GroupRecipientDetailWithoutAccess.js +1 -1
- package/dist/components/Recipient/LinkRecipient.js +1 -1
- package/dist/components/Recipient/LinkRecipientLite.js +1 -1
- package/dist/components/Recipient/actions/revokeLink.js +1 -1
- package/dist/components/ShareButton.js +1 -1
- package/dist/components/ShareByLink.js +1 -1
- package/dist/components/ShareLinkAccessModal/ShareLinkAccessModal.js +316 -0
- package/dist/components/ShareLinkAccessModal/ShareLinkAccessModal.spec.js +372 -0
- package/dist/components/ShareLinkAccessModal/index.js +1 -0
- package/dist/components/ShareRestrictionModal/BoxDate.js +1 -1
- package/dist/components/ShareRestrictionModal/BoxEditingRights.js +1 -1
- package/dist/components/ShareRestrictionModal/BoxPassword.js +1 -1
- package/dist/components/ShareRestrictionModal/ShareRestrictionModal.js +1 -1
- package/dist/components/ShareRestrictionModal/helpers.js +36 -18
- package/dist/components/ShareRestrictionModal/helpers.spec.js +3 -3
- package/dist/components/SharedBadge.js +1 -1
- package/dist/components/SharedDrive/SharedDriveHeader.js +1 -1
- package/dist/index.js +1 -0
- package/locales/en.json +21 -3
- package/locales/fr.json +22 -4
- package/locales/ru.json +21 -3
- package/locales/vi.json +21 -3
- package/package.json +3 -3
- package/src/OpenSharingLinkButton.jsx +1 -1
- package/src/SharingProvider.jsx +91 -27
- package/src/SharingProvider.spec.jsx +212 -60
- package/src/actions/addToCozySharingLink.js +1 -1
- package/src/actions/createCozySharingLink.js +1 -1
- package/src/actions/shareNative.js +1 -1
- package/src/actions/syncToCozySharingLink.js +1 -1
- package/src/components/Avatar/AvatarList.jsx +1 -1
- package/src/components/Recipient/GroupRecipient.jsx +1 -2
- package/src/components/Recipient/GroupRecipientDetail.jsx +3 -33
- package/src/components/Recipient/GroupRecipientDetailWithoutAccess.jsx +1 -1
- package/src/components/Recipient/LinkRecipient.jsx +1 -1
- package/src/components/Recipient/LinkRecipientLite.jsx +1 -1
- package/src/components/Recipient/actions/revokeLink.js +1 -1
- package/src/components/ShareButton.jsx +1 -1
- package/src/components/ShareByLink.jsx +1 -1
- package/src/components/ShareLinkAccessModal/ShareLinkAccessModal.jsx +293 -0
- package/src/components/ShareLinkAccessModal/ShareLinkAccessModal.spec.jsx +291 -0
- package/src/components/ShareLinkAccessModal/index.js +1 -0
- package/src/components/ShareRestrictionModal/BoxDate.jsx +1 -1
- package/src/components/ShareRestrictionModal/BoxEditingRights.jsx +1 -1
- package/src/components/ShareRestrictionModal/BoxPassword.jsx +1 -1
- package/src/components/ShareRestrictionModal/ShareRestrictionModal.jsx +1 -1
- package/src/components/ShareRestrictionModal/helpers.js +30 -6
- package/src/components/ShareRestrictionModal/helpers.spec.js +3 -3
- package/src/components/SharedBadge.jsx +2 -1
- package/src/components/SharedDrive/SharedDriveHeader.jsx +1 -1
- package/src/helpers/sharings.js +0 -1
- package/src/index.jsx +1 -0
package/dist/SharingProvider.js
CHANGED
|
@@ -33,7 +33,7 @@ function _callSuper(_this, derived, args) {
|
|
|
33
33
|
import React, { Component } from 'react';
|
|
34
34
|
import { withClient } from 'cozy-client';
|
|
35
35
|
import minilog from 'cozy-minilog';
|
|
36
|
-
import { generateShareLinkFromFile } from './components/ShareRestrictionModal/helpers';
|
|
36
|
+
import { generateShareLinkFromFile, getLinkAccessOptions } from './components/ShareRestrictionModal/helpers';
|
|
37
37
|
import SharingContext from './context';
|
|
38
38
|
import { fetchNextPermissions } from './fetchNextPermissions';
|
|
39
39
|
import { fetchFilesPaths } from './helpers/files';
|
|
@@ -41,10 +41,15 @@ import { getSharingObject, createSharingInStore, updateSharingInStore } from './
|
|
|
41
41
|
import { getShortcode } from './helpers/shortcodes';
|
|
42
42
|
import { SynchronousJobQueue } from './helpers/synchronousJobQueue';
|
|
43
43
|
import { fetchApps } from './queries/queries';
|
|
44
|
-
import reducer, { receiveSharings, addSharing, updateSharing, addSharingLink, updateSharingLink, revokeSharingLink, revokeRecipient, revokeGroup as revokeGroupFromState, revokeSelf, receivePaths, isOwner as _isOwner, isSharedDrive as _isSharedDrive, isOrgSharedDrive as _isOrgSharedDrive, canLeave as _canLeave, canReshare as _canReshare, getOwner as _getOwner, getRecipients as _getRecipients, getSharingById as _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, getSharedDriveSharingType, SHARING_TYPE } from './state';
|
|
44
|
+
import reducer, { receiveSharings, addSharing, updateSharing, addSharingLink, updateSharingLink, revokeSharingLink, revokeRecipient, revokeGroup as revokeGroupFromState, revokeSelf, receivePaths, isOwner as _isOwner, isSharedDrive as _isSharedDrive, isOrgSharedDrive as _isOrgSharedDrive, canLeave as _canLeave, canReshare as _canReshare, getOwner as _getOwner, getRecipients as _getRecipients, getSharingById as _getSharingById, getExternalSharingIds, getSharingForSelf as _getSharingForSelf, getSharingType as _getSharingType, getSharingLink as _getSharingLink, getSharedDocIdsBySharings, getDocumentSharing, getDocumentPermissions as _getDocumentPermissions, getPermissionDocIds, hasSharedParent as _hasSharedParent, hasSharedChild as _hasSharedChild, getSharedParentPath as _getSharedParentPath, getSharedDriveSharingType, SHARING_TYPE } from './state';
|
|
45
45
|
var log = minilog('SharingProvider');
|
|
46
46
|
var SHARING_DOCTYPE = 'io.cozy.sharings';
|
|
47
47
|
var PERMISSION_DOCTYPE = 'io.cozy.permissions';
|
|
48
|
+
|
|
49
|
+
var getDocumentId = function getDocumentId(document) {
|
|
50
|
+
return (document === null || document === void 0 ? void 0 : document._id) || (document === null || document === void 0 ? void 0 : document.id) || null;
|
|
51
|
+
};
|
|
52
|
+
|
|
48
53
|
export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
49
54
|
function SharingProvider(props, context) {
|
|
50
55
|
var _props$isPublic;
|
|
@@ -644,9 +649,192 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
644
649
|
};
|
|
645
650
|
}());
|
|
646
651
|
|
|
652
|
+
_defineProperty(_this2, "fetchSharingLinks", /*#__PURE__*/function () {
|
|
653
|
+
var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(document) {
|
|
654
|
+
var permissionCol,
|
|
655
|
+
documentId,
|
|
656
|
+
response,
|
|
657
|
+
permissions,
|
|
658
|
+
existingPermissions,
|
|
659
|
+
existingPermissionIds,
|
|
660
|
+
newPermissions,
|
|
661
|
+
_args12 = arguments;
|
|
662
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
663
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
664
|
+
case 0:
|
|
665
|
+
permissionCol = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : _this2.permissionCol;
|
|
666
|
+
documentId = getDocumentId(document);
|
|
667
|
+
|
|
668
|
+
if (documentId) {
|
|
669
|
+
_context12.next = 4;
|
|
670
|
+
break;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
return _context12.abrupt("return", []);
|
|
674
|
+
|
|
675
|
+
case 4:
|
|
676
|
+
if (!document.driveId) {
|
|
677
|
+
_context12.next = 10;
|
|
678
|
+
break;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
_context12.next = 7;
|
|
682
|
+
return permissionCol.findLinksByIds([documentId]);
|
|
683
|
+
|
|
684
|
+
case 7:
|
|
685
|
+
_context12.t0 = _context12.sent;
|
|
686
|
+
_context12.next = 13;
|
|
687
|
+
break;
|
|
688
|
+
|
|
689
|
+
case 10:
|
|
690
|
+
_context12.next = 12;
|
|
691
|
+
return permissionCol.findLinksByDoctype(_this2.props.doctype);
|
|
692
|
+
|
|
693
|
+
case 12:
|
|
694
|
+
_context12.t0 = _context12.sent;
|
|
695
|
+
|
|
696
|
+
case 13:
|
|
697
|
+
response = _context12.t0;
|
|
698
|
+
permissions = ((response === null || response === void 0 ? void 0 : response.data) || []).filter(function (permission) {
|
|
699
|
+
return document.driveId || getPermissionDocIds(permission).includes(documentId);
|
|
700
|
+
});
|
|
701
|
+
existingPermissions = _getDocumentPermissions(_this2.state, documentId);
|
|
702
|
+
existingPermissionIds = existingPermissions.map(function (permission) {
|
|
703
|
+
return permission.id;
|
|
704
|
+
});
|
|
705
|
+
newPermissions = permissions.filter(function (permission) {
|
|
706
|
+
return !existingPermissionIds.includes(permission.id);
|
|
707
|
+
});
|
|
708
|
+
|
|
709
|
+
if (newPermissions.length > 0) {
|
|
710
|
+
_this2.dispatch(addSharingLink(newPermissions));
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
return _context12.abrupt("return", permissions);
|
|
714
|
+
|
|
715
|
+
case 20:
|
|
716
|
+
case "end":
|
|
717
|
+
return _context12.stop();
|
|
718
|
+
}
|
|
719
|
+
}, _callee12);
|
|
720
|
+
}));
|
|
721
|
+
|
|
722
|
+
return function (_x21) {
|
|
723
|
+
return _ref14.apply(this, arguments);
|
|
724
|
+
};
|
|
725
|
+
}());
|
|
726
|
+
|
|
727
|
+
_defineProperty(_this2, "ensureSharingLink", /*#__PURE__*/function () {
|
|
728
|
+
var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(document, linkAccess) {
|
|
729
|
+
var documentId, permissions, _getLinkAccessOptions, verbs, expiresAt, ttl, password, permissionResponse, permission, sharecode;
|
|
730
|
+
|
|
731
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
732
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
733
|
+
case 0:
|
|
734
|
+
documentId = getDocumentId(document);
|
|
735
|
+
|
|
736
|
+
if (documentId) {
|
|
737
|
+
_context13.next = 3;
|
|
738
|
+
break;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
throw new Error('Sharing links require a document id');
|
|
742
|
+
|
|
743
|
+
case 3:
|
|
744
|
+
if (!document.driveId) {
|
|
745
|
+
_context13.next = 9;
|
|
746
|
+
break;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
_context13.next = 6;
|
|
750
|
+
return _this2.fetchSharedDriveSharingLinks(document);
|
|
751
|
+
|
|
752
|
+
case 6:
|
|
753
|
+
_context13.t0 = _context13.sent;
|
|
754
|
+
_context13.next = 12;
|
|
755
|
+
break;
|
|
756
|
+
|
|
757
|
+
case 9:
|
|
758
|
+
_context13.next = 11;
|
|
759
|
+
return _this2.fetchSharingLinks(document);
|
|
760
|
+
|
|
761
|
+
case 11:
|
|
762
|
+
_context13.t0 = _context13.sent;
|
|
763
|
+
|
|
764
|
+
case 12:
|
|
765
|
+
permissions = _context13.t0;
|
|
766
|
+
_getLinkAccessOptions = getLinkAccessOptions(linkAccess), verbs = _getLinkAccessOptions.verbs, expiresAt = _getLinkAccessOptions.expiresAt, ttl = _getLinkAccessOptions.ttl, password = _getLinkAccessOptions.password;
|
|
767
|
+
|
|
768
|
+
if (!(permissions.length > 0)) {
|
|
769
|
+
_context13.next = 20;
|
|
770
|
+
break;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
_context13.next = 17;
|
|
774
|
+
return _this2.updateDocumentPermissions(_objectSpread(_objectSpread({}, document), {}, {
|
|
775
|
+
id: documentId
|
|
776
|
+
}), {
|
|
777
|
+
verbs: verbs,
|
|
778
|
+
expiresAt: expiresAt,
|
|
779
|
+
password: password
|
|
780
|
+
}, permissions);
|
|
781
|
+
|
|
782
|
+
case 17:
|
|
783
|
+
_context13.t1 = _context13.sent[0];
|
|
784
|
+
_context13.next = 23;
|
|
785
|
+
break;
|
|
786
|
+
|
|
787
|
+
case 20:
|
|
788
|
+
_context13.next = 22;
|
|
789
|
+
return _this2.shareByLink(document, {
|
|
790
|
+
verbs: verbs,
|
|
791
|
+
ttl: ttl,
|
|
792
|
+
password: password
|
|
793
|
+
});
|
|
794
|
+
|
|
795
|
+
case 22:
|
|
796
|
+
_context13.t1 = _context13.sent;
|
|
797
|
+
|
|
798
|
+
case 23:
|
|
799
|
+
permissionResponse = _context13.t1;
|
|
800
|
+
permission = permissionResponse === null || permissionResponse === void 0 ? void 0 : permissionResponse.data;
|
|
801
|
+
sharecode = getShortcode(permission);
|
|
802
|
+
|
|
803
|
+
if (sharecode) {
|
|
804
|
+
_context13.next = 28;
|
|
805
|
+
break;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
throw new Error('Sharing permission does not contain a shortcode');
|
|
809
|
+
|
|
810
|
+
case 28:
|
|
811
|
+
return _context13.abrupt("return", {
|
|
812
|
+
documentId: documentId,
|
|
813
|
+
url: generateShareLinkFromFile({
|
|
814
|
+
client: _this2.props.client,
|
|
815
|
+
file: document,
|
|
816
|
+
sharecode: sharecode,
|
|
817
|
+
getOwner: _this2.state.getOwner,
|
|
818
|
+
getSharingById: _this2.state.getSharingById,
|
|
819
|
+
documentType: _this2.state.documentType
|
|
820
|
+
})
|
|
821
|
+
});
|
|
822
|
+
|
|
823
|
+
case 29:
|
|
824
|
+
case "end":
|
|
825
|
+
return _context13.stop();
|
|
826
|
+
}
|
|
827
|
+
}, _callee13);
|
|
828
|
+
}));
|
|
829
|
+
|
|
830
|
+
return function (_x22, _x23) {
|
|
831
|
+
return _ref15.apply(this, arguments);
|
|
832
|
+
};
|
|
833
|
+
}());
|
|
834
|
+
|
|
647
835
|
_defineProperty(_this2, "getFederatedShareLink", function (document) {
|
|
648
836
|
if (!(document !== null && document !== void 0 && document.driveId)) return null;
|
|
649
|
-
var documentId = document
|
|
837
|
+
var documentId = getDocumentId(document);
|
|
650
838
|
if (!documentId) return null;
|
|
651
839
|
|
|
652
840
|
var permissions = _getDocumentPermissions(_this2.state, documentId);
|
|
@@ -669,127 +857,99 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
669
857
|
});
|
|
670
858
|
|
|
671
859
|
_defineProperty(_this2, "createSharedDriveSharingLink", /*#__PURE__*/function () {
|
|
672
|
-
var
|
|
860
|
+
var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(document, options) {
|
|
673
861
|
var client, drivePermissionCollection, resp;
|
|
674
|
-
return _regeneratorRuntime.wrap(function
|
|
675
|
-
while (1) switch (
|
|
862
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
863
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
676
864
|
case 0:
|
|
677
865
|
client = _this2.props.client;
|
|
678
866
|
drivePermissionCollection = client.collection('io.cozy.permissions', {
|
|
679
867
|
driveId: document.driveId
|
|
680
868
|
});
|
|
681
|
-
|
|
869
|
+
_context14.next = 4;
|
|
682
870
|
return drivePermissionCollection.createSharingLink(document, options);
|
|
683
871
|
|
|
684
872
|
case 4:
|
|
685
|
-
resp =
|
|
686
|
-
return
|
|
873
|
+
resp = _context14.sent;
|
|
874
|
+
return _context14.abrupt("return", resp);
|
|
687
875
|
|
|
688
876
|
case 6:
|
|
689
877
|
case "end":
|
|
690
|
-
return
|
|
878
|
+
return _context14.stop();
|
|
691
879
|
}
|
|
692
|
-
},
|
|
880
|
+
}, _callee14);
|
|
693
881
|
}));
|
|
694
882
|
|
|
695
|
-
return function (
|
|
696
|
-
return
|
|
883
|
+
return function (_x24, _x25) {
|
|
884
|
+
return _ref16.apply(this, arguments);
|
|
697
885
|
};
|
|
698
886
|
}());
|
|
699
887
|
|
|
700
888
|
_defineProperty(_this2, "fetchSharedDriveSharingLinks", /*#__PURE__*/function () {
|
|
701
|
-
var
|
|
702
|
-
var client, drivePermissionCollection
|
|
703
|
-
return _regeneratorRuntime.wrap(function
|
|
704
|
-
while (1) switch (
|
|
889
|
+
var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(document) {
|
|
890
|
+
var client, drivePermissionCollection;
|
|
891
|
+
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
892
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
705
893
|
case 0:
|
|
706
894
|
if (!(!document || !document.driveId)) {
|
|
707
|
-
|
|
895
|
+
_context15.next = 2;
|
|
708
896
|
break;
|
|
709
897
|
}
|
|
710
898
|
|
|
711
|
-
return
|
|
899
|
+
return _context15.abrupt("return", []);
|
|
712
900
|
|
|
713
901
|
case 2:
|
|
714
902
|
client = _this2.props.client;
|
|
715
903
|
drivePermissionCollection = client.collection('io.cozy.permissions', {
|
|
716
904
|
driveId: document.driveId
|
|
717
905
|
});
|
|
718
|
-
|
|
906
|
+
return _context15.abrupt("return", _this2.fetchSharingLinks(document, drivePermissionCollection));
|
|
719
907
|
|
|
720
|
-
|
|
721
|
-
_context13.next = 7;
|
|
722
|
-
break;
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
return _context13.abrupt("return", []);
|
|
726
|
-
|
|
727
|
-
case 7:
|
|
728
|
-
_context13.next = 9;
|
|
729
|
-
return drivePermissionCollection.findLinksByIds([documentId]);
|
|
730
|
-
|
|
731
|
-
case 9:
|
|
732
|
-
resp = _context13.sent;
|
|
733
|
-
permissions = resp.data || [];
|
|
734
|
-
existingPermissions = _getDocumentPermissions(_this2.state, documentId);
|
|
735
|
-
existingPermissionIds = existingPermissions.map(function (permission) {
|
|
736
|
-
return permission.id;
|
|
737
|
-
});
|
|
738
|
-
newPermissions = permissions.filter(function (permission) {
|
|
739
|
-
return !existingPermissionIds.includes(permission.id);
|
|
740
|
-
});
|
|
741
|
-
|
|
742
|
-
if (newPermissions.length > 0) {
|
|
743
|
-
_this2.dispatch(addSharingLink(newPermissions));
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
return _context13.abrupt("return", permissions);
|
|
747
|
-
|
|
748
|
-
case 16:
|
|
908
|
+
case 5:
|
|
749
909
|
case "end":
|
|
750
|
-
return
|
|
910
|
+
return _context15.stop();
|
|
751
911
|
}
|
|
752
|
-
},
|
|
912
|
+
}, _callee15);
|
|
753
913
|
}));
|
|
754
914
|
|
|
755
|
-
return function (
|
|
756
|
-
return
|
|
915
|
+
return function (_x26) {
|
|
916
|
+
return _ref17.apply(this, arguments);
|
|
757
917
|
};
|
|
758
918
|
}());
|
|
759
919
|
|
|
760
920
|
_defineProperty(_this2, "updateSharedDrivePermissions", /*#__PURE__*/function () {
|
|
761
|
-
var
|
|
921
|
+
var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(document, permissionDocument, updatedPermissions, options) {
|
|
762
922
|
var client, expiresAt, password, drivePermissionCollection, resp;
|
|
763
|
-
return _regeneratorRuntime.wrap(function
|
|
764
|
-
while (1) switch (
|
|
923
|
+
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
924
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
765
925
|
case 0:
|
|
766
926
|
client = _this2.props.client;
|
|
767
927
|
expiresAt = options.expiresAt, password = options.password;
|
|
768
928
|
drivePermissionCollection = client.collection('io.cozy.permissions', {
|
|
769
929
|
driveId: document.driveId
|
|
770
930
|
});
|
|
771
|
-
|
|
931
|
+
_context16.next = 5;
|
|
772
932
|
return drivePermissionCollection.add(permissionDocument, updatedPermissions, {
|
|
773
933
|
expiresAt: expiresAt,
|
|
774
934
|
password: password
|
|
775
935
|
});
|
|
776
936
|
|
|
777
937
|
case 5:
|
|
778
|
-
resp =
|
|
938
|
+
resp = _context16.sent;
|
|
779
939
|
|
|
780
940
|
_this2.dispatch(updateSharingLink(resp.data));
|
|
781
941
|
|
|
782
|
-
return
|
|
942
|
+
return _context16.abrupt("return", resp);
|
|
783
943
|
|
|
784
944
|
case 8:
|
|
785
945
|
case "end":
|
|
786
|
-
return
|
|
946
|
+
return _context16.stop();
|
|
787
947
|
}
|
|
788
|
-
},
|
|
948
|
+
}, _callee16);
|
|
789
949
|
}));
|
|
790
950
|
|
|
791
|
-
return function (
|
|
792
|
-
return
|
|
951
|
+
return function (_x27, _x28, _x29, _x30) {
|
|
952
|
+
return _ref18.apply(this, arguments);
|
|
793
953
|
};
|
|
794
954
|
}());
|
|
795
955
|
|
|
@@ -801,147 +961,163 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
801
961
|
* @param {string[]} options.verbs The new verbs to use for the permission, eg. ['GET']
|
|
802
962
|
* @param {string} [options.expiresAt] The new expiration date for the permission
|
|
803
963
|
* @param {string} [options.password] The new password for the permission
|
|
964
|
+
* @param {object[]|null} [permissionsToUpdate] Permission documents to update
|
|
965
|
+
* instead of the document's permissions from state
|
|
804
966
|
*
|
|
805
967
|
* @return {Array}
|
|
806
968
|
*/
|
|
807
969
|
_defineProperty(_this2, "updateDocumentPermissions", /*#__PURE__*/function () {
|
|
808
|
-
var
|
|
809
|
-
var
|
|
810
|
-
|
|
811
|
-
|
|
970
|
+
var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(document, options) {
|
|
971
|
+
var permissionsToUpdate,
|
|
972
|
+
verbs,
|
|
973
|
+
expiresAt,
|
|
974
|
+
password,
|
|
975
|
+
documentId,
|
|
976
|
+
permissions,
|
|
977
|
+
responses,
|
|
978
|
+
_args18 = arguments;
|
|
979
|
+
return _regeneratorRuntime.wrap(function _callee18$(_context18) {
|
|
980
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
812
981
|
case 0:
|
|
982
|
+
permissionsToUpdate = _args18.length > 2 && _args18[2] !== undefined ? _args18[2] : null;
|
|
813
983
|
verbs = options.verbs, expiresAt = options.expiresAt, password = options.password;
|
|
814
|
-
|
|
984
|
+
documentId = getDocumentId(document);
|
|
985
|
+
permissions = permissionsToUpdate || _getDocumentPermissions(_this2.state, documentId);
|
|
815
986
|
|
|
816
987
|
if (!(!permissions || permissions.length === 0)) {
|
|
817
|
-
|
|
988
|
+
_context18.next = 6;
|
|
818
989
|
break;
|
|
819
990
|
}
|
|
820
991
|
|
|
821
|
-
return
|
|
992
|
+
return _context18.abrupt("return", []);
|
|
822
993
|
|
|
823
|
-
case
|
|
824
|
-
|
|
994
|
+
case 6:
|
|
995
|
+
_context18.next = 8;
|
|
825
996
|
return Promise.all(permissions.map( /*#__PURE__*/function () {
|
|
826
|
-
var
|
|
997
|
+
var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(permissionDocument) {
|
|
827
998
|
var updatedPermissions, resp;
|
|
828
|
-
return _regeneratorRuntime.wrap(function
|
|
829
|
-
while (1) switch (
|
|
999
|
+
return _regeneratorRuntime.wrap(function _callee17$(_context17) {
|
|
1000
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
830
1001
|
case 0:
|
|
831
|
-
updatedPermissions = permissionDocument.attributes.permissions
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
1002
|
+
updatedPermissions = Object.fromEntries(Object.entries(permissionDocument.attributes.permissions).map(function (_ref21) {
|
|
1003
|
+
var _ref22 = _slicedToArray(_ref21, 2),
|
|
1004
|
+
permissionType = _ref22[0],
|
|
1005
|
+
rules = _ref22[1];
|
|
1006
|
+
|
|
1007
|
+
return [permissionType, _objectSpread(_objectSpread({}, rules), {}, {
|
|
1008
|
+
verbs: verbs
|
|
1009
|
+
})];
|
|
1010
|
+
}));
|
|
835
1011
|
|
|
836
1012
|
if (!document.driveId) {
|
|
837
|
-
|
|
1013
|
+
_context17.next = 7;
|
|
838
1014
|
break;
|
|
839
1015
|
}
|
|
840
1016
|
|
|
841
|
-
|
|
1017
|
+
_context17.next = 4;
|
|
842
1018
|
return _this2.updateSharedDrivePermissions(document, permissionDocument, updatedPermissions, options);
|
|
843
1019
|
|
|
844
|
-
case
|
|
845
|
-
|
|
846
|
-
|
|
1020
|
+
case 4:
|
|
1021
|
+
_context17.t0 = _context17.sent;
|
|
1022
|
+
_context17.next = 10;
|
|
847
1023
|
break;
|
|
848
1024
|
|
|
849
|
-
case
|
|
850
|
-
|
|
1025
|
+
case 7:
|
|
1026
|
+
_context17.next = 9;
|
|
851
1027
|
return _this2.permissionCol.add(permissionDocument, updatedPermissions, {
|
|
852
1028
|
expiresAt: expiresAt,
|
|
853
1029
|
password: password
|
|
854
1030
|
});
|
|
855
1031
|
|
|
856
|
-
case
|
|
857
|
-
|
|
1032
|
+
case 9:
|
|
1033
|
+
_context17.t0 = _context17.sent;
|
|
858
1034
|
|
|
859
|
-
case
|
|
860
|
-
resp =
|
|
1035
|
+
case 10:
|
|
1036
|
+
resp = _context17.t0;
|
|
861
1037
|
|
|
862
1038
|
_this2.dispatch(updateSharingLink(resp.data));
|
|
863
1039
|
|
|
864
|
-
return
|
|
1040
|
+
return _context17.abrupt("return", resp);
|
|
865
1041
|
|
|
866
|
-
case
|
|
1042
|
+
case 13:
|
|
867
1043
|
case "end":
|
|
868
|
-
return
|
|
1044
|
+
return _context17.stop();
|
|
869
1045
|
}
|
|
870
|
-
},
|
|
1046
|
+
}, _callee17);
|
|
871
1047
|
}));
|
|
872
1048
|
|
|
873
|
-
return function (
|
|
874
|
-
return
|
|
1049
|
+
return function (_x33) {
|
|
1050
|
+
return _ref20.apply(this, arguments);
|
|
875
1051
|
};
|
|
876
1052
|
}()));
|
|
877
1053
|
|
|
878
|
-
case 6:
|
|
879
|
-
responses = _context16.sent;
|
|
880
|
-
return _context16.abrupt("return", responses);
|
|
881
|
-
|
|
882
1054
|
case 8:
|
|
1055
|
+
responses = _context18.sent;
|
|
1056
|
+
return _context18.abrupt("return", responses);
|
|
1057
|
+
|
|
1058
|
+
case 10:
|
|
883
1059
|
case "end":
|
|
884
|
-
return
|
|
1060
|
+
return _context18.stop();
|
|
885
1061
|
}
|
|
886
|
-
},
|
|
1062
|
+
}, _callee18);
|
|
887
1063
|
}));
|
|
888
1064
|
|
|
889
|
-
return function (
|
|
890
|
-
return
|
|
1065
|
+
return function (_x31, _x32) {
|
|
1066
|
+
return _ref19.apply(this, arguments);
|
|
891
1067
|
};
|
|
892
1068
|
}());
|
|
893
1069
|
|
|
894
1070
|
_defineProperty(_this2, "revokeSharedDriveSharingLink", /*#__PURE__*/function () {
|
|
895
|
-
var
|
|
1071
|
+
var _ref23 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(document, perms) {
|
|
896
1072
|
var client, drivePermissionCollection;
|
|
897
|
-
return _regeneratorRuntime.wrap(function
|
|
898
|
-
while (1) switch (
|
|
1073
|
+
return _regeneratorRuntime.wrap(function _callee19$(_context19) {
|
|
1074
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
899
1075
|
case 0:
|
|
900
1076
|
client = _this2.props.client;
|
|
901
1077
|
drivePermissionCollection = client.collection('io.cozy.permissions', {
|
|
902
1078
|
driveId: document.driveId
|
|
903
1079
|
});
|
|
904
|
-
|
|
1080
|
+
_context19.next = 4;
|
|
905
1081
|
return Promise.all(perms.map(function (p) {
|
|
906
1082
|
return drivePermissionCollection.destroy(p);
|
|
907
1083
|
}));
|
|
908
1084
|
|
|
909
1085
|
case 4:
|
|
910
1086
|
case "end":
|
|
911
|
-
return
|
|
1087
|
+
return _context19.stop();
|
|
912
1088
|
}
|
|
913
|
-
},
|
|
1089
|
+
}, _callee19);
|
|
914
1090
|
}));
|
|
915
1091
|
|
|
916
|
-
return function (
|
|
917
|
-
return
|
|
1092
|
+
return function (_x34, _x35) {
|
|
1093
|
+
return _ref23.apply(this, arguments);
|
|
918
1094
|
};
|
|
919
1095
|
}());
|
|
920
1096
|
|
|
921
1097
|
_defineProperty(_this2, "revokeSharingLink", /*#__PURE__*/function () {
|
|
922
|
-
var
|
|
1098
|
+
var _ref24 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(document) {
|
|
923
1099
|
var perms;
|
|
924
|
-
return _regeneratorRuntime.wrap(function
|
|
925
|
-
while (1) switch (
|
|
1100
|
+
return _regeneratorRuntime.wrap(function _callee20$(_context20) {
|
|
1101
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
926
1102
|
case 0:
|
|
927
1103
|
// Because some duplicate links have been created in the past, we must ensure
|
|
928
1104
|
// we revoke all of them
|
|
929
1105
|
perms = _getDocumentPermissions(_this2.state, document.id);
|
|
930
1106
|
|
|
931
1107
|
if (!document.driveId) {
|
|
932
|
-
|
|
1108
|
+
_context20.next = 6;
|
|
933
1109
|
break;
|
|
934
1110
|
}
|
|
935
1111
|
|
|
936
|
-
|
|
1112
|
+
_context20.next = 4;
|
|
937
1113
|
return _this2.revokeSharedDriveSharingLink(document, perms);
|
|
938
1114
|
|
|
939
1115
|
case 4:
|
|
940
|
-
|
|
1116
|
+
_context20.next = 8;
|
|
941
1117
|
break;
|
|
942
1118
|
|
|
943
1119
|
case 6:
|
|
944
|
-
|
|
1120
|
+
_context20.next = 8;
|
|
945
1121
|
return Promise.all(perms.map(function (p) {
|
|
946
1122
|
return _this2.permissionCol.destroy(p);
|
|
947
1123
|
}));
|
|
@@ -951,13 +1127,13 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
951
1127
|
|
|
952
1128
|
case 9:
|
|
953
1129
|
case "end":
|
|
954
|
-
return
|
|
1130
|
+
return _context20.stop();
|
|
955
1131
|
}
|
|
956
|
-
},
|
|
1132
|
+
}, _callee20);
|
|
957
1133
|
}));
|
|
958
1134
|
|
|
959
|
-
return function (
|
|
960
|
-
return
|
|
1135
|
+
return function (_x36) {
|
|
1136
|
+
return _ref24.apply(this, arguments);
|
|
961
1137
|
};
|
|
962
1138
|
}());
|
|
963
1139
|
|
|
@@ -1042,6 +1218,7 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
1042
1218
|
revokeGroup: _this2.revokeGroup,
|
|
1043
1219
|
revokeSelf: _this2.revokeSelf,
|
|
1044
1220
|
shareByLink: _this2.shareByLink,
|
|
1221
|
+
ensureSharingLink: _this2.ensureSharingLink,
|
|
1045
1222
|
getFederatedShareLink: _this2.getFederatedShareLink,
|
|
1046
1223
|
fetchSharedDriveSharingLinks: _this2.fetchSharedDriveSharingLinks,
|
|
1047
1224
|
updateDocumentPermissions: _this2.updateDocumentPermissions,
|
|
@@ -1088,14 +1265,14 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
1088
1265
|
}, {
|
|
1089
1266
|
key: "fetchAllSharings",
|
|
1090
1267
|
value: function () {
|
|
1091
|
-
var _fetchAllSharings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1268
|
+
var _fetchAllSharings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21() {
|
|
1092
1269
|
var _this$props, doctype, client, _yield$Promise$all, _yield$Promise$all2, sharings, permissions, apps, sharedDocIds, resp, folderPaths, filePaths;
|
|
1093
1270
|
|
|
1094
|
-
return _regeneratorRuntime.wrap(function
|
|
1095
|
-
while (1) switch (
|
|
1271
|
+
return _regeneratorRuntime.wrap(function _callee21$(_context21) {
|
|
1272
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1096
1273
|
case 0:
|
|
1097
1274
|
if (!this.isPublic) {
|
|
1098
|
-
|
|
1275
|
+
_context21.next = 4;
|
|
1099
1276
|
break;
|
|
1100
1277
|
}
|
|
1101
1278
|
|
|
@@ -1104,17 +1281,17 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
1104
1281
|
this.setState({
|
|
1105
1282
|
allLoaded: true
|
|
1106
1283
|
});
|
|
1107
|
-
return
|
|
1284
|
+
return _context21.abrupt("return");
|
|
1108
1285
|
|
|
1109
1286
|
case 4:
|
|
1110
1287
|
_this$props = this.props, doctype = _this$props.doctype, client = _this$props.client;
|
|
1111
|
-
|
|
1288
|
+
_context21.next = 7;
|
|
1112
1289
|
return Promise.all([this.sharingCol.findByDoctype(doctype, {
|
|
1113
1290
|
withSharedDocs: false
|
|
1114
1291
|
}), this.permissionCol.findLinksByDoctype(doctype), client.fetchQueryAndGetFromState(fetchApps())]);
|
|
1115
1292
|
|
|
1116
1293
|
case 7:
|
|
1117
|
-
_yield$Promise$all =
|
|
1294
|
+
_yield$Promise$all = _context21.sent;
|
|
1118
1295
|
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
|
|
1119
1296
|
sharings = _yield$Promise$all2[0];
|
|
1120
1297
|
permissions = _yield$Promise$all2[1];
|
|
@@ -1128,35 +1305,35 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
1128
1305
|
this.setState({
|
|
1129
1306
|
hasLoadedAtLeastOnePage: true
|
|
1130
1307
|
});
|
|
1131
|
-
|
|
1308
|
+
_context21.next = 16;
|
|
1132
1309
|
return fetchNextPermissions(permissions, this.dispatch, this.permissionCol);
|
|
1133
1310
|
|
|
1134
1311
|
case 16:
|
|
1135
1312
|
if (!(doctype === 'io.cozy.files')) {
|
|
1136
|
-
|
|
1313
|
+
_context21.next = 26;
|
|
1137
1314
|
break;
|
|
1138
1315
|
}
|
|
1139
1316
|
|
|
1140
1317
|
sharedDocIds = getSharedDocIdsBySharings(sharings);
|
|
1141
|
-
|
|
1318
|
+
_context21.next = 20;
|
|
1142
1319
|
return client.collection(doctype).all({
|
|
1143
1320
|
keys: sharedDocIds
|
|
1144
1321
|
});
|
|
1145
1322
|
|
|
1146
1323
|
case 20:
|
|
1147
|
-
resp =
|
|
1324
|
+
resp = _context21.sent;
|
|
1148
1325
|
folderPaths = resp.data.filter(function (f) {
|
|
1149
1326
|
return f.type === 'directory' && !f.trashed;
|
|
1150
1327
|
}).map(function (f) {
|
|
1151
1328
|
return f.path;
|
|
1152
1329
|
});
|
|
1153
|
-
|
|
1330
|
+
_context21.next = 24;
|
|
1154
1331
|
return fetchFilesPaths(client, doctype, resp.data.filter(function (f) {
|
|
1155
1332
|
return f.type !== 'directory' && !f.trashed;
|
|
1156
1333
|
}));
|
|
1157
1334
|
|
|
1158
1335
|
case 24:
|
|
1159
|
-
filePaths =
|
|
1336
|
+
filePaths = _context21.sent;
|
|
1160
1337
|
this.dispatch(receivePaths([].concat(_toConsumableArray(folderPaths), _toConsumableArray(filePaths))));
|
|
1161
1338
|
|
|
1162
1339
|
case 26:
|
|
@@ -1166,9 +1343,9 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
1166
1343
|
|
|
1167
1344
|
case 27:
|
|
1168
1345
|
case "end":
|
|
1169
|
-
return
|
|
1346
|
+
return _context21.stop();
|
|
1170
1347
|
}
|
|
1171
|
-
},
|
|
1348
|
+
}, _callee21, this);
|
|
1172
1349
|
}));
|
|
1173
1350
|
|
|
1174
1351
|
function fetchAllSharings() {
|