cozy-sharing 40.1.6 → 40.1.7
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 +4 -0
- package/dist/components/FederatedFolder/FederatedFolderModal.js +10 -12
- 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/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/SharingContent.js +3 -5
- package/dist/components/WhoHasAccess.js +27 -11
- package/dist/components/WhoHasAccessWrapper.js +122 -0
- 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/package.json +3 -3
- package/src/components/FederatedFolder/FederatedFolderModal.jsx +6 -12
- 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/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/SharingContent.jsx +2 -4
- package/src/components/WhoHasAccess.jsx +26 -12
- package/src/components/WhoHasAccessWrapper.jsx +117 -0
- 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
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [40.1.7](https://github.com/cozy/cozy-libs/compare/cozy-sharing@40.1.6...cozy-sharing@40.1.7) (2026-10-27)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package cozy-sharing
|
|
9
|
+
|
|
6
10
|
## [40.1.6](https://github.com/cozy/cozy-libs/compare/cozy-sharing@40.1.5...cozy-sharing@40.1.6) (2026-10-26)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package cozy-sharing
|
|
@@ -6,7 +6,6 @@ var _excluded = ["document"];
|
|
|
6
6
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
9
|
-
import { useClient } from 'cozy-client';
|
|
10
9
|
import minilog from 'cozy-minilog';
|
|
11
10
|
import Button from 'cozy-ui/transpiled/react/Buttons';
|
|
12
11
|
import { FixedDialog } from 'cozy-ui/transpiled/react/CozyDialogs';
|
|
@@ -14,9 +13,9 @@ import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
|
14
13
|
import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert';
|
|
15
14
|
import ConfirmDialogProvider, { useConfirmDialog } from 'cozy-ui/transpiled/react/providers/ConfirmDialog';
|
|
16
15
|
import { useI18n } from 'twake-i18n';
|
|
17
|
-
import { getOrCreateFromArray } from '../../helpers/contacts';
|
|
18
16
|
import withLocales from '../../hoc/withLocales';
|
|
19
17
|
import { usePendingRecipients } from '../../hooks/usePendingRecipients';
|
|
18
|
+
import { useResolveRecipients } from '../../hooks/useResolveRecipients';
|
|
20
19
|
import { useSharingContext } from '../../hooks/useSharingContext';
|
|
21
20
|
var styles = {
|
|
22
21
|
"share-modal-content": "share__share-modal-content___1iqEq",
|
|
@@ -39,7 +38,7 @@ var styles = {
|
|
|
39
38
|
import AntivirusAlert from '../AntivirusAlert';
|
|
40
39
|
import { default as DumbShareByEmail } from '../ShareByEmail';
|
|
41
40
|
import ShareByLink from '../ShareByLink';
|
|
42
|
-
import
|
|
41
|
+
import WhoHasAccessWrapper from '../WhoHasAccessWrapper';
|
|
43
42
|
var log = minilog('FederatedFolderModal');
|
|
44
43
|
|
|
45
44
|
var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
|
|
@@ -57,7 +56,7 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
|
|
|
57
56
|
// we close the popup and we do not want to see briefly the new contacts added
|
|
58
57
|
// in members before the modal closes. That's why when clicking on "Share"
|
|
59
58
|
// we do not use the reactive existingDocument and existingRecipients.
|
|
60
|
-
var
|
|
59
|
+
var resolveRecipients = useResolveRecipients();
|
|
61
60
|
|
|
62
61
|
var _useI18n = useI18n(),
|
|
63
62
|
t = _useI18n.t;
|
|
@@ -180,7 +179,8 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
|
|
|
180
179
|
|
|
181
180
|
var onSend = /*#__PURE__*/function () {
|
|
182
181
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
183
|
-
var
|
|
182
|
+
var _yield$resolveRecipie2, readWriteRecipients, readOnlyRecipients;
|
|
183
|
+
|
|
184
184
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
185
185
|
while (1) switch (_context2.prev = _context2.next) {
|
|
186
186
|
case 0:
|
|
@@ -198,14 +198,12 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
|
|
|
198
198
|
setFrozenRecipients(recipients);
|
|
199
199
|
_context2.prev = 6;
|
|
200
200
|
_context2.next = 9;
|
|
201
|
-
return
|
|
202
|
-
return client.create('io.cozy.contacts', contact);
|
|
203
|
-
});
|
|
201
|
+
return resolveRecipients(pendingRecipients, selectedOption);
|
|
204
202
|
|
|
205
203
|
case 9:
|
|
206
|
-
|
|
207
|
-
readWriteRecipients =
|
|
208
|
-
readOnlyRecipients =
|
|
204
|
+
_yield$resolveRecipie2 = _context2.sent;
|
|
205
|
+
readWriteRecipients = _yield$resolveRecipie2.recipients;
|
|
206
|
+
readOnlyRecipients = _yield$resolveRecipie2.readOnlyRecipients;
|
|
209
207
|
_context2.next = 14;
|
|
210
208
|
return share({
|
|
211
209
|
description: folderName,
|
|
@@ -336,7 +334,7 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
|
|
|
336
334
|
selectedOption: selectedOption,
|
|
337
335
|
onSelectedOptionChange: setSelectedOption,
|
|
338
336
|
enableCreateContact: true
|
|
339
|
-
}))), /*#__PURE__*/React.createElement(
|
|
337
|
+
}))), /*#__PURE__*/React.createElement(WhoHasAccessWrapper, {
|
|
340
338
|
isOwner: isCurrentUserOwner,
|
|
341
339
|
canManageSharing: canManageSharing,
|
|
342
340
|
isSharedDrive: true,
|
|
@@ -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, FolderOutlined, ArrowUp } from '@linagora/twake-icons';
|
|
6
|
-
import { useClient } from 'cozy-client';
|
|
7
6
|
import Button from 'cozy-ui/transpiled/react/Buttons';
|
|
8
7
|
import { ConfirmDialog } from 'cozy-ui/transpiled/react/CozyDialogs';
|
|
9
8
|
import Timeline from 'cozy-ui/transpiled/react/Timeline';
|
|
@@ -16,27 +15,18 @@ import TimelineSeparator from 'cozy-ui/transpiled/react/TimelineSeparator';
|
|
|
16
15
|
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
17
16
|
import { useI18n } from 'twake-i18n';
|
|
18
17
|
import { DEFAULT_DISPLAY_NAME } from '../../helpers/recipients';
|
|
19
|
-
import { useFetchDocumentPath } from '../../hooks/useFetchDocumentPath';
|
|
20
|
-
import { useSharingContext } from '../../hooks/useSharingContext';
|
|
21
18
|
import { getDisplayName } from '../../models';
|
|
22
19
|
|
|
23
20
|
var DowngradePermissionConfirmDialog = function DowngradePermissionConfirmDialog(_ref) {
|
|
24
21
|
var document = _ref.document,
|
|
25
22
|
recipient = _ref.recipient,
|
|
23
|
+
sharedParentName = _ref.sharedParentName,
|
|
26
24
|
onCancel = _ref.onCancel,
|
|
27
25
|
onConfirm = _ref.onConfirm;
|
|
28
26
|
|
|
29
27
|
var _useI18n = useI18n(),
|
|
30
28
|
t = _useI18n.t;
|
|
31
29
|
|
|
32
|
-
var client = useClient();
|
|
33
|
-
|
|
34
|
-
var _useSharingContext = useSharingContext(),
|
|
35
|
-
getSharedParentPath = _useSharingContext.getSharedParentPath;
|
|
36
|
-
|
|
37
|
-
var documentPath = useFetchDocumentPath(client, document);
|
|
38
|
-
var sharedParentPath = documentPath && getSharedParentPath(documentPath);
|
|
39
|
-
var parentFolderName = sharedParentPath === null || sharedParentPath === void 0 ? void 0 : sharedParentPath.split('/').pop();
|
|
40
30
|
var contactName = getDisplayName(recipient, t(DEFAULT_DISPLAY_NAME));
|
|
41
31
|
|
|
42
32
|
var _snarkdown$split = snarkdown(t('DowngradePermissionConfirmDialog.content', {
|
|
@@ -68,7 +58,7 @@ var DowngradePermissionConfirmDialog = function DowngradePermissionConfirmDialog
|
|
|
68
58
|
size: 24
|
|
69
59
|
}))), /*#__PURE__*/React.createElement(TimelineConnector, null)), /*#__PURE__*/React.createElement(TimelineContent, null, /*#__PURE__*/React.createElement(Typography, {
|
|
70
60
|
variant: "body2"
|
|
71
|
-
},
|
|
61
|
+
}, sharedParentName), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("s", null, /*#__PURE__*/React.createElement(Typography, {
|
|
72
62
|
display: "inline",
|
|
73
63
|
variant: "caption"
|
|
74
64
|
}, t('Share.type.two-way'))), /*#__PURE__*/React.createElement(Icon, {
|
|
@@ -123,6 +113,7 @@ var DowngradePermissionConfirmDialog = function DowngradePermissionConfirmDialog
|
|
|
123
113
|
DowngradePermissionConfirmDialog.propTypes = {
|
|
124
114
|
document: PropTypes.object.isRequired,
|
|
125
115
|
recipient: PropTypes.object.isRequired,
|
|
116
|
+
sharedParentName: PropTypes.string,
|
|
126
117
|
onCancel: PropTypes.func.isRequired,
|
|
127
118
|
onConfirm: PropTypes.func.isRequired
|
|
128
119
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import React, { useState } from 'react';
|
|
4
|
-
import { useClient } from 'cozy-client';
|
|
5
4
|
import Fade from 'cozy-ui/transpiled/react/Fade';
|
|
6
5
|
import ListItem from 'cozy-ui/transpiled/react/ListItem';
|
|
7
6
|
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
|
|
@@ -25,8 +24,6 @@ var GroupRecipient = function GroupRecipient(props) {
|
|
|
25
24
|
var _useI18n = useI18n(),
|
|
26
25
|
t = _useI18n.t;
|
|
27
26
|
|
|
28
|
-
var client = useClient();
|
|
29
|
-
|
|
30
27
|
var _useBreakpoints = useBreakpoints(),
|
|
31
28
|
isMobile = _useBreakpoints.isMobile;
|
|
32
29
|
|
|
@@ -40,7 +37,7 @@ var GroupRecipient = function GroupRecipient(props) {
|
|
|
40
37
|
return !['revoked', 'mail-not-sent'].includes(member.status);
|
|
41
38
|
}).length;
|
|
42
39
|
var isUserInsideMembers = members.some(function (member) {
|
|
43
|
-
return member.
|
|
40
|
+
return member.isCurrentUser;
|
|
44
41
|
});
|
|
45
42
|
|
|
46
43
|
var toogleDetailOpened = function toogleDetailOpened() {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { useClient } from 'cozy-client';
|
|
3
2
|
import Avatar from 'cozy-ui/transpiled/react/Avatar';
|
|
4
3
|
import List from 'cozy-ui/transpiled/react/List';
|
|
5
4
|
import ListItem from 'cozy-ui/transpiled/react/ListItem';
|
|
@@ -16,12 +15,10 @@ var GroupRecipientDetailWithAccess = function GroupRecipientDetailWithAccess(_re
|
|
|
16
15
|
var _useI18n = useI18n(),
|
|
17
16
|
t = _useI18n.t;
|
|
18
17
|
|
|
19
|
-
var client = useClient();
|
|
20
18
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Typography, {
|
|
21
19
|
variant: "subtitle2"
|
|
22
20
|
}, t('GroupRecipientDetail.withAccess.title')), /*#__PURE__*/React.createElement(List, null, withAccess.map(function (recipient) {
|
|
23
21
|
var name = getDisplayName(recipient);
|
|
24
|
-
var isMe = recipient.instance === client.options.uri;
|
|
25
22
|
return /*#__PURE__*/React.createElement(ListItem, {
|
|
26
23
|
disableGutters: true,
|
|
27
24
|
key: recipient.index,
|
|
@@ -32,7 +29,7 @@ var GroupRecipientDetailWithAccess = function GroupRecipientDetailWithAccess(_re
|
|
|
32
29
|
primary: name,
|
|
33
30
|
secondary: /*#__PURE__*/React.createElement(MemberRecipientStatus, {
|
|
34
31
|
status: recipient.status,
|
|
35
|
-
isMe:
|
|
32
|
+
isMe: Boolean(recipient.isCurrentUser),
|
|
36
33
|
instance: recipient.instance,
|
|
37
34
|
email: recipient.email,
|
|
38
35
|
name: recipient.name || recipient.public_name
|
|
@@ -14,7 +14,6 @@ import Spinner from 'cozy-ui/transpiled/react/Spinner';
|
|
|
14
14
|
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
15
15
|
import { useI18n } from 'twake-i18n';
|
|
16
16
|
import { permission } from './actions/permission';
|
|
17
|
-
import { useSharingContext } from '../../hooks/useSharingContext';
|
|
18
17
|
import { GroupAvatar } from '../Avatar/GroupAvatar';
|
|
19
18
|
|
|
20
19
|
var GroupRecipientPermissions = function GroupRecipientPermissions(_ref) {
|
|
@@ -29,17 +28,15 @@ var GroupRecipientPermissions = function GroupRecipientPermissions(_ref) {
|
|
|
29
28
|
read_only = _ref$read_only === void 0 ? false : _ref$read_only,
|
|
30
29
|
className = _ref.className,
|
|
31
30
|
isUserInsideMembers = _ref.isUserInsideMembers,
|
|
32
|
-
document = _ref.document
|
|
31
|
+
document = _ref.document,
|
|
32
|
+
onRevokeGroup = _ref.onRevokeGroup,
|
|
33
|
+
onLeaveGroup = _ref.onLeaveGroup;
|
|
33
34
|
|
|
34
35
|
var _useI18n = useI18n(),
|
|
35
36
|
t = _useI18n.t;
|
|
36
37
|
|
|
37
38
|
var buttonRef = useRef();
|
|
38
39
|
|
|
39
|
-
var _useSharingContext = useSharingContext(),
|
|
40
|
-
revokeGroup = _useSharingContext.revokeGroup,
|
|
41
|
-
revokeSelf = _useSharingContext.revokeSelf;
|
|
42
|
-
|
|
43
40
|
var _useState = useState(false),
|
|
44
41
|
_useState2 = _slicedToArray(_useState, 2),
|
|
45
42
|
isMenuDisplayed = _useState2[0],
|
|
@@ -73,7 +70,7 @@ var GroupRecipientPermissions = function GroupRecipientPermissions(_ref) {
|
|
|
73
70
|
}
|
|
74
71
|
|
|
75
72
|
_context.next = 4;
|
|
76
|
-
return
|
|
73
|
+
return onRevokeGroup(document, sharingId, groupIndex);
|
|
77
74
|
|
|
78
75
|
case 4:
|
|
79
76
|
_context.next = 8;
|
|
@@ -81,7 +78,7 @@ var GroupRecipientPermissions = function GroupRecipientPermissions(_ref) {
|
|
|
81
78
|
|
|
82
79
|
case 6:
|
|
83
80
|
_context.next = 8;
|
|
84
|
-
return
|
|
81
|
+
return onLeaveGroup(document);
|
|
85
82
|
|
|
86
83
|
case 8:
|
|
87
84
|
setRevoking(false);
|
|
@@ -15,7 +15,6 @@ import LinkRecipientPermissions from './LinkRecipientPermissions';
|
|
|
15
15
|
import RecipientConfirm from './RecipientConfirm';
|
|
16
16
|
import { checkIsPermissionHasPassword, getPermissionExpiresDate } from '../../helpers/permissions';
|
|
17
17
|
import { FADE_IN_DURATION } from '../../helpers/recipients';
|
|
18
|
-
import { useSharingContext } from '../../hooks/useSharingContext';
|
|
19
18
|
import { ShareRestrictionModal } from '../ShareRestrictionModal/ShareRestrictionModal';
|
|
20
19
|
|
|
21
20
|
var LinkRecipientTextReadOnly = function LinkRecipientTextReadOnly(_ref) {
|
|
@@ -58,21 +57,18 @@ var LinkRecipient = function LinkRecipient(props) {
|
|
|
58
57
|
var _useBreakpoints = useBreakpoints(),
|
|
59
58
|
isMobile = _useBreakpoints.isMobile;
|
|
60
59
|
|
|
61
|
-
var _useSharingContext = useSharingContext(),
|
|
62
|
-
getDocumentPermissions = _useSharingContext.getDocumentPermissions;
|
|
63
|
-
|
|
64
60
|
var recipientConfirmationData = props.recipientConfirmationData,
|
|
65
61
|
verifyRecipient = props.verifyRecipient,
|
|
66
62
|
fadeIn = props.fadeIn,
|
|
67
63
|
document = props.document,
|
|
68
|
-
isReadOnly = props.isReadOnly
|
|
64
|
+
isReadOnly = props.isReadOnly,
|
|
65
|
+
permissions = props.permissions;
|
|
69
66
|
|
|
70
67
|
var _useState = useState(false),
|
|
71
68
|
_useState2 = _slicedToArray(_useState, 2),
|
|
72
69
|
openShareRestrictionModal = _useState2[0],
|
|
73
70
|
setOpenShareRestrictionModal = _useState2[1];
|
|
74
71
|
|
|
75
|
-
var permissions = getDocumentPermissions(document === null || document === void 0 ? void 0 : document._id);
|
|
76
72
|
var hasPassword = checkIsPermissionHasPassword(permissions);
|
|
77
73
|
var expiresDate = getPermissionExpiresDate(permissions);
|
|
78
74
|
var dateFormatted = expiresDate ? f(expiresDate, lang === 'fr' ? 'dd/LL/yyyy' : 'LL/dd/yyyy') : null;
|
|
@@ -11,12 +11,15 @@ import { setReadOnlySharedPermission } from './actions/setReadOnlySharedPermissi
|
|
|
11
11
|
import { setReadWriteSharedPermission } from './actions/setReadWriteSharedPermission';
|
|
12
12
|
import { isOnlyReadOnlyLinkAllowed } from '../../helpers/link';
|
|
13
13
|
import { checkIsReadOnlyPermissions } from '../../helpers/permissions';
|
|
14
|
-
import { useSharingContext } from '../../hooks/useSharingContext';
|
|
15
14
|
import { WRITE_PERMS, READ_ONLY_PERMS } from '../ShareRestrictionModal/helpers';
|
|
16
15
|
|
|
17
16
|
var LinkRecipientPermissions = function LinkRecipientPermissions(_ref) {
|
|
18
17
|
var document = _ref.document,
|
|
19
|
-
|
|
18
|
+
documentType = _ref.documentType,
|
|
19
|
+
isReadOnly = _ref.isReadOnly,
|
|
20
|
+
permissions = _ref.permissions,
|
|
21
|
+
onUpdateLinkPermissions = _ref.onUpdateLinkPermissions,
|
|
22
|
+
onRevokeLink = _ref.onRevokeLink;
|
|
20
23
|
|
|
21
24
|
var _useI18n = useI18n(),
|
|
22
25
|
t = _useI18n.t;
|
|
@@ -28,13 +31,6 @@ var LinkRecipientPermissions = function LinkRecipientPermissions(_ref) {
|
|
|
28
31
|
isMenuDisplayed = _useState2[0],
|
|
29
32
|
setMenuDisplayed = _useState2[1];
|
|
30
33
|
|
|
31
|
-
var _useSharingContext = useSharingContext(),
|
|
32
|
-
updateDocumentPermissions = _useSharingContext.updateDocumentPermissions,
|
|
33
|
-
revokeSharingLink = _useSharingContext.revokeSharingLink,
|
|
34
|
-
documentType = _useSharingContext.documentType,
|
|
35
|
-
getDocumentPermissions = _useSharingContext.getDocumentPermissions;
|
|
36
|
-
|
|
37
|
-
var permissions = getDocumentPermissions(document._id);
|
|
38
34
|
var isReadOnlyPermissions = checkIsReadOnlyPermissions(permissions);
|
|
39
35
|
var type = isReadOnlyPermissions ? 'one-way' : 'two-way';
|
|
40
36
|
|
|
@@ -48,14 +44,14 @@ var LinkRecipientPermissions = function LinkRecipientPermissions(_ref) {
|
|
|
48
44
|
|
|
49
45
|
var handleSetType = function handleSetType(newType) {
|
|
50
46
|
var verbs = newType === 'one-way' ? READ_ONLY_PERMS : WRITE_PERMS;
|
|
51
|
-
|
|
47
|
+
onUpdateLinkPermissions(document, {
|
|
52
48
|
verbs: verbs
|
|
53
49
|
});
|
|
54
50
|
hideMenu();
|
|
55
51
|
};
|
|
56
52
|
|
|
57
53
|
var handleRevocation = function handleRevocation() {
|
|
58
|
-
return
|
|
54
|
+
return onRevokeLink(document);
|
|
59
55
|
};
|
|
60
56
|
|
|
61
57
|
var actionsToShow = [setReadOnlySharedPermission];
|
|
@@ -90,6 +86,11 @@ var LinkRecipientPermissions = function LinkRecipientPermissions(_ref) {
|
|
|
90
86
|
};
|
|
91
87
|
|
|
92
88
|
LinkRecipientPermissions.propTypes = {
|
|
93
|
-
document: PropTypes.object.isRequired
|
|
89
|
+
document: PropTypes.object.isRequired,
|
|
90
|
+
documentType: PropTypes.string.isRequired,
|
|
91
|
+
isReadOnly: PropTypes.bool,
|
|
92
|
+
permissions: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
93
|
+
onUpdateLinkPermissions: PropTypes.func.isRequired,
|
|
94
|
+
onRevokeLink: PropTypes.func.isRequired
|
|
94
95
|
};
|
|
95
96
|
export default LinkRecipientPermissions;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["instance", "isOwner", "status", "recipientConfirmationData", "verifyRecipient", "fadeIn", "isOrgSharedDrive"];
|
|
3
|
+
var _excluded = ["instance", "isOwner", "status", "isCurrentUser", "recipientConfirmationData", "verifyRecipient", "fadeIn", "isOrgSharedDrive"];
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import React from 'react';
|
|
6
|
-
import { useClient } from 'cozy-client';
|
|
7
6
|
import Fade from 'cozy-ui/transpiled/react/Fade';
|
|
8
7
|
import ListItem from 'cozy-ui/transpiled/react/ListItem';
|
|
9
8
|
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
|
|
@@ -22,21 +21,21 @@ var MemberRecipient = function MemberRecipient(props) {
|
|
|
22
21
|
var _useI18n = useI18n(),
|
|
23
22
|
t = _useI18n.t;
|
|
24
23
|
|
|
25
|
-
var client = useClient();
|
|
26
|
-
|
|
27
24
|
var _useBreakpoints = useBreakpoints(),
|
|
28
25
|
isMobile = _useBreakpoints.isMobile;
|
|
29
26
|
|
|
30
27
|
var instance = props.instance,
|
|
31
28
|
isOwner = props.isOwner,
|
|
32
29
|
status = props.status,
|
|
30
|
+
_props$isCurrentUser = props.isCurrentUser,
|
|
31
|
+
isCurrentUser = _props$isCurrentUser === void 0 ? false : _props$isCurrentUser,
|
|
33
32
|
recipientConfirmationData = props.recipientConfirmationData,
|
|
34
33
|
verifyRecipient = props.verifyRecipient,
|
|
35
34
|
fadeIn = props.fadeIn,
|
|
36
35
|
isOrgSharedDrive = props.isOrgSharedDrive,
|
|
37
36
|
rest = _objectWithoutProperties(props, _excluded);
|
|
38
37
|
|
|
39
|
-
var isMe = isOwner && status === 'owner' ||
|
|
38
|
+
var isMe = isOwner && status === 'owner' || isCurrentUser;
|
|
40
39
|
var defaultDisplayName = t(DEFAULT_DISPLAY_NAME);
|
|
41
40
|
var name = getDisplayName(rest, defaultDisplayName);
|
|
42
41
|
var RightPart = recipientConfirmationData ? /*#__PURE__*/React.createElement(RecipientConfirm, {
|
|
@@ -45,7 +44,8 @@ var MemberRecipient = function MemberRecipient(props) {
|
|
|
45
44
|
}) : /*#__PURE__*/React.createElement(MemberRecipientPermissions, _extends({}, rest, {
|
|
46
45
|
instance: instance,
|
|
47
46
|
isOwner: isOwner,
|
|
48
|
-
status: status
|
|
47
|
+
status: status,
|
|
48
|
+
isCurrentUser: isCurrentUser
|
|
49
49
|
}));
|
|
50
50
|
return /*#__PURE__*/React.createElement(Fade, {
|
|
51
51
|
in: true,
|
|
@@ -75,6 +75,7 @@ MemberRecipient.propTypes = {
|
|
|
75
75
|
instance: PropTypes.string,
|
|
76
76
|
isOwner: PropTypes.bool,
|
|
77
77
|
status: PropTypes.string,
|
|
78
|
+
isCurrentUser: PropTypes.bool,
|
|
78
79
|
recipientConfirmationData: PropTypes.object,
|
|
79
80
|
verifyRecipient: PropTypes.func,
|
|
80
81
|
isOrgSharedDrive: PropTypes.bool
|
|
@@ -5,18 +5,6 @@ import React from 'react';
|
|
|
5
5
|
import { createMockClient } from 'cozy-client';
|
|
6
6
|
import MemberRecipient from './MemberRecipient';
|
|
7
7
|
import AppLike from '../../../test/AppLike';
|
|
8
|
-
var mockUpdateDocumentPermissions = jest.fn();
|
|
9
|
-
var mockUpdateSharingMemberType = jest.fn();
|
|
10
|
-
jest.mock('../../hooks/useSharingContext', function () {
|
|
11
|
-
return {
|
|
12
|
-
useSharingContext: function useSharingContext() {
|
|
13
|
-
return {
|
|
14
|
-
updateDocumentPermissions: mockUpdateDocumentPermissions,
|
|
15
|
-
updateSharingMemberType: mockUpdateSharingMemberType
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
});
|
|
20
8
|
describe('MemberRecipient component', function () {
|
|
21
9
|
var client = createMockClient({});
|
|
22
10
|
client.options = {
|
|
@@ -49,6 +37,7 @@ describe('MemberRecipient component', function () {
|
|
|
49
37
|
it('should render if isMe ', function () {
|
|
50
38
|
var _setup = setup({
|
|
51
39
|
instance: 'foo.mycozy.cloud',
|
|
40
|
+
isCurrentUser: true,
|
|
52
41
|
status: 'ready',
|
|
53
42
|
type: 'two-way'
|
|
54
43
|
}),
|
|
@@ -60,6 +49,7 @@ describe('MemberRecipient component', function () {
|
|
|
60
49
|
it('should match snapshot if isOwner', function () {
|
|
61
50
|
var _setup2 = setup({
|
|
62
51
|
instance: 'foo.mycozy.cloud',
|
|
52
|
+
isCurrentUser: true,
|
|
63
53
|
status: 'ready',
|
|
64
54
|
type: 'two-way',
|
|
65
55
|
isOwner: true
|
|
@@ -79,6 +69,7 @@ describe('MemberRecipient component', function () {
|
|
|
79
69
|
onRevokeSelf = jest.fn();
|
|
80
70
|
_setup3 = setup({
|
|
81
71
|
instance: 'foo.mycozy.cloud',
|
|
72
|
+
isCurrentUser: true,
|
|
82
73
|
status: 'ready',
|
|
83
74
|
type: 'two-way',
|
|
84
75
|
documentType: 'Files',
|
|
@@ -105,6 +96,7 @@ describe('MemberRecipient component', function () {
|
|
|
105
96
|
onRevokeSelf = jest.fn();
|
|
106
97
|
_setup4 = setup({
|
|
107
98
|
instance: 'foo.mycozy.cloud',
|
|
99
|
+
isCurrentUser: true,
|
|
108
100
|
status: 'ready',
|
|
109
101
|
type: 'two-way',
|
|
110
102
|
isOwner: true,
|
|
@@ -128,6 +120,7 @@ describe('MemberRecipient component', function () {
|
|
|
128
120
|
|
|
129
121
|
var _setup5 = setup({
|
|
130
122
|
instance: 'foo.mycozy.cloud',
|
|
123
|
+
isCurrentUser: true,
|
|
131
124
|
status: 'ready',
|
|
132
125
|
type: 'two-way',
|
|
133
126
|
isOwner: false,
|
|
@@ -148,6 +141,7 @@ describe('MemberRecipient component', function () {
|
|
|
148
141
|
|
|
149
142
|
var _setup6 = setup({
|
|
150
143
|
instance: 'foo.mycozy.cloud',
|
|
144
|
+
isCurrentUser: true,
|
|
151
145
|
status: 'ready',
|
|
152
146
|
type: 'two-way',
|
|
153
147
|
isOwner: false,
|
|
@@ -165,6 +159,7 @@ describe('MemberRecipient component', function () {
|
|
|
165
159
|
|
|
166
160
|
var _setup7 = setup({
|
|
167
161
|
instance: 'foo.mycozy.cloud',
|
|
162
|
+
isCurrentUser: true,
|
|
168
163
|
status: 'ready',
|
|
169
164
|
type: 'two-way',
|
|
170
165
|
isOwner: false,
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["isOwner", "canManageSharing", "canManageMembers", "status", "
|
|
4
|
+
var _excluded = ["isOwner", "canManageSharing", "canManageMembers", "status", "isCurrentUser", "type", "document", "isInsideSharedParent", "sharedParentName", "onRevoke", "onRevokeSelf", "onSetMemberType", "sharingId", "memberIndex"];
|
|
5
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
6
|
import React, { useState, useCallback } from 'react';
|
|
7
7
|
import { Icon, CrossCircleOutline } from '@linagora/twake-icons';
|
|
8
|
-
import { useClient } from 'cozy-client';
|
|
9
8
|
import IconButton from 'cozy-ui/transpiled/react/IconButton';
|
|
10
9
|
import Spinner from 'cozy-ui/transpiled/react/Spinner';
|
|
11
10
|
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
12
11
|
import { useI18n } from 'twake-i18n';
|
|
13
|
-
import
|
|
12
|
+
import PermissionTypeMenu from './PermissionTypeMenu';
|
|
13
|
+
import { hasMemberActions } from '../../helpers/recipients';
|
|
14
14
|
|
|
15
15
|
var MemberRecipientPermissions = function MemberRecipientPermissions(_ref) {
|
|
16
16
|
var isOwner = _ref.isOwner,
|
|
@@ -19,11 +19,15 @@ var MemberRecipientPermissions = function MemberRecipientPermissions(_ref) {
|
|
|
19
19
|
_ref$canManageMembers = _ref.canManageMembers,
|
|
20
20
|
canManageMembers = _ref$canManageMembers === void 0 ? true : _ref$canManageMembers,
|
|
21
21
|
status = _ref.status,
|
|
22
|
-
|
|
22
|
+
_ref$isCurrentUser = _ref.isCurrentUser,
|
|
23
|
+
isCurrentUser = _ref$isCurrentUser === void 0 ? false : _ref$isCurrentUser,
|
|
23
24
|
type = _ref.type,
|
|
24
25
|
document = _ref.document,
|
|
26
|
+
isInsideSharedParent = _ref.isInsideSharedParent,
|
|
27
|
+
sharedParentName = _ref.sharedParentName,
|
|
25
28
|
onRevoke = _ref.onRevoke,
|
|
26
29
|
onRevokeSelf = _ref.onRevokeSelf,
|
|
30
|
+
onSetMemberType = _ref.onSetMemberType,
|
|
27
31
|
sharingId = _ref.sharingId,
|
|
28
32
|
memberIndex = _ref.memberIndex,
|
|
29
33
|
recipient = _objectWithoutProperties(_ref, _excluded);
|
|
@@ -31,16 +35,19 @@ var MemberRecipientPermissions = function MemberRecipientPermissions(_ref) {
|
|
|
31
35
|
var _useI18n = useI18n(),
|
|
32
36
|
t = _useI18n.t;
|
|
33
37
|
|
|
34
|
-
var client = useClient();
|
|
35
|
-
|
|
36
38
|
var _useState = useState(false),
|
|
37
39
|
_useState2 = _slicedToArray(_useState, 2),
|
|
38
40
|
revoking = _useState2[0],
|
|
39
41
|
setRevoking = _useState2[1];
|
|
40
42
|
|
|
41
|
-
var instanceMatchesClient = instance !== undefined && instance === client.options.uri;
|
|
42
43
|
var contactIsOwner = status === 'owner';
|
|
43
|
-
var shouldShowMenu =
|
|
44
|
+
var shouldShowMenu = !revoking && hasMemberActions({
|
|
45
|
+
status: status,
|
|
46
|
+
isCurrentUser: isCurrentUser,
|
|
47
|
+
isOwner: isOwner,
|
|
48
|
+
canManageSharing: canManageSharing,
|
|
49
|
+
canManageMembers: canManageMembers
|
|
50
|
+
});
|
|
44
51
|
var handleRevocation = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
45
52
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
46
53
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -48,7 +55,7 @@ var MemberRecipientPermissions = function MemberRecipientPermissions(_ref) {
|
|
|
48
55
|
setRevoking(true);
|
|
49
56
|
_context.prev = 1;
|
|
50
57
|
|
|
51
|
-
if (!(
|
|
58
|
+
if (!(isCurrentUser && !isOwner)) {
|
|
52
59
|
_context.next = 7;
|
|
53
60
|
break;
|
|
54
61
|
}
|
|
@@ -74,15 +81,23 @@ var MemberRecipientPermissions = function MemberRecipientPermissions(_ref) {
|
|
|
74
81
|
return _context.stop();
|
|
75
82
|
}
|
|
76
83
|
}, _callee, null, [[1,, 9, 12]]);
|
|
77
|
-
})), [document,
|
|
84
|
+
})), [document, isCurrentUser, isOwner, memberIndex, onRevoke, onRevokeSelf, sharingId]);
|
|
78
85
|
return /*#__PURE__*/React.createElement(React.Fragment, null, revoking && /*#__PURE__*/React.createElement(Spinner, null), !shouldShowMenu && /*#__PURE__*/React.createElement(Typography, {
|
|
79
86
|
variant: "body2"
|
|
80
87
|
}, contactIsOwner ? t("Share.status.".concat(status)) : t("Share.type.".concat(type))), shouldShowMenu && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(PermissionTypeMenu, {
|
|
81
|
-
sharingId: sharingId,
|
|
82
|
-
memberIndex: memberIndex,
|
|
83
88
|
type: type !== null && type !== void 0 ? type : 'one-way',
|
|
84
89
|
document: document,
|
|
85
|
-
recipient: recipient
|
|
90
|
+
recipient: recipient,
|
|
91
|
+
isInsideSharedParent: isInsideSharedParent,
|
|
92
|
+
sharedParentName: sharedParentName,
|
|
93
|
+
onSetType: function onSetType(newType, options) {
|
|
94
|
+
return onSetMemberType({
|
|
95
|
+
sharingId: sharingId,
|
|
96
|
+
memberIndex: memberIndex,
|
|
97
|
+
type: type !== null && type !== void 0 ? type : 'one-way',
|
|
98
|
+
recipient: recipient
|
|
99
|
+
}, newType, options);
|
|
100
|
+
}
|
|
86
101
|
}), /*#__PURE__*/React.createElement(IconButton, {
|
|
87
102
|
onClick: handleRevocation,
|
|
88
103
|
size: "small",
|
|
@@ -4,17 +4,7 @@ import React from 'react';
|
|
|
4
4
|
import { createMockClient } from 'cozy-client';
|
|
5
5
|
import MemberRecipientPermissions from './MemberRecipientPermissions';
|
|
6
6
|
import AppLike from '../../../test/AppLike';
|
|
7
|
-
var mockUpdateSharingMemberType = jest.fn();
|
|
8
7
|
var mockShowAlert = jest.fn();
|
|
9
|
-
jest.mock('../../hooks/useSharingContext', function () {
|
|
10
|
-
return {
|
|
11
|
-
useSharingContext: function useSharingContext() {
|
|
12
|
-
return {
|
|
13
|
-
updateSharingMemberType: mockUpdateSharingMemberType
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
});
|
|
18
8
|
jest.mock('cozy-ui/transpiled/react/providers/Alert', function () {
|
|
19
9
|
return {
|
|
20
10
|
__esModule: true,
|
|
@@ -38,7 +28,7 @@ describe('MemberRecipientPermissions component', function () {
|
|
|
38
28
|
isOwner: true,
|
|
39
29
|
isSharedDrive: false,
|
|
40
30
|
status: 'ready',
|
|
41
|
-
|
|
31
|
+
isCurrentUser: true,
|
|
42
32
|
type: 'two-way',
|
|
43
33
|
document: {
|
|
44
34
|
id: 'doc-123',
|
|
@@ -48,7 +38,8 @@ describe('MemberRecipientPermissions component', function () {
|
|
|
48
38
|
sharingId: 'sharing-123',
|
|
49
39
|
memberIndex: 1,
|
|
50
40
|
onRevoke: jest.fn(),
|
|
51
|
-
onRevokeSelf: jest.fn()
|
|
41
|
+
onRevokeSelf: jest.fn(),
|
|
42
|
+
onSetMemberType: jest.fn()
|
|
52
43
|
};
|
|
53
44
|
beforeEach(function () {
|
|
54
45
|
jest.clearAllMocks();
|
|
@@ -80,7 +71,7 @@ describe('MemberRecipientPermissions component', function () {
|
|
|
80
71
|
it('should not render menu when user is not owner and not the shared drive contact', function () {
|
|
81
72
|
var _setup = setup({
|
|
82
73
|
isOwner: false,
|
|
83
|
-
|
|
74
|
+
isCurrentUser: false
|
|
84
75
|
}),
|
|
85
76
|
queryByRole = _setup.queryByRole;
|
|
86
77
|
|
|
@@ -104,7 +95,7 @@ describe('MemberRecipientPermissions component', function () {
|
|
|
104
95
|
it('should render menu for the user themselves', function () {
|
|
105
96
|
var _setup3 = setup({
|
|
106
97
|
isOwner: false,
|
|
107
|
-
|
|
98
|
+
isCurrentUser: true
|
|
108
99
|
}),
|
|
109
100
|
getByRole = _setup3.getByRole;
|
|
110
101
|
|