cozy-sharing 4.9.0 → 6.0.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 +90 -0
- package/dist/SharedRecipients.js +1 -1
- package/dist/SharedStatus.js +1 -1
- package/dist/SharingBanner/hooks/useSharingInfos.js +1 -1
- package/dist/SharingDetailsModal.js +1 -1
- package/dist/SharingOwnerAvatar.js +1 -1
- package/dist/SharingProvider.js +21 -8
- package/dist/components/ContactSuggestion.js +15 -27
- package/dist/components/EditLinkPermissionDialog.js +72 -0
- package/dist/components/EditLinkPermissionDialog.spec.js +48 -0
- package/dist/components/EditableSharingModal.js +15 -62
- package/dist/components/{AvatarPlusX.js → Recipient/AvatarPlusX.js} +1 -1
- package/dist/components/{Identity.js → Recipient/Identity.js} +17 -16
- package/dist/components/Recipient/LinkRecipient.js +72 -0
- package/dist/components/Recipient/LinkRecipientPermissions.js +159 -0
- package/dist/components/Recipient/OwnerIdentity.js +44 -0
- package/dist/components/Recipient/Recipient.js +72 -0
- package/dist/components/{Recipient.spec.js → Recipient/Recipient.spec.js} +4 -45
- package/dist/components/Recipient/RecipientAvatar.js +33 -0
- package/dist/components/Recipient/RecipientConfirm.js +63 -0
- package/dist/components/Recipient/RecipientPermissions.js +126 -0
- package/dist/components/Recipient/RecipientPlusX.js +45 -0
- package/dist/components/Recipient/RecipientStatus.js +64 -0
- package/dist/components/Recipient/RecipientWithoutStatus.js +45 -0
- package/dist/components/Recipient/RecipientsAvatars.js +100 -0
- package/dist/components/{RecipientsAvatars.spec.js → Recipient/RecipientsAvatars.spec.js} +43 -2
- package/dist/components/{recipient.styl → Recipient/recipient.styl} +6 -2
- package/dist/components/ShareAutosuggest.js +176 -252
- package/dist/components/ShareAutosuggest.spec.js +3 -2
- package/dist/components/ShareByEmail.js +142 -193
- package/dist/components/ShareByEmail.spec.js +42 -23
- package/dist/components/ShareByLink.js +251 -357
- package/dist/components/ShareDialogCozyToCozy.js +16 -4
- package/dist/components/ShareDialogCozyToCozy.spec.js +12 -1
- package/dist/components/ShareDialogOnlyByLink.js +23 -10
- package/dist/components/ShareDialogTwoStepsConfirmationContainer.js +7 -7
- package/dist/components/ShareModal.js +5 -1
- package/dist/components/ShareRecipientsInput.js +44 -128
- package/dist/components/WhoHasAccess.js +43 -5
- package/dist/components/WhoHasAccessLight.js +3 -19
- package/dist/components/autosuggest.styl +21 -36
- package/dist/components/badge.styl +1 -1
- package/dist/helpers/documentType.js +6 -0
- package/dist/helpers/hooks.js +8 -1
- package/dist/helpers/link.js +5 -0
- package/dist/helpers/permissions.js +8 -0
- package/dist/helpers/recipients.js +24 -0
- package/dist/helpers/sharings.js +72 -53
- package/dist/helpers/synchronousJobQueue.js +67 -0
- package/dist/helpers/synchronousJobQueue.spec.js +97 -0
- package/dist/index.js +2 -1
- package/dist/queries/queries.js +72 -0
- package/dist/share.styl +0 -15
- package/dist/stylesheet.css +68 -93
- package/locales/en.json +29 -41
- package/locales/fr.json +26 -39
- package/package.json +10 -10
- package/src/SharedRecipients.jsx +1 -1
- package/src/SharedStatus.jsx +1 -1
- package/src/SharingBanner/hooks/useSharingInfos.jsx +1 -1
- package/src/SharingDetailsModal.jsx +1 -1
- package/src/SharingOwnerAvatar.jsx +1 -1
- package/src/SharingProvider.jsx +17 -4
- package/src/components/ContactSuggestion.jsx +25 -10
- package/src/components/EditLinkPermissionDialog.jsx +89 -0
- package/src/components/EditLinkPermissionDialog.spec.jsx +52 -0
- package/src/components/EditableSharingModal.jsx +58 -100
- package/src/components/{AvatarPlusX.jsx → Recipient/AvatarPlusX.jsx} +1 -1
- package/src/components/{Identity.jsx → Recipient/Identity.jsx} +0 -0
- package/src/components/Recipient/LinkRecipient.jsx +59 -0
- package/src/components/Recipient/LinkRecipientPermissions.jsx +157 -0
- package/src/components/Recipient/OwnerIdentity.jsx +20 -0
- package/src/components/Recipient/Recipient.jsx +79 -0
- package/src/components/{Recipient.spec.jsx → Recipient/Recipient.spec.jsx} +4 -42
- package/src/components/Recipient/RecipientAvatar.jsx +38 -0
- package/src/components/Recipient/RecipientConfirm.jsx +37 -0
- package/src/components/Recipient/RecipientPermissions.jsx +114 -0
- package/src/components/Recipient/RecipientPlusX.jsx +28 -0
- package/src/components/Recipient/RecipientStatus.jsx +48 -0
- package/src/components/Recipient/RecipientWithoutStatus.jsx +21 -0
- package/src/components/Recipient/RecipientsAvatars.jsx +108 -0
- package/src/components/{RecipientsAvatars.spec.jsx → Recipient/RecipientsAvatars.spec.jsx} +43 -2
- package/src/components/{recipient.styl → Recipient/recipient.styl} +6 -2
- package/src/components/ShareAutosuggest.jsx +136 -127
- package/src/components/ShareAutosuggest.spec.jsx +12 -8
- package/src/components/ShareByEmail.jsx +65 -90
- package/src/components/ShareByEmail.spec.jsx +39 -11
- package/src/components/ShareByLink.jsx +146 -238
- package/src/components/ShareDialogCozyToCozy.jsx +14 -2
- package/src/components/ShareDialogCozyToCozy.spec.jsx +8 -1
- package/src/components/ShareDialogOnlyByLink.jsx +30 -13
- package/src/components/ShareDialogTwoStepsConfirmationContainer.jsx +5 -5
- package/src/components/ShareModal.jsx +5 -1
- package/src/components/ShareRecipientsInput.jsx +30 -44
- package/src/components/WhoHasAccess.jsx +85 -27
- package/src/components/WhoHasAccessLight.jsx +2 -1
- package/src/components/__snapshots__/ContactSuggestion.spec.jsx.snap +915 -132
- package/src/components/__snapshots__/ShareRecipientsInput.spec.jsx.snap +86 -102
- package/src/components/autosuggest.styl +21 -36
- package/src/components/badge.styl +1 -1
- package/src/helpers/documentType.js +6 -0
- package/src/helpers/hooks.js +11 -1
- package/src/helpers/link.js +4 -0
- package/src/helpers/permissions.js +15 -0
- package/src/helpers/recipients.js +21 -0
- package/src/helpers/sharings.js +15 -12
- package/src/helpers/synchronousJobQueue.js +22 -0
- package/src/helpers/synchronousJobQueue.spec.js +75 -0
- package/src/index.jsx +1 -0
- package/src/queries/queries.js +75 -0
- package/src/share.styl +0 -15
- package/dist/SharingBanner/helpers/queries.js +0 -12
- package/dist/components/ContactsAndGroupsDataLoader.js +0 -50
- package/dist/components/Recipient.js +0 -450
- package/src/SharingBanner/helpers/queries.js +0 -14
- package/src/components/ContactsAndGroupsDataLoader.jsx +0 -30
- package/src/components/Recipient.jsx +0 -415
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { useI18n } from 'cozy-ui/transpiled/react/I18n';
|
|
5
|
+
import ListItem from 'cozy-ui/transpiled/react/MuiCozyTheme/ListItem';
|
|
6
|
+
import ListItemIcon from 'cozy-ui/transpiled/react/MuiCozyTheme/ListItemIcon';
|
|
7
|
+
import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
|
|
8
|
+
import Icon from 'cozy-ui/transpiled/react/Icon';
|
|
9
|
+
import LinkIcon from 'cozy-ui/transpiled/react/Icons/Link';
|
|
10
|
+
import Circle from 'cozy-ui/transpiled/react/Circle';
|
|
11
|
+
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
12
|
+
import Fade from 'cozy-ui/transpiled/react/Fade';
|
|
13
|
+
import { FADE_IN_DURATION } from '../../helpers/recipients';
|
|
14
|
+
import RecipientConfirm from './RecipientConfirm';
|
|
15
|
+
import LinkRecipientPermissions from './LinkRecipientPermissions';
|
|
16
|
+
var styles = {
|
|
17
|
+
"CozyTheme--inverted": "recipient__CozyTheme--inverted___2Hb9c",
|
|
18
|
+
"CozyTheme--normal": "recipient__CozyTheme--normal___3WdEw",
|
|
19
|
+
"recipient": "recipient__recipient___2zWmH",
|
|
20
|
+
"recipients-list-light": "recipient__recipients-list-light___1-dkI",
|
|
21
|
+
"recipient-idents": "recipient__recipient-idents___3F3zL",
|
|
22
|
+
"recipient-status-icon": "recipient__recipient-status-icon___1GvS9",
|
|
23
|
+
"recipient-user": "recipient__recipient-user___3hOyK",
|
|
24
|
+
"recipient-details": "recipient__recipient-details___3fmFE",
|
|
25
|
+
"avatar": "recipient__avatar___2NIEb",
|
|
26
|
+
"link-recipient-icon-circle": "recipient__link-recipient-icon-circle___3gmgy",
|
|
27
|
+
"recipients-avatars": "recipient__recipients-avatars___MXhiL",
|
|
28
|
+
"--interactive": "recipient__--interactive___1gDjM",
|
|
29
|
+
"recipients-avatars--link": "recipient__recipients-avatars--link___2s02h",
|
|
30
|
+
"recipients-avatars--plusX": "recipient__recipients-avatars--plusX___WRllr",
|
|
31
|
+
"recipients-avatars--avatar": "recipient__recipients-avatars--avatar___3j3_A",
|
|
32
|
+
"spin": "recipient__spin___3_Uja",
|
|
33
|
+
"shake": "recipient__shake___TrWC0"
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
var LinkRecipient = function LinkRecipient(props) {
|
|
37
|
+
var _useI18n = useI18n(),
|
|
38
|
+
t = _useI18n.t;
|
|
39
|
+
|
|
40
|
+
var recipientConfirmationData = props.recipientConfirmationData,
|
|
41
|
+
verifyRecipient = props.verifyRecipient,
|
|
42
|
+
link = props.link,
|
|
43
|
+
fadeIn = props.fadeIn;
|
|
44
|
+
var RightPart = recipientConfirmationData ? /*#__PURE__*/React.createElement(RecipientConfirm, {
|
|
45
|
+
recipientConfirmationData: recipientConfirmationData,
|
|
46
|
+
verifyRecipient: verifyRecipient
|
|
47
|
+
}) : /*#__PURE__*/React.createElement(LinkRecipientPermissions, _extends({}, props, {
|
|
48
|
+
className: "u-flex-shrink-0"
|
|
49
|
+
}));
|
|
50
|
+
return /*#__PURE__*/React.createElement(Fade, {
|
|
51
|
+
in: true,
|
|
52
|
+
timeout: fadeIn ? FADE_IN_DURATION : 0
|
|
53
|
+
}, /*#__PURE__*/React.createElement(ListItem, {
|
|
54
|
+
disableGutters: true
|
|
55
|
+
}, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Circle, {
|
|
56
|
+
size: "small",
|
|
57
|
+
className: styles['link-recipient-icon-circle']
|
|
58
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
59
|
+
icon: LinkIcon
|
|
60
|
+
}))), /*#__PURE__*/React.createElement(ListItemText, {
|
|
61
|
+
primary: /*#__PURE__*/React.createElement(Typography, {
|
|
62
|
+
className: "u-ellipsis",
|
|
63
|
+
variant: "body1"
|
|
64
|
+
}, t('Share.recipients.anyoneWithTheLink')),
|
|
65
|
+
secondary: link
|
|
66
|
+
}), RightPart));
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
LinkRecipient.propTypes = {
|
|
70
|
+
link: PropTypes.string.isRequired
|
|
71
|
+
};
|
|
72
|
+
export default LinkRecipient;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
+
import React, { useState, useRef } from 'react';
|
|
5
|
+
import { useI18n } from 'cozy-ui/transpiled/react/I18n';
|
|
6
|
+
import DropdownButton from 'cozy-ui/transpiled/react/DropdownButton';
|
|
7
|
+
import ActionMenu, { ActionMenuItem, ActionMenuRadio } from 'cozy-ui/transpiled/react/ActionMenu';
|
|
8
|
+
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
9
|
+
import Icon from 'cozy-ui/transpiled/react/Icon';
|
|
10
|
+
import TrashIcon from 'cozy-ui/transpiled/react/Icons/Trash';
|
|
11
|
+
import Alerter from 'cozy-ui/transpiled/react/Alerter';
|
|
12
|
+
import Spinner from 'cozy-ui/transpiled/react/Spinner';
|
|
13
|
+
import { checkIsReadOnlyPermissions } from '../../helpers/permissions';
|
|
14
|
+
import { isOnlyReadOnlyLinkAllowed } from '../../helpers/link';
|
|
15
|
+
import logger from '../../logger';
|
|
16
|
+
|
|
17
|
+
var LinkRecipientPermissions = function LinkRecipientPermissions(_ref) {
|
|
18
|
+
var className = _ref.className,
|
|
19
|
+
document = _ref.document,
|
|
20
|
+
documentType = _ref.documentType,
|
|
21
|
+
permissions = _ref.permissions,
|
|
22
|
+
onChangePermissions = _ref.onChangePermissions,
|
|
23
|
+
onDisable = _ref.onDisable;
|
|
24
|
+
|
|
25
|
+
var _useI18n = useI18n(),
|
|
26
|
+
t = _useI18n.t;
|
|
27
|
+
|
|
28
|
+
var buttonRef = useRef();
|
|
29
|
+
|
|
30
|
+
var _useState = useState(false),
|
|
31
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
32
|
+
menuIsOpen = _useState2[0],
|
|
33
|
+
setMenuIsOpen = _useState2[1];
|
|
34
|
+
|
|
35
|
+
var _useState3 = useState(false),
|
|
36
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
37
|
+
loading = _useState4[0],
|
|
38
|
+
setLoading = _useState4[1];
|
|
39
|
+
|
|
40
|
+
var isReadOnlyPermissions = checkIsReadOnlyPermissions(permissions);
|
|
41
|
+
|
|
42
|
+
var toggleMenu = function toggleMenu() {
|
|
43
|
+
setMenuIsOpen(!menuIsOpen);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
var deleteShareLink = /*#__PURE__*/function () {
|
|
47
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
48
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
49
|
+
while (1) {
|
|
50
|
+
switch (_context.prev = _context.next) {
|
|
51
|
+
case 0:
|
|
52
|
+
_context.prev = 0;
|
|
53
|
+
setLoading(true);
|
|
54
|
+
_context.next = 4;
|
|
55
|
+
return onDisable(document);
|
|
56
|
+
|
|
57
|
+
case 4:
|
|
58
|
+
_context.next = 10;
|
|
59
|
+
break;
|
|
60
|
+
|
|
61
|
+
case 6:
|
|
62
|
+
_context.prev = 6;
|
|
63
|
+
_context.t0 = _context["catch"](0);
|
|
64
|
+
Alerter.error(t("".concat(documentType, ".share.error.revoke")));
|
|
65
|
+
logger.log(_context.t0);
|
|
66
|
+
|
|
67
|
+
case 10:
|
|
68
|
+
_context.prev = 10;
|
|
69
|
+
setLoading(false);
|
|
70
|
+
return _context.finish(10);
|
|
71
|
+
|
|
72
|
+
case 13:
|
|
73
|
+
case "end":
|
|
74
|
+
return _context.stop();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}, _callee, null, [[0, 6, 10, 13]]);
|
|
78
|
+
}));
|
|
79
|
+
|
|
80
|
+
return function deleteShareLink() {
|
|
81
|
+
return _ref2.apply(this, arguments);
|
|
82
|
+
};
|
|
83
|
+
}();
|
|
84
|
+
|
|
85
|
+
var updateLinkPermissions = function updateLinkPermissions(_ref3) {
|
|
86
|
+
var isReadOnly = _ref3.isReadOnly;
|
|
87
|
+
var verbs = isReadOnly ? ['GET'] : ['GET', 'POST', 'PUT', 'PATCH'];
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
onChangePermissions(document, verbs);
|
|
91
|
+
} catch (err) {
|
|
92
|
+
Alerter.error(t("".concat(documentType, ".share.shareByLink.permserror")));
|
|
93
|
+
logger.log(err);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
98
|
+
className: className
|
|
99
|
+
}, loading && /*#__PURE__*/React.createElement(Spinner, null), !loading && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DropdownButton, {
|
|
100
|
+
onClick: toggleMenu,
|
|
101
|
+
ref: buttonRef,
|
|
102
|
+
textVariant: "body2"
|
|
103
|
+
}, t("Share.type.".concat(isReadOnlyPermissions ? 'one-way' : 'two-way')).toLowerCase()), menuIsOpen && /*#__PURE__*/React.createElement(ActionMenu, {
|
|
104
|
+
onClose: toggleMenu,
|
|
105
|
+
popperOptions: {
|
|
106
|
+
placement: 'bottom-end',
|
|
107
|
+
strategy: 'fixed'
|
|
108
|
+
},
|
|
109
|
+
anchorElRef: buttonRef
|
|
110
|
+
}, /*#__PURE__*/React.createElement(ActionMenuItem, {
|
|
111
|
+
left: /*#__PURE__*/React.createElement(ActionMenuRadio, {
|
|
112
|
+
name: "permissionLinkMenu",
|
|
113
|
+
value: "true",
|
|
114
|
+
checked: isReadOnlyPermissions
|
|
115
|
+
}),
|
|
116
|
+
onClick: function onClick() {
|
|
117
|
+
toggleMenu();
|
|
118
|
+
updateLinkPermissions({
|
|
119
|
+
isReadOnly: true
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}, /*#__PURE__*/React.createElement(React.Fragment, null, (document === null || document === void 0 ? void 0 : document.type) === 'directory' ? t("Share.permissionLink.seeFolder") : t("Share.permissionLink.seeFile"), /*#__PURE__*/React.createElement(Typography, {
|
|
123
|
+
className: "u-mt-half",
|
|
124
|
+
variant: "caption",
|
|
125
|
+
color: "textSecondary"
|
|
126
|
+
}, t('Share.permissionLink.readDescription')))), !isOnlyReadOnlyLinkAllowed({
|
|
127
|
+
documentType: documentType
|
|
128
|
+
}) && /*#__PURE__*/React.createElement(ActionMenuItem, {
|
|
129
|
+
left: /*#__PURE__*/React.createElement(ActionMenuRadio, {
|
|
130
|
+
name: "permissionLinkMenu",
|
|
131
|
+
value: "false",
|
|
132
|
+
checked: !isReadOnlyPermissions
|
|
133
|
+
}),
|
|
134
|
+
onClick: function onClick() {
|
|
135
|
+
toggleMenu();
|
|
136
|
+
updateLinkPermissions({
|
|
137
|
+
isReadOnly: false
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}, /*#__PURE__*/React.createElement(React.Fragment, null, (document === null || document === void 0 ? void 0 : document.type) === 'directory' ? t("Share.permissionLink.modifyFolder") : t("Share.permissionLink.modifyFile"), /*#__PURE__*/React.createElement(Typography, {
|
|
141
|
+
className: "u-mt-half",
|
|
142
|
+
variant: "caption",
|
|
143
|
+
color: "textSecondary"
|
|
144
|
+
}, t('Share.permissionLink.writeDescription')))), /*#__PURE__*/React.createElement("hr", null), /*#__PURE__*/React.createElement(ActionMenuItem, {
|
|
145
|
+
left: /*#__PURE__*/React.createElement(Icon, {
|
|
146
|
+
icon: TrashIcon,
|
|
147
|
+
color: "var(--errorColor)"
|
|
148
|
+
}),
|
|
149
|
+
onClick: function onClick() {
|
|
150
|
+
toggleMenu();
|
|
151
|
+
deleteShareLink();
|
|
152
|
+
}
|
|
153
|
+
}, /*#__PURE__*/React.createElement(Typography, {
|
|
154
|
+
className: "u-error",
|
|
155
|
+
variant: "body1"
|
|
156
|
+
}, t('Share.permissionLink.deactivate'))))));
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export default LinkRecipientPermissions;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
|
+
var _excluded = ["url", "size"];
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import Avatar from 'cozy-ui/transpiled/react/Avatar';
|
|
5
|
+
var styles = {
|
|
6
|
+
"CozyTheme--inverted": "recipient__CozyTheme--inverted___2Hb9c",
|
|
7
|
+
"CozyTheme--normal": "recipient__CozyTheme--normal___3WdEw",
|
|
8
|
+
"recipient": "recipient__recipient___2zWmH",
|
|
9
|
+
"recipients-list-light": "recipient__recipients-list-light___1-dkI",
|
|
10
|
+
"recipient-idents": "recipient__recipient-idents___3F3zL",
|
|
11
|
+
"recipient-status-icon": "recipient__recipient-status-icon___1GvS9",
|
|
12
|
+
"recipient-user": "recipient__recipient-user___3hOyK",
|
|
13
|
+
"recipient-details": "recipient__recipient-details___3fmFE",
|
|
14
|
+
"avatar": "recipient__avatar___2NIEb",
|
|
15
|
+
"link-recipient-icon-circle": "recipient__link-recipient-icon-circle___3gmgy",
|
|
16
|
+
"recipients-avatars": "recipient__recipients-avatars___MXhiL",
|
|
17
|
+
"--interactive": "recipient__--interactive___1gDjM",
|
|
18
|
+
"recipients-avatars--link": "recipient__recipients-avatars--link___2s02h",
|
|
19
|
+
"recipients-avatars--plusX": "recipient__recipients-avatars--plusX___WRllr",
|
|
20
|
+
"recipients-avatars--avatar": "recipient__recipients-avatars--avatar___3j3_A",
|
|
21
|
+
"spin": "recipient__spin___3_Uja",
|
|
22
|
+
"shake": "recipient__shake___TrWC0"
|
|
23
|
+
};
|
|
24
|
+
import { getDisplayName, getInitials } from '../../models';
|
|
25
|
+
import Identity from './Identity';
|
|
26
|
+
|
|
27
|
+
var OwnerIdentity = function OwnerIdentity(_ref) {
|
|
28
|
+
var url = _ref.url,
|
|
29
|
+
size = _ref.size,
|
|
30
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
31
|
+
|
|
32
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
33
|
+
className: styles['avatar']
|
|
34
|
+
}, /*#__PURE__*/React.createElement(Avatar, {
|
|
35
|
+
text: getInitials(rest),
|
|
36
|
+
size: size,
|
|
37
|
+
textId: getDisplayName(rest)
|
|
38
|
+
}), /*#__PURE__*/React.createElement(Identity, {
|
|
39
|
+
name: getDisplayName(rest),
|
|
40
|
+
details: url
|
|
41
|
+
}));
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default OwnerIdentity;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["instance", "isOwner", "status", "recipientConfirmationData", "verifyRecipient", "fadeIn"];
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { useClient } from 'cozy-client';
|
|
7
|
+
import { useI18n } from 'cozy-ui/transpiled/react/I18n';
|
|
8
|
+
import ListItem from 'cozy-ui/transpiled/react/MuiCozyTheme/ListItem';
|
|
9
|
+
import ListItemIcon from 'cozy-ui/transpiled/react/MuiCozyTheme/ListItemIcon';
|
|
10
|
+
import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
|
|
11
|
+
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
12
|
+
import Fade from 'cozy-ui/transpiled/react/Fade';
|
|
13
|
+
import { FADE_IN_DURATION } from '../../helpers/recipients';
|
|
14
|
+
import { getDisplayName } from '../../models';
|
|
15
|
+
import RecipientConfirm from './RecipientConfirm';
|
|
16
|
+
import RecipientPermissions from './RecipientPermissions';
|
|
17
|
+
import RecipientAvatar from './RecipientAvatar';
|
|
18
|
+
import RecipientStatus from './RecipientStatus';
|
|
19
|
+
var DEFAULT_DISPLAY_NAME = 'Share.contacts.defaultDisplayName';
|
|
20
|
+
|
|
21
|
+
var Recipient = function Recipient(props) {
|
|
22
|
+
var _useI18n = useI18n(),
|
|
23
|
+
t = _useI18n.t;
|
|
24
|
+
|
|
25
|
+
var client = useClient();
|
|
26
|
+
|
|
27
|
+
var instance = props.instance,
|
|
28
|
+
isOwner = props.isOwner,
|
|
29
|
+
status = props.status,
|
|
30
|
+
recipientConfirmationData = props.recipientConfirmationData,
|
|
31
|
+
verifyRecipient = props.verifyRecipient,
|
|
32
|
+
fadeIn = props.fadeIn,
|
|
33
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
34
|
+
|
|
35
|
+
var isMe = isOwner && status === 'owner' || instance === client.options.uri;
|
|
36
|
+
var defaultDisplayName = t(DEFAULT_DISPLAY_NAME);
|
|
37
|
+
var name = getDisplayName(rest, defaultDisplayName);
|
|
38
|
+
var RightPart = recipientConfirmationData ? /*#__PURE__*/React.createElement(RecipientConfirm, {
|
|
39
|
+
recipientConfirmationData: recipientConfirmationData,
|
|
40
|
+
verifyRecipient: verifyRecipient
|
|
41
|
+
}) : /*#__PURE__*/React.createElement(RecipientPermissions, _extends({}, props, {
|
|
42
|
+
className: "u-flex-shrink-0"
|
|
43
|
+
}));
|
|
44
|
+
return /*#__PURE__*/React.createElement(Fade, {
|
|
45
|
+
in: true,
|
|
46
|
+
timeout: fadeIn ? FADE_IN_DURATION : 0
|
|
47
|
+
}, /*#__PURE__*/React.createElement(ListItem, {
|
|
48
|
+
disableGutters: true
|
|
49
|
+
}, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(RecipientAvatar, {
|
|
50
|
+
size: "small",
|
|
51
|
+
recipient: props
|
|
52
|
+
})), /*#__PURE__*/React.createElement(ListItemText, {
|
|
53
|
+
primary: /*#__PURE__*/React.createElement(Typography, {
|
|
54
|
+
className: "u-ellipsis",
|
|
55
|
+
variant: "body1"
|
|
56
|
+
}, isMe ? t('Share.recipients.you') : name),
|
|
57
|
+
secondary: /*#__PURE__*/React.createElement(RecipientStatus, {
|
|
58
|
+
status: status,
|
|
59
|
+
isMe: isMe,
|
|
60
|
+
instance: instance
|
|
61
|
+
})
|
|
62
|
+
}), RightPart));
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
Recipient.propTypes = {
|
|
66
|
+
instance: PropTypes.string,
|
|
67
|
+
isOwner: PropTypes.bool,
|
|
68
|
+
status: PropTypes.string,
|
|
69
|
+
recipientConfirmationData: PropTypes.object,
|
|
70
|
+
verifyRecipient: PropTypes.func
|
|
71
|
+
};
|
|
72
|
+
export default Recipient;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import Recipient
|
|
5
|
-
import AppLike from '
|
|
4
|
+
import Recipient from './Recipient';
|
|
5
|
+
import AppLike from '../../../test/AppLike';
|
|
6
6
|
import { createMockClient } from 'cozy-client';
|
|
7
7
|
import { render, fireEvent } from '@testing-library/react';
|
|
8
8
|
describe('Recipient component', function () {
|
|
@@ -74,7 +74,7 @@ describe('Recipient component', function () {
|
|
|
74
74
|
onRevoke: onRevoke,
|
|
75
75
|
onRevokeSelf: onRevokeSelf
|
|
76
76
|
}), getByText = _setup3.getByText;
|
|
77
|
-
fireEvent.click(getByText('
|
|
77
|
+
fireEvent.click(getByText('can change'));
|
|
78
78
|
fireEvent.click(getByText('Remove me from sharing'));
|
|
79
79
|
expect(onRevoke).not.toBeCalled();
|
|
80
80
|
expect(onRevokeSelf).toBeCalled();
|
|
@@ -104,7 +104,7 @@ describe('Recipient component', function () {
|
|
|
104
104
|
onRevoke: onRevoke,
|
|
105
105
|
onRevokeSelf: onRevokeSelf
|
|
106
106
|
}), getByText = _setup4.getByText;
|
|
107
|
-
fireEvent.click(getByText('
|
|
107
|
+
fireEvent.click(getByText('can change'));
|
|
108
108
|
fireEvent.click(getByText('Remove from sharing'));
|
|
109
109
|
expect(onRevoke).toBeCalled();
|
|
110
110
|
expect(onRevokeSelf).not.toBeCalled();
|
|
@@ -175,45 +175,4 @@ describe('Recipient component', function () {
|
|
|
175
175
|
email: 'me@bob.cozy.localhost'
|
|
176
176
|
});
|
|
177
177
|
});
|
|
178
|
-
});
|
|
179
|
-
describe('excludeMeAsOwnerFromRecipients', function () {
|
|
180
|
-
test('excludeMeAsOwnerFromRecipients behavior', function () {
|
|
181
|
-
var recipients = [{
|
|
182
|
-
status: 'owner',
|
|
183
|
-
instance: 'http://foo1.cozy.bar'
|
|
184
|
-
}, {
|
|
185
|
-
status: 'pending',
|
|
186
|
-
instance: 'http://foo2.cozy.bar'
|
|
187
|
-
}, {
|
|
188
|
-
status: 'pending',
|
|
189
|
-
instance: 'http://foo3.cozy.bar'
|
|
190
|
-
}];
|
|
191
|
-
var client = {
|
|
192
|
-
options: {
|
|
193
|
-
uri: 'http://foo2.cozy.bar'
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
expect(excludeMeAsOwnerFromRecipients({
|
|
197
|
-
recipients: recipients,
|
|
198
|
-
isOwner: true,
|
|
199
|
-
client: client
|
|
200
|
-
})).toEqual([{
|
|
201
|
-
status: 'pending',
|
|
202
|
-
instance: 'http://foo2.cozy.bar'
|
|
203
|
-
}, {
|
|
204
|
-
status: 'pending',
|
|
205
|
-
instance: 'http://foo3.cozy.bar'
|
|
206
|
-
}]);
|
|
207
|
-
expect(excludeMeAsOwnerFromRecipients({
|
|
208
|
-
recipients: recipients,
|
|
209
|
-
isOwner: false,
|
|
210
|
-
client: client
|
|
211
|
-
})).toEqual([{
|
|
212
|
-
status: 'owner',
|
|
213
|
-
instance: 'http://foo1.cozy.bar'
|
|
214
|
-
}, {
|
|
215
|
-
status: 'pending',
|
|
216
|
-
instance: 'http://foo3.cozy.bar'
|
|
217
|
-
}]);
|
|
218
|
-
});
|
|
219
178
|
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["recipient"];
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { useClient } from 'cozy-client';
|
|
6
|
+
import Avatar from 'cozy-ui/transpiled/react/Avatar';
|
|
7
|
+
import { getDisplayName, getInitials } from '../../models';
|
|
8
|
+
|
|
9
|
+
var RecipientAvatar = function RecipientAvatar(_ref) {
|
|
10
|
+
var recipient = _ref.recipient,
|
|
11
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
12
|
+
|
|
13
|
+
var client = useClient();
|
|
14
|
+
/**
|
|
15
|
+
* avatarPath is always the same for a recipient, but image
|
|
16
|
+
* can be different since the stack generate it on the fly.
|
|
17
|
+
* It can be "gray" during the first load depending of the
|
|
18
|
+
* status' sharing, but can become active (from the realtime)
|
|
19
|
+
* so we need a way to "refresh" the image. Passing the
|
|
20
|
+
* status in the url force the refresh of the image when the
|
|
21
|
+
* status changes
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
var image = recipient.avatarPath && recipient.status ? "".concat(client.options.uri).concat(recipient.avatarPath, "?v=").concat(recipient.status) : null;
|
|
25
|
+
return /*#__PURE__*/React.createElement(Avatar, _extends({
|
|
26
|
+
image: image,
|
|
27
|
+
text: getInitials(recipient),
|
|
28
|
+
textId: getDisplayName(recipient),
|
|
29
|
+
disabled: recipient.status === 'pending' || recipient.status === 'mail-not-send'
|
|
30
|
+
}, rest));
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export default RecipientAvatar;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { useI18n } from 'cozy-ui/transpiled/react/I18n';
|
|
4
|
+
import Button from 'cozy-ui/transpiled/react/Button';
|
|
5
|
+
var modalStyles = {
|
|
6
|
+
"share-modal-content": "share__share-modal-content___XTtaK",
|
|
7
|
+
"coz-form": "share__coz-form___33NYF",
|
|
8
|
+
"coz-form-group": "share__coz-form-group___1PLAZ",
|
|
9
|
+
"coz-form-desc": "share__coz-form-desc___-pmK5",
|
|
10
|
+
"coz-form-label": "share__coz-form-label___31jb0",
|
|
11
|
+
"coz-form-label--error": "share__coz-form-label--error___2EXCl",
|
|
12
|
+
"coz-form-errors": "share__coz-form-errors___1rk2R",
|
|
13
|
+
"coz-form-controls": "share__coz-form-controls___39Uwg",
|
|
14
|
+
"coz-form-controls--full": "share__coz-form-controls--full___1YpNp",
|
|
15
|
+
"coz-form-controls--dispatch": "share__coz-form-controls--dispatch___3JXzz",
|
|
16
|
+
"error": "share__error___6Ycal",
|
|
17
|
+
"CozyTheme--inverted": "share__CozyTheme--inverted___2pLD2",
|
|
18
|
+
"CozyTheme--normal": "share__CozyTheme--normal___qSFyr",
|
|
19
|
+
"share-byemail-onlybylink": "share__share-byemail-onlybylink___C_7b_",
|
|
20
|
+
"aligned-dropdown-button": "share__aligned-dropdown-button___CeTDs",
|
|
21
|
+
"share-type-control": "share__share-type-control___KcpDf",
|
|
22
|
+
"select-wrapper": "share__select-wrapper___3FfiH",
|
|
23
|
+
"select-option": "share__select-option___13o6b",
|
|
24
|
+
"select-option-label": "share__select-option-label___Zj_RU",
|
|
25
|
+
"select-option-desc": "share__select-option-desc___6uaQq",
|
|
26
|
+
"share-details-created": "share__share-details-created___13BO0",
|
|
27
|
+
"share-details-perm": "share__share-details-perm___23_VF",
|
|
28
|
+
"share-details-perm-desc": "share__share-details-perm-desc___tqfXx",
|
|
29
|
+
"spin": "share__spin___1P7nU",
|
|
30
|
+
"shake": "share__shake___1EeCI"
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Displays the confirmation interface that allows to confirm or reject a recipient
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
var RecipientConfirm = function RecipientConfirm(_ref) {
|
|
37
|
+
var recipientConfirmationData = _ref.recipientConfirmationData,
|
|
38
|
+
verifyRecipient = _ref.verifyRecipient;
|
|
39
|
+
|
|
40
|
+
var _useI18n = useI18n(),
|
|
41
|
+
t = _useI18n.t;
|
|
42
|
+
|
|
43
|
+
var verify = function verify() {
|
|
44
|
+
verifyRecipient(recipientConfirmationData);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
|
|
48
|
+
style: {
|
|
49
|
+
position: 'initial'
|
|
50
|
+
} // fix z-index bug on iOS when under a BottomDrawer due to relative position
|
|
51
|
+
,
|
|
52
|
+
theme: "text",
|
|
53
|
+
className: modalStyles['aligned-dropdown-button'],
|
|
54
|
+
onClick: verify,
|
|
55
|
+
label: t("Share.twoStepsConfirmation.verify")
|
|
56
|
+
}));
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
RecipientConfirm.propTypes = {
|
|
60
|
+
recipientConfirmationData: PropTypes.object.isRequired,
|
|
61
|
+
verifyRecipient: PropTypes.func.isRequired
|
|
62
|
+
};
|
|
63
|
+
export default RecipientConfirm;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
+
import React, { useState, useRef, useCallback } from 'react';
|
|
5
|
+
import { useClient } from 'cozy-client';
|
|
6
|
+
import { useI18n } from 'cozy-ui/transpiled/react/I18n';
|
|
7
|
+
import Spinner from 'cozy-ui/transpiled/react/Spinner';
|
|
8
|
+
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
9
|
+
import DropdownButton from 'cozy-ui/transpiled/react/DropdownButton';
|
|
10
|
+
import ActionMenu, { ActionMenuItem } from 'cozy-ui/transpiled/react/ActionMenu';
|
|
11
|
+
import Icon from 'cozy-ui/transpiled/react/Icon';
|
|
12
|
+
import RenameIcon from 'cozy-ui/transpiled/react/Icons/Rename';
|
|
13
|
+
import TrashIcon from 'cozy-ui/transpiled/react/Icons/Trash';
|
|
14
|
+
import EyeIcon from 'cozy-ui/transpiled/react/Icons/Eye';
|
|
15
|
+
|
|
16
|
+
var RecipientPermissions = function RecipientPermissions(_ref) {
|
|
17
|
+
var isOwner = _ref.isOwner,
|
|
18
|
+
status = _ref.status,
|
|
19
|
+
instance = _ref.instance,
|
|
20
|
+
type = _ref.type,
|
|
21
|
+
document = _ref.document,
|
|
22
|
+
documentType = _ref.documentType,
|
|
23
|
+
className = _ref.className,
|
|
24
|
+
onRevoke = _ref.onRevoke,
|
|
25
|
+
onRevokeSelf = _ref.onRevokeSelf,
|
|
26
|
+
sharingId = _ref.sharingId,
|
|
27
|
+
index = _ref.index;
|
|
28
|
+
|
|
29
|
+
var _useI18n = useI18n(),
|
|
30
|
+
t = _useI18n.t;
|
|
31
|
+
|
|
32
|
+
var buttonRef = useRef();
|
|
33
|
+
var client = useClient();
|
|
34
|
+
|
|
35
|
+
var _useState = useState(false),
|
|
36
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
37
|
+
revoking = _useState2[0],
|
|
38
|
+
setRevoking = _useState2[1];
|
|
39
|
+
|
|
40
|
+
var _useState3 = useState(false),
|
|
41
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
42
|
+
isMenuDisplayed = _useState4[0],
|
|
43
|
+
setIsMenuDisplayed = _useState4[1];
|
|
44
|
+
|
|
45
|
+
var instanceMatchesClient = instance !== undefined && instance === client.options.uri;
|
|
46
|
+
var contactIsOwner = status === 'owner';
|
|
47
|
+
var shouldShowMenu = !revoking && !contactIsOwner && (instanceMatchesClient && !isOwner || isOwner);
|
|
48
|
+
|
|
49
|
+
var showMenu = function showMenu() {
|
|
50
|
+
return setIsMenuDisplayed(true);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
var hideMenu = function hideMenu() {
|
|
54
|
+
return setIsMenuDisplayed(false);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
var onRevokeClick = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
58
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
59
|
+
while (1) {
|
|
60
|
+
switch (_context.prev = _context.next) {
|
|
61
|
+
case 0:
|
|
62
|
+
setRevoking(true);
|
|
63
|
+
|
|
64
|
+
if (!isOwner) {
|
|
65
|
+
_context.next = 6;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
_context.next = 4;
|
|
70
|
+
return onRevoke(document, sharingId, index);
|
|
71
|
+
|
|
72
|
+
case 4:
|
|
73
|
+
_context.next = 8;
|
|
74
|
+
break;
|
|
75
|
+
|
|
76
|
+
case 6:
|
|
77
|
+
_context.next = 8;
|
|
78
|
+
return onRevokeSelf(document);
|
|
79
|
+
|
|
80
|
+
case 8:
|
|
81
|
+
setRevoking(false);
|
|
82
|
+
|
|
83
|
+
case 9:
|
|
84
|
+
case "end":
|
|
85
|
+
return _context.stop();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}, _callee);
|
|
89
|
+
})), [isOwner, onRevoke, onRevokeSelf, document, sharingId, index]);
|
|
90
|
+
var PermissionIcon = type === 'two-way' ? RenameIcon : EyeIcon;
|
|
91
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
92
|
+
className: className
|
|
93
|
+
}, revoking && /*#__PURE__*/React.createElement(Spinner, null), !shouldShowMenu && !revoking && /*#__PURE__*/React.createElement(Typography, {
|
|
94
|
+
variant: "body2"
|
|
95
|
+
}, t("Share.status.".concat(status)).toLowerCase()), shouldShowMenu && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DropdownButton, {
|
|
96
|
+
onClick: showMenu,
|
|
97
|
+
ref: buttonRef,
|
|
98
|
+
textVariant: "body2"
|
|
99
|
+
}, t("Share.type.".concat(type)).toLowerCase()), isMenuDisplayed && /*#__PURE__*/React.createElement(ActionMenu, {
|
|
100
|
+
onClose: hideMenu,
|
|
101
|
+
popperOptions: {
|
|
102
|
+
placement: 'bottom-end',
|
|
103
|
+
strategy: 'fixed'
|
|
104
|
+
},
|
|
105
|
+
anchorElRef: buttonRef
|
|
106
|
+
}, /*#__PURE__*/React.createElement(ActionMenuItem, {
|
|
107
|
+
left: /*#__PURE__*/React.createElement(Icon, {
|
|
108
|
+
icon: PermissionIcon,
|
|
109
|
+
color: "var(--primaryTextColor)"
|
|
110
|
+
})
|
|
111
|
+
}, t("Share.type.".concat(type))), /*#__PURE__*/React.createElement("hr", null), /*#__PURE__*/React.createElement(ActionMenuItem, {
|
|
112
|
+
onClick: onRevokeClick,
|
|
113
|
+
left: /*#__PURE__*/React.createElement(Icon, {
|
|
114
|
+
icon: TrashIcon,
|
|
115
|
+
color: "var(--errorColor)"
|
|
116
|
+
})
|
|
117
|
+
}, /*#__PURE__*/React.createElement(Typography, {
|
|
118
|
+
className: "u-error",
|
|
119
|
+
variant: "body1"
|
|
120
|
+
}, isOwner ? t("".concat(documentType, ".share.revoke.title")) : t("".concat(documentType, ".share.revokeSelf.title"))), /*#__PURE__*/React.createElement(Typography, {
|
|
121
|
+
variant: "caption",
|
|
122
|
+
color: "textSecondary"
|
|
123
|
+
}, isOwner ? t("".concat(documentType, ".share.revoke.desc")) : t("".concat(documentType, ".share.revokeSelf.desc")))))));
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export default RecipientPermissions;
|