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
|
@@ -15,10 +15,12 @@ import { getOrCreateFromArray } from '../../helpers/contacts';
|
|
|
15
15
|
import { usePendingRecipients } from '../../hooks/usePendingRecipients';
|
|
16
16
|
import AppLike from '../SharingBanner/test/AppLike';
|
|
17
17
|
var mockShare = jest.fn();
|
|
18
|
+
var mockShareByLink = jest.fn();
|
|
18
19
|
var mockRevoke = jest.fn();
|
|
19
20
|
var mockGetSharingLink = jest.fn();
|
|
20
21
|
var mockGetFederatedShareLink = jest.fn();
|
|
21
22
|
var mockGetRecipients = jest.fn().mockReturnValue([]);
|
|
23
|
+
var mockGetSharingById = jest.fn();
|
|
22
24
|
var mockHasSharedChild = jest.fn();
|
|
23
25
|
var mockHasSharedParent = jest.fn();
|
|
24
26
|
var mockShowAlert = jest.fn();
|
|
@@ -28,11 +30,14 @@ jest.mock('../../hooks/useSharingContext', function () {
|
|
|
28
30
|
useSharingContext: function useSharingContext() {
|
|
29
31
|
return {
|
|
30
32
|
share: mockShare,
|
|
33
|
+
shareByLink: mockShareByLink,
|
|
31
34
|
revoke: mockRevoke,
|
|
32
35
|
getSharingLink: mockGetSharingLink,
|
|
33
36
|
getFederatedShareLink: mockGetFederatedShareLink,
|
|
34
37
|
getDocumentPermissions: jest.fn().mockReturnValue([]),
|
|
38
|
+
getOwner: jest.fn(),
|
|
35
39
|
getRecipients: mockGetRecipients,
|
|
40
|
+
getSharingById: mockGetSharingById,
|
|
36
41
|
hasSharedChild: mockHasSharedChild,
|
|
37
42
|
hasSharedParent: mockHasSharedParent
|
|
38
43
|
};
|
|
@@ -63,6 +68,11 @@ jest.mock('../../hooks/usePendingRecipients', function () {
|
|
|
63
68
|
usePendingRecipients: jest.fn()
|
|
64
69
|
};
|
|
65
70
|
});
|
|
71
|
+
jest.mock('../ShareByLink', function () {
|
|
72
|
+
return function () {
|
|
73
|
+
return /*#__PURE__*/React.createElement("button", null, "Copy link");
|
|
74
|
+
};
|
|
75
|
+
});
|
|
66
76
|
var mockDocument = {
|
|
67
77
|
_id: 'folder-123',
|
|
68
78
|
name: 'My Test Folder',
|
|
@@ -109,10 +119,26 @@ describe('FederatedFolderModal', function () {
|
|
|
109
119
|
beforeEach(function () {
|
|
110
120
|
jest.clearAllMocks();
|
|
111
121
|
mockGetSharingLink.mockReturnValue('https://example.com/share/abc123');
|
|
112
|
-
mockGetFederatedShareLink.
|
|
122
|
+
mockGetFederatedShareLink.mockReturnValue('https://example.com/share/federated-abc123');
|
|
113
123
|
mockGetRecipients.mockReturnValue([]);
|
|
124
|
+
mockGetSharingById.mockReturnValue(null);
|
|
114
125
|
mockHasSharedChild.mockReturnValue(false);
|
|
115
126
|
mockHasSharedParent.mockReturnValue(false);
|
|
127
|
+
mockShareByLink.mockResolvedValue({
|
|
128
|
+
data: {
|
|
129
|
+
_id: 'permission-id',
|
|
130
|
+
attributes: {
|
|
131
|
+
shortcodes: {
|
|
132
|
+
code: 'abc123'
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
Object.assign(navigator, {
|
|
138
|
+
clipboard: {
|
|
139
|
+
writeText: jest.fn()
|
|
140
|
+
}
|
|
141
|
+
});
|
|
116
142
|
client = createTestClient();
|
|
117
143
|
sharingContextValue = createSharingContextValue();
|
|
118
144
|
usePendingRecipients.mockReturnValue({
|
|
@@ -190,18 +216,44 @@ describe('FederatedFolderModal', function () {
|
|
|
190
216
|
}
|
|
191
217
|
}, _callee3);
|
|
192
218
|
})));
|
|
193
|
-
it('should
|
|
194
|
-
var _setup4, findByText, queryByText;
|
|
219
|
+
it('should show link access as soon as a link is generated', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
220
|
+
var _setup4, findByText, queryByText, rerender;
|
|
195
221
|
|
|
196
222
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
197
223
|
while (1) switch (_context4.prev = _context4.next) {
|
|
198
224
|
case 0:
|
|
199
|
-
|
|
225
|
+
mockGetSharingLink.mockReturnValue(null);
|
|
226
|
+
_setup4 = setup(), findByText = _setup4.findByText, queryByText = _setup4.queryByText, rerender = _setup4.rerender;
|
|
227
|
+
expect(queryByText('Anyone with the link')).toBe(null);
|
|
228
|
+
mockGetSharingLink.mockReturnValue('https://example.com/share/abc123');
|
|
229
|
+
rerender( /*#__PURE__*/React.createElement(AppLike, {
|
|
230
|
+
client: client,
|
|
231
|
+
sharingContextValue: sharingContextValue
|
|
232
|
+
}, /*#__PURE__*/React.createElement(FederatedFolderModal, {
|
|
233
|
+
document: mockDocument,
|
|
234
|
+
onClose: mockOnClose
|
|
235
|
+
})));
|
|
236
|
+
_context4.next = 7;
|
|
237
|
+
return findByText('Anyone with the link');
|
|
238
|
+
|
|
239
|
+
case 7:
|
|
240
|
+
case "end":
|
|
241
|
+
return _context4.stop();
|
|
242
|
+
}
|
|
243
|
+
}, _callee4);
|
|
244
|
+
})));
|
|
245
|
+
it('should hide share by email when document is in federated shared folder received by current user', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
246
|
+
var _setup5, findByText, queryByText;
|
|
247
|
+
|
|
248
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
249
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
250
|
+
case 0:
|
|
251
|
+
_setup5 = setup({
|
|
200
252
|
document: _objectSpread(_objectSpread({}, mockDocument), {}, {
|
|
201
253
|
driveId: 'federated-folder-id'
|
|
202
254
|
})
|
|
203
|
-
}), findByText =
|
|
204
|
-
|
|
255
|
+
}), findByText = _setup5.findByText, queryByText = _setup5.queryByText;
|
|
256
|
+
_context5.next = 3;
|
|
205
257
|
return findByText('Copy link');
|
|
206
258
|
|
|
207
259
|
case 3:
|
|
@@ -210,34 +262,68 @@ describe('FederatedFolderModal', function () {
|
|
|
210
262
|
|
|
211
263
|
case 5:
|
|
212
264
|
case "end":
|
|
213
|
-
return
|
|
265
|
+
return _context5.stop();
|
|
214
266
|
}
|
|
215
|
-
},
|
|
267
|
+
}, _callee5);
|
|
216
268
|
})));
|
|
217
|
-
it('should show only by link message when document is in federated shared folder received by current user', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
218
|
-
var
|
|
269
|
+
it('should show only by link message when document is in federated shared folder received by current user', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
270
|
+
var _setup6, findByText;
|
|
219
271
|
|
|
220
|
-
return _regeneratorRuntime.wrap(function
|
|
221
|
-
while (1) switch (
|
|
272
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
273
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
222
274
|
case 0:
|
|
223
|
-
|
|
275
|
+
_setup6 = setup({
|
|
224
276
|
document: _objectSpread(_objectSpread({}, mockDocument), {}, {
|
|
225
277
|
driveId: 'federated-folder-id',
|
|
226
278
|
type: 'directory'
|
|
227
279
|
})
|
|
228
|
-
}), findByText =
|
|
229
|
-
|
|
280
|
+
}), findByText = _setup6.findByText;
|
|
281
|
+
_context6.next = 3;
|
|
230
282
|
return findByText('This folder can only be shared by link, because');
|
|
231
283
|
|
|
232
284
|
case 3:
|
|
233
|
-
|
|
285
|
+
_context6.next = 5;
|
|
234
286
|
return findByText('it has a shared parent');
|
|
235
287
|
|
|
236
288
|
case 5:
|
|
237
289
|
case "end":
|
|
238
|
-
return
|
|
290
|
+
return _context6.stop();
|
|
239
291
|
}
|
|
240
|
-
},
|
|
292
|
+
}, _callee6);
|
|
293
|
+
})));
|
|
294
|
+
it('should allow share by email when document is the federated shared folder root', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
|
|
295
|
+
var _setup7, findByText, queryByText;
|
|
296
|
+
|
|
297
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
298
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
299
|
+
case 0:
|
|
300
|
+
mockGetSharingById.mockReturnValue({
|
|
301
|
+
attributes: {
|
|
302
|
+
rules: [{
|
|
303
|
+
values: ['another-folder-id']
|
|
304
|
+
}, {
|
|
305
|
+
values: ['yet-another-folder-id', mockDocument._id]
|
|
306
|
+
}]
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
_setup7 = setup({
|
|
310
|
+
document: _objectSpread(_objectSpread({}, mockDocument), {}, {
|
|
311
|
+
driveId: 'federated-folder-id',
|
|
312
|
+
type: 'directory'
|
|
313
|
+
})
|
|
314
|
+
}), findByText = _setup7.findByText, queryByText = _setup7.queryByText;
|
|
315
|
+
_context7.next = 4;
|
|
316
|
+
return findByText('Add users');
|
|
317
|
+
|
|
318
|
+
case 4:
|
|
319
|
+
expect(queryByText('This folder can only be shared by link, because')).toBe(null);
|
|
320
|
+
expect(queryByText('it has a shared parent')).toBe(null);
|
|
321
|
+
|
|
322
|
+
case 6:
|
|
323
|
+
case "end":
|
|
324
|
+
return _context7.stop();
|
|
325
|
+
}
|
|
326
|
+
}, _callee7);
|
|
241
327
|
})));
|
|
242
328
|
});
|
|
243
329
|
describe('onSend callback', function () {
|
|
@@ -245,21 +331,21 @@ describe('FederatedFolderModal', function () {
|
|
|
245
331
|
name: 'Alice',
|
|
246
332
|
email: 'alice@example.com'
|
|
247
333
|
};
|
|
248
|
-
it('should call onClose and skip share when there are no pending recipients', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
249
|
-
var
|
|
334
|
+
it('should call onClose and skip share when there are no pending recipients', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
335
|
+
var _setup8, findByText, sendButton;
|
|
250
336
|
|
|
251
|
-
return _regeneratorRuntime.wrap(function
|
|
252
|
-
while (1) switch (
|
|
337
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
338
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
253
339
|
case 0:
|
|
254
340
|
// pendingRecipients defaults to [] via beforeEach
|
|
255
|
-
|
|
256
|
-
|
|
341
|
+
_setup8 = setup(), findByText = _setup8.findByText;
|
|
342
|
+
_context8.next = 3;
|
|
257
343
|
return findByText('Done');
|
|
258
344
|
|
|
259
345
|
case 3:
|
|
260
|
-
sendButton =
|
|
346
|
+
sendButton = _context8.sent;
|
|
261
347
|
fireEvent.click(sendButton);
|
|
262
|
-
|
|
348
|
+
_context8.next = 7;
|
|
263
349
|
return waitFor(function () {
|
|
264
350
|
expect(mockOnClose).toHaveBeenCalled();
|
|
265
351
|
expect(mockShare).not.toHaveBeenCalled();
|
|
@@ -267,15 +353,15 @@ describe('FederatedFolderModal', function () {
|
|
|
267
353
|
|
|
268
354
|
case 7:
|
|
269
355
|
case "end":
|
|
270
|
-
return
|
|
356
|
+
return _context8.stop();
|
|
271
357
|
}
|
|
272
|
-
},
|
|
358
|
+
}, _callee8);
|
|
273
359
|
})));
|
|
274
|
-
it('should call share with correct parameters', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
275
|
-
var
|
|
360
|
+
it('should call share with correct parameters', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
|
|
361
|
+
var _setup9, findByText, sendButton;
|
|
276
362
|
|
|
277
|
-
return _regeneratorRuntime.wrap(function
|
|
278
|
-
while (1) switch (
|
|
363
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
364
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
279
365
|
case 0:
|
|
280
366
|
usePendingRecipients.mockReturnValue({
|
|
281
367
|
pendingRecipients: [pendingRecipient],
|
|
@@ -285,14 +371,14 @@ describe('FederatedFolderModal', function () {
|
|
|
285
371
|
});
|
|
286
372
|
getOrCreateFromArray.mockResolvedValue([pendingRecipient]);
|
|
287
373
|
mockShare.mockResolvedValueOnce({});
|
|
288
|
-
|
|
289
|
-
|
|
374
|
+
_setup9 = setup(), findByText = _setup9.findByText;
|
|
375
|
+
_context9.next = 6;
|
|
290
376
|
return findByText('Done');
|
|
291
377
|
|
|
292
378
|
case 6:
|
|
293
|
-
sendButton =
|
|
379
|
+
sendButton = _context9.sent;
|
|
294
380
|
fireEvent.click(sendButton);
|
|
295
|
-
|
|
381
|
+
_context9.next = 10;
|
|
296
382
|
return waitFor(function () {
|
|
297
383
|
expect(mockShare).toHaveBeenCalledWith({
|
|
298
384
|
description: 'My Test Folder',
|
|
@@ -306,15 +392,15 @@ describe('FederatedFolderModal', function () {
|
|
|
306
392
|
|
|
307
393
|
case 10:
|
|
308
394
|
case "end":
|
|
309
|
-
return
|
|
395
|
+
return _context9.stop();
|
|
310
396
|
}
|
|
311
|
-
},
|
|
397
|
+
}, _callee9);
|
|
312
398
|
})));
|
|
313
|
-
it('should show success alert and close modal on successful share', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
314
|
-
var
|
|
399
|
+
it('should show success alert and close modal on successful share', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
|
|
400
|
+
var _setup10, findByText, sendButton;
|
|
315
401
|
|
|
316
|
-
return _regeneratorRuntime.wrap(function
|
|
317
|
-
while (1) switch (
|
|
402
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
403
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
318
404
|
case 0:
|
|
319
405
|
usePendingRecipients.mockReturnValue({
|
|
320
406
|
pendingRecipients: [pendingRecipient],
|
|
@@ -324,14 +410,14 @@ describe('FederatedFolderModal', function () {
|
|
|
324
410
|
});
|
|
325
411
|
getOrCreateFromArray.mockResolvedValue([pendingRecipient]);
|
|
326
412
|
mockShare.mockResolvedValueOnce({});
|
|
327
|
-
|
|
328
|
-
|
|
413
|
+
_setup10 = setup(), findByText = _setup10.findByText;
|
|
414
|
+
_context10.next = 6;
|
|
329
415
|
return findByText('Done');
|
|
330
416
|
|
|
331
417
|
case 6:
|
|
332
|
-
sendButton =
|
|
418
|
+
sendButton = _context10.sent;
|
|
333
419
|
fireEvent.click(sendButton);
|
|
334
|
-
|
|
420
|
+
_context10.next = 10;
|
|
335
421
|
return waitFor(function () {
|
|
336
422
|
expect(mockShowAlert).toHaveBeenCalledWith({
|
|
337
423
|
message: 'Folder has been shared',
|
|
@@ -343,15 +429,15 @@ describe('FederatedFolderModal', function () {
|
|
|
343
429
|
|
|
344
430
|
case 10:
|
|
345
431
|
case "end":
|
|
346
|
-
return
|
|
432
|
+
return _context10.stop();
|
|
347
433
|
}
|
|
348
|
-
},
|
|
434
|
+
}, _callee10);
|
|
349
435
|
})));
|
|
350
|
-
it('should show error alert when share fails', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
351
|
-
var
|
|
436
|
+
it('should show error alert when share fails', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
|
|
437
|
+
var _setup11, findByText, sendButton;
|
|
352
438
|
|
|
353
|
-
return _regeneratorRuntime.wrap(function
|
|
354
|
-
while (1) switch (
|
|
439
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
440
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
355
441
|
case 0:
|
|
356
442
|
usePendingRecipients.mockReturnValue({
|
|
357
443
|
pendingRecipients: [pendingRecipient],
|
|
@@ -361,14 +447,14 @@ describe('FederatedFolderModal', function () {
|
|
|
361
447
|
});
|
|
362
448
|
getOrCreateFromArray.mockResolvedValue([pendingRecipient]);
|
|
363
449
|
mockShare.mockRejectedValueOnce(new Error('Share failed'));
|
|
364
|
-
|
|
365
|
-
|
|
450
|
+
_setup11 = setup(), findByText = _setup11.findByText;
|
|
451
|
+
_context11.next = 6;
|
|
366
452
|
return findByText('Done');
|
|
367
453
|
|
|
368
454
|
case 6:
|
|
369
|
-
sendButton =
|
|
455
|
+
sendButton = _context11.sent;
|
|
370
456
|
fireEvent.click(sendButton);
|
|
371
|
-
|
|
457
|
+
_context11.next = 10;
|
|
372
458
|
return waitFor(function () {
|
|
373
459
|
expect(mockShowAlert).toHaveBeenCalledWith({
|
|
374
460
|
message: 'Error while sharing folder',
|
|
@@ -380,15 +466,15 @@ describe('FederatedFolderModal', function () {
|
|
|
380
466
|
|
|
381
467
|
case 10:
|
|
382
468
|
case "end":
|
|
383
|
-
return
|
|
469
|
+
return _context11.stop();
|
|
384
470
|
}
|
|
385
|
-
},
|
|
471
|
+
}, _callee11);
|
|
386
472
|
})));
|
|
387
|
-
it('should show progress icon on Done button while share is in progress', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
388
|
-
var resolveShare,
|
|
473
|
+
it('should show progress icon on Done button while share is in progress', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
|
|
474
|
+
var resolveShare, _setup12, findByText, getByRole, queryByRole, sendButton;
|
|
389
475
|
|
|
390
|
-
return _regeneratorRuntime.wrap(function
|
|
391
|
-
while (1) switch (
|
|
476
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
477
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
392
478
|
case 0:
|
|
393
479
|
usePendingRecipients.mockReturnValue({
|
|
394
480
|
pendingRecipients: [pendingRecipient],
|
|
@@ -400,14 +486,14 @@ describe('FederatedFolderModal', function () {
|
|
|
400
486
|
mockShare.mockReturnValueOnce(new Promise(function (resolve) {
|
|
401
487
|
resolveShare = resolve;
|
|
402
488
|
}));
|
|
403
|
-
|
|
404
|
-
|
|
489
|
+
_setup12 = setup(), findByText = _setup12.findByText, getByRole = _setup12.getByRole, queryByRole = _setup12.queryByRole;
|
|
490
|
+
_context13.next = 6;
|
|
405
491
|
return findByText('Done');
|
|
406
492
|
|
|
407
493
|
case 6:
|
|
408
|
-
sendButton =
|
|
494
|
+
sendButton = _context13.sent;
|
|
409
495
|
fireEvent.click(sendButton);
|
|
410
|
-
|
|
496
|
+
_context13.next = 10;
|
|
411
497
|
return waitFor(function () {
|
|
412
498
|
expect(getByRole('button', {
|
|
413
499
|
name: 'Done'
|
|
@@ -416,56 +502,56 @@ describe('FederatedFolderModal', function () {
|
|
|
416
502
|
});
|
|
417
503
|
|
|
418
504
|
case 10:
|
|
419
|
-
|
|
420
|
-
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
421
|
-
return _regeneratorRuntime.wrap(function
|
|
422
|
-
while (1) switch (
|
|
505
|
+
_context13.next = 12;
|
|
506
|
+
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
|
|
507
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
508
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
423
509
|
case 0:
|
|
424
510
|
resolveShare({});
|
|
425
511
|
|
|
426
512
|
case 1:
|
|
427
513
|
case "end":
|
|
428
|
-
return
|
|
514
|
+
return _context12.stop();
|
|
429
515
|
}
|
|
430
|
-
},
|
|
516
|
+
}, _callee12);
|
|
431
517
|
})));
|
|
432
518
|
|
|
433
519
|
case 12:
|
|
434
520
|
case "end":
|
|
435
|
-
return
|
|
521
|
+
return _context13.stop();
|
|
436
522
|
}
|
|
437
|
-
},
|
|
523
|
+
}, _callee13);
|
|
438
524
|
})));
|
|
439
525
|
});
|
|
440
526
|
describe('onClose callback', function () {
|
|
441
|
-
it('should call onClose when close button is clicked', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
442
|
-
var
|
|
527
|
+
it('should call onClose when close button is clicked', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
|
|
528
|
+
var _setup13, findByRole, closeButton;
|
|
443
529
|
|
|
444
|
-
return _regeneratorRuntime.wrap(function
|
|
445
|
-
while (1) switch (
|
|
530
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
531
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
446
532
|
case 0:
|
|
447
|
-
|
|
448
|
-
|
|
533
|
+
_setup13 = setup(), findByRole = _setup13.findByRole;
|
|
534
|
+
_context14.next = 3;
|
|
449
535
|
return findByRole('button', {
|
|
450
536
|
name: /close/i
|
|
451
537
|
});
|
|
452
538
|
|
|
453
539
|
case 3:
|
|
454
|
-
closeButton =
|
|
540
|
+
closeButton = _context14.sent;
|
|
455
541
|
fireEvent.click(closeButton);
|
|
456
542
|
expect(mockOnClose).toHaveBeenCalled();
|
|
457
543
|
|
|
458
544
|
case 6:
|
|
459
545
|
case "end":
|
|
460
|
-
return
|
|
546
|
+
return _context14.stop();
|
|
461
547
|
}
|
|
462
|
-
},
|
|
548
|
+
}, _callee14);
|
|
463
549
|
})));
|
|
464
|
-
it('should ask confirmation when close button is clicked with pending recipients', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
465
|
-
var
|
|
550
|
+
it('should ask confirmation when close button is clicked with pending recipients', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15() {
|
|
551
|
+
var _setup14, getByRole, findByRole, getByText, closeButton;
|
|
466
552
|
|
|
467
|
-
return _regeneratorRuntime.wrap(function
|
|
468
|
-
while (1) switch (
|
|
553
|
+
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
554
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
469
555
|
case 0:
|
|
470
556
|
usePendingRecipients.mockReturnValue({
|
|
471
557
|
pendingRecipients: [{
|
|
@@ -476,14 +562,14 @@ describe('FederatedFolderModal', function () {
|
|
|
476
562
|
selectedOption: 'readWrite',
|
|
477
563
|
setSelectedOption: jest.fn()
|
|
478
564
|
});
|
|
479
|
-
|
|
480
|
-
|
|
565
|
+
_setup14 = setup(), getByRole = _setup14.getByRole, findByRole = _setup14.findByRole, getByText = _setup14.getByText;
|
|
566
|
+
_context15.next = 4;
|
|
481
567
|
return findByRole('button', {
|
|
482
568
|
name: /close/i
|
|
483
569
|
});
|
|
484
570
|
|
|
485
571
|
case 4:
|
|
486
|
-
closeButton =
|
|
572
|
+
closeButton = _context15.sent;
|
|
487
573
|
fireEvent.click(closeButton);
|
|
488
574
|
expect(getByText("Discard the changes you haven't saved?")).toBeTruthy();
|
|
489
575
|
expect(mockOnClose).not.toHaveBeenCalled();
|
|
@@ -494,15 +580,15 @@ describe('FederatedFolderModal', function () {
|
|
|
494
580
|
|
|
495
581
|
case 10:
|
|
496
582
|
case "end":
|
|
497
|
-
return
|
|
583
|
+
return _context15.stop();
|
|
498
584
|
}
|
|
499
|
-
},
|
|
585
|
+
}, _callee15);
|
|
500
586
|
})));
|
|
501
|
-
it('should close after discard confirmation', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
502
|
-
var
|
|
587
|
+
it('should close after discard confirmation', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16() {
|
|
588
|
+
var _setup15, getByRole, findByRole, getByText, closeButton;
|
|
503
589
|
|
|
504
|
-
return _regeneratorRuntime.wrap(function
|
|
505
|
-
while (1) switch (
|
|
590
|
+
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
591
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
506
592
|
case 0:
|
|
507
593
|
usePendingRecipients.mockReturnValue({
|
|
508
594
|
pendingRecipients: [{
|
|
@@ -513,14 +599,14 @@ describe('FederatedFolderModal', function () {
|
|
|
513
599
|
selectedOption: 'readWrite',
|
|
514
600
|
setSelectedOption: jest.fn()
|
|
515
601
|
});
|
|
516
|
-
|
|
517
|
-
|
|
602
|
+
_setup15 = setup(), getByRole = _setup15.getByRole, findByRole = _setup15.findByRole, getByText = _setup15.getByText;
|
|
603
|
+
_context16.next = 4;
|
|
518
604
|
return findByRole('button', {
|
|
519
605
|
name: /close/i
|
|
520
606
|
});
|
|
521
607
|
|
|
522
608
|
case 4:
|
|
523
|
-
closeButton =
|
|
609
|
+
closeButton = _context16.sent;
|
|
524
610
|
fireEvent.click(closeButton);
|
|
525
611
|
expect(getByText("Discard the changes you haven't saved?")).toBeTruthy();
|
|
526
612
|
fireEvent.click(getByRole('button', {
|
|
@@ -530,9 +616,9 @@ describe('FederatedFolderModal', function () {
|
|
|
530
616
|
|
|
531
617
|
case 9:
|
|
532
618
|
case "end":
|
|
533
|
-
return
|
|
619
|
+
return _context16.stop();
|
|
534
620
|
}
|
|
535
|
-
},
|
|
621
|
+
}, _callee16);
|
|
536
622
|
})));
|
|
537
623
|
});
|
|
538
624
|
});
|
|
@@ -24,6 +24,7 @@ import { getOrCreateFromArray } from '../helpers/contacts';
|
|
|
24
24
|
import { hasReachRecipientsLimit } from '../helpers/recipients';
|
|
25
25
|
import { getErrorMessage, getSuccessMessage } from '../helpers/share';
|
|
26
26
|
import { usePendingRecipients } from '../hooks/usePendingRecipients';
|
|
27
|
+
import { useSharingContext } from '../hooks/useSharingContext';
|
|
27
28
|
var styles = {
|
|
28
29
|
"share-modal-content": "share__share-modal-content___1iqEq",
|
|
29
30
|
"coz-form": "share__coz-form___1ICST",
|
|
@@ -144,6 +145,9 @@ var ShareDialogCozyToCozy = function ShareDialogCozyToCozy(_ref3) {
|
|
|
144
145
|
var _useAlert = useAlert(),
|
|
145
146
|
showAlert = _useAlert.showAlert;
|
|
146
147
|
|
|
148
|
+
var _useSharingContext = useSharingContext(),
|
|
149
|
+
getSharingLink = _useSharingContext.getSharingLink;
|
|
150
|
+
|
|
147
151
|
var _usePendingRecipients = usePendingRecipients(),
|
|
148
152
|
pendingRecipients = _usePendingRecipients.pendingRecipients,
|
|
149
153
|
setPendingRecipients = _usePendingRecipients.setPendingRecipients,
|
|
@@ -160,6 +164,7 @@ var ShareDialogCozyToCozy = function ShareDialogCozyToCozy(_ref3) {
|
|
|
160
164
|
showRecipientsLimit = _useState4[0],
|
|
161
165
|
setShowRecipientsLimit = _useState4[1];
|
|
162
166
|
|
|
167
|
+
var displayedLink = getSharingLink(document._id || document.id);
|
|
163
168
|
var handleShare = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
164
169
|
var contacts, readWriteRecipients, readOnlyRecipients;
|
|
165
170
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
@@ -254,6 +259,7 @@ var ShareDialogCozyToCozy = function ShareDialogCozyToCozy(_ref3) {
|
|
|
254
259
|
return Actions;
|
|
255
260
|
}, [handleShare, submitting, t, documentType, showShareByLink, showGenerateLinkButton, autoOpenShareRestriction]);
|
|
256
261
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ShareDialogTwoStepsConfirmationContainer, _extends({}, props, {
|
|
262
|
+
link: displayedLink,
|
|
257
263
|
documentType: documentType,
|
|
258
264
|
document: document,
|
|
259
265
|
recipients: recipients,
|
|
@@ -7,6 +7,7 @@ import { useI18n } from 'twake-i18n';
|
|
|
7
7
|
import AntivirusAlert from './AntivirusAlert';
|
|
8
8
|
import { default as DumbShareByLink } from './ShareByLink';
|
|
9
9
|
import WhoHasAccess from './WhoHasAccess';
|
|
10
|
+
import { useSharingContext } from '../hooks/useSharingContext';
|
|
10
11
|
|
|
11
12
|
var ShareDialogOnlyByLink = function ShareDialogOnlyByLink(_ref) {
|
|
12
13
|
var isOwner = _ref.isOwner,
|
|
@@ -15,7 +16,6 @@ var ShareDialogOnlyByLink = function ShareDialogOnlyByLink(_ref) {
|
|
|
15
16
|
recipients = _ref.recipients,
|
|
16
17
|
document = _ref.document,
|
|
17
18
|
documentType = _ref.documentType,
|
|
18
|
-
link = _ref.link,
|
|
19
19
|
onClose = _ref.onClose,
|
|
20
20
|
permissions = _ref.permissions,
|
|
21
21
|
showGenerateLinkButton = _ref.showGenerateLinkButton,
|
|
@@ -27,6 +27,10 @@ var ShareDialogOnlyByLink = function ShareDialogOnlyByLink(_ref) {
|
|
|
27
27
|
var _useBreakpoints = useBreakpoints(),
|
|
28
28
|
isMobile = _useBreakpoints.isMobile;
|
|
29
29
|
|
|
30
|
+
var _useSharingContext = useSharingContext(),
|
|
31
|
+
getSharingLink = _useSharingContext.getSharingLink;
|
|
32
|
+
|
|
33
|
+
var displayedLink = getSharingLink(document._id || document.id);
|
|
30
34
|
return /*#__PURE__*/React.createElement(Dialog, {
|
|
31
35
|
disableGutters: true,
|
|
32
36
|
disableEnforceFocus: true,
|
|
@@ -47,12 +51,12 @@ var ShareDialogOnlyByLink = function ShareDialogOnlyByLink(_ref) {
|
|
|
47
51
|
onRevoke: onRevoke,
|
|
48
52
|
onRevokeSelf: onRevokeSelf,
|
|
49
53
|
recipients: recipients,
|
|
50
|
-
link:
|
|
54
|
+
link: displayedLink,
|
|
51
55
|
permissions: permissions
|
|
52
56
|
}), /*#__PURE__*/React.createElement("div", {
|
|
53
57
|
className: cx('u-mt-half', isMobile ? 'u-ph-1 u-mb-1' : 'u-ph-2 u-mb-1-half')
|
|
54
58
|
}, /*#__PURE__*/React.createElement(DumbShareByLink, {
|
|
55
|
-
link:
|
|
59
|
+
link: displayedLink,
|
|
56
60
|
document: document,
|
|
57
61
|
documentType: documentType,
|
|
58
62
|
showGenerateLinkButton: showGenerateLinkButton,
|