cozy-sharing 15.0.3 → 16.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/SharingProvider.js +106 -109
- package/dist/components/Tooltip.js +3 -5
- package/dist/fetchNextPermissions.js +5 -3
- package/dist/helpers/synchronousJobQueue.js +1 -3
- package/package.json +7 -7
- package/test/AppLike.jsx +9 -11
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
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
|
+
# [16.0.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@15.0.4...cozy-sharing@16.0.0) (2024-09-23)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **sharing:** Upgrade packages ([c2acd41](https://github.com/cozy/cozy-libs/commit/c2acd41fbac71ab80071201a23c4c8797c10346e))
|
|
11
|
+
|
|
12
|
+
### BREAKING CHANGES
|
|
13
|
+
|
|
14
|
+
- **sharing:** you must have `cozy-ui >= 111.12.0 and cozy-client >= 48.25.0`
|
|
15
|
+
|
|
16
|
+
## [15.0.4](https://github.com/cozy/cozy-libs/compare/cozy-sharing@15.0.3...cozy-sharing@15.0.4) (2024-09-09)
|
|
17
|
+
|
|
18
|
+
**Note:** Version bump only for package cozy-sharing
|
|
19
|
+
|
|
6
20
|
## [15.0.3](https://github.com/cozy/cozy-libs/compare/cozy-sharing@15.0.2...cozy-sharing@15.0.3) (2024-08-28)
|
|
7
21
|
|
|
8
22
|
### Bug Fixes
|
package/dist/SharingProvider.js
CHANGED
|
@@ -5,7 +5,6 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
|
5
5
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
6
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
9
8
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
10
9
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
11
10
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
@@ -43,63 +42,61 @@ import reducer, { receiveSharings, addSharing, updateSharing, addSharingLink, up
|
|
|
43
42
|
var SHARING_DOCTYPE = 'io.cozy.sharings';
|
|
44
43
|
var PERMISSION_DOCTYPE = 'io.cozy.permissions';
|
|
45
44
|
export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
46
|
-
_inherits(SharingProvider, _Component);
|
|
47
|
-
|
|
48
45
|
function SharingProvider(props, context) {
|
|
49
|
-
var
|
|
46
|
+
var _this2;
|
|
50
47
|
|
|
51
48
|
_classCallCheck(this, SharingProvider);
|
|
52
49
|
|
|
53
|
-
|
|
50
|
+
_this2 = _callSuper(this, SharingProvider, [props, context]);
|
|
54
51
|
|
|
55
|
-
_defineProperty(
|
|
56
|
-
return
|
|
52
|
+
_defineProperty(_this2, "dispatch", function (action) {
|
|
53
|
+
return _this2.setState(function (state) {
|
|
57
54
|
return _objectSpread(_objectSpread({}, state), reducer(state, action));
|
|
58
55
|
});
|
|
59
56
|
});
|
|
60
57
|
|
|
61
|
-
_defineProperty(
|
|
62
|
-
if (
|
|
63
|
-
var client =
|
|
58
|
+
_defineProperty(_this2, "initialize", function () {
|
|
59
|
+
if (_this2.isInitialized) return;
|
|
60
|
+
var client = _this2.props.client;
|
|
64
61
|
|
|
65
|
-
|
|
62
|
+
_this2.fetchAllSharings();
|
|
66
63
|
|
|
67
64
|
if (!client.plugins.realtime) {
|
|
68
65
|
// eslint-disable-next-line
|
|
69
66
|
console.warn("You should register the realtime plugin to your CozyClient instance see https://docs.cozy.io/en/cozy-realtime/#example");
|
|
70
67
|
} else {
|
|
71
|
-
|
|
68
|
+
_this2.realtime = client.plugins.realtime;
|
|
72
69
|
|
|
73
|
-
|
|
70
|
+
_this2.realtime.subscribe('created', SHARING_DOCTYPE, _this2.handleCreateOrUpdateSharings);
|
|
74
71
|
|
|
75
|
-
|
|
72
|
+
_this2.realtime.subscribe('updated', SHARING_DOCTYPE, _this2.handleCreateOrUpdateSharings);
|
|
76
73
|
}
|
|
77
74
|
|
|
78
|
-
|
|
75
|
+
_this2.isInitialized = true;
|
|
79
76
|
});
|
|
80
77
|
|
|
81
|
-
_defineProperty(
|
|
78
|
+
_defineProperty(_this2, "handleCreateOrUpdateSharings", /*#__PURE__*/function () {
|
|
82
79
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(sharing) {
|
|
83
|
-
var
|
|
80
|
+
var _this2$props, client, doctype, internalSharing, newSharing, docsId;
|
|
84
81
|
|
|
85
82
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
86
83
|
while (1) switch (_context.prev = _context.next) {
|
|
87
84
|
case 0:
|
|
88
|
-
|
|
89
|
-
internalSharing = getSharingById(
|
|
85
|
+
_this2$props = _this2.props, client = _this2$props.client, doctype = _this2$props.doctype;
|
|
86
|
+
internalSharing = getSharingById(_this2.state, sharing._id);
|
|
90
87
|
newSharing = getSharingObject(internalSharing, sharing);
|
|
91
88
|
|
|
92
89
|
if (internalSharing) {
|
|
93
|
-
updateSharingInStore(
|
|
90
|
+
updateSharingInStore(_this2.dispatch, newSharing);
|
|
94
91
|
} else {
|
|
95
92
|
docsId = getExternalSharingIds(newSharing, client.getStackClient().uri);
|
|
96
93
|
|
|
97
|
-
|
|
94
|
+
_this2.synchronousJobQueue.push({
|
|
98
95
|
function: createSharingInStore,
|
|
99
96
|
arguments: {
|
|
100
97
|
client: client,
|
|
101
98
|
doctype: doctype,
|
|
102
|
-
dispatch:
|
|
99
|
+
dispatch: _this2.dispatch,
|
|
103
100
|
docsId: docsId,
|
|
104
101
|
sharing: newSharing
|
|
105
102
|
}
|
|
@@ -118,18 +115,18 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
118
115
|
};
|
|
119
116
|
}());
|
|
120
117
|
|
|
121
|
-
_defineProperty(
|
|
118
|
+
_defineProperty(_this2, "share", /*#__PURE__*/function () {
|
|
122
119
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref2) {
|
|
123
|
-
var
|
|
120
|
+
var _this2$props$previewP;
|
|
124
121
|
|
|
125
|
-
var document, recipients, readOnlyRecipients, description, openSharing,
|
|
122
|
+
var document, recipients, readOnlyRecipients, description, openSharing, _this2$props2, client, doctype, sharing, sharingResult, previewPath, _yield$_this2$sharing, data;
|
|
126
123
|
|
|
127
124
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
128
125
|
while (1) switch (_context2.prev = _context2.next) {
|
|
129
126
|
case 0:
|
|
130
127
|
document = _ref2.document, recipients = _ref2.recipients, readOnlyRecipients = _ref2.readOnlyRecipients, description = _ref2.description, openSharing = _ref2.openSharing;
|
|
131
|
-
|
|
132
|
-
sharing = getDocumentSharing(
|
|
128
|
+
_this2$props2 = _this2.props, client = _this2$props2.client, doctype = _this2$props2.doctype;
|
|
129
|
+
sharing = getDocumentSharing(_this2.state, document.id);
|
|
133
130
|
|
|
134
131
|
if (!sharing) {
|
|
135
132
|
_context2.next = 10;
|
|
@@ -137,7 +134,7 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
137
134
|
}
|
|
138
135
|
|
|
139
136
|
_context2.next = 6;
|
|
140
|
-
return
|
|
137
|
+
return _this2.addRecipients({
|
|
141
138
|
document: sharing,
|
|
142
139
|
recipients: recipients,
|
|
143
140
|
readOnlyRecipients: readOnlyRecipients
|
|
@@ -146,7 +143,7 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
146
143
|
case 6:
|
|
147
144
|
sharingResult = _context2.sent;
|
|
148
145
|
_context2.next = 9;
|
|
149
|
-
return
|
|
146
|
+
return _this2.state.onShared({
|
|
150
147
|
document: document,
|
|
151
148
|
recipients: recipients,
|
|
152
149
|
readOnlyRecipients: readOnlyRecipients
|
|
@@ -156,9 +153,9 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
156
153
|
return _context2.abrupt("return", sharingResult);
|
|
157
154
|
|
|
158
155
|
case 10:
|
|
159
|
-
previewPath = (
|
|
156
|
+
previewPath = (_this2$props$previewP = _this2.props.previewPath) !== null && _this2$props$previewP !== void 0 ? _this2$props$previewP : '/preview';
|
|
160
157
|
_context2.next = 13;
|
|
161
|
-
return
|
|
158
|
+
return _this2.sharingCol.create({
|
|
162
159
|
document: document,
|
|
163
160
|
recipients: recipients,
|
|
164
161
|
readOnlyRecipients: readOnlyRecipients,
|
|
@@ -168,9 +165,9 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
168
165
|
});
|
|
169
166
|
|
|
170
167
|
case 13:
|
|
171
|
-
_yield$
|
|
172
|
-
data = _yield$
|
|
173
|
-
_context2.t0 =
|
|
168
|
+
_yield$_this2$sharing = _context2.sent;
|
|
169
|
+
data = _yield$_this2$sharing.data;
|
|
170
|
+
_context2.t0 = _this2;
|
|
174
171
|
_context2.t1 = addSharing;
|
|
175
172
|
_context2.t2 = data;
|
|
176
173
|
_context2.t3 = document.path;
|
|
@@ -193,7 +190,7 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
193
190
|
_context2.t0.dispatch.call(_context2.t0, _context2.t5);
|
|
194
191
|
|
|
195
192
|
_context2.next = 28;
|
|
196
|
-
return
|
|
193
|
+
return _this2.state.onShared({
|
|
197
194
|
document: document,
|
|
198
195
|
recipients: recipients,
|
|
199
196
|
readOnlyRecipients: readOnlyRecipients
|
|
@@ -214,7 +211,7 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
214
211
|
};
|
|
215
212
|
}());
|
|
216
213
|
|
|
217
|
-
_defineProperty(
|
|
214
|
+
_defineProperty(_this2, "addRecipients", /*#__PURE__*/function () {
|
|
218
215
|
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref4) {
|
|
219
216
|
var document, recipients, readOnlyRecipients, resp;
|
|
220
217
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
@@ -222,7 +219,7 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
222
219
|
case 0:
|
|
223
220
|
document = _ref4.document, recipients = _ref4.recipients, readOnlyRecipients = _ref4.readOnlyRecipients;
|
|
224
221
|
_context3.next = 3;
|
|
225
|
-
return
|
|
222
|
+
return _this2.sharingCol.addRecipients({
|
|
226
223
|
document: document,
|
|
227
224
|
recipients: recipients,
|
|
228
225
|
readOnlyRecipients: readOnlyRecipients
|
|
@@ -231,7 +228,7 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
231
228
|
case 3:
|
|
232
229
|
resp = _context3.sent;
|
|
233
230
|
|
|
234
|
-
|
|
231
|
+
_this2.dispatch(updateSharing(resp.data));
|
|
235
232
|
|
|
236
233
|
case 5:
|
|
237
234
|
case "end":
|
|
@@ -245,18 +242,18 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
245
242
|
};
|
|
246
243
|
}());
|
|
247
244
|
|
|
248
|
-
_defineProperty(
|
|
245
|
+
_defineProperty(_this2, "revokeAllRecipients", /*#__PURE__*/function () {
|
|
249
246
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(document) {
|
|
250
|
-
var
|
|
247
|
+
var _this2$props3, client, doctype, recipients, sharing;
|
|
251
248
|
|
|
252
249
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
253
250
|
while (1) switch (_context5.prev = _context5.next) {
|
|
254
251
|
case 0:
|
|
255
|
-
|
|
256
|
-
recipients = _getRecipients(
|
|
257
|
-
sharing = getDocumentSharing(
|
|
252
|
+
_this2$props3 = _this2.props, client = _this2$props3.client, doctype = _this2$props3.doctype;
|
|
253
|
+
recipients = _getRecipients(_this2.state, document.id);
|
|
254
|
+
sharing = getDocumentSharing(_this2.state, document.id);
|
|
258
255
|
_context5.next = 5;
|
|
259
|
-
return
|
|
256
|
+
return _this2.sharingCol.revokeAllRecipients(sharing);
|
|
260
257
|
|
|
261
258
|
case 5:
|
|
262
259
|
recipients.map( /*#__PURE__*/function () {
|
|
@@ -264,7 +261,7 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
264
261
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
265
262
|
while (1) switch (_context4.prev = _context4.next) {
|
|
266
263
|
case 0:
|
|
267
|
-
_context4.t0 =
|
|
264
|
+
_context4.t0 = _this2;
|
|
268
265
|
_context4.t1 = revokeRecipient;
|
|
269
266
|
_context4.t2 = sharing;
|
|
270
267
|
_context4.t3 = recipientIndex;
|
|
@@ -311,20 +308,20 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
311
308
|
};
|
|
312
309
|
}());
|
|
313
310
|
|
|
314
|
-
_defineProperty(
|
|
311
|
+
_defineProperty(_this2, "revoke", /*#__PURE__*/function () {
|
|
315
312
|
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(document, sharingId, recipientIndex) {
|
|
316
|
-
var
|
|
313
|
+
var _this2$props4, client, doctype, sharing;
|
|
317
314
|
|
|
318
315
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
319
316
|
while (1) switch (_context6.prev = _context6.next) {
|
|
320
317
|
case 0:
|
|
321
|
-
|
|
322
|
-
sharing = getSharingById(
|
|
318
|
+
_this2$props4 = _this2.props, client = _this2$props4.client, doctype = _this2$props4.doctype;
|
|
319
|
+
sharing = getSharingById(_this2.state, sharingId);
|
|
323
320
|
_context6.next = 4;
|
|
324
|
-
return
|
|
321
|
+
return _this2.sharingCol.revokeRecipient(sharing, recipientIndex);
|
|
325
322
|
|
|
326
323
|
case 4:
|
|
327
|
-
_context6.t0 =
|
|
324
|
+
_context6.t0 = _this2;
|
|
328
325
|
_context6.t1 = revokeRecipient;
|
|
329
326
|
_context6.t2 = sharing;
|
|
330
327
|
_context6.t3 = recipientIndex;
|
|
@@ -359,20 +356,20 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
359
356
|
};
|
|
360
357
|
}());
|
|
361
358
|
|
|
362
|
-
_defineProperty(
|
|
359
|
+
_defineProperty(_this2, "revokeGroup", /*#__PURE__*/function () {
|
|
363
360
|
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(document, sharingId, recipientIndex) {
|
|
364
|
-
var
|
|
361
|
+
var _this2$props5, client, doctype, sharing;
|
|
365
362
|
|
|
366
363
|
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
367
364
|
while (1) switch (_context7.prev = _context7.next) {
|
|
368
365
|
case 0:
|
|
369
|
-
|
|
370
|
-
sharing = getSharingById(
|
|
366
|
+
_this2$props5 = _this2.props, client = _this2$props5.client, doctype = _this2$props5.doctype;
|
|
367
|
+
sharing = getSharingById(_this2.state, sharingId);
|
|
371
368
|
_context7.next = 4;
|
|
372
|
-
return
|
|
369
|
+
return _this2.sharingCol.revokeGroup(sharing, recipientIndex);
|
|
373
370
|
|
|
374
371
|
case 4:
|
|
375
|
-
_context7.t0 =
|
|
372
|
+
_context7.t0 = _this2;
|
|
376
373
|
_context7.t1 = revokeGroupFromState;
|
|
377
374
|
_context7.t2 = sharing;
|
|
378
375
|
_context7.t3 = recipientIndex;
|
|
@@ -407,18 +404,18 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
407
404
|
};
|
|
408
405
|
}());
|
|
409
406
|
|
|
410
|
-
_defineProperty(
|
|
407
|
+
_defineProperty(_this2, "revokeSelf", /*#__PURE__*/function () {
|
|
411
408
|
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(document) {
|
|
412
409
|
var sharing;
|
|
413
410
|
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
414
411
|
while (1) switch (_context8.prev = _context8.next) {
|
|
415
412
|
case 0:
|
|
416
|
-
sharing = _getSharingForSelf(
|
|
413
|
+
sharing = _getSharingForSelf(_this2.state, document.id);
|
|
417
414
|
_context8.next = 3;
|
|
418
|
-
return
|
|
415
|
+
return _this2.sharingCol.revokeSelf(sharing);
|
|
419
416
|
|
|
420
417
|
case 3:
|
|
421
|
-
|
|
418
|
+
_this2.dispatch(revokeSelf(sharing));
|
|
422
419
|
|
|
423
420
|
case 4:
|
|
424
421
|
case "end":
|
|
@@ -432,19 +429,19 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
432
429
|
};
|
|
433
430
|
}());
|
|
434
431
|
|
|
435
|
-
_defineProperty(
|
|
432
|
+
_defineProperty(_this2, "shareByLink", /*#__PURE__*/function () {
|
|
436
433
|
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(document, options) {
|
|
437
434
|
var resp;
|
|
438
435
|
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
439
436
|
while (1) switch (_context9.prev = _context9.next) {
|
|
440
437
|
case 0:
|
|
441
438
|
_context9.next = 2;
|
|
442
|
-
return
|
|
439
|
+
return _this2.permissionCol.createSharingLink(document, options);
|
|
443
440
|
|
|
444
441
|
case 2:
|
|
445
442
|
resp = _context9.sent;
|
|
446
443
|
|
|
447
|
-
|
|
444
|
+
_this2.dispatch(addSharingLink(resp.data));
|
|
448
445
|
|
|
449
446
|
return _context9.abrupt("return", resp);
|
|
450
447
|
|
|
@@ -468,13 +465,13 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
468
465
|
*
|
|
469
466
|
* @return {Array}
|
|
470
467
|
*/
|
|
471
|
-
_defineProperty(
|
|
468
|
+
_defineProperty(_this2, "updateDocumentPermissions", /*#__PURE__*/function () {
|
|
472
469
|
var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(document, newVerbs) {
|
|
473
470
|
var permissions, responses;
|
|
474
471
|
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
475
472
|
while (1) switch (_context11.prev = _context11.next) {
|
|
476
473
|
case 0:
|
|
477
|
-
permissions = _getDocumentPermissions(
|
|
474
|
+
permissions = _getDocumentPermissions(_this2.state, document.id);
|
|
478
475
|
_context11.next = 3;
|
|
479
476
|
return Promise.all(permissions.map( /*#__PURE__*/function () {
|
|
480
477
|
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(permissionDocument) {
|
|
@@ -487,12 +484,12 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
487
484
|
updatedPermissions[permType].verbs = newVerbs;
|
|
488
485
|
});
|
|
489
486
|
_context10.next = 4;
|
|
490
|
-
return
|
|
487
|
+
return _this2.permissionCol.add(permissionDocument, updatedPermissions);
|
|
491
488
|
|
|
492
489
|
case 4:
|
|
493
490
|
resp = _context10.sent;
|
|
494
491
|
|
|
495
|
-
|
|
492
|
+
_this2.dispatch(updateSharingLink(resp));
|
|
496
493
|
|
|
497
494
|
return _context10.abrupt("return", resp);
|
|
498
495
|
|
|
@@ -524,7 +521,7 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
524
521
|
};
|
|
525
522
|
}());
|
|
526
523
|
|
|
527
|
-
_defineProperty(
|
|
524
|
+
_defineProperty(_this2, "revokeSharingLink", /*#__PURE__*/function () {
|
|
528
525
|
var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(document) {
|
|
529
526
|
var perms;
|
|
530
527
|
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
@@ -532,14 +529,14 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
532
529
|
case 0:
|
|
533
530
|
// Because some duplicate links have been created in the past, we must ensure
|
|
534
531
|
// we revoke all of them
|
|
535
|
-
perms = _getDocumentPermissions(
|
|
532
|
+
perms = _getDocumentPermissions(_this2.state, document.id);
|
|
536
533
|
_context12.next = 3;
|
|
537
534
|
return Promise.all(perms.map(function (p) {
|
|
538
|
-
return
|
|
535
|
+
return _this2.permissionCol.destroy(p);
|
|
539
536
|
}));
|
|
540
537
|
|
|
541
538
|
case 3:
|
|
542
|
-
|
|
539
|
+
_this2.dispatch(revokeSharingLink(perms));
|
|
543
540
|
|
|
544
541
|
case 4:
|
|
545
542
|
case "end":
|
|
@@ -553,10 +550,10 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
553
550
|
};
|
|
554
551
|
}());
|
|
555
552
|
|
|
556
|
-
_defineProperty(
|
|
557
|
-
var instanceUri =
|
|
553
|
+
_defineProperty(_this2, "hasWriteAccess", function (docId) {
|
|
554
|
+
var instanceUri = _this2.props.client.getStackClient().uri;
|
|
558
555
|
|
|
559
|
-
return !
|
|
556
|
+
return !_this2.state.byDocId || !_this2.state.byDocId[docId] || _isOwner(_this2.state, docId) || _getSharingType(_this2.state, docId, instanceUri) === 'two-way';
|
|
560
557
|
});
|
|
561
558
|
|
|
562
559
|
var _instanceUri = props.client.getStackClient().uri;
|
|
@@ -564,70 +561,72 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
564
561
|
|
|
565
562
|
var onShared = props.onShared || function () {};
|
|
566
563
|
|
|
567
|
-
|
|
564
|
+
_this2.state = {
|
|
568
565
|
byDocId: {},
|
|
569
566
|
sharings: [],
|
|
570
567
|
permissions: [],
|
|
571
568
|
sharedFolderPaths: [],
|
|
572
569
|
documentType: documentType,
|
|
573
570
|
isOwner: function isOwner(docId) {
|
|
574
|
-
return _isOwner(
|
|
571
|
+
return _isOwner(_this2.state, docId);
|
|
575
572
|
},
|
|
576
573
|
canReshare: function canReshare(docId) {
|
|
577
|
-
return _canReshare(
|
|
574
|
+
return _canReshare(_this2.state, docId, _instanceUri);
|
|
578
575
|
},
|
|
579
576
|
getOwner: function getOwner(docId) {
|
|
580
|
-
return _getOwner(
|
|
577
|
+
return _getOwner(_this2.state, docId);
|
|
581
578
|
},
|
|
582
579
|
getSharingType: function getSharingType(docId) {
|
|
583
|
-
return _getSharingType(
|
|
580
|
+
return _getSharingType(_this2.state, docId, _instanceUri);
|
|
584
581
|
},
|
|
585
582
|
getSharingForSelf: function getSharingForSelf(docId) {
|
|
586
|
-
return _getSharingForSelf(
|
|
583
|
+
return _getSharingForSelf(_this2.state, docId);
|
|
587
584
|
},
|
|
588
585
|
getRecipients: function getRecipients(docId) {
|
|
589
|
-
return _getRecipients(
|
|
586
|
+
return _getRecipients(_this2.state, docId);
|
|
590
587
|
},
|
|
591
588
|
getSharedParentPath: function getSharedParentPath(documentPath) {
|
|
592
|
-
return _getSharedParentPath(
|
|
589
|
+
return _getSharedParentPath(_this2.state, documentPath);
|
|
593
590
|
},
|
|
594
591
|
getDocumentPermissions: function getDocumentPermissions(docId) {
|
|
595
|
-
return _getDocumentPermissions(
|
|
592
|
+
return _getDocumentPermissions(_this2.state, docId);
|
|
596
593
|
},
|
|
597
594
|
getSharingLink: function getSharingLink(docId) {
|
|
598
|
-
return _getSharingLink(
|
|
595
|
+
return _getSharingLink(_this2.state, docId, documentType);
|
|
599
596
|
},
|
|
600
597
|
hasSharedParent: function hasSharedParent(documentPath) {
|
|
601
|
-
return _hasSharedParent(
|
|
598
|
+
return _hasSharedParent(_this2.state, documentPath);
|
|
602
599
|
},
|
|
603
600
|
hasSharedChild: function hasSharedChild(documentPath) {
|
|
604
|
-
return _hasSharedChild(
|
|
601
|
+
return _hasSharedChild(_this2.state, documentPath);
|
|
605
602
|
},
|
|
606
|
-
share:
|
|
603
|
+
share: _this2.share,
|
|
607
604
|
onShared: onShared,
|
|
608
|
-
revoke:
|
|
609
|
-
revokeGroup:
|
|
610
|
-
revokeSelf:
|
|
611
|
-
shareByLink:
|
|
612
|
-
updateDocumentPermissions:
|
|
613
|
-
revokeSharingLink:
|
|
605
|
+
revoke: _this2.revoke,
|
|
606
|
+
revokeGroup: _this2.revokeGroup,
|
|
607
|
+
revokeSelf: _this2.revokeSelf,
|
|
608
|
+
shareByLink: _this2.shareByLink,
|
|
609
|
+
updateDocumentPermissions: _this2.updateDocumentPermissions,
|
|
610
|
+
revokeSharingLink: _this2.revokeSharingLink,
|
|
614
611
|
hasLoadedAtLeastOnePage: false,
|
|
615
612
|
allLoaded: false,
|
|
616
|
-
revokeAllRecipients:
|
|
617
|
-
refresh:
|
|
618
|
-
hasWriteAccess:
|
|
613
|
+
revokeAllRecipients: _this2.revokeAllRecipients,
|
|
614
|
+
refresh: _this2.fetchAllSharings,
|
|
615
|
+
hasWriteAccess: _this2.hasWriteAccess
|
|
619
616
|
};
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
617
|
+
_this2.realtime = null;
|
|
618
|
+
_this2.isInitialized = false;
|
|
619
|
+
_this2.synchronousJobQueue = new SynchronousJobQueue();
|
|
623
620
|
var _client = props.client;
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
return
|
|
621
|
+
_this2.sharingCol = _client.collection(SHARING_DOCTYPE);
|
|
622
|
+
_this2.permissionCol = _client.collection(PERMISSION_DOCTYPE);
|
|
623
|
+
_this2.fetchAllSharings = _this2.fetchAllSharings.bind(_this2);
|
|
624
|
+
return _this2;
|
|
628
625
|
}
|
|
629
626
|
|
|
630
|
-
|
|
627
|
+
_inherits(SharingProvider, _Component);
|
|
628
|
+
|
|
629
|
+
return _createClass(SharingProvider, [{
|
|
631
630
|
key: "componentDidMount",
|
|
632
631
|
value: function componentDidMount() {
|
|
633
632
|
var client = this.props.client;
|
|
@@ -650,12 +649,12 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
650
649
|
key: "fetchAllSharings",
|
|
651
650
|
value: function () {
|
|
652
651
|
var _fetchAllSharings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
|
|
653
|
-
var _this$
|
|
652
|
+
var _this$props, doctype, client, _yield$Promise$all, _yield$Promise$all2, sharings, permissions, apps, sharedDocIds, resp, folderPaths, filePaths;
|
|
654
653
|
|
|
655
654
|
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
656
655
|
while (1) switch (_context13.prev = _context13.next) {
|
|
657
656
|
case 0:
|
|
658
|
-
_this$
|
|
657
|
+
_this$props = this.props, doctype = _this$props.doctype, client = _this$props.client;
|
|
659
658
|
_context13.next = 3;
|
|
660
659
|
return Promise.all([this.sharingCol.findByDoctype(doctype), this.permissionCol.findLinksByDoctype(doctype), client.fetchQueryAndGetFromState(fetchApps())]);
|
|
661
660
|
|
|
@@ -735,7 +734,5 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
735
734
|
}, this.props.children);
|
|
736
735
|
}
|
|
737
736
|
}]);
|
|
738
|
-
|
|
739
|
-
return SharingProvider;
|
|
740
737
|
}(Component);
|
|
741
738
|
export default withClient(SharingProvider);
|
|
@@ -39,15 +39,15 @@ export var SharingTooltip = function SharingTooltip(props) {
|
|
|
39
39
|
}; // accepts all the props from https://github.com/wwayne/react-tooltip#options
|
|
40
40
|
|
|
41
41
|
export var TooltipRecipientList = /*#__PURE__*/function (_React$Component) {
|
|
42
|
-
_inherits(TooltipRecipientList, _React$Component);
|
|
43
|
-
|
|
44
42
|
function TooltipRecipientList() {
|
|
45
43
|
_classCallCheck(this, TooltipRecipientList);
|
|
46
44
|
|
|
47
45
|
return _callSuper(this, TooltipRecipientList, arguments);
|
|
48
46
|
}
|
|
49
47
|
|
|
50
|
-
|
|
48
|
+
_inherits(TooltipRecipientList, _React$Component);
|
|
49
|
+
|
|
50
|
+
return _createClass(TooltipRecipientList, [{
|
|
51
51
|
key: "render",
|
|
52
52
|
value: function render() {
|
|
53
53
|
var t = this.context.t;
|
|
@@ -66,8 +66,6 @@ export var TooltipRecipientList = /*#__PURE__*/function (_React$Component) {
|
|
|
66
66
|
})));
|
|
67
67
|
}
|
|
68
68
|
}]);
|
|
69
|
-
|
|
70
|
-
return TooltipRecipientList;
|
|
71
69
|
}(React.Component);
|
|
72
70
|
|
|
73
71
|
_defineProperty(TooltipRecipientList, "contextTypes", {
|
|
@@ -9,7 +9,7 @@ import { addSharingLink } from './state';
|
|
|
9
9
|
* @param {Object} client
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
var _fetchNextPermissions = /*#__PURE__*/function () {
|
|
13
13
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(permissions, dispatch, permissionCol) {
|
|
14
14
|
var resp;
|
|
15
15
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
@@ -26,7 +26,7 @@ export var fetchNextPermissions = /*#__PURE__*/function () {
|
|
|
26
26
|
case 3:
|
|
27
27
|
resp = _context.sent;
|
|
28
28
|
dispatch(addSharingLink(resp.data));
|
|
29
|
-
return _context.abrupt("return",
|
|
29
|
+
return _context.abrupt("return", _fetchNextPermissions(resp, dispatch, permissionCol));
|
|
30
30
|
|
|
31
31
|
case 6:
|
|
32
32
|
case "end":
|
|
@@ -38,4 +38,6 @@ export var fetchNextPermissions = /*#__PURE__*/function () {
|
|
|
38
38
|
return function fetchNextPermissions(_x, _x2, _x3) {
|
|
39
39
|
return _ref.apply(this, arguments);
|
|
40
40
|
};
|
|
41
|
-
}();
|
|
41
|
+
}();
|
|
42
|
+
|
|
43
|
+
export { _fetchNextPermissions as fetchNextPermissions };
|
|
@@ -10,7 +10,7 @@ export var SynchronousJobQueue = /*#__PURE__*/function () {
|
|
|
10
10
|
this.queue = [];
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
_createClass(SynchronousJobQueue, [{
|
|
13
|
+
return _createClass(SynchronousJobQueue, [{
|
|
14
14
|
key: "push",
|
|
15
15
|
value: function push(job) {
|
|
16
16
|
this.queue.push(job);
|
|
@@ -60,6 +60,4 @@ export var SynchronousJobQueue = /*#__PURE__*/function () {
|
|
|
60
60
|
return run;
|
|
61
61
|
}()
|
|
62
62
|
}]);
|
|
63
|
-
|
|
64
|
-
return SynchronousJobQueue;
|
|
65
63
|
}();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-sharing",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "16.0.0",
|
|
4
4
|
"description": "Provides sharing login for React applications.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "Cozy",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@cozy/minilog": "^1.0.0",
|
|
32
32
|
"classnames": "^2.2.6",
|
|
33
|
-
"cozy-device-helper": "^3.
|
|
33
|
+
"cozy-device-helper": "^3.1.0",
|
|
34
34
|
"cozy-doctypes": "^1.91.1",
|
|
35
35
|
"lodash": "^4.17.19",
|
|
36
36
|
"react-autosuggest": "^10.1.0",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"babel-jest": "26.6.3",
|
|
50
50
|
"babel-plugin-css-modules-transform": "1.6.2",
|
|
51
51
|
"babel-plugin-inline-react-svg": "1.1.2",
|
|
52
|
-
"cozy-client": "^
|
|
53
|
-
"cozy-ui": "^
|
|
52
|
+
"cozy-client": "^48.25.0",
|
|
53
|
+
"cozy-ui": "^111.12.0",
|
|
54
54
|
"enzyme": "3.11.0",
|
|
55
55
|
"enzyme-adapter-react-16": "1.15.6",
|
|
56
56
|
"enzyme-to-json": "3.6.2",
|
|
@@ -61,9 +61,9 @@
|
|
|
61
61
|
"storybook": "7.6.0"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"cozy-client": ">=
|
|
64
|
+
"cozy-client": ">=48.25.0",
|
|
65
65
|
"cozy-realtime": "^3.11.0",
|
|
66
|
-
"cozy-ui": ">=
|
|
66
|
+
"cozy-ui": ">=111.12.0",
|
|
67
67
|
"prop-types": "^15.7.2",
|
|
68
68
|
"react": "^16.12.0",
|
|
69
69
|
"react-router": "^5.0.1"
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"sideEffects": [
|
|
72
72
|
"*.css"
|
|
73
73
|
],
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "cd826b4d7b13547bb315574bc554f090efdca11f"
|
|
75
75
|
}
|
package/test/AppLike.jsx
CHANGED
|
@@ -9,17 +9,15 @@ import { I18n } from 'cozy-ui/transpiled/react/providers/I18n'
|
|
|
9
9
|
import langEn from '../locales/en.json'
|
|
10
10
|
|
|
11
11
|
const AppLike = ({ children, client }) => (
|
|
12
|
-
<
|
|
13
|
-
<
|
|
14
|
-
<
|
|
15
|
-
<
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
</CozyTheme>
|
|
22
|
-
</BreakpointsProvider>
|
|
12
|
+
<CozyProvider client={client || createMockClient({})}>
|
|
13
|
+
<BreakpointsProvider>
|
|
14
|
+
<CozyTheme>
|
|
15
|
+
<I18n lang="en" dictRequire={() => langEn}>
|
|
16
|
+
<AlertProvider>{children}</AlertProvider>
|
|
17
|
+
</I18n>
|
|
18
|
+
</CozyTheme>
|
|
19
|
+
</BreakpointsProvider>
|
|
20
|
+
</CozyProvider>
|
|
23
21
|
)
|
|
24
22
|
|
|
25
23
|
export default AppLike
|