cozy-sharing 30.1.0 → 30.2.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 +9 -3
- package/dist/components/FederatedFolder/FederatedFolderModal.js +9 -3
- package/dist/components/ShareByLink.js +100 -46
- package/dist/components/ShareDialogCozyToCozy.js +18 -3
- package/dist/components/ShareDialogOnlyByLink.js +6 -2
- package/dist/components/ShareModal/ShareModal.js +6 -5
- package/dist/components/ShareModal.js +13 -3
- package/dist/components/ShareModal.spec.js +4 -4
- package/dist/components/SharedDrive/DumbSharedDriveModal.js +9 -3
- package/dist/components/SharedDrive/SharedDriveEditModal.js +14 -3
- package/dist/components/SharedFolder/DumbBatchSharedFolderModal.js +12 -4
- package/package.json +3 -3
- package/src/components/FederatedFolder/DumbFederatedFolderModal.jsx +8 -2
- package/src/components/FederatedFolder/FederatedFolderModal.jsx +11 -2
- package/src/components/ShareByLink.jsx +49 -19
- package/src/components/ShareDialogCozyToCozy.jsx +17 -2
- package/src/components/ShareDialogOnlyByLink.jsx +5 -1
- package/src/components/ShareModal/ShareModal.jsx +4 -2
- package/src/components/ShareModal.jsx +10 -0
- package/src/components/ShareModal.spec.js +7 -3
- package/src/components/SharedDrive/DumbSharedDriveModal.jsx +8 -2
- package/src/components/SharedDrive/SharedDriveEditModal.jsx +20 -2
- package/src/components/SharedFolder/DumbBatchSharedFolderModal.jsx +10 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
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
|
+
# [30.2.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@30.1.1...cozy-sharing@30.2.0) (2026-04-20)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **cozy-sharing:** Add props to tune the link sharing flow ([0bfc1b9](https://github.com/cozy/cozy-libs/commit/0bfc1b9d58c3c8ce709c0ab7057e028f012d6924))
|
|
11
|
+
|
|
12
|
+
## [30.1.1](https://github.com/cozy/cozy-libs/compare/cozy-sharing@30.1.0...cozy-sharing@30.1.1) (2026-04-07)
|
|
13
|
+
|
|
14
|
+
**Note:** Version bump only for package cozy-sharing
|
|
15
|
+
|
|
6
16
|
# [30.1.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@30.0.3...cozy-sharing@30.1.0) (2026-04-02)
|
|
7
17
|
|
|
8
18
|
### Features
|
|
@@ -16,7 +16,9 @@ export var DumbFederatedFolderModal = withLocales(function (_ref) {
|
|
|
16
16
|
onClose = _ref.onClose,
|
|
17
17
|
onShare = _ref.onShare,
|
|
18
18
|
sharingLink = _ref.sharingLink,
|
|
19
|
-
showShareByEmail = _ref.showShareByEmail
|
|
19
|
+
showShareByEmail = _ref.showShareByEmail,
|
|
20
|
+
autoOpenShareRestriction = _ref.autoOpenShareRestriction,
|
|
21
|
+
showGenerateLinkButton = _ref.showGenerateLinkButton;
|
|
20
22
|
|
|
21
23
|
var _useI18n = useI18n(),
|
|
22
24
|
t = _useI18n.t;
|
|
@@ -38,7 +40,9 @@ export var DumbFederatedFolderModal = withLocales(function (_ref) {
|
|
|
38
40
|
addPeopleLabel: t('FederatedFolder.addPeople'),
|
|
39
41
|
addButtonLabel: t('FederatedFolder.add'),
|
|
40
42
|
shareLabel: t('FederatedFolder.share'),
|
|
41
|
-
showShareByEmail: showShareByEmail
|
|
43
|
+
showShareByEmail: showShareByEmail,
|
|
44
|
+
autoOpenShareRestriction: autoOpenShareRestriction,
|
|
45
|
+
showGenerateLinkButton: showGenerateLinkButton
|
|
42
46
|
});
|
|
43
47
|
});
|
|
44
48
|
DumbFederatedFolderModal.propTypes = {
|
|
@@ -54,6 +58,8 @@ DumbFederatedFolderModal.propTypes = {
|
|
|
54
58
|
onClose: PropTypes.func.isRequired,
|
|
55
59
|
onShare: PropTypes.func.isRequired,
|
|
56
60
|
sharingLink: PropTypes.string,
|
|
57
|
-
showShareByEmail: PropTypes.bool
|
|
61
|
+
showShareByEmail: PropTypes.bool,
|
|
62
|
+
autoOpenShareRestriction: PropTypes.bool,
|
|
63
|
+
showGenerateLinkButton: PropTypes.bool
|
|
58
64
|
};
|
|
59
65
|
export default DumbFederatedFolderModal;
|
|
@@ -13,7 +13,9 @@ import { useSharingContext } from '../../hooks/useSharingContext';
|
|
|
13
13
|
import { formatRecipients, mergeAndDeduplicateRecipients, moveRecipientToReadWrite, moveRecipientToReadOnly, RECIPIENT_INDEX_PREFIX } from '../SharedDrive/helpers';
|
|
14
14
|
export var FederatedFolderModal = withLocales(function (_ref) {
|
|
15
15
|
var onClose = _ref.onClose,
|
|
16
|
-
existingDocument = _ref.document
|
|
16
|
+
existingDocument = _ref.document,
|
|
17
|
+
autoOpenShareRestriction = _ref.autoOpenShareRestriction,
|
|
18
|
+
showGenerateLinkButton = _ref.showGenerateLinkButton;
|
|
17
19
|
var client = useClient();
|
|
18
20
|
|
|
19
21
|
var _useI18n = useI18n(),
|
|
@@ -230,11 +232,15 @@ export var FederatedFolderModal = withLocales(function (_ref) {
|
|
|
230
232
|
onClose: onClose,
|
|
231
233
|
onShare: onShare,
|
|
232
234
|
sharingLink: sharingLink,
|
|
233
|
-
showShareByEmail: !isSharedDrive
|
|
235
|
+
showShareByEmail: !isSharedDrive,
|
|
236
|
+
autoOpenShareRestriction: autoOpenShareRestriction,
|
|
237
|
+
showGenerateLinkButton: showGenerateLinkButton
|
|
234
238
|
});
|
|
235
239
|
});
|
|
236
240
|
FederatedFolderModal.propTypes = {
|
|
237
241
|
onClose: PropTypes.func.isRequired,
|
|
238
|
-
document: PropTypes.object.isRequired
|
|
242
|
+
document: PropTypes.object.isRequired,
|
|
243
|
+
autoOpenShareRestriction: PropTypes.bool,
|
|
244
|
+
showGenerateLinkButton: PropTypes.bool
|
|
239
245
|
};
|
|
240
246
|
export default FederatedFolderModal;
|
|
@@ -21,7 +21,11 @@ var ShareByLink = function ShareByLink(_ref) {
|
|
|
21
21
|
|
|
22
22
|
var link = _ref.link,
|
|
23
23
|
document = _ref.document,
|
|
24
|
-
documentType = _ref.documentType
|
|
24
|
+
documentType = _ref.documentType,
|
|
25
|
+
_ref$showGenerateLink = _ref.showGenerateLinkButton,
|
|
26
|
+
showGenerateLinkButton = _ref$showGenerateLink === void 0 ? false : _ref$showGenerateLink,
|
|
27
|
+
_ref$autoOpenShareRes = _ref.autoOpenShareRestriction,
|
|
28
|
+
autoOpenShareRestriction = _ref$autoOpenShareRes === void 0 ? false : _ref$autoOpenShareRes;
|
|
25
29
|
|
|
26
30
|
var _useI18n = useI18n(),
|
|
27
31
|
t = _useI18n.t;
|
|
@@ -45,8 +49,9 @@ var ShareByLink = function ShareByLink(_ref) {
|
|
|
45
49
|
setIsGenerating = _useState2[1];
|
|
46
50
|
|
|
47
51
|
var canShare = typeof ((_navigator = navigator) === null || _navigator === void 0 ? void 0 : _navigator.share) === 'function';
|
|
48
|
-
var
|
|
49
|
-
var
|
|
52
|
+
var showGenerateButton = showGenerateLinkButton && !link;
|
|
53
|
+
var showCopyAndSendButtons = !showGenerateButton && isMobile && canShare;
|
|
54
|
+
var showOnlyCopyButton = !showGenerateButton && (!isMobile || !canShare);
|
|
50
55
|
var isFederated = flag('drive.federated-shared-folder.enabled');
|
|
51
56
|
|
|
52
57
|
var _useReducer = useReducer(function (state) {
|
|
@@ -56,6 +61,14 @@ var ShareByLink = function ShareByLink(_ref) {
|
|
|
56
61
|
isEditDialogOpen = _useReducer2[0],
|
|
57
62
|
toggleEditDialogOpen = _useReducer2[1];
|
|
58
63
|
|
|
64
|
+
var showGenericError = function showGenericError() {
|
|
65
|
+
showAlert({
|
|
66
|
+
message: t("".concat(documentType, ".share.error.generic")),
|
|
67
|
+
severity: 'error',
|
|
68
|
+
variant: 'filled'
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
|
|
59
72
|
var handleGenerateLink = /*#__PURE__*/function () {
|
|
60
73
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
61
74
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
@@ -105,47 +118,48 @@ var ShareByLink = function ShareByLink(_ref) {
|
|
|
105
118
|
|
|
106
119
|
var generateLinkAndCopyLinkToClipboard = /*#__PURE__*/function () {
|
|
107
120
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
108
|
-
var linkToCopy;
|
|
121
|
+
var linkToCopy, wasNewlyGenerated;
|
|
109
122
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
110
123
|
while (1) switch (_context2.prev = _context2.next) {
|
|
111
124
|
case 0:
|
|
112
125
|
linkToCopy = link;
|
|
126
|
+
wasNewlyGenerated = !linkToCopy;
|
|
113
127
|
|
|
114
128
|
if (linkToCopy) {
|
|
115
|
-
_context2.next =
|
|
129
|
+
_context2.next = 6;
|
|
116
130
|
break;
|
|
117
131
|
}
|
|
118
132
|
|
|
119
|
-
_context2.next =
|
|
133
|
+
_context2.next = 5;
|
|
120
134
|
return handleGenerateLink();
|
|
121
135
|
|
|
122
|
-
case
|
|
136
|
+
case 5:
|
|
123
137
|
linkToCopy = _context2.sent;
|
|
124
138
|
|
|
125
|
-
case
|
|
139
|
+
case 6:
|
|
126
140
|
if (!linkToCopy) {
|
|
127
|
-
_context2.next =
|
|
141
|
+
_context2.next = 12;
|
|
128
142
|
break;
|
|
129
143
|
}
|
|
130
144
|
|
|
131
|
-
_context2.next =
|
|
145
|
+
_context2.next = 9;
|
|
132
146
|
return copyToClipboard(linkToCopy, {
|
|
133
147
|
t: t,
|
|
134
148
|
showAlert: showAlert
|
|
135
149
|
});
|
|
136
150
|
|
|
137
|
-
case
|
|
138
|
-
|
|
151
|
+
case 9:
|
|
152
|
+
if (wasNewlyGenerated && autoOpenShareRestriction) {
|
|
153
|
+
toggleEditDialogOpen();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
_context2.next = 13;
|
|
139
157
|
break;
|
|
140
158
|
|
|
141
|
-
case
|
|
142
|
-
|
|
143
|
-
message: t("".concat(documentType, ".share.error.generic")),
|
|
144
|
-
severity: 'error',
|
|
145
|
-
variant: 'filled'
|
|
146
|
-
});
|
|
159
|
+
case 12:
|
|
160
|
+
showGenericError();
|
|
147
161
|
|
|
148
|
-
case
|
|
162
|
+
case 13:
|
|
149
163
|
case "end":
|
|
150
164
|
return _context2.stop();
|
|
151
165
|
}
|
|
@@ -157,75 +171,104 @@ var ShareByLink = function ShareByLink(_ref) {
|
|
|
157
171
|
};
|
|
158
172
|
}();
|
|
159
173
|
|
|
160
|
-
var
|
|
174
|
+
var generateLinkSilently = /*#__PURE__*/function () {
|
|
161
175
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
162
|
-
var
|
|
176
|
+
var generated;
|
|
163
177
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
164
178
|
while (1) switch (_context3.prev = _context3.next) {
|
|
179
|
+
case 0:
|
|
180
|
+
_context3.next = 2;
|
|
181
|
+
return handleGenerateLink();
|
|
182
|
+
|
|
183
|
+
case 2:
|
|
184
|
+
generated = _context3.sent;
|
|
185
|
+
|
|
186
|
+
if (generated) {
|
|
187
|
+
_context3.next = 6;
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
showGenericError();
|
|
192
|
+
return _context3.abrupt("return");
|
|
193
|
+
|
|
194
|
+
case 6:
|
|
195
|
+
if (autoOpenShareRestriction) {
|
|
196
|
+
toggleEditDialogOpen();
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
case 7:
|
|
200
|
+
case "end":
|
|
201
|
+
return _context3.stop();
|
|
202
|
+
}
|
|
203
|
+
}, _callee3);
|
|
204
|
+
}));
|
|
205
|
+
|
|
206
|
+
return function generateLinkSilently() {
|
|
207
|
+
return _ref4.apply(this, arguments);
|
|
208
|
+
};
|
|
209
|
+
}();
|
|
210
|
+
|
|
211
|
+
var shareLink = /*#__PURE__*/function () {
|
|
212
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
213
|
+
var linkToShare, shareData;
|
|
214
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
215
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
165
216
|
case 0:
|
|
166
217
|
linkToShare = link;
|
|
167
218
|
|
|
168
219
|
if (linkToShare) {
|
|
169
|
-
|
|
220
|
+
_context4.next = 5;
|
|
170
221
|
break;
|
|
171
222
|
}
|
|
172
223
|
|
|
173
|
-
|
|
224
|
+
_context4.next = 4;
|
|
174
225
|
return handleGenerateLink();
|
|
175
226
|
|
|
176
227
|
case 4:
|
|
177
|
-
linkToShare =
|
|
228
|
+
linkToShare = _context4.sent;
|
|
178
229
|
|
|
179
230
|
case 5:
|
|
180
231
|
if (linkToShare) {
|
|
181
|
-
|
|
232
|
+
_context4.next = 8;
|
|
182
233
|
break;
|
|
183
234
|
}
|
|
184
235
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
severity: 'error',
|
|
188
|
-
variant: 'filled'
|
|
189
|
-
});
|
|
190
|
-
return _context3.abrupt("return");
|
|
236
|
+
showGenericError();
|
|
237
|
+
return _context4.abrupt("return");
|
|
191
238
|
|
|
192
239
|
case 8:
|
|
193
|
-
|
|
240
|
+
_context4.prev = 8;
|
|
194
241
|
shareData = {
|
|
195
242
|
text: t("".concat(documentType, ".share.shareByLink.shareDescription"), {
|
|
196
243
|
name: document.name || ''
|
|
197
244
|
}),
|
|
198
245
|
url: linkToShare
|
|
199
246
|
};
|
|
200
|
-
|
|
247
|
+
_context4.next = 12;
|
|
201
248
|
return navigator.share(shareData);
|
|
202
249
|
|
|
203
250
|
case 12:
|
|
204
|
-
|
|
251
|
+
_context4.next = 17;
|
|
205
252
|
break;
|
|
206
253
|
|
|
207
254
|
case 14:
|
|
208
|
-
|
|
209
|
-
|
|
255
|
+
_context4.prev = 14;
|
|
256
|
+
_context4.t0 = _context4["catch"](8);
|
|
210
257
|
|
|
211
258
|
// Don't show error when user cancels the share dialog
|
|
212
|
-
if (
|
|
213
|
-
|
|
214
|
-
message: t("".concat(documentType, ".share.error.generic")),
|
|
215
|
-
severity: 'error',
|
|
216
|
-
variant: 'filled'
|
|
217
|
-
});
|
|
259
|
+
if (_context4.t0.name !== 'AbortError') {
|
|
260
|
+
showGenericError();
|
|
218
261
|
}
|
|
219
262
|
|
|
220
263
|
case 17:
|
|
221
264
|
case "end":
|
|
222
|
-
return
|
|
265
|
+
return _context4.stop();
|
|
223
266
|
}
|
|
224
|
-
},
|
|
267
|
+
}, _callee4, null, [[8, 14]]);
|
|
225
268
|
}));
|
|
226
269
|
|
|
227
270
|
return function shareLink() {
|
|
228
|
-
return
|
|
271
|
+
return _ref5.apply(this, arguments);
|
|
229
272
|
};
|
|
230
273
|
}();
|
|
231
274
|
|
|
@@ -257,6 +300,15 @@ var ShareByLink = function ShareByLink(_ref) {
|
|
|
257
300
|
}),
|
|
258
301
|
onClick: generateLinkAndCopyLinkToClipboard,
|
|
259
302
|
busy: isGenerating
|
|
303
|
+
}), showGenerateButton && /*#__PURE__*/React.createElement(Button, {
|
|
304
|
+
label: t("".concat(documentType, ".share.shareByLink.create")),
|
|
305
|
+
variant: "secondary",
|
|
306
|
+
size: "medium",
|
|
307
|
+
startIcon: /*#__PURE__*/React.createElement(Icon, {
|
|
308
|
+
icon: LinkIcon
|
|
309
|
+
}),
|
|
310
|
+
onClick: generateLinkSilently,
|
|
311
|
+
busy: isGenerating
|
|
260
312
|
}), isEditDialogOpen && /*#__PURE__*/React.createElement(ShareRestrictionModal, {
|
|
261
313
|
file: document,
|
|
262
314
|
onClose: toggleEditDialogOpen
|
|
@@ -266,6 +318,8 @@ var ShareByLink = function ShareByLink(_ref) {
|
|
|
266
318
|
ShareByLink.propTypes = {
|
|
267
319
|
link: PropTypes.string,
|
|
268
320
|
document: PropTypes.object.isRequired,
|
|
269
|
-
documentType: PropTypes.string.isRequired
|
|
321
|
+
documentType: PropTypes.string.isRequired,
|
|
322
|
+
showGenerateLinkButton: PropTypes.bool,
|
|
323
|
+
autoOpenShareRestriction: PropTypes.bool
|
|
270
324
|
};
|
|
271
325
|
export default ShareByLink;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["showShareByLink", "documentType", "document"];
|
|
3
|
+
var _excluded = ["showShareByLink", "showGenerateLinkButton", "autoOpenShareRestriction", "documentType", "document"];
|
|
4
4
|
import cx from 'classnames';
|
|
5
|
-
import React from 'react';
|
|
5
|
+
import React, { useMemo } from 'react';
|
|
6
6
|
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
7
7
|
import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints';
|
|
8
8
|
import { useI18n } from 'twake-i18n';
|
|
@@ -125,15 +125,30 @@ var SharingTitleFunction = function SharingTitleFunction(_ref2) {
|
|
|
125
125
|
|
|
126
126
|
var ShareDialogCozyToCozy = function ShareDialogCozyToCozy(_ref3) {
|
|
127
127
|
var showShareByLink = _ref3.showShareByLink,
|
|
128
|
+
showGenerateLinkButton = _ref3.showGenerateLinkButton,
|
|
129
|
+
autoOpenShareRestriction = _ref3.autoOpenShareRestriction,
|
|
128
130
|
documentType = _ref3.documentType,
|
|
129
131
|
document = _ref3.document,
|
|
130
132
|
props = _objectWithoutProperties(_ref3, _excluded);
|
|
131
133
|
|
|
134
|
+
var dialogActionsOnShare = useMemo(function () {
|
|
135
|
+
if (!showShareByLink) return null;
|
|
136
|
+
|
|
137
|
+
var BoundShareByLink = function BoundShareByLink(dialogActionProps) {
|
|
138
|
+
return /*#__PURE__*/React.createElement(DumbShareByLink, _extends({}, dialogActionProps, {
|
|
139
|
+
showGenerateLinkButton: showGenerateLinkButton,
|
|
140
|
+
autoOpenShareRestriction: autoOpenShareRestriction
|
|
141
|
+
}));
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
BoundShareByLink.displayName = 'BoundShareByLink';
|
|
145
|
+
return BoundShareByLink;
|
|
146
|
+
}, [showShareByLink, showGenerateLinkButton, autoOpenShareRestriction]);
|
|
132
147
|
return /*#__PURE__*/React.createElement(ShareDialogTwoStepsConfirmationContainer, _extends({}, props, {
|
|
133
148
|
documentType: documentType,
|
|
134
149
|
document: document,
|
|
135
150
|
dialogContentOnShare: SharingContent,
|
|
136
|
-
dialogActionsOnShare:
|
|
151
|
+
dialogActionsOnShare: dialogActionsOnShare,
|
|
137
152
|
dialogTitleOnShare: SharingTitleFunction({
|
|
138
153
|
documentType: documentType,
|
|
139
154
|
document: document
|
|
@@ -17,7 +17,9 @@ var ShareDialogOnlyByLink = function ShareDialogOnlyByLink(_ref) {
|
|
|
17
17
|
documentType = _ref.documentType,
|
|
18
18
|
link = _ref.link,
|
|
19
19
|
onClose = _ref.onClose,
|
|
20
|
-
permissions = _ref.permissions
|
|
20
|
+
permissions = _ref.permissions,
|
|
21
|
+
showGenerateLinkButton = _ref.showGenerateLinkButton,
|
|
22
|
+
autoOpenShareRestriction = _ref.autoOpenShareRestriction;
|
|
21
23
|
|
|
22
24
|
var _useI18n = useI18n(),
|
|
23
25
|
t = _useI18n.t;
|
|
@@ -52,7 +54,9 @@ var ShareDialogOnlyByLink = function ShareDialogOnlyByLink(_ref) {
|
|
|
52
54
|
}, /*#__PURE__*/React.createElement(DumbShareByLink, {
|
|
53
55
|
link: link,
|
|
54
56
|
document: document,
|
|
55
|
-
documentType: documentType
|
|
57
|
+
documentType: documentType,
|
|
58
|
+
showGenerateLinkButton: showGenerateLinkButton,
|
|
59
|
+
autoOpenShareRestriction: autoOpenShareRestriction
|
|
56
60
|
})))
|
|
57
61
|
});
|
|
58
62
|
};
|
|
@@ -61,10 +61,9 @@ export var ShareModal = withLocales(function (props) {
|
|
|
61
61
|
var isFederatedMode = flag('drive.federated-shared-folder.enabled');
|
|
62
62
|
|
|
63
63
|
if (isFederatedMode && allLoaded) {
|
|
64
|
-
return /*#__PURE__*/React.createElement(FederatedFolderModal, {
|
|
65
|
-
document: document
|
|
66
|
-
|
|
67
|
-
});
|
|
64
|
+
return /*#__PURE__*/React.createElement(FederatedFolderModal, _extends({
|
|
65
|
+
document: document
|
|
66
|
+
}, rest));
|
|
68
67
|
}
|
|
69
68
|
|
|
70
69
|
var isEditable = !byDocId[document.id] || isOwner(document.id) || canReshare(document.id);
|
|
@@ -86,6 +85,8 @@ export var ShareModal = withLocales(function (props) {
|
|
|
86
85
|
}, rest));
|
|
87
86
|
});
|
|
88
87
|
ShareModal.propTypes = {
|
|
88
|
+
autoOpenShareRestriction: PropTypes.bool,
|
|
89
89
|
document: PropTypes.object.isRequired,
|
|
90
|
-
onRevokeSuccess: PropTypes.func
|
|
90
|
+
onRevokeSuccess: PropTypes.func,
|
|
91
|
+
showGenerateLinkButton: PropTypes.bool
|
|
91
92
|
};
|
|
@@ -5,7 +5,8 @@ import ShareDialogCozyToCozy from './ShareDialogCozyToCozy';
|
|
|
5
5
|
import ShareDialogOnlyByLink from './ShareDialogOnlyByLink';
|
|
6
6
|
import { SharedDriveEditModal } from './SharedDrive/SharedDriveEditModal';
|
|
7
7
|
export var ShareModal = function ShareModal(_ref) {
|
|
8
|
-
var
|
|
8
|
+
var autoOpenShareRestriction = _ref.autoOpenShareRestriction,
|
|
9
|
+
createContact = _ref.createContact,
|
|
9
10
|
document = _ref.document,
|
|
10
11
|
_ref$documentType = _ref.documentType,
|
|
11
12
|
documentType = _ref$documentType === void 0 ? 'Document' : _ref$documentType,
|
|
@@ -22,6 +23,7 @@ export var ShareModal = function ShareModal(_ref) {
|
|
|
22
23
|
recipients = _ref.recipients,
|
|
23
24
|
sharing = _ref.sharing,
|
|
24
25
|
sharingDesc = _ref.sharingDesc,
|
|
26
|
+
showGenerateLinkButton = _ref.showGenerateLinkButton,
|
|
25
27
|
twoStepsConfirmationMethods = _ref.twoStepsConfirmationMethods;
|
|
26
28
|
|
|
27
29
|
if (isSharedDrive && !flag('drive.federated-shared-folder.enabled')) {
|
|
@@ -31,7 +33,9 @@ export var ShareModal = function ShareModal(_ref) {
|
|
|
31
33
|
recipients: recipients,
|
|
32
34
|
onShare: onShare,
|
|
33
35
|
onRevoke: onRevoke,
|
|
34
|
-
onClose: onClose
|
|
36
|
+
onClose: onClose,
|
|
37
|
+
autoOpenShareRestriction: autoOpenShareRestriction,
|
|
38
|
+
showGenerateLinkButton: showGenerateLinkButton
|
|
35
39
|
});
|
|
36
40
|
}
|
|
37
41
|
|
|
@@ -49,7 +53,9 @@ export var ShareModal = function ShareModal(_ref) {
|
|
|
49
53
|
documentType: documentType,
|
|
50
54
|
link: link,
|
|
51
55
|
onClose: onClose,
|
|
52
|
-
permissions: permissions
|
|
56
|
+
permissions: permissions,
|
|
57
|
+
showGenerateLinkButton: showGenerateLinkButton,
|
|
58
|
+
autoOpenShareRestriction: autoOpenShareRestriction
|
|
53
59
|
}) : /*#__PURE__*/React.createElement(ShareDialogCozyToCozy, {
|
|
54
60
|
createContact: createContact,
|
|
55
61
|
document: document,
|
|
@@ -69,11 +75,14 @@ export var ShareModal = function ShareModal(_ref) {
|
|
|
69
75
|
showShareByLink: showShareByLink,
|
|
70
76
|
showShareOnlyByLink: showShareOnlyByLink,
|
|
71
77
|
showWhoHasAccess: showWhoHasAccess,
|
|
78
|
+
showGenerateLinkButton: showGenerateLinkButton,
|
|
79
|
+
autoOpenShareRestriction: autoOpenShareRestriction,
|
|
72
80
|
twoStepsConfirmationMethods: twoStepsConfirmationMethods
|
|
73
81
|
});
|
|
74
82
|
};
|
|
75
83
|
export default ShareModal;
|
|
76
84
|
ShareModal.propTypes = {
|
|
85
|
+
autoOpenShareRestriction: PropTypes.bool,
|
|
77
86
|
createContact: PropTypes.func.isRequired,
|
|
78
87
|
document: PropTypes.object.isRequired,
|
|
79
88
|
documentType: PropTypes.string,
|
|
@@ -87,6 +96,7 @@ ShareModal.propTypes = {
|
|
|
87
96
|
permissions: PropTypes.array.isRequired,
|
|
88
97
|
recipients: PropTypes.array.isRequired,
|
|
89
98
|
sharingDesc: PropTypes.string,
|
|
99
|
+
showGenerateLinkButton: PropTypes.bool,
|
|
90
100
|
twoStepsConfirmationMethods: PropTypes.shape({
|
|
91
101
|
getRecipientsToBeConfirmed: PropTypes.func,
|
|
92
102
|
confirmRecipient: PropTypes.func,
|
|
@@ -5,12 +5,12 @@ import { ShareModal } from './ShareModal';
|
|
|
5
5
|
import AppLike from '../../test/AppLike';
|
|
6
6
|
jest.mock('./ShareDialogCozyToCozy', function () {
|
|
7
7
|
return function () {
|
|
8
|
-
return /*#__PURE__*/React.createElement(
|
|
8
|
+
return /*#__PURE__*/React.createElement("div", null, "ShareDialogCozyToCozy");
|
|
9
9
|
};
|
|
10
10
|
});
|
|
11
11
|
jest.mock('./ShareDialogOnlyByLink', function () {
|
|
12
12
|
return function () {
|
|
13
|
-
return /*#__PURE__*/React.createElement(
|
|
13
|
+
return /*#__PURE__*/React.createElement("div", null, "ShareDialogOnlyByLink");
|
|
14
14
|
};
|
|
15
15
|
});
|
|
16
16
|
jest.mock('cozy-flags');
|
|
@@ -43,8 +43,8 @@ describe('ShareModal component', function () {
|
|
|
43
43
|
expect(root.getByText('ShareDialogCozyToCozy'));
|
|
44
44
|
});
|
|
45
45
|
it('should render ShareDialogOnlyByLink if flag cozy.hide-sharing-cozy-to-cozy is true', function () {
|
|
46
|
-
flag.mockImplementation(function () {
|
|
47
|
-
return
|
|
46
|
+
flag.mockImplementation(function (name) {
|
|
47
|
+
return name === 'cozy.hide-sharing-cozy-to-cozy';
|
|
48
48
|
});
|
|
49
49
|
var root = setup({
|
|
50
50
|
documentType: 'Document'
|
|
@@ -20,7 +20,9 @@ export var DumbSharedDriveModal = withLocales(function (_ref) {
|
|
|
20
20
|
onRename = _ref.onRename,
|
|
21
21
|
_ref$showNameField = _ref.showNameField,
|
|
22
22
|
showNameField = _ref$showNameField === void 0 ? true : _ref$showNameField,
|
|
23
|
-
sharingLink = _ref.sharingLink
|
|
23
|
+
sharingLink = _ref.sharingLink,
|
|
24
|
+
autoOpenShareRestriction = _ref.autoOpenShareRestriction,
|
|
25
|
+
showGenerateLinkButton = _ref.showGenerateLinkButton;
|
|
24
26
|
|
|
25
27
|
var _useI18n = useI18n(),
|
|
26
28
|
t = _useI18n.t;
|
|
@@ -48,7 +50,9 @@ export var DumbSharedDriveModal = withLocales(function (_ref) {
|
|
|
48
50
|
cancelLabel: t('SharedDrive.sharedDriveModal.cancel'),
|
|
49
51
|
createLabel: t('SharedDrive.sharedDriveModal.create'),
|
|
50
52
|
shareLabel: t('FederatedFolder.share'),
|
|
51
|
-
saveLabel: t('SharedDrive.sharedDriveModal.save')
|
|
53
|
+
saveLabel: t('SharedDrive.sharedDriveModal.save'),
|
|
54
|
+
autoOpenShareRestriction: autoOpenShareRestriction,
|
|
55
|
+
showGenerateLinkButton: showGenerateLinkButton
|
|
52
56
|
});
|
|
53
57
|
});
|
|
54
58
|
DumbSharedDriveModal.propTypes = {
|
|
@@ -67,6 +71,8 @@ DumbSharedDriveModal.propTypes = {
|
|
|
67
71
|
onShare: PropTypes.func.isRequired,
|
|
68
72
|
onRename: PropTypes.func,
|
|
69
73
|
showNameField: PropTypes.bool,
|
|
70
|
-
sharingLink: PropTypes.string
|
|
74
|
+
sharingLink: PropTypes.string,
|
|
75
|
+
autoOpenShareRestriction: PropTypes.bool,
|
|
76
|
+
showGenerateLinkButton: PropTypes.bool
|
|
71
77
|
};
|
|
72
78
|
export default DumbSharedDriveModal;
|
|
@@ -16,7 +16,9 @@ export var SharedDriveEditModal = withLocales(function (_ref) {
|
|
|
16
16
|
recipients = _ref.recipients,
|
|
17
17
|
onShare = _ref.onShare,
|
|
18
18
|
onRevoke = _ref.onRevoke,
|
|
19
|
-
onClose = _ref.onClose
|
|
19
|
+
onClose = _ref.onClose,
|
|
20
|
+
autoOpenShareRestriction = _ref.autoOpenShareRestriction,
|
|
21
|
+
showGenerateLinkButton = _ref.showGenerateLinkButton;
|
|
20
22
|
var client = useClient();
|
|
21
23
|
|
|
22
24
|
var _useI18n = useI18n(),
|
|
@@ -91,9 +93,18 @@ export var SharedDriveEditModal = withLocales(function (_ref) {
|
|
|
91
93
|
onShare: onShare,
|
|
92
94
|
sharedDriveName: name,
|
|
93
95
|
handleSharedDriveNameChange: handleNameChange,
|
|
94
|
-
onRename: onRename
|
|
96
|
+
onRename: onRename,
|
|
97
|
+
autoOpenShareRestriction: autoOpenShareRestriction,
|
|
98
|
+
showGenerateLinkButton: showGenerateLinkButton
|
|
95
99
|
});
|
|
96
100
|
});
|
|
97
101
|
SharedDriveEditModal.propTypes = {
|
|
98
|
-
|
|
102
|
+
document: PropTypes.object,
|
|
103
|
+
sharing: PropTypes.object,
|
|
104
|
+
recipients: PropTypes.array,
|
|
105
|
+
onShare: PropTypes.func.isRequired,
|
|
106
|
+
onRevoke: PropTypes.func.isRequired,
|
|
107
|
+
onClose: PropTypes.func.isRequired,
|
|
108
|
+
autoOpenShareRestriction: PropTypes.bool,
|
|
109
|
+
showGenerateLinkButton: PropTypes.bool
|
|
99
110
|
};
|
|
@@ -36,7 +36,9 @@ export var DumbBatchSharedFolderModal = withLocales(function (_ref) {
|
|
|
36
36
|
saveLabel = _ref.saveLabel,
|
|
37
37
|
sharingDesc = _ref.sharingDesc,
|
|
38
38
|
_ref$showShareByEmail = _ref.showShareByEmail,
|
|
39
|
-
showShareByEmail = _ref$showShareByEmail === void 0 ? true : _ref$showShareByEmail
|
|
39
|
+
showShareByEmail = _ref$showShareByEmail === void 0 ? true : _ref$showShareByEmail,
|
|
40
|
+
autoOpenShareRestriction = _ref.autoOpenShareRestriction,
|
|
41
|
+
showGenerateLinkButton = _ref.showGenerateLinkButton;
|
|
40
42
|
var hasRecipients = Boolean(recipients === null || recipients === void 0 ? void 0 : recipients.length); // Determine action buttons based on modal mode
|
|
41
43
|
|
|
42
44
|
var actionButtons = function () {
|
|
@@ -56,7 +58,9 @@ export var DumbBatchSharedFolderModal = withLocales(function (_ref) {
|
|
|
56
58
|
return /*#__PURE__*/React.createElement(ShareByLink, {
|
|
57
59
|
link: sharingLink,
|
|
58
60
|
document: document,
|
|
59
|
-
documentType: "Files"
|
|
61
|
+
documentType: "Files",
|
|
62
|
+
showGenerateLinkButton: showGenerateLinkButton,
|
|
63
|
+
autoOpenShareRestriction: autoOpenShareRestriction
|
|
60
64
|
});
|
|
61
65
|
}
|
|
62
66
|
|
|
@@ -64,7 +68,9 @@ export var DumbBatchSharedFolderModal = withLocales(function (_ref) {
|
|
|
64
68
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ShareByLink, {
|
|
65
69
|
link: sharingLink,
|
|
66
70
|
document: document,
|
|
67
|
-
documentType: "Files"
|
|
71
|
+
documentType: "Files",
|
|
72
|
+
showGenerateLinkButton: showGenerateLinkButton,
|
|
73
|
+
autoOpenShareRestriction: autoOpenShareRestriction
|
|
68
74
|
}), /*#__PURE__*/React.createElement(Button, {
|
|
69
75
|
variant: "primary",
|
|
70
76
|
label: shareLabel,
|
|
@@ -165,7 +171,9 @@ DumbBatchSharedFolderModal.propTypes = {
|
|
|
165
171
|
shareLabel: PropTypes.string,
|
|
166
172
|
saveLabel: PropTypes.string,
|
|
167
173
|
sharingDesc: PropTypes.string,
|
|
168
|
-
showShareByEmail: PropTypes.bool
|
|
174
|
+
showShareByEmail: PropTypes.bool,
|
|
175
|
+
autoOpenShareRestriction: PropTypes.bool,
|
|
176
|
+
showGenerateLinkButton: PropTypes.bool
|
|
169
177
|
};
|
|
170
178
|
DumbBatchSharedFolderModal.defaultProps = {
|
|
171
179
|
sharingDesc: ''
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-sharing",
|
|
3
|
-
"version": "30.
|
|
3
|
+
"version": "30.2.0",
|
|
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": "^138.1.0",
|
|
62
|
-
"cozy-ui-plus": "^
|
|
62
|
+
"cozy-ui-plus": "^7.0.0",
|
|
63
63
|
"jest": "30.3.0",
|
|
64
64
|
"jest-environment-jsdom": "30.3.0",
|
|
65
65
|
"react": "16.12.0",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"sideEffects": [
|
|
85
85
|
"*.css"
|
|
86
86
|
],
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "b8142134f35abde2f7c32aa2109f5f5b111505c9"
|
|
88
88
|
}
|
|
@@ -20,7 +20,9 @@ export const DumbFederatedFolderModal = withLocales(
|
|
|
20
20
|
onClose,
|
|
21
21
|
onShare,
|
|
22
22
|
sharingLink,
|
|
23
|
-
showShareByEmail
|
|
23
|
+
showShareByEmail,
|
|
24
|
+
autoOpenShareRestriction,
|
|
25
|
+
showGenerateLinkButton
|
|
24
26
|
}) => {
|
|
25
27
|
const { t } = useI18n()
|
|
26
28
|
return (
|
|
@@ -42,6 +44,8 @@ export const DumbFederatedFolderModal = withLocales(
|
|
|
42
44
|
addButtonLabel={t('FederatedFolder.add')}
|
|
43
45
|
shareLabel={t('FederatedFolder.share')}
|
|
44
46
|
showShareByEmail={showShareByEmail}
|
|
47
|
+
autoOpenShareRestriction={autoOpenShareRestriction}
|
|
48
|
+
showGenerateLinkButton={showGenerateLinkButton}
|
|
45
49
|
/>
|
|
46
50
|
)
|
|
47
51
|
}
|
|
@@ -60,7 +64,9 @@ DumbFederatedFolderModal.propTypes = {
|
|
|
60
64
|
onClose: PropTypes.func.isRequired,
|
|
61
65
|
onShare: PropTypes.func.isRequired,
|
|
62
66
|
sharingLink: PropTypes.string,
|
|
63
|
-
showShareByEmail: PropTypes.bool
|
|
67
|
+
showShareByEmail: PropTypes.bool,
|
|
68
|
+
autoOpenShareRestriction: PropTypes.bool,
|
|
69
|
+
showGenerateLinkButton: PropTypes.bool
|
|
64
70
|
}
|
|
65
71
|
|
|
66
72
|
export default DumbFederatedFolderModal
|
|
@@ -17,7 +17,12 @@ import {
|
|
|
17
17
|
} from '../SharedDrive/helpers'
|
|
18
18
|
|
|
19
19
|
export const FederatedFolderModal = withLocales(
|
|
20
|
-
({
|
|
20
|
+
({
|
|
21
|
+
onClose,
|
|
22
|
+
document: existingDocument,
|
|
23
|
+
autoOpenShareRestriction,
|
|
24
|
+
showGenerateLinkButton
|
|
25
|
+
}) => {
|
|
21
26
|
const client = useClient()
|
|
22
27
|
const { t } = useI18n()
|
|
23
28
|
const {
|
|
@@ -159,6 +164,8 @@ export const FederatedFolderModal = withLocales(
|
|
|
159
164
|
onShare={onShare}
|
|
160
165
|
sharingLink={sharingLink}
|
|
161
166
|
showShareByEmail={!isSharedDrive}
|
|
167
|
+
autoOpenShareRestriction={autoOpenShareRestriction}
|
|
168
|
+
showGenerateLinkButton={showGenerateLinkButton}
|
|
162
169
|
/>
|
|
163
170
|
)
|
|
164
171
|
}
|
|
@@ -166,7 +173,9 @@ export const FederatedFolderModal = withLocales(
|
|
|
166
173
|
|
|
167
174
|
FederatedFolderModal.propTypes = {
|
|
168
175
|
onClose: PropTypes.func.isRequired,
|
|
169
|
-
document: PropTypes.object.isRequired
|
|
176
|
+
document: PropTypes.object.isRequired,
|
|
177
|
+
autoOpenShareRestriction: PropTypes.bool,
|
|
178
|
+
showGenerateLinkButton: PropTypes.bool
|
|
170
179
|
}
|
|
171
180
|
|
|
172
181
|
export default FederatedFolderModal
|
|
@@ -18,7 +18,13 @@ import {
|
|
|
18
18
|
} from './ShareRestrictionModal/helpers'
|
|
19
19
|
import { useSharingContext } from '../hooks/useSharingContext'
|
|
20
20
|
|
|
21
|
-
const ShareByLink = ({
|
|
21
|
+
const ShareByLink = ({
|
|
22
|
+
link,
|
|
23
|
+
document,
|
|
24
|
+
documentType,
|
|
25
|
+
showGenerateLinkButton = false,
|
|
26
|
+
autoOpenShareRestriction = false
|
|
27
|
+
}) => {
|
|
22
28
|
const { t } = useI18n()
|
|
23
29
|
const { isMobile } = useBreakpoints()
|
|
24
30
|
const { showAlert } = useAlert()
|
|
@@ -27,8 +33,9 @@ const ShareByLink = ({ link, document, documentType }) => {
|
|
|
27
33
|
const [isGenerating, setIsGenerating] = useState(false)
|
|
28
34
|
|
|
29
35
|
const canShare = typeof navigator?.share === 'function'
|
|
30
|
-
const
|
|
31
|
-
const
|
|
36
|
+
const showGenerateButton = showGenerateLinkButton && !link
|
|
37
|
+
const showCopyAndSendButtons = !showGenerateButton && isMobile && canShare
|
|
38
|
+
const showOnlyCopyButton = !showGenerateButton && (!isMobile || !canShare)
|
|
32
39
|
const isFederated = flag('drive.federated-shared-folder.enabled')
|
|
33
40
|
|
|
34
41
|
const [isEditDialogOpen, toggleEditDialogOpen] = useReducer(
|
|
@@ -36,6 +43,14 @@ const ShareByLink = ({ link, document, documentType }) => {
|
|
|
36
43
|
false
|
|
37
44
|
)
|
|
38
45
|
|
|
46
|
+
const showGenericError = () => {
|
|
47
|
+
showAlert({
|
|
48
|
+
message: t(`${documentType}.share.error.generic`),
|
|
49
|
+
severity: 'error',
|
|
50
|
+
variant: 'filled'
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
|
|
39
54
|
const handleGenerateLink = async () => {
|
|
40
55
|
setIsGenerating(true)
|
|
41
56
|
try {
|
|
@@ -61,17 +76,28 @@ const ShareByLink = ({ link, document, documentType }) => {
|
|
|
61
76
|
|
|
62
77
|
const generateLinkAndCopyLinkToClipboard = async () => {
|
|
63
78
|
let linkToCopy = link
|
|
79
|
+
const wasNewlyGenerated = !linkToCopy
|
|
64
80
|
if (!linkToCopy) {
|
|
65
81
|
linkToCopy = await handleGenerateLink()
|
|
66
82
|
}
|
|
67
83
|
if (linkToCopy) {
|
|
68
84
|
await copyToClipboard(linkToCopy, { t, showAlert })
|
|
85
|
+
if (wasNewlyGenerated && autoOpenShareRestriction) {
|
|
86
|
+
toggleEditDialogOpen()
|
|
87
|
+
}
|
|
69
88
|
} else {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
89
|
+
showGenericError()
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const generateLinkSilently = async () => {
|
|
94
|
+
const generated = await handleGenerateLink()
|
|
95
|
+
if (!generated) {
|
|
96
|
+
showGenericError()
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
if (autoOpenShareRestriction) {
|
|
100
|
+
toggleEditDialogOpen()
|
|
75
101
|
}
|
|
76
102
|
}
|
|
77
103
|
|
|
@@ -81,11 +107,7 @@ const ShareByLink = ({ link, document, documentType }) => {
|
|
|
81
107
|
linkToShare = await handleGenerateLink()
|
|
82
108
|
}
|
|
83
109
|
if (!linkToShare) {
|
|
84
|
-
|
|
85
|
-
message: t(`${documentType}.share.error.generic`),
|
|
86
|
-
severity: 'error',
|
|
87
|
-
variant: 'filled'
|
|
88
|
-
})
|
|
110
|
+
showGenericError()
|
|
89
111
|
return
|
|
90
112
|
}
|
|
91
113
|
|
|
@@ -100,11 +122,7 @@ const ShareByLink = ({ link, document, documentType }) => {
|
|
|
100
122
|
} catch (error) {
|
|
101
123
|
// Don't show error when user cancels the share dialog
|
|
102
124
|
if (error.name !== 'AbortError') {
|
|
103
|
-
|
|
104
|
-
message: t(`${documentType}.share.error.generic`),
|
|
105
|
-
severity: 'error',
|
|
106
|
-
variant: 'filled'
|
|
107
|
-
})
|
|
125
|
+
showGenericError()
|
|
108
126
|
}
|
|
109
127
|
}
|
|
110
128
|
}
|
|
@@ -144,6 +162,16 @@ const ShareByLink = ({ link, document, documentType }) => {
|
|
|
144
162
|
busy={isGenerating}
|
|
145
163
|
/>
|
|
146
164
|
)}
|
|
165
|
+
{showGenerateButton && (
|
|
166
|
+
<Button
|
|
167
|
+
label={t(`${documentType}.share.shareByLink.create`)}
|
|
168
|
+
variant="secondary"
|
|
169
|
+
size="medium"
|
|
170
|
+
startIcon={<Icon icon={LinkIcon} />}
|
|
171
|
+
onClick={generateLinkSilently}
|
|
172
|
+
busy={isGenerating}
|
|
173
|
+
/>
|
|
174
|
+
)}
|
|
147
175
|
{isEditDialogOpen && (
|
|
148
176
|
<ShareRestrictionModal file={document} onClose={toggleEditDialogOpen} />
|
|
149
177
|
)}
|
|
@@ -154,7 +182,9 @@ const ShareByLink = ({ link, document, documentType }) => {
|
|
|
154
182
|
ShareByLink.propTypes = {
|
|
155
183
|
link: PropTypes.string,
|
|
156
184
|
document: PropTypes.object.isRequired,
|
|
157
|
-
documentType: PropTypes.string.isRequired
|
|
185
|
+
documentType: PropTypes.string.isRequired,
|
|
186
|
+
showGenerateLinkButton: PropTypes.bool,
|
|
187
|
+
autoOpenShareRestriction: PropTypes.bool
|
|
158
188
|
}
|
|
159
189
|
|
|
160
190
|
export default ShareByLink
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import cx from 'classnames'
|
|
2
|
-
import React from 'react'
|
|
2
|
+
import React, { useMemo } from 'react'
|
|
3
3
|
|
|
4
4
|
import Typography from 'cozy-ui/transpiled/react/Typography'
|
|
5
5
|
import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints'
|
|
@@ -111,17 +111,32 @@ const SharingTitleFunction = ({ documentType, document }) =>
|
|
|
111
111
|
*/
|
|
112
112
|
const ShareDialogCozyToCozy = ({
|
|
113
113
|
showShareByLink,
|
|
114
|
+
showGenerateLinkButton,
|
|
115
|
+
autoOpenShareRestriction,
|
|
114
116
|
documentType,
|
|
115
117
|
document,
|
|
116
118
|
...props
|
|
117
119
|
}) => {
|
|
120
|
+
const dialogActionsOnShare = useMemo(() => {
|
|
121
|
+
if (!showShareByLink) return null
|
|
122
|
+
const BoundShareByLink = dialogActionProps => (
|
|
123
|
+
<DumbShareByLink
|
|
124
|
+
{...dialogActionProps}
|
|
125
|
+
showGenerateLinkButton={showGenerateLinkButton}
|
|
126
|
+
autoOpenShareRestriction={autoOpenShareRestriction}
|
|
127
|
+
/>
|
|
128
|
+
)
|
|
129
|
+
BoundShareByLink.displayName = 'BoundShareByLink'
|
|
130
|
+
return BoundShareByLink
|
|
131
|
+
}, [showShareByLink, showGenerateLinkButton, autoOpenShareRestriction])
|
|
132
|
+
|
|
118
133
|
return (
|
|
119
134
|
<ShareDialogTwoStepsConfirmationContainer
|
|
120
135
|
{...props}
|
|
121
136
|
documentType={documentType}
|
|
122
137
|
document={document}
|
|
123
138
|
dialogContentOnShare={SharingContent}
|
|
124
|
-
dialogActionsOnShare={
|
|
139
|
+
dialogActionsOnShare={dialogActionsOnShare}
|
|
125
140
|
dialogTitleOnShare={SharingTitleFunction({ documentType, document })}
|
|
126
141
|
disableGutters
|
|
127
142
|
/>
|
|
@@ -19,7 +19,9 @@ const ShareDialogOnlyByLink = ({
|
|
|
19
19
|
documentType,
|
|
20
20
|
link,
|
|
21
21
|
onClose,
|
|
22
|
-
permissions
|
|
22
|
+
permissions,
|
|
23
|
+
showGenerateLinkButton,
|
|
24
|
+
autoOpenShareRestriction
|
|
23
25
|
}) => {
|
|
24
26
|
const { t } = useI18n()
|
|
25
27
|
const { isMobile } = useBreakpoints()
|
|
@@ -62,6 +64,8 @@ const ShareDialogOnlyByLink = ({
|
|
|
62
64
|
link={link}
|
|
63
65
|
document={document}
|
|
64
66
|
documentType={documentType}
|
|
67
|
+
showGenerateLinkButton={showGenerateLinkButton}
|
|
68
|
+
autoOpenShareRestriction={autoOpenShareRestriction}
|
|
65
69
|
/>
|
|
66
70
|
</div>
|
|
67
71
|
</>
|
|
@@ -36,7 +36,7 @@ export const ShareModal = withLocales(props => {
|
|
|
36
36
|
|
|
37
37
|
const isFederatedMode = flag('drive.federated-shared-folder.enabled')
|
|
38
38
|
if (isFederatedMode && allLoaded) {
|
|
39
|
-
return <FederatedFolderModal document={document}
|
|
39
|
+
return <FederatedFolderModal document={document} {...rest} />
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
const isEditable =
|
|
@@ -61,6 +61,8 @@ export const ShareModal = withLocales(props => {
|
|
|
61
61
|
})
|
|
62
62
|
|
|
63
63
|
ShareModal.propTypes = {
|
|
64
|
+
autoOpenShareRestriction: PropTypes.bool,
|
|
64
65
|
document: PropTypes.object.isRequired,
|
|
65
|
-
onRevokeSuccess: PropTypes.func
|
|
66
|
+
onRevokeSuccess: PropTypes.func,
|
|
67
|
+
showGenerateLinkButton: PropTypes.bool
|
|
66
68
|
}
|
|
@@ -8,6 +8,7 @@ import ShareDialogOnlyByLink from './ShareDialogOnlyByLink'
|
|
|
8
8
|
import { SharedDriveEditModal } from './SharedDrive/SharedDriveEditModal'
|
|
9
9
|
|
|
10
10
|
export const ShareModal = ({
|
|
11
|
+
autoOpenShareRestriction,
|
|
11
12
|
createContact,
|
|
12
13
|
document,
|
|
13
14
|
documentType = 'Document',
|
|
@@ -24,6 +25,7 @@ export const ShareModal = ({
|
|
|
24
25
|
recipients,
|
|
25
26
|
sharing,
|
|
26
27
|
sharingDesc,
|
|
28
|
+
showGenerateLinkButton,
|
|
27
29
|
twoStepsConfirmationMethods
|
|
28
30
|
}) => {
|
|
29
31
|
if (isSharedDrive && !flag('drive.federated-shared-folder.enabled')) {
|
|
@@ -35,6 +37,8 @@ export const ShareModal = ({
|
|
|
35
37
|
onShare={onShare}
|
|
36
38
|
onRevoke={onRevoke}
|
|
37
39
|
onClose={onClose}
|
|
40
|
+
autoOpenShareRestriction={autoOpenShareRestriction}
|
|
41
|
+
showGenerateLinkButton={showGenerateLinkButton}
|
|
38
42
|
/>
|
|
39
43
|
)
|
|
40
44
|
}
|
|
@@ -58,6 +62,8 @@ export const ShareModal = ({
|
|
|
58
62
|
link={link}
|
|
59
63
|
onClose={onClose}
|
|
60
64
|
permissions={permissions}
|
|
65
|
+
showGenerateLinkButton={showGenerateLinkButton}
|
|
66
|
+
autoOpenShareRestriction={autoOpenShareRestriction}
|
|
61
67
|
/>
|
|
62
68
|
) : (
|
|
63
69
|
<ShareDialogCozyToCozy
|
|
@@ -79,6 +85,8 @@ export const ShareModal = ({
|
|
|
79
85
|
showShareByLink={showShareByLink}
|
|
80
86
|
showShareOnlyByLink={showShareOnlyByLink}
|
|
81
87
|
showWhoHasAccess={showWhoHasAccess}
|
|
88
|
+
showGenerateLinkButton={showGenerateLinkButton}
|
|
89
|
+
autoOpenShareRestriction={autoOpenShareRestriction}
|
|
82
90
|
twoStepsConfirmationMethods={twoStepsConfirmationMethods}
|
|
83
91
|
/>
|
|
84
92
|
)
|
|
@@ -87,6 +95,7 @@ export const ShareModal = ({
|
|
|
87
95
|
export default ShareModal
|
|
88
96
|
|
|
89
97
|
ShareModal.propTypes = {
|
|
98
|
+
autoOpenShareRestriction: PropTypes.bool,
|
|
90
99
|
createContact: PropTypes.func.isRequired,
|
|
91
100
|
document: PropTypes.object.isRequired,
|
|
92
101
|
documentType: PropTypes.string,
|
|
@@ -100,6 +109,7 @@ ShareModal.propTypes = {
|
|
|
100
109
|
permissions: PropTypes.array.isRequired,
|
|
101
110
|
recipients: PropTypes.array.isRequired,
|
|
102
111
|
sharingDesc: PropTypes.string,
|
|
112
|
+
showGenerateLinkButton: PropTypes.bool,
|
|
103
113
|
twoStepsConfirmationMethods: PropTypes.shape({
|
|
104
114
|
getRecipientsToBeConfirmed: PropTypes.func,
|
|
105
115
|
confirmRecipient: PropTypes.func,
|
|
@@ -6,8 +6,12 @@ import flag from 'cozy-flags'
|
|
|
6
6
|
import { ShareModal } from './ShareModal'
|
|
7
7
|
import AppLike from '../../test/AppLike'
|
|
8
8
|
|
|
9
|
-
jest.mock('./ShareDialogCozyToCozy', () => () =>
|
|
10
|
-
|
|
9
|
+
jest.mock('./ShareDialogCozyToCozy', () => () => (
|
|
10
|
+
<div>ShareDialogCozyToCozy</div>
|
|
11
|
+
))
|
|
12
|
+
jest.mock('./ShareDialogOnlyByLink', () => () => (
|
|
13
|
+
<div>ShareDialogOnlyByLink</div>
|
|
14
|
+
))
|
|
11
15
|
|
|
12
16
|
jest.mock('cozy-flags')
|
|
13
17
|
|
|
@@ -43,7 +47,7 @@ describe('ShareModal component', () => {
|
|
|
43
47
|
})
|
|
44
48
|
|
|
45
49
|
it('should render ShareDialogOnlyByLink if flag cozy.hide-sharing-cozy-to-cozy is true', () => {
|
|
46
|
-
flag.mockImplementation(
|
|
50
|
+
flag.mockImplementation(name => name === 'cozy.hide-sharing-cozy-to-cozy')
|
|
47
51
|
|
|
48
52
|
const root = setup({ documentType: 'Document' })
|
|
49
53
|
|
|
@@ -23,7 +23,9 @@ export const DumbSharedDriveModal = withLocales(
|
|
|
23
23
|
onShare,
|
|
24
24
|
onRename,
|
|
25
25
|
showNameField = true,
|
|
26
|
-
sharingLink
|
|
26
|
+
sharingLink,
|
|
27
|
+
autoOpenShareRestriction,
|
|
28
|
+
showGenerateLinkButton
|
|
27
29
|
}) => {
|
|
28
30
|
const { t } = useI18n()
|
|
29
31
|
return (
|
|
@@ -51,6 +53,8 @@ export const DumbSharedDriveModal = withLocales(
|
|
|
51
53
|
createLabel={t('SharedDrive.sharedDriveModal.create')}
|
|
52
54
|
shareLabel={t('FederatedFolder.share')}
|
|
53
55
|
saveLabel={t('SharedDrive.sharedDriveModal.save')}
|
|
56
|
+
autoOpenShareRestriction={autoOpenShareRestriction}
|
|
57
|
+
showGenerateLinkButton={showGenerateLinkButton}
|
|
54
58
|
/>
|
|
55
59
|
)
|
|
56
60
|
}
|
|
@@ -72,7 +76,9 @@ DumbSharedDriveModal.propTypes = {
|
|
|
72
76
|
onShare: PropTypes.func.isRequired,
|
|
73
77
|
onRename: PropTypes.func,
|
|
74
78
|
showNameField: PropTypes.bool,
|
|
75
|
-
sharingLink: PropTypes.string
|
|
79
|
+
sharingLink: PropTypes.string,
|
|
80
|
+
autoOpenShareRestriction: PropTypes.bool,
|
|
81
|
+
showGenerateLinkButton: PropTypes.bool
|
|
76
82
|
}
|
|
77
83
|
|
|
78
84
|
export default DumbSharedDriveModal
|
|
@@ -11,7 +11,16 @@ import { useSharingContext } from '../../hooks/useSharingContext'
|
|
|
11
11
|
import { Contact } from '../../models'
|
|
12
12
|
|
|
13
13
|
export const SharedDriveEditModal = withLocales(
|
|
14
|
-
({
|
|
14
|
+
({
|
|
15
|
+
document,
|
|
16
|
+
sharing,
|
|
17
|
+
recipients,
|
|
18
|
+
onShare,
|
|
19
|
+
onRevoke,
|
|
20
|
+
onClose,
|
|
21
|
+
autoOpenShareRestriction,
|
|
22
|
+
showGenerateLinkButton
|
|
23
|
+
}) => {
|
|
15
24
|
const client = useClient()
|
|
16
25
|
const { t } = useI18n()
|
|
17
26
|
const { showAlert } = useAlert()
|
|
@@ -51,11 +60,20 @@ export const SharedDriveEditModal = withLocales(
|
|
|
51
60
|
sharedDriveName={name}
|
|
52
61
|
handleSharedDriveNameChange={handleNameChange}
|
|
53
62
|
onRename={onRename}
|
|
63
|
+
autoOpenShareRestriction={autoOpenShareRestriction}
|
|
64
|
+
showGenerateLinkButton={showGenerateLinkButton}
|
|
54
65
|
/>
|
|
55
66
|
)
|
|
56
67
|
}
|
|
57
68
|
)
|
|
58
69
|
|
|
59
70
|
SharedDriveEditModal.propTypes = {
|
|
60
|
-
|
|
71
|
+
document: PropTypes.object,
|
|
72
|
+
sharing: PropTypes.object,
|
|
73
|
+
recipients: PropTypes.array,
|
|
74
|
+
onShare: PropTypes.func.isRequired,
|
|
75
|
+
onRevoke: PropTypes.func.isRequired,
|
|
76
|
+
onClose: PropTypes.func.isRequired,
|
|
77
|
+
autoOpenShareRestriction: PropTypes.bool,
|
|
78
|
+
showGenerateLinkButton: PropTypes.bool
|
|
61
79
|
}
|
|
@@ -38,7 +38,9 @@ export const DumbBatchSharedFolderModal = withLocales(
|
|
|
38
38
|
shareLabel,
|
|
39
39
|
saveLabel,
|
|
40
40
|
sharingDesc,
|
|
41
|
-
showShareByEmail = true
|
|
41
|
+
showShareByEmail = true,
|
|
42
|
+
autoOpenShareRestriction,
|
|
43
|
+
showGenerateLinkButton
|
|
42
44
|
}) => {
|
|
43
45
|
const hasRecipients = Boolean(recipients?.length)
|
|
44
46
|
|
|
@@ -59,6 +61,8 @@ export const DumbBatchSharedFolderModal = withLocales(
|
|
|
59
61
|
link={sharingLink}
|
|
60
62
|
document={document}
|
|
61
63
|
documentType="Files"
|
|
64
|
+
showGenerateLinkButton={showGenerateLinkButton}
|
|
65
|
+
autoOpenShareRestriction={autoOpenShareRestriction}
|
|
62
66
|
/>
|
|
63
67
|
)
|
|
64
68
|
}
|
|
@@ -70,6 +74,8 @@ export const DumbBatchSharedFolderModal = withLocales(
|
|
|
70
74
|
link={sharingLink}
|
|
71
75
|
document={document}
|
|
72
76
|
documentType="Files"
|
|
77
|
+
showGenerateLinkButton={showGenerateLinkButton}
|
|
78
|
+
autoOpenShareRestriction={autoOpenShareRestriction}
|
|
73
79
|
/>
|
|
74
80
|
<Button
|
|
75
81
|
variant="primary"
|
|
@@ -182,7 +188,9 @@ DumbBatchSharedFolderModal.propTypes = {
|
|
|
182
188
|
shareLabel: PropTypes.string,
|
|
183
189
|
saveLabel: PropTypes.string,
|
|
184
190
|
sharingDesc: PropTypes.string,
|
|
185
|
-
showShareByEmail: PropTypes.bool
|
|
191
|
+
showShareByEmail: PropTypes.bool,
|
|
192
|
+
autoOpenShareRestriction: PropTypes.bool,
|
|
193
|
+
showGenerateLinkButton: PropTypes.bool
|
|
186
194
|
}
|
|
187
195
|
|
|
188
196
|
DumbBatchSharedFolderModal.defaultProps = {
|