cozy-sharing 28.3.4 → 28.4.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 +10 -0
- package/dist/components/FederatedFolder/DumbFederatedFolderModal.js +56 -0
- package/dist/components/FederatedFolder/FederatedFolderModal.js +150 -0
- package/dist/components/FederatedFolder/FederatedFolderModal.spec.js +543 -0
- package/dist/components/Recipient/LinkRecipient.js +1 -1
- package/dist/components/ShareAutosuggest.js +4 -1
- package/dist/components/ShareByEmail.js +105 -33
- package/dist/components/ShareByEmail.spec.js +111 -9
- package/dist/components/ShareByLink.js +3 -3
- package/dist/components/ShareModal/ShareModal.js +18 -2
- package/dist/components/ShareModal.js +1 -1
- package/dist/components/ShareRecipientsInput.js +5 -2
- package/dist/components/SharedDrive/DumbSharedDriveModal.js +39 -72
- package/dist/components/SharedDrive/SharedDriveModal.js +11 -5
- package/dist/components/SharedDrive/helpers.js +28 -2
- package/dist/components/SharedFolder/DumbBatchSharedFolderModal.js +159 -0
- package/dist/components/WhoHasAccess.js +1 -1
- package/dist/index.js +1 -0
- package/locales/en.json +13 -1
- package/locales/fr.json +15 -3
- package/locales/ru.json +13 -1
- package/locales/vi.json +13 -1
- package/package.json +3 -3
- package/src/components/FederatedFolder/DumbFederatedFolderModal.jsx +62 -0
- package/src/components/FederatedFolder/FederatedFolderModal.jsx +119 -0
- package/src/components/FederatedFolder/FederatedFolderModal.spec.jsx +376 -0
- package/src/components/Recipient/LinkRecipient.jsx +1 -1
- package/src/components/ShareAutosuggest.jsx +4 -1
- package/src/components/ShareByEmail.jsx +47 -8
- package/src/components/ShareByEmail.spec.jsx +96 -6
- package/src/components/ShareByLink.jsx +7 -3
- package/src/components/ShareModal/ShareModal.jsx +16 -1
- package/src/components/ShareModal.jsx +1 -1
- package/src/components/ShareRecipientsInput.jsx +5 -2
- package/src/components/SharedDrive/DumbSharedDriveModal.jsx +38 -88
- package/src/components/SharedDrive/SharedDriveModal.jsx +14 -4
- package/src/components/SharedDrive/helpers.js +33 -2
- package/src/components/SharedFolder/DumbBatchSharedFolderModal.jsx +174 -0
- package/src/components/WhoHasAccess.jsx +1 -1
- package/src/index.jsx +1 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
4
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
@@ -49,7 +49,9 @@ export var ShareByEmail = function ShareByEmail(_ref) {
|
|
|
49
49
|
sharing = _ref.sharing,
|
|
50
50
|
submitLabel = _ref.submitLabel,
|
|
51
51
|
_ref$showNotification = _ref.showNotifications,
|
|
52
|
-
showNotifications = _ref$showNotification === void 0 ? true : _ref$showNotification
|
|
52
|
+
showNotifications = _ref$showNotification === void 0 ? true : _ref$showNotification,
|
|
53
|
+
_ref$sharedDrive = _ref.sharedDrive,
|
|
54
|
+
sharedDrive = _ref$sharedDrive === void 0 ? false : _ref$sharedDrive;
|
|
53
55
|
var client = useClient();
|
|
54
56
|
|
|
55
57
|
var _useI18n = useI18n(),
|
|
@@ -58,6 +60,8 @@ export var ShareByEmail = function ShareByEmail(_ref) {
|
|
|
58
60
|
var _useAlert = useAlert(),
|
|
59
61
|
showAlert = _useAlert.showAlert;
|
|
60
62
|
|
|
63
|
+
var isFederatedMode = flag('drive.federated-shared-folder.enabled');
|
|
64
|
+
|
|
61
65
|
var _useState = useState([]),
|
|
62
66
|
_useState2 = _slicedToArray(_useState, 2),
|
|
63
67
|
recipients = _useState2[0],
|
|
@@ -88,10 +92,74 @@ export var ShareByEmail = function ShareByEmail(_ref) {
|
|
|
88
92
|
setSelectedOption(value);
|
|
89
93
|
};
|
|
90
94
|
|
|
91
|
-
var onRecipientPick = function
|
|
92
|
-
var
|
|
93
|
-
|
|
94
|
-
|
|
95
|
+
var onRecipientPick = /*#__PURE__*/function () {
|
|
96
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(recipient) {
|
|
97
|
+
var contacts, mergedRecipients;
|
|
98
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
99
|
+
while (1) switch (_context.prev = _context.next) {
|
|
100
|
+
case 0:
|
|
101
|
+
if (!isFederatedMode) {
|
|
102
|
+
_context.next = 17;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
setLoading(true);
|
|
107
|
+
_context.prev = 2;
|
|
108
|
+
_context.next = 5;
|
|
109
|
+
return getOrCreateFromArray(client, [recipient], createContact);
|
|
110
|
+
|
|
111
|
+
case 5:
|
|
112
|
+
contacts = _context.sent;
|
|
113
|
+
_context.next = 8;
|
|
114
|
+
return onShare({
|
|
115
|
+
document: document,
|
|
116
|
+
recipients: contacts,
|
|
117
|
+
readOnlyRecipients: [],
|
|
118
|
+
description: sharingDesc,
|
|
119
|
+
openSharing: false,
|
|
120
|
+
sharedDrive: true
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
case 8:
|
|
124
|
+
_context.next = 13;
|
|
125
|
+
break;
|
|
126
|
+
|
|
127
|
+
case 10:
|
|
128
|
+
_context.prev = 10;
|
|
129
|
+
_context.t0 = _context["catch"](2);
|
|
130
|
+
|
|
131
|
+
if (showNotifications) {
|
|
132
|
+
showAlert({
|
|
133
|
+
message: t('Share.shareByEmail.error.addingRecipient'),
|
|
134
|
+
severity: 'error',
|
|
135
|
+
variant: 'filled'
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
case 13:
|
|
140
|
+
_context.prev = 13;
|
|
141
|
+
reset();
|
|
142
|
+
return _context.finish(13);
|
|
143
|
+
|
|
144
|
+
case 16:
|
|
145
|
+
return _context.abrupt("return");
|
|
146
|
+
|
|
147
|
+
case 17:
|
|
148
|
+
// Normal mode: just add to the list
|
|
149
|
+
mergedRecipients = flag('sharing.show-recipient-groups') ? mergeRecipients(recipients, recipient) : spreadGroupAndMergeRecipients(recipients, recipient);
|
|
150
|
+
setRecipients(mergedRecipients);
|
|
151
|
+
|
|
152
|
+
case 19:
|
|
153
|
+
case "end":
|
|
154
|
+
return _context.stop();
|
|
155
|
+
}
|
|
156
|
+
}, _callee, null, [[2, 10, 13, 16]]);
|
|
157
|
+
}));
|
|
158
|
+
|
|
159
|
+
return function onRecipientPick(_x) {
|
|
160
|
+
return _ref2.apply(this, arguments);
|
|
161
|
+
};
|
|
162
|
+
}();
|
|
95
163
|
|
|
96
164
|
var onRecipientRemove = function onRecipientRemove(recipient) {
|
|
97
165
|
var idx = recipients.findIndex(function (r) {
|
|
@@ -101,17 +169,17 @@ export var ShareByEmail = function ShareByEmail(_ref) {
|
|
|
101
169
|
};
|
|
102
170
|
|
|
103
171
|
var share = /*#__PURE__*/function () {
|
|
104
|
-
var
|
|
172
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
105
173
|
var recipientsBefore, contacts, readWriteRecipients, readOnlyRecipients;
|
|
106
|
-
return _regeneratorRuntime.wrap(function
|
|
107
|
-
while (1) switch (
|
|
174
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
175
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
108
176
|
case 0:
|
|
109
177
|
if (!(recipients.length === 0)) {
|
|
110
|
-
|
|
178
|
+
_context2.next = 2;
|
|
111
179
|
break;
|
|
112
180
|
}
|
|
113
181
|
|
|
114
|
-
return
|
|
182
|
+
return _context2.abrupt("return");
|
|
115
183
|
|
|
116
184
|
case 2:
|
|
117
185
|
// we can't use currentRecipients prop in getSuccessMessage because it may use
|
|
@@ -119,21 +187,21 @@ export var ShareByEmail = function ShareByEmail(_ref) {
|
|
|
119
187
|
recipientsBefore = currentRecipients;
|
|
120
188
|
|
|
121
189
|
if (!hasReachRecipientsLimit(recipientsBefore, recipients)) {
|
|
122
|
-
|
|
190
|
+
_context2.next = 6;
|
|
123
191
|
break;
|
|
124
192
|
}
|
|
125
193
|
|
|
126
194
|
setRecipientsLimit(true);
|
|
127
|
-
return
|
|
195
|
+
return _context2.abrupt("return");
|
|
128
196
|
|
|
129
197
|
case 6:
|
|
130
198
|
setLoading(true);
|
|
131
|
-
|
|
132
|
-
|
|
199
|
+
_context2.prev = 7;
|
|
200
|
+
_context2.next = 10;
|
|
133
201
|
return getOrCreateFromArray(client, recipients, createContact);
|
|
134
202
|
|
|
135
203
|
case 10:
|
|
136
|
-
contacts =
|
|
204
|
+
contacts = _context2.sent;
|
|
137
205
|
readWriteRecipients = [];
|
|
138
206
|
readOnlyRecipients = [];
|
|
139
207
|
|
|
@@ -143,13 +211,14 @@ export var ShareByEmail = function ShareByEmail(_ref) {
|
|
|
143
211
|
readWriteRecipients = contacts;
|
|
144
212
|
}
|
|
145
213
|
|
|
146
|
-
|
|
214
|
+
_context2.next = 16;
|
|
147
215
|
return onShare({
|
|
148
216
|
document: document,
|
|
149
217
|
recipients: readWriteRecipients,
|
|
150
218
|
readOnlyRecipients: readOnlyRecipients,
|
|
151
219
|
description: sharingDesc,
|
|
152
|
-
openSharing: readWriteRecipients.length > 0
|
|
220
|
+
openSharing: readWriteRecipients.length > 0,
|
|
221
|
+
sharedDrive: sharedDrive
|
|
153
222
|
});
|
|
154
223
|
|
|
155
224
|
case 16:
|
|
@@ -161,18 +230,18 @@ export var ShareByEmail = function ShareByEmail(_ref) {
|
|
|
161
230
|
});
|
|
162
231
|
}
|
|
163
232
|
|
|
164
|
-
|
|
233
|
+
_context2.next = 22;
|
|
165
234
|
break;
|
|
166
235
|
|
|
167
236
|
case 19:
|
|
168
|
-
|
|
169
|
-
|
|
237
|
+
_context2.prev = 19;
|
|
238
|
+
_context2.t0 = _context2["catch"](7);
|
|
170
239
|
|
|
171
240
|
if (showNotifications) {
|
|
172
241
|
showAlert({
|
|
173
242
|
message: t.apply(void 0, _toConsumableArray(getErrorMessage({
|
|
174
243
|
t: t,
|
|
175
|
-
err:
|
|
244
|
+
err: _context2.t0,
|
|
176
245
|
documentType: documentType,
|
|
177
246
|
recipients: recipients,
|
|
178
247
|
selectedOption: selectedOption
|
|
@@ -183,24 +252,24 @@ export var ShareByEmail = function ShareByEmail(_ref) {
|
|
|
183
252
|
}
|
|
184
253
|
|
|
185
254
|
case 22:
|
|
186
|
-
|
|
255
|
+
_context2.prev = 22;
|
|
187
256
|
reset();
|
|
188
|
-
return
|
|
257
|
+
return _context2.finish(22);
|
|
189
258
|
|
|
190
259
|
case 25:
|
|
191
260
|
case "end":
|
|
192
|
-
return
|
|
261
|
+
return _context2.stop();
|
|
193
262
|
}
|
|
194
|
-
},
|
|
263
|
+
}, _callee2, null, [[7, 19, 22, 25]]);
|
|
195
264
|
}));
|
|
196
265
|
|
|
197
266
|
return function share() {
|
|
198
|
-
return
|
|
267
|
+
return _ref3.apply(this, arguments);
|
|
199
268
|
};
|
|
200
269
|
}();
|
|
201
270
|
|
|
202
271
|
var getSharingOptions = function getSharingOptions() {
|
|
203
|
-
var isSharingReadOnly = sharing ? isReadOnlySharing(sharing, document._id) : false;
|
|
272
|
+
var isSharingReadOnly = sharing ? isReadOnlySharing(sharing, document === null || document === void 0 ? void 0 : document._id) : false;
|
|
204
273
|
var readWrite = {
|
|
205
274
|
value: 'readWrite',
|
|
206
275
|
label: t('Share.type.two-way'),
|
|
@@ -230,8 +299,9 @@ export var ShareByEmail = function ShareByEmail(_ref) {
|
|
|
230
299
|
return onRecipientRemove(recipient);
|
|
231
300
|
},
|
|
232
301
|
currentRecipients: currentRecipients,
|
|
233
|
-
recipients: recipients
|
|
234
|
-
|
|
302
|
+
recipients: recipients,
|
|
303
|
+
disabled: loading
|
|
304
|
+
})), !isFederatedMode && showShareControl && /*#__PURE__*/React.createElement("div", {
|
|
235
305
|
className: styles['share-type-control']
|
|
236
306
|
}, /*#__PURE__*/React.createElement(ShareTypeSelect, {
|
|
237
307
|
value: selectedOption,
|
|
@@ -243,7 +313,7 @@ export var ShareByEmail = function ShareByEmail(_ref) {
|
|
|
243
313
|
loading: loading,
|
|
244
314
|
disabled: recipients.length === 0
|
|
245
315
|
})), showRecipientsLimit ? /*#__PURE__*/React.createElement(ShareRecipientsLimitModal, {
|
|
246
|
-
documentName: document.name,
|
|
316
|
+
documentName: document === null || document === void 0 ? void 0 : document.name,
|
|
247
317
|
onConfirm: function onConfirm() {
|
|
248
318
|
return setRecipientsLimit(false);
|
|
249
319
|
}
|
|
@@ -251,7 +321,7 @@ export var ShareByEmail = function ShareByEmail(_ref) {
|
|
|
251
321
|
};
|
|
252
322
|
ShareByEmail.propTypes = {
|
|
253
323
|
currentRecipients: PropTypes.arrayOf(PropTypes.object),
|
|
254
|
-
document: PropTypes.object
|
|
324
|
+
document: PropTypes.object,
|
|
255
325
|
documentType: PropTypes.string.isRequired,
|
|
256
326
|
sharingDesc: PropTypes.string.isRequired,
|
|
257
327
|
onShare: PropTypes.func.isRequired,
|
|
@@ -261,6 +331,8 @@ ShareByEmail.propTypes = {
|
|
|
261
331
|
// Customize the label of the button that submit contacts
|
|
262
332
|
submitLabel: PropTypes.string,
|
|
263
333
|
// Display success or error notifications
|
|
264
|
-
showNotifications: PropTypes.bool
|
|
334
|
+
showNotifications: PropTypes.bool,
|
|
335
|
+
// Set to true for shared drive context
|
|
336
|
+
sharedDrive: PropTypes.bool
|
|
265
337
|
};
|
|
266
338
|
export default ShareByEmail;
|
|
@@ -6,14 +6,25 @@ import { act } from 'react-dom/test-utils';
|
|
|
6
6
|
import flag from 'cozy-flags';
|
|
7
7
|
import { ShareByEmail } from './ShareByEmail';
|
|
8
8
|
import AppLike from '../../test/AppLike';
|
|
9
|
+
import { getOrCreateFromArray } from '../helpers/contacts';
|
|
9
10
|
jest.mock('../helpers/contacts', function () {
|
|
10
11
|
return {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
// eslint-disable-next-line no-unused-vars
|
|
13
|
+
getOrCreateFromArray: jest.fn(function (client, recipients, _createContact) {
|
|
14
|
+
// Return the recipients as-is by default (simulating contact creation/lookup)
|
|
15
|
+
return Promise.resolve(recipients);
|
|
16
|
+
})
|
|
14
17
|
};
|
|
15
18
|
});
|
|
16
|
-
jest.mock('cozy-flags')
|
|
19
|
+
jest.mock('cozy-flags', function () {
|
|
20
|
+
return jest.fn(function (flagName) {
|
|
21
|
+
if (flagName === 'drive.federated-shared-folder.enabled') {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return null;
|
|
26
|
+
});
|
|
27
|
+
});
|
|
17
28
|
describe('ShareByEmailComponent', function () {
|
|
18
29
|
var defaultDocument = {
|
|
19
30
|
id: 'doc_id',
|
|
@@ -28,7 +39,9 @@ describe('ShareByEmailComponent', function () {
|
|
|
28
39
|
_ref$document = _ref.document,
|
|
29
40
|
document = _ref$document === void 0 ? defaultDocument : _ref$document,
|
|
30
41
|
_ref$currentRecipient = _ref.currentRecipients,
|
|
31
|
-
currentRecipients = _ref$currentRecipient === void 0 ? [] : _ref$currentRecipient
|
|
42
|
+
currentRecipients = _ref$currentRecipient === void 0 ? [] : _ref$currentRecipient,
|
|
43
|
+
_ref$sharedDrive = _ref.sharedDrive,
|
|
44
|
+
sharedDrive = _ref$sharedDrive === void 0 ? false : _ref$sharedDrive;
|
|
32
45
|
|
|
33
46
|
var props = {
|
|
34
47
|
documentType: 'Files',
|
|
@@ -36,13 +49,22 @@ describe('ShareByEmailComponent', function () {
|
|
|
36
49
|
document: document,
|
|
37
50
|
sharingDesc: sharingDesc,
|
|
38
51
|
currentRecipients: currentRecipients,
|
|
39
|
-
createContact: jest.fn()
|
|
52
|
+
createContact: jest.fn(),
|
|
53
|
+
sharedDrive: sharedDrive
|
|
40
54
|
};
|
|
41
55
|
return render( /*#__PURE__*/React.createElement(AppLike, null, /*#__PURE__*/React.createElement(ShareByEmail, props)));
|
|
42
56
|
};
|
|
43
57
|
|
|
44
58
|
beforeEach(function () {
|
|
45
|
-
jest.clearAllMocks();
|
|
59
|
+
jest.clearAllMocks(); // Reset flag mock to default (non-federated mode)
|
|
60
|
+
|
|
61
|
+
flag.mockImplementation(function (flagName) {
|
|
62
|
+
if (flagName === 'drive.federated-shared-folder.enabled') {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return null;
|
|
67
|
+
});
|
|
46
68
|
});
|
|
47
69
|
it('shoud call share if submited', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
48
70
|
var sharingDesc;
|
|
@@ -81,7 +103,8 @@ describe('ShareByEmailComponent', function () {
|
|
|
81
103
|
readOnlyRecipients: [],
|
|
82
104
|
recipients: [{
|
|
83
105
|
email: 'quentin@cozycloud.cc'
|
|
84
|
-
}]
|
|
106
|
+
}],
|
|
107
|
+
sharedDrive: false
|
|
85
108
|
});
|
|
86
109
|
});
|
|
87
110
|
|
|
@@ -95,7 +118,17 @@ describe('ShareByEmailComponent', function () {
|
|
|
95
118
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
96
119
|
while (1) switch (_context2.prev = _context2.next) {
|
|
97
120
|
case 0:
|
|
98
|
-
flag.
|
|
121
|
+
flag.mockImplementation(function (flagName) {
|
|
122
|
+
if (flagName === 'sharing.recipients-limit') {
|
|
123
|
+
return 2;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (flagName === 'drive.federated-shared-folder.enabled') {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return null;
|
|
131
|
+
});
|
|
99
132
|
setup({
|
|
100
133
|
currentRecipients: [{
|
|
101
134
|
email: 'alice@gmail.com',
|
|
@@ -142,4 +175,73 @@ describe('ShareByEmailComponent', function () {
|
|
|
142
175
|
}
|
|
143
176
|
}, _callee2);
|
|
144
177
|
})));
|
|
178
|
+
describe('federated mode', function () {
|
|
179
|
+
beforeEach(function () {
|
|
180
|
+
flag.mockImplementation(function (flagName) {
|
|
181
|
+
if (flagName === 'drive.federated-shared-folder.enabled') {
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return null;
|
|
186
|
+
});
|
|
187
|
+
getOrCreateFromArray.mockResolvedValue([{
|
|
188
|
+
_id: 'contact1',
|
|
189
|
+
email: 'quentin@cozycloud.cc'
|
|
190
|
+
}]);
|
|
191
|
+
});
|
|
192
|
+
it('should directly share when selecting a recipient in federated mode', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
193
|
+
var sharingDesc, createContact;
|
|
194
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
195
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
196
|
+
case 0:
|
|
197
|
+
sharingDesc = 'test';
|
|
198
|
+
createContact = jest.fn();
|
|
199
|
+
setup({
|
|
200
|
+
sharingDesc: sharingDesc,
|
|
201
|
+
createContact: createContact
|
|
202
|
+
});
|
|
203
|
+
act(function () {
|
|
204
|
+
fireEvent.change(screen.getByPlaceholderText('Add contacts or groups'), {
|
|
205
|
+
target: {
|
|
206
|
+
value: 'quentin@cozycloud.cc'
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
act(function () {
|
|
211
|
+
fireEvent.keyPress(screen.getByPlaceholderText('Add contacts or groups'), {
|
|
212
|
+
key: 'Enter',
|
|
213
|
+
code: 'Enter',
|
|
214
|
+
charCode: 13
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
_context3.next = 7;
|
|
218
|
+
return waitFor(function () {
|
|
219
|
+
expect(getOrCreateFromArray).toHaveBeenCalledWith(expect.any(Object), [{
|
|
220
|
+
email: 'quentin@cozycloud.cc'
|
|
221
|
+
}], expect.any(Function));
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
case 7:
|
|
225
|
+
_context3.next = 9;
|
|
226
|
+
return waitFor(function () {
|
|
227
|
+
expect(onShare).toHaveBeenCalledWith({
|
|
228
|
+
document: defaultDocument,
|
|
229
|
+
recipients: [{
|
|
230
|
+
_id: 'contact1',
|
|
231
|
+
email: 'quentin@cozycloud.cc'
|
|
232
|
+
}],
|
|
233
|
+
readOnlyRecipients: [],
|
|
234
|
+
description: sharingDesc,
|
|
235
|
+
openSharing: false,
|
|
236
|
+
sharedDrive: true
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
case 9:
|
|
241
|
+
case "end":
|
|
242
|
+
return _context3.stop();
|
|
243
|
+
}
|
|
244
|
+
}, _callee3);
|
|
245
|
+
})));
|
|
246
|
+
});
|
|
145
247
|
});
|
|
@@ -5,6 +5,7 @@ import PropTypes from 'prop-types';
|
|
|
5
5
|
import React, { useReducer, useState } from 'react';
|
|
6
6
|
import { useI18n } from 'twake-i18n';
|
|
7
7
|
import { useClient } from 'cozy-client';
|
|
8
|
+
import flag from 'cozy-flags';
|
|
8
9
|
import Button from 'cozy-ui/transpiled/react/Buttons';
|
|
9
10
|
import Icon from 'cozy-ui/transpiled/react/Icon';
|
|
10
11
|
import CopyIcon from 'cozy-ui/transpiled/react/Icons/Copy';
|
|
@@ -44,6 +45,7 @@ var ShareByLink = function ShareByLink(_ref) {
|
|
|
44
45
|
var canShare = typeof ((_navigator = navigator) === null || _navigator === void 0 ? void 0 : _navigator.share) === 'function';
|
|
45
46
|
var showCopyAndSendButtons = isMobile && canShare;
|
|
46
47
|
var showOnlyCopyButton = !isMobile || !canShare;
|
|
48
|
+
var isFederated = flag('drive.federated-shared-folder.enabled');
|
|
47
49
|
|
|
48
50
|
var _useReducer = useReducer(function (state) {
|
|
49
51
|
return !state;
|
|
@@ -224,7 +226,7 @@ var ShareByLink = function ShareByLink(_ref) {
|
|
|
224
226
|
}();
|
|
225
227
|
|
|
226
228
|
return /*#__PURE__*/React.createElement("div", {
|
|
227
|
-
className:
|
|
229
|
+
className: isFederated ? 'u-w-100' : 'u-w-100 u-flex u-flex-justify-center'
|
|
228
230
|
}, showCopyAndSendButtons && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
|
|
229
231
|
label: t("".concat(documentType, ".share.shareByLink.send")),
|
|
230
232
|
variant: "secondary",
|
|
@@ -232,7 +234,6 @@ var ShareByLink = function ShareByLink(_ref) {
|
|
|
232
234
|
startIcon: /*#__PURE__*/React.createElement(Icon, {
|
|
233
235
|
icon: LinkIcon
|
|
234
236
|
}),
|
|
235
|
-
className: "u-flex-auto u-mr-half",
|
|
236
237
|
onClick: shareLink,
|
|
237
238
|
busy: isGenerating
|
|
238
239
|
}), /*#__PURE__*/React.createElement(Button, {
|
|
@@ -250,7 +251,6 @@ var ShareByLink = function ShareByLink(_ref) {
|
|
|
250
251
|
startIcon: /*#__PURE__*/React.createElement(Icon, {
|
|
251
252
|
icon: LinkIcon
|
|
252
253
|
}),
|
|
253
|
-
className: "u-flex-auto u-mr-half",
|
|
254
254
|
onClick: generateLinkAndCopyLinkToClipboard,
|
|
255
255
|
busy: isGenerating
|
|
256
256
|
}), isEditDialogOpen && /*#__PURE__*/React.createElement(ShareRestrictionModal, {
|
|
@@ -7,12 +7,14 @@ import omit from 'lodash/omit';
|
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import { useLocation } from 'react-router';
|
|
10
|
+
import flag from 'cozy-flags';
|
|
10
11
|
import EditableSharingModal from './EditableSharingModal';
|
|
11
12
|
import { SharingDetailsModal } from './SharingDetailsModal';
|
|
12
13
|
import withLocales from '../../hoc/withLocales';
|
|
13
14
|
import { useSharingContext } from '../../hooks/useSharingContext';
|
|
15
|
+
import { FederatedFolderModal } from '../FederatedFolder/FederatedFolderModal';
|
|
14
16
|
export var ShareModal = withLocales(function (props) {
|
|
15
|
-
var _location$state;
|
|
17
|
+
var _location$state, _byDocId$document$id;
|
|
16
18
|
|
|
17
19
|
var location = useLocation === null || useLocation === void 0 ? void 0 : useLocation();
|
|
18
20
|
var locationProps = location === null || location === void 0 || (_location$state = location.state) === null || _location$state === void 0 ? void 0 : _location$state.modalProps;
|
|
@@ -30,7 +32,8 @@ export var ShareModal = withLocales(function (props) {
|
|
|
30
32
|
getOwner = _useSharingContext.getOwner,
|
|
31
33
|
getSharingType = _useSharingContext.getSharingType,
|
|
32
34
|
getRecipients = _useSharingContext.getRecipients,
|
|
33
|
-
revokeSelf = _useSharingContext.revokeSelf
|
|
35
|
+
revokeSelf = _useSharingContext.revokeSelf,
|
|
36
|
+
allLoaded = _useSharingContext.allLoaded;
|
|
34
37
|
|
|
35
38
|
var handleRevokeSelf = /*#__PURE__*/function () {
|
|
36
39
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(document) {
|
|
@@ -55,6 +58,19 @@ export var ShareModal = withLocales(function (props) {
|
|
|
55
58
|
};
|
|
56
59
|
}();
|
|
57
60
|
|
|
61
|
+
var isFederatedMode = flag('drive.federated-shared-folder.enabled');
|
|
62
|
+
var hasSharings = ((_byDocId$document$id = byDocId[document.id]) === null || _byDocId$document$id === void 0 || (_byDocId$document$id = _byDocId$document$id.sharings) === null || _byDocId$document$id === void 0 ? void 0 : _byDocId$document$id.length) > 0; // In federated mode, show FederatedFolderModal for unshared documents (sharing an existing folder).
|
|
63
|
+
// When isFederatedMode && hasSharings is true, we intentionally fall through to the legacy
|
|
64
|
+
// modals (EditableSharingModal / SharingDetailsModal) because federated-shared folders are
|
|
65
|
+
// handled by those components.
|
|
66
|
+
|
|
67
|
+
if (isFederatedMode && allLoaded && !hasSharings) {
|
|
68
|
+
return /*#__PURE__*/React.createElement(FederatedFolderModal, {
|
|
69
|
+
document: document,
|
|
70
|
+
onClose: rest.onClose
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
58
74
|
var isEditable = !byDocId[document.id] || isOwner(document.id) || canReshare(document.id);
|
|
59
75
|
|
|
60
76
|
if (isEditable) {
|
|
@@ -24,7 +24,7 @@ export var ShareModal = function ShareModal(_ref) {
|
|
|
24
24
|
sharingDesc = _ref.sharingDesc,
|
|
25
25
|
twoStepsConfirmationMethods = _ref.twoStepsConfirmationMethods;
|
|
26
26
|
|
|
27
|
-
if (isSharedDrive) {
|
|
27
|
+
if (isSharedDrive && !flag('drive.federated-shared-folder.enabled')) {
|
|
28
28
|
return /*#__PURE__*/React.createElement(SharedDriveEditModal, {
|
|
29
29
|
document: document,
|
|
30
30
|
sharing: sharing,
|
|
@@ -23,7 +23,8 @@ var ShareRecipientsInput = function ShareRecipientsInput(_ref) {
|
|
|
23
23
|
recipients = _ref.recipients,
|
|
24
24
|
placeholder = _ref.placeholder,
|
|
25
25
|
onPick = _ref.onPick,
|
|
26
|
-
onRemove = _ref.onRemove
|
|
26
|
+
onRemove = _ref.onRemove,
|
|
27
|
+
disabled = _ref.disabled;
|
|
27
28
|
var reachableContactsQuery = buildReachableContactsQuery();
|
|
28
29
|
var reachableContactsResult = useQueryAll(reachableContactsQuery.definition, reachableContactsQuery.options);
|
|
29
30
|
var unreachableContactsWithGroupsQuery = buildUnreachableContactsWithGroupsQuery();
|
|
@@ -65,6 +66,7 @@ var ShareRecipientsInput = function ShareRecipientsInput(_ref) {
|
|
|
65
66
|
var contactsAndGroups = [].concat(_toConsumableArray(reachableContactsResult.data || []), _toConsumableArray(contactGroups));
|
|
66
67
|
return /*#__PURE__*/React.createElement(ShareAutosuggest, {
|
|
67
68
|
loading: isLoading,
|
|
69
|
+
disabled: disabled,
|
|
68
70
|
contactsAndGroups: contactsAndGroups,
|
|
69
71
|
recipients: recipients,
|
|
70
72
|
onPick: onPick,
|
|
@@ -78,7 +80,8 @@ ShareRecipientsInput.propTypes = {
|
|
|
78
80
|
recipients: PropTypes.array,
|
|
79
81
|
placeholder: PropTypes.string,
|
|
80
82
|
onPick: PropTypes.func.isRequired,
|
|
81
|
-
onRemove: PropTypes.func.isRequired
|
|
83
|
+
onRemove: PropTypes.func.isRequired,
|
|
84
|
+
disabled: PropTypes.bool
|
|
82
85
|
};
|
|
83
86
|
ShareRecipientsInput.defaultProps = {
|
|
84
87
|
currentRecipients: [],
|