cozy-sharing 31.0.2 → 31.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 +30 -0
- package/dist/components/FederatedFolder/DumbFederatedFolderModal.js +15 -16
- package/dist/components/FederatedFolder/FederatedFolderModal.js +78 -103
- package/dist/components/FederatedFolder/FederatedFolderModal.spec.js +102 -292
- package/dist/components/Recipient/GroupRecipientPermissions.js +15 -11
- package/dist/components/Recipient/LinkRecipient.js +15 -11
- package/dist/components/Recipient/LinkRecipientLite.js +1 -1
- package/dist/components/Recipient/LinkRecipientPermissions.js +2 -1
- package/dist/components/Recipient/MemberRecipient.spec.js +8 -10
- package/dist/components/Recipient/MemberRecipientLite.js +1 -1
- package/dist/components/Recipient/MemberRecipientPermissions.js +16 -12
- package/dist/components/Recipient/MemberRecipientPermissions.spec.js +62 -50
- package/dist/components/Recipient/RecipientConfirm.js +0 -5
- package/dist/components/ShareAutosuggest.js +9 -4
- package/dist/components/ShareByEmail.js +29 -274
- package/dist/components/ShareByEmail.spec.js +52 -230
- package/dist/components/ShareByLink.js +1 -3
- package/dist/components/ShareDialogCozyToCozy.js +169 -35
- package/dist/components/ShareDialogCozyToCozy.spec.js +123 -36
- package/dist/components/ShareDialogTwoStepsConfirmationContainer.js +13 -3
- package/dist/components/ShareModal/SharingDetailsModal.js +0 -5
- package/dist/components/ShareRecipientsInput.js +6 -3
- package/dist/components/SharedDrive/SharedDriveForm.js +17 -25
- package/dist/components/SharedDrive/SharedDriveModal.js +1 -1
- package/dist/components/SharedDrive/SharedDriveRecipientPermissions.js +15 -10
- package/dist/components/SharedDrive/useSharedDrive.js +33 -57
- package/dist/components/SharedDrive/useSharedDrive.spec.js +29 -93
- package/dist/components/SharedFolder/DumbBatchSharedFolderModal.js +15 -26
- package/dist/components/Sharetypeselect.js +85 -90
- package/dist/hooks/usePendingRecipients.js +20 -0
- package/dist/hooks/usePendingRecipients.spec.js +30 -0
- package/dist/styles/autosuggest.styl +8 -2
- package/dist/styles/share.styl +0 -39
- package/dist/stylesheet.css +8 -36
- package/locales/en.json +14 -44
- package/locales/fr.json +14 -44
- package/locales/ru.json +14 -44
- package/locales/vi.json +14 -42
- package/package.json +2 -2
- package/src/components/FederatedFolder/DumbFederatedFolderModal.jsx +14 -15
- package/src/components/FederatedFolder/FederatedFolderModal.jsx +50 -67
- package/src/components/FederatedFolder/FederatedFolderModal.spec.jsx +63 -186
- package/src/components/Recipient/GroupRecipientPermissions.jsx +15 -13
- package/src/components/Recipient/LinkRecipient.jsx +9 -9
- package/src/components/Recipient/LinkRecipientLite.jsx +1 -3
- package/src/components/Recipient/LinkRecipientPermissions.jsx +2 -1
- package/src/components/Recipient/MemberRecipient.spec.jsx +4 -6
- package/src/components/Recipient/MemberRecipientLite.jsx +2 -2
- package/src/components/Recipient/MemberRecipientPermissions.jsx +16 -21
- package/src/components/Recipient/MemberRecipientPermissions.spec.jsx +21 -23
- package/src/components/ShareAutosuggest.jsx +7 -2
- package/src/components/ShareByEmail.jsx +35 -186
- package/src/components/ShareByEmail.spec.jsx +22 -173
- package/src/components/ShareByLink.jsx +1 -7
- package/src/components/ShareDialogCozyToCozy.jsx +171 -38
- package/src/components/ShareDialogCozyToCozy.spec.jsx +67 -1
- package/src/components/ShareDialogTwoStepsConfirmationContainer.jsx +11 -1
- package/src/components/ShareRecipientsInput.jsx +5 -2
- package/src/components/SharedDrive/SharedDriveForm.jsx +16 -25
- package/src/components/SharedDrive/SharedDriveModal.jsx +1 -1
- package/src/components/SharedDrive/SharedDriveRecipientPermissions.jsx +15 -17
- package/src/components/SharedDrive/useSharedDrive.js +24 -50
- package/src/components/SharedDrive/useSharedDrive.spec.js +19 -67
- package/src/components/SharedFolder/DumbBatchSharedFolderModal.jsx +15 -29
- package/src/components/Sharetypeselect.jsx +75 -58
- package/src/hooks/usePendingRecipients.js +13 -0
- package/src/hooks/usePendingRecipients.spec.js +21 -0
- package/src/styles/autosuggest.styl +8 -2
- package/src/styles/share.styl +0 -39
- package/dist/components/Recipient/actions/revokeGroup.js +0 -42
- package/dist/components/Recipient/actions/revokeMember.js +0 -42
- package/dist/components/Recipient/actions/revokeSharedDriveMember.js +0 -41
- package/dist/components/SharedDrive/helpers.js +0 -102
- package/dist/components/SharedDrive/helpers.spec.js +0 -227
- package/dist/components/Sharesubmit.js +0 -28
- package/src/components/Recipient/actions/revokeGroup.js +0 -42
- package/src/components/Recipient/actions/revokeMember.js +0 -42
- package/src/components/Recipient/actions/revokeSharedDriveMember.js +0 -41
- package/src/components/SharedDrive/helpers.js +0 -108
- package/src/components/SharedDrive/helpers.spec.js +0 -177
- package/src/components/Sharesubmit.jsx +0 -31
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
5
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["showShareByLink", "showGenerateLinkButton", "autoOpenShareRestriction", "documentType", "document"];
|
|
6
|
+
var _excluded = ["showShareByLink", "showGenerateLinkButton", "autoOpenShareRestriction", "documentType", "document", "onShare", "recipients", "sharingDesc", "createContact", "onClose"];
|
|
7
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
8
|
import cx from 'classnames';
|
|
5
|
-
import
|
|
9
|
+
import PropTypes from 'prop-types';
|
|
10
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
11
|
+
import { useClient } from 'cozy-client';
|
|
12
|
+
import Button from 'cozy-ui/transpiled/react/Buttons';
|
|
6
13
|
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
14
|
+
import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert';
|
|
7
15
|
import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints';
|
|
8
16
|
import { useI18n } from 'twake-i18n';
|
|
9
17
|
import AntivirusAlert from './AntivirusAlert';
|
|
10
18
|
import { default as DumbShareByEmail } from './ShareByEmail';
|
|
11
19
|
import { default as DumbShareByLink } from './ShareByLink';
|
|
12
20
|
import ShareDialogTwoStepsConfirmationContainer from './ShareDialogTwoStepsConfirmationContainer';
|
|
21
|
+
import { ShareRecipientsLimitModal } from './ShareRecipientsLimitModal';
|
|
13
22
|
import WhoHasAccess from './WhoHasAccess';
|
|
23
|
+
import { getOrCreateFromArray } from '../helpers/contacts';
|
|
24
|
+
import { hasReachRecipientsLimit } from '../helpers/recipients';
|
|
25
|
+
import { getErrorMessage, getSuccessMessage } from '../helpers/share';
|
|
26
|
+
import { usePendingRecipients } from '../hooks/usePendingRecipients';
|
|
14
27
|
var styles = {
|
|
15
28
|
"share-modal-content": "share__share-modal-content___1iqEq",
|
|
16
29
|
"coz-form": "share__coz-form___1ICST",
|
|
@@ -25,38 +38,31 @@ var styles = {
|
|
|
25
38
|
"error": "share__error___pwqPO",
|
|
26
39
|
"share-byemail-onlybylink": "share__share-byemail-onlybylink___29W-t",
|
|
27
40
|
"aligned-dropdown-button": "share__aligned-dropdown-button___3crgG",
|
|
28
|
-
"share-type-control": "share__share-type-control___1YoRr",
|
|
29
|
-
"select-wrapper": "share__select-wrapper___3XBKC",
|
|
30
|
-
"select-option": "share__select-option___3Jp8_",
|
|
31
|
-
"select-option-label": "share__select-option-label___1BWz_",
|
|
32
|
-
"select-option-desc": "share__select-option-desc___3jOnr",
|
|
33
41
|
"share-details-created": "share__share-details-created___z3nvO",
|
|
34
42
|
"share-details-perm": "share__share-details-perm___3HjxK",
|
|
35
43
|
"share-details-perm-desc": "share__share-details-perm-desc___3HyHu"
|
|
36
44
|
};
|
|
37
|
-
/**
|
|
38
|
-
* Displays the sharing interface that can be used when ShareDialogCozyToCozy is in sharing state
|
|
39
|
-
*/
|
|
40
45
|
|
|
41
46
|
var SharingContent = function SharingContent(_ref) {
|
|
42
|
-
var
|
|
43
|
-
document = _ref.document,
|
|
47
|
+
var document = _ref.document,
|
|
44
48
|
documentType = _ref.documentType,
|
|
45
49
|
hasSharedParent = _ref.hasSharedParent,
|
|
46
50
|
isOwner = _ref.isOwner,
|
|
47
51
|
onRevoke = _ref.onRevoke,
|
|
48
52
|
onRevokeSelf = _ref.onRevokeSelf,
|
|
49
|
-
onShare = _ref.onShare,
|
|
50
53
|
recipients = _ref.recipients,
|
|
51
54
|
sharing = _ref.sharing,
|
|
52
|
-
sharingDesc = _ref.sharingDesc,
|
|
53
55
|
showShareByEmail = _ref.showShareByEmail,
|
|
54
56
|
showShareOnlyByLink = _ref.showShareOnlyByLink,
|
|
55
57
|
showWhoHasAccess = _ref.showWhoHasAccess,
|
|
56
58
|
recipientsToBeConfirmed = _ref.recipientsToBeConfirmed,
|
|
57
59
|
verifyRecipient = _ref.verifyRecipient,
|
|
58
60
|
link = _ref.link,
|
|
59
|
-
permissions = _ref.permissions
|
|
61
|
+
permissions = _ref.permissions,
|
|
62
|
+
pendingRecipients = _ref.pendingRecipients,
|
|
63
|
+
onPendingRecipientsChange = _ref.onPendingRecipientsChange,
|
|
64
|
+
selectedOption = _ref.selectedOption,
|
|
65
|
+
onSelectedOptionChange = _ref.onSelectedOptionChange;
|
|
60
66
|
|
|
61
67
|
var _useI18n = useI18n(),
|
|
62
68
|
t = _useI18n.t;
|
|
@@ -78,13 +84,14 @@ var SharingContent = function SharingContent(_ref) {
|
|
|
78
84
|
variant: "h6",
|
|
79
85
|
className: "u-mb-1-half"
|
|
80
86
|
}, t('Share.contacts.whoHasAccess')), showShareByEmail && /*#__PURE__*/React.createElement(DumbShareByEmail, {
|
|
81
|
-
createContact: createContact,
|
|
82
87
|
currentRecipients: recipients,
|
|
83
88
|
document: document,
|
|
84
89
|
documentType: documentType,
|
|
85
|
-
onShare: onShare,
|
|
86
90
|
sharing: sharing,
|
|
87
|
-
|
|
91
|
+
pendingRecipients: pendingRecipients,
|
|
92
|
+
onPendingRecipientsChange: onPendingRecipientsChange,
|
|
93
|
+
selectedOption: selectedOption,
|
|
94
|
+
onSelectedOptionChange: onSelectedOptionChange
|
|
88
95
|
})), showWhoHasAccess && /*#__PURE__*/React.createElement(WhoHasAccess, {
|
|
89
96
|
document: document,
|
|
90
97
|
documentType: documentType,
|
|
@@ -98,10 +105,6 @@ var SharingContent = function SharingContent(_ref) {
|
|
|
98
105
|
permissions: permissions
|
|
99
106
|
}));
|
|
100
107
|
};
|
|
101
|
-
/**
|
|
102
|
-
* Displays the dialog's title that can be used when ShareDialogCozyToCozy is in sharing state
|
|
103
|
-
*/
|
|
104
|
-
|
|
105
108
|
|
|
106
109
|
var SharingTitleFunction = function SharingTitleFunction(_ref2) {
|
|
107
110
|
var documentType = _ref2.documentType,
|
|
@@ -118,10 +121,6 @@ var SharingTitleFunction = function SharingTitleFunction(_ref2) {
|
|
|
118
121
|
return title;
|
|
119
122
|
};
|
|
120
123
|
};
|
|
121
|
-
/**
|
|
122
|
-
* Displays a sharing dialog that allows to share a document between multiple Cozy users
|
|
123
|
-
*/
|
|
124
|
-
|
|
125
124
|
|
|
126
125
|
var ShareDialogCozyToCozy = function ShareDialogCozyToCozy(_ref3) {
|
|
127
126
|
var showShareByLink = _ref3.showShareByLink,
|
|
@@ -129,32 +128,167 @@ var ShareDialogCozyToCozy = function ShareDialogCozyToCozy(_ref3) {
|
|
|
129
128
|
autoOpenShareRestriction = _ref3.autoOpenShareRestriction,
|
|
130
129
|
documentType = _ref3.documentType,
|
|
131
130
|
document = _ref3.document,
|
|
131
|
+
onShare = _ref3.onShare,
|
|
132
|
+
recipients = _ref3.recipients,
|
|
133
|
+
sharingDesc = _ref3.sharingDesc,
|
|
134
|
+
createContact = _ref3.createContact,
|
|
135
|
+
onClose = _ref3.onClose,
|
|
132
136
|
props = _objectWithoutProperties(_ref3, _excluded);
|
|
133
137
|
|
|
134
|
-
var
|
|
135
|
-
|
|
138
|
+
var _useI18n3 = useI18n(),
|
|
139
|
+
t = _useI18n3.t;
|
|
140
|
+
|
|
141
|
+
var client = useClient();
|
|
142
|
+
|
|
143
|
+
var _useAlert = useAlert(),
|
|
144
|
+
showAlert = _useAlert.showAlert;
|
|
145
|
+
|
|
146
|
+
var _usePendingRecipients = usePendingRecipients(),
|
|
147
|
+
pendingRecipients = _usePendingRecipients.pendingRecipients,
|
|
148
|
+
setPendingRecipients = _usePendingRecipients.setPendingRecipients,
|
|
149
|
+
selectedOption = _usePendingRecipients.selectedOption,
|
|
150
|
+
setSelectedOption = _usePendingRecipients.setSelectedOption;
|
|
151
|
+
|
|
152
|
+
var _useState = useState(false),
|
|
153
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
154
|
+
submitting = _useState2[0],
|
|
155
|
+
setSubmitting = _useState2[1];
|
|
156
|
+
|
|
157
|
+
var _useState3 = useState(false),
|
|
158
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
159
|
+
showRecipientsLimit = _useState4[0],
|
|
160
|
+
setShowRecipientsLimit = _useState4[1];
|
|
161
|
+
|
|
162
|
+
var handleShare = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
163
|
+
var contacts, readWriteRecipients, readOnlyRecipients;
|
|
164
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
165
|
+
while (1) switch (_context.prev = _context.next) {
|
|
166
|
+
case 0:
|
|
167
|
+
if (!(pendingRecipients.length === 0)) {
|
|
168
|
+
_context.next = 3;
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
onClose();
|
|
173
|
+
return _context.abrupt("return");
|
|
136
174
|
|
|
137
|
-
|
|
138
|
-
|
|
175
|
+
case 3:
|
|
176
|
+
if (!hasReachRecipientsLimit(recipients, pendingRecipients)) {
|
|
177
|
+
_context.next = 6;
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
setShowRecipientsLimit(true);
|
|
182
|
+
return _context.abrupt("return");
|
|
183
|
+
|
|
184
|
+
case 6:
|
|
185
|
+
setSubmitting(true);
|
|
186
|
+
_context.prev = 7;
|
|
187
|
+
_context.next = 10;
|
|
188
|
+
return getOrCreateFromArray(client, pendingRecipients, createContact);
|
|
189
|
+
|
|
190
|
+
case 10:
|
|
191
|
+
contacts = _context.sent;
|
|
192
|
+
readWriteRecipients = selectedOption === 'readOnly' ? [] : contacts;
|
|
193
|
+
readOnlyRecipients = selectedOption === 'readOnly' ? contacts : [];
|
|
194
|
+
_context.next = 15;
|
|
195
|
+
return onShare({
|
|
196
|
+
document: document,
|
|
197
|
+
recipients: readWriteRecipients,
|
|
198
|
+
readOnlyRecipients: readOnlyRecipients,
|
|
199
|
+
description: sharingDesc,
|
|
200
|
+
openSharing: readWriteRecipients.length > 0
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
case 15:
|
|
204
|
+
showAlert({
|
|
205
|
+
message: t.apply(void 0, _toConsumableArray(getSuccessMessage(recipients, contacts, documentType))),
|
|
206
|
+
severity: 'success',
|
|
207
|
+
variant: 'filled'
|
|
208
|
+
});
|
|
209
|
+
onClose();
|
|
210
|
+
_context.next = 22;
|
|
211
|
+
break;
|
|
212
|
+
|
|
213
|
+
case 19:
|
|
214
|
+
_context.prev = 19;
|
|
215
|
+
_context.t0 = _context["catch"](7);
|
|
216
|
+
showAlert({
|
|
217
|
+
message: t.apply(void 0, _toConsumableArray(getErrorMessage({
|
|
218
|
+
t: t,
|
|
219
|
+
err: _context.t0,
|
|
220
|
+
documentType: documentType,
|
|
221
|
+
recipients: pendingRecipients,
|
|
222
|
+
selectedOption: selectedOption
|
|
223
|
+
}))),
|
|
224
|
+
severity: 'error',
|
|
225
|
+
variant: 'filled'
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
case 22:
|
|
229
|
+
_context.prev = 22;
|
|
230
|
+
setSubmitting(false);
|
|
231
|
+
return _context.finish(22);
|
|
232
|
+
|
|
233
|
+
case 25:
|
|
234
|
+
case "end":
|
|
235
|
+
return _context.stop();
|
|
236
|
+
}
|
|
237
|
+
}, _callee, null, [[7, 19, 22, 25]]);
|
|
238
|
+
})), [pendingRecipients, selectedOption, client, showAlert, t, recipients, onShare, onClose, createContact, document, documentType, sharingDesc]);
|
|
239
|
+
var dialogActionsOnShare = useMemo(function () {
|
|
240
|
+
var Actions = function Actions(dialogActionProps) {
|
|
241
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, showShareByLink && /*#__PURE__*/React.createElement(DumbShareByLink, _extends({}, dialogActionProps, {
|
|
139
242
|
showGenerateLinkButton: showGenerateLinkButton,
|
|
140
243
|
autoOpenShareRestriction: autoOpenShareRestriction
|
|
244
|
+
})), /*#__PURE__*/React.createElement(Button, {
|
|
245
|
+
variant: "primary",
|
|
246
|
+
label: t("".concat(documentType, ".share.shareByEmail.send")),
|
|
247
|
+
busy: submitting,
|
|
248
|
+
onClick: handleShare
|
|
141
249
|
}));
|
|
142
250
|
};
|
|
143
251
|
|
|
144
|
-
|
|
145
|
-
return
|
|
146
|
-
}, [showShareByLink, showGenerateLinkButton, autoOpenShareRestriction]);
|
|
147
|
-
return /*#__PURE__*/React.createElement(ShareDialogTwoStepsConfirmationContainer, _extends({}, props, {
|
|
252
|
+
Actions.displayName = 'ShareDialogCozyToCozyActions';
|
|
253
|
+
return Actions;
|
|
254
|
+
}, [handleShare, submitting, t, documentType, showShareByLink, showGenerateLinkButton, autoOpenShareRestriction]);
|
|
255
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ShareDialogTwoStepsConfirmationContainer, _extends({}, props, {
|
|
148
256
|
documentType: documentType,
|
|
149
257
|
document: document,
|
|
258
|
+
recipients: recipients,
|
|
259
|
+
sharingDesc: sharingDesc,
|
|
260
|
+
createContact: createContact,
|
|
261
|
+
onShare: onShare,
|
|
262
|
+
onClose: onClose,
|
|
150
263
|
dialogContentOnShare: SharingContent,
|
|
151
264
|
dialogActionsOnShare: dialogActionsOnShare,
|
|
152
265
|
dialogTitleOnShare: SharingTitleFunction({
|
|
153
266
|
documentType: documentType,
|
|
154
267
|
document: document
|
|
155
268
|
}),
|
|
156
|
-
disableGutters: true
|
|
269
|
+
disableGutters: true,
|
|
270
|
+
pendingRecipients: pendingRecipients,
|
|
271
|
+
onPendingRecipientsChange: setPendingRecipients,
|
|
272
|
+
selectedOption: selectedOption,
|
|
273
|
+
onSelectedOptionChange: setSelectedOption
|
|
274
|
+
})), showRecipientsLimit && /*#__PURE__*/React.createElement(ShareRecipientsLimitModal, {
|
|
275
|
+
documentName: document === null || document === void 0 ? void 0 : document.name,
|
|
276
|
+
onConfirm: function onConfirm() {
|
|
277
|
+
return setShowRecipientsLimit(false);
|
|
278
|
+
}
|
|
157
279
|
}));
|
|
158
280
|
};
|
|
159
281
|
|
|
282
|
+
ShareDialogCozyToCozy.propTypes = {
|
|
283
|
+
showShareByLink: PropTypes.bool,
|
|
284
|
+
showGenerateLinkButton: PropTypes.bool,
|
|
285
|
+
autoOpenShareRestriction: PropTypes.bool,
|
|
286
|
+
documentType: PropTypes.string.isRequired,
|
|
287
|
+
document: PropTypes.object.isRequired,
|
|
288
|
+
onShare: PropTypes.func.isRequired,
|
|
289
|
+
recipients: PropTypes.array.isRequired,
|
|
290
|
+
sharingDesc: PropTypes.string,
|
|
291
|
+
createContact: PropTypes.func.isRequired,
|
|
292
|
+
onClose: PropTypes.func.isRequired
|
|
293
|
+
};
|
|
160
294
|
export default ShareDialogCozyToCozy;
|
|
@@ -38,6 +38,13 @@ jest.mock('../hooks/useSharingContext', function () {
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
});
|
|
41
|
+
jest.mock('../helpers/contacts', function () {
|
|
42
|
+
return {
|
|
43
|
+
getOrCreateFromArray: jest.fn(function (client, recipients) {
|
|
44
|
+
return Promise.resolve(recipients);
|
|
45
|
+
})
|
|
46
|
+
};
|
|
47
|
+
});
|
|
41
48
|
describe('ShareDialogCozyToCozy', function () {
|
|
42
49
|
var client = createMockClient({});
|
|
43
50
|
client.options = {
|
|
@@ -57,7 +64,7 @@ describe('ShareDialogCozyToCozy', function () {
|
|
|
57
64
|
getByText = _setup.getByText;
|
|
58
65
|
|
|
59
66
|
expect(getByText('You')).toBeTruthy();
|
|
60
|
-
expect(getByText('
|
|
67
|
+
expect(getByText('Owner')).toBeTruthy();
|
|
61
68
|
});
|
|
62
69
|
it('should show loading while calling getRecipientsToBeConfirmed', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
63
70
|
var _deferablePromise, promise, resolve, props, _setup2, getByText;
|
|
@@ -243,11 +250,90 @@ describe('ShareDialogCozyToCozy', function () {
|
|
|
243
250
|
}
|
|
244
251
|
}, _callee8);
|
|
245
252
|
})));
|
|
246
|
-
it(
|
|
247
|
-
var
|
|
253
|
+
it('main Share button calls onClose when there are no pending chips', function () {
|
|
254
|
+
var onClose = jest.fn();
|
|
255
|
+
var onShare = jest.fn();
|
|
256
|
+
|
|
257
|
+
var props = _objectSpread(_objectSpread({}, getMockProps()), {}, {
|
|
258
|
+
onClose: onClose,
|
|
259
|
+
onShare: onShare
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
var _setup6 = setup(props),
|
|
263
|
+
getByRole = _setup6.getByRole;
|
|
264
|
+
|
|
265
|
+
fireEvent.click(getByRole('button', {
|
|
266
|
+
name: 'Share'
|
|
267
|
+
}));
|
|
268
|
+
expect(onShare).not.toHaveBeenCalled();
|
|
269
|
+
expect(onClose).toHaveBeenCalledTimes(1);
|
|
270
|
+
});
|
|
271
|
+
it('main Share button calls onShare with chips then closes', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
|
|
272
|
+
var onClose, onShare, props, _setup7, getByPlaceholderText, getByRole;
|
|
273
|
+
|
|
274
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
275
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
276
|
+
case 0:
|
|
277
|
+
onClose = jest.fn();
|
|
278
|
+
onShare = jest.fn().mockResolvedValue(undefined);
|
|
279
|
+
props = _objectSpread(_objectSpread({}, getMockProps()), {}, {
|
|
280
|
+
onClose: onClose,
|
|
281
|
+
onShare: onShare
|
|
282
|
+
});
|
|
283
|
+
_setup7 = setup(props), getByPlaceholderText = _setup7.getByPlaceholderText, getByRole = _setup7.getByRole;
|
|
284
|
+
act(function () {
|
|
285
|
+
fireEvent.change(getByPlaceholderText('Enter the email address or name of the recipient'), {
|
|
286
|
+
target: {
|
|
287
|
+
value: 'new@cozycloud.cc'
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
act(function () {
|
|
292
|
+
fireEvent.keyPress(getByPlaceholderText('Enter the email address or name of the recipient'), {
|
|
293
|
+
key: 'Enter',
|
|
294
|
+
code: 'Enter',
|
|
295
|
+
charCode: 13
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
_context10.next = 8;
|
|
299
|
+
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
|
|
300
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
301
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
302
|
+
case 0:
|
|
303
|
+
fireEvent.click(getByRole('button', {
|
|
304
|
+
name: 'Share'
|
|
305
|
+
}));
|
|
306
|
+
|
|
307
|
+
case 1:
|
|
308
|
+
case "end":
|
|
309
|
+
return _context9.stop();
|
|
310
|
+
}
|
|
311
|
+
}, _callee9);
|
|
312
|
+
})));
|
|
313
|
+
|
|
314
|
+
case 8:
|
|
315
|
+
expect(onShare).toHaveBeenCalledWith(expect.objectContaining({
|
|
316
|
+
document: props.document,
|
|
317
|
+
recipients: [{
|
|
318
|
+
email: 'new@cozycloud.cc'
|
|
319
|
+
}],
|
|
320
|
+
readOnlyRecipients: [],
|
|
321
|
+
description: props.sharingDesc,
|
|
322
|
+
openSharing: true
|
|
323
|
+
}));
|
|
324
|
+
expect(onClose).toHaveBeenCalledTimes(1);
|
|
325
|
+
|
|
326
|
+
case 10:
|
|
327
|
+
case "end":
|
|
328
|
+
return _context10.stop();
|
|
329
|
+
}
|
|
330
|
+
}, _callee10);
|
|
331
|
+
})));
|
|
332
|
+
it("should display confirmation of 'contact rejection' when user click on the 'reject' button", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15() {
|
|
333
|
+
var _deferablePromise5, promise, resolve, rejectRecipient, props, _setup8, getByText, verifyButton, rejectButton, confirmRejectButton;
|
|
248
334
|
|
|
249
|
-
return _regeneratorRuntime.wrap(function
|
|
250
|
-
while (1) switch (
|
|
335
|
+
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
336
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
251
337
|
case 0:
|
|
252
338
|
_deferablePromise5 = deferablePromise(), promise = _deferablePromise5.promise, resolve = _deferablePromise5.resolve;
|
|
253
339
|
rejectRecipient = jest.fn(function () {
|
|
@@ -262,11 +348,11 @@ describe('ShareDialogCozyToCozy', function () {
|
|
|
262
348
|
recipientConfirmationDialogContent: CozyPassFingerprintDialogContent
|
|
263
349
|
}
|
|
264
350
|
});
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
268
|
-
return _regeneratorRuntime.wrap(function
|
|
269
|
-
while (1) switch (
|
|
351
|
+
_setup8 = setup(props), getByText = _setup8.getByText;
|
|
352
|
+
_context15.next = 6;
|
|
353
|
+
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
|
|
354
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
355
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
270
356
|
case 0:
|
|
271
357
|
resolve([{
|
|
272
358
|
name: mockRecipientBob.public_name,
|
|
@@ -274,63 +360,63 @@ describe('ShareDialogCozyToCozy', function () {
|
|
|
274
360
|
email: mockRecipientBob.email,
|
|
275
361
|
fingerprintPhrase: 'SOME_FINGERPRINT_PHRASE'
|
|
276
362
|
}]);
|
|
277
|
-
|
|
363
|
+
_context11.next = 3;
|
|
278
364
|
return promise;
|
|
279
365
|
|
|
280
366
|
case 3:
|
|
281
367
|
case "end":
|
|
282
|
-
return
|
|
368
|
+
return _context11.stop();
|
|
283
369
|
}
|
|
284
|
-
},
|
|
370
|
+
}, _callee11);
|
|
285
371
|
})));
|
|
286
372
|
|
|
287
373
|
case 6:
|
|
288
374
|
verifyButton = getByText('Verify');
|
|
289
|
-
|
|
290
|
-
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
291
|
-
return _regeneratorRuntime.wrap(function
|
|
292
|
-
while (1) switch (
|
|
375
|
+
_context15.next = 9;
|
|
376
|
+
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
|
|
377
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
378
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
293
379
|
case 0:
|
|
294
|
-
return
|
|
380
|
+
return _context12.abrupt("return", fireEvent.click(verifyButton));
|
|
295
381
|
|
|
296
382
|
case 1:
|
|
297
383
|
case "end":
|
|
298
|
-
return
|
|
384
|
+
return _context12.stop();
|
|
299
385
|
}
|
|
300
|
-
},
|
|
386
|
+
}, _callee12);
|
|
301
387
|
})));
|
|
302
388
|
|
|
303
389
|
case 9:
|
|
304
390
|
rejectButton = getByText('Reject');
|
|
305
|
-
|
|
306
|
-
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
307
|
-
return _regeneratorRuntime.wrap(function
|
|
308
|
-
while (1) switch (
|
|
391
|
+
_context15.next = 12;
|
|
392
|
+
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
|
|
393
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
394
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
309
395
|
case 0:
|
|
310
|
-
return
|
|
396
|
+
return _context13.abrupt("return", fireEvent.click(rejectButton));
|
|
311
397
|
|
|
312
398
|
case 1:
|
|
313
399
|
case "end":
|
|
314
|
-
return
|
|
400
|
+
return _context13.stop();
|
|
315
401
|
}
|
|
316
|
-
},
|
|
402
|
+
}, _callee13);
|
|
317
403
|
})));
|
|
318
404
|
|
|
319
405
|
case 12:
|
|
320
406
|
expect(getByText("Do you really want to reject contact ".concat(mockRecipientBob.public_name, " (").concat(mockRecipientBob.email, ")?"))).toBeTruthy();
|
|
321
407
|
confirmRejectButton = getByText('Reject');
|
|
322
|
-
|
|
323
|
-
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
324
|
-
return _regeneratorRuntime.wrap(function
|
|
325
|
-
while (1) switch (
|
|
408
|
+
_context15.next = 16;
|
|
409
|
+
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
|
|
410
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
411
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
326
412
|
case 0:
|
|
327
|
-
return
|
|
413
|
+
return _context14.abrupt("return", fireEvent.click(confirmRejectButton));
|
|
328
414
|
|
|
329
415
|
case 1:
|
|
330
416
|
case "end":
|
|
331
|
-
return
|
|
417
|
+
return _context14.stop();
|
|
332
418
|
}
|
|
333
|
-
},
|
|
419
|
+
}, _callee14);
|
|
334
420
|
})));
|
|
335
421
|
|
|
336
422
|
case 16:
|
|
@@ -338,9 +424,9 @@ describe('ShareDialogCozyToCozy', function () {
|
|
|
338
424
|
|
|
339
425
|
case 17:
|
|
340
426
|
case "end":
|
|
341
|
-
return
|
|
427
|
+
return _context15.stop();
|
|
342
428
|
}
|
|
343
|
-
},
|
|
429
|
+
}, _callee15);
|
|
344
430
|
})));
|
|
345
431
|
});
|
|
346
432
|
var mockRecipientAlice = {
|
|
@@ -484,6 +570,7 @@ var getMockProps = function getMockProps() {
|
|
|
484
570
|
showWhoHasAccess: true,
|
|
485
571
|
onRevoke: jest.fn(),
|
|
486
572
|
onShare: jest.fn(),
|
|
573
|
+
onClose: jest.fn(),
|
|
487
574
|
createContact: jest.fn()
|
|
488
575
|
};
|
|
489
576
|
};
|
|
@@ -120,7 +120,11 @@ var ShareDialogTwoStepsConfirmationContainer = function ShareDialogTwoStepsConfi
|
|
|
120
120
|
twoStepsConfirmationMethods = _ref4$twoStepsConfirm === void 0 ? {} : _ref4$twoStepsConfirm,
|
|
121
121
|
DialogContentOnShare = _ref4.dialogContentOnShare,
|
|
122
122
|
DialogActionsOnShare = _ref4.dialogActionsOnShare,
|
|
123
|
-
DialogTitleOnShare = _ref4.dialogTitleOnShare
|
|
123
|
+
DialogTitleOnShare = _ref4.dialogTitleOnShare,
|
|
124
|
+
pendingRecipients = _ref4.pendingRecipients,
|
|
125
|
+
onPendingRecipientsChange = _ref4.onPendingRecipientsChange,
|
|
126
|
+
selectedOption = _ref4.selectedOption,
|
|
127
|
+
onSelectedOptionChange = _ref4.onSelectedOptionChange;
|
|
124
128
|
|
|
125
129
|
var _useI18n5 = useI18n(),
|
|
126
130
|
t = _useI18n5.t;
|
|
@@ -254,12 +258,18 @@ var ShareDialogTwoStepsConfirmationContainer = function ShareDialogTwoStepsConfi
|
|
|
254
258
|
link: link,
|
|
255
259
|
permissions: permissions,
|
|
256
260
|
onUpdateShareLinkPermissions: onUpdateShareLinkPermissions,
|
|
257
|
-
onRevokeLink: onRevokeLink
|
|
261
|
+
onRevokeLink: onRevokeLink,
|
|
262
|
+
pendingRecipients: pendingRecipients,
|
|
263
|
+
onPendingRecipientsChange: onPendingRecipientsChange,
|
|
264
|
+
selectedOption: selectedOption,
|
|
265
|
+
onSelectedOptionChange: onSelectedOptionChange
|
|
258
266
|
});
|
|
259
267
|
dialogActions = DialogActionsOnShare ? /*#__PURE__*/React.createElement(DialogActionsOnShare, {
|
|
260
268
|
link: link,
|
|
261
269
|
document: document,
|
|
262
|
-
documentType: documentType
|
|
270
|
+
documentType: documentType,
|
|
271
|
+
pendingRecipients: pendingRecipients,
|
|
272
|
+
selectedOption: selectedOption
|
|
263
273
|
}) : null;
|
|
264
274
|
} else if (status === 'confirmingRecipient') {
|
|
265
275
|
dialogTitle = t("Share.twoStepsConfirmation.title");
|
|
@@ -20,11 +20,6 @@ var styles = {
|
|
|
20
20
|
"error": "share__error___pwqPO",
|
|
21
21
|
"share-byemail-onlybylink": "share__share-byemail-onlybylink___29W-t",
|
|
22
22
|
"aligned-dropdown-button": "share__aligned-dropdown-button___3crgG",
|
|
23
|
-
"share-type-control": "share__share-type-control___1YoRr",
|
|
24
|
-
"select-wrapper": "share__select-wrapper___3XBKC",
|
|
25
|
-
"select-option": "share__select-option___3Jp8_",
|
|
26
|
-
"select-option-label": "share__select-option-label___1BWz_",
|
|
27
|
-
"select-option-desc": "share__select-option-desc___3jOnr",
|
|
28
23
|
"share-details-created": "share__share-details-created___z3nvO",
|
|
29
24
|
"share-details-perm": "share__share-details-perm___3HjxK",
|
|
30
25
|
"share-details-perm-desc": "share__share-details-perm-desc___3HyHu"
|
|
@@ -24,7 +24,8 @@ var ShareRecipientsInput = function ShareRecipientsInput(_ref) {
|
|
|
24
24
|
placeholder = _ref.placeholder,
|
|
25
25
|
onPick = _ref.onPick,
|
|
26
26
|
onRemove = _ref.onRemove,
|
|
27
|
-
disabled = _ref.disabled
|
|
27
|
+
disabled = _ref.disabled,
|
|
28
|
+
endAdornment = _ref.endAdornment;
|
|
28
29
|
var reachableContactsQuery = buildReachableContactsQuery();
|
|
29
30
|
var reachableContactsResult = useQueryAll(reachableContactsQuery.definition, reachableContactsQuery.options);
|
|
30
31
|
var unreachableContactsWithGroupsQuery = buildUnreachableContactsWithGroupsQuery();
|
|
@@ -71,7 +72,8 @@ var ShareRecipientsInput = function ShareRecipientsInput(_ref) {
|
|
|
71
72
|
recipients: recipients,
|
|
72
73
|
onPick: onPick,
|
|
73
74
|
onRemove: onRemove,
|
|
74
|
-
placeholder: placeholder
|
|
75
|
+
placeholder: placeholder,
|
|
76
|
+
endAdornment: endAdornment
|
|
75
77
|
});
|
|
76
78
|
};
|
|
77
79
|
|
|
@@ -81,7 +83,8 @@ ShareRecipientsInput.propTypes = {
|
|
|
81
83
|
placeholder: PropTypes.string,
|
|
82
84
|
onPick: PropTypes.func.isRequired,
|
|
83
85
|
onRemove: PropTypes.func.isRequired,
|
|
84
|
-
disabled: PropTypes.bool
|
|
86
|
+
disabled: PropTypes.bool,
|
|
87
|
+
endAdornment: PropTypes.node
|
|
85
88
|
};
|
|
86
89
|
ShareRecipientsInput.defaultProps = {
|
|
87
90
|
currentRecipients: [],
|