cozy-sharing 28.4.3 → 28.5.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/SharingProvider.js +192 -58
- package/dist/SharingProvider.spec.js +180 -2
- package/dist/components/FederatedFolder/DumbFederatedFolderModal.js +7 -4
- package/dist/components/FederatedFolder/FederatedFolderModal.js +79 -23
- package/dist/components/ShareByLink.js +5 -1
- package/dist/components/ShareRestrictionModal/helpers.js +66 -29
- package/dist/components/SharedDrive/DumbSharedDriveModal.js +1 -1
- package/dist/components/SharedFolder/DumbBatchSharedFolderModal.js +17 -4
- package/dist/helpers/shortcodes.js +24 -0
- package/dist/state.js +3 -10
- package/package.json +5 -5
- package/src/SharingProvider.jsx +77 -8
- package/src/SharingProvider.spec.jsx +130 -1
- package/src/components/FederatedFolder/DumbFederatedFolderModal.jsx +6 -3
- package/src/components/FederatedFolder/FederatedFolderModal.jsx +39 -6
- package/src/components/ShareByLink.jsx +3 -1
- package/src/components/ShareRestrictionModal/helpers.js +42 -4
- package/src/components/SharedDrive/DumbSharedDriveModal.jsx +1 -1
- package/src/components/SharedFolder/DumbBatchSharedFolderModal.jsx +32 -16
- package/src/helpers/shortcodes.js +28 -0
- package/src/state.js +3 -14
|
@@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { useI18n } from 'twake-i18n';
|
|
4
4
|
import withLocales from '../../hoc/withLocales';
|
|
5
|
-
import DumbBatchSharedFolderModal from '../SharedFolder/DumbBatchSharedFolderModal';
|
|
5
|
+
import { DumbBatchSharedFolderModal } from '../SharedFolder/DumbBatchSharedFolderModal';
|
|
6
6
|
export var DumbFederatedFolderModal = withLocales(function (_ref) {
|
|
7
7
|
var title = _ref.title,
|
|
8
8
|
document = _ref.document,
|
|
@@ -15,7 +15,8 @@ export var DumbFederatedFolderModal = withLocales(function (_ref) {
|
|
|
15
15
|
onSend = _ref.onSend,
|
|
16
16
|
onClose = _ref.onClose,
|
|
17
17
|
onShare = _ref.onShare,
|
|
18
|
-
sharingLink = _ref.sharingLink
|
|
18
|
+
sharingLink = _ref.sharingLink,
|
|
19
|
+
showShareByEmail = _ref.showShareByEmail;
|
|
19
20
|
|
|
20
21
|
var _useI18n = useI18n(),
|
|
21
22
|
t = _useI18n.t;
|
|
@@ -36,7 +37,8 @@ export var DumbFederatedFolderModal = withLocales(function (_ref) {
|
|
|
36
37
|
showNameField: false,
|
|
37
38
|
addPeopleLabel: t('FederatedFolder.addPeople'),
|
|
38
39
|
addButtonLabel: t('FederatedFolder.add'),
|
|
39
|
-
shareLabel: t('FederatedFolder.share')
|
|
40
|
+
shareLabel: t('FederatedFolder.share'),
|
|
41
|
+
showShareByEmail: showShareByEmail
|
|
40
42
|
});
|
|
41
43
|
});
|
|
42
44
|
DumbFederatedFolderModal.propTypes = {
|
|
@@ -51,6 +53,7 @@ DumbFederatedFolderModal.propTypes = {
|
|
|
51
53
|
onSend: PropTypes.func.isRequired,
|
|
52
54
|
onClose: PropTypes.func.isRequired,
|
|
53
55
|
onShare: PropTypes.func.isRequired,
|
|
54
|
-
sharingLink: PropTypes.string
|
|
56
|
+
sharingLink: PropTypes.string,
|
|
57
|
+
showShareByEmail: PropTypes.bool
|
|
55
58
|
};
|
|
56
59
|
export default DumbFederatedFolderModal;
|
|
@@ -2,7 +2,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
|
-
import React, { useState } from 'react';
|
|
5
|
+
import React, { useState, useEffect } from 'react';
|
|
6
6
|
import { useI18n } from 'twake-i18n';
|
|
7
7
|
import { useClient } from 'cozy-client';
|
|
8
8
|
import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert';
|
|
@@ -20,25 +20,79 @@ export var FederatedFolderModal = withLocales(function (_ref) {
|
|
|
20
20
|
|
|
21
21
|
var _useSharingContext = useSharingContext(),
|
|
22
22
|
share = _useSharingContext.share,
|
|
23
|
-
getSharingLink = _useSharingContext.getSharingLink
|
|
23
|
+
getSharingLink = _useSharingContext.getSharingLink,
|
|
24
|
+
getFederatedShareLink = _useSharingContext.getFederatedShareLink,
|
|
25
|
+
getDocumentPermissions = _useSharingContext.getDocumentPermissions,
|
|
26
|
+
getOwner = _useSharingContext.getOwner,
|
|
27
|
+
getSharingById = _useSharingContext.getSharingById;
|
|
24
28
|
|
|
25
29
|
var _useAlert = useAlert(),
|
|
26
|
-
showAlert = _useAlert.showAlert;
|
|
30
|
+
showAlert = _useAlert.showAlert;
|
|
27
31
|
|
|
32
|
+
var _useState = useState(null),
|
|
33
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
34
|
+
sharingLink = _useState2[0],
|
|
35
|
+
setSharingLink = _useState2[1];
|
|
36
|
+
|
|
37
|
+
var documentPermissions = existingDocument ? getDocumentPermissions(existingDocument._id) : [];
|
|
38
|
+
useEffect(function () {
|
|
39
|
+
var fetchSharingLink = /*#__PURE__*/function () {
|
|
40
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
41
|
+
var link;
|
|
42
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
43
|
+
while (1) switch (_context.prev = _context.next) {
|
|
44
|
+
case 0:
|
|
45
|
+
if (existingDocument) {
|
|
46
|
+
_context.next = 2;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return _context.abrupt("return");
|
|
51
|
+
|
|
52
|
+
case 2:
|
|
53
|
+
if (!existingDocument.driveId) {
|
|
54
|
+
_context.next = 9;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
_context.next = 5;
|
|
59
|
+
return getFederatedShareLink(existingDocument);
|
|
60
|
+
|
|
61
|
+
case 5:
|
|
62
|
+
link = _context.sent;
|
|
63
|
+
setSharingLink(link);
|
|
64
|
+
_context.next = 10;
|
|
65
|
+
break;
|
|
66
|
+
|
|
67
|
+
case 9:
|
|
68
|
+
setSharingLink(getSharingLink(existingDocument._id));
|
|
69
|
+
|
|
70
|
+
case 10:
|
|
71
|
+
case "end":
|
|
72
|
+
return _context.stop();
|
|
73
|
+
}
|
|
74
|
+
}, _callee);
|
|
75
|
+
}));
|
|
76
|
+
|
|
77
|
+
return function fetchSharingLink() {
|
|
78
|
+
return _ref2.apply(this, arguments);
|
|
79
|
+
};
|
|
80
|
+
}();
|
|
28
81
|
|
|
29
|
-
|
|
82
|
+
fetchSharingLink();
|
|
83
|
+
}, [existingDocument, documentPermissions, getFederatedShareLink, getSharingLink, getOwner, getSharingById]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
30
84
|
|
|
31
|
-
var
|
|
85
|
+
var _useState3 = useState({
|
|
32
86
|
recipients: [],
|
|
33
87
|
readOnlyRecipients: []
|
|
34
88
|
}),
|
|
35
|
-
|
|
36
|
-
federatedRecipients =
|
|
37
|
-
setFederatedRecipients =
|
|
89
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
90
|
+
federatedRecipients = _useState4[0],
|
|
91
|
+
setFederatedRecipients = _useState4[1];
|
|
38
92
|
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
folderName =
|
|
93
|
+
var _useState5 = useState((existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument.name) || ''),
|
|
94
|
+
_useState6 = _slicedToArray(_useState5, 1),
|
|
95
|
+
folderName = _useState6[0];
|
|
42
96
|
|
|
43
97
|
var onShare = function onShare(params) {
|
|
44
98
|
setFederatedRecipients({
|
|
@@ -48,12 +102,12 @@ export var FederatedFolderModal = withLocales(function (_ref) {
|
|
|
48
102
|
};
|
|
49
103
|
|
|
50
104
|
var onSend = /*#__PURE__*/function () {
|
|
51
|
-
var
|
|
52
|
-
return _regeneratorRuntime.wrap(function
|
|
53
|
-
while (1) switch (
|
|
105
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
106
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
107
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
54
108
|
case 0:
|
|
55
|
-
|
|
56
|
-
|
|
109
|
+
_context2.prev = 0;
|
|
110
|
+
_context2.next = 3;
|
|
57
111
|
return share({
|
|
58
112
|
description: folderName,
|
|
59
113
|
document: existingDocument,
|
|
@@ -70,12 +124,12 @@ export var FederatedFolderModal = withLocales(function (_ref) {
|
|
|
70
124
|
variant: 'filled'
|
|
71
125
|
});
|
|
72
126
|
onClose();
|
|
73
|
-
|
|
127
|
+
_context2.next = 10;
|
|
74
128
|
break;
|
|
75
129
|
|
|
76
130
|
case 7:
|
|
77
|
-
|
|
78
|
-
|
|
131
|
+
_context2.prev = 7;
|
|
132
|
+
_context2.t0 = _context2["catch"](0);
|
|
79
133
|
showAlert({
|
|
80
134
|
message: t('FederatedFolder.errorNotification'),
|
|
81
135
|
severity: 'error',
|
|
@@ -84,13 +138,13 @@ export var FederatedFolderModal = withLocales(function (_ref) {
|
|
|
84
138
|
|
|
85
139
|
case 10:
|
|
86
140
|
case "end":
|
|
87
|
-
return
|
|
141
|
+
return _context2.stop();
|
|
88
142
|
}
|
|
89
|
-
},
|
|
143
|
+
}, _callee2, null, [[0, 7]]);
|
|
90
144
|
}));
|
|
91
145
|
|
|
92
146
|
return function onSend() {
|
|
93
|
-
return
|
|
147
|
+
return _ref3.apply(this, arguments);
|
|
94
148
|
};
|
|
95
149
|
}();
|
|
96
150
|
|
|
@@ -126,6 +180,7 @@ export var FederatedFolderModal = withLocales(function (_ref) {
|
|
|
126
180
|
var modalTitle = t('FederatedFolder.shareTitle', {
|
|
127
181
|
name: folderName
|
|
128
182
|
});
|
|
183
|
+
var isSharedDrive = Boolean(existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument.driveId);
|
|
129
184
|
return /*#__PURE__*/React.createElement(DumbFederatedFolderModal, {
|
|
130
185
|
title: modalTitle,
|
|
131
186
|
document: existingDocument,
|
|
@@ -140,7 +195,8 @@ export var FederatedFolderModal = withLocales(function (_ref) {
|
|
|
140
195
|
onSend: onSend,
|
|
141
196
|
onClose: onClose,
|
|
142
197
|
onShare: onShare,
|
|
143
|
-
sharingLink: sharingLink
|
|
198
|
+
sharingLink: sharingLink,
|
|
199
|
+
showShareByEmail: !isSharedDrive
|
|
144
200
|
});
|
|
145
201
|
});
|
|
146
202
|
FederatedFolderModal.propTypes = {
|
|
@@ -35,7 +35,9 @@ var ShareByLink = function ShareByLink(_ref) {
|
|
|
35
35
|
var client = useClient();
|
|
36
36
|
|
|
37
37
|
var _useSharingContext = useSharingContext(),
|
|
38
|
-
shareByLink = _useSharingContext.shareByLink
|
|
38
|
+
shareByLink = _useSharingContext.shareByLink,
|
|
39
|
+
getOwner = _useSharingContext.getOwner,
|
|
40
|
+
getSharingById = _useSharingContext.getSharingById;
|
|
39
41
|
|
|
40
42
|
var _useState = useState(false),
|
|
41
43
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -67,6 +69,8 @@ var ShareByLink = function ShareByLink(_ref) {
|
|
|
67
69
|
file: document,
|
|
68
70
|
documentType: documentType,
|
|
69
71
|
shareByLink: shareByLink,
|
|
72
|
+
getOwner: getOwner,
|
|
73
|
+
getSharingById: getSharingById,
|
|
70
74
|
t: t,
|
|
71
75
|
showAlert: showAlert,
|
|
72
76
|
password: '',
|
|
@@ -3,6 +3,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
3
3
|
import { generateWebLink } from 'cozy-client';
|
|
4
4
|
import minilog from 'cozy-minilog';
|
|
5
5
|
import { getAppSlugFromDocumentType } from '../../helpers/link';
|
|
6
|
+
import { getShortcode } from '../../helpers/shortcodes';
|
|
6
7
|
var log = minilog('ShareRestrictionModal/helpers');
|
|
7
8
|
export var WRITE_PERMS = ['GET', 'POST', 'PUT', 'PATCH'];
|
|
8
9
|
export var READ_ONLY_PERMS = ['GET'];
|
|
@@ -24,14 +25,12 @@ export var READ_ONLY_PERMS = ['GET'];
|
|
|
24
25
|
|
|
25
26
|
export var createSharingLink = /*#__PURE__*/function () {
|
|
26
27
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
var client, file, documentType, shareByLink, t, ttl, _ref$editingRights, editingRights, password, showAlert, permsResult, perms;
|
|
28
|
+
var client, file, documentType, shareByLink, getOwner, getSharingById, t, ttl, _ref$editingRights, editingRights, password, showAlert, permsResult, code;
|
|
30
29
|
|
|
31
30
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
32
31
|
while (1) switch (_context.prev = _context.next) {
|
|
33
32
|
case 0:
|
|
34
|
-
client = _ref.client, file = _ref.file, documentType = _ref.documentType, shareByLink = _ref.shareByLink, t = _ref.t, ttl = _ref.ttl, _ref$editingRights = _ref.editingRights, editingRights = _ref$editingRights === void 0 ? 'readOnly' : _ref$editingRights, password = _ref.password, showAlert = _ref.showAlert;
|
|
33
|
+
client = _ref.client, file = _ref.file, documentType = _ref.documentType, shareByLink = _ref.shareByLink, getOwner = _ref.getOwner, getSharingById = _ref.getSharingById, t = _ref.t, ttl = _ref.ttl, _ref$editingRights = _ref.editingRights, editingRights = _ref$editingRights === void 0 ? 'readOnly' : _ref$editingRights, password = _ref.password, showAlert = _ref.showAlert;
|
|
35
34
|
_context.next = 3;
|
|
36
35
|
return createPermissions({
|
|
37
36
|
file: file,
|
|
@@ -46,24 +45,23 @@ export var createSharingLink = /*#__PURE__*/function () {
|
|
|
46
45
|
|
|
47
46
|
case 3:
|
|
48
47
|
permsResult = _context.sent;
|
|
48
|
+
code = getShortcode(permsResult === null || permsResult === void 0 ? void 0 : permsResult.data);
|
|
49
49
|
|
|
50
|
-
if (
|
|
51
|
-
_context.next =
|
|
50
|
+
if (code) {
|
|
51
|
+
_context.next = 7;
|
|
52
52
|
break;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
return _context.abrupt("return", null);
|
|
56
56
|
|
|
57
|
-
case
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}),
|
|
66
|
-
subDomainType: client.capabilities.flat_subdomains ? 'flat' : 'nested'
|
|
57
|
+
case 7:
|
|
58
|
+
return _context.abrupt("return", generateShareLinkFromFile({
|
|
59
|
+
client: client,
|
|
60
|
+
file: file,
|
|
61
|
+
sharecode: code,
|
|
62
|
+
getOwner: getOwner,
|
|
63
|
+
getSharingById: getSharingById,
|
|
64
|
+
documentType: documentType
|
|
67
65
|
}));
|
|
68
66
|
|
|
69
67
|
case 8:
|
|
@@ -77,6 +75,45 @@ export var createSharingLink = /*#__PURE__*/function () {
|
|
|
77
75
|
return _ref2.apply(this, arguments);
|
|
78
76
|
};
|
|
79
77
|
}();
|
|
78
|
+
/**
|
|
79
|
+
* Generate a sharing link from a file and sharecode
|
|
80
|
+
* @param {object} options
|
|
81
|
+
* @param {object} options.client - CozyClient instance
|
|
82
|
+
* @param {object} options.file - File to share
|
|
83
|
+
* @param {string} options.sharecode - Share code
|
|
84
|
+
* @param {Function} options.getOwner - Function to get the owner of a sharing
|
|
85
|
+
* @param {Function} options.getSharingById - Function to get a sharing by ID
|
|
86
|
+
* @param {string} options.documentType - Type of the document
|
|
87
|
+
* @returns {string} - The generated web link
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
export var generateShareLinkFromFile = function generateShareLinkFromFile(_ref3) {
|
|
91
|
+
var client = _ref3.client,
|
|
92
|
+
file = _ref3.file,
|
|
93
|
+
sharecode = _ref3.sharecode,
|
|
94
|
+
getOwner = _ref3.getOwner,
|
|
95
|
+
getSharingById = _ref3.getSharingById,
|
|
96
|
+
documentType = _ref3.documentType;
|
|
97
|
+
var cozyUrl = client.getStackClient().uri;
|
|
98
|
+
|
|
99
|
+
if (file.driveId) {
|
|
100
|
+
var _sharing$rules;
|
|
101
|
+
|
|
102
|
+
var sharing = getSharingById(file.driveId);
|
|
103
|
+
var owner = getOwner(sharing === null || sharing === void 0 || (_sharing$rules = sharing.rules) === null || _sharing$rules === void 0 || (_sharing$rules = _sharing$rules[0]) === null || _sharing$rules === void 0 || (_sharing$rules = _sharing$rules.values) === null || _sharing$rules === void 0 ? void 0 : _sharing$rules[0]);
|
|
104
|
+
cozyUrl = (owner === null || owner === void 0 ? void 0 : owner.instance) || client.getStackClient().uri;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return generateWebLink({
|
|
108
|
+
cozyUrl: cozyUrl,
|
|
109
|
+
searchParams: [['sharecode', sharecode]],
|
|
110
|
+
pathname: '/public',
|
|
111
|
+
slug: getAppSlugFromDocumentType({
|
|
112
|
+
documentType: documentType
|
|
113
|
+
}),
|
|
114
|
+
subDomainType: client.capabilities.flat_subdomains ? 'flat' : 'nested'
|
|
115
|
+
});
|
|
116
|
+
};
|
|
80
117
|
/**
|
|
81
118
|
* Copy a string to the clipboard
|
|
82
119
|
*
|
|
@@ -87,8 +124,8 @@ export var createSharingLink = /*#__PURE__*/function () {
|
|
|
87
124
|
*/
|
|
88
125
|
|
|
89
126
|
export var copyToClipboard = /*#__PURE__*/function () {
|
|
90
|
-
var
|
|
91
|
-
var
|
|
127
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(value) {
|
|
128
|
+
var _ref5,
|
|
92
129
|
t,
|
|
93
130
|
showAlert,
|
|
94
131
|
_args2 = arguments;
|
|
@@ -96,7 +133,7 @@ export var copyToClipboard = /*#__PURE__*/function () {
|
|
|
96
133
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
97
134
|
while (1) switch (_context2.prev = _context2.next) {
|
|
98
135
|
case 0:
|
|
99
|
-
|
|
136
|
+
_ref5 = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {}, t = _ref5.t, showAlert = _ref5.showAlert;
|
|
100
137
|
|
|
101
138
|
if (value) {
|
|
102
139
|
_context2.next = 3;
|
|
@@ -137,7 +174,7 @@ export var copyToClipboard = /*#__PURE__*/function () {
|
|
|
137
174
|
}));
|
|
138
175
|
|
|
139
176
|
return function copyToClipboard(_x2) {
|
|
140
|
-
return
|
|
177
|
+
return _ref4.apply(this, arguments);
|
|
141
178
|
};
|
|
142
179
|
}();
|
|
143
180
|
/**
|
|
@@ -188,12 +225,12 @@ export var makeTTL = function makeTTL(selectedDate) {
|
|
|
188
225
|
*/
|
|
189
226
|
|
|
190
227
|
export var createPermissions = /*#__PURE__*/function () {
|
|
191
|
-
var
|
|
228
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref6) {
|
|
192
229
|
var file, t, ttl, password, editingRights, documentType, shareByLink, showAlert, verbs;
|
|
193
230
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
194
231
|
while (1) switch (_context3.prev = _context3.next) {
|
|
195
232
|
case 0:
|
|
196
|
-
file =
|
|
233
|
+
file = _ref6.file, t = _ref6.t, ttl = _ref6.ttl, password = _ref6.password, editingRights = _ref6.editingRights, documentType = _ref6.documentType, shareByLink = _ref6.shareByLink, showAlert = _ref6.showAlert;
|
|
197
234
|
_context3.prev = 1;
|
|
198
235
|
verbs = editingRights === 'readOnly' ? READ_ONLY_PERMS : WRITE_PERMS;
|
|
199
236
|
return _context3.abrupt("return", shareByLink(file, {
|
|
@@ -220,7 +257,7 @@ export var createPermissions = /*#__PURE__*/function () {
|
|
|
220
257
|
}));
|
|
221
258
|
|
|
222
259
|
return function createPermissions(_x3) {
|
|
223
|
-
return
|
|
260
|
+
return _ref7.apply(this, arguments);
|
|
224
261
|
};
|
|
225
262
|
}();
|
|
226
263
|
/**
|
|
@@ -239,12 +276,12 @@ export var createPermissions = /*#__PURE__*/function () {
|
|
|
239
276
|
*/
|
|
240
277
|
|
|
241
278
|
export var updatePermissions = /*#__PURE__*/function () {
|
|
242
|
-
var
|
|
279
|
+
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref8) {
|
|
243
280
|
var file, t, dateToggle, selectedDate, passwordToggle, password, editingRights, documentType, updateDocumentPermissions, showAlert, expiresAt, ensurePassword, verbs;
|
|
244
281
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
245
282
|
while (1) switch (_context4.prev = _context4.next) {
|
|
246
283
|
case 0:
|
|
247
|
-
file =
|
|
284
|
+
file = _ref8.file, t = _ref8.t, dateToggle = _ref8.dateToggle, selectedDate = _ref8.selectedDate, passwordToggle = _ref8.passwordToggle, password = _ref8.password, editingRights = _ref8.editingRights, documentType = _ref8.documentType, updateDocumentPermissions = _ref8.updateDocumentPermissions, showAlert = _ref8.showAlert;
|
|
248
285
|
_context4.prev = 1;
|
|
249
286
|
expiresAt = dateToggle ? (selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate.toISOString()) || undefined : '';
|
|
250
287
|
ensurePassword = passwordToggle ? password || undefined : '';
|
|
@@ -273,7 +310,7 @@ export var updatePermissions = /*#__PURE__*/function () {
|
|
|
273
310
|
}));
|
|
274
311
|
|
|
275
312
|
return function updatePermissions(_x4) {
|
|
276
|
-
return
|
|
313
|
+
return _ref9.apply(this, arguments);
|
|
277
314
|
};
|
|
278
315
|
}();
|
|
279
316
|
/**
|
|
@@ -287,12 +324,12 @@ export var updatePermissions = /*#__PURE__*/function () {
|
|
|
287
324
|
*/
|
|
288
325
|
|
|
289
326
|
export var revokePermissions = /*#__PURE__*/function () {
|
|
290
|
-
var
|
|
327
|
+
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref10) {
|
|
291
328
|
var file, t, documentType, revokeSharingLink, showAlert;
|
|
292
329
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
293
330
|
while (1) switch (_context5.prev = _context5.next) {
|
|
294
331
|
case 0:
|
|
295
|
-
file =
|
|
332
|
+
file = _ref10.file, t = _ref10.t, documentType = _ref10.documentType, revokeSharingLink = _ref10.revokeSharingLink, showAlert = _ref10.showAlert;
|
|
296
333
|
_context5.prev = 1;
|
|
297
334
|
return _context5.abrupt("return", revokeSharingLink(file));
|
|
298
335
|
|
|
@@ -314,6 +351,6 @@ export var revokePermissions = /*#__PURE__*/function () {
|
|
|
314
351
|
}));
|
|
315
352
|
|
|
316
353
|
return function revokePermissions(_x5) {
|
|
317
|
-
return
|
|
354
|
+
return _ref11.apply(this, arguments);
|
|
318
355
|
};
|
|
319
356
|
}();
|
|
@@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { useI18n } from 'twake-i18n';
|
|
4
4
|
import withLocales from '../../hoc/withLocales';
|
|
5
|
-
import DumbBatchSharedFolderModal from '../SharedFolder/DumbBatchSharedFolderModal';
|
|
5
|
+
import { DumbBatchSharedFolderModal } from '../SharedFolder/DumbBatchSharedFolderModal';
|
|
6
6
|
export var DumbSharedDriveModal = withLocales(function (_ref) {
|
|
7
7
|
var title = _ref.title,
|
|
8
8
|
document = _ref.document,
|
|
@@ -34,7 +34,9 @@ export var DumbBatchSharedFolderModal = withLocales(function (_ref) {
|
|
|
34
34
|
createLabel = _ref.createLabel,
|
|
35
35
|
shareLabel = _ref.shareLabel,
|
|
36
36
|
saveLabel = _ref.saveLabel,
|
|
37
|
-
sharingDesc = _ref.sharingDesc
|
|
37
|
+
sharingDesc = _ref.sharingDesc,
|
|
38
|
+
_ref$showShareByEmail = _ref.showShareByEmail,
|
|
39
|
+
showShareByEmail = _ref$showShareByEmail === void 0 ? true : _ref$showShareByEmail;
|
|
38
40
|
var hasRecipients = Boolean(recipients === null || recipients === void 0 ? void 0 : recipients.length); // Determine action buttons based on modal mode
|
|
39
41
|
|
|
40
42
|
var actionButtons = function () {
|
|
@@ -50,6 +52,14 @@ export var DumbBatchSharedFolderModal = withLocales(function (_ref) {
|
|
|
50
52
|
}));
|
|
51
53
|
}
|
|
52
54
|
|
|
55
|
+
if (!showShareByEmail) {
|
|
56
|
+
return /*#__PURE__*/React.createElement(ShareByLink, {
|
|
57
|
+
link: sharingLink,
|
|
58
|
+
document: document,
|
|
59
|
+
documentType: "Files"
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
53
63
|
if (!showNameField) {
|
|
54
64
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ShareByLink, {
|
|
55
65
|
link: sharingLink,
|
|
@@ -104,7 +114,7 @@ export var DumbBatchSharedFolderModal = withLocales(function (_ref) {
|
|
|
104
114
|
}), /*#__PURE__*/React.createElement(Typography, {
|
|
105
115
|
variant: "h6",
|
|
106
116
|
className: "u-mt-1-half u-mb-half"
|
|
107
|
-
}, addPeopleLabel), /*#__PURE__*/React.createElement(DumbShareByEmail, {
|
|
117
|
+
}, addPeopleLabel), showShareByEmail && /*#__PURE__*/React.createElement(DumbShareByEmail, {
|
|
108
118
|
createContact: createContact,
|
|
109
119
|
currentRecipients: currentRecipients,
|
|
110
120
|
document: document,
|
|
@@ -154,6 +164,9 @@ DumbBatchSharedFolderModal.propTypes = {
|
|
|
154
164
|
createLabel: PropTypes.string,
|
|
155
165
|
shareLabel: PropTypes.string,
|
|
156
166
|
saveLabel: PropTypes.string,
|
|
157
|
-
sharingDesc: PropTypes.string
|
|
167
|
+
sharingDesc: PropTypes.string,
|
|
168
|
+
showShareByEmail: PropTypes.bool
|
|
158
169
|
};
|
|
159
|
-
|
|
170
|
+
DumbBatchSharedFolderModal.defaultProps = {
|
|
171
|
+
sharingDesc: ''
|
|
172
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the shortcode from a permission object
|
|
3
|
+
* The shortcode can be in different places depending on how the sharing was created:
|
|
4
|
+
* - attributes.shortcodes.email
|
|
5
|
+
* - attributes.shortcodes.code
|
|
6
|
+
* - attributes.codes.email
|
|
7
|
+
* - attributes.codes.code
|
|
8
|
+
*
|
|
9
|
+
* We used to use `email` as `codes` attribute for a sharingByLink.
|
|
10
|
+
* But when we use cozy-client to create a Permission, by default
|
|
11
|
+
* the codes attribute is set to `code`. MesPapiers app is using this
|
|
12
|
+
* default behavior... So the sharing by link created by mes papiers
|
|
13
|
+
* didn't appear correctly in cozy-sharing.
|
|
14
|
+
* This is a bit ugly, we should have a better way to know if this is
|
|
15
|
+
* a sharing by link or not.
|
|
16
|
+
*
|
|
17
|
+
* @param {object} permission - The permission object
|
|
18
|
+
* @returns {string|null} The shortcode or null if not found
|
|
19
|
+
*/
|
|
20
|
+
export var getShortcode = function getShortcode(permission) {
|
|
21
|
+
var _permission$attribute, _permission$attribute2, _permission$attribute3, _permission$attribute4;
|
|
22
|
+
|
|
23
|
+
return (permission === null || permission === void 0 || (_permission$attribute = permission.attributes) === null || _permission$attribute === void 0 || (_permission$attribute = _permission$attribute.shortcodes) === null || _permission$attribute === void 0 ? void 0 : _permission$attribute.email) || (permission === null || permission === void 0 || (_permission$attribute2 = permission.attributes) === null || _permission$attribute2 === void 0 || (_permission$attribute2 = _permission$attribute2.shortcodes) === null || _permission$attribute2 === void 0 ? void 0 : _permission$attribute2.code) || (permission === null || permission === void 0 || (_permission$attribute3 = permission.attributes) === null || _permission$attribute3 === void 0 || (_permission$attribute3 = _permission$attribute3.codes) === null || _permission$attribute3 === void 0 ? void 0 : _permission$attribute3.email) || (permission === null || permission === void 0 || (_permission$attribute4 = permission.attributes) === null || _permission$attribute4 === void 0 || (_permission$attribute4 = _permission$attribute4.codes) === null || _permission$attribute4 === void 0 ? void 0 : _permission$attribute4.code) || null;
|
|
24
|
+
};
|
package/dist/state.js
CHANGED
|
@@ -10,8 +10,8 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
10
10
|
|
|
11
11
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
12
12
|
|
|
13
|
-
import get from 'lodash/get';
|
|
14
13
|
import flag from 'cozy-flags';
|
|
14
|
+
import { getShortcode } from './helpers/shortcodes';
|
|
15
15
|
var RECEIVE_SHARINGS = 'RECEIVE_SHARINGS';
|
|
16
16
|
var ADD_SHARING = 'ADD_SHARING';
|
|
17
17
|
var UPDATE_SHARING = 'UPDATE_SHARING';
|
|
@@ -521,15 +521,8 @@ export var getSharingLink = function getSharingLink(state, docId, documentType)
|
|
|
521
521
|
// This shouldn't have happened, but unfortunately some duplicate sharing links have been created in the past
|
|
522
522
|
var perms = getDocumentPermissions(state, docId);
|
|
523
523
|
if (perms.length === 0) return null;
|
|
524
|
-
var perm = perms[0];
|
|
525
|
-
|
|
526
|
-
// the codes attribute is set to `code`. MesPapiers app is using this
|
|
527
|
-
// default behavior... So the sharing by link created by mes papiers
|
|
528
|
-
// didn't appear correctly in cozy-sharing.
|
|
529
|
-
// This is a bit ugly, we should have a better way to know if this is
|
|
530
|
-
// a sharing by link or not.
|
|
531
|
-
|
|
532
|
-
var code = get(perm, 'attributes.shortcodes.email') || get(perm, 'attributes.shortcodes.code') || get(perm, 'attributes.codes.email') || get(perm, 'attributes.codes.code');
|
|
524
|
+
var perm = perms[0];
|
|
525
|
+
var code = getShortcode(perm);
|
|
533
526
|
|
|
534
527
|
if (code) {
|
|
535
528
|
return buildSharingLink(state, documentType, code);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-sharing",
|
|
3
|
-
"version": "28.
|
|
3
|
+
"version": "28.5.0",
|
|
4
4
|
"description": "Provides sharing login for React applications.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "Cozy",
|
|
@@ -54,12 +54,12 @@
|
|
|
54
54
|
"babel-jest": "27.5.1",
|
|
55
55
|
"babel-plugin-css-modules-transform": "1.6.2",
|
|
56
56
|
"babel-plugin-inline-react-svg": "1.1.2",
|
|
57
|
-
"cozy-client": "^60.
|
|
57
|
+
"cozy-client": "^60.22.0",
|
|
58
58
|
"cozy-device-helper": "^3.7.1",
|
|
59
59
|
"cozy-intent": "^2.30.3",
|
|
60
60
|
"cozy-minilog": "^3.10.0",
|
|
61
61
|
"cozy-ui": "^135.0.0",
|
|
62
|
-
"cozy-ui-plus": "^5.2.
|
|
62
|
+
"cozy-ui-plus": "^5.2.1",
|
|
63
63
|
"jest": "27.5.1",
|
|
64
64
|
"jest-environment-jsdom": "27.5.1",
|
|
65
65
|
"react": "16.12.0",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"twake-i18n": "^0.3.2"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
|
-
"cozy-client": ">=60.
|
|
72
|
+
"cozy-client": ">=60.22.0",
|
|
73
73
|
"cozy-device-helper": ">=3.7.1",
|
|
74
74
|
"cozy-intent": ">=2.29.1",
|
|
75
75
|
"cozy-minilog": ">=3.9.1",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"sideEffects": [
|
|
84
84
|
"*.css"
|
|
85
85
|
],
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "598f2e27b115ca69eda056332c6ab91fa92096d3"
|
|
87
87
|
}
|