cozy-sharing 5.0.0 → 6.0.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.
Files changed (115) hide show
  1. package/CHANGELOG.md +69 -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/ContactSuggestion.js +15 -27
  9. package/dist/components/EditLinkPermissionDialog.js +72 -0
  10. package/dist/components/EditLinkPermissionDialog.spec.js +48 -0
  11. package/dist/components/EditableSharingModal.js +15 -62
  12. package/dist/components/{AvatarPlusX.js → Recipient/AvatarPlusX.js} +1 -1
  13. package/dist/components/{Identity.js → Recipient/Identity.js} +17 -16
  14. package/dist/components/Recipient/LinkRecipient.js +72 -0
  15. package/dist/components/Recipient/LinkRecipientPermissions.js +159 -0
  16. package/dist/components/Recipient/OwnerIdentity.js +44 -0
  17. package/dist/components/Recipient/Recipient.js +72 -0
  18. package/dist/components/{Recipient.spec.js → Recipient/Recipient.spec.js} +4 -45
  19. package/dist/components/Recipient/RecipientAvatar.js +33 -0
  20. package/dist/components/Recipient/RecipientConfirm.js +63 -0
  21. package/dist/components/Recipient/RecipientPermissions.js +126 -0
  22. package/dist/components/Recipient/RecipientPlusX.js +45 -0
  23. package/dist/components/Recipient/RecipientStatus.js +64 -0
  24. package/dist/components/Recipient/RecipientWithoutStatus.js +45 -0
  25. package/dist/components/Recipient/RecipientsAvatars.js +100 -0
  26. package/dist/components/{RecipientsAvatars.spec.js → Recipient/RecipientsAvatars.spec.js} +43 -2
  27. package/dist/components/{recipient.styl → Recipient/recipient.styl} +6 -2
  28. package/dist/components/ShareAutosuggest.js +176 -252
  29. package/dist/components/ShareAutosuggest.spec.js +3 -2
  30. package/dist/components/ShareByEmail.js +142 -193
  31. package/dist/components/ShareByEmail.spec.js +42 -23
  32. package/dist/components/ShareByLink.js +251 -357
  33. package/dist/components/ShareDialogCozyToCozy.js +16 -4
  34. package/dist/components/ShareDialogCozyToCozy.spec.js +12 -1
  35. package/dist/components/ShareDialogOnlyByLink.js +23 -10
  36. package/dist/components/ShareDialogTwoStepsConfirmationContainer.js +7 -7
  37. package/dist/components/ShareModal.js +5 -1
  38. package/dist/components/ShareRecipientsInput.js +44 -128
  39. package/dist/components/WhoHasAccess.js +43 -5
  40. package/dist/components/WhoHasAccessLight.js +3 -19
  41. package/dist/components/autosuggest.styl +21 -36
  42. package/dist/helpers/documentType.js +6 -0
  43. package/dist/helpers/hooks.js +8 -1
  44. package/dist/helpers/link.js +5 -0
  45. package/dist/helpers/permissions.js +8 -0
  46. package/dist/helpers/recipients.js +24 -0
  47. package/dist/helpers/sharings.js +72 -53
  48. package/dist/helpers/synchronousJobQueue.js +67 -0
  49. package/dist/helpers/synchronousJobQueue.spec.js +97 -0
  50. package/dist/index.js +2 -1
  51. package/dist/queries/queries.js +72 -0
  52. package/dist/share.styl +0 -15
  53. package/dist/stylesheet.css +67 -92
  54. package/locales/en.json +29 -41
  55. package/locales/fr.json +26 -39
  56. package/package.json +10 -10
  57. package/src/SharedRecipients.jsx +1 -1
  58. package/src/SharedStatus.jsx +1 -1
  59. package/src/SharingBanner/hooks/useSharingInfos.jsx +1 -1
  60. package/src/SharingDetailsModal.jsx +1 -1
  61. package/src/SharingOwnerAvatar.jsx +1 -1
  62. package/src/SharingProvider.jsx +17 -4
  63. package/src/components/ContactSuggestion.jsx +25 -10
  64. package/src/components/EditLinkPermissionDialog.jsx +89 -0
  65. package/src/components/EditLinkPermissionDialog.spec.jsx +52 -0
  66. package/src/components/EditableSharingModal.jsx +58 -100
  67. package/src/components/{AvatarPlusX.jsx → Recipient/AvatarPlusX.jsx} +1 -1
  68. package/src/components/{Identity.jsx → Recipient/Identity.jsx} +0 -0
  69. package/src/components/Recipient/LinkRecipient.jsx +59 -0
  70. package/src/components/Recipient/LinkRecipientPermissions.jsx +157 -0
  71. package/src/components/Recipient/OwnerIdentity.jsx +20 -0
  72. package/src/components/Recipient/Recipient.jsx +79 -0
  73. package/src/components/{Recipient.spec.jsx → Recipient/Recipient.spec.jsx} +4 -42
  74. package/src/components/Recipient/RecipientAvatar.jsx +38 -0
  75. package/src/components/Recipient/RecipientConfirm.jsx +37 -0
  76. package/src/components/Recipient/RecipientPermissions.jsx +114 -0
  77. package/src/components/Recipient/RecipientPlusX.jsx +28 -0
  78. package/src/components/Recipient/RecipientStatus.jsx +48 -0
  79. package/src/components/Recipient/RecipientWithoutStatus.jsx +21 -0
  80. package/src/components/Recipient/RecipientsAvatars.jsx +108 -0
  81. package/src/components/{RecipientsAvatars.spec.jsx → Recipient/RecipientsAvatars.spec.jsx} +43 -2
  82. package/src/components/{recipient.styl → Recipient/recipient.styl} +6 -2
  83. package/src/components/ShareAutosuggest.jsx +136 -127
  84. package/src/components/ShareAutosuggest.spec.jsx +12 -8
  85. package/src/components/ShareByEmail.jsx +65 -90
  86. package/src/components/ShareByEmail.spec.jsx +39 -11
  87. package/src/components/ShareByLink.jsx +146 -238
  88. package/src/components/ShareDialogCozyToCozy.jsx +14 -2
  89. package/src/components/ShareDialogCozyToCozy.spec.jsx +8 -1
  90. package/src/components/ShareDialogOnlyByLink.jsx +30 -13
  91. package/src/components/ShareDialogTwoStepsConfirmationContainer.jsx +5 -5
  92. package/src/components/ShareModal.jsx +5 -1
  93. package/src/components/ShareRecipientsInput.jsx +30 -44
  94. package/src/components/WhoHasAccess.jsx +85 -27
  95. package/src/components/WhoHasAccessLight.jsx +2 -1
  96. package/src/components/__snapshots__/ContactSuggestion.spec.jsx.snap +915 -132
  97. package/src/components/__snapshots__/ShareRecipientsInput.spec.jsx.snap +86 -102
  98. package/src/components/autosuggest.styl +21 -36
  99. package/src/helpers/documentType.js +6 -0
  100. package/src/helpers/hooks.js +11 -1
  101. package/src/helpers/link.js +4 -0
  102. package/src/helpers/permissions.js +15 -0
  103. package/src/helpers/recipients.js +21 -0
  104. package/src/helpers/sharings.js +15 -12
  105. package/src/helpers/synchronousJobQueue.js +22 -0
  106. package/src/helpers/synchronousJobQueue.spec.js +75 -0
  107. package/src/index.jsx +1 -0
  108. package/src/queries/queries.js +75 -0
  109. package/src/share.styl +0 -15
  110. package/dist/SharingBanner/helpers/queries.js +0 -12
  111. package/dist/components/ContactsAndGroupsDataLoader.js +0 -50
  112. package/dist/components/Recipient.js +0 -450
  113. package/src/SharingBanner/helpers/queries.js +0 -14
  114. package/src/components/ContactsAndGroupsDataLoader.jsx +0 -30
  115. package/src/components/Recipient.jsx +0 -415
@@ -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;
@@ -5,8 +5,8 @@ var _excluded = ["recipients", "link", "isOwner", "onClick"];
5
5
  import React from 'react';
6
6
  import { createMockClient } from 'cozy-client';
7
7
  import { render } from '@testing-library/react';
8
- import { RecipientsAvatars, MAX_DISPLAYED_RECIPIENTS } from './Recipient';
9
- import AppLike from '../../test/AppLike';
8
+ import RecipientsAvatars, { MAX_DISPLAYED_RECIPIENTS, excludeMeAsOwnerFromRecipients } from './RecipientsAvatars';
9
+ import AppLike from '../../../test/AppLike';
10
10
  var mockRecipients = new Array(MAX_DISPLAYED_RECIPIENTS - 1).fill({
11
11
  status: 'owner',
12
12
  public_name: 'cozy'
@@ -101,4 +101,45 @@ describe('RecipientsAvatars', function () {
101
101
  expect(getByTestId('recipientsAvatars-plusX')).toBeTruthy();
102
102
  expect(getByTestId('recipientsAvatars-link')).toBeTruthy();
103
103
  });
104
+ });
105
+ describe('excludeMeAsOwnerFromRecipients', function () {
106
+ test('excludeMeAsOwnerFromRecipients behavior', function () {
107
+ var recipients = [{
108
+ status: 'owner',
109
+ instance: 'http://foo1.cozy.bar'
110
+ }, {
111
+ status: 'pending',
112
+ instance: 'http://foo2.cozy.bar'
113
+ }, {
114
+ status: 'pending',
115
+ instance: 'http://foo3.cozy.bar'
116
+ }];
117
+ var client = {
118
+ options: {
119
+ uri: 'http://foo2.cozy.bar'
120
+ }
121
+ };
122
+ expect(excludeMeAsOwnerFromRecipients({
123
+ recipients: recipients,
124
+ isOwner: true,
125
+ client: client
126
+ })).toEqual([{
127
+ status: 'pending',
128
+ instance: 'http://foo2.cozy.bar'
129
+ }, {
130
+ status: 'pending',
131
+ instance: 'http://foo3.cozy.bar'
132
+ }]);
133
+ expect(excludeMeAsOwnerFromRecipients({
134
+ recipients: recipients,
135
+ isOwner: false,
136
+ client: client
137
+ })).toEqual([{
138
+ status: 'owner',
139
+ instance: 'http://foo1.cozy.bar'
140
+ }, {
141
+ status: 'pending',
142
+ instance: 'http://foo3.cozy.bar'
143
+ }]);
144
+ });
104
145
  });
@@ -52,6 +52,11 @@
52
52
  .recipient-user
53
53
  font-size 1.125rem
54
54
 
55
+ .link-recipient-icon-circle
56
+ border 1px solid var(--borderMainColor)
57
+ background-color unset
58
+ color unset
59
+
55
60
  .recipients-avatars
56
61
  display inline-flex
57
62
  flex-direction row-reverse
@@ -74,5 +79,4 @@
74
79
 
75
80
  &--plusX,
76
81
  &--avatar
77
- margin-right -0.6rem
78
-
82
+ margin-right -0.6rem