cozy-sharing 33.2.0 → 33.2.2
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 +13 -0
- package/dist/components/FederatedFolder/FederatedFolderModal.js +44 -88
- package/dist/components/FederatedFolder/FederatedFolderModal.spec.js +187 -101
- package/dist/components/ShareDialogCozyToCozy.js +6 -0
- package/dist/components/ShareDialogCozyToCozy.spec.js +3 -0
- package/dist/components/ShareDialogOnlyByLink.js +7 -3
- package/dist/components/ShareDialogOnlyByLink.spec.js +75 -0
- package/package.json +2 -2
- package/src/components/FederatedFolder/FederatedFolderModal.jsx +27 -37
- package/src/components/FederatedFolder/FederatedFolderModal.spec.jsx +64 -1
- package/src/components/ShareDialogCozyToCozy.jsx +4 -0
- package/src/components/ShareDialogCozyToCozy.spec.jsx +1 -0
- package/src/components/ShareDialogOnlyByLink.jsx +5 -3
- package/src/components/ShareDialogOnlyByLink.spec.jsx +65 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,19 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [33.2.2](https://github.com/cozy/cozy-libs/compare/cozy-sharing@33.2.1...cozy-sharing@33.2.2) (2026-06-10)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **cozy-sharing:** Allow sharing shared drive folder root by email ([5110b4f](https://github.com/cozy/cozy-libs/commit/5110b4fb306bb664f2c6b62f209ef4af1e25c293))
|
|
11
|
+
- **cozy-sharing:** Fix lint issue in master ([5acd30a](https://github.com/cozy/cozy-libs/commit/5acd30a31412552be6b6223e43df2b320ea07098))
|
|
12
|
+
|
|
13
|
+
## [33.2.1](https://github.com/cozy/cozy-libs/compare/cozy-sharing@33.2.0...cozy-sharing@33.2.1) (2026-06-09)
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
- **cozy-sharing:** Refresh link state in share modal ([dfb6dd3](https://github.com/cozy/cozy-libs/commit/dfb6dd39e81b13a7da37ab8f5b4480fb645df01e))
|
|
18
|
+
|
|
6
19
|
# [33.2.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@33.1.2...cozy-sharing@33.2.0) (2026-06-09)
|
|
7
20
|
|
|
8
21
|
### Features
|
|
@@ -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, { useCallback,
|
|
5
|
+
import React, { useCallback, useState } from 'react';
|
|
6
6
|
import { useClient } from 'cozy-client';
|
|
7
7
|
import Button from 'cozy-ui/transpiled/react/Buttons';
|
|
8
8
|
import { FixedDialog } from 'cozy-ui/transpiled/react/CozyDialogs';
|
|
@@ -38,6 +38,8 @@ import ShareByLink from '../ShareByLink';
|
|
|
38
38
|
import WhoHasAccess from '../WhoHasAccess';
|
|
39
39
|
|
|
40
40
|
var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
|
|
41
|
+
var _sharedDriveSharing$a;
|
|
42
|
+
|
|
41
43
|
var onClose = _ref.onClose,
|
|
42
44
|
existingDocument = _ref.document,
|
|
43
45
|
autoOpenShareRestriction = _ref.autoOpenShareRestriction,
|
|
@@ -49,11 +51,9 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
|
|
|
49
51
|
|
|
50
52
|
var _useSharingContext = useSharingContext(),
|
|
51
53
|
share = _useSharingContext.share,
|
|
54
|
+
getSharingById = _useSharingContext.getSharingById,
|
|
52
55
|
getSharingLink = _useSharingContext.getSharingLink,
|
|
53
56
|
getFederatedShareLink = _useSharingContext.getFederatedShareLink,
|
|
54
|
-
getDocumentPermissions = _useSharingContext.getDocumentPermissions,
|
|
55
|
-
getOwner = _useSharingContext.getOwner,
|
|
56
|
-
getSharingById = _useSharingContext.getSharingById,
|
|
57
57
|
getRecipients = _useSharingContext.getRecipients,
|
|
58
58
|
hasSharedChild = _useSharingContext.hasSharedChild,
|
|
59
59
|
hasSharedParent = _useSharingContext.hasSharedParent,
|
|
@@ -66,11 +66,6 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
|
|
|
66
66
|
showConfirmDialog = _useConfirmDialog.showConfirmDialog,
|
|
67
67
|
closeConfirmDialog = _useConfirmDialog.closeConfirmDialog;
|
|
68
68
|
|
|
69
|
-
var _useState = useState(null),
|
|
70
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
71
|
-
sharingLink = _useState2[0],
|
|
72
|
-
setSharingLink = _useState2[1];
|
|
73
|
-
|
|
74
69
|
var _usePendingRecipients = usePendingRecipients(),
|
|
75
70
|
pendingRecipients = _usePendingRecipients.pendingRecipients,
|
|
76
71
|
setPendingRecipients = _usePendingRecipients.setPendingRecipients,
|
|
@@ -83,20 +78,20 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
|
|
|
83
78
|
// we do not use the reactive existingDocument and existingRecipients.
|
|
84
79
|
|
|
85
80
|
|
|
86
|
-
var
|
|
81
|
+
var _useState = useState(false),
|
|
82
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
83
|
+
isSending = _useState2[0],
|
|
84
|
+
setIsSending = _useState2[1];
|
|
85
|
+
|
|
86
|
+
var _useState3 = useState(null),
|
|
87
87
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
frozenDoc = _useState4[0],
|
|
89
|
+
setFrozenDoc = _useState4[1];
|
|
90
90
|
|
|
91
91
|
var _useState5 = useState(null),
|
|
92
92
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
var _useState7 = useState(null),
|
|
97
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
98
|
-
frozenRecipients = _useState8[0],
|
|
99
|
-
setFrozenRecipients = _useState8[1];
|
|
93
|
+
frozenRecipients = _useState6[0],
|
|
94
|
+
setFrozenRecipients = _useState6[1];
|
|
100
95
|
|
|
101
96
|
var handleCloseRequest = useCallback(function () {
|
|
102
97
|
if (pendingRecipients.length === 0) {
|
|
@@ -122,90 +117,50 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
|
|
|
122
117
|
}))
|
|
123
118
|
});
|
|
124
119
|
}, [closeConfirmDialog, onClose, pendingRecipients.length, showConfirmDialog, t]);
|
|
125
|
-
var documentPermissions = useMemo(function () {
|
|
126
|
-
return existingDocument ? getDocumentPermissions(existingDocument._id) : [];
|
|
127
|
-
}, [existingDocument, getDocumentPermissions]);
|
|
128
|
-
useEffect(function () {
|
|
129
|
-
var fetchSharingLink = /*#__PURE__*/function () {
|
|
130
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
131
|
-
var link;
|
|
132
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
133
|
-
while (1) switch (_context.prev = _context.next) {
|
|
134
|
-
case 0:
|
|
135
|
-
if (existingDocument) {
|
|
136
|
-
_context.next = 2;
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return _context.abrupt("return");
|
|
141
|
-
|
|
142
|
-
case 2:
|
|
143
|
-
if (!existingDocument.driveId) {
|
|
144
|
-
_context.next = 9;
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
_context.next = 5;
|
|
149
|
-
return getFederatedShareLink(existingDocument);
|
|
150
|
-
|
|
151
|
-
case 5:
|
|
152
|
-
link = _context.sent;
|
|
153
|
-
setSharingLink(link);
|
|
154
|
-
_context.next = 10;
|
|
155
|
-
break;
|
|
156
|
-
|
|
157
|
-
case 9:
|
|
158
|
-
setSharingLink(getSharingLink(existingDocument._id));
|
|
159
|
-
|
|
160
|
-
case 10:
|
|
161
|
-
case "end":
|
|
162
|
-
return _context.stop();
|
|
163
|
-
}
|
|
164
|
-
}, _callee);
|
|
165
|
-
}));
|
|
166
|
-
|
|
167
|
-
return function fetchSharingLink() {
|
|
168
|
-
return _ref2.apply(this, arguments);
|
|
169
|
-
};
|
|
170
|
-
}();
|
|
171
|
-
|
|
172
|
-
fetchSharingLink();
|
|
173
|
-
}, [existingDocument, documentPermissions, getFederatedShareLink, getSharingLink, getOwner, getSharingById]);
|
|
174
120
|
var folderName = (existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument.name) || '';
|
|
175
121
|
var documentPath = existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument.path;
|
|
176
|
-
var
|
|
122
|
+
var sharedDriveSharing = existingDocument !== null && existingDocument !== void 0 && existingDocument.driveId ? getSharingById(existingDocument.driveId) : null;
|
|
123
|
+
var sharedDriveRootIds = (sharedDriveSharing === null || sharedDriveSharing === void 0 || (_sharedDriveSharing$a = sharedDriveSharing.attributes) === null || _sharedDriveSharing$a === void 0 || (_sharedDriveSharing$a = _sharedDriveSharing$a.rules) === null || _sharedDriveSharing$a === void 0 ? void 0 : _sharedDriveSharing$a.reduce(function (ids, rule) {
|
|
124
|
+
return ids.concat(rule.values || []);
|
|
125
|
+
}, [])) || [];
|
|
126
|
+
var isSharedDriveRoot = Boolean((existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument.driveId) && sharedDriveRootIds.some(function (id) {
|
|
127
|
+
return id === (existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument._id) || id === (existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument.id);
|
|
128
|
+
}));
|
|
129
|
+
var isInsideSharedDrive = Boolean((existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument.driveId) && !isSharedDriveRoot);
|
|
130
|
+
var hasSharedParentByPath = Boolean(documentPath && hasSharedParent(documentPath));
|
|
131
|
+
var hasParentRestriction = isInsideSharedDrive || hasSharedParentByPath;
|
|
177
132
|
var hasChildRestriction = Boolean(documentPath && hasSharedChild(documentPath));
|
|
178
133
|
var canShareByEmail = !hasParentRestriction && !hasChildRestriction;
|
|
179
134
|
|
|
180
135
|
var onSend = /*#__PURE__*/function () {
|
|
181
|
-
var
|
|
136
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
182
137
|
var contacts, readWriteRecipients, readOnlyRecipients;
|
|
183
|
-
return _regeneratorRuntime.wrap(function
|
|
184
|
-
while (1) switch (
|
|
138
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
139
|
+
while (1) switch (_context.prev = _context.next) {
|
|
185
140
|
case 0:
|
|
186
141
|
if (!(isSending || pendingRecipients.length === 0)) {
|
|
187
|
-
|
|
142
|
+
_context.next = 3;
|
|
188
143
|
break;
|
|
189
144
|
}
|
|
190
145
|
|
|
191
146
|
onClose();
|
|
192
|
-
return
|
|
147
|
+
return _context.abrupt("return");
|
|
193
148
|
|
|
194
149
|
case 3:
|
|
195
150
|
setIsSending(true);
|
|
196
151
|
setFrozenDoc(existingDocument);
|
|
197
152
|
setFrozenRecipients(existingRecipients);
|
|
198
|
-
|
|
199
|
-
|
|
153
|
+
_context.prev = 6;
|
|
154
|
+
_context.next = 9;
|
|
200
155
|
return getOrCreateFromArray(client, pendingRecipients, function (contact) {
|
|
201
156
|
return client.create('io.cozy.contacts', contact);
|
|
202
157
|
});
|
|
203
158
|
|
|
204
159
|
case 9:
|
|
205
|
-
contacts =
|
|
160
|
+
contacts = _context.sent;
|
|
206
161
|
readWriteRecipients = selectedOption === 'readOnly' ? [] : contacts;
|
|
207
162
|
readOnlyRecipients = selectedOption === 'readOnly' ? contacts : [];
|
|
208
|
-
|
|
163
|
+
_context.next = 14;
|
|
209
164
|
return share({
|
|
210
165
|
description: folderName,
|
|
211
166
|
document: existingDocument,
|
|
@@ -222,12 +177,12 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
|
|
|
222
177
|
variant: 'filled'
|
|
223
178
|
});
|
|
224
179
|
onClose();
|
|
225
|
-
|
|
180
|
+
_context.next = 21;
|
|
226
181
|
break;
|
|
227
182
|
|
|
228
183
|
case 18:
|
|
229
|
-
|
|
230
|
-
|
|
184
|
+
_context.prev = 18;
|
|
185
|
+
_context.t0 = _context["catch"](6);
|
|
231
186
|
showAlert({
|
|
232
187
|
message: t('FederatedFolder.errorNotification'),
|
|
233
188
|
severity: 'error',
|
|
@@ -235,23 +190,24 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
|
|
|
235
190
|
});
|
|
236
191
|
|
|
237
192
|
case 21:
|
|
238
|
-
|
|
193
|
+
_context.prev = 21;
|
|
239
194
|
setIsSending(false);
|
|
240
|
-
return
|
|
195
|
+
return _context.finish(21);
|
|
241
196
|
|
|
242
197
|
case 24:
|
|
243
198
|
case "end":
|
|
244
|
-
return
|
|
199
|
+
return _context.stop();
|
|
245
200
|
}
|
|
246
|
-
},
|
|
201
|
+
}, _callee, null, [[6, 18, 21, 24]]);
|
|
247
202
|
}));
|
|
248
203
|
|
|
249
204
|
return function onSend() {
|
|
250
|
-
return
|
|
205
|
+
return _ref2.apply(this, arguments);
|
|
251
206
|
};
|
|
252
207
|
}();
|
|
253
208
|
|
|
254
209
|
var existingRecipients = existingDocument ? getRecipients(existingDocument._id) : [];
|
|
210
|
+
var displayedLink = existingDocument !== null && existingDocument !== void 0 && existingDocument.driveId ? getFederatedShareLink(existingDocument) : getSharingLink(existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument._id);
|
|
255
211
|
var modalTitle = t('FederatedFolder.shareTitle', {
|
|
256
212
|
name: folderName
|
|
257
213
|
});
|
|
@@ -296,10 +252,10 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
|
|
|
296
252
|
documentType: "Files",
|
|
297
253
|
className: "u-w-100",
|
|
298
254
|
onRevoke: revoke,
|
|
299
|
-
link:
|
|
255
|
+
link: displayedLink
|
|
300
256
|
})),
|
|
301
257
|
actions: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ShareByLink, {
|
|
302
|
-
link:
|
|
258
|
+
link: displayedLink,
|
|
303
259
|
document: isSending ? frozenDoc : existingDocument,
|
|
304
260
|
documentType: "Files",
|
|
305
261
|
showGenerateLinkButton: showGenerateLinkButton,
|