cozy-sharing 37.2.7 → 37.2.9

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 CHANGED
@@ -3,6 +3,14 @@
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
+ ## [37.2.9](https://github.com/cozy/cozy-libs/compare/cozy-sharing@37.2.8...cozy-sharing@37.2.9) (2026-07-29)
7
+
8
+ **Note:** Version bump only for package cozy-sharing
9
+
10
+ ## [37.2.8](https://github.com/cozy/cozy-libs/compare/cozy-sharing@37.2.7...cozy-sharing@37.2.8) (2026-07-29)
11
+
12
+ **Note:** Version bump only for package cozy-sharing
13
+
6
14
  ## [37.2.7](https://github.com/cozy/cozy-libs/compare/cozy-sharing@37.2.6...cozy-sharing@37.2.7) (2026-07-29)
7
15
 
8
16
  ### Bug Fixes
@@ -48,6 +48,12 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
48
48
  existingDocument = _ref.document,
49
49
  autoOpenShareRestriction = _ref.autoOpenShareRestriction,
50
50
  showGenerateLinkButton = _ref.showGenerateLinkButton;
51
+ // share from CozyProvider is wired to callbacks and realtime that
52
+ // makes existingDocument and existingRecipients reactive to changes.
53
+ // But we want it to be reactive only when we revoke a member. When we add member
54
+ // we close the popup and we do not want to see briefly the new contacts added
55
+ // in members before the modal closes. That's why when clicking on "Share"
56
+ // we do not use the reactive existingDocument and existingRecipients.
51
57
  var client = useClient();
52
58
 
53
59
  var _useI18n = useI18n(),
@@ -80,13 +86,7 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
80
86
  pendingRecipients = _usePendingRecipients.pendingRecipients,
81
87
  setPendingRecipients = _usePendingRecipients.setPendingRecipients,
82
88
  selectedOption = _usePendingRecipients.selectedOption,
83
- setSelectedOption = _usePendingRecipients.setSelectedOption; // share from CozyProvider is wired to callbacks and realtime that
84
- // makes existingDocument and existingRecipients reactive to changes.
85
- // But we want it to be reactive only when we revoke a member. When we add member
86
- // we close the popup and we do not want to see briefly the new contacts added
87
- // in members before the modal closes. That's why when clicking on "Share"
88
- // we do not use the reactive existingDocument and existingRecipients.
89
-
89
+ setSelectedOption = _usePendingRecipients.setSelectedOption;
90
90
 
91
91
  var _useState = useState(false),
92
92
  _useState2 = _slicedToArray(_useState, 2),
@@ -113,6 +113,59 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
113
113
  frozenRecipients = _useState10[0],
114
114
  setFrozenRecipients = _useState10[1];
115
115
 
116
+ var _useState11 = useState(null),
117
+ _useState12 = _slicedToArray(_useState11, 2),
118
+ sharedParentFolder = _useState12[0],
119
+ setSharedParentFolder = _useState12[1];
120
+
121
+ var documentId = (existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument._id) || (existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument.id);
122
+ var folderName = (existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument.name) || '';
123
+ var documentPath = existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument.path;
124
+ var sharedDriveSharing = existingDocument !== null && existingDocument !== void 0 && existingDocument.driveId ? getSharingById(existingDocument.driveId) : null;
125
+ 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) {
126
+ return ids.concat(rule.values || []);
127
+ }, [])) || []; // Owner case: when document is inside a shared folder (via path) but has no driveId,
128
+ // find the parent shared folder to use its _id for recipient/permission lookups.
129
+
130
+ var hasSharedParentByPath = Boolean(documentPath && hasSharedParent(documentPath));
131
+ var sharedParentPath = !sharedDriveSharing && hasSharedParentByPath && documentPath ? getSharedParentPath(documentPath) : null;
132
+ var sharingReferenceId = !sharedDriveSharing && sharedParentFolder !== null && sharedParentFolder !== void 0 && sharedParentFolder._id ? sharedParentFolder._id : documentId;
133
+ var existingRecipients = sharedDriveSharing !== null && sharedDriveSharing !== void 0 && (_sharedDriveSharing$a2 = sharedDriveSharing.attributes) !== null && _sharedDriveSharing$a2 !== void 0 && _sharedDriveSharing$a2.members && documentId ? getRecipientsFromSharing(sharedDriveSharing, documentId) : sharingReferenceId ? getRecipients(sharingReferenceId) : [];
134
+ var documentPermissions = documentId ? getDocumentPermissions(documentId) : [];
135
+ var displayedLink = existingDocument !== null && existingDocument !== void 0 && existingDocument.driveId ? getFederatedShareLink(existingDocument) : getSharingLink(existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument._id);
136
+ var isSharedDriveRoot = Boolean((existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument.driveId) && sharedDriveRootIds.some(function (id) {
137
+ return id === (existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument._id) || id === (existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument.id);
138
+ }));
139
+ var isInsideSharedDrive = Boolean((existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument.driveId) && !isSharedDriveRoot);
140
+ var isCurrentUserOwner = documentId ? isOwner(documentId) : false;
141
+ var hasParentRestriction = isInsideSharedDrive || hasSharedParentByPath;
142
+ var hasChildRestriction = Boolean(documentPath && hasSharedChild(documentPath));
143
+ var canShareByEmail = !hasParentRestriction && !hasChildRestriction;
144
+ var canManageSharing = isCurrentUserOwner || (documentId ? canReshare(documentId) : false);
145
+
146
+ var handleRevokeSelf = /*#__PURE__*/function () {
147
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(document) {
148
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
149
+ while (1) switch (_context.prev = _context.next) {
150
+ case 0:
151
+ _context.next = 2;
152
+ return revokeSelf(document);
153
+
154
+ case 2:
155
+ onRevokeSuccess === null || onRevokeSuccess === void 0 || onRevokeSuccess(document);
156
+
157
+ case 3:
158
+ case "end":
159
+ return _context.stop();
160
+ }
161
+ }, _callee);
162
+ }));
163
+
164
+ return function handleRevokeSelf(_x) {
165
+ return _ref2.apply(this, arguments);
166
+ };
167
+ }();
168
+
116
169
  var handleCloseRequest = useCallback(function () {
117
170
  if (pendingRecipients.length === 0) {
118
171
  onClose();
@@ -137,50 +190,36 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
137
190
  }))
138
191
  });
139
192
  }, [closeConfirmDialog, onClose, pendingRecipients.length, showConfirmDialog, t]);
140
- var folderName = (existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument.name) || '';
141
- var documentPath = existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument.path;
142
- var sharedDriveSharing = existingDocument !== null && existingDocument !== void 0 && existingDocument.driveId ? getSharingById(existingDocument.driveId) : null;
143
- 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) {
144
- return ids.concat(rule.values || []);
145
- }, [])) || [];
146
- var isSharedDriveRoot = Boolean((existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument.driveId) && sharedDriveRootIds.some(function (id) {
147
- return id === (existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument._id) || id === (existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument.id);
148
- }));
149
- var isInsideSharedDrive = Boolean((existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument.driveId) && !isSharedDriveRoot);
150
- var hasSharedParentByPath = Boolean(documentPath && hasSharedParent(documentPath));
151
- var hasParentRestriction = isInsideSharedDrive || hasSharedParentByPath;
152
- var hasChildRestriction = Boolean(documentPath && hasSharedChild(documentPath));
153
- var canShareByEmail = !hasParentRestriction && !hasChildRestriction;
154
193
 
155
194
  var onSend = /*#__PURE__*/function () {
156
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
195
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
157
196
  var contacts, readWriteRecipients, readOnlyRecipients;
158
- return _regeneratorRuntime.wrap(function _callee$(_context) {
159
- while (1) switch (_context.prev = _context.next) {
197
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
198
+ while (1) switch (_context2.prev = _context2.next) {
160
199
  case 0:
161
200
  if (!(isSending || pendingRecipients.length === 0)) {
162
- _context.next = 3;
201
+ _context2.next = 3;
163
202
  break;
164
203
  }
165
204
 
166
205
  onClose();
167
- return _context.abrupt("return");
206
+ return _context2.abrupt("return");
168
207
 
169
208
  case 3:
170
209
  setIsSending(true);
171
210
  setFrozenDoc(existingDocument);
172
211
  setFrozenRecipients(existingRecipients);
173
- _context.prev = 6;
174
- _context.next = 9;
212
+ _context2.prev = 6;
213
+ _context2.next = 9;
175
214
  return getOrCreateFromArray(client, pendingRecipients, function (contact) {
176
215
  return client.create('io.cozy.contacts', contact);
177
216
  });
178
217
 
179
218
  case 9:
180
- contacts = _context.sent;
219
+ contacts = _context2.sent;
181
220
  readWriteRecipients = selectedOption === 'readOnly' ? [] : contacts;
182
221
  readOnlyRecipients = selectedOption === 'readOnly' ? contacts : [];
183
- _context.next = 14;
222
+ _context2.next = 14;
184
223
  return share({
185
224
  description: folderName,
186
225
  document: existingDocument,
@@ -197,12 +236,12 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
197
236
  variant: 'filled'
198
237
  });
199
238
  onClose();
200
- _context.next = 21;
239
+ _context2.next = 21;
201
240
  break;
202
241
 
203
242
  case 18:
204
- _context.prev = 18;
205
- _context.t0 = _context["catch"](6);
243
+ _context2.prev = 18;
244
+ _context2.t0 = _context2["catch"](6);
206
245
  showAlert({
207
246
  message: t('FederatedFolder.errorNotification'),
208
247
  severity: 'error',
@@ -210,100 +249,60 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
210
249
  });
211
250
 
212
251
  case 21:
213
- _context.prev = 21;
252
+ _context2.prev = 21;
214
253
  setIsSending(false);
215
- return _context.finish(21);
254
+ return _context2.finish(21);
216
255
 
217
256
  case 24:
218
257
  case "end":
219
- return _context.stop();
258
+ return _context2.stop();
220
259
  }
221
- }, _callee, null, [[6, 18, 21, 24]]);
260
+ }, _callee2, null, [[6, 18, 21, 24]]);
222
261
  }));
223
262
 
224
263
  return function onSend() {
225
- return _ref2.apply(this, arguments);
264
+ return _ref3.apply(this, arguments);
226
265
  };
227
266
  }();
228
267
 
229
- var documentId = (existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument._id) || (existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument.id); // Owner case: when document is inside a shared folder (via path) but has no driveId,
230
- // find the parent shared folder to use its _id for recipient/permission lookups.
231
-
232
- var sharedParentPath = !sharedDriveSharing && hasSharedParentByPath && documentPath ? getSharedParentPath(documentPath) : null;
233
-
234
- var _useState11 = useState(null),
235
- _useState12 = _slicedToArray(_useState11, 2),
236
- sharedParentFolder = _useState12[0],
237
- setSharedParentFolder = _useState12[1];
238
-
239
268
  useEffect(function () {
240
269
  if (!sharedParentPath) return;
241
270
 
242
271
  var fetchParentFolder = /*#__PURE__*/function () {
243
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
272
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
244
273
  var res;
245
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
246
- while (1) switch (_context2.prev = _context2.next) {
274
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
275
+ while (1) switch (_context3.prev = _context3.next) {
247
276
  case 0:
248
- _context2.prev = 0;
249
- _context2.next = 3;
277
+ _context3.prev = 0;
278
+ _context3.next = 3;
250
279
  return client.collection('io.cozy.files').statByPath(sharedParentPath);
251
280
 
252
281
  case 3:
253
- res = _context2.sent;
282
+ res = _context3.sent;
254
283
  if (res.data) setSharedParentFolder(res.data);
255
- _context2.next = 10;
284
+ _context3.next = 10;
256
285
  break;
257
286
 
258
287
  case 7:
259
- _context2.prev = 7;
260
- _context2.t0 = _context2["catch"](0);
261
- log.error('Failed to fetch shared parent folder', _context2.t0);
288
+ _context3.prev = 7;
289
+ _context3.t0 = _context3["catch"](0);
290
+ log.error('Failed to fetch shared parent folder', _context3.t0);
262
291
 
263
292
  case 10:
264
293
  case "end":
265
- return _context2.stop();
294
+ return _context3.stop();
266
295
  }
267
- }, _callee2, null, [[0, 7]]);
296
+ }, _callee3, null, [[0, 7]]);
268
297
  }));
269
298
 
270
299
  return function fetchParentFolder() {
271
- return _ref3.apply(this, arguments);
300
+ return _ref4.apply(this, arguments);
272
301
  };
273
302
  }();
274
303
 
275
304
  fetchParentFolder();
276
305
  }, [sharedParentPath, client]);
277
- var sharingReferenceId = !sharedDriveSharing && sharedParentFolder !== null && sharedParentFolder !== void 0 && sharedParentFolder._id ? sharedParentFolder._id : documentId;
278
- var existingRecipients = sharedDriveSharing !== null && sharedDriveSharing !== void 0 && (_sharedDriveSharing$a2 = sharedDriveSharing.attributes) !== null && _sharedDriveSharing$a2 !== void 0 && _sharedDriveSharing$a2.members && documentId ? getRecipientsFromSharing(sharedDriveSharing, documentId) : sharingReferenceId ? getRecipients(sharingReferenceId) : [];
279
- var documentPermissions = documentId ? getDocumentPermissions(documentId) : [];
280
- var displayedLink = existingDocument !== null && existingDocument !== void 0 && existingDocument.driveId ? getFederatedShareLink(existingDocument) : getSharingLink(existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument._id);
281
- var isCurrentUserOwner = documentId ? isOwner(documentId) : false;
282
- var canManageSharing = isCurrentUserOwner || (documentId ? canReshare(documentId) : false);
283
-
284
- var handleRevokeSelf = /*#__PURE__*/function () {
285
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(document) {
286
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
287
- while (1) switch (_context3.prev = _context3.next) {
288
- case 0:
289
- _context3.next = 2;
290
- return revokeSelf(document);
291
-
292
- case 2:
293
- onRevokeSuccess === null || onRevokeSuccess === void 0 || onRevokeSuccess(document);
294
-
295
- case 3:
296
- case "end":
297
- return _context3.stop();
298
- }
299
- }, _callee3);
300
- }));
301
-
302
- return function handleRevokeSelf(_x) {
303
- return _ref4.apply(this, arguments);
304
- };
305
- }();
306
-
307
306
  useEffect(function () {
308
307
  if (!(existingDocument !== null && existingDocument !== void 0 && existingDocument.driveId)) return;
309
308
  if (!documentId) return;
@@ -351,14 +350,13 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
351
350
 
352
351
  fetchSharingLinks();
353
352
  }, [documentId, existingDocument, documentPermissions.length, fetchedSharingLinksDocumentId, fetchSharedDriveSharingLinks, isFetchingSharingLinks]);
354
- var modalTitle = t('FederatedFolder.shareTitle', {
355
- name: folderName
356
- });
357
353
  return /*#__PURE__*/React.createElement(FixedDialog, {
358
354
  open: true,
359
355
  disableGutters: true,
360
356
  onClose: handleCloseRequest,
361
- title: modalTitle,
357
+ title: t('FederatedFolder.shareTitle', {
358
+ name: folderName
359
+ }),
362
360
  classes: {
363
361
  paper: 'u-ov-visible'
364
362
  },
@@ -22,13 +22,13 @@ var styles = {
22
22
  };
23
23
  import WhoHasAccess from '../WhoHasAccess';
24
24
  export var SharingDetailsModal = function SharingDetailsModal(_ref) {
25
- var onClose = _ref.onClose,
26
- recipients = _ref.recipients,
25
+ var recipients = _ref.recipients,
27
26
  document = _ref.document,
28
27
  _ref$documentType = _ref.documentType,
29
28
  documentType = _ref$documentType === void 0 ? 'Document' : _ref$documentType,
30
29
  onRevoke = _ref.onRevoke,
31
- onRevokeSelf = _ref.onRevokeSelf;
30
+ onRevokeSelf = _ref.onRevokeSelf,
31
+ onClose = _ref.onClose;
32
32
 
33
33
  var _useI18n = useI18n(),
34
34
  t = _useI18n.t;
@@ -53,12 +53,11 @@ export var SharingDetailsModal = function SharingDetailsModal(_ref) {
53
53
  });
54
54
  };
55
55
  SharingDetailsModal.propTypes = {
56
- onClose: PropTypes.func,
57
- sharingType: PropTypes.string,
58
- owner: PropTypes.object.isRequired,
56
+ recipients: PropTypes.array.isRequired,
59
57
  document: PropTypes.object.isRequired,
60
58
  documentType: PropTypes.string.isRequired,
61
59
  onRevoke: PropTypes.func.isRequired,
62
- onRevokeSelf: PropTypes.func
60
+ onRevokeSelf: PropTypes.func,
61
+ onClose: PropTypes.func
63
62
  };
64
63
  export default SharingDetailsModal;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-sharing",
3
- "version": "37.2.7",
3
+ "version": "37.2.9",
4
4
  "description": "Provides sharing login for React applications.",
5
5
  "main": "dist/index.js",
6
6
  "author": "Cozy",
@@ -59,7 +59,7 @@
59
59
  "cozy-intent": "^2.31.1",
60
60
  "cozy-minilog": "^3.10.1",
61
61
  "cozy-ui": "^140.5.0",
62
- "cozy-ui-plus": "^12.3.1",
62
+ "cozy-ui-plus": "^12.3.3",
63
63
  "jest": "30.3.0",
64
64
  "jest-environment-jsdom": "30.3.0",
65
65
  "react": "16.12.0",
@@ -85,5 +85,5 @@
85
85
  "sideEffects": [
86
86
  "*.css"
87
87
  ],
88
- "gitHead": "d1b71486a45b2a87c7d93311d09b7bb4bd58a8af"
88
+ "gitHead": "f173ec5ce78ad2bf5f9abd174f8cef980a8ebfc7"
89
89
  }
@@ -32,6 +32,12 @@ const FederatedFolderModalContent = ({
32
32
  autoOpenShareRestriction,
33
33
  showGenerateLinkButton
34
34
  }) => {
35
+ // share from CozyProvider is wired to callbacks and realtime that
36
+ // makes existingDocument and existingRecipients reactive to changes.
37
+ // But we want it to be reactive only when we revoke a member. When we add member
38
+ // we close the popup and we do not want to see briefly the new contacts added
39
+ // in members before the modal closes. That's why when clicking on "Share"
40
+ // we do not use the reactive existingDocument and existingRecipients.
35
41
  const client = useClient()
36
42
  const { t } = useI18n()
37
43
  const {
@@ -52,26 +58,79 @@ const FederatedFolderModalContent = ({
52
58
  } = useSharingContext()
53
59
  const { showAlert } = useAlert()
54
60
  const { showConfirmDialog, closeConfirmDialog } = useConfirmDialog()
55
-
56
61
  const {
57
62
  pendingRecipients,
58
63
  setPendingRecipients,
59
64
  selectedOption,
60
65
  setSelectedOption
61
66
  } = usePendingRecipients()
62
-
63
- // share from CozyProvider is wired to callbacks and realtime that
64
- // makes existingDocument and existingRecipients reactive to changes.
65
- // But we want it to be reactive only when we revoke a member. When we add member
66
- // we close the popup and we do not want to see briefly the new contacts added
67
- // in members before the modal closes. That's why when clicking on "Share"
68
- // we do not use the reactive existingDocument and existingRecipients.
69
67
  const [isSending, setIsSending] = useState(false)
70
68
  const [isFetchingSharingLinks, setIsFetchingSharingLinks] = useState(false)
71
69
  const [fetchedSharingLinksDocumentId, setFetchedSharingLinksDocumentId] =
72
70
  useState(null)
73
71
  const [frozenDoc, setFrozenDoc] = useState(null)
74
72
  const [frozenRecipients, setFrozenRecipients] = useState(null)
73
+ const [sharedParentFolder, setSharedParentFolder] = useState(null)
74
+
75
+ const documentId = existingDocument?._id || existingDocument?.id
76
+ const folderName = existingDocument?.name || ''
77
+ const documentPath = existingDocument?.path
78
+ const sharedDriveSharing = existingDocument?.driveId
79
+ ? getSharingById(existingDocument.driveId)
80
+ : null
81
+ const sharedDriveRootIds =
82
+ sharedDriveSharing?.attributes?.rules?.reduce(
83
+ (ids, rule) => ids.concat(rule.values || []),
84
+ []
85
+ ) || []
86
+ // Owner case: when document is inside a shared folder (via path) but has no driveId,
87
+ // find the parent shared folder to use its _id for recipient/permission lookups.
88
+ const hasSharedParentByPath = Boolean(
89
+ documentPath && hasSharedParent(documentPath)
90
+ )
91
+ const sharedParentPath =
92
+ !sharedDriveSharing && hasSharedParentByPath && documentPath
93
+ ? getSharedParentPath(documentPath)
94
+ : null
95
+ const sharingReferenceId =
96
+ !sharedDriveSharing && sharedParentFolder?._id
97
+ ? sharedParentFolder._id
98
+ : documentId
99
+ const existingRecipients =
100
+ sharedDriveSharing?.attributes?.members && documentId
101
+ ? getRecipientsFromSharing(sharedDriveSharing, documentId)
102
+ : sharingReferenceId
103
+ ? getRecipients(sharingReferenceId)
104
+ : []
105
+ const documentPermissions = documentId
106
+ ? getDocumentPermissions(documentId)
107
+ : []
108
+ const displayedLink = existingDocument?.driveId
109
+ ? getFederatedShareLink(existingDocument)
110
+ : getSharingLink(existingDocument?._id)
111
+
112
+ const isSharedDriveRoot = Boolean(
113
+ existingDocument?.driveId &&
114
+ sharedDriveRootIds.some(
115
+ id => id === existingDocument?._id || id === existingDocument?.id
116
+ )
117
+ )
118
+ const isInsideSharedDrive = Boolean(
119
+ existingDocument?.driveId && !isSharedDriveRoot
120
+ )
121
+ const isCurrentUserOwner = documentId ? isOwner(documentId) : false
122
+ const hasParentRestriction = isInsideSharedDrive || hasSharedParentByPath
123
+ const hasChildRestriction = Boolean(
124
+ documentPath && hasSharedChild(documentPath)
125
+ )
126
+ const canShareByEmail = !hasParentRestriction && !hasChildRestriction
127
+ const canManageSharing =
128
+ isCurrentUserOwner || (documentId ? canReshare(documentId) : false)
129
+
130
+ const handleRevokeSelf = async document => {
131
+ await revokeSelf(document)
132
+ onRevokeSuccess?.(document)
133
+ }
75
134
 
76
135
  const handleCloseRequest = useCallback(() => {
77
136
  if (pendingRecipients.length === 0) {
@@ -109,34 +168,6 @@ const FederatedFolderModalContent = ({
109
168
  t
110
169
  ])
111
170
 
112
- const folderName = existingDocument?.name || ''
113
- const documentPath = existingDocument?.path
114
- const sharedDriveSharing = existingDocument?.driveId
115
- ? getSharingById(existingDocument.driveId)
116
- : null
117
- const sharedDriveRootIds =
118
- sharedDriveSharing?.attributes?.rules?.reduce(
119
- (ids, rule) => ids.concat(rule.values || []),
120
- []
121
- ) || []
122
- const isSharedDriveRoot = Boolean(
123
- existingDocument?.driveId &&
124
- sharedDriveRootIds.some(
125
- id => id === existingDocument?._id || id === existingDocument?.id
126
- )
127
- )
128
- const isInsideSharedDrive = Boolean(
129
- existingDocument?.driveId && !isSharedDriveRoot
130
- )
131
- const hasSharedParentByPath = Boolean(
132
- documentPath && hasSharedParent(documentPath)
133
- )
134
- const hasParentRestriction = isInsideSharedDrive || hasSharedParentByPath
135
- const hasChildRestriction = Boolean(
136
- documentPath && hasSharedChild(documentPath)
137
- )
138
- const canShareByEmail = !hasParentRestriction && !hasChildRestriction
139
-
140
171
  const onSend = async () => {
141
172
  if (isSending || pendingRecipients.length === 0) {
142
173
  onClose()
@@ -183,15 +214,6 @@ const FederatedFolderModalContent = ({
183
214
  }
184
215
  }
185
216
 
186
- const documentId = existingDocument?._id || existingDocument?.id
187
- // Owner case: when document is inside a shared folder (via path) but has no driveId,
188
- // find the parent shared folder to use its _id for recipient/permission lookups.
189
- const sharedParentPath =
190
- !sharedDriveSharing && hasSharedParentByPath && documentPath
191
- ? getSharedParentPath(documentPath)
192
- : null
193
- const [sharedParentFolder, setSharedParentFolder] = useState(null)
194
-
195
217
  useEffect(() => {
196
218
  if (!sharedParentPath) return
197
219
  const fetchParentFolder = async () => {
@@ -207,32 +229,6 @@ const FederatedFolderModalContent = ({
207
229
  fetchParentFolder()
208
230
  }, [sharedParentPath, client])
209
231
 
210
- const sharingReferenceId =
211
- !sharedDriveSharing && sharedParentFolder?._id
212
- ? sharedParentFolder._id
213
- : documentId
214
-
215
- const existingRecipients =
216
- sharedDriveSharing?.attributes?.members && documentId
217
- ? getRecipientsFromSharing(sharedDriveSharing, documentId)
218
- : sharingReferenceId
219
- ? getRecipients(sharingReferenceId)
220
- : []
221
- const documentPermissions = documentId
222
- ? getDocumentPermissions(documentId)
223
- : []
224
- const displayedLink = existingDocument?.driveId
225
- ? getFederatedShareLink(existingDocument)
226
- : getSharingLink(existingDocument?._id)
227
- const isCurrentUserOwner = documentId ? isOwner(documentId) : false
228
- const canManageSharing =
229
- isCurrentUserOwner || (documentId ? canReshare(documentId) : false)
230
-
231
- const handleRevokeSelf = async document => {
232
- await revokeSelf(document)
233
- onRevokeSuccess?.(document)
234
- }
235
-
236
232
  useEffect(() => {
237
233
  if (!existingDocument?.driveId) return
238
234
  if (!documentId) return
@@ -264,14 +260,12 @@ const FederatedFolderModalContent = ({
264
260
  isFetchingSharingLinks
265
261
  ])
266
262
 
267
- const modalTitle = t('FederatedFolder.shareTitle', { name: folderName })
268
-
269
263
  return (
270
264
  <FixedDialog
271
265
  open
272
266
  disableGutters
273
267
  onClose={handleCloseRequest}
274
- title={modalTitle}
268
+ title={t('FederatedFolder.shareTitle', { name: folderName })}
275
269
  classes={{ paper: 'u-ov-visible' }}
276
270
  componentsProps={{
277
271
  dialogContent: {
@@ -8,12 +8,12 @@ import styles from '../../styles/share.styl'
8
8
  import WhoHasAccess from '../WhoHasAccess'
9
9
 
10
10
  export const SharingDetailsModal = ({
11
- onClose,
12
11
  recipients,
13
12
  document,
14
13
  documentType = 'Document',
15
14
  onRevoke,
16
- onRevokeSelf
15
+ onRevokeSelf,
16
+ onClose
17
17
  }) => {
18
18
  const { t } = useI18n()
19
19
 
@@ -42,12 +42,11 @@ export const SharingDetailsModal = ({
42
42
  }
43
43
 
44
44
  SharingDetailsModal.propTypes = {
45
- onClose: PropTypes.func,
46
- sharingType: PropTypes.string,
47
- owner: PropTypes.object.isRequired,
45
+ recipients: PropTypes.array.isRequired,
48
46
  document: PropTypes.object.isRequired,
49
47
  documentType: PropTypes.string.isRequired,
50
48
  onRevoke: PropTypes.func.isRequired,
51
- onRevokeSelf: PropTypes.func
49
+ onRevokeSelf: PropTypes.func,
50
+ onClose: PropTypes.func
52
51
  }
53
52
  export default SharingDetailsModal