cozy-sharing 11.0.1 → 11.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 +14 -0
- package/dist/components/Avatar/GroupAvatar.js +13 -0
- package/dist/components/Avatar/GroupAvatar.stories.js +10 -0
- package/dist/components/Recipient/GroupRecipient.js +49 -0
- package/dist/components/Recipient/GroupRecipient.stories.js +41 -0
- package/dist/components/Recipient/GroupRecipientPermissions.js +71 -0
- package/dist/components/Recipient/GroupRecipientPermissions.stories.js +37 -0
- package/dist/components/Recipient/MemberRecipient.stories.js +11 -1
- package/dist/components/Recipient/MemberRecipientPermissions.js +31 -40
- package/dist/components/Recipient/MemberRecipientPermissions.stories.js +30 -4
- package/dist/components/Recipient/RecipientList.js +16 -1
- package/dist/components/Recipient/RecipientList.stories.js +28 -0
- package/dist/components/Recipient/actions/permission.js +33 -0
- package/dist/components/Recipient/actions/revokeGroup.js +41 -0
- package/dist/components/Recipient/actions/revokeMember.js +41 -0
- package/dist/components/ShareByEmail.js +8 -29
- package/dist/components/ShareByEmail.spec.js +1 -1
- package/dist/components/ShareDialogCozyToCozy.js +2 -2
- package/dist/components/ShareDialogCozyToCozy.spec.js +1 -1
- package/dist/components/ShareDialogTwoStepsConfirmationContainer.js +2 -2
- package/dist/components/ShareDialogTwoStepsConfirmationContainer.spec.js +1 -1
- package/dist/components/ShareModal/EditableSharingModal.js +43 -42
- package/dist/components/ShareModal/EditableSharingModal.spec.js +2 -2
- package/dist/components/ShareModal.js +4 -4
- package/dist/components/ShareRecipientsInput.js +7 -7
- package/dist/components/ShareRecipientsInput.spec.js +2 -2
- package/dist/helpers/recipients.js +38 -0
- package/dist/helpers/successMessage.spec.js +1 -1
- package/dist/propTypes.js +1 -1
- package/dist/queries/queries.js +1 -1
- package/dist/state.js +58 -2
- package/dist/state.spec.js +190 -10
- package/locales/en.json +24 -30
- package/locales/fr.json +24 -30
- package/package.json +2 -2
- package/src/components/Avatar/GroupAvatar.jsx +10 -0
- package/src/components/Avatar/GroupAvatar.stories.jsx +13 -0
- package/src/components/Recipient/GroupRecipient.jsx +56 -0
- package/src/components/Recipient/GroupRecipient.stories.jsx +38 -0
- package/src/components/Recipient/GroupRecipientPermissions.jsx +77 -0
- package/src/components/Recipient/GroupRecipientPermissions.stories.jsx +41 -0
- package/src/components/Recipient/MemberRecipient.stories.jsx +12 -1
- package/src/components/Recipient/MemberRecipientPermissions.jsx +37 -53
- package/src/components/Recipient/MemberRecipientPermissions.stories.jsx +31 -4
- package/src/components/Recipient/RecipientList.jsx +18 -1
- package/src/components/Recipient/RecipientList.stories.jsx +34 -0
- package/src/components/Recipient/actions/permission.js +31 -0
- package/src/components/Recipient/actions/revokeGroup.js +39 -0
- package/src/components/Recipient/actions/revokeMember.js +39 -0
- package/src/components/ShareByEmail.jsx +14 -32
- package/src/components/ShareByEmail.spec.jsx +1 -1
- package/src/components/ShareDialogCozyToCozy.jsx +2 -2
- package/src/components/ShareDialogCozyToCozy.spec.jsx +1 -1
- package/src/components/ShareDialogTwoStepsConfirmationContainer.jsx +2 -2
- package/src/components/ShareDialogTwoStepsConfirmationContainer.spec.jsx +1 -1
- package/src/components/ShareModal/EditableSharingModal.jsx +48 -46
- package/src/components/ShareModal/EditableSharingModal.spec.jsx +1 -1
- package/src/components/ShareModal.jsx +4 -4
- package/src/components/ShareRecipientsInput.jsx +9 -9
- package/src/components/ShareRecipientsInput.spec.jsx +2 -2
- package/src/helpers/recipients.js +45 -0
- package/src/helpers/successMessage.spec.js +1 -1
- package/src/propTypes.js +1 -1
- package/src/queries/queries.js +1 -1
- package/src/state.js +53 -2
- package/src/state.spec.js +230 -9
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
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
|
+
# [11.1.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@11.0.1...cozy-sharing@11.1.0) (2024-03-21)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Add groups to recipients ([4be590d](https://github.com/cozy/cozy-libs/commit/4be590d8280fe9198fb56d32d2ff55665864e746))
|
|
12
|
+
* Add groups to recipients if flag ([4ac2199](https://github.com/cozy/cozy-libs/commit/4ac21990174d1312ee8d5b452e524db6c53429a9))
|
|
13
|
+
* Extract logic from onRecipientPick to an helper ([2d08da1](https://github.com/cozy/cozy-libs/commit/2d08da1fb5a767819d8d89bd3e59f8d9927cceea))
|
|
14
|
+
* **RecipientList:** Show recipient groups ([60d155c](https://github.com/cozy/cozy-libs/commit/60d155c53702782863a777c649e786deeb64a314))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
6
20
|
## [11.0.1](https://github.com/cozy/cozy-libs/compare/cozy-sharing@11.0.0...cozy-sharing@11.0.1) (2024-03-12)
|
|
7
21
|
|
|
8
22
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Avatar from 'cozy-ui/transpiled/react/Avatar';
|
|
3
|
+
import TeamIcon from 'cozy-ui/transpiled/react/Icons/Team';
|
|
4
|
+
|
|
5
|
+
var GroupAvatar = function GroupAvatar(_ref) {
|
|
6
|
+
var size = _ref.size;
|
|
7
|
+
return /*#__PURE__*/React.createElement(Avatar, {
|
|
8
|
+
icon: TeamIcon,
|
|
9
|
+
size: size
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { GroupAvatar };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useClient } from 'cozy-client';
|
|
3
|
+
import Fade from 'cozy-ui/transpiled/react/Fade';
|
|
4
|
+
import ListItem from 'cozy-ui/transpiled/react/ListItem';
|
|
5
|
+
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
|
|
6
|
+
import ListItemSecondaryAction from 'cozy-ui/transpiled/react/ListItemSecondaryAction';
|
|
7
|
+
import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
|
|
8
|
+
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
9
|
+
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
|
|
10
|
+
import { GroupRecipientPermissions } from './GroupRecipientPermissions';
|
|
11
|
+
import { FADE_IN_DURATION } from '../../helpers/recipients';
|
|
12
|
+
import { GroupAvatar } from '../Avatar/GroupAvatar';
|
|
13
|
+
|
|
14
|
+
var GroupRecipient = function GroupRecipient(props) {
|
|
15
|
+
var name = props.name,
|
|
16
|
+
members = props.members,
|
|
17
|
+
fadeIn = props.fadeIn;
|
|
18
|
+
|
|
19
|
+
var _useI18n = useI18n(),
|
|
20
|
+
t = _useI18n.t;
|
|
21
|
+
|
|
22
|
+
var client = useClient();
|
|
23
|
+
var nbMember = members.length;
|
|
24
|
+
var nbMemberReady = members.filter(function (member) {
|
|
25
|
+
return !['revoked', 'mail-not-sent'].includes(member.status);
|
|
26
|
+
}).length;
|
|
27
|
+
var isCurrentInstanceInsideMembers = members.some(function (member) {
|
|
28
|
+
return member.instance === client.options.uri;
|
|
29
|
+
});
|
|
30
|
+
return /*#__PURE__*/React.createElement(Fade, {
|
|
31
|
+
in: true,
|
|
32
|
+
timeout: fadeIn ? FADE_IN_DURATION : 0
|
|
33
|
+
}, /*#__PURE__*/React.createElement(ListItem, {
|
|
34
|
+
disableGutters: true
|
|
35
|
+
}, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(GroupAvatar, {
|
|
36
|
+
size: "small"
|
|
37
|
+
})), /*#__PURE__*/React.createElement(ListItemText, {
|
|
38
|
+
primary: /*#__PURE__*/React.createElement(Typography, {
|
|
39
|
+
className: "u-ellipsis",
|
|
40
|
+
variant: "body1"
|
|
41
|
+
}, name),
|
|
42
|
+
secondary: t('GroupRecipient.secondary', {
|
|
43
|
+
nbMember: nbMember,
|
|
44
|
+
nbMemberReady: nbMemberReady
|
|
45
|
+
}) + (isCurrentInstanceInsideMembers ? " (".concat(t('GroupRecipient.secondary_you'), ")") : '')
|
|
46
|
+
}), /*#__PURE__*/React.createElement(ListItemSecondaryAction, null, /*#__PURE__*/React.createElement(GroupRecipientPermissions, props))));
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export { GroupRecipient };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { GroupRecipient } from './GroupRecipient';
|
|
2
|
+
var meta = {
|
|
3
|
+
component: GroupRecipient,
|
|
4
|
+
args: {
|
|
5
|
+
name: 'Family',
|
|
6
|
+
isOwner: true,
|
|
7
|
+
read_only: false,
|
|
8
|
+
members: [{
|
|
9
|
+
status: 'ready'
|
|
10
|
+
}, {
|
|
11
|
+
status: 'mail-not-sent'
|
|
12
|
+
}, {
|
|
13
|
+
status: 'pending'
|
|
14
|
+
}, {
|
|
15
|
+
status: 'revoked'
|
|
16
|
+
}],
|
|
17
|
+
groupIndex: 0
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
export default meta;
|
|
21
|
+
export var Default = {
|
|
22
|
+
name: 'Default',
|
|
23
|
+
args: {}
|
|
24
|
+
};
|
|
25
|
+
export var InstanceInsideMembers = {
|
|
26
|
+
name: 'Instance inside members',
|
|
27
|
+
args: {
|
|
28
|
+
isOwner: false,
|
|
29
|
+
instance: 'http://alice.cozy.localhost:8080',
|
|
30
|
+
members: [{
|
|
31
|
+
status: 'ready',
|
|
32
|
+
instance: 'http://alice.cozy.localhost:8080'
|
|
33
|
+
}, {
|
|
34
|
+
status: 'mail-not-sent'
|
|
35
|
+
}, {
|
|
36
|
+
status: 'pending'
|
|
37
|
+
}, {
|
|
38
|
+
status: 'revoked'
|
|
39
|
+
}]
|
|
40
|
+
}
|
|
41
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import React, { useState, useRef } from 'react';
|
|
3
|
+
import { useClient } from 'cozy-client';
|
|
4
|
+
import ActionsMenu from 'cozy-ui/transpiled/react/ActionsMenu';
|
|
5
|
+
import { makeActions, divider } from 'cozy-ui/transpiled/react/ActionsMenu/Actions';
|
|
6
|
+
import DropdownButton from 'cozy-ui/transpiled/react/DropdownButton';
|
|
7
|
+
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
|
|
8
|
+
import { permission } from './actions/permission';
|
|
9
|
+
import { revokeGroup } from './actions/revokeGroup';
|
|
10
|
+
|
|
11
|
+
var GroupRecipientPermissions = function GroupRecipientPermissions(_ref) {
|
|
12
|
+
var isOwner = _ref.isOwner,
|
|
13
|
+
instance = _ref.instance,
|
|
14
|
+
_ref$read_only = _ref.read_only,
|
|
15
|
+
isReadOnly = _ref$read_only === void 0 ? false : _ref$read_only,
|
|
16
|
+
className = _ref.className;
|
|
17
|
+
|
|
18
|
+
var _useI18n = useI18n(),
|
|
19
|
+
t = _useI18n.t;
|
|
20
|
+
|
|
21
|
+
var buttonRef = useRef();
|
|
22
|
+
var client = useClient();
|
|
23
|
+
|
|
24
|
+
var _useState = useState(false),
|
|
25
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
26
|
+
isMenuDisplayed = _useState2[0],
|
|
27
|
+
setMenuDisplayed = _useState2[1];
|
|
28
|
+
|
|
29
|
+
var instanceMatchesClient = instance !== undefined && instance === client.options.uri;
|
|
30
|
+
var shouldShowMenu = instanceMatchesClient && !isOwner || isOwner;
|
|
31
|
+
|
|
32
|
+
var toggleMenu = function toggleMenu() {
|
|
33
|
+
return setMenuDisplayed(!isMenuDisplayed);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
var hideMenu = function hideMenu() {
|
|
37
|
+
return setMenuDisplayed(false);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
var handleRevocation = function handleRevocation() {// TODO : Need to be implemented
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
var type = isReadOnly ? 'one-way' : 'two-way';
|
|
44
|
+
var actions = makeActions([permission, divider, revokeGroup], {
|
|
45
|
+
t: t,
|
|
46
|
+
type: type,
|
|
47
|
+
isOwner: isOwner,
|
|
48
|
+
handleRevocation: handleRevocation
|
|
49
|
+
});
|
|
50
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
51
|
+
className: className
|
|
52
|
+
}, shouldShowMenu && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DropdownButton, {
|
|
53
|
+
ref: buttonRef,
|
|
54
|
+
"aria-controls": "simple-menu",
|
|
55
|
+
"aria-haspopup": "true",
|
|
56
|
+
onClick: toggleMenu,
|
|
57
|
+
textVariant: "body2"
|
|
58
|
+
}, t("Share.type.".concat(type)).toLowerCase()), /*#__PURE__*/React.createElement(ActionsMenu, {
|
|
59
|
+
ref: buttonRef,
|
|
60
|
+
open: isMenuDisplayed,
|
|
61
|
+
actions: actions,
|
|
62
|
+
anchorOrigin: {
|
|
63
|
+
vertical: 'bottom',
|
|
64
|
+
horizontal: 'right'
|
|
65
|
+
},
|
|
66
|
+
autoClose: true,
|
|
67
|
+
onClose: hideMenu
|
|
68
|
+
})));
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export { GroupRecipientPermissions };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { GroupRecipientPermissions } from './GroupRecipientPermissions';
|
|
2
|
+
var meta = {
|
|
3
|
+
component: GroupRecipientPermissions,
|
|
4
|
+
args: {
|
|
5
|
+
onRevoke: function onRevoke() {},
|
|
6
|
+
onRevokeSelf: function onRevokeSelf() {},
|
|
7
|
+
type: 'two-way',
|
|
8
|
+
status: 'ready',
|
|
9
|
+
groupIndex: 0
|
|
10
|
+
},
|
|
11
|
+
argTypes: {
|
|
12
|
+
status: {
|
|
13
|
+
control: 'select',
|
|
14
|
+
options: ['ready', 'mail-not-sent', 'pending', 'seen', 'owner'],
|
|
15
|
+
defaultValue: 'ready'
|
|
16
|
+
},
|
|
17
|
+
type: {
|
|
18
|
+
control: 'select',
|
|
19
|
+
options: ['one-way', 'two-way'],
|
|
20
|
+
defaultValue: 'two-way'
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
export default meta;
|
|
25
|
+
export var Owner = {
|
|
26
|
+
name: 'Owner',
|
|
27
|
+
args: {
|
|
28
|
+
isOwner: true
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export var Self = {
|
|
32
|
+
name: 'Self',
|
|
33
|
+
args: {
|
|
34
|
+
isOwner: false,
|
|
35
|
+
instance: 'http://alice.cozy.localhost:8080'
|
|
36
|
+
}
|
|
37
|
+
};
|
|
@@ -7,7 +7,10 @@ var meta = {
|
|
|
7
7
|
status: 'ready',
|
|
8
8
|
recipientConfirmationData: null,
|
|
9
9
|
verifyRecipient: function verifyRecipient() {},
|
|
10
|
-
fadeIn: true
|
|
10
|
+
fadeIn: true,
|
|
11
|
+
type: 'two-way',
|
|
12
|
+
onRevoke: function onRevoke() {},
|
|
13
|
+
onRevokeSelf: function onRevokeSelf() {}
|
|
11
14
|
},
|
|
12
15
|
argTypes: {
|
|
13
16
|
status: {
|
|
@@ -29,6 +32,13 @@ export var Owner = {
|
|
|
29
32
|
status: 'owner'
|
|
30
33
|
}
|
|
31
34
|
};
|
|
35
|
+
export var SameInstance = {
|
|
36
|
+
name: 'SameInstance',
|
|
37
|
+
args: {
|
|
38
|
+
isOwner: false,
|
|
39
|
+
instance: 'http://alice.cozy.localhost:8080'
|
|
40
|
+
}
|
|
41
|
+
};
|
|
32
42
|
export var RecipientConfirm = {
|
|
33
43
|
name: 'RecipientConfirm',
|
|
34
44
|
args: {
|
|
@@ -3,15 +3,14 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
4
|
import React, { useState, useRef, useCallback } from 'react';
|
|
5
5
|
import { useClient } from 'cozy-client';
|
|
6
|
+
import ActionsMenu from 'cozy-ui/transpiled/react/ActionsMenu';
|
|
7
|
+
import { makeActions, divider } from 'cozy-ui/transpiled/react/ActionsMenu/Actions';
|
|
6
8
|
import DropdownButton from 'cozy-ui/transpiled/react/DropdownButton';
|
|
7
|
-
import Icon from 'cozy-ui/transpiled/react/Icon';
|
|
8
|
-
import EyeIcon from 'cozy-ui/transpiled/react/Icons/Eye';
|
|
9
|
-
import RenameIcon from 'cozy-ui/transpiled/react/Icons/Rename';
|
|
10
|
-
import TrashIcon from 'cozy-ui/transpiled/react/Icons/Trash';
|
|
11
9
|
import Spinner from 'cozy-ui/transpiled/react/Spinner';
|
|
12
10
|
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
13
|
-
import ActionMenu, { ActionMenuItem } from 'cozy-ui/transpiled/react/deprecated/ActionMenu';
|
|
14
11
|
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
|
|
12
|
+
import { permission } from './actions/permission';
|
|
13
|
+
import { revokeMember } from './actions/revokeMember';
|
|
15
14
|
|
|
16
15
|
var MemberRecipientPermissions = function MemberRecipientPermissions(_ref) {
|
|
17
16
|
var isOwner = _ref.isOwner,
|
|
@@ -19,12 +18,11 @@ var MemberRecipientPermissions = function MemberRecipientPermissions(_ref) {
|
|
|
19
18
|
instance = _ref.instance,
|
|
20
19
|
type = _ref.type,
|
|
21
20
|
document = _ref.document,
|
|
22
|
-
documentType = _ref.documentType,
|
|
23
21
|
className = _ref.className,
|
|
24
22
|
onRevoke = _ref.onRevoke,
|
|
25
23
|
onRevokeSelf = _ref.onRevokeSelf,
|
|
26
24
|
sharingId = _ref.sharingId,
|
|
27
|
-
|
|
25
|
+
memberIndex = _ref.memberIndex;
|
|
28
26
|
|
|
29
27
|
var _useI18n = useI18n(),
|
|
30
28
|
t = _useI18n.t;
|
|
@@ -40,21 +38,21 @@ var MemberRecipientPermissions = function MemberRecipientPermissions(_ref) {
|
|
|
40
38
|
var _useState3 = useState(false),
|
|
41
39
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
42
40
|
isMenuDisplayed = _useState4[0],
|
|
43
|
-
|
|
41
|
+
setMenuDisplayed = _useState4[1];
|
|
44
42
|
|
|
45
43
|
var instanceMatchesClient = instance !== undefined && instance === client.options.uri;
|
|
46
44
|
var contactIsOwner = status === 'owner';
|
|
47
45
|
var shouldShowMenu = !revoking && !contactIsOwner && (instanceMatchesClient && !isOwner || isOwner);
|
|
48
46
|
|
|
49
|
-
var
|
|
50
|
-
return
|
|
47
|
+
var toggleMenu = function toggleMenu() {
|
|
48
|
+
return setMenuDisplayed(!isMenuDisplayed);
|
|
51
49
|
};
|
|
52
50
|
|
|
53
51
|
var hideMenu = function hideMenu() {
|
|
54
|
-
return
|
|
52
|
+
return setMenuDisplayed(false);
|
|
55
53
|
};
|
|
56
54
|
|
|
57
|
-
var
|
|
55
|
+
var handleRevocation = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
58
56
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
59
57
|
while (1) switch (_context.prev = _context.next) {
|
|
60
58
|
case 0:
|
|
@@ -66,7 +64,7 @@ var MemberRecipientPermissions = function MemberRecipientPermissions(_ref) {
|
|
|
66
64
|
}
|
|
67
65
|
|
|
68
66
|
_context.next = 4;
|
|
69
|
-
return onRevoke(document, sharingId,
|
|
67
|
+
return onRevoke(document, sharingId, memberIndex);
|
|
70
68
|
|
|
71
69
|
case 4:
|
|
72
70
|
_context.next = 8;
|
|
@@ -84,41 +82,34 @@ var MemberRecipientPermissions = function MemberRecipientPermissions(_ref) {
|
|
|
84
82
|
return _context.stop();
|
|
85
83
|
}
|
|
86
84
|
}, _callee);
|
|
87
|
-
})), [isOwner, onRevoke, onRevokeSelf, document, sharingId,
|
|
88
|
-
var
|
|
85
|
+
})), [isOwner, onRevoke, onRevokeSelf, document, sharingId, memberIndex]);
|
|
86
|
+
var actions = makeActions([permission, divider, revokeMember], {
|
|
87
|
+
t: t,
|
|
88
|
+
type: type,
|
|
89
|
+
isOwner: isOwner,
|
|
90
|
+
handleRevocation: handleRevocation
|
|
91
|
+
});
|
|
89
92
|
return /*#__PURE__*/React.createElement("div", {
|
|
90
93
|
className: className
|
|
91
94
|
}, revoking && /*#__PURE__*/React.createElement(Spinner, null), !shouldShowMenu && !revoking && /*#__PURE__*/React.createElement(Typography, {
|
|
92
95
|
variant: "body2"
|
|
93
96
|
}, t("Share.status.".concat(status)).toLowerCase()), shouldShowMenu && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DropdownButton, {
|
|
94
|
-
onClick: showMenu,
|
|
95
97
|
ref: buttonRef,
|
|
98
|
+
"aria-controls": "simple-menu",
|
|
99
|
+
"aria-haspopup": "true",
|
|
100
|
+
onClick: toggleMenu,
|
|
96
101
|
textVariant: "body2"
|
|
97
|
-
}, t("Share.type.".concat(type)).toLowerCase()),
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
+
}, t("Share.type.".concat(type)).toLowerCase()), /*#__PURE__*/React.createElement(ActionsMenu, {
|
|
103
|
+
ref: buttonRef,
|
|
104
|
+
open: isMenuDisplayed,
|
|
105
|
+
actions: actions,
|
|
106
|
+
anchorOrigin: {
|
|
107
|
+
vertical: 'bottom',
|
|
108
|
+
horizontal: 'right'
|
|
102
109
|
},
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
icon: PermissionIcon,
|
|
107
|
-
color: "var(--primaryTextColor)"
|
|
108
|
-
})
|
|
109
|
-
}, t("Share.type.".concat(type))), /*#__PURE__*/React.createElement("hr", null), /*#__PURE__*/React.createElement(ActionMenuItem, {
|
|
110
|
-
onClick: onRevokeClick,
|
|
111
|
-
left: /*#__PURE__*/React.createElement(Icon, {
|
|
112
|
-
icon: TrashIcon,
|
|
113
|
-
color: "var(--errorColor)"
|
|
114
|
-
})
|
|
115
|
-
}, /*#__PURE__*/React.createElement(Typography, {
|
|
116
|
-
className: "u-error",
|
|
117
|
-
variant: "body1"
|
|
118
|
-
}, isOwner ? t("".concat(documentType, ".share.revoke.title")) : t("".concat(documentType, ".share.revokeSelf.title"))), /*#__PURE__*/React.createElement(Typography, {
|
|
119
|
-
variant: "caption",
|
|
120
|
-
color: "textSecondary"
|
|
121
|
-
}, isOwner ? t("".concat(documentType, ".share.revoke.desc")) : t("".concat(documentType, ".share.revokeSelf.desc")))))));
|
|
110
|
+
autoClose: true,
|
|
111
|
+
onClose: hideMenu
|
|
112
|
+
})));
|
|
122
113
|
};
|
|
123
114
|
|
|
124
115
|
export default MemberRecipientPermissions;
|
|
@@ -1,10 +1,36 @@
|
|
|
1
1
|
import MemberRecipientPermissions from './MemberRecipientPermissions';
|
|
2
2
|
var meta = {
|
|
3
3
|
component: MemberRecipientPermissions,
|
|
4
|
-
args: {
|
|
4
|
+
args: {
|
|
5
|
+
onRevoke: function onRevoke() {},
|
|
6
|
+
onRevokeSelf: function onRevokeSelf() {},
|
|
7
|
+
type: 'two-way',
|
|
8
|
+
status: 'ready'
|
|
9
|
+
},
|
|
10
|
+
argTypes: {
|
|
11
|
+
status: {
|
|
12
|
+
control: 'select',
|
|
13
|
+
options: ['ready', 'mail-not-sent', 'pending', 'seen', 'owner'],
|
|
14
|
+
defaultValue: 'ready'
|
|
15
|
+
},
|
|
16
|
+
type: {
|
|
17
|
+
control: 'select',
|
|
18
|
+
options: ['one-way', 'two-way'],
|
|
19
|
+
defaultValue: 'two-way'
|
|
20
|
+
}
|
|
21
|
+
}
|
|
5
22
|
};
|
|
6
23
|
export default meta;
|
|
7
|
-
export var
|
|
8
|
-
name: '
|
|
9
|
-
args: {
|
|
24
|
+
export var Owner = {
|
|
25
|
+
name: 'Owner',
|
|
26
|
+
args: {
|
|
27
|
+
isOwner: true
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
export var Self = {
|
|
31
|
+
name: 'Self',
|
|
32
|
+
args: {
|
|
33
|
+
isOwner: false,
|
|
34
|
+
instance: 'http://alice.cozy.localhost:8080'
|
|
35
|
+
}
|
|
10
36
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { GroupRecipient } from './GroupRecipient';
|
|
3
4
|
import MemberRecipient from './MemberRecipient';
|
|
4
5
|
import { usePrevious } from '../../helpers/hooks';
|
|
5
6
|
import { filterAndReworkRecipients } from '../../helpers/recipients';
|
|
@@ -19,8 +20,22 @@ var RecipientList = function RecipientList(_ref) {
|
|
|
19
20
|
var recipientConfirmationData = recipientsToBeConfirmed.find(function (user) {
|
|
20
21
|
return user.email === recipient.email;
|
|
21
22
|
});
|
|
23
|
+
var isGroupRecipient = recipient.members;
|
|
24
|
+
|
|
25
|
+
if (isGroupRecipient) {
|
|
26
|
+
return /*#__PURE__*/React.createElement(GroupRecipient, _extends({}, recipient, {
|
|
27
|
+
isOwner: isOwner,
|
|
28
|
+
key: recipient.index,
|
|
29
|
+
document: document,
|
|
30
|
+
documentType: documentType,
|
|
31
|
+
onRevoke: onRevoke,
|
|
32
|
+
onRevokeSelf: onRevokeSelf,
|
|
33
|
+
fadeIn: recipient.hasBeenJustAdded
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
|
|
22
37
|
return /*#__PURE__*/React.createElement(MemberRecipient, _extends({}, recipient, {
|
|
23
|
-
key:
|
|
38
|
+
key: recipient.index,
|
|
24
39
|
isOwner: isOwner,
|
|
25
40
|
document: document,
|
|
26
41
|
documentType: documentType,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
1
2
|
import { RecipientList } from './RecipientList';
|
|
2
3
|
import { recipients } from '../../../.storybook/fixtures/recipients';
|
|
3
4
|
var meta = {
|
|
@@ -23,4 +24,31 @@ export var Owner = {
|
|
|
23
24
|
args: {
|
|
24
25
|
isOwner: true
|
|
25
26
|
}
|
|
27
|
+
};
|
|
28
|
+
export var WithGroup = {
|
|
29
|
+
name: 'With group',
|
|
30
|
+
args: {
|
|
31
|
+
recipients: [].concat(_toConsumableArray(recipients), [{
|
|
32
|
+
id: '2c8d4d5abbec5b4606a1ebe01a021dfd',
|
|
33
|
+
name: 'Famille',
|
|
34
|
+
addedBy: 0,
|
|
35
|
+
read_only: false,
|
|
36
|
+
index: 0,
|
|
37
|
+
members: [{
|
|
38
|
+
status: 'pending',
|
|
39
|
+
email: 'ben@gmail.com',
|
|
40
|
+
only_in_groups: true,
|
|
41
|
+
groups: [0],
|
|
42
|
+
type: 'two-way',
|
|
43
|
+
index: 1
|
|
44
|
+
}, {
|
|
45
|
+
status: 'pending',
|
|
46
|
+
email: 'bob@gmail.com',
|
|
47
|
+
only_in_groups: true,
|
|
48
|
+
groups: [0],
|
|
49
|
+
type: 'two-way',
|
|
50
|
+
index: 2
|
|
51
|
+
}]
|
|
52
|
+
}])
|
|
53
|
+
}
|
|
26
54
|
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem';
|
|
4
|
+
import Icon from 'cozy-ui/transpiled/react/Icon';
|
|
5
|
+
import EyeIcon from 'cozy-ui/transpiled/react/Icons/Eye';
|
|
6
|
+
import RenameIcon from 'cozy-ui/transpiled/react/Icons/Rename';
|
|
7
|
+
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
|
|
8
|
+
import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
|
|
9
|
+
|
|
10
|
+
var permission = function permission(_ref) {
|
|
11
|
+
var t = _ref.t,
|
|
12
|
+
type = _ref.type;
|
|
13
|
+
var title = t("Share.type.".concat(type));
|
|
14
|
+
var icon = type === 'two-way' ? RenameIcon : EyeIcon;
|
|
15
|
+
return {
|
|
16
|
+
name: 'permission',
|
|
17
|
+
label: title,
|
|
18
|
+
icon: icon,
|
|
19
|
+
action: null,
|
|
20
|
+
Component: /*#__PURE__*/forwardRef(function RevokeItem(props, ref) {
|
|
21
|
+
return /*#__PURE__*/React.createElement(ActionsMenuItem, _extends({}, props, {
|
|
22
|
+
ref: ref,
|
|
23
|
+
button: false
|
|
24
|
+
}), /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Icon, {
|
|
25
|
+
icon: icon
|
|
26
|
+
})), /*#__PURE__*/React.createElement(ListItemText, {
|
|
27
|
+
primary: title
|
|
28
|
+
}));
|
|
29
|
+
})
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { permission };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem';
|
|
4
|
+
import Icon from 'cozy-ui/transpiled/react/Icon';
|
|
5
|
+
import ForbiddenIcon from 'cozy-ui/transpiled/react/Icons/Forbidden';
|
|
6
|
+
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
|
|
7
|
+
import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
|
|
8
|
+
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
9
|
+
|
|
10
|
+
var revokeGroup = function revokeGroup(_ref) {
|
|
11
|
+
var t = _ref.t,
|
|
12
|
+
isOwner = _ref.isOwner,
|
|
13
|
+
handleRevocation = _ref.handleRevocation;
|
|
14
|
+
var revokeType = isOwner ? 'revoke' : 'revokeSelf';
|
|
15
|
+
var title = t("RevokeGroupItem.".concat(revokeType, ".title"));
|
|
16
|
+
var desc = t("RevokeGroupItem.".concat(revokeType, ".desc"));
|
|
17
|
+
var icon = ForbiddenIcon;
|
|
18
|
+
return {
|
|
19
|
+
name: 'revokeMember',
|
|
20
|
+
label: title,
|
|
21
|
+
icon: icon,
|
|
22
|
+
action: function action() {
|
|
23
|
+
handleRevocation();
|
|
24
|
+
},
|
|
25
|
+
Component: /*#__PURE__*/forwardRef(function RevokeMemberItem(props, ref) {
|
|
26
|
+
return /*#__PURE__*/React.createElement(ActionsMenuItem, _extends({}, props, {
|
|
27
|
+
ref: ref
|
|
28
|
+
}), /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Icon, {
|
|
29
|
+
icon: icon,
|
|
30
|
+
color: "var(--errorColor)"
|
|
31
|
+
})), /*#__PURE__*/React.createElement(ListItemText, {
|
|
32
|
+
primary: /*#__PURE__*/React.createElement(Typography, {
|
|
33
|
+
color: "error"
|
|
34
|
+
}, title),
|
|
35
|
+
secondary: desc
|
|
36
|
+
}));
|
|
37
|
+
})
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export { revokeGroup };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem';
|
|
4
|
+
import Icon from 'cozy-ui/transpiled/react/Icon';
|
|
5
|
+
import TrashIcon from 'cozy-ui/transpiled/react/Icons/Trash';
|
|
6
|
+
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
|
|
7
|
+
import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
|
|
8
|
+
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
9
|
+
|
|
10
|
+
var revokeMember = function revokeMember(_ref) {
|
|
11
|
+
var t = _ref.t,
|
|
12
|
+
isOwner = _ref.isOwner,
|
|
13
|
+
handleRevocation = _ref.handleRevocation;
|
|
14
|
+
var revokeType = isOwner ? 'revoke' : 'revokeSelf';
|
|
15
|
+
var title = t("RevokeMemberItem.".concat(revokeType, ".title"));
|
|
16
|
+
var desc = t("RevokeMemberItem.".concat(revokeType, ".desc"));
|
|
17
|
+
var icon = TrashIcon;
|
|
18
|
+
return {
|
|
19
|
+
name: 'revokeMember',
|
|
20
|
+
label: title,
|
|
21
|
+
icon: icon,
|
|
22
|
+
action: function action() {
|
|
23
|
+
handleRevocation();
|
|
24
|
+
},
|
|
25
|
+
Component: /*#__PURE__*/forwardRef(function RevokeMemberItem(props, ref) {
|
|
26
|
+
return /*#__PURE__*/React.createElement(ActionsMenuItem, _extends({}, props, {
|
|
27
|
+
ref: ref
|
|
28
|
+
}), /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Icon, {
|
|
29
|
+
icon: icon,
|
|
30
|
+
color: "var(--errorColor)"
|
|
31
|
+
})), /*#__PURE__*/React.createElement(ListItemText, {
|
|
32
|
+
primary: /*#__PURE__*/React.createElement(Typography, {
|
|
33
|
+
color: "error"
|
|
34
|
+
}, title),
|
|
35
|
+
secondary: desc
|
|
36
|
+
}));
|
|
37
|
+
})
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export { revokeMember };
|