cozy-sharing 5.0.0 → 6.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.
Files changed (117) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/dist/SharedRecipients.js +1 -1
  3. package/dist/SharedStatus.js +1 -1
  4. package/dist/SharingBanner/hooks/useSharingInfos.js +1 -1
  5. package/dist/SharingDetailsModal.js +1 -1
  6. package/dist/SharingOwnerAvatar.js +1 -1
  7. package/dist/SharingProvider.js +21 -8
  8. package/dist/components/ConfirmTrustedRecipientsDialog.js +1 -1
  9. package/dist/components/ContactSuggestion.js +15 -27
  10. package/dist/components/EditLinkPermissionDialog.js +72 -0
  11. package/dist/components/EditLinkPermissionDialog.spec.js +48 -0
  12. package/dist/components/EditableSharingModal.js +15 -62
  13. package/dist/components/{AvatarPlusX.js → Recipient/AvatarPlusX.js} +1 -1
  14. package/dist/components/{Identity.js → Recipient/Identity.js} +17 -16
  15. package/dist/components/Recipient/LinkRecipient.js +72 -0
  16. package/dist/components/Recipient/LinkRecipientPermissions.js +159 -0
  17. package/dist/components/Recipient/OwnerIdentity.js +44 -0
  18. package/dist/components/Recipient/Recipient.js +72 -0
  19. package/dist/components/{Recipient.spec.js → Recipient/Recipient.spec.js} +4 -45
  20. package/dist/components/Recipient/RecipientAvatar.js +33 -0
  21. package/dist/components/Recipient/RecipientConfirm.js +63 -0
  22. package/dist/components/Recipient/RecipientPermissions.js +126 -0
  23. package/dist/components/Recipient/RecipientPlusX.js +45 -0
  24. package/dist/components/Recipient/RecipientStatus.js +64 -0
  25. package/dist/components/Recipient/RecipientWithoutStatus.js +45 -0
  26. package/dist/components/Recipient/RecipientsAvatars.js +100 -0
  27. package/dist/components/{RecipientsAvatars.spec.js → Recipient/RecipientsAvatars.spec.js} +43 -2
  28. package/dist/components/{recipient.styl → Recipient/recipient.styl} +6 -2
  29. package/dist/components/ShareAutosuggest.js +176 -252
  30. package/dist/components/ShareAutosuggest.spec.js +3 -2
  31. package/dist/components/ShareByEmail.js +142 -193
  32. package/dist/components/ShareByEmail.spec.js +42 -23
  33. package/dist/components/ShareByLink.js +251 -357
  34. package/dist/components/ShareDialogCozyToCozy.js +16 -4
  35. package/dist/components/ShareDialogCozyToCozy.spec.js +12 -1
  36. package/dist/components/ShareDialogOnlyByLink.js +23 -10
  37. package/dist/components/ShareDialogTwoStepsConfirmationContainer.js +7 -7
  38. package/dist/components/ShareModal.js +5 -1
  39. package/dist/components/ShareRecipientsInput.js +44 -128
  40. package/dist/components/WhoHasAccess.js +43 -5
  41. package/dist/components/WhoHasAccessLight.js +3 -19
  42. package/dist/components/autosuggest.styl +21 -36
  43. package/dist/helpers/documentType.js +6 -0
  44. package/dist/helpers/hooks.js +8 -1
  45. package/dist/helpers/link.js +5 -0
  46. package/dist/helpers/permissions.js +8 -0
  47. package/dist/helpers/recipients.js +24 -0
  48. package/dist/helpers/sharings.js +72 -53
  49. package/dist/helpers/synchronousJobQueue.js +67 -0
  50. package/dist/helpers/synchronousJobQueue.spec.js +97 -0
  51. package/dist/index.js +2 -1
  52. package/dist/queries/queries.js +72 -0
  53. package/dist/share.styl +0 -15
  54. package/dist/stylesheet.css +67 -92
  55. package/locales/en.json +29 -41
  56. package/locales/fr.json +26 -39
  57. package/package.json +10 -10
  58. package/src/SharedRecipients.jsx +1 -1
  59. package/src/SharedStatus.jsx +1 -1
  60. package/src/SharingBanner/hooks/useSharingInfos.jsx +1 -1
  61. package/src/SharingDetailsModal.jsx +1 -1
  62. package/src/SharingOwnerAvatar.jsx +1 -1
  63. package/src/SharingProvider.jsx +17 -4
  64. package/src/components/ConfirmTrustedRecipientsDialog.jsx +1 -1
  65. package/src/components/ContactSuggestion.jsx +25 -10
  66. package/src/components/EditLinkPermissionDialog.jsx +89 -0
  67. package/src/components/EditLinkPermissionDialog.spec.jsx +52 -0
  68. package/src/components/EditableSharingModal.jsx +58 -100
  69. package/src/components/{AvatarPlusX.jsx → Recipient/AvatarPlusX.jsx} +1 -1
  70. package/src/components/{Identity.jsx → Recipient/Identity.jsx} +0 -0
  71. package/src/components/Recipient/LinkRecipient.jsx +59 -0
  72. package/src/components/Recipient/LinkRecipientPermissions.jsx +157 -0
  73. package/src/components/Recipient/OwnerIdentity.jsx +20 -0
  74. package/src/components/Recipient/Recipient.jsx +79 -0
  75. package/src/components/{Recipient.spec.jsx → Recipient/Recipient.spec.jsx} +4 -42
  76. package/src/components/Recipient/RecipientAvatar.jsx +38 -0
  77. package/src/components/Recipient/RecipientConfirm.jsx +37 -0
  78. package/src/components/Recipient/RecipientPermissions.jsx +114 -0
  79. package/src/components/Recipient/RecipientPlusX.jsx +28 -0
  80. package/src/components/Recipient/RecipientStatus.jsx +48 -0
  81. package/src/components/Recipient/RecipientWithoutStatus.jsx +21 -0
  82. package/src/components/Recipient/RecipientsAvatars.jsx +108 -0
  83. package/src/components/{RecipientsAvatars.spec.jsx → Recipient/RecipientsAvatars.spec.jsx} +43 -2
  84. package/src/components/{recipient.styl → Recipient/recipient.styl} +6 -2
  85. package/src/components/ShareAutosuggest.jsx +136 -127
  86. package/src/components/ShareAutosuggest.spec.jsx +12 -8
  87. package/src/components/ShareByEmail.jsx +65 -90
  88. package/src/components/ShareByEmail.spec.jsx +39 -11
  89. package/src/components/ShareByLink.jsx +146 -238
  90. package/src/components/ShareDialogCozyToCozy.jsx +14 -2
  91. package/src/components/ShareDialogCozyToCozy.spec.jsx +8 -1
  92. package/src/components/ShareDialogOnlyByLink.jsx +30 -13
  93. package/src/components/ShareDialogTwoStepsConfirmationContainer.jsx +5 -5
  94. package/src/components/ShareModal.jsx +5 -1
  95. package/src/components/ShareRecipientsInput.jsx +30 -44
  96. package/src/components/WhoHasAccess.jsx +85 -27
  97. package/src/components/WhoHasAccessLight.jsx +2 -1
  98. package/src/components/__snapshots__/ContactSuggestion.spec.jsx.snap +915 -132
  99. package/src/components/__snapshots__/ShareRecipientsInput.spec.jsx.snap +86 -102
  100. package/src/components/autosuggest.styl +21 -36
  101. package/src/helpers/documentType.js +6 -0
  102. package/src/helpers/hooks.js +11 -1
  103. package/src/helpers/link.js +4 -0
  104. package/src/helpers/permissions.js +15 -0
  105. package/src/helpers/recipients.js +21 -0
  106. package/src/helpers/sharings.js +15 -12
  107. package/src/helpers/synchronousJobQueue.js +22 -0
  108. package/src/helpers/synchronousJobQueue.spec.js +75 -0
  109. package/src/index.jsx +1 -0
  110. package/src/queries/queries.js +75 -0
  111. package/src/share.styl +0 -15
  112. package/dist/SharingBanner/helpers/queries.js +0 -12
  113. package/dist/components/ContactsAndGroupsDataLoader.js +0 -50
  114. package/dist/components/Recipient.js +0 -450
  115. package/src/SharingBanner/helpers/queries.js +0 -14
  116. package/src/components/ContactsAndGroupsDataLoader.jsx +0 -30
  117. package/src/components/Recipient.jsx +0 -415
@@ -1,450 +0,0 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
- import _extends from "@babel/runtime/helpers/extends";
4
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
6
- var _excluded = ["recipient"],
7
- _excluded2 = ["url", "size"],
8
- _excluded3 = ["instance", "isOwner", "status", "recipientConfirmationData", "verifyRecipient"],
9
- _excluded4 = ["instance"];
10
- import _regeneratorRuntime from "@babel/runtime/regenerator";
11
- import React, { useState, useCallback } from 'react';
12
- import PropTypes from 'prop-types';
13
- import cx from 'classnames';
14
- import { useClient } from 'cozy-client';
15
- import Spinner from 'cozy-ui/transpiled/react/Spinner';
16
- import { useI18n } from 'cozy-ui/transpiled/react/I18n';
17
- import Avatar from 'cozy-ui/transpiled/react/Avatar';
18
- import Button from 'cozy-ui/transpiled/react/Button';
19
- import CompositeRow from 'cozy-ui/transpiled/react/CompositeRow';
20
- import DropdownButton from 'cozy-ui/transpiled/react/DropdownButton';
21
- import ActionMenu, { ActionMenuItem } from 'cozy-ui/transpiled/react/ActionMenu';
22
- import Icon from 'cozy-ui/transpiled/react/Icon';
23
- import { Media, Img, Bd } from 'cozy-ui/transpiled/react/Media';
24
- import RenameIcon from 'cozy-ui/transpiled/react/Icons/Rename';
25
- import TrashIcon from 'cozy-ui/transpiled/react/Icons/Trash';
26
- import EyeIcon from 'cozy-ui/transpiled/react/Icons/Eye';
27
- import PaperplaneIcon from 'cozy-ui/transpiled/react/Icons/Paperplane';
28
- import ToTheCloudIcon from 'cozy-ui/transpiled/react/Icons/ToTheCloud';
29
- import AvatarPlusX from './AvatarPlusX';
30
- var styles = {
31
- "CozyTheme--inverted": "recipient__CozyTheme--inverted___2anJa",
32
- "CozyTheme--normal": "recipient__CozyTheme--normal___994FQ",
33
- "recipient": "recipient__recipient___2FlkK",
34
- "recipients-list-light": "recipient__recipients-list-light___1Rt5q",
35
- "recipient-idents": "recipient__recipient-idents___3-fjp",
36
- "recipient-status-icon": "recipient__recipient-status-icon___J4sIm",
37
- "recipient-user": "recipient__recipient-user___2cNHW",
38
- "recipient-details": "recipient__recipient-details___4SMW5",
39
- "avatar": "recipient__avatar___pPmxN",
40
- "recipients-avatars": "recipient__recipients-avatars___2Qth2",
41
- "--interactive": "recipient__--interactive___1V89N",
42
- "recipients-avatars--link": "recipient__recipients-avatars--link___12LyR",
43
- "recipients-avatars--plusX": "recipient__recipients-avatars--plusX___28dFs",
44
- "recipients-avatars--avatar": "recipient__recipients-avatars--avatar___15hBo",
45
- "spin": "recipient__spin___2cogO",
46
- "shake": "recipient__shake___3lxk5"
47
- };
48
- var modalStyles = {
49
- "share-modal-content": "share__share-modal-content___XTtaK",
50
- "coz-form": "share__coz-form___33NYF",
51
- "coz-form-group": "share__coz-form-group___1PLAZ",
52
- "coz-form-desc": "share__coz-form-desc___-pmK5",
53
- "coz-form-label": "share__coz-form-label___31jb0",
54
- "coz-form-label--error": "share__coz-form-label--error___2EXCl",
55
- "coz-form-errors": "share__coz-form-errors___1rk2R",
56
- "coz-form-controls": "share__coz-form-controls___39Uwg",
57
- "coz-form-controls--full": "share__coz-form-controls--full___1YpNp",
58
- "coz-form-controls--dispatch": "share__coz-form-controls--dispatch___3JXzz",
59
- "error": "share__error___6Ycal",
60
- "CozyTheme--inverted": "share__CozyTheme--inverted___2pLD2",
61
- "CozyTheme--normal": "share__CozyTheme--normal___qSFyr",
62
- "share-byemail-onlybylink": "share__share-byemail-onlybylink___C_7b_",
63
- "aligned-dropdown-button": "share__aligned-dropdown-button___CeTDs",
64
- "share-type-control": "share__share-type-control___KcpDf",
65
- "select-wrapper": "share__select-wrapper___3FfiH",
66
- "select-option": "share__select-option___13o6b",
67
- "select-option-label": "share__select-option-label___Zj_RU",
68
- "select-option-desc": "share__select-option-desc___6uaQq",
69
- "share-details-created": "share__share-details-created___13BO0",
70
- "share-details-perm": "share__share-details-perm___23_VF",
71
- "share-details-perm-desc": "share__share-details-perm-desc___tqfXx",
72
- "spin": "share__spin___1P7nU",
73
- "shake": "share__shake___1EeCI"
74
- };
75
- import { getDisplayName, getInitials } from '../models';
76
- import Identity from './Identity';
77
- import LinkIcon from 'cozy-ui/transpiled/react/Icons/Link';
78
- import Typography from 'cozy-ui/transpiled/react/Typography';
79
- export var MAX_DISPLAYED_RECIPIENTS = 3;
80
- var DEFAULT_DISPLAY_NAME = 'Share.contacts.defaultDisplayName';
81
- /**
82
- * Exclude me from the list of recipients.
83
- * @typedef {object} Recipient
84
- * @param {array<Recipient>} recipients - List of recipients
85
- * @param {boolean} isOwner - Indicates if I'm the owner or not
86
- * @param {object} client - CozyClient instance
87
- * @returns {array<Recipient>} List of recipients without me if I'm the owner
88
- */
89
-
90
- export var excludeMeAsOwnerFromRecipients = function excludeMeAsOwnerFromRecipients(_ref) {
91
- var recipients = _ref.recipients,
92
- isOwner = _ref.isOwner,
93
- client = _ref.client;
94
- return recipients.filter(function (recipient) {
95
- if (isOwner) {
96
- return recipient.status !== 'owner';
97
- }
98
-
99
- return recipient.instance !== client.options.uri;
100
- });
101
- };
102
- export var RecipientsAvatars = function RecipientsAvatars(_ref2) {
103
- var recipients = _ref2.recipients,
104
- link = _ref2.link,
105
- size = _ref2.size,
106
- className = _ref2.className,
107
- onClick = _ref2.onClick,
108
- isOwner = _ref2.isOwner,
109
- showMeAsOwner = _ref2.showMeAsOwner;
110
- var client = useClient();
111
- var filteredRecipients = showMeAsOwner ? recipients.slice().reverse() // we slice first to clone the original array because reverser() mutates it
112
- : excludeMeAsOwnerFromRecipients({
113
- recipients: recipients,
114
- isOwner: isOwner,
115
- client: client
116
- }).reverse(); // we reverse the recipients array because we use `flex-direction: row-reverse` to display them correctly
117
-
118
- var isAvatarPlusX = filteredRecipients.length > MAX_DISPLAYED_RECIPIENTS;
119
- var extraRecipients = filteredRecipients.slice(MAX_DISPLAYED_RECIPIENTS).map(function (recipient) {
120
- return getDisplayName(recipient);
121
- });
122
- var shownRecipients = filteredRecipients.slice(0, MAX_DISPLAYED_RECIPIENTS);
123
- return /*#__PURE__*/React.createElement("div", {
124
- className: cx(styles['recipients-avatars'], _defineProperty({}, styles['--interactive'], onClick), className),
125
- onClick: onClick
126
- }, link && /*#__PURE__*/React.createElement("span", {
127
- "data-testid": "recipientsAvatars-link"
128
- }, /*#__PURE__*/React.createElement(Avatar, {
129
- className: styles['recipients-avatars--link'],
130
- icon: LinkIcon,
131
- size: size
132
- })), isAvatarPlusX && /*#__PURE__*/React.createElement("span", {
133
- "data-testid": "recipientsAvatars-plusX"
134
- }, /*#__PURE__*/React.createElement(AvatarPlusX, {
135
- className: styles['recipients-avatars--plusX'],
136
- extraRecipients: extraRecipients,
137
- size: size
138
- })), shownRecipients.map(function (recipient, idx) {
139
- return /*#__PURE__*/React.createElement("span", {
140
- "data-testid": "recipientsAvatars-avatar".concat(recipient.status === 'owner' ? '-owner' : ''),
141
- key: idx
142
- }, /*#__PURE__*/React.createElement(RecipientAvatar, {
143
- recipient: recipient,
144
- size: size,
145
- className: cx(styles['recipients-avatars--avatar'])
146
- }));
147
- }));
148
- };
149
- export var RecipientAvatar = function RecipientAvatar(_ref3) {
150
- var recipient = _ref3.recipient,
151
- rest = _objectWithoutProperties(_ref3, _excluded);
152
-
153
- var client = useClient();
154
- /**
155
- * avatarPath is always the same for a recipient, but image
156
- * can be different since the stack generate it on the fly.
157
- * It can be "gray" during the first load depending of the
158
- * status' sharing, but can become active (from the realtime)
159
- * so we need a way to "refresh" the image. Passing the
160
- * status in the url force the refresh of the image when the
161
- * status changes
162
- */
163
-
164
- var image = recipient.avatarPath && recipient.status ? "".concat(client.options.uri).concat(recipient.avatarPath, "?v=").concat(recipient.status) : null;
165
- return /*#__PURE__*/React.createElement(Avatar, _extends({
166
- image: image,
167
- text: getInitials(recipient),
168
- textId: getDisplayName(recipient),
169
- disabled: recipient.status === 'pending' || recipient.status === 'mail-not-send'
170
- }, rest));
171
- };
172
- export var OwnerIdentity = function OwnerIdentity(_ref4) {
173
- var url = _ref4.url,
174
- size = _ref4.size,
175
- rest = _objectWithoutProperties(_ref4, _excluded2);
176
-
177
- return /*#__PURE__*/React.createElement("div", {
178
- className: styles['avatar']
179
- }, /*#__PURE__*/React.createElement(Avatar, {
180
- text: getInitials(rest),
181
- size: size,
182
- textId: getDisplayName(rest)
183
- }), /*#__PURE__*/React.createElement(Identity, {
184
- name: getDisplayName(rest),
185
- details: url
186
- }));
187
- };
188
- export var Permissions = function Permissions(_ref5) {
189
- var isOwner = _ref5.isOwner,
190
- status = _ref5.status,
191
- instance = _ref5.instance,
192
- type = _ref5.type,
193
- document = _ref5.document,
194
- documentType = _ref5.documentType,
195
- className = _ref5.className,
196
- onRevoke = _ref5.onRevoke,
197
- onRevokeSelf = _ref5.onRevokeSelf,
198
- sharingId = _ref5.sharingId,
199
- index = _ref5.index;
200
-
201
- var _useI18n = useI18n(),
202
- t = _useI18n.t;
203
-
204
- var client = useClient();
205
-
206
- var _useState = useState(false),
207
- _useState2 = _slicedToArray(_useState, 2),
208
- revoking = _useState2[0],
209
- setRevoking = _useState2[1];
210
-
211
- var _useState3 = useState(false),
212
- _useState4 = _slicedToArray(_useState3, 2),
213
- isMenuDisplayed = _useState4[0],
214
- setIsMenuDisplayed = _useState4[1];
215
-
216
- var instanceMatchesClient = instance !== undefined && instance === client.options.uri;
217
- var contactIsOwner = status === 'owner';
218
- var shouldShowMenu = !revoking && !contactIsOwner && (instanceMatchesClient && !isOwner || isOwner);
219
-
220
- var showMenu = function showMenu() {
221
- return setIsMenuDisplayed(true);
222
- };
223
-
224
- var hideMenu = function hideMenu() {
225
- return setIsMenuDisplayed(false);
226
- };
227
-
228
- var onRevokeClick = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
229
- return _regeneratorRuntime.wrap(function _callee$(_context) {
230
- while (1) {
231
- switch (_context.prev = _context.next) {
232
- case 0:
233
- setRevoking(true);
234
-
235
- if (!isOwner) {
236
- _context.next = 6;
237
- break;
238
- }
239
-
240
- _context.next = 4;
241
- return onRevoke(document, sharingId, index);
242
-
243
- case 4:
244
- _context.next = 8;
245
- break;
246
-
247
- case 6:
248
- _context.next = 8;
249
- return onRevokeSelf(document);
250
-
251
- case 8:
252
- setRevoking(false);
253
-
254
- case 9:
255
- case "end":
256
- return _context.stop();
257
- }
258
- }
259
- }, _callee);
260
- })), [isOwner, onRevoke, onRevokeSelf, document, sharingId, index]);
261
- var buttonRef = /*#__PURE__*/React.createRef();
262
- var PermissionIcon = type === 'two-way' ? RenameIcon : EyeIcon;
263
- return /*#__PURE__*/React.createElement("div", {
264
- className: className
265
- }, revoking && /*#__PURE__*/React.createElement(Spinner, null), !shouldShowMenu && !revoking && /*#__PURE__*/React.createElement("span", null, t("Share.status.".concat(status))), shouldShowMenu && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DropdownButton, {
266
- onClick: showMenu,
267
- ref: buttonRef,
268
- className: modalStyles['aligned-dropdown-button']
269
- }, /*#__PURE__*/React.createElement(Typography, {
270
- variant: "body1"
271
- }, t("Share.type.".concat(type)))), isMenuDisplayed && /*#__PURE__*/React.createElement(ActionMenu, {
272
- onClose: hideMenu,
273
- popperOptions: {
274
- placement: 'bottom-end',
275
- modifiers: [{
276
- name: 'preventOverflow'
277
- }]
278
- },
279
- anchorElRef: buttonRef
280
- }, /*#__PURE__*/React.createElement(ActionMenuItem, {
281
- left: /*#__PURE__*/React.createElement(Icon, {
282
- icon: PermissionIcon,
283
- color: "var(--primaryTextColor)"
284
- })
285
- }, t("Share.type.".concat(type))), /*#__PURE__*/React.createElement("hr", null), /*#__PURE__*/React.createElement(ActionMenuItem, {
286
- onClick: onRevokeClick,
287
- left: /*#__PURE__*/React.createElement(Icon, {
288
- icon: TrashIcon,
289
- color: "var(--errorColor)"
290
- })
291
- }, /*#__PURE__*/React.createElement(Typography, {
292
- className: "u-error",
293
- variant: "body1"
294
- }, isOwner ? t("".concat(documentType, ".share.revoke.title")) : t("".concat(documentType, ".share.revokeSelf.title"))), /*#__PURE__*/React.createElement(Typography, {
295
- variant: "caption",
296
- color: "textSecondary"
297
- }, isOwner ? t("".concat(documentType, ".share.revoke.desc")) : t("".concat(documentType, ".share.revokeSelf.desc")))))));
298
- };
299
-
300
- var Status = function Status(_ref7) {
301
- var status = _ref7.status,
302
- isMe = _ref7.isMe,
303
- instance = _ref7.instance;
304
-
305
- var _useI18n2 = useI18n(),
306
- t = _useI18n2.t;
307
-
308
- var isSendingEmail = !isMe && status === 'mail-not-sent';
309
- var isReady = isMe || status === 'ready';
310
- var text, icon;
311
-
312
- if (isReady) {
313
- text = instance;
314
- icon = ToTheCloudIcon;
315
- } else if (isSendingEmail) {
316
- text = t('Share.status.mail-not-sent');
317
- icon = PaperplaneIcon;
318
- } else {
319
- var supportedStatus = ['pending', 'seen'];
320
- text = supportedStatus.includes(status) ? t("Share.status.".concat(status)) : t('Share.status.pending');
321
- icon = status === 'seen' ? EyeIcon : PaperplaneIcon;
322
- }
323
-
324
- return /*#__PURE__*/React.createElement(Media, null, /*#__PURE__*/React.createElement(Img, {
325
- className: styles['recipient-status-icon']
326
- }, /*#__PURE__*/React.createElement(Icon, {
327
- icon: icon,
328
- size: 10
329
- })), /*#__PURE__*/React.createElement(Bd, null, /*#__PURE__*/React.createElement(Typography, {
330
- variant: "caption",
331
- color: "textSecondary"
332
- }, text)));
333
- };
334
- /**
335
- * Displays the confirmation interface that allows to confirm or reject a recipient
336
- */
337
-
338
-
339
- var RecipientConfirm = function RecipientConfirm(_ref8) {
340
- var recipientConfirmationData = _ref8.recipientConfirmationData,
341
- verifyRecipient = _ref8.verifyRecipient;
342
-
343
- var _useI18n3 = useI18n(),
344
- t = _useI18n3.t;
345
-
346
- var verify = function verify() {
347
- verifyRecipient(recipientConfirmationData);
348
- };
349
-
350
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
351
- style: {
352
- position: 'initial'
353
- } // fix z-index bug on iOS when under a BottomDrawer due to relative position
354
- ,
355
- theme: "text",
356
- className: modalStyles['aligned-dropdown-button'],
357
- onClick: verify,
358
- label: t("Share.twoStepsConfirmation.verify")
359
- }));
360
- };
361
-
362
- RecipientConfirm.propTypes = {
363
- recipientConfirmationData: PropTypes.object.isRequired,
364
- verifyRecipient: PropTypes.func.isRequired
365
- };
366
-
367
- var Recipient = function Recipient(props) {
368
- var _useI18n4 = useI18n(),
369
- t = _useI18n4.t;
370
-
371
- var client = useClient();
372
-
373
- var instance = props.instance,
374
- isOwner = props.isOwner,
375
- status = props.status,
376
- recipientConfirmationData = props.recipientConfirmationData,
377
- verifyRecipient = props.verifyRecipient,
378
- rest = _objectWithoutProperties(props, _excluded3);
379
-
380
- var isMe = isOwner && status === 'owner' || instance === client.options.uri;
381
- var defaultDisplayName = t(DEFAULT_DISPLAY_NAME);
382
- var name = getDisplayName(rest, defaultDisplayName);
383
- var RightPart = recipientConfirmationData ? /*#__PURE__*/React.createElement(RecipientConfirm, {
384
- recipientConfirmationData: recipientConfirmationData,
385
- verifyRecipient: verifyRecipient
386
- }) : /*#__PURE__*/React.createElement(Permissions, _extends({}, props, {
387
- className: "u-flex-shrink-0"
388
- }));
389
- return /*#__PURE__*/React.createElement(CompositeRow, {
390
- dense: true,
391
- className: cx(styles['recipient'], 'u-ph-0'),
392
- primaryText: /*#__PURE__*/React.createElement(Typography, {
393
- className: "u-ellipsis",
394
- variant: "body1"
395
- }, isMe ? t('Share.recipients.you') : name),
396
- secondaryText: /*#__PURE__*/React.createElement(Status, {
397
- status: status,
398
- isMe: isMe,
399
- instance: instance
400
- }),
401
- image: /*#__PURE__*/React.createElement(RecipientAvatar, {
402
- recipient: props
403
- }),
404
- right: RightPart
405
- });
406
- };
407
-
408
- Recipient.propTypes = {
409
- instance: PropTypes.string,
410
- isOwner: PropTypes.bool,
411
- status: PropTypes.string,
412
- recipientConfirmationData: PropTypes.object,
413
- verifyRecipient: PropTypes.func
414
- };
415
- export default Recipient;
416
- export var RecipientWithoutStatus = function RecipientWithoutStatus(_ref9) {
417
- var instance = _ref9.instance,
418
- rest = _objectWithoutProperties(_ref9, _excluded4);
419
-
420
- var name = getDisplayName(rest);
421
- return /*#__PURE__*/React.createElement("div", {
422
- className: styles['recipient']
423
- }, /*#__PURE__*/React.createElement(Avatar, {
424
- text: getInitials(rest),
425
- textId: name
426
- }), /*#__PURE__*/React.createElement("div", {
427
- className: styles['recipient-ident-status']
428
- }, /*#__PURE__*/React.createElement(Identity, {
429
- name: name,
430
- details: instance
431
- })));
432
- };
433
- export var RecipientPlusX = function RecipientPlusX(_ref10, _ref11) {
434
- var extraRecipients = _ref10.extraRecipients;
435
- var t = _ref11.t;
436
- return /*#__PURE__*/React.createElement("div", {
437
- className: styles['recipient']
438
- }, /*#__PURE__*/React.createElement(AvatarPlusX, {
439
- extraRecipients: extraRecipients.map(function (recipient) {
440
- return getDisplayName(recipient);
441
- })
442
- }), /*#__PURE__*/React.createElement("div", {
443
- className: styles['recipient-ident-status']
444
- }, /*#__PURE__*/React.createElement(Identity, {
445
- name: t('Share.members.otherContacts', extraRecipients.length)
446
- })));
447
- };
448
- RecipientPlusX.contextTypes = {
449
- t: PropTypes.func.isRequired
450
- };
@@ -1,14 +0,0 @@
1
- import CozyClient, { Q } from 'cozy-client'
2
-
3
- const DEFAULT_CACHE_TIMEOUT_QUERIES = 9 * 60 * 1000
4
- const defaultFetchPolicy = CozyClient.fetchPolicies.olderThan(
5
- DEFAULT_CACHE_TIMEOUT_QUERIES
6
- )
7
-
8
- export const buildSharingsByIdQuery = sharingId => ({
9
- definition: Q('io.cozy.sharings').getById(sharingId),
10
- options: {
11
- as: `io.cozy.sharings/${sharingId}`,
12
- fetchPolicy: defaultFetchPolicy
13
- }
14
- })
@@ -1,30 +0,0 @@
1
- import { Component } from 'react'
2
-
3
- class ContactsAndGroupsDataLoader extends Component {
4
- shouldComponentUpdate(nextProps) {
5
- return (
6
- nextProps.contacts.hasMore !== this.props.contacts.hasMore ||
7
- nextProps.contacts.fetchStatus !== this.props.contacts.fetchStatus ||
8
- nextProps.contacts.data.length !== this.props.contacts.data.length ||
9
- nextProps.groups.hasMore !== this.props.groups.hasMore ||
10
- nextProps.groups.fetchStatus !== this.props.groups.fetchStatus ||
11
- nextProps.groups.data.length !== this.props.groups.data.length
12
- )
13
- }
14
-
15
- componentDidUpdate() {
16
- if (this.props.contacts.hasMore) {
17
- this.props.contacts.fetchMore()
18
- }
19
-
20
- if (this.props.groups.hasMore) {
21
- this.props.groups.fetchMore()
22
- }
23
- }
24
-
25
- render() {
26
- return this.props.children
27
- }
28
- }
29
-
30
- export default ContactsAndGroupsDataLoader