cozy-sharing 31.0.1 → 31.1.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 +20 -0
- package/dist/components/Recipient/GroupRecipientPermissions.js +15 -11
- package/dist/components/Recipient/LinkRecipient.js +15 -11
- package/dist/components/Recipient/LinkRecipientLite.js +1 -1
- package/dist/components/Recipient/LinkRecipientPermissions.js +2 -1
- package/dist/components/Recipient/MemberRecipient.spec.js +8 -10
- package/dist/components/Recipient/MemberRecipientLite.js +1 -1
- package/dist/components/Recipient/MemberRecipientPermissions.js +16 -12
- package/dist/components/Recipient/MemberRecipientPermissions.spec.js +62 -50
- package/dist/components/ShareDialogCozyToCozy.spec.js +1 -1
- package/dist/components/SharedDrive/SharedDriveForm.js +6 -2
- package/dist/components/SharedDrive/SharedDriveRecipientPermissions.js +15 -10
- package/dist/suggestionMatchers.js +5 -4
- package/dist/suggestionMatchers.spec.js +38 -0
- package/locales/en.json +10 -36
- package/locales/fr.json +10 -36
- package/locales/ru.json +10 -36
- package/locales/vi.json +10 -34
- package/package.json +2 -2
- package/src/components/Recipient/GroupRecipientPermissions.jsx +15 -13
- package/src/components/Recipient/LinkRecipient.jsx +9 -9
- package/src/components/Recipient/LinkRecipientLite.jsx +1 -3
- package/src/components/Recipient/LinkRecipientPermissions.jsx +2 -1
- package/src/components/Recipient/MemberRecipient.spec.jsx +4 -6
- package/src/components/Recipient/MemberRecipientLite.jsx +2 -2
- package/src/components/Recipient/MemberRecipientPermissions.jsx +16 -21
- package/src/components/Recipient/MemberRecipientPermissions.spec.jsx +21 -23
- package/src/components/ShareDialogCozyToCozy.spec.jsx +1 -1
- package/src/components/SharedDrive/SharedDriveForm.jsx +6 -2
- package/src/components/SharedDrive/SharedDriveRecipientPermissions.jsx +15 -17
- package/src/suggestionMatchers.js +6 -4
- package/src/suggestionMatchers.spec.js +30 -0
- package/dist/components/Recipient/actions/revokeGroup.js +0 -42
- package/dist/components/Recipient/actions/revokeMember.js +0 -42
- package/dist/components/Recipient/actions/revokeSharedDriveMember.js +0 -41
- package/src/components/Recipient/actions/revokeGroup.js +0 -42
- package/src/components/Recipient/actions/revokeMember.js +0 -42
- package/src/components/Recipient/actions/revokeSharedDriveMember.js +0 -41
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,26 @@
|
|
|
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
|
+
# [31.1.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@31.0.2...cozy-sharing@31.1.0) (2026-05-07)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- Autoclose sharing link permission menu ([82f6b62](https://github.com/cozy/cozy-libs/commit/82f6b62c78232805150e8c927955bb7eeb108ad4))
|
|
11
|
+
- Fix hover issue in link recipient text ([dce027c](https://github.com/cozy/cozy-libs/commit/dce027c16eecf8f3309da73a1dd01d537a2cef47))
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
- Revoke member or group with button instead of action ([3fa0c4d](https://github.com/cozy/cozy-libs/commit/3fa0c4d3035d57fa65e231fbbddc5b06955b3ecb))
|
|
16
|
+
- Update permission menu UI ([bc0c0ad](https://github.com/cozy/cozy-libs/commit/bc0c0ade86d86e82299397c09cdc5f4c19c1c4ac))
|
|
17
|
+
- Update SharedDriveForm UI ([b3ab3ff](https://github.com/cozy/cozy-libs/commit/b3ab3ffd3881ccae74c1e3486706e7c108ed151b))
|
|
18
|
+
- Update SharedDriveForm wording ([c46750b](https://github.com/cozy/cozy-libs/commit/c46750be56cbc0c99b2c3f46b069d361cadddb82))
|
|
19
|
+
|
|
20
|
+
## [31.0.2](https://github.com/cozy/cozy-libs/compare/cozy-sharing@31.0.1...cozy-sharing@31.0.2) (2026-05-07)
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
- **cozy-sharing:** Escape user input in suggestion matchers ([d1bce0d](https://github.com/cozy/cozy-libs/commit/d1bce0d4426a04960e8e44d93b301c2f673e584e))
|
|
25
|
+
|
|
6
26
|
## [31.0.1](https://github.com/cozy/cozy-libs/compare/cozy-sharing@31.0.0...cozy-sharing@31.0.1) (2026-05-07)
|
|
7
27
|
|
|
8
28
|
**Note:** Version bump only for package cozy-sharing
|
|
@@ -2,17 +2,18 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
4
|
import React, { useState, useRef } from 'react';
|
|
5
|
-
import { useClient } from 'cozy-client';
|
|
6
5
|
import ActionsMenu from 'cozy-ui/transpiled/react/ActionsMenu';
|
|
7
|
-
import { makeActions
|
|
6
|
+
import { makeActions } from 'cozy-ui/transpiled/react/ActionsMenu/Actions';
|
|
8
7
|
import ActionsMenuMobileHeader from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuMobileHeader';
|
|
9
8
|
import DropdownButton from 'cozy-ui/transpiled/react/DropdownButton';
|
|
9
|
+
import Icon from 'cozy-ui/transpiled/react/Icon';
|
|
10
|
+
import IconButton from 'cozy-ui/transpiled/react/IconButton';
|
|
11
|
+
import CrossCircleOutlineIcon from 'cozy-ui/transpiled/react/Icons/CrossCircleOutline';
|
|
10
12
|
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
|
|
11
13
|
import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
|
|
12
14
|
import Spinner from 'cozy-ui/transpiled/react/Spinner';
|
|
13
15
|
import { useI18n } from 'twake-i18n';
|
|
14
16
|
import { permission } from './actions/permission';
|
|
15
|
-
import { revokeGroup as revokeGroupAction } from './actions/revokeGroup';
|
|
16
17
|
import { useSharingContext } from '../../hooks/useSharingContext';
|
|
17
18
|
import { GroupAvatar } from '../Avatar/GroupAvatar';
|
|
18
19
|
|
|
@@ -31,7 +32,6 @@ var GroupRecipientPermissions = function GroupRecipientPermissions(_ref) {
|
|
|
31
32
|
t = _useI18n.t;
|
|
32
33
|
|
|
33
34
|
var buttonRef = useRef();
|
|
34
|
-
var client = useClient();
|
|
35
35
|
|
|
36
36
|
var _useSharingContext = useSharingContext(),
|
|
37
37
|
revokeGroup = _useSharingContext.revokeGroup,
|
|
@@ -96,12 +96,9 @@ var GroupRecipientPermissions = function GroupRecipientPermissions(_ref) {
|
|
|
96
96
|
}();
|
|
97
97
|
|
|
98
98
|
var type = isReadOnly ? 'one-way' : 'two-way';
|
|
99
|
-
var actions = makeActions([permission
|
|
100
|
-
client: client,
|
|
99
|
+
var actions = makeActions([permission], {
|
|
101
100
|
t: t,
|
|
102
|
-
type: type
|
|
103
|
-
isOwner: isOwner,
|
|
104
|
-
handleRevocation: handleRevocation
|
|
101
|
+
type: type
|
|
105
102
|
});
|
|
106
103
|
return /*#__PURE__*/React.createElement("div", {
|
|
107
104
|
className: className
|
|
@@ -111,7 +108,7 @@ var GroupRecipientPermissions = function GroupRecipientPermissions(_ref) {
|
|
|
111
108
|
"aria-haspopup": "true",
|
|
112
109
|
onClick: toggleMenu,
|
|
113
110
|
textVariant: "body2"
|
|
114
|
-
}, t("Share.type.".concat(type))
|
|
111
|
+
}, t("Share.type.".concat(type))), /*#__PURE__*/React.createElement(ActionsMenu, {
|
|
115
112
|
ref: buttonRef,
|
|
116
113
|
open: isMenuDisplayed,
|
|
117
114
|
actions: actions,
|
|
@@ -124,7 +121,14 @@ var GroupRecipientPermissions = function GroupRecipientPermissions(_ref) {
|
|
|
124
121
|
primaryTypographyProps: {
|
|
125
122
|
variant: 'h6'
|
|
126
123
|
}
|
|
127
|
-
})))
|
|
124
|
+
}))), /*#__PURE__*/React.createElement(IconButton, {
|
|
125
|
+
onClick: handleRevocation,
|
|
126
|
+
size: "small",
|
|
127
|
+
className: "u-ml-half",
|
|
128
|
+
"aria-label": t('Share.members.revoke')
|
|
129
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
130
|
+
icon: CrossCircleOutlineIcon
|
|
131
|
+
}))));
|
|
128
132
|
};
|
|
129
133
|
|
|
130
134
|
export { GroupRecipientPermissions };
|
|
@@ -3,14 +3,15 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import React, { useState } from 'react';
|
|
5
5
|
import Avatar from 'cozy-ui/transpiled/react/Avatar';
|
|
6
|
-
import Button from 'cozy-ui/transpiled/react/Button';
|
|
7
6
|
import Fade from 'cozy-ui/transpiled/react/Fade';
|
|
8
7
|
import Icon from 'cozy-ui/transpiled/react/Icon';
|
|
8
|
+
import IconButton from 'cozy-ui/transpiled/react/IconButton';
|
|
9
9
|
import Gear from 'cozy-ui/transpiled/react/Icons/Gear';
|
|
10
10
|
import LinkIcon from 'cozy-ui/transpiled/react/Icons/Link';
|
|
11
11
|
import ListItem from 'cozy-ui/transpiled/react/ListItem';
|
|
12
12
|
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
|
|
13
13
|
import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
|
|
14
|
+
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
14
15
|
import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints';
|
|
15
16
|
import { useI18n } from 'twake-i18n';
|
|
16
17
|
import LinkRecipientPermissions from './LinkRecipientPermissions';
|
|
@@ -70,16 +71,19 @@ var LinkRecipient = function LinkRecipient(props) {
|
|
|
70
71
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
71
72
|
icon: LinkIcon
|
|
72
73
|
}))), /*#__PURE__*/React.createElement(ListItemText, {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
74
|
+
onClick: function onClick() {
|
|
75
|
+
return setOpenShareRestrictionModal(true);
|
|
76
|
+
},
|
|
77
|
+
primary: /*#__PURE__*/React.createElement("div", {
|
|
78
|
+
className: "u-flex u-flex-items-center"
|
|
79
|
+
}, /*#__PURE__*/React.createElement(Typography, {
|
|
80
|
+
className: "u-c-pointer "
|
|
81
|
+
}, textPrimary), /*#__PURE__*/React.createElement(IconButton, {
|
|
82
|
+
size: "small",
|
|
83
|
+
className: "u-ml-half"
|
|
84
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
85
|
+
icon: Gear
|
|
86
|
+
}))),
|
|
83
87
|
secondary: textSecondary
|
|
84
88
|
}), RightPart, openShareRestrictionModal && /*#__PURE__*/React.createElement(ShareRestrictionModal, {
|
|
85
89
|
file: document,
|
|
@@ -36,7 +36,7 @@ var LinkRecipientLite = function LinkRecipientLite(_ref) {
|
|
|
36
36
|
}), /*#__PURE__*/React.createElement(Typography, {
|
|
37
37
|
className: "u-flex-shrink-0",
|
|
38
38
|
variant: "body2"
|
|
39
|
-
}, t("Share.type.".concat(isReadOnlyPermissions ? 'one-way' : 'two-way'))
|
|
39
|
+
}, t("Share.type.".concat(isReadOnlyPermissions ? 'one-way' : 'two-way'))));
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
LinkRecipientLite.propTypes = {
|
|
@@ -50,6 +50,7 @@ var LinkRecipientPermissions = function LinkRecipientPermissions(_ref) {
|
|
|
50
50
|
updateDocumentPermissions(document, {
|
|
51
51
|
verbs: verbs
|
|
52
52
|
});
|
|
53
|
+
hideMenu();
|
|
53
54
|
};
|
|
54
55
|
|
|
55
56
|
var handleRevocation = function handleRevocation() {
|
|
@@ -77,7 +78,7 @@ var LinkRecipientPermissions = function LinkRecipientPermissions(_ref) {
|
|
|
77
78
|
ref: buttonRef,
|
|
78
79
|
textVariant: "body2",
|
|
79
80
|
onClick: toggleMenu
|
|
80
|
-
}, t("Share.type.".concat(type))
|
|
81
|
+
}, t("Share.type.".concat(type))), /*#__PURE__*/React.createElement(ActionsMenu, {
|
|
81
82
|
ref: buttonRef,
|
|
82
83
|
open: isMenuDisplayed,
|
|
83
84
|
actions: actions,
|
|
@@ -70,7 +70,7 @@ describe('MemberRecipient component', function () {
|
|
|
70
70
|
expect(getByText('foo.mycozy.cloud')).toBeTruthy();
|
|
71
71
|
});
|
|
72
72
|
it('should call revokeSelf if I am not the owner but try to revoke myself', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
73
|
-
var onRevoke, onRevokeSelf, _setup3,
|
|
73
|
+
var onRevoke, onRevokeSelf, _setup3, getByLabelText;
|
|
74
74
|
|
|
75
75
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
76
76
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -84,20 +84,19 @@ describe('MemberRecipient component', function () {
|
|
|
84
84
|
documentType: 'Files',
|
|
85
85
|
onRevoke: onRevoke,
|
|
86
86
|
onRevokeSelf: onRevokeSelf
|
|
87
|
-
}),
|
|
88
|
-
fireEvent.click(
|
|
89
|
-
fireEvent.click(getByText('Remove me from sharing'));
|
|
87
|
+
}), getByLabelText = _setup3.getByLabelText;
|
|
88
|
+
fireEvent.click(getByLabelText('Remove from sharing'));
|
|
90
89
|
expect(onRevoke).not.toHaveBeenCalled();
|
|
91
90
|
expect(onRevokeSelf).toHaveBeenCalled();
|
|
92
91
|
|
|
93
|
-
case
|
|
92
|
+
case 6:
|
|
94
93
|
case "end":
|
|
95
94
|
return _context.stop();
|
|
96
95
|
}
|
|
97
96
|
}, _callee);
|
|
98
97
|
})));
|
|
99
98
|
it('should call revoke if I am the owner of the sharing', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
100
|
-
var onRevoke, onRevokeSelf, _setup4,
|
|
99
|
+
var onRevoke, onRevokeSelf, _setup4, getByLabelText;
|
|
101
100
|
|
|
102
101
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
103
102
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -112,13 +111,12 @@ describe('MemberRecipient component', function () {
|
|
|
112
111
|
documentType: 'Files',
|
|
113
112
|
onRevoke: onRevoke,
|
|
114
113
|
onRevokeSelf: onRevokeSelf
|
|
115
|
-
}),
|
|
116
|
-
fireEvent.click(
|
|
117
|
-
fireEvent.click(getByText('Remove from sharing'));
|
|
114
|
+
}), getByLabelText = _setup4.getByLabelText;
|
|
115
|
+
fireEvent.click(getByLabelText('Remove from sharing'));
|
|
118
116
|
expect(onRevoke).toHaveBeenCalled();
|
|
119
117
|
expect(onRevokeSelf).not.toHaveBeenCalled();
|
|
120
118
|
|
|
121
|
-
case
|
|
119
|
+
case 6:
|
|
122
120
|
case "end":
|
|
123
121
|
return _context2.stop();
|
|
124
122
|
}
|
|
@@ -47,7 +47,7 @@ var MemberRecipientLite = function MemberRecipientLite(_ref) {
|
|
|
47
47
|
}), /*#__PURE__*/React.createElement(Typography, {
|
|
48
48
|
className: "u-flex-shrink-0",
|
|
49
49
|
variant: "body2"
|
|
50
|
-
}, recipientOwner ? t("Share.status.".concat(recipient.status))
|
|
50
|
+
}, recipientOwner ? t("Share.status.".concat(recipient.status)) : t("Share.type.".concat((_recipient$type = recipient.type) !== null && _recipient$type !== void 0 ? _recipient$type : 'one-way'))));
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
MemberRecipientLite.propTypes = {
|
|
@@ -5,13 +5,15 @@ import React, { useState, useRef, useCallback } from 'react';
|
|
|
5
5
|
import { useClient } from 'cozy-client';
|
|
6
6
|
import minilog from 'cozy-minilog';
|
|
7
7
|
import ActionsMenu from 'cozy-ui/transpiled/react/ActionsMenu';
|
|
8
|
-
import { makeActions
|
|
8
|
+
import { makeActions } from 'cozy-ui/transpiled/react/ActionsMenu/Actions';
|
|
9
9
|
import DropdownButton from 'cozy-ui/transpiled/react/DropdownButton';
|
|
10
|
+
import Icon from 'cozy-ui/transpiled/react/Icon';
|
|
11
|
+
import IconButton from 'cozy-ui/transpiled/react/IconButton';
|
|
12
|
+
import CrossCircleOutlineIcon from 'cozy-ui/transpiled/react/Icons/CrossCircleOutline';
|
|
10
13
|
import Spinner from 'cozy-ui/transpiled/react/Spinner';
|
|
11
14
|
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
12
15
|
import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert';
|
|
13
16
|
import { useI18n } from 'twake-i18n';
|
|
14
|
-
import { revokeMember } from './actions/revokeMember';
|
|
15
17
|
import { setReadOnlySharedPermission } from './actions/setReadOnlySharedPermission';
|
|
16
18
|
import { setReadWriteSharedPermission } from './actions/setReadWriteSharedPermission';
|
|
17
19
|
import { useSharingContext } from '../../hooks/useSharingContext';
|
|
@@ -19,7 +21,6 @@ var log = minilog('MemberRecipientPermissions');
|
|
|
19
21
|
|
|
20
22
|
var MemberRecipientPermissions = function MemberRecipientPermissions(_ref) {
|
|
21
23
|
var isOwner = _ref.isOwner,
|
|
22
|
-
isSharedDrive = _ref.isSharedDrive,
|
|
23
24
|
status = _ref.status,
|
|
24
25
|
instance = _ref.instance,
|
|
25
26
|
type = _ref.type,
|
|
@@ -143,32 +144,35 @@ var MemberRecipientPermissions = function MemberRecipientPermissions(_ref) {
|
|
|
143
144
|
return _ref3.apply(this, arguments);
|
|
144
145
|
};
|
|
145
146
|
}(), [hideMenu, memberIndex, sharingId, showAlert, t, type, updateSharingMemberType]);
|
|
146
|
-
var actions = makeActions([setReadOnlySharedPermission, setReadWriteSharedPermission
|
|
147
|
-
client: client,
|
|
147
|
+
var actions = makeActions([setReadOnlySharedPermission, setReadWriteSharedPermission], {
|
|
148
148
|
t: t,
|
|
149
149
|
type: type !== null && type !== void 0 ? type : 'one-way',
|
|
150
|
-
|
|
151
|
-
isSharedDrive: isSharedDrive,
|
|
152
|
-
setType: setType,
|
|
153
|
-
handleRevocation: handleRevocation
|
|
150
|
+
setType: setType
|
|
154
151
|
});
|
|
155
152
|
return /*#__PURE__*/React.createElement("div", {
|
|
156
153
|
className: className
|
|
157
154
|
}, revoking && /*#__PURE__*/React.createElement(Spinner, null), !shouldShowMenu && !revoking && /*#__PURE__*/React.createElement(Typography, {
|
|
158
155
|
variant: "body2"
|
|
159
|
-
}, t("Share.status.".concat(status))
|
|
156
|
+
}, t("Share.status.".concat(status))), shouldShowMenu && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DropdownButton, {
|
|
160
157
|
ref: buttonRef,
|
|
161
158
|
"aria-controls": "simple-menu",
|
|
162
159
|
"aria-haspopup": "true",
|
|
163
160
|
onClick: toggleMenu,
|
|
164
161
|
textVariant: "body2"
|
|
165
|
-
}, t("Share.type.".concat(type))
|
|
162
|
+
}, t("Share.type.".concat(type))), /*#__PURE__*/React.createElement(ActionsMenu, {
|
|
166
163
|
ref: buttonRef,
|
|
167
164
|
open: isMenuDisplayed,
|
|
168
165
|
actions: actions,
|
|
169
166
|
autoClose: true,
|
|
170
167
|
onClose: hideMenu
|
|
171
|
-
})
|
|
168
|
+
}), /*#__PURE__*/React.createElement(IconButton, {
|
|
169
|
+
onClick: handleRevocation,
|
|
170
|
+
size: "small",
|
|
171
|
+
className: "u-ml-half",
|
|
172
|
+
"aria-label": t('Share.members.revoke')
|
|
173
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
174
|
+
icon: CrossCircleOutlineIcon
|
|
175
|
+
}))));
|
|
172
176
|
};
|
|
173
177
|
|
|
174
178
|
export default MemberRecipientPermissions;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
-
import { render, fireEvent, screen,
|
|
4
|
+
import { render, fireEvent, screen, waitFor } from '@testing-library/react';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { createMockClient } from 'cozy-client';
|
|
7
7
|
import MemberRecipientPermissions from './MemberRecipientPermissions';
|
|
@@ -81,10 +81,12 @@ describe('MemberRecipientPermissions component', function () {
|
|
|
81
81
|
});
|
|
82
82
|
it('should render the current permission type', function () {
|
|
83
83
|
setup();
|
|
84
|
-
expect(screen.
|
|
84
|
+
expect(screen.getByRole('button', {
|
|
85
|
+
name: 'Editor'
|
|
86
|
+
})).toBeInTheDocument();
|
|
85
87
|
});
|
|
86
88
|
it('should call updateSharingMemberType when changing to one-way', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
87
|
-
var _setup,
|
|
89
|
+
var _setup, getByRole;
|
|
88
90
|
|
|
89
91
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
90
92
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -92,9 +94,13 @@ describe('MemberRecipientPermissions component', function () {
|
|
|
92
94
|
mockUpdateSharingMemberType.mockResolvedValue(undefined);
|
|
93
95
|
_setup = setup({
|
|
94
96
|
type: 'two-way'
|
|
95
|
-
}),
|
|
96
|
-
fireEvent.click(
|
|
97
|
-
|
|
97
|
+
}), getByRole = _setup.getByRole;
|
|
98
|
+
fireEvent.click(getByRole('button', {
|
|
99
|
+
name: 'Editor'
|
|
100
|
+
}));
|
|
101
|
+
fireEvent.click(getByRole('menuitem', {
|
|
102
|
+
name: 'Viewer'
|
|
103
|
+
}));
|
|
98
104
|
expect(mockUpdateSharingMemberType).toHaveBeenCalledWith('sharing-123', 1, 'one-way');
|
|
99
105
|
|
|
100
106
|
case 5:
|
|
@@ -104,7 +110,7 @@ describe('MemberRecipientPermissions component', function () {
|
|
|
104
110
|
}, _callee);
|
|
105
111
|
})));
|
|
106
112
|
it('should call updateSharingMemberType when changing to two-way', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
107
|
-
var _setup2,
|
|
113
|
+
var _setup2, getByRole;
|
|
108
114
|
|
|
109
115
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
110
116
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -112,9 +118,13 @@ describe('MemberRecipientPermissions component', function () {
|
|
|
112
118
|
mockUpdateSharingMemberType.mockResolvedValue(undefined);
|
|
113
119
|
_setup2 = setup({
|
|
114
120
|
type: 'one-way'
|
|
115
|
-
}),
|
|
116
|
-
fireEvent.click(
|
|
117
|
-
|
|
121
|
+
}), getByRole = _setup2.getByRole;
|
|
122
|
+
fireEvent.click(getByRole('button', {
|
|
123
|
+
name: 'Viewer'
|
|
124
|
+
}));
|
|
125
|
+
fireEvent.click(getByRole('menuitem', {
|
|
126
|
+
name: 'Editor'
|
|
127
|
+
}));
|
|
118
128
|
expect(mockUpdateSharingMemberType).toHaveBeenCalledWith('sharing-123', 1, 'two-way');
|
|
119
129
|
|
|
120
130
|
case 5:
|
|
@@ -123,33 +133,23 @@ describe('MemberRecipientPermissions component', function () {
|
|
|
123
133
|
}
|
|
124
134
|
}, _callee2);
|
|
125
135
|
})));
|
|
126
|
-
it('should show error alert when updateSharingMemberType fails', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
127
|
-
var _setup3,
|
|
136
|
+
it('should show error alert when updateSharingMemberType fails', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
137
|
+
var _setup3, getByRole;
|
|
128
138
|
|
|
129
|
-
return _regeneratorRuntime.wrap(function
|
|
130
|
-
while (1) switch (
|
|
139
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
140
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
131
141
|
case 0:
|
|
132
142
|
mockUpdateSharingMemberType.mockRejectedValue(new Error('Network error'));
|
|
133
143
|
_setup3 = setup({
|
|
134
144
|
type: 'two-way'
|
|
135
|
-
}),
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
case 2:
|
|
145
|
-
case "end":
|
|
146
|
-
return _context3.stop();
|
|
147
|
-
}
|
|
148
|
-
}, _callee3);
|
|
149
|
-
})));
|
|
150
|
-
|
|
151
|
-
case 4:
|
|
152
|
-
_context4.next = 6;
|
|
145
|
+
}), getByRole = _setup3.getByRole;
|
|
146
|
+
fireEvent.click(getByRole('button', {
|
|
147
|
+
name: 'Editor'
|
|
148
|
+
}));
|
|
149
|
+
fireEvent.click(getByRole('menuitem', {
|
|
150
|
+
name: 'Viewer'
|
|
151
|
+
}));
|
|
152
|
+
_context3.next = 6;
|
|
153
153
|
return waitFor(function () {
|
|
154
154
|
expect(mockShowAlert).toHaveBeenCalledWith({
|
|
155
155
|
message: 'An error occurred while changing the permissions. Please try again.',
|
|
@@ -160,55 +160,67 @@ describe('MemberRecipientPermissions component', function () {
|
|
|
160
160
|
|
|
161
161
|
case 6:
|
|
162
162
|
case "end":
|
|
163
|
-
return
|
|
163
|
+
return _context3.stop();
|
|
164
164
|
}
|
|
165
|
-
},
|
|
165
|
+
}, _callee3);
|
|
166
166
|
})));
|
|
167
|
-
it('should not call updateSharingMemberType when selecting same type', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
168
|
-
var _setup4,
|
|
167
|
+
it('should not call updateSharingMemberType when selecting same type', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
168
|
+
var _setup4, getByRole;
|
|
169
169
|
|
|
170
|
-
return _regeneratorRuntime.wrap(function
|
|
171
|
-
while (1) switch (
|
|
170
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
171
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
172
172
|
case 0:
|
|
173
173
|
mockUpdateSharingMemberType.mockResolvedValue(undefined);
|
|
174
174
|
_setup4 = setup({
|
|
175
175
|
type: 'two-way'
|
|
176
|
-
}),
|
|
177
|
-
fireEvent.click(
|
|
178
|
-
|
|
176
|
+
}), getByRole = _setup4.getByRole;
|
|
177
|
+
fireEvent.click(getByRole('button', {
|
|
178
|
+
name: 'Editor'
|
|
179
|
+
}));
|
|
180
|
+
fireEvent.click(getByRole('menuitem', {
|
|
181
|
+
name: 'Editor'
|
|
182
|
+
}));
|
|
179
183
|
expect(mockUpdateSharingMemberType).not.toHaveBeenCalled();
|
|
180
184
|
|
|
181
185
|
case 5:
|
|
182
186
|
case "end":
|
|
183
|
-
return
|
|
187
|
+
return _context4.stop();
|
|
184
188
|
}
|
|
185
|
-
},
|
|
189
|
+
}, _callee4);
|
|
186
190
|
})));
|
|
187
191
|
it('should not render menu when user is not owner and not the shared drive contact', function () {
|
|
188
192
|
var _setup5 = setup({
|
|
189
193
|
isOwner: false,
|
|
190
194
|
instance: 'http://other-cozy.local:8080'
|
|
191
195
|
}),
|
|
192
|
-
|
|
196
|
+
queryByRole = _setup5.queryByRole;
|
|
193
197
|
|
|
194
|
-
expect(
|
|
195
|
-
|
|
198
|
+
expect(queryByRole('button', {
|
|
199
|
+
name: 'Editor'
|
|
200
|
+
})).not.toBeInTheDocument();
|
|
201
|
+
expect(queryByRole('button', {
|
|
202
|
+
name: 'Viewer'
|
|
203
|
+
})).not.toBeInTheDocument();
|
|
196
204
|
});
|
|
197
205
|
it('should render menu for owner', function () {
|
|
198
206
|
var _setup6 = setup({
|
|
199
207
|
isOwner: true
|
|
200
208
|
}),
|
|
201
|
-
|
|
209
|
+
getByRole = _setup6.getByRole;
|
|
202
210
|
|
|
203
|
-
expect(
|
|
211
|
+
expect(getByRole('button', {
|
|
212
|
+
name: 'Editor'
|
|
213
|
+
})).toBeInTheDocument();
|
|
204
214
|
});
|
|
205
215
|
it('should render menu for the user themselves', function () {
|
|
206
216
|
var _setup7 = setup({
|
|
207
217
|
isOwner: false,
|
|
208
218
|
instance: 'http://cozy.local:8080'
|
|
209
219
|
}),
|
|
210
|
-
|
|
220
|
+
getByRole = _setup7.getByRole;
|
|
211
221
|
|
|
212
|
-
expect(
|
|
222
|
+
expect(getByRole('button', {
|
|
223
|
+
name: 'Editor'
|
|
224
|
+
})).toBeInTheDocument();
|
|
213
225
|
});
|
|
214
226
|
});
|
|
@@ -57,7 +57,7 @@ describe('ShareDialogCozyToCozy', function () {
|
|
|
57
57
|
getByText = _setup.getByText;
|
|
58
58
|
|
|
59
59
|
expect(getByText('You')).toBeTruthy();
|
|
60
|
-
expect(getByText('
|
|
60
|
+
expect(getByText('Owner')).toBeTruthy();
|
|
61
61
|
});
|
|
62
62
|
it('should show loading while calling getRecipientsToBeConfirmed', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
63
63
|
var _deferablePromise, promise, resolve, props, _setup2, getByText;
|
|
@@ -58,14 +58,18 @@ export var SharedDriveForm = withLocales(function (_ref) {
|
|
|
58
58
|
onRevoke: onRevoke,
|
|
59
59
|
onSetType: onSetType
|
|
60
60
|
}), /*#__PURE__*/React.createElement("div", {
|
|
61
|
-
className: "u-flex u-
|
|
61
|
+
className: "u-flex u-ph-2 u-pv-1"
|
|
62
62
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
63
|
-
variant: "
|
|
63
|
+
variant: "text",
|
|
64
64
|
label: t('SharedDrive.sharedDriveModal.cancel'),
|
|
65
|
+
className: "u-w-100 u-m-1",
|
|
66
|
+
size: "large",
|
|
65
67
|
onClick: onCancel
|
|
66
68
|
}), /*#__PURE__*/React.createElement(Button, {
|
|
67
69
|
variant: "primary",
|
|
68
70
|
label: t('SharedDrive.sharedDriveModal.create'),
|
|
71
|
+
className: "u-w-100 u-m-1",
|
|
72
|
+
size: "large",
|
|
69
73
|
onClick: onCreate
|
|
70
74
|
})));
|
|
71
75
|
});
|
|
@@ -2,12 +2,13 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
4
|
import React, { useState, useRef } from 'react';
|
|
5
|
-
import { useClient } from 'cozy-client';
|
|
6
5
|
import ActionsMenu from 'cozy-ui/transpiled/react/ActionsMenu';
|
|
7
|
-
import { makeActions
|
|
6
|
+
import { makeActions } from 'cozy-ui/transpiled/react/ActionsMenu/Actions';
|
|
8
7
|
import DropdownButton from 'cozy-ui/transpiled/react/DropdownButton';
|
|
8
|
+
import Icon from 'cozy-ui/transpiled/react/Icon';
|
|
9
|
+
import IconButton from 'cozy-ui/transpiled/react/IconButton';
|
|
10
|
+
import CrossCircleOutlineIcon from 'cozy-ui/transpiled/react/Icons/CrossCircleOutline';
|
|
9
11
|
import { useI18n } from 'twake-i18n';
|
|
10
|
-
import { revokeSharedDriveMember } from '../Recipient/actions/revokeSharedDriveMember';
|
|
11
12
|
import { setReadOnlySharedPermission } from '../Recipient/actions/setReadOnlySharedPermission';
|
|
12
13
|
import { setReadWriteSharedPermission } from '../Recipient/actions/setReadWriteSharedPermission';
|
|
13
14
|
|
|
@@ -21,7 +22,6 @@ var ShareDriveRecipientPermissions = function ShareDriveRecipientPermissions(_re
|
|
|
21
22
|
t = _useI18n.t;
|
|
22
23
|
|
|
23
24
|
var buttonRef = useRef();
|
|
24
|
-
var client = useClient();
|
|
25
25
|
|
|
26
26
|
var _useState = useState(false),
|
|
27
27
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -79,12 +79,10 @@ var ShareDriveRecipientPermissions = function ShareDriveRecipientPermissions(_re
|
|
|
79
79
|
};
|
|
80
80
|
}();
|
|
81
81
|
|
|
82
|
-
var actions = makeActions([setReadOnlySharedPermission, setReadWriteSharedPermission
|
|
82
|
+
var actions = makeActions([setReadOnlySharedPermission, setReadWriteSharedPermission], {
|
|
83
83
|
t: t,
|
|
84
|
-
client: client,
|
|
85
84
|
type: type,
|
|
86
|
-
setType: setType
|
|
87
|
-
handleRevocation: handleRevocation
|
|
85
|
+
setType: setType
|
|
88
86
|
});
|
|
89
87
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(DropdownButton, {
|
|
90
88
|
ref: buttonRef,
|
|
@@ -92,13 +90,20 @@ var ShareDriveRecipientPermissions = function ShareDriveRecipientPermissions(_re
|
|
|
92
90
|
"aria-haspopup": "true",
|
|
93
91
|
onClick: toggleMenu,
|
|
94
92
|
textVariant: "body2"
|
|
95
|
-
}, t("Share.type.".concat(type))
|
|
93
|
+
}, t("Share.type.".concat(type))), /*#__PURE__*/React.createElement(ActionsMenu, {
|
|
96
94
|
ref: buttonRef,
|
|
97
95
|
open: isMenuDisplayed,
|
|
98
96
|
actions: actions,
|
|
99
97
|
autoClose: true,
|
|
100
98
|
onClose: hideMenu
|
|
101
|
-
})
|
|
99
|
+
}), /*#__PURE__*/React.createElement(IconButton, {
|
|
100
|
+
onClick: handleRevocation,
|
|
101
|
+
size: "small",
|
|
102
|
+
className: "u-ml-half",
|
|
103
|
+
"aria-label": t('Share.members.revoke')
|
|
104
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
105
|
+
icon: CrossCircleOutlineIcon
|
|
106
|
+
})));
|
|
102
107
|
};
|
|
103
108
|
|
|
104
109
|
export default ShareDriveRecipientPermissions;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import escapeRegExp from 'lodash/escapeRegExp';
|
|
1
2
|
import { Group } from 'cozy-doctypes'; // TODO: sadly we have different versions of contacts' doctype to handle...
|
|
2
3
|
// A migration tool on the stack side is needed here
|
|
3
4
|
|
|
4
5
|
var emailMatch = function emailMatch(input, contact) {
|
|
5
6
|
if (!contact.email) return false;
|
|
6
|
-
var emailInput = new RegExp(input, 'i');
|
|
7
|
+
var emailInput = new RegExp(escapeRegExp(input), 'i');
|
|
7
8
|
|
|
8
9
|
if (Array.isArray(contact.email)) {
|
|
9
10
|
return contact.email.some(function (email) {
|
|
@@ -16,7 +17,7 @@ var emailMatch = function emailMatch(input, contact) {
|
|
|
16
17
|
|
|
17
18
|
var cozyUrlMatch = function cozyUrlMatch(input, contact) {
|
|
18
19
|
if (!contact.cozy && !contact.url) return false;
|
|
19
|
-
var urlInput = new RegExp(input, 'i');
|
|
20
|
+
var urlInput = new RegExp(escapeRegExp(input), 'i');
|
|
20
21
|
|
|
21
22
|
if (contact.cozy && Array.isArray(contact.cozy)) {
|
|
22
23
|
return contact.cozy.some(function (cozy) {
|
|
@@ -29,13 +30,13 @@ var cozyUrlMatch = function cozyUrlMatch(input, contact) {
|
|
|
29
30
|
|
|
30
31
|
var groupNameMatch = function groupNameMatch(input, contactOrGroup) {
|
|
31
32
|
if (contactOrGroup._type !== Group.doctype) return false;
|
|
32
|
-
var nameInput = new RegExp(input, 'i');
|
|
33
|
+
var nameInput = new RegExp(escapeRegExp(input), 'i');
|
|
33
34
|
return nameInput.test(contactOrGroup.name);
|
|
34
35
|
};
|
|
35
36
|
|
|
36
37
|
var fullnameMatch = function fullnameMatch(input, contact) {
|
|
37
38
|
if (!contact.fullname) return false;
|
|
38
|
-
var fullnameInput = new RegExp(input, 'i');
|
|
39
|
+
var fullnameInput = new RegExp(escapeRegExp(input), 'i');
|
|
39
40
|
return fullnameInput.test(contact.fullname);
|
|
40
41
|
};
|
|
41
42
|
|