cozy-sharing 5.0.0 → 5.0.1
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 +7 -0
- package/dist/SharingBanner/components/getHomeLinkHref.js +5 -0
- package/dist/SharingBanner/components/getHomeLinkHref.spec.js +9 -0
- package/dist/SharingBanner/hooks/useSharingInfos.js +3 -2
- package/dist/SharingBanner/index.js +7 -2
- package/dist/components/EditLinkPermissionDialog.js +72 -0
- package/dist/components/EditLinkPermissionDialog.spec.js +48 -0
- package/dist/components/Recipient/AvatarPlusX.js +41 -0
- package/dist/components/Recipient/Identity.js +43 -0
- package/dist/components/Recipient/LinkRecipient.js +72 -0
- package/dist/components/Recipient/LinkRecipientPermissions.js +159 -0
- package/dist/components/Recipient/OwnerIdentity.js +44 -0
- package/dist/components/Recipient/Recipient.js +72 -0
- package/dist/components/Recipient/Recipient.spec.js +178 -0
- package/dist/components/Recipient/RecipientAvatar.js +33 -0
- package/dist/components/Recipient/RecipientConfirm.js +63 -0
- package/dist/components/Recipient/RecipientPermissions.js +126 -0
- package/dist/components/Recipient/RecipientPlusX.js +45 -0
- package/dist/components/Recipient/RecipientStatus.js +64 -0
- package/dist/components/Recipient/RecipientWithoutStatus.js +45 -0
- package/dist/components/Recipient/RecipientsAvatars.js +100 -0
- package/dist/components/Recipient/RecipientsAvatars.spec.js +145 -0
- package/dist/components/Recipient/recipient.styl +82 -0
- package/dist/components/ShareButtonWithRecipients.js +8 -0
- package/dist/helpers/documentType.js +6 -0
- package/dist/helpers/link.js +5 -0
- package/dist/helpers/permissions.js +8 -0
- package/dist/helpers/recipients.js +24 -0
- package/dist/helpers/synchronousJobQueue.js +67 -0
- package/dist/helpers/synchronousJobQueue.spec.js +97 -0
- package/dist/queries/queries.js +72 -0
- package/package.json +2 -3
- package/src/SharingBanner/hooks/useSharingInfos.jsx +3 -3
- package/src/SharingBanner/index.jsx +7 -3
- package/LICENSE +0 -21
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import Recipient from './Recipient';
|
|
5
|
+
import AppLike from '../../../test/AppLike';
|
|
6
|
+
import { createMockClient } from 'cozy-client';
|
|
7
|
+
import { render, fireEvent } from '@testing-library/react';
|
|
8
|
+
describe('Recipient component', function () {
|
|
9
|
+
var client = createMockClient({});
|
|
10
|
+
client.options = {
|
|
11
|
+
uri: 'foo.mycozy.cloud'
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
var setup = function setup(props) {
|
|
15
|
+
return render( /*#__PURE__*/React.createElement(AppLike, {
|
|
16
|
+
client: client
|
|
17
|
+
}, /*#__PURE__*/React.createElement(Recipient, props)));
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
var createRangeBackup;
|
|
21
|
+
beforeAll(function () {
|
|
22
|
+
createRangeBackup = global.document.createRange;
|
|
23
|
+
global.document.createRange = jest.fn(function () {
|
|
24
|
+
return {
|
|
25
|
+
setStart: function setStart() {},
|
|
26
|
+
setEnd: function setEnd() {},
|
|
27
|
+
commonAncestorContainer: {
|
|
28
|
+
nodeName: 'BODY',
|
|
29
|
+
ownerDocument: document
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
afterAll(function () {
|
|
35
|
+
global.document.createRange = createRangeBackup;
|
|
36
|
+
});
|
|
37
|
+
it('should render if isMe ', function () {
|
|
38
|
+
var _setup = setup({
|
|
39
|
+
instance: 'foo.mycozy.cloud',
|
|
40
|
+
status: 'ready',
|
|
41
|
+
type: 'two-way'
|
|
42
|
+
}),
|
|
43
|
+
getByText = _setup.getByText;
|
|
44
|
+
|
|
45
|
+
expect(getByText('You')).toBeTruthy();
|
|
46
|
+
expect(getByText('foo.mycozy.cloud')).toBeTruthy();
|
|
47
|
+
});
|
|
48
|
+
it('should match snapshot if isOwner', function () {
|
|
49
|
+
var _setup2 = setup({
|
|
50
|
+
instance: 'foo.mycozy.cloud',
|
|
51
|
+
status: 'ready',
|
|
52
|
+
type: 'two-way',
|
|
53
|
+
isOwner: true
|
|
54
|
+
}),
|
|
55
|
+
getByText = _setup2.getByText;
|
|
56
|
+
|
|
57
|
+
expect(getByText('You')).toBeTruthy();
|
|
58
|
+
expect(getByText('foo.mycozy.cloud')).toBeTruthy();
|
|
59
|
+
});
|
|
60
|
+
it('should call revokeSelf if I am not the owner but try to revoke myself', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
61
|
+
var onRevoke, onRevokeSelf, _setup3, getByText;
|
|
62
|
+
|
|
63
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
64
|
+
while (1) {
|
|
65
|
+
switch (_context.prev = _context.next) {
|
|
66
|
+
case 0:
|
|
67
|
+
onRevoke = jest.fn();
|
|
68
|
+
onRevokeSelf = jest.fn();
|
|
69
|
+
_setup3 = setup({
|
|
70
|
+
instance: 'foo.mycozy.cloud',
|
|
71
|
+
status: 'ready',
|
|
72
|
+
type: 'two-way',
|
|
73
|
+
documentType: 'Files',
|
|
74
|
+
onRevoke: onRevoke,
|
|
75
|
+
onRevokeSelf: onRevokeSelf
|
|
76
|
+
}), getByText = _setup3.getByText;
|
|
77
|
+
fireEvent.click(getByText('can change'));
|
|
78
|
+
fireEvent.click(getByText('Remove me from sharing'));
|
|
79
|
+
expect(onRevoke).not.toBeCalled();
|
|
80
|
+
expect(onRevokeSelf).toBeCalled();
|
|
81
|
+
|
|
82
|
+
case 7:
|
|
83
|
+
case "end":
|
|
84
|
+
return _context.stop();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}, _callee);
|
|
88
|
+
})));
|
|
89
|
+
it('should call revoke if I am the owner of the sharing', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
90
|
+
var onRevoke, onRevokeSelf, _setup4, getByText;
|
|
91
|
+
|
|
92
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
93
|
+
while (1) {
|
|
94
|
+
switch (_context2.prev = _context2.next) {
|
|
95
|
+
case 0:
|
|
96
|
+
onRevoke = jest.fn();
|
|
97
|
+
onRevokeSelf = jest.fn();
|
|
98
|
+
_setup4 = setup({
|
|
99
|
+
instance: 'foo.mycozy.cloud',
|
|
100
|
+
status: 'ready',
|
|
101
|
+
type: 'two-way',
|
|
102
|
+
isOwner: true,
|
|
103
|
+
documentType: 'Files',
|
|
104
|
+
onRevoke: onRevoke,
|
|
105
|
+
onRevokeSelf: onRevokeSelf
|
|
106
|
+
}), getByText = _setup4.getByText;
|
|
107
|
+
fireEvent.click(getByText('can change'));
|
|
108
|
+
fireEvent.click(getByText('Remove from sharing'));
|
|
109
|
+
expect(onRevoke).toBeCalled();
|
|
110
|
+
expect(onRevokeSelf).not.toBeCalled();
|
|
111
|
+
|
|
112
|
+
case 7:
|
|
113
|
+
case "end":
|
|
114
|
+
return _context2.stop();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}, _callee2);
|
|
118
|
+
})));
|
|
119
|
+
it('should render confirmation actions if recipient is waiting for confirmation', function () {
|
|
120
|
+
var confirmRecipient = jest.fn();
|
|
121
|
+
var rejectRecipient = jest.fn();
|
|
122
|
+
|
|
123
|
+
var _setup5 = setup({
|
|
124
|
+
instance: 'foo.mycozy.cloud',
|
|
125
|
+
status: 'ready',
|
|
126
|
+
type: 'two-way',
|
|
127
|
+
isOwner: false,
|
|
128
|
+
documentType: 'Organizations',
|
|
129
|
+
recipientConfirmationData: {
|
|
130
|
+
email: 'me@bob.cozy.localhost'
|
|
131
|
+
},
|
|
132
|
+
rejectRecipient: rejectRecipient,
|
|
133
|
+
confirmRecipient: confirmRecipient
|
|
134
|
+
}),
|
|
135
|
+
getByText = _setup5.getByText;
|
|
136
|
+
|
|
137
|
+
expect(getByText('Verify')).toBeTruthy();
|
|
138
|
+
});
|
|
139
|
+
it('should not render confirmation actions if no recipient is waiting for confirmation', function () {
|
|
140
|
+
var confirmRecipient = jest.fn();
|
|
141
|
+
var rejectRecipient = jest.fn();
|
|
142
|
+
|
|
143
|
+
var _setup6 = setup({
|
|
144
|
+
instance: 'foo.mycozy.cloud',
|
|
145
|
+
status: 'ready',
|
|
146
|
+
type: 'two-way',
|
|
147
|
+
isOwner: false,
|
|
148
|
+
documentType: 'Organizations',
|
|
149
|
+
recipientConfirmationData: undefined,
|
|
150
|
+
rejectRecipient: rejectRecipient,
|
|
151
|
+
confirmRecipient: confirmRecipient
|
|
152
|
+
}),
|
|
153
|
+
queryByText = _setup6.queryByText;
|
|
154
|
+
|
|
155
|
+
expect(queryByText('Verify')).not.toBeInTheDocument();
|
|
156
|
+
});
|
|
157
|
+
it("should call verifyRecipient when clicking 'verify' button", function () {
|
|
158
|
+
var verifyRecipient = jest.fn();
|
|
159
|
+
|
|
160
|
+
var _setup7 = setup({
|
|
161
|
+
instance: 'foo.mycozy.cloud',
|
|
162
|
+
status: 'ready',
|
|
163
|
+
type: 'two-way',
|
|
164
|
+
isOwner: false,
|
|
165
|
+
documentType: 'Organizations',
|
|
166
|
+
recipientConfirmationData: {
|
|
167
|
+
email: 'me@bob.cozy.localhost'
|
|
168
|
+
},
|
|
169
|
+
verifyRecipient: verifyRecipient
|
|
170
|
+
}),
|
|
171
|
+
getByText = _setup7.getByText;
|
|
172
|
+
|
|
173
|
+
fireEvent.click(getByText('Verify'));
|
|
174
|
+
expect(verifyRecipient).toBeCalledWith({
|
|
175
|
+
email: 'me@bob.cozy.localhost'
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["recipient"];
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { useClient } from 'cozy-client';
|
|
6
|
+
import Avatar from 'cozy-ui/transpiled/react/Avatar';
|
|
7
|
+
import { getDisplayName, getInitials } from '../../models';
|
|
8
|
+
|
|
9
|
+
var RecipientAvatar = function RecipientAvatar(_ref) {
|
|
10
|
+
var recipient = _ref.recipient,
|
|
11
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
12
|
+
|
|
13
|
+
var client = useClient();
|
|
14
|
+
/**
|
|
15
|
+
* avatarPath is always the same for a recipient, but image
|
|
16
|
+
* can be different since the stack generate it on the fly.
|
|
17
|
+
* It can be "gray" during the first load depending of the
|
|
18
|
+
* status' sharing, but can become active (from the realtime)
|
|
19
|
+
* so we need a way to "refresh" the image. Passing the
|
|
20
|
+
* status in the url force the refresh of the image when the
|
|
21
|
+
* status changes
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
var image = recipient.avatarPath && recipient.status ? "".concat(client.options.uri).concat(recipient.avatarPath, "?v=").concat(recipient.status) : null;
|
|
25
|
+
return /*#__PURE__*/React.createElement(Avatar, _extends({
|
|
26
|
+
image: image,
|
|
27
|
+
text: getInitials(recipient),
|
|
28
|
+
textId: getDisplayName(recipient),
|
|
29
|
+
disabled: recipient.status === 'pending' || recipient.status === 'mail-not-send'
|
|
30
|
+
}, rest));
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export default RecipientAvatar;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { useI18n } from 'cozy-ui/transpiled/react/I18n';
|
|
4
|
+
import Button from 'cozy-ui/transpiled/react/Button';
|
|
5
|
+
var modalStyles = {
|
|
6
|
+
"share-modal-content": "share__share-modal-content___XTtaK",
|
|
7
|
+
"coz-form": "share__coz-form___33NYF",
|
|
8
|
+
"coz-form-group": "share__coz-form-group___1PLAZ",
|
|
9
|
+
"coz-form-desc": "share__coz-form-desc___-pmK5",
|
|
10
|
+
"coz-form-label": "share__coz-form-label___31jb0",
|
|
11
|
+
"coz-form-label--error": "share__coz-form-label--error___2EXCl",
|
|
12
|
+
"coz-form-errors": "share__coz-form-errors___1rk2R",
|
|
13
|
+
"coz-form-controls": "share__coz-form-controls___39Uwg",
|
|
14
|
+
"coz-form-controls--full": "share__coz-form-controls--full___1YpNp",
|
|
15
|
+
"coz-form-controls--dispatch": "share__coz-form-controls--dispatch___3JXzz",
|
|
16
|
+
"error": "share__error___6Ycal",
|
|
17
|
+
"CozyTheme--inverted": "share__CozyTheme--inverted___2pLD2",
|
|
18
|
+
"CozyTheme--normal": "share__CozyTheme--normal___qSFyr",
|
|
19
|
+
"share-byemail-onlybylink": "share__share-byemail-onlybylink___C_7b_",
|
|
20
|
+
"aligned-dropdown-button": "share__aligned-dropdown-button___CeTDs",
|
|
21
|
+
"share-type-control": "share__share-type-control___KcpDf",
|
|
22
|
+
"select-wrapper": "share__select-wrapper___3FfiH",
|
|
23
|
+
"select-option": "share__select-option___13o6b",
|
|
24
|
+
"select-option-label": "share__select-option-label___Zj_RU",
|
|
25
|
+
"select-option-desc": "share__select-option-desc___6uaQq",
|
|
26
|
+
"share-details-created": "share__share-details-created___13BO0",
|
|
27
|
+
"share-details-perm": "share__share-details-perm___23_VF",
|
|
28
|
+
"share-details-perm-desc": "share__share-details-perm-desc___tqfXx",
|
|
29
|
+
"spin": "share__spin___1P7nU",
|
|
30
|
+
"shake": "share__shake___1EeCI"
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Displays the confirmation interface that allows to confirm or reject a recipient
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
var RecipientConfirm = function RecipientConfirm(_ref) {
|
|
37
|
+
var recipientConfirmationData = _ref.recipientConfirmationData,
|
|
38
|
+
verifyRecipient = _ref.verifyRecipient;
|
|
39
|
+
|
|
40
|
+
var _useI18n = useI18n(),
|
|
41
|
+
t = _useI18n.t;
|
|
42
|
+
|
|
43
|
+
var verify = function verify() {
|
|
44
|
+
verifyRecipient(recipientConfirmationData);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
|
|
48
|
+
style: {
|
|
49
|
+
position: 'initial'
|
|
50
|
+
} // fix z-index bug on iOS when under a BottomDrawer due to relative position
|
|
51
|
+
,
|
|
52
|
+
theme: "text",
|
|
53
|
+
className: modalStyles['aligned-dropdown-button'],
|
|
54
|
+
onClick: verify,
|
|
55
|
+
label: t("Share.twoStepsConfirmation.verify")
|
|
56
|
+
}));
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
RecipientConfirm.propTypes = {
|
|
60
|
+
recipientConfirmationData: PropTypes.object.isRequired,
|
|
61
|
+
verifyRecipient: PropTypes.func.isRequired
|
|
62
|
+
};
|
|
63
|
+
export default RecipientConfirm;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
+
import React, { useState, useRef, useCallback } from 'react';
|
|
5
|
+
import { useClient } from 'cozy-client';
|
|
6
|
+
import { useI18n } from 'cozy-ui/transpiled/react/I18n';
|
|
7
|
+
import Spinner from 'cozy-ui/transpiled/react/Spinner';
|
|
8
|
+
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
9
|
+
import DropdownButton from 'cozy-ui/transpiled/react/DropdownButton';
|
|
10
|
+
import ActionMenu, { ActionMenuItem } from 'cozy-ui/transpiled/react/ActionMenu';
|
|
11
|
+
import Icon from 'cozy-ui/transpiled/react/Icon';
|
|
12
|
+
import RenameIcon from 'cozy-ui/transpiled/react/Icons/Rename';
|
|
13
|
+
import TrashIcon from 'cozy-ui/transpiled/react/Icons/Trash';
|
|
14
|
+
import EyeIcon from 'cozy-ui/transpiled/react/Icons/Eye';
|
|
15
|
+
|
|
16
|
+
var RecipientPermissions = function RecipientPermissions(_ref) {
|
|
17
|
+
var isOwner = _ref.isOwner,
|
|
18
|
+
status = _ref.status,
|
|
19
|
+
instance = _ref.instance,
|
|
20
|
+
type = _ref.type,
|
|
21
|
+
document = _ref.document,
|
|
22
|
+
documentType = _ref.documentType,
|
|
23
|
+
className = _ref.className,
|
|
24
|
+
onRevoke = _ref.onRevoke,
|
|
25
|
+
onRevokeSelf = _ref.onRevokeSelf,
|
|
26
|
+
sharingId = _ref.sharingId,
|
|
27
|
+
index = _ref.index;
|
|
28
|
+
|
|
29
|
+
var _useI18n = useI18n(),
|
|
30
|
+
t = _useI18n.t;
|
|
31
|
+
|
|
32
|
+
var buttonRef = useRef();
|
|
33
|
+
var client = useClient();
|
|
34
|
+
|
|
35
|
+
var _useState = useState(false),
|
|
36
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
37
|
+
revoking = _useState2[0],
|
|
38
|
+
setRevoking = _useState2[1];
|
|
39
|
+
|
|
40
|
+
var _useState3 = useState(false),
|
|
41
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
42
|
+
isMenuDisplayed = _useState4[0],
|
|
43
|
+
setIsMenuDisplayed = _useState4[1];
|
|
44
|
+
|
|
45
|
+
var instanceMatchesClient = instance !== undefined && instance === client.options.uri;
|
|
46
|
+
var contactIsOwner = status === 'owner';
|
|
47
|
+
var shouldShowMenu = !revoking && !contactIsOwner && (instanceMatchesClient && !isOwner || isOwner);
|
|
48
|
+
|
|
49
|
+
var showMenu = function showMenu() {
|
|
50
|
+
return setIsMenuDisplayed(true);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
var hideMenu = function hideMenu() {
|
|
54
|
+
return setIsMenuDisplayed(false);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
var onRevokeClick = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
58
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
59
|
+
while (1) {
|
|
60
|
+
switch (_context.prev = _context.next) {
|
|
61
|
+
case 0:
|
|
62
|
+
setRevoking(true);
|
|
63
|
+
|
|
64
|
+
if (!isOwner) {
|
|
65
|
+
_context.next = 6;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
_context.next = 4;
|
|
70
|
+
return onRevoke(document, sharingId, index);
|
|
71
|
+
|
|
72
|
+
case 4:
|
|
73
|
+
_context.next = 8;
|
|
74
|
+
break;
|
|
75
|
+
|
|
76
|
+
case 6:
|
|
77
|
+
_context.next = 8;
|
|
78
|
+
return onRevokeSelf(document);
|
|
79
|
+
|
|
80
|
+
case 8:
|
|
81
|
+
setRevoking(false);
|
|
82
|
+
|
|
83
|
+
case 9:
|
|
84
|
+
case "end":
|
|
85
|
+
return _context.stop();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}, _callee);
|
|
89
|
+
})), [isOwner, onRevoke, onRevokeSelf, document, sharingId, index]);
|
|
90
|
+
var PermissionIcon = type === 'two-way' ? RenameIcon : EyeIcon;
|
|
91
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
92
|
+
className: className
|
|
93
|
+
}, revoking && /*#__PURE__*/React.createElement(Spinner, null), !shouldShowMenu && !revoking && /*#__PURE__*/React.createElement(Typography, {
|
|
94
|
+
variant: "body2"
|
|
95
|
+
}, t("Share.status.".concat(status)).toLowerCase()), shouldShowMenu && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DropdownButton, {
|
|
96
|
+
onClick: showMenu,
|
|
97
|
+
ref: buttonRef,
|
|
98
|
+
textVariant: "body2"
|
|
99
|
+
}, t("Share.type.".concat(type)).toLowerCase()), isMenuDisplayed && /*#__PURE__*/React.createElement(ActionMenu, {
|
|
100
|
+
onClose: hideMenu,
|
|
101
|
+
popperOptions: {
|
|
102
|
+
placement: 'bottom-end',
|
|
103
|
+
strategy: 'fixed'
|
|
104
|
+
},
|
|
105
|
+
anchorElRef: buttonRef
|
|
106
|
+
}, /*#__PURE__*/React.createElement(ActionMenuItem, {
|
|
107
|
+
left: /*#__PURE__*/React.createElement(Icon, {
|
|
108
|
+
icon: PermissionIcon,
|
|
109
|
+
color: "var(--primaryTextColor)"
|
|
110
|
+
})
|
|
111
|
+
}, t("Share.type.".concat(type))), /*#__PURE__*/React.createElement("hr", null), /*#__PURE__*/React.createElement(ActionMenuItem, {
|
|
112
|
+
onClick: onRevokeClick,
|
|
113
|
+
left: /*#__PURE__*/React.createElement(Icon, {
|
|
114
|
+
icon: TrashIcon,
|
|
115
|
+
color: "var(--errorColor)"
|
|
116
|
+
})
|
|
117
|
+
}, /*#__PURE__*/React.createElement(Typography, {
|
|
118
|
+
className: "u-error",
|
|
119
|
+
variant: "body1"
|
|
120
|
+
}, isOwner ? t("".concat(documentType, ".share.revoke.title")) : t("".concat(documentType, ".share.revokeSelf.title"))), /*#__PURE__*/React.createElement(Typography, {
|
|
121
|
+
variant: "caption",
|
|
122
|
+
color: "textSecondary"
|
|
123
|
+
}, isOwner ? t("".concat(documentType, ".share.revoke.desc")) : t("".concat(documentType, ".share.revokeSelf.desc")))))));
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export default RecipientPermissions;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import AvatarPlusX from './AvatarPlusX';
|
|
4
|
+
var styles = {
|
|
5
|
+
"CozyTheme--inverted": "recipient__CozyTheme--inverted___2Hb9c",
|
|
6
|
+
"CozyTheme--normal": "recipient__CozyTheme--normal___3WdEw",
|
|
7
|
+
"recipient": "recipient__recipient___2zWmH",
|
|
8
|
+
"recipients-list-light": "recipient__recipients-list-light___1-dkI",
|
|
9
|
+
"recipient-idents": "recipient__recipient-idents___3F3zL",
|
|
10
|
+
"recipient-status-icon": "recipient__recipient-status-icon___1GvS9",
|
|
11
|
+
"recipient-user": "recipient__recipient-user___3hOyK",
|
|
12
|
+
"recipient-details": "recipient__recipient-details___3fmFE",
|
|
13
|
+
"avatar": "recipient__avatar___2NIEb",
|
|
14
|
+
"link-recipient-icon-circle": "recipient__link-recipient-icon-circle___3gmgy",
|
|
15
|
+
"recipients-avatars": "recipient__recipients-avatars___MXhiL",
|
|
16
|
+
"--interactive": "recipient__--interactive___1gDjM",
|
|
17
|
+
"recipients-avatars--link": "recipient__recipients-avatars--link___2s02h",
|
|
18
|
+
"recipients-avatars--plusX": "recipient__recipients-avatars--plusX___WRllr",
|
|
19
|
+
"recipients-avatars--avatar": "recipient__recipients-avatars--avatar___3j3_A",
|
|
20
|
+
"spin": "recipient__spin___3_Uja",
|
|
21
|
+
"shake": "recipient__shake___TrWC0"
|
|
22
|
+
};
|
|
23
|
+
import { getDisplayName } from '../../models';
|
|
24
|
+
import Identity from './Identity';
|
|
25
|
+
|
|
26
|
+
var RecipientPlusX = function RecipientPlusX(_ref, _ref2) {
|
|
27
|
+
var extraRecipients = _ref.extraRecipients;
|
|
28
|
+
var t = _ref2.t;
|
|
29
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
30
|
+
className: styles['recipient']
|
|
31
|
+
}, /*#__PURE__*/React.createElement(AvatarPlusX, {
|
|
32
|
+
extraRecipients: extraRecipients.map(function (recipient) {
|
|
33
|
+
return getDisplayName(recipient);
|
|
34
|
+
})
|
|
35
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
36
|
+
className: styles['recipient-ident-status']
|
|
37
|
+
}, /*#__PURE__*/React.createElement(Identity, {
|
|
38
|
+
name: t('Share.members.otherContacts', extraRecipients.length)
|
|
39
|
+
})));
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
RecipientPlusX.contextTypes = {
|
|
43
|
+
t: PropTypes.func.isRequired
|
|
44
|
+
};
|
|
45
|
+
export default RecipientPlusX;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useI18n } from 'cozy-ui/transpiled/react/I18n';
|
|
3
|
+
import { Media, Img, Bd } from 'cozy-ui/transpiled/react/Media';
|
|
4
|
+
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
5
|
+
import Icon from 'cozy-ui/transpiled/react/Icon';
|
|
6
|
+
import PaperplaneIcon from 'cozy-ui/transpiled/react/Icons/Paperplane';
|
|
7
|
+
import ToTheCloudIcon from 'cozy-ui/transpiled/react/Icons/ToTheCloud';
|
|
8
|
+
import EyeIcon from 'cozy-ui/transpiled/react/Icons/Eye';
|
|
9
|
+
var styles = {
|
|
10
|
+
"CozyTheme--inverted": "recipient__CozyTheme--inverted___2Hb9c",
|
|
11
|
+
"CozyTheme--normal": "recipient__CozyTheme--normal___3WdEw",
|
|
12
|
+
"recipient": "recipient__recipient___2zWmH",
|
|
13
|
+
"recipients-list-light": "recipient__recipients-list-light___1-dkI",
|
|
14
|
+
"recipient-idents": "recipient__recipient-idents___3F3zL",
|
|
15
|
+
"recipient-status-icon": "recipient__recipient-status-icon___1GvS9",
|
|
16
|
+
"recipient-user": "recipient__recipient-user___3hOyK",
|
|
17
|
+
"recipient-details": "recipient__recipient-details___3fmFE",
|
|
18
|
+
"avatar": "recipient__avatar___2NIEb",
|
|
19
|
+
"link-recipient-icon-circle": "recipient__link-recipient-icon-circle___3gmgy",
|
|
20
|
+
"recipients-avatars": "recipient__recipients-avatars___MXhiL",
|
|
21
|
+
"--interactive": "recipient__--interactive___1gDjM",
|
|
22
|
+
"recipients-avatars--link": "recipient__recipients-avatars--link___2s02h",
|
|
23
|
+
"recipients-avatars--plusX": "recipient__recipients-avatars--plusX___WRllr",
|
|
24
|
+
"recipients-avatars--avatar": "recipient__recipients-avatars--avatar___3j3_A",
|
|
25
|
+
"spin": "recipient__spin___3_Uja",
|
|
26
|
+
"shake": "recipient__shake___TrWC0"
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
var RecipientStatus = function RecipientStatus(_ref) {
|
|
30
|
+
var status = _ref.status,
|
|
31
|
+
isMe = _ref.isMe,
|
|
32
|
+
instance = _ref.instance;
|
|
33
|
+
|
|
34
|
+
var _useI18n = useI18n(),
|
|
35
|
+
t = _useI18n.t;
|
|
36
|
+
|
|
37
|
+
var isSendingEmail = !isMe && status === 'mail-not-sent';
|
|
38
|
+
var isReady = isMe || status === 'ready';
|
|
39
|
+
var text, icon;
|
|
40
|
+
|
|
41
|
+
if (isReady) {
|
|
42
|
+
text = instance;
|
|
43
|
+
icon = ToTheCloudIcon;
|
|
44
|
+
} else if (isSendingEmail) {
|
|
45
|
+
text = t('Share.status.mail-not-sent');
|
|
46
|
+
icon = PaperplaneIcon;
|
|
47
|
+
} else {
|
|
48
|
+
var supportedStatus = ['pending', 'seen'];
|
|
49
|
+
text = supportedStatus.includes(status) ? t("Share.status.".concat(status)) : t('Share.status.pending');
|
|
50
|
+
icon = status === 'seen' ? EyeIcon : PaperplaneIcon;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return /*#__PURE__*/React.createElement(Media, null, /*#__PURE__*/React.createElement(Img, {
|
|
54
|
+
className: styles['recipient-status-icon']
|
|
55
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
56
|
+
icon: icon,
|
|
57
|
+
size: 10
|
|
58
|
+
})), /*#__PURE__*/React.createElement(Bd, null, /*#__PURE__*/React.createElement(Typography, {
|
|
59
|
+
variant: "caption",
|
|
60
|
+
color: "textSecondary"
|
|
61
|
+
}, text)));
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export default RecipientStatus;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
|
+
var _excluded = ["instance"];
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import Avatar from 'cozy-ui/transpiled/react/Avatar';
|
|
5
|
+
var styles = {
|
|
6
|
+
"CozyTheme--inverted": "recipient__CozyTheme--inverted___2Hb9c",
|
|
7
|
+
"CozyTheme--normal": "recipient__CozyTheme--normal___3WdEw",
|
|
8
|
+
"recipient": "recipient__recipient___2zWmH",
|
|
9
|
+
"recipients-list-light": "recipient__recipients-list-light___1-dkI",
|
|
10
|
+
"recipient-idents": "recipient__recipient-idents___3F3zL",
|
|
11
|
+
"recipient-status-icon": "recipient__recipient-status-icon___1GvS9",
|
|
12
|
+
"recipient-user": "recipient__recipient-user___3hOyK",
|
|
13
|
+
"recipient-details": "recipient__recipient-details___3fmFE",
|
|
14
|
+
"avatar": "recipient__avatar___2NIEb",
|
|
15
|
+
"link-recipient-icon-circle": "recipient__link-recipient-icon-circle___3gmgy",
|
|
16
|
+
"recipients-avatars": "recipient__recipients-avatars___MXhiL",
|
|
17
|
+
"--interactive": "recipient__--interactive___1gDjM",
|
|
18
|
+
"recipients-avatars--link": "recipient__recipients-avatars--link___2s02h",
|
|
19
|
+
"recipients-avatars--plusX": "recipient__recipients-avatars--plusX___WRllr",
|
|
20
|
+
"recipients-avatars--avatar": "recipient__recipients-avatars--avatar___3j3_A",
|
|
21
|
+
"spin": "recipient__spin___3_Uja",
|
|
22
|
+
"shake": "recipient__shake___TrWC0"
|
|
23
|
+
};
|
|
24
|
+
import { getDisplayName, getInitials } from '../../models';
|
|
25
|
+
import Identity from './Identity';
|
|
26
|
+
|
|
27
|
+
var RecipientWithoutStatus = function RecipientWithoutStatus(_ref) {
|
|
28
|
+
var instance = _ref.instance,
|
|
29
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
30
|
+
|
|
31
|
+
var name = getDisplayName(rest);
|
|
32
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
33
|
+
className: styles['recipient']
|
|
34
|
+
}, /*#__PURE__*/React.createElement(Avatar, {
|
|
35
|
+
text: getInitials(rest),
|
|
36
|
+
textId: name
|
|
37
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
38
|
+
className: styles['recipient-ident-status']
|
|
39
|
+
}, /*#__PURE__*/React.createElement(Identity, {
|
|
40
|
+
name: name,
|
|
41
|
+
details: instance
|
|
42
|
+
})));
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default RecipientWithoutStatus;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import cx from 'classnames';
|
|
4
|
+
import { useClient } from 'cozy-client';
|
|
5
|
+
import Avatar from 'cozy-ui/transpiled/react/Avatar';
|
|
6
|
+
import LinkIcon from 'cozy-ui/transpiled/react/Icons/Link';
|
|
7
|
+
import RecipientAvatar from './RecipientAvatar';
|
|
8
|
+
import AvatarPlusX from './AvatarPlusX';
|
|
9
|
+
var styles = {
|
|
10
|
+
"CozyTheme--inverted": "recipient__CozyTheme--inverted___2Hb9c",
|
|
11
|
+
"CozyTheme--normal": "recipient__CozyTheme--normal___3WdEw",
|
|
12
|
+
"recipient": "recipient__recipient___2zWmH",
|
|
13
|
+
"recipients-list-light": "recipient__recipients-list-light___1-dkI",
|
|
14
|
+
"recipient-idents": "recipient__recipient-idents___3F3zL",
|
|
15
|
+
"recipient-status-icon": "recipient__recipient-status-icon___1GvS9",
|
|
16
|
+
"recipient-user": "recipient__recipient-user___3hOyK",
|
|
17
|
+
"recipient-details": "recipient__recipient-details___3fmFE",
|
|
18
|
+
"avatar": "recipient__avatar___2NIEb",
|
|
19
|
+
"link-recipient-icon-circle": "recipient__link-recipient-icon-circle___3gmgy",
|
|
20
|
+
"recipients-avatars": "recipient__recipients-avatars___MXhiL",
|
|
21
|
+
"--interactive": "recipient__--interactive___1gDjM",
|
|
22
|
+
"recipients-avatars--link": "recipient__recipients-avatars--link___2s02h",
|
|
23
|
+
"recipients-avatars--plusX": "recipient__recipients-avatars--plusX___WRllr",
|
|
24
|
+
"recipients-avatars--avatar": "recipient__recipients-avatars--avatar___3j3_A",
|
|
25
|
+
"spin": "recipient__spin___3_Uja",
|
|
26
|
+
"shake": "recipient__shake___TrWC0"
|
|
27
|
+
};
|
|
28
|
+
import { getDisplayName } from '../../models';
|
|
29
|
+
export var MAX_DISPLAYED_RECIPIENTS = 3;
|
|
30
|
+
/**
|
|
31
|
+
* Exclude me from the list of recipients.
|
|
32
|
+
* @typedef {object} Recipient
|
|
33
|
+
* @param {array<Recipient>} recipients - List of recipients
|
|
34
|
+
* @param {boolean} isOwner - Indicates if I'm the owner or not
|
|
35
|
+
* @param {object} client - CozyClient instance
|
|
36
|
+
* @returns {array<Recipient>} List of recipients without me if I'm the owner
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
export var excludeMeAsOwnerFromRecipients = function excludeMeAsOwnerFromRecipients(_ref) {
|
|
40
|
+
var recipients = _ref.recipients,
|
|
41
|
+
isOwner = _ref.isOwner,
|
|
42
|
+
client = _ref.client;
|
|
43
|
+
return recipients.filter(function (recipient) {
|
|
44
|
+
if (isOwner) {
|
|
45
|
+
return recipient.status !== 'owner';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return recipient.instance !== client.options.uri;
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
var RecipientsAvatars = function RecipientsAvatars(_ref2) {
|
|
53
|
+
var recipients = _ref2.recipients,
|
|
54
|
+
link = _ref2.link,
|
|
55
|
+
size = _ref2.size,
|
|
56
|
+
className = _ref2.className,
|
|
57
|
+
onClick = _ref2.onClick,
|
|
58
|
+
isOwner = _ref2.isOwner,
|
|
59
|
+
showMeAsOwner = _ref2.showMeAsOwner;
|
|
60
|
+
var client = useClient();
|
|
61
|
+
var filteredRecipients = showMeAsOwner ? recipients.slice().reverse() // we slice first to clone the original array because reverser() mutates it
|
|
62
|
+
: excludeMeAsOwnerFromRecipients({
|
|
63
|
+
recipients: recipients,
|
|
64
|
+
isOwner: isOwner,
|
|
65
|
+
client: client
|
|
66
|
+
}).reverse(); // we reverse the recipients array because we use `flex-direction: row-reverse` to display them correctly
|
|
67
|
+
|
|
68
|
+
var isAvatarPlusX = filteredRecipients.length > MAX_DISPLAYED_RECIPIENTS;
|
|
69
|
+
var extraRecipients = filteredRecipients.slice(MAX_DISPLAYED_RECIPIENTS).map(function (recipient) {
|
|
70
|
+
return getDisplayName(recipient);
|
|
71
|
+
});
|
|
72
|
+
var shownRecipients = filteredRecipients.slice(0, MAX_DISPLAYED_RECIPIENTS);
|
|
73
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
74
|
+
className: cx(styles['recipients-avatars'], _defineProperty({}, styles['--interactive'], onClick), className),
|
|
75
|
+
onClick: onClick
|
|
76
|
+
}, link && /*#__PURE__*/React.createElement("span", {
|
|
77
|
+
"data-testid": "recipientsAvatars-link"
|
|
78
|
+
}, /*#__PURE__*/React.createElement(Avatar, {
|
|
79
|
+
className: styles['recipients-avatars--link'],
|
|
80
|
+
icon: LinkIcon,
|
|
81
|
+
size: size
|
|
82
|
+
})), isAvatarPlusX && /*#__PURE__*/React.createElement("span", {
|
|
83
|
+
"data-testid": "recipientsAvatars-plusX"
|
|
84
|
+
}, /*#__PURE__*/React.createElement(AvatarPlusX, {
|
|
85
|
+
className: styles['recipients-avatars--plusX'],
|
|
86
|
+
extraRecipients: extraRecipients,
|
|
87
|
+
size: size
|
|
88
|
+
})), shownRecipients.map(function (recipient, idx) {
|
|
89
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
90
|
+
"data-testid": "recipientsAvatars-avatar".concat(recipient.status === 'owner' ? '-owner' : ''),
|
|
91
|
+
key: idx
|
|
92
|
+
}, /*#__PURE__*/React.createElement(RecipientAvatar, {
|
|
93
|
+
recipient: recipient,
|
|
94
|
+
size: size,
|
|
95
|
+
className: cx(styles['recipients-avatars--avatar'])
|
|
96
|
+
}));
|
|
97
|
+
}));
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export default RecipientsAvatars;
|