cozy-sharing 40.1.6 → 40.1.8
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 +8 -0
- package/dist/components/FederatedFolder/FederatedFolderModal.js +10 -12
- package/dist/components/FederatedFolder/FederatedFolderModal.spec.js +2 -2
- package/dist/components/Recipient/DowngradePermissionConfirmDialog.js +3 -12
- package/dist/components/Recipient/GroupRecipient.js +1 -4
- package/dist/components/Recipient/GroupRecipient.stories.js +3 -1
- package/dist/components/Recipient/GroupRecipientDetailWithAccess.js +1 -4
- package/dist/components/Recipient/GroupRecipientPermissions.js +5 -8
- package/dist/components/Recipient/GroupRecipientPermissions.stories.js +2 -0
- package/dist/components/Recipient/LinkRecipient.js +2 -6
- package/dist/components/Recipient/LinkRecipient.stories.js +4 -0
- package/dist/components/Recipient/LinkRecipientPermissions.js +13 -12
- package/dist/components/Recipient/LinkRecipientPermissions.stories.js +5 -1
- package/dist/components/Recipient/MemberRecipient.js +7 -6
- package/dist/components/Recipient/MemberRecipient.spec.js +7 -12
- package/dist/components/Recipient/MemberRecipientPermissions.js +28 -13
- package/dist/components/Recipient/MemberRecipientPermissions.spec.js +5 -14
- package/dist/components/Recipient/MemberRecipientPermissions.stories.js +2 -1
- package/dist/components/Recipient/OwnerRecipient.js +4 -17
- package/dist/components/Recipient/OwnerRecipient.stories.js +3 -1
- package/dist/components/Recipient/OwnerRecipientDefaultLite.js +1 -1
- package/dist/components/Recipient/PermissionTypeMenu.js +32 -155
- package/dist/components/Recipient/PermissionTypeMenuWrapper.js +37 -0
- package/dist/components/Recipient/{PermissionTypeMenu.spec.js → PermissionTypeMenuWrapper.spec.js} +2 -2
- package/dist/components/Recipient/RecipientList.js +10 -0
- package/dist/components/Recipient/RecipientList.stories.js +3 -0
- package/dist/components/{ShareRecipientsInput.js → ShareAutosuggestWrapper.js} +12 -54
- package/dist/components/{ShareRecipientsInput.spec.js → ShareAutosuggestWrapper.spec.js} +3 -3
- package/dist/components/ShareByEmail.js +2 -2
- package/dist/components/ShareDialogCozyToCozy.js +20 -19
- package/dist/components/ShareDialogCozyToCozy.spec.js +3 -0
- package/dist/components/ShareDialogOnlyByLink.js +3 -5
- package/dist/components/ShareDialogOnlyByLink.spec.js +0 -1
- package/dist/components/ShareModal/SharingDetailsModal.js +2 -2
- package/dist/components/SharedDrive/EditSharedDriveModal.js +11 -10
- package/dist/components/SharedDrive/useSharedDrive.js +8 -11
- package/dist/components/SharingBanner/components/PublicBanner.js +8 -6
- package/dist/components/SharingBanner/components/PublicBanner.spec.js +1 -9
- package/dist/components/SharingBanner/components/SharingBanner.js +3 -0
- package/dist/components/SharingBanner/index.js +3 -0
- package/dist/components/SharingContent.js +3 -5
- package/dist/components/WhoHasAccess.js +27 -11
- package/dist/components/WhoHasAccessWrapper.js +122 -0
- package/dist/helpers/contacts.js +79 -1
- package/dist/helpers/contacts.spec.js +122 -1
- package/dist/helpers/recipients.js +46 -0
- package/dist/helpers/recipients.spec.js +89 -0
- package/dist/hooks/useMemberPermissionType.js +191 -0
- package/dist/hooks/useResolveRecipients.js +53 -0
- package/dist/hooks/useResolveRecipients.spec.js +140 -0
- package/dist/index.js +1 -1
- package/docs/share-modal-architecture.md +2 -2
- package/package.json +3 -3
- package/src/components/FederatedFolder/FederatedFolderModal.jsx +6 -12
- package/src/components/FederatedFolder/FederatedFolderModal.spec.jsx +1 -0
- package/src/components/Recipient/DowngradePermissionConfirmDialog.jsx +3 -10
- package/src/components/Recipient/GroupRecipient.jsx +1 -5
- package/src/components/Recipient/GroupRecipient.stories.jsx +3 -1
- package/src/components/Recipient/GroupRecipientDetailWithAccess.jsx +1 -4
- package/src/components/Recipient/GroupRecipientPermissions.jsx +5 -5
- package/src/components/Recipient/GroupRecipientPermissions.stories.jsx +2 -0
- package/src/components/Recipient/LinkRecipient.jsx +2 -4
- package/src/components/Recipient/LinkRecipient.stories.jsx +4 -0
- package/src/components/Recipient/LinkRecipientPermissions.jsx +16 -12
- package/src/components/Recipient/LinkRecipientPermissions.stories.jsx +5 -1
- package/src/components/Recipient/MemberRecipient.jsx +4 -4
- package/src/components/Recipient/MemberRecipient.spec.jsx +7 -10
- package/src/components/Recipient/MemberRecipientPermissions.jsx +29 -13
- package/src/components/Recipient/MemberRecipientPermissions.spec.jsx +5 -11
- package/src/components/Recipient/MemberRecipientPermissions.stories.jsx +2 -1
- package/src/components/Recipient/OwnerRecipient.jsx +4 -17
- package/src/components/Recipient/OwnerRecipient.stories.jsx +1 -1
- package/src/components/Recipient/OwnerRecipientDefaultLite.jsx +1 -1
- package/src/components/Recipient/PermissionTypeMenu.jsx +21 -81
- package/src/components/Recipient/PermissionTypeMenuWrapper.jsx +32 -0
- package/src/components/Recipient/{PermissionTypeMenu.spec.jsx → PermissionTypeMenuWrapper.spec.jsx} +2 -2
- package/src/components/Recipient/RecipientList.jsx +10 -0
- package/src/components/Recipient/RecipientList.stories.jsx +3 -0
- package/src/components/{ShareRecipientsInput.jsx → ShareAutosuggestWrapper.jsx} +14 -65
- package/src/components/{ShareRecipientsInput.spec.jsx → ShareAutosuggestWrapper.spec.jsx} +3 -3
- package/src/components/ShareByEmail.jsx +2 -2
- package/src/components/ShareDialogCozyToCozy.jsx +10 -11
- package/src/components/ShareDialogCozyToCozy.spec.jsx +1 -0
- package/src/components/ShareDialogOnlyByLink.jsx +2 -4
- package/src/components/ShareDialogOnlyByLink.spec.jsx +0 -1
- package/src/components/ShareModal/SharingDetailsModal.jsx +2 -2
- package/src/components/SharedDrive/EditSharedDriveModal.jsx +6 -11
- package/src/components/SharedDrive/useSharedDrive.js +4 -11
- package/src/components/SharingBanner/components/PublicBanner.jsx +6 -6
- package/src/components/SharingBanner/components/PublicBanner.spec.jsx +1 -8
- package/src/components/SharingBanner/components/SharingBanner.jsx +7 -1
- package/src/components/SharingBanner/index.jsx +4 -0
- package/src/components/SharingContent.jsx +2 -4
- package/src/components/WhoHasAccess.jsx +26 -12
- package/src/components/WhoHasAccessWrapper.jsx +117 -0
- package/src/helpers/contacts.js +83 -0
- package/src/helpers/contacts.spec.js +78 -1
- package/src/helpers/recipients.js +44 -0
- package/src/helpers/recipients.spec.js +82 -0
- package/src/hooks/useMemberPermissionType.js +110 -0
- package/src/hooks/useResolveRecipients.js +38 -0
- package/src/hooks/useResolveRecipients.spec.js +70 -0
- package/src/index.jsx +1 -1
- package/dist/components/Recipient/OwnerRecipientDefault.js +0 -27
- package/dist/components/Recipient/OwnerRecipientDefault.stories.js +0 -10
- package/src/components/Recipient/OwnerRecipientDefault.jsx +0 -37
- package/src/components/Recipient/OwnerRecipientDefault.stories.jsx +0 -13
|
@@ -7,7 +7,6 @@ var _excluded = ["showShareByLink", "showGenerateLinkButton", "autoOpenShareRest
|
|
|
7
7
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
9
|
import React, { useCallback, useMemo, useState } from 'react';
|
|
10
|
-
import { useClient } from 'cozy-client';
|
|
11
10
|
import Button from 'cozy-ui/transpiled/react/Buttons';
|
|
12
11
|
import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert';
|
|
13
12
|
import { useI18n } from 'twake-i18n';
|
|
@@ -15,10 +14,10 @@ import { default as DumbShareByLink } from './ShareByLink';
|
|
|
15
14
|
import ShareDialogTwoStepsConfirmationContainer from './ShareDialogTwoStepsConfirmationContainer';
|
|
16
15
|
import { ShareRecipientsLimitModal } from './ShareRecipientsLimitModal';
|
|
17
16
|
import SharingContent from './SharingContent';
|
|
18
|
-
import { getOrCreateFromArray } from '../helpers/contacts';
|
|
19
17
|
import { hasReachRecipientsLimit } from '../helpers/recipients';
|
|
20
18
|
import { getErrorMessage, getSuccessMessage } from '../helpers/share';
|
|
21
19
|
import { usePendingRecipients } from '../hooks/usePendingRecipients';
|
|
20
|
+
import { useResolveRecipients } from '../hooks/useResolveRecipients';
|
|
22
21
|
import { useSharingContext } from '../hooks/useSharingContext';
|
|
23
22
|
|
|
24
23
|
var SharingTitleFunction = function SharingTitleFunction(_ref) {
|
|
@@ -53,7 +52,7 @@ var ShareDialogCozyToCozy = function ShareDialogCozyToCozy(_ref2) {
|
|
|
53
52
|
var _useI18n2 = useI18n(),
|
|
54
53
|
t = _useI18n2.t;
|
|
55
54
|
|
|
56
|
-
var
|
|
55
|
+
var resolveRecipients = useResolveRecipients();
|
|
57
56
|
|
|
58
57
|
var _useAlert = useAlert(),
|
|
59
58
|
showAlert = _useAlert.showAlert;
|
|
@@ -79,7 +78,8 @@ var ShareDialogCozyToCozy = function ShareDialogCozyToCozy(_ref2) {
|
|
|
79
78
|
|
|
80
79
|
var displayedLink = getSharingLink(document._id || document.id);
|
|
81
80
|
var handleShare = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
82
|
-
var
|
|
81
|
+
var _yield$resolveRecipie2, readWriteRecipients, readOnlyRecipients, contacts;
|
|
82
|
+
|
|
83
83
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
84
84
|
while (1) switch (_context.prev = _context.next) {
|
|
85
85
|
case 0:
|
|
@@ -104,13 +104,14 @@ var ShareDialogCozyToCozy = function ShareDialogCozyToCozy(_ref2) {
|
|
|
104
104
|
setSubmitting(true);
|
|
105
105
|
_context.prev = 7;
|
|
106
106
|
_context.next = 10;
|
|
107
|
-
return
|
|
107
|
+
return resolveRecipients(pendingRecipients, selectedOption, createContact);
|
|
108
108
|
|
|
109
109
|
case 10:
|
|
110
|
-
|
|
111
|
-
readWriteRecipients =
|
|
112
|
-
readOnlyRecipients =
|
|
113
|
-
|
|
110
|
+
_yield$resolveRecipie2 = _context.sent;
|
|
111
|
+
readWriteRecipients = _yield$resolveRecipie2.recipients;
|
|
112
|
+
readOnlyRecipients = _yield$resolveRecipie2.readOnlyRecipients;
|
|
113
|
+
contacts = [].concat(_toConsumableArray(readWriteRecipients), _toConsumableArray(readOnlyRecipients));
|
|
114
|
+
_context.next = 16;
|
|
114
115
|
return onShare({
|
|
115
116
|
document: document,
|
|
116
117
|
recipients: readWriteRecipients,
|
|
@@ -119,18 +120,18 @@ var ShareDialogCozyToCozy = function ShareDialogCozyToCozy(_ref2) {
|
|
|
119
120
|
openSharing: readWriteRecipients.length > 0
|
|
120
121
|
});
|
|
121
122
|
|
|
122
|
-
case
|
|
123
|
+
case 16:
|
|
123
124
|
showAlert({
|
|
124
125
|
message: t.apply(void 0, _toConsumableArray(getSuccessMessage(recipients, contacts, documentType))),
|
|
125
126
|
severity: 'success',
|
|
126
127
|
variant: 'filled'
|
|
127
128
|
});
|
|
128
129
|
onClose();
|
|
129
|
-
_context.next =
|
|
130
|
+
_context.next = 23;
|
|
130
131
|
break;
|
|
131
132
|
|
|
132
|
-
case
|
|
133
|
-
_context.prev =
|
|
133
|
+
case 20:
|
|
134
|
+
_context.prev = 20;
|
|
134
135
|
_context.t0 = _context["catch"](7);
|
|
135
136
|
showAlert({
|
|
136
137
|
message: t.apply(void 0, _toConsumableArray(getErrorMessage({
|
|
@@ -144,17 +145,17 @@ var ShareDialogCozyToCozy = function ShareDialogCozyToCozy(_ref2) {
|
|
|
144
145
|
variant: 'filled'
|
|
145
146
|
});
|
|
146
147
|
|
|
147
|
-
case
|
|
148
|
-
_context.prev =
|
|
148
|
+
case 23:
|
|
149
|
+
_context.prev = 23;
|
|
149
150
|
setSubmitting(false);
|
|
150
|
-
return _context.finish(
|
|
151
|
+
return _context.finish(23);
|
|
151
152
|
|
|
152
|
-
case
|
|
153
|
+
case 26:
|
|
153
154
|
case "end":
|
|
154
155
|
return _context.stop();
|
|
155
156
|
}
|
|
156
|
-
}, _callee, null, [[7,
|
|
157
|
-
})), [pendingRecipients, selectedOption,
|
|
157
|
+
}, _callee, null, [[7, 20, 23, 26]]);
|
|
158
|
+
})), [pendingRecipients, selectedOption, resolveRecipients, showAlert, t, recipients, onShare, onClose, createContact, document, documentType, sharingDesc]);
|
|
158
159
|
var dialogActionsOnShare = useMemo(function () {
|
|
159
160
|
var Actions = function Actions(dialogActionProps) {
|
|
160
161
|
return /*#__PURE__*/React.createElement(React.Fragment, null, showShareByLink && /*#__PURE__*/React.createElement(DumbShareByLink, _extends({}, dialogActionProps, {
|
|
@@ -36,6 +36,9 @@ jest.mock('../hooks/useSharingContext', function () {
|
|
|
36
36
|
getSharingLink: jest.fn(function () {
|
|
37
37
|
return null;
|
|
38
38
|
}),
|
|
39
|
+
getDocumentPermissions: jest.fn(function () {
|
|
40
|
+
return [];
|
|
41
|
+
}),
|
|
39
42
|
updateSharingMemberType: jest.fn(),
|
|
40
43
|
isOrgSharedDrive: jest.fn(function () {
|
|
41
44
|
return false;
|
|
@@ -6,7 +6,7 @@ import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints';
|
|
|
6
6
|
import { useI18n } from 'twake-i18n';
|
|
7
7
|
import AntivirusAlert from './AntivirusAlert';
|
|
8
8
|
import { default as DumbShareByLink } from './ShareByLink';
|
|
9
|
-
import
|
|
9
|
+
import WhoHasAccessWrapper from './WhoHasAccessWrapper';
|
|
10
10
|
import { useSharingContext } from '../hooks/useSharingContext';
|
|
11
11
|
|
|
12
12
|
var ShareDialogOnlyByLink = function ShareDialogOnlyByLink(_ref) {
|
|
@@ -17,7 +17,6 @@ var ShareDialogOnlyByLink = function ShareDialogOnlyByLink(_ref) {
|
|
|
17
17
|
document = _ref.document,
|
|
18
18
|
documentType = _ref.documentType,
|
|
19
19
|
onClose = _ref.onClose,
|
|
20
|
-
permissions = _ref.permissions,
|
|
21
20
|
showGenerateLinkButton = _ref.showGenerateLinkButton,
|
|
22
21
|
autoOpenShareRestriction = _ref.autoOpenShareRestriction;
|
|
23
22
|
|
|
@@ -44,15 +43,14 @@ var ShareDialogOnlyByLink = function ShareDialogOnlyByLink(_ref) {
|
|
|
44
43
|
}), /*#__PURE__*/React.createElement(Typography, {
|
|
45
44
|
variant: "h6",
|
|
46
45
|
className: cx(isMobile ? 'u-ph-1 u-mt-1' : 'u-ph-2 u-mt-1-half')
|
|
47
|
-
}, t('Share.contacts.whoHasAccess')), /*#__PURE__*/React.createElement(
|
|
46
|
+
}, t('Share.contacts.whoHasAccess')), /*#__PURE__*/React.createElement(WhoHasAccessWrapper, {
|
|
48
47
|
document: document,
|
|
49
48
|
documentType: documentType,
|
|
50
49
|
isOwner: isOwner,
|
|
51
50
|
onRevoke: onRevoke,
|
|
52
51
|
onRevokeSelf: onRevokeSelf,
|
|
53
52
|
recipients: recipients,
|
|
54
|
-
link: displayedLink
|
|
55
|
-
permissions: permissions
|
|
53
|
+
link: displayedLink
|
|
56
54
|
}), /*#__PURE__*/React.createElement("div", {
|
|
57
55
|
className: cx('u-mt-half', isMobile ? 'u-ph-1 u-mb-1' : 'u-ph-2 u-mb-1-half')
|
|
58
56
|
}, /*#__PURE__*/React.createElement(DumbShareByLink, {
|
|
@@ -22,7 +22,7 @@ var styles = {
|
|
|
22
22
|
"aligned-dropdown-button": "share__aligned-dropdown-button___3crgG"
|
|
23
23
|
};
|
|
24
24
|
import ShareByLink from '../ShareByLink';
|
|
25
|
-
import
|
|
25
|
+
import WhoHasAccessWrapper from '../WhoHasAccessWrapper';
|
|
26
26
|
export var SharingDetailsModal = function SharingDetailsModal(_ref) {
|
|
27
27
|
var recipients = _ref.recipients,
|
|
28
28
|
document = _ref.document,
|
|
@@ -49,7 +49,7 @@ export var SharingDetailsModal = function SharingDetailsModal(_ref) {
|
|
|
49
49
|
title: t("".concat(documentType, ".share.details.title")),
|
|
50
50
|
content: /*#__PURE__*/React.createElement("div", {
|
|
51
51
|
className: styles['share-modal-content']
|
|
52
|
-
}, /*#__PURE__*/React.createElement(
|
|
52
|
+
}, /*#__PURE__*/React.createElement(WhoHasAccessWrapper, {
|
|
53
53
|
canManageMembers: false,
|
|
54
54
|
canManageLink: isSharedDrive,
|
|
55
55
|
isSharedDrive: isSharedDrive,
|
|
@@ -17,9 +17,9 @@ import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
|
17
17
|
import { useSubmitWithLoader } from 'cozy-ui/transpiled/react/hooks/useSubmitWithLoader';
|
|
18
18
|
import { useI18n } from 'twake-i18n';
|
|
19
19
|
import SharedDriveHeader from './SharedDriveHeader';
|
|
20
|
-
import { getOrCreateFromArray } from '../../helpers/contacts';
|
|
21
20
|
import withLocales from '../../hoc/withLocales';
|
|
22
21
|
import { usePendingRecipients } from '../../hooks/usePendingRecipients';
|
|
22
|
+
import { useResolveRecipients } from '../../hooks/useResolveRecipients';
|
|
23
23
|
import { useSharingContext } from '../../hooks/useSharingContext';
|
|
24
24
|
var styles = {
|
|
25
25
|
"share-modal-content": "share__share-modal-content___1iqEq",
|
|
@@ -40,7 +40,7 @@ var styles = {
|
|
|
40
40
|
"aligned-dropdown-button": "share__aligned-dropdown-button___3crgG"
|
|
41
41
|
};
|
|
42
42
|
import { default as DumbShareByEmail } from '../ShareByEmail';
|
|
43
|
-
import
|
|
43
|
+
import WhoHasAccessWrapper from '../WhoHasAccessWrapper';
|
|
44
44
|
export var EditSharedDriveModal = withLocales(function (_ref) {
|
|
45
45
|
var onClose = _ref.onClose,
|
|
46
46
|
document = _ref.document;
|
|
@@ -64,6 +64,8 @@ export var EditSharedDriveModal = withLocales(function (_ref) {
|
|
|
64
64
|
onSubmit = _useSubmitWithLoader.onSubmit,
|
|
65
65
|
isLoading = _useSubmitWithLoader.isLoading;
|
|
66
66
|
|
|
67
|
+
var resolveRecipients = useResolveRecipients();
|
|
68
|
+
|
|
67
69
|
var _useState = useState(document.name),
|
|
68
70
|
_useState2 = _slicedToArray(_useState, 2),
|
|
69
71
|
driveName = _useState2[0],
|
|
@@ -71,19 +73,18 @@ export var EditSharedDriveModal = withLocales(function (_ref) {
|
|
|
71
73
|
|
|
72
74
|
var onSave = /*#__PURE__*/function () {
|
|
73
75
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
74
|
-
var
|
|
76
|
+
var _yield$resolveRecipie, readWriteRecipients, readOnlyRecipients;
|
|
77
|
+
|
|
75
78
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
76
79
|
while (1) switch (_context.prev = _context.next) {
|
|
77
80
|
case 0:
|
|
78
81
|
_context.next = 2;
|
|
79
|
-
return
|
|
80
|
-
return client.create('io.cozy.contacts', contact);
|
|
81
|
-
});
|
|
82
|
+
return resolveRecipients(pendingRecipients, selectedOption);
|
|
82
83
|
|
|
83
84
|
case 2:
|
|
84
|
-
|
|
85
|
-
readWriteRecipients =
|
|
86
|
-
readOnlyRecipients =
|
|
85
|
+
_yield$resolveRecipie = _context.sent;
|
|
86
|
+
readWriteRecipients = _yield$resolveRecipie.recipients;
|
|
87
|
+
readOnlyRecipients = _yield$resolveRecipie.readOnlyRecipients;
|
|
87
88
|
_context.next = 7;
|
|
88
89
|
return share({
|
|
89
90
|
document: document,
|
|
@@ -156,7 +157,7 @@ export var EditSharedDriveModal = withLocales(function (_ref) {
|
|
|
156
157
|
onPendingRecipientsChange: setPendingRecipients,
|
|
157
158
|
selectedOption: selectedOption,
|
|
158
159
|
onSelectedOptionChange: setSelectedOption
|
|
159
|
-
})), /*#__PURE__*/React.createElement(
|
|
160
|
+
})), /*#__PURE__*/React.createElement(WhoHasAccessWrapper, {
|
|
160
161
|
isOwner: true,
|
|
161
162
|
isSharedDrive: true,
|
|
162
163
|
showOwner: false,
|
|
@@ -3,11 +3,11 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
4
|
import { useState } from 'react';
|
|
5
5
|
import { useClient } from 'cozy-client';
|
|
6
|
-
import { getOrCreateFromArray } from '../../helpers/contacts';
|
|
7
6
|
import { usePendingRecipients } from '../../hooks/usePendingRecipients';
|
|
8
|
-
import {
|
|
7
|
+
import { useResolveRecipients } from '../../hooks/useResolveRecipients';
|
|
9
8
|
export var useSharedDrive = function useSharedDrive() {
|
|
10
9
|
var client = useClient();
|
|
10
|
+
var resolveRecipients = useResolveRecipients();
|
|
11
11
|
|
|
12
12
|
var _useState = useState(''),
|
|
13
13
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -24,23 +24,20 @@ export var useSharedDrive = function useSharedDrive() {
|
|
|
24
24
|
setSharedDriveName(event.target.value);
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
var createContact = function createContact(contact) {
|
|
28
|
-
return client.create(DOCTYPE_CONTACTS, contact);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
27
|
var onCreate = /*#__PURE__*/function () {
|
|
32
28
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
33
|
-
var
|
|
29
|
+
var _yield$resolveRecipie, readWriteRecipients, readOnlyRecipients;
|
|
30
|
+
|
|
34
31
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
35
32
|
while (1) switch (_context.prev = _context.next) {
|
|
36
33
|
case 0:
|
|
37
34
|
_context.next = 2;
|
|
38
|
-
return
|
|
35
|
+
return resolveRecipients(pendingRecipients, selectedOption);
|
|
39
36
|
|
|
40
37
|
case 2:
|
|
41
|
-
|
|
42
|
-
readWriteRecipients =
|
|
43
|
-
readOnlyRecipients =
|
|
38
|
+
_yield$resolveRecipie = _context.sent;
|
|
39
|
+
readWriteRecipients = _yield$resolveRecipie.recipients;
|
|
40
|
+
readOnlyRecipients = _yield$resolveRecipie.readOnlyRecipients;
|
|
44
41
|
_context.next = 7;
|
|
45
42
|
return client.collection('io.cozy.sharings').createSharedDrive({
|
|
46
43
|
name: sharedDriveName,
|
|
@@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import snarkdown from 'snarkdown';
|
|
5
5
|
import { Icon, SyncCozy, ToTheCloud } from '@linagora/twake-icons';
|
|
6
|
-
import { useClient } from 'cozy-client';
|
|
7
6
|
import flag from 'cozy-flags';
|
|
8
7
|
import Alert from 'cozy-ui/transpiled/react/Alert';
|
|
9
8
|
import Avatar from 'cozy-ui/transpiled/react/Avatar';
|
|
@@ -20,14 +19,13 @@ var getPublicNameFromSharing = function getPublicNameFromSharing(sharing) {
|
|
|
20
19
|
};
|
|
21
20
|
|
|
22
21
|
var PublicBannerCozyToCozyContent = function PublicBannerCozyToCozyContent(_ref) {
|
|
23
|
-
var sharing = _ref.sharing
|
|
22
|
+
var sharing = _ref.sharing,
|
|
23
|
+
avatarURL = _ref.avatarURL;
|
|
24
24
|
|
|
25
25
|
var _useI18n = useI18n(),
|
|
26
26
|
t = _useI18n.t;
|
|
27
27
|
|
|
28
|
-
var client = useClient();
|
|
29
28
|
var name = getPublicNameFromSharing(sharing);
|
|
30
|
-
var avatarURL = "".concat(client.options.uri, "/public/avatar?fallback=initials");
|
|
31
29
|
var withAvatar = snarkdown(t('Share.banner.shared_from', {
|
|
32
30
|
name: name,
|
|
33
31
|
image: avatarURL
|
|
@@ -48,7 +46,8 @@ var PublicBannerCozyToCozyContent = function PublicBannerCozyToCozyContent(_ref)
|
|
|
48
46
|
};
|
|
49
47
|
|
|
50
48
|
PublicBannerCozyToCozyContent.propTypes = {
|
|
51
|
-
sharing: PropTypes.object.isRequired
|
|
49
|
+
sharing: PropTypes.object.isRequired,
|
|
50
|
+
avatarURL: PropTypes.string.isRequired
|
|
52
51
|
};
|
|
53
52
|
|
|
54
53
|
var openExternalLink = function openExternalLink(url) {
|
|
@@ -57,6 +56,7 @@ var openExternalLink = function openExternalLink(url) {
|
|
|
57
56
|
|
|
58
57
|
var SharingBannerCozyToCozy = function SharingBannerCozyToCozy(_ref2) {
|
|
59
58
|
var sharing = _ref2.sharing,
|
|
59
|
+
avatarURL = _ref2.avatarURL,
|
|
60
60
|
isSharingShortcutCreated = _ref2.isSharingShortcutCreated,
|
|
61
61
|
addSharingLink = _ref2.addSharingLink,
|
|
62
62
|
onClose = _ref2.onClose;
|
|
@@ -101,7 +101,8 @@ var SharingBannerCozyToCozy = function SharingBannerCozyToCozy(_ref2) {
|
|
|
101
101
|
onClick: onClose
|
|
102
102
|
}))
|
|
103
103
|
}, /*#__PURE__*/React.createElement(PublicBannerCozyToCozyContent, {
|
|
104
|
-
sharing: sharing
|
|
104
|
+
sharing: sharing,
|
|
105
|
+
avatarURL: avatarURL
|
|
105
106
|
}));
|
|
106
107
|
};
|
|
107
108
|
|
|
@@ -168,6 +169,7 @@ SharingBannerByLink.propTypes = {
|
|
|
168
169
|
};
|
|
169
170
|
SharingBannerCozyToCozy.propTypes = {
|
|
170
171
|
sharing: PropTypes.object.isRequired,
|
|
172
|
+
avatarURL: PropTypes.string.isRequired,
|
|
171
173
|
isSharingShortcutCreated: PropTypes.bool.isRequired,
|
|
172
174
|
addSharingLink: PropTypes.string.isRequired,
|
|
173
175
|
onClose: PropTypes.func.isRequired
|
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
import { render } from '@testing-library/react';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { useClient } from 'cozy-client';
|
|
4
3
|
import { BreakpointsProvider } from 'cozy-ui/transpiled/react/providers/Breakpoints';
|
|
5
4
|
import { useI18n } from 'twake-i18n';
|
|
6
5
|
import { SharingBannerCozyToCozy } from './PublicBanner';
|
|
7
6
|
jest.mock('twake-i18n');
|
|
8
|
-
jest.mock('cozy-client');
|
|
9
7
|
describe('PublicBanner', function () {
|
|
10
|
-
beforeEach(function () {
|
|
11
|
-
useClient.mockReturnValue({
|
|
12
|
-
options: {
|
|
13
|
-
uri: 'http://cozy.localhost:8080'
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
8
|
it('should not add dangerous html', function () {
|
|
18
9
|
// Given
|
|
19
10
|
useI18n.mockReturnValue({
|
|
@@ -36,6 +27,7 @@ describe('PublicBanner', function () {
|
|
|
36
27
|
|
|
37
28
|
var _render = render( /*#__PURE__*/React.createElement(BreakpointsProvider, null, /*#__PURE__*/React.createElement(SharingBannerCozyToCozy, {
|
|
38
29
|
sharing: sharing,
|
|
30
|
+
avatarURL: "http://cozy.localhost:8080/public/avatar?fallback=initials",
|
|
39
31
|
isSharingShortcutCreated: true,
|
|
40
32
|
addSharingLink: "discoveryLink",
|
|
41
33
|
onClose: function onClose() {}
|
|
@@ -4,6 +4,7 @@ import React, { useState, useCallback } from 'react';
|
|
|
4
4
|
import { SharingBannerByLink, SharingBannerCozyToCozy } from './PublicBanner';
|
|
5
5
|
export var SharingBanner = function SharingBanner(_ref) {
|
|
6
6
|
var sharingInfos = _ref.sharingInfos,
|
|
7
|
+
avatarURL = _ref.avatarURL,
|
|
7
8
|
hideCreateCozyAction = _ref.hideCreateCozyAction;
|
|
8
9
|
|
|
9
10
|
var _useState = useState(true),
|
|
@@ -25,12 +26,14 @@ export var SharingBanner = function SharingBanner(_ref) {
|
|
|
25
26
|
}) : /*#__PURE__*/React.createElement(SharingBannerCozyToCozy, {
|
|
26
27
|
isSharingShortcutCreated: isSharingShortcutCreated,
|
|
27
28
|
sharing: sharing,
|
|
29
|
+
avatarURL: avatarURL,
|
|
28
30
|
addSharingLink: addSharingLink,
|
|
29
31
|
onClose: onClose
|
|
30
32
|
}));
|
|
31
33
|
};
|
|
32
34
|
SharingBanner.propTypes = {
|
|
33
35
|
sharingInfos: PropTypes.object,
|
|
36
|
+
avatarURL: PropTypes.string,
|
|
34
37
|
hideCreateCozyAction: PropTypes.bool
|
|
35
38
|
};
|
|
36
39
|
export default SharingBanner;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { useClient } from 'cozy-client';
|
|
3
4
|
import { SharingBanner } from './components/SharingBanner';
|
|
4
5
|
import { useSharingInfos } from './hooks/useSharingInfos';
|
|
5
6
|
import withLocales from '../../hoc/withLocales';
|
|
@@ -7,9 +8,11 @@ import withLocales from '../../hoc/withLocales';
|
|
|
7
8
|
var Plugin = function Plugin(_ref) {
|
|
8
9
|
var previewPath = _ref.previewPath,
|
|
9
10
|
hideCreateCozyAction = _ref.hideCreateCozyAction;
|
|
11
|
+
var client = useClient();
|
|
10
12
|
var sharingInfos = useSharingInfos(previewPath);
|
|
11
13
|
return /*#__PURE__*/React.createElement(SharingBanner, {
|
|
12
14
|
sharingInfos: sharingInfos,
|
|
15
|
+
avatarURL: "".concat(client.options.uri, "/public/avatar?fallback=initials"),
|
|
13
16
|
hideCreateCozyAction: hideCreateCozyAction
|
|
14
17
|
});
|
|
15
18
|
};
|
|
@@ -5,7 +5,7 @@ import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints';
|
|
|
5
5
|
import { useI18n } from 'twake-i18n';
|
|
6
6
|
import AntivirusAlert from './AntivirusAlert';
|
|
7
7
|
import { default as DumbShareByEmail } from './ShareByEmail';
|
|
8
|
-
import
|
|
8
|
+
import WhoHasAccessWrapper from './WhoHasAccessWrapper';
|
|
9
9
|
var styles = {
|
|
10
10
|
"share-modal-content": "share__share-modal-content___1iqEq",
|
|
11
11
|
"coz-form": "share__coz-form___1ICST",
|
|
@@ -40,7 +40,6 @@ var SharingContent = function SharingContent(_ref) {
|
|
|
40
40
|
recipientsToBeConfirmed = _ref.recipientsToBeConfirmed,
|
|
41
41
|
verifyRecipient = _ref.verifyRecipient,
|
|
42
42
|
link = _ref.link,
|
|
43
|
-
permissions = _ref.permissions,
|
|
44
43
|
pendingRecipients = _ref.pendingRecipients,
|
|
45
44
|
onPendingRecipientsChange = _ref.onPendingRecipientsChange,
|
|
46
45
|
selectedOption = _ref.selectedOption,
|
|
@@ -75,7 +74,7 @@ var SharingContent = function SharingContent(_ref) {
|
|
|
75
74
|
selectedOption: selectedOption,
|
|
76
75
|
onSelectedOptionChange: onSelectedOptionChange,
|
|
77
76
|
enableCreateContact: true
|
|
78
|
-
})), showWhoHasAccess && /*#__PURE__*/React.createElement(
|
|
77
|
+
})), showWhoHasAccess && /*#__PURE__*/React.createElement(WhoHasAccessWrapper, {
|
|
79
78
|
document: document,
|
|
80
79
|
documentType: documentType,
|
|
81
80
|
isOwner: isOwner,
|
|
@@ -84,8 +83,7 @@ var SharingContent = function SharingContent(_ref) {
|
|
|
84
83
|
recipients: recipients,
|
|
85
84
|
recipientsToBeConfirmed: recipientsToBeConfirmed,
|
|
86
85
|
verifyRecipient: verifyRecipient,
|
|
87
|
-
link: link
|
|
88
|
-
permissions: permissions
|
|
86
|
+
link: link
|
|
89
87
|
}));
|
|
90
88
|
};
|
|
91
89
|
|
|
@@ -6,7 +6,6 @@ import LinkRecipient from './Recipient/LinkRecipient';
|
|
|
6
6
|
import OwnerRecipient from './Recipient/OwnerRecipient';
|
|
7
7
|
import { RecipientList } from './Recipient/RecipientList';
|
|
8
8
|
import { usePrevious } from '../helpers/hooks';
|
|
9
|
-
import { useSharingContext } from '../hooks/useSharingContext';
|
|
10
9
|
/**
|
|
11
10
|
* Displays a warning if some contacts are waiting for confirmation of their sharing
|
|
12
11
|
*
|
|
@@ -43,6 +42,10 @@ var WhoHasAccess = function WhoHasAccess(_ref2) {
|
|
|
43
42
|
canManageLink = _ref2$canManageLink === void 0 ? canManageMembers : _ref2$canManageLink,
|
|
44
43
|
_ref2$showOwner = _ref2.showOwner,
|
|
45
44
|
showOwner = _ref2$showOwner === void 0 ? true : _ref2$showOwner,
|
|
45
|
+
owner = _ref2.owner,
|
|
46
|
+
_ref2$isInsideSharedP = _ref2.isInsideSharedParent,
|
|
47
|
+
isInsideSharedParent = _ref2$isInsideSharedP === void 0 ? false : _ref2$isInsideSharedP,
|
|
48
|
+
sharedParentName = _ref2.sharedParentName,
|
|
46
49
|
recipients = _ref2.recipients,
|
|
47
50
|
_ref2$recipientsToBeC = _ref2.recipientsToBeConfirmed,
|
|
48
51
|
recipientsToBeConfirmed = _ref2$recipientsToBeC === void 0 ? [] : _ref2$recipientsToBeC,
|
|
@@ -51,17 +54,16 @@ var WhoHasAccess = function WhoHasAccess(_ref2) {
|
|
|
51
54
|
className = _ref2.className,
|
|
52
55
|
onRevoke = _ref2.onRevoke,
|
|
53
56
|
onRevokeSelf = _ref2.onRevokeSelf,
|
|
54
|
-
|
|
57
|
+
onRevokeGroup = _ref2.onRevokeGroup,
|
|
58
|
+
onLeaveGroup = _ref2.onLeaveGroup,
|
|
59
|
+
onSetMemberType = _ref2.onSetMemberType,
|
|
60
|
+
onUpdateLinkPermissions = _ref2.onUpdateLinkPermissions,
|
|
61
|
+
onRevokeLink = _ref2.onRevokeLink,
|
|
55
62
|
verifyRecipient = _ref2.verifyRecipient,
|
|
56
63
|
link = _ref2.link,
|
|
57
64
|
permissions = _ref2.permissions;
|
|
58
65
|
var previousLink = usePrevious(link);
|
|
59
66
|
var linkHasBeenJustCreated = link && previousLink === null;
|
|
60
|
-
|
|
61
|
-
var _useSharingContext = useSharingContext(),
|
|
62
|
-
isOrgSharedDrive = _useSharingContext.isOrgSharedDrive;
|
|
63
|
-
|
|
64
|
-
var isOrgDrive = isOrgSharedDrive(document === null || document === void 0 ? void 0 : document._id);
|
|
65
67
|
return /*#__PURE__*/React.createElement("div", {
|
|
66
68
|
className: className
|
|
67
69
|
}, /*#__PURE__*/React.createElement(RecipientWaitingForConfirmationAlert, {
|
|
@@ -73,10 +75,11 @@ var WhoHasAccess = function WhoHasAccess(_ref2) {
|
|
|
73
75
|
onRevoke: onRevoke,
|
|
74
76
|
onRevokeSelf: onRevokeSelf,
|
|
75
77
|
permissions: permissions,
|
|
78
|
+
onUpdateLinkPermissions: onUpdateLinkPermissions,
|
|
79
|
+
onRevokeLink: onRevokeLink,
|
|
76
80
|
fadeIn: linkHasBeenJustCreated
|
|
77
81
|
}), showOwner && /*#__PURE__*/React.createElement(OwnerRecipient, {
|
|
78
|
-
|
|
79
|
-
isOrgSharedDrive: isOrgDrive
|
|
82
|
+
owner: owner
|
|
80
83
|
}), /*#__PURE__*/React.createElement(RecipientList, {
|
|
81
84
|
recipients: recipients,
|
|
82
85
|
recipientsToBeConfirmed: recipientsToBeConfirmed,
|
|
@@ -86,9 +89,13 @@ var WhoHasAccess = function WhoHasAccess(_ref2) {
|
|
|
86
89
|
isSharedDrive: isSharedDrive,
|
|
87
90
|
document: document,
|
|
88
91
|
documentType: documentType,
|
|
92
|
+
isInsideSharedParent: isInsideSharedParent,
|
|
93
|
+
sharedParentName: sharedParentName,
|
|
89
94
|
onRevoke: onRevoke,
|
|
90
95
|
onRevokeSelf: onRevokeSelf,
|
|
91
|
-
|
|
96
|
+
onRevokeGroup: onRevokeGroup,
|
|
97
|
+
onLeaveGroup: onLeaveGroup,
|
|
98
|
+
onSetMemberType: onSetMemberType,
|
|
92
99
|
verifyRecipient: verifyRecipient
|
|
93
100
|
})));
|
|
94
101
|
};
|
|
@@ -99,6 +106,9 @@ WhoHasAccess.propTypes = {
|
|
|
99
106
|
canManageMembers: PropTypes.bool,
|
|
100
107
|
canManageLink: PropTypes.bool,
|
|
101
108
|
showOwner: PropTypes.bool,
|
|
109
|
+
owner: PropTypes.object,
|
|
110
|
+
isInsideSharedParent: PropTypes.bool,
|
|
111
|
+
sharedParentName: PropTypes.string,
|
|
102
112
|
recipients: PropTypes.array.isRequired,
|
|
103
113
|
recipientsToBeConfirmed: PropTypes.arrayOf(PropTypes.shape({
|
|
104
114
|
email: PropTypes.string.isRequired
|
|
@@ -107,6 +117,12 @@ WhoHasAccess.propTypes = {
|
|
|
107
117
|
documentType: PropTypes.string.isRequired,
|
|
108
118
|
onRevoke: PropTypes.func.isRequired,
|
|
109
119
|
onRevokeSelf: PropTypes.func,
|
|
110
|
-
|
|
120
|
+
onRevokeGroup: PropTypes.func.isRequired,
|
|
121
|
+
onLeaveGroup: PropTypes.func.isRequired,
|
|
122
|
+
onSetMemberType: PropTypes.func.isRequired,
|
|
123
|
+
onUpdateLinkPermissions: PropTypes.func.isRequired,
|
|
124
|
+
onRevokeLink: PropTypes.func.isRequired,
|
|
125
|
+
verifyRecipient: PropTypes.func,
|
|
126
|
+
permissions: PropTypes.arrayOf(PropTypes.object)
|
|
111
127
|
};
|
|
112
128
|
export default WhoHasAccess;
|