cozy-sharing 10.4.0 → 11.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 (90) hide show
  1. package/.storybook/fixtures/recipients.js +30 -0
  2. package/.storybook/main.js +18 -0
  3. package/.storybook/manager.js +6 -0
  4. package/.storybook/preview-head.html +21 -0
  5. package/.storybook/preview.jsx +64 -0
  6. package/.storybook/public/Lato-Bold.immutable.woff2 +0 -0
  7. package/.storybook/public/Lato-Regular.immutable.woff2 +0 -0
  8. package/CHANGELOG.md +38 -0
  9. package/dist/SharedRecipients.js +2 -2
  10. package/dist/SharedStatus.js +2 -2
  11. package/dist/SharingOwnerAvatar.js +2 -2
  12. package/dist/components/{Recipient/RecipientsAvatars.js → Avatar/AvatarList.js} +11 -11
  13. package/dist/components/{Recipient/RecipientsAvatars.spec.js → Avatar/AvatarList.spec.js} +10 -10
  14. package/dist/components/Avatar/AvatarList.stories.js +14 -0
  15. package/dist/components/{Recipient/AvatarPlusX.js → Avatar/ExtraAvatar.js} +4 -4
  16. package/dist/components/Avatar/ExtraAvatar.stories.js +10 -0
  17. package/dist/components/{Recipient/RecipientAvatar.js → Avatar/MemberAvatar.js} +2 -2
  18. package/dist/components/Avatar/MemberAvatar.stories.js +15 -0
  19. package/dist/components/ConfirmTrustedRecipientsDialog.js +2 -2
  20. package/dist/components/{Recipient/RecipientPlusX.js → Identity/ExtraIdentity.js} +5 -5
  21. package/dist/components/Identity/ExtraIdentity.stories.js +13 -0
  22. package/dist/components/Identity/Identity.stories.js +13 -0
  23. package/dist/components/{Recipient/RecipientWithoutStatus.js → Identity/MemberIdentity.js} +2 -2
  24. package/dist/components/Identity/MemberIdentity.stories.js +10 -0
  25. package/dist/components/Identity/OwnerIdentity.stories.js +10 -0
  26. package/dist/components/Recipient/LinkRecipient.stories.js +16 -0
  27. package/dist/components/Recipient/LinkRecipientPermissions.stories.js +10 -0
  28. package/dist/components/Recipient/{Recipient.js → MemberRecipient.js} +9 -9
  29. package/dist/components/Recipient/{Recipient.spec.js → MemberRecipient.spec.js} +3 -3
  30. package/dist/components/Recipient/MemberRecipient.stories.js +39 -0
  31. package/dist/components/Recipient/{RecipientPermissions.js → MemberRecipientPermissions.js} +2 -2
  32. package/dist/components/Recipient/MemberRecipientPermissions.stories.js +10 -0
  33. package/dist/components/Recipient/{RecipientStatus.js → MemberRecipientStatus.js} +2 -2
  34. package/dist/components/Recipient/MemberRecipientStatus.stories.js +10 -0
  35. package/dist/components/Recipient/OwnerRecipient.js +2 -2
  36. package/dist/components/Recipient/OwnerRecipient.stories.js +13 -0
  37. package/dist/components/Recipient/OwnerRecipientDefault.js +2 -2
  38. package/dist/components/Recipient/OwnerRecipientDefault.stories.js +10 -0
  39. package/dist/components/Recipient/RecipientConfirm.js +2 -2
  40. package/dist/components/Recipient/RecipientConfirm.stories.js +10 -0
  41. package/dist/components/Recipient/RecipientList.js +2 -2
  42. package/dist/components/Recipient/RecipientList.stories.js +26 -0
  43. package/dist/components/ShareModal/SharingDetailsModal.js +1 -1
  44. package/dist/components/WhoHasAccessLight.js +4 -4
  45. package/dist/helpers/files.js +10 -0
  46. package/dist/hooks/useFetchDocumentPath.js +18 -8
  47. package/dist/stylesheet.css +10 -10
  48. package/package.json +16 -5
  49. package/src/SharedRecipients.jsx +2 -2
  50. package/src/SharedStatus.jsx +2 -2
  51. package/src/SharingOwnerAvatar.jsx +2 -2
  52. package/src/components/{Recipient/RecipientsAvatars.jsx → Avatar/AvatarList.jsx} +12 -11
  53. package/src/components/{Recipient/RecipientsAvatars.spec.jsx → Avatar/AvatarList.spec.jsx} +12 -11
  54. package/src/components/Avatar/AvatarList.stories.jsx +16 -0
  55. package/src/components/{Recipient/AvatarPlusX.jsx → Avatar/ExtraAvatar.jsx} +4 -4
  56. package/src/components/Avatar/ExtraAvatar.stories.jsx +13 -0
  57. package/src/components/{Recipient/RecipientAvatar.jsx → Avatar/MemberAvatar.jsx} +2 -2
  58. package/src/components/Avatar/MemberAvatar.stories.jsx +18 -0
  59. package/src/components/ConfirmTrustedRecipientsDialog.jsx +2 -2
  60. package/src/components/{Recipient/RecipientPlusX.jsx → Identity/ExtraIdentity.jsx} +5 -5
  61. package/src/components/Identity/ExtraIdentity.stories.jsx +16 -0
  62. package/src/components/Identity/Identity.stories.jsx +16 -0
  63. package/src/components/{Recipient/RecipientWithoutStatus.jsx → Identity/MemberIdentity.jsx} +2 -2
  64. package/src/components/Identity/MemberIdentity.stories.jsx +13 -0
  65. package/src/components/Identity/OwnerIdentity.stories.jsx +13 -0
  66. package/src/components/Recipient/LinkRecipient.stories.jsx +17 -0
  67. package/src/components/Recipient/LinkRecipientPermissions.stories.jsx +13 -0
  68. package/src/components/Recipient/{Recipient.jsx → MemberRecipient.jsx} +14 -10
  69. package/src/components/Recipient/{Recipient.spec.jsx → MemberRecipient.spec.jsx} +3 -3
  70. package/src/components/Recipient/MemberRecipient.stories.jsx +44 -0
  71. package/src/components/Recipient/{RecipientPermissions.jsx → MemberRecipientPermissions.jsx} +2 -2
  72. package/src/components/Recipient/MemberRecipientPermissions.stories.jsx +13 -0
  73. package/src/components/Recipient/{RecipientStatus.jsx → MemberRecipientStatus.jsx} +2 -2
  74. package/src/components/Recipient/MemberRecipientStatus.stories.jsx +13 -0
  75. package/src/components/Recipient/OwnerRecipient.jsx +2 -2
  76. package/src/components/Recipient/OwnerRecipient.stories.jsx +16 -0
  77. package/src/components/Recipient/OwnerRecipientDefault.jsx +2 -2
  78. package/src/components/Recipient/OwnerRecipientDefault.stories.jsx +13 -0
  79. package/src/components/Recipient/RecipientConfirm.jsx +7 -9
  80. package/src/components/Recipient/RecipientConfirm.stories.jsx +13 -0
  81. package/src/components/Recipient/RecipientList.jsx +2 -2
  82. package/src/components/Recipient/RecipientList.stories.jsx +28 -0
  83. package/src/components/ShareModal/SharingDetailsModal.jsx +1 -1
  84. package/src/components/WhoHasAccessLight.jsx +4 -4
  85. package/src/helpers/files.js +9 -0
  86. package/src/hooks/useFetchDocumentPath.jsx +4 -0
  87. /package/dist/components/{Recipient → Identity}/Identity.js +0 -0
  88. /package/dist/components/{Recipient → Identity}/OwnerIdentity.js +0 -0
  89. /package/src/components/{Recipient → Identity}/Identity.jsx +0 -0
  90. /package/src/components/{Recipient → Identity}/OwnerIdentity.jsx +0 -0
@@ -10,15 +10,15 @@ import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
10
10
  import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
11
11
  import Typography from 'cozy-ui/transpiled/react/Typography';
12
12
  import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
13
- import RecipientAvatar from './RecipientAvatar';
13
+ import MemberRecipientPermissions from './MemberRecipientPermissions';
14
+ import MemberRecipientStatus from './MemberRecipientStatus';
14
15
  import RecipientConfirm from './RecipientConfirm';
15
- import RecipientPermissions from './RecipientPermissions';
16
- import RecipientStatus from './RecipientStatus';
17
16
  import { FADE_IN_DURATION } from '../../helpers/recipients';
18
17
  import { getDisplayName } from '../../models';
18
+ import { MemberAvatar } from '../Avatar/MemberAvatar';
19
19
  var DEFAULT_DISPLAY_NAME = 'Share.contacts.defaultDisplayName';
20
20
 
21
- var Recipient = function Recipient(props) {
21
+ var MemberRecipient = function MemberRecipient(props) {
22
22
  var _useI18n = useI18n(),
23
23
  t = _useI18n.t;
24
24
 
@@ -38,7 +38,7 @@ var Recipient = function Recipient(props) {
38
38
  var RightPart = recipientConfirmationData ? /*#__PURE__*/React.createElement(RecipientConfirm, {
39
39
  recipientConfirmationData: recipientConfirmationData,
40
40
  verifyRecipient: verifyRecipient
41
- }) : /*#__PURE__*/React.createElement(RecipientPermissions, _extends({}, props, {
41
+ }) : /*#__PURE__*/React.createElement(MemberRecipientPermissions, _extends({}, props, {
42
42
  className: "u-flex-shrink-0"
43
43
  }));
44
44
  return /*#__PURE__*/React.createElement(Fade, {
@@ -46,7 +46,7 @@ var Recipient = function Recipient(props) {
46
46
  timeout: fadeIn ? FADE_IN_DURATION : 0
47
47
  }, /*#__PURE__*/React.createElement(ListItem, {
48
48
  disableGutters: true
49
- }, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(RecipientAvatar, {
49
+ }, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(MemberAvatar, {
50
50
  size: "small",
51
51
  recipient: props
52
52
  })), /*#__PURE__*/React.createElement(ListItemText, {
@@ -54,7 +54,7 @@ var Recipient = function Recipient(props) {
54
54
  className: "u-ellipsis",
55
55
  variant: "body1"
56
56
  }, isMe ? t('Share.recipients.you') : name),
57
- secondary: /*#__PURE__*/React.createElement(RecipientStatus, {
57
+ secondary: /*#__PURE__*/React.createElement(MemberRecipientStatus, {
58
58
  status: status,
59
59
  isMe: isMe,
60
60
  instance: instance
@@ -62,11 +62,11 @@ var Recipient = function Recipient(props) {
62
62
  }), RightPart));
63
63
  };
64
64
 
65
- Recipient.propTypes = {
65
+ MemberRecipient.propTypes = {
66
66
  instance: PropTypes.string,
67
67
  isOwner: PropTypes.bool,
68
68
  status: PropTypes.string,
69
69
  recipientConfirmationData: PropTypes.object,
70
70
  verifyRecipient: PropTypes.func
71
71
  };
72
- export default Recipient;
72
+ export default MemberRecipient;
@@ -3,9 +3,9 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  import { render, fireEvent } from '@testing-library/react';
4
4
  import React from 'react';
5
5
  import { createMockClient } from 'cozy-client';
6
- import Recipient from './Recipient';
6
+ import MemberRecipient from './MemberRecipient';
7
7
  import AppLike from '../../../test/AppLike';
8
- describe('Recipient component', function () {
8
+ describe('MemberRecipient component', function () {
9
9
  var client = createMockClient({});
10
10
  client.options = {
11
11
  uri: 'foo.mycozy.cloud'
@@ -14,7 +14,7 @@ describe('Recipient component', function () {
14
14
  var setup = function setup(props) {
15
15
  return render( /*#__PURE__*/React.createElement(AppLike, {
16
16
  client: client
17
- }, /*#__PURE__*/React.createElement(Recipient, props)));
17
+ }, /*#__PURE__*/React.createElement(MemberRecipient, props)));
18
18
  };
19
19
 
20
20
  var createRangeBackup;
@@ -0,0 +1,39 @@
1
+ import MemberRecipient from './MemberRecipient';
2
+ var meta = {
3
+ component: MemberRecipient,
4
+ args: {
5
+ instance: 'https://example.com',
6
+ isOwner: false,
7
+ status: 'ready',
8
+ recipientConfirmationData: null,
9
+ verifyRecipient: function verifyRecipient() {},
10
+ fadeIn: true
11
+ },
12
+ argTypes: {
13
+ status: {
14
+ control: 'select',
15
+ options: ['ready', 'mail-not-sent', 'pending', 'seen', 'owner'],
16
+ defaultValue: 'ready'
17
+ }
18
+ }
19
+ };
20
+ export default meta;
21
+ export var Default = {
22
+ name: 'Default',
23
+ args: {}
24
+ };
25
+ export var Owner = {
26
+ name: 'Owner',
27
+ args: {
28
+ isOwner: true,
29
+ status: 'owner'
30
+ }
31
+ };
32
+ export var RecipientConfirm = {
33
+ name: 'RecipientConfirm',
34
+ args: {
35
+ recipientConfirmationData: {
36
+ email: 'test'
37
+ }
38
+ }
39
+ };
@@ -13,7 +13,7 @@ import Typography from 'cozy-ui/transpiled/react/Typography';
13
13
  import ActionMenu, { ActionMenuItem } from 'cozy-ui/transpiled/react/deprecated/ActionMenu';
14
14
  import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
15
15
 
16
- var RecipientPermissions = function RecipientPermissions(_ref) {
16
+ var MemberRecipientPermissions = function MemberRecipientPermissions(_ref) {
17
17
  var isOwner = _ref.isOwner,
18
18
  status = _ref.status,
19
19
  instance = _ref.instance,
@@ -121,4 +121,4 @@ var RecipientPermissions = function RecipientPermissions(_ref) {
121
121
  }, isOwner ? t("".concat(documentType, ".share.revoke.desc")) : t("".concat(documentType, ".share.revokeSelf.desc")))))));
122
122
  };
123
123
 
124
- export default RecipientPermissions;
124
+ export default MemberRecipientPermissions;
@@ -0,0 +1,10 @@
1
+ import MemberRecipientPermissions from './MemberRecipientPermissions';
2
+ var meta = {
3
+ component: MemberRecipientPermissions,
4
+ args: {}
5
+ };
6
+ export default meta;
7
+ export var Default = {
8
+ name: 'Default',
9
+ args: {}
10
+ };
@@ -24,7 +24,7 @@ var styles = {
24
24
  "shake": "recipient__shake___TGyPp"
25
25
  };
26
26
 
27
- var RecipientStatus = function RecipientStatus(_ref) {
27
+ var MemberRecipientStatus = function MemberRecipientStatus(_ref) {
28
28
  var status = _ref.status,
29
29
  isMe = _ref.isMe,
30
30
  instance = _ref.instance;
@@ -59,4 +59,4 @@ var RecipientStatus = function RecipientStatus(_ref) {
59
59
  }, text)));
60
60
  };
61
61
 
62
- export default RecipientStatus;
62
+ export default MemberRecipientStatus;
@@ -0,0 +1,10 @@
1
+ import MemberRecipientStatus from './MemberRecipientStatus';
2
+ var meta = {
3
+ component: MemberRecipientStatus,
4
+ args: {}
5
+ };
6
+ export default meta;
7
+ export var Default = {
8
+ name: 'Default',
9
+ args: {}
10
+ };
@@ -1,7 +1,7 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
+ import MemberRecipient from './MemberRecipient';
3
4
  import OwnerRecipientDefault from './OwnerRecipientDefault';
4
- import Recipient from './Recipient';
5
5
 
6
6
  var OwnerRecipient = function OwnerRecipient(_ref) {
7
7
  var recipients = _ref.recipients;
@@ -10,7 +10,7 @@ var OwnerRecipient = function OwnerRecipient(_ref) {
10
10
  });
11
11
 
12
12
  if (ownerRecipient) {
13
- return /*#__PURE__*/React.createElement(Recipient, ownerRecipient);
13
+ return /*#__PURE__*/React.createElement(MemberRecipient, ownerRecipient);
14
14
  }
15
15
 
16
16
  return /*#__PURE__*/React.createElement(OwnerRecipientDefault, null);
@@ -0,0 +1,13 @@
1
+ import OwnerRecipient from './OwnerRecipient';
2
+ import { recipients } from '../../../.storybook/fixtures/recipients';
3
+ var meta = {
4
+ component: OwnerRecipient,
5
+ args: {
6
+ recipients: recipients
7
+ }
8
+ };
9
+ export default meta;
10
+ export var Default = {
11
+ name: 'Default',
12
+ args: {}
13
+ };
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { useClient, useQuery, hasQueryBeenLoaded } from 'cozy-client';
3
- import Recipient from './Recipient';
3
+ import MemberRecipient from './MemberRecipient';
4
4
  import { buildInstanceSettingsQuery } from '../../queries/queries';
5
5
 
6
6
  var OwnerRecipientDefault = function OwnerRecipientDefault() {
@@ -9,7 +9,7 @@ var OwnerRecipientDefault = function OwnerRecipientDefault() {
9
9
  var client = useClient();
10
10
  var instanceSettingsQuery = buildInstanceSettingsQuery();
11
11
  var instanceSettingsResult = useQuery(instanceSettingsQuery.definition, instanceSettingsQuery.options);
12
- return hasQueryBeenLoaded(instanceSettingsResult) && /*#__PURE__*/React.createElement(Recipient, {
12
+ return hasQueryBeenLoaded(instanceSettingsResult) && /*#__PURE__*/React.createElement(MemberRecipient, {
13
13
  isOwner: true,
14
14
  status: "owner",
15
15
  instance: client.options.uri,
@@ -0,0 +1,10 @@
1
+ import OwnerRecipientDefault from './OwnerRecipientDefault';
2
+ var meta = {
3
+ component: OwnerRecipientDefault,
4
+ args: {}
5
+ };
6
+ export default meta;
7
+ export var Default = {
8
+ name: 'Default',
9
+ args: {}
10
+ };
@@ -40,7 +40,7 @@ var RecipientConfirm = function RecipientConfirm(_ref) {
40
40
  verifyRecipient(recipientConfirmationData);
41
41
  };
42
42
 
43
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
43
+ return /*#__PURE__*/React.createElement(Button, {
44
44
  style: {
45
45
  position: 'initial'
46
46
  } // fix z-index bug on iOS when under a BottomDrawer due to relative position
@@ -49,7 +49,7 @@ var RecipientConfirm = function RecipientConfirm(_ref) {
49
49
  className: modalStyles['aligned-dropdown-button'],
50
50
  onClick: verify,
51
51
  label: t("Share.twoStepsConfirmation.verify")
52
- }));
52
+ });
53
53
  };
54
54
 
55
55
  RecipientConfirm.propTypes = {
@@ -0,0 +1,10 @@
1
+ import RecipientConfirm from './RecipientConfirm';
2
+ var meta = {
3
+ component: RecipientConfirm,
4
+ args: {}
5
+ };
6
+ export default meta;
7
+ export var Default = {
8
+ name: 'Default',
9
+ args: {}
10
+ };
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React from 'react';
3
- import Recipient from './Recipient';
3
+ import MemberRecipient from './MemberRecipient';
4
4
  import { usePrevious } from '../../helpers/hooks';
5
5
  import { filterAndReworkRecipients } from '../../helpers/recipients';
6
6
 
@@ -19,7 +19,7 @@ var RecipientList = function RecipientList(_ref) {
19
19
  var recipientConfirmationData = recipientsToBeConfirmed.find(function (user) {
20
20
  return user.email === recipient.email;
21
21
  });
22
- return /*#__PURE__*/React.createElement(Recipient, _extends({}, recipient, {
22
+ return /*#__PURE__*/React.createElement(MemberRecipient, _extends({}, recipient, {
23
23
  key: "key_r_".concat(recipient.index),
24
24
  isOwner: isOwner,
25
25
  document: document,
@@ -0,0 +1,26 @@
1
+ import { RecipientList } from './RecipientList';
2
+ import { recipients } from '../../../.storybook/fixtures/recipients';
3
+ var meta = {
4
+ component: RecipientList,
5
+ args: {
6
+ recipients: recipients,
7
+ recipientsToBeConfirmed: [],
8
+ isOwner: false,
9
+ onRevoke: function onRevoke() {},
10
+ onRevokeSelf: function onRevokeSelf() {},
11
+ verifyRecipient: function verifyRecipient() {
12
+ return true;
13
+ }
14
+ }
15
+ };
16
+ export default meta;
17
+ export var Default = {
18
+ name: 'Default',
19
+ args: {}
20
+ };
21
+ export var Owner = {
22
+ name: 'Owner',
23
+ args: {
24
+ isOwner: true
25
+ }
26
+ };
@@ -27,7 +27,7 @@ var styles = {
27
27
  "share-details-perm": "share__share-details-perm___3HjxK",
28
28
  "share-details-perm-desc": "share__share-details-perm-desc___3HyHu"
29
29
  };
30
- import OwnerIdentity from '../Recipient/OwnerIdentity';
30
+ import OwnerIdentity from '../Identity/OwnerIdentity';
31
31
  import WhoHasAccess from '../WhoHasAccess';
32
32
  export var SharingDetailsModal = function SharingDetailsModal(_ref) {
33
33
  var onClose = _ref.onClose,
@@ -1,8 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import cx from 'classnames';
3
3
  import React from 'react';
4
- import RecipientPlusX from './Recipient/RecipientPlusX';
5
- import RecipientWithoutStatus from './Recipient/RecipientWithoutStatus';
4
+ import { ExtraIdentity } from './Identity/ExtraIdentity';
5
+ import { MemberIdentity } from './Identity/MemberIdentity';
6
6
  var styles = {
7
7
  "recipient": "recipient__recipient___2DmZI",
8
8
  "recipients-list-light": "recipient__recipients-list-light___Vq4op",
@@ -28,10 +28,10 @@ var WhoHasAccessLight = function WhoHasAccessLight(_ref) {
28
28
  return /*#__PURE__*/React.createElement("div", {
29
29
  className: cx(styles['recipients-list-light'], className)
30
30
  }, recipients.slice(0, MAX_DISPLAYED_RECIPIENTS).map(function (recipient, index) {
31
- return /*#__PURE__*/React.createElement(RecipientWithoutStatus, _extends({}, recipient, {
31
+ return /*#__PURE__*/React.createElement(MemberIdentity, _extends({}, recipient, {
32
32
  key: "key_recipient__".concat(index)
33
33
  }));
34
- }), recipients.length > MAX_DISPLAYED_RECIPIENTS && /*#__PURE__*/React.createElement(RecipientPlusX, {
34
+ }), recipients.length > MAX_DISPLAYED_RECIPIENTS && /*#__PURE__*/React.createElement(ExtraIdentity, {
35
35
  extraRecipients: recipients.slice(MAX_DISPLAYED_RECIPIENTS)
36
36
  }));
37
37
  };
@@ -1,5 +1,15 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _regeneratorRuntime from "@babel/runtime/regenerator";
3
+
4
+ /**
5
+ * Fetches the file paths for the given files.
6
+ * Should not be used for directories.
7
+ *
8
+ * @param {Object} client - The cozy-client instance.
9
+ * @param {string} doctype - The type of document.
10
+ * @param {Array} files - The array of files.
11
+ * @returns {Promise<Array>} - The array of file paths.
12
+ */
3
13
  export var fetchFilesPaths = /*#__PURE__*/function () {
4
14
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(client, doctype, files) {
5
15
  var parentDirIds, parentDirs, filePaths;
@@ -13,30 +13,40 @@ export var useFetchDocumentPath = function useFetchDocumentPath(client, document
13
13
  ;
14
14
 
15
15
  _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
16
- var path;
16
+ var isDirectory, path;
17
17
  return _regeneratorRuntime.wrap(function _callee$(_context) {
18
18
  while (1) switch (_context.prev = _context.next) {
19
19
  case 0:
20
20
  _context.prev = 0;
21
- _context.next = 3;
21
+ isDirectory = document.type === 'directory';
22
+
23
+ if (!isDirectory) {
24
+ _context.next = 4;
25
+ break;
26
+ }
27
+
28
+ return _context.abrupt("return", setDocumentPath(document.path));
29
+
30
+ case 4:
31
+ _context.next = 6;
22
32
  return fetchFilesPaths(client, document._type, [document]);
23
33
 
24
- case 3:
34
+ case 6:
25
35
  path = _context.sent;
26
36
  setDocumentPath(path[0]); // eslint-disable-next-line
27
37
 
28
- _context.next = 9;
38
+ _context.next = 12;
29
39
  break;
30
40
 
31
- case 7:
32
- _context.prev = 7;
41
+ case 10:
42
+ _context.prev = 10;
33
43
  _context.t0 = _context["catch"](0);
34
44
 
35
- case 9:
45
+ case 12:
36
46
  case "end":
37
47
  return _context.stop();
38
48
  }
39
- }, _callee, null, [[0, 7]]);
49
+ }, _callee, null, [[0, 10]]);
40
50
  }))();
41
51
  }, [client, document]);
42
52
  return documentPath;
@@ -1,13 +1,3 @@
1
- /* imported from CozyPassFingerprintDialogContent.styl */
2
-
3
- .CozyPassFingerprintDialogContent__cozy-pass-fingerprint-modal__fingerprint___3qIGs {
4
- padding: 16px;
5
- margin: 24px 0;
6
- text-align: center;
7
- }
8
- .CozyPassFingerprintDialogContent__cozy-pass-fingerprint-modal__fingerprint___3qIGs p {
9
- color: var(--secondaryColor);
10
- }
11
1
  /* imported from recipient.styl */
12
2
 
13
3
  @-moz-keyframes recipient__spin___2tYv3 {
@@ -181,6 +171,16 @@
181
171
  .recipient__recipients-avatars--avatar___-owjC {
182
172
  margin-right: -0.6rem;
183
173
  }
174
+ /* imported from CozyPassFingerprintDialogContent.styl */
175
+
176
+ .CozyPassFingerprintDialogContent__cozy-pass-fingerprint-modal__fingerprint___3qIGs {
177
+ padding: 16px;
178
+ margin: 24px 0;
179
+ text-align: center;
180
+ }
181
+ .CozyPassFingerprintDialogContent__cozy-pass-fingerprint-modal__fingerprint___3qIGs p {
182
+ color: var(--secondaryColor);
183
+ }
184
184
  /* imported from share.styl */
185
185
 
186
186
  .share__share-modal-content___1iqEq .share__coz-form___1ICST {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-sharing",
3
- "version": "10.4.0",
3
+ "version": "11.0.0",
4
4
  "description": "Provides sharing login for React applications.",
5
5
  "main": "dist/index.js",
6
6
  "author": "Cozy",
@@ -21,8 +21,11 @@
21
21
  "prepublishOnly": "yarn build",
22
22
  "test": "env NODE_ENV=test jest --env=jest-environment-jsdom-sixteen",
23
23
  "lint": "cd .. && yarn eslint --ext js,jsx packages/cozy-sharing",
24
- "watch": "yarn build --watch",
25
- "watch:doc:react": "(cd ../.. && TARGET=cozy-sharing yarn watch:doc:react)"
24
+ "start": "yarn build --watch",
25
+ "watch": "yarn run start",
26
+ "watch:doc:react": "(cd ../.. && TARGET=cozy-sharing yarn watch:doc:react)",
27
+ "storybook": "storybook dev -p 6006",
28
+ "build-storybook": "storybook build"
26
29
  },
27
30
  "dependencies": {
28
31
  "@cozy/minilog": "^1.0.0",
@@ -36,6 +39,13 @@
36
39
  },
37
40
  "devDependencies": {
38
41
  "@babel/core": "7.16.12",
42
+ "@storybook/addon-essentials": "7.6.0",
43
+ "@storybook/addon-interactions": "7.6.0",
44
+ "@storybook/addon-links": "7.6.0",
45
+ "@storybook/blocks": "7.6.0",
46
+ "@storybook/react": "7.6.0",
47
+ "@storybook/react-webpack5": "7.6.0",
48
+ "@storybook/testing-library": "0.2.2",
39
49
  "babel-jest": "26.6.3",
40
50
  "babel-plugin-css-modules-transform": "1.6.2",
41
51
  "babel-plugin-inline-react-svg": "1.1.2",
@@ -47,7 +57,8 @@
47
57
  "jest": "26.6.3",
48
58
  "react": "16.12.0",
49
59
  "react-dom": "16.13.0",
50
- "react-router": "^5.0.1"
60
+ "react-router": "^5.0.1",
61
+ "storybook": "7.6.0"
51
62
  },
52
63
  "peerDependencies": {
53
64
  "cozy-client": ">=45.14.0",
@@ -60,5 +71,5 @@
60
71
  "sideEffects": [
61
72
  "*.css"
62
73
  ],
63
- "gitHead": "e3e6b6ca27bfcc2c61893eeb763c43f926308630"
74
+ "gitHead": "b98230a4b8974af2699385bbe8edf5635a46b4a3"
64
75
  }
@@ -1,6 +1,6 @@
1
1
  import React from 'react'
2
2
 
3
- import RecipientsAvatars from './components/Recipient/RecipientsAvatars'
3
+ import { AvatarList } from './components/Avatar/AvatarList'
4
4
  import SharingContext from './context'
5
5
  import withLocales from './hoc/withLocales'
6
6
 
@@ -8,7 +8,7 @@ export const SharedRecipients = withLocales(({ docId, onClick, ...rest }) => (
8
8
  <SharingContext.Consumer>
9
9
  {({ byDocId, getRecipients, getSharingLink, isOwner } = {}) =>
10
10
  !byDocId || !byDocId[docId] ? null : (
11
- <RecipientsAvatars
11
+ <AvatarList
12
12
  recipients={getRecipients(docId)}
13
13
  link={getSharingLink(docId) !== null}
14
14
  onClick={onClick}
@@ -1,6 +1,6 @@
1
1
  import React from 'react'
2
2
 
3
- import RecipientsAvatars from './components/Recipient/RecipientsAvatars'
3
+ import { AvatarList } from './components/Avatar/AvatarList'
4
4
  import SharingContext from './context'
5
5
  import withLocales from './hoc/withLocales'
6
6
 
@@ -11,7 +11,7 @@ export const SharedStatus = withLocales(
11
11
  !byDocId || !byDocId[docId] ? (
12
12
  <span className={className + ' ' + noSharedClassName}>—</span>
13
13
  ) : (
14
- <RecipientsAvatars
14
+ <AvatarList
15
15
  className={className}
16
16
  recipients={getRecipients(docId)}
17
17
  link={getSharingLink(docId) !== null}
@@ -1,6 +1,6 @@
1
1
  import React from 'react'
2
2
 
3
- import RecipientAvatar from './components/Recipient/RecipientAvatar'
3
+ import { MemberAvatar } from './components/Avatar/MemberAvatar'
4
4
  import SharingContext from './context'
5
5
  import withLocales from './hoc/withLocales'
6
6
 
@@ -8,7 +8,7 @@ export const SharingOwnerAvatar = withLocales(({ docId, ...rest }) => (
8
8
  <SharingContext.Consumer>
9
9
  {({ byDocId, getOwner } = {}) => {
10
10
  return !byDocId || !byDocId[docId] ? null : (
11
- <RecipientAvatar recipient={getOwner(docId)} {...rest} />
11
+ <MemberAvatar recipient={getOwner(docId)} {...rest} />
12
12
  )
13
13
  }}
14
14
  </SharingContext.Consumer>
@@ -5,8 +5,8 @@ import { useClient } from 'cozy-client'
5
5
  import Avatar from 'cozy-ui/transpiled/react/Avatar'
6
6
  import LinkIcon from 'cozy-ui/transpiled/react/Icons/Link'
7
7
 
8
- import AvatarPlusX from './AvatarPlusX'
9
- import RecipientAvatar from './RecipientAvatar'
8
+ import { ExtraAvatar } from './ExtraAvatar'
9
+ import { MemberAvatar } from './MemberAvatar'
10
10
  import { getDisplayName } from '../../models'
11
11
  import styles from '../../styles/recipient.styl'
12
12
 
@@ -33,7 +33,7 @@ export const excludeMeAsOwnerFromRecipients = ({
33
33
  })
34
34
  }
35
35
 
36
- const RecipientsAvatars = ({
36
+ const AvatarList = ({
37
37
  recipients,
38
38
  link,
39
39
  size,
@@ -52,7 +52,8 @@ const RecipientsAvatars = ({
52
52
  }).reverse()
53
53
  // we reverse the recipients array because we use `flex-direction: row-reverse` to display them correctly
54
54
 
55
- const isAvatarPlusX = filteredRecipients.length > MAX_DISPLAYED_RECIPIENTS
55
+ const hasExtraRecipients =
56
+ filteredRecipients.length > MAX_DISPLAYED_RECIPIENTS
56
57
  const extraRecipients = filteredRecipients
57
58
  .slice(MAX_DISPLAYED_RECIPIENTS)
58
59
  .map(recipient => getDisplayName(recipient))
@@ -70,7 +71,7 @@ const RecipientsAvatars = ({
70
71
  onClick={onClick}
71
72
  >
72
73
  {link && (
73
- <span data-testid="recipientsAvatars-link">
74
+ <span data-testid="AvatarList-link">
74
75
  <Avatar
75
76
  className={styles['recipients-avatars--link']}
76
77
  icon={LinkIcon}
@@ -78,9 +79,9 @@ const RecipientsAvatars = ({
78
79
  />
79
80
  </span>
80
81
  )}
81
- {isAvatarPlusX && (
82
- <span data-testid="recipientsAvatars-plusX">
83
- <AvatarPlusX
82
+ {hasExtraRecipients && (
83
+ <span data-testid="AvatarList-plusX">
84
+ <ExtraAvatar
84
85
  className={styles['recipients-avatars--plusX']}
85
86
  extraRecipients={extraRecipients}
86
87
  size={size}
@@ -89,12 +90,12 @@ const RecipientsAvatars = ({
89
90
  )}
90
91
  {shownRecipients.map((recipient, idx) => (
91
92
  <span
92
- data-testid={`recipientsAvatars-avatar${
93
+ data-testid={`AvatarList-avatar${
93
94
  recipient.status === 'owner' ? '-owner' : ''
94
95
  }`}
95
96
  key={idx}
96
97
  >
97
- <RecipientAvatar
98
+ <MemberAvatar
98
99
  recipient={recipient}
99
100
  size={size}
100
101
  className={cx(styles['recipients-avatars--avatar'])}
@@ -105,4 +106,4 @@ const RecipientsAvatars = ({
105
106
  )
106
107
  }
107
108
 
108
- export default RecipientsAvatars
109
+ export { AvatarList }