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
@@ -3,6 +3,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
3
3
  var _excluded = ["showShareByLink", "documentType", "document"];
4
4
  import React from 'react';
5
5
  import { useI18n } from 'cozy-ui/transpiled/react/I18n';
6
+ import Typography from 'cozy-ui/transpiled/react/Typography';
6
7
  import { default as DumbShareByLink } from './ShareByLink';
7
8
  import { default as DumbShareByEmail } from './ShareByEmail';
8
9
  import WhoHasAccess from './WhoHasAccess';
@@ -58,7 +59,11 @@ var SharingContent = function SharingContent(_ref) {
58
59
  showShareOnlyByLink = _ref.showShareOnlyByLink,
59
60
  showWhoHasAccess = _ref.showWhoHasAccess,
60
61
  recipientsToBeConfirmed = _ref.recipientsToBeConfirmed,
61
- verifyRecipient = _ref.verifyRecipient;
62
+ verifyRecipient = _ref.verifyRecipient,
63
+ link = _ref.link,
64
+ permissions = _ref.permissions,
65
+ onUpdateShareLinkPermissions = _ref.onUpdateShareLinkPermissions,
66
+ onRevokeLink = _ref.onRevokeLink;
62
67
 
63
68
  var _useI18n = useI18n(),
64
69
  t = _useI18n.t;
@@ -69,7 +74,10 @@ var SharingContent = function SharingContent(_ref) {
69
74
  className: styles['share-byemail-onlybylink']
70
75
  }, t("".concat(documentType, ".share.shareByEmail.onlyByLink"), {
71
76
  type: t("".concat(documentType, ".share.shareByEmail.type.").concat(document.type === 'directory' ? 'folder' : 'file'))
72
- }), ' ', /*#__PURE__*/React.createElement("strong", null, t("".concat(documentType, ".share.shareByEmail.").concat(hasSharedParent ? 'hasSharedParent' : 'hasSharedChild')))), showShareByEmail && /*#__PURE__*/React.createElement(DumbShareByEmail, {
77
+ }), ' ', /*#__PURE__*/React.createElement("strong", null, t("".concat(documentType, ".share.shareByEmail.").concat(hasSharedParent ? 'hasSharedParent' : 'hasSharedChild')))), /*#__PURE__*/React.createElement(Typography, {
78
+ variant: "h6",
79
+ className: "u-mb-1-half"
80
+ }, t('Share.contacts.whoHasAccess')), showShareByEmail && /*#__PURE__*/React.createElement(DumbShareByEmail, {
73
81
  contacts: contacts,
74
82
  createContact: createContact,
75
83
  currentRecipients: recipients,
@@ -81,7 +89,7 @@ var SharingContent = function SharingContent(_ref) {
81
89
  sharing: sharing,
82
90
  sharingDesc: sharingDesc
83
91
  }), showWhoHasAccess && /*#__PURE__*/React.createElement(WhoHasAccess, {
84
- className: "u-mt-1",
92
+ className: "u-mt-half",
85
93
  document: document,
86
94
  documentType: documentType,
87
95
  isOwner: isOwner,
@@ -89,7 +97,11 @@ var SharingContent = function SharingContent(_ref) {
89
97
  onRevokeSelf: onRevokeSelf,
90
98
  recipients: recipients,
91
99
  recipientsToBeConfirmed: recipientsToBeConfirmed,
92
- verifyRecipient: verifyRecipient
100
+ verifyRecipient: verifyRecipient,
101
+ link: link,
102
+ permissions: permissions,
103
+ onUpdateShareLinkPermissions: onUpdateShareLinkPermissions,
104
+ onRevokeLink: onRevokeLink
93
105
  }));
94
106
  };
95
107
  /**
@@ -12,6 +12,16 @@ import { CozyPassFingerprintDialogContent } from './CozyPassFingerprintDialogCon
12
12
  import AppLike from '../../test/AppLike';
13
13
  import { createMockClient } from 'cozy-client';
14
14
  import { act, render, fireEvent } from '@testing-library/react';
15
+ jest.mock('cozy-client', function () {
16
+ return _objectSpread(_objectSpread({}, jest.requireActual('cozy-client')), {}, {
17
+ useQuery: jest.fn().mockReturnValue({
18
+ data: {
19
+ public_name: 'Alice'
20
+ }
21
+ }),
22
+ hasQueryBeenLoaded: jest.fn().mockReturnValue(true)
23
+ });
24
+ });
15
25
  describe('ShareDialogCozyToCozy', function () {
16
26
  var client = createMockClient({});
17
27
  client.options = {
@@ -30,7 +40,8 @@ describe('ShareDialogCozyToCozy', function () {
30
40
  var _setup = setup(props),
31
41
  getByText = _setup.getByText;
32
42
 
33
- expect(getByText('Owner')).toBeTruthy();
43
+ expect(getByText('You')).toBeTruthy();
44
+ expect(getByText('owner')).toBeTruthy();
34
45
  });
35
46
  it('should show loading while calling getRecipientsToBeConfirmed', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
36
47
  var _deferablePromise, promise, resolve, props, _setup2, getByText;
@@ -2,9 +2,15 @@ import React from 'react';
2
2
  import { Dialog } from 'cozy-ui/transpiled/react/CozyDialogs';
3
3
  import { useI18n } from 'cozy-ui/transpiled/react/I18n';
4
4
  import { default as DumbShareByLink } from './ShareByLink';
5
+ import WhoHasAccess from './WhoHasAccess';
6
+ import Typography from 'cozy-ui/transpiled/react/Typography';
5
7
 
6
8
  var ShareDialogOnlyByLink = function ShareDialogOnlyByLink(_ref) {
7
- var document = _ref.document,
9
+ var isOwner = _ref.isOwner,
10
+ onRevoke = _ref.onRevoke,
11
+ onRevokeSelf = _ref.onRevokeSelf,
12
+ recipients = _ref.recipients,
13
+ document = _ref.document,
8
14
  documentType = _ref.documentType,
9
15
  link = _ref.link,
10
16
  onClose = _ref.onClose,
@@ -23,19 +29,26 @@ var ShareDialogOnlyByLink = function ShareDialogOnlyByLink(_ref) {
23
29
  title: t("".concat(documentType, ".share.title"), {
24
30
  name: document.name || document.attributes.name
25
31
  }),
26
- content: /*#__PURE__*/React.createElement(DumbShareByLink, {
27
- checked: link !== null,
32
+ content: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Typography, {
33
+ variant: "h6"
34
+ }, t('Share.contacts.whoHasAccess')), /*#__PURE__*/React.createElement(WhoHasAccess, {
35
+ className: "u-mt-half",
28
36
  document: document,
29
37
  documentType: documentType,
38
+ isOwner: isOwner,
39
+ onRevoke: onRevoke,
40
+ onRevokeSelf: onRevokeSelf,
41
+ recipients: recipients,
30
42
  link: link,
31
- onChangePermissions: onUpdateShareLinkPermissions,
32
- onDisable: onRevokeLink,
33
- onEnable: onShareByLink,
34
43
  permissions: permissions,
35
- popperOptions: {
36
- strategy: 'fixed'
37
- }
38
- })
44
+ onUpdateShareLinkPermissions: onUpdateShareLinkPermissions,
45
+ onRevokeLink: onRevokeLink
46
+ }), /*#__PURE__*/React.createElement(DumbShareByLink, {
47
+ link: link,
48
+ document: document,
49
+ documentType: documentType,
50
+ onEnable: onShareByLink
51
+ }))
39
52
  });
40
53
  };
41
54
 
@@ -260,17 +260,17 @@ var ShareDialogTwoStepsConfirmationContainer = function ShareDialogTwoStepsConfi
260
260
  showShareOnlyByLink: showShareOnlyByLink,
261
261
  showWhoHasAccess: showWhoHasAccess,
262
262
  recipientsToBeConfirmed: recipientsToBeConfirmed,
263
- verifyRecipient: showConfirmationDialog
263
+ verifyRecipient: showConfirmationDialog,
264
+ link: link,
265
+ permissions: permissions,
266
+ onUpdateShareLinkPermissions: onUpdateShareLinkPermissions,
267
+ onRevokeLink: onRevokeLink
264
268
  });
265
269
  dialogActions = DialogActionsOnShare ? /*#__PURE__*/React.createElement(DialogActionsOnShare, {
266
- checked: link !== null,
270
+ link: link,
267
271
  document: document,
268
272
  documentType: documentType,
269
- link: link,
270
- onChangePermissions: onUpdateShareLinkPermissions,
271
- onDisable: onRevokeLink,
272
- onEnable: onShareByLink,
273
- permissions: permissions
273
+ onEnable: onShareByLink
274
274
  }) : null;
275
275
  } else if (status === 'confirmingRecipient') {
276
276
  dialogTitle = t("Share.twoStepsConfirmation.title");
@@ -34,6 +34,10 @@ export var ShareModal = function ShareModal(_ref) {
34
34
  var showShareOnlyByLink = hasSharedParent || hasSharedChild;
35
35
  var showWhoHasAccess = documentType !== 'Albums';
36
36
  return shareDialogOnlyByLink ? /*#__PURE__*/React.createElement(ShareDialogOnlyByLink, {
37
+ isOwner: isOwner,
38
+ onRevoke: onRevoke,
39
+ onRevokeSelf: onRevokeSelf,
40
+ recipients: recipients,
37
41
  document: document,
38
42
  documentType: documentType,
39
43
  link: link,
@@ -80,7 +84,7 @@ ShareModal.propTypes = {
80
84
  hasSharedChild: PropTypes.bool,
81
85
  hasSharedParent: PropTypes.bool,
82
86
  isOwner: PropTypes.bool,
83
- link: PropTypes.string.isRequired,
87
+ link: PropTypes.string,
84
88
  needsContactsPermission: PropTypes.bool,
85
89
  onClose: PropTypes.func.isRequired,
86
90
  onRevoke: PropTypes.func.isRequired,
@@ -1,148 +1,64 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/createClass";
4
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
5
- import _inherits from "@babel/runtime/helpers/inherits";
6
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
7
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
-
10
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11
-
12
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
13
-
14
- import React, { Component } from 'react';
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import React, { useState, useEffect } from 'react';
15
4
  import PropTypes from 'prop-types';
16
5
  import { contactsResponseType, groupsResponseType } from '../propTypes';
17
6
  import ShareAutosuggest from './ShareAutosuggest';
18
- var styles = {
19
- "share-modal-content": "share__share-modal-content___XTtaK",
20
- "coz-form": "share__coz-form___33NYF",
21
- "coz-form-group": "share__coz-form-group___1PLAZ",
22
- "coz-form-desc": "share__coz-form-desc___-pmK5",
23
- "coz-form-label": "share__coz-form-label___31jb0",
24
- "coz-form-label--error": "share__coz-form-label--error___2EXCl",
25
- "coz-form-errors": "share__coz-form-errors___1rk2R",
26
- "coz-form-controls": "share__coz-form-controls___39Uwg",
27
- "coz-form-controls--full": "share__coz-form-controls--full___1YpNp",
28
- "coz-form-controls--dispatch": "share__coz-form-controls--dispatch___3JXzz",
29
- "error": "share__error___6Ycal",
30
- "CozyTheme--inverted": "share__CozyTheme--inverted___2pLD2",
31
- "CozyTheme--normal": "share__CozyTheme--normal___qSFyr",
32
- "share-byemail-onlybylink": "share__share-byemail-onlybylink___C_7b_",
33
- "aligned-dropdown-button": "share__aligned-dropdown-button___CeTDs",
34
- "share-type-control": "share__share-type-control___KcpDf",
35
- "select-wrapper": "share__select-wrapper___3FfiH",
36
- "select-option": "share__select-option___13o6b",
37
- "select-option-label": "share__select-option-label___Zj_RU",
38
- "select-option-desc": "share__select-option-desc___6uaQq",
39
- "share-details-created": "share__share-details-created___13BO0",
40
- "share-details-perm": "share__share-details-perm___23_VF",
41
- "share-details-perm-desc": "share__share-details-perm-desc___tqfXx",
42
- "spin": "share__spin___1P7nU",
43
- "shake": "share__shake___1EeCI"
44
- };
45
-
46
- var ShareRecipientsInput = /*#__PURE__*/function (_Component) {
47
- _inherits(ShareRecipientsInput, _Component);
48
7
 
49
- var _super = _createSuper(ShareRecipientsInput);
50
-
51
- function ShareRecipientsInput() {
52
- var _this;
53
-
54
- _classCallCheck(this, ShareRecipientsInput);
55
-
56
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
57
- args[_key] = arguments[_key];
8
+ var ShareRecipientsInput = function ShareRecipientsInput(_ref) {
9
+ var contacts = _ref.contacts,
10
+ groups = _ref.groups,
11
+ recipients = _ref.recipients,
12
+ placeholder = _ref.placeholder,
13
+ onPick = _ref.onPick,
14
+ onRemove = _ref.onRemove;
15
+
16
+ var _useState = useState(false),
17
+ _useState2 = _slicedToArray(_useState, 2),
18
+ loading = _useState2[0],
19
+ setLoading = _useState2[1];
20
+
21
+ useEffect(function () {
22
+ if (loading && !contacts.hasMore && contacts.fetchStatus === 'loaded' && !groups.hasMore && groups.fetchStatus === 'loaded') {
23
+ setLoading(false);
58
24
  }
25
+ }, [contacts, groups, loading]);
59
26
 
60
- _this = _super.call.apply(_super, [this].concat(args));
61
-
62
- _defineProperty(_assertThisInitialized(_this), "state", {
63
- loading: false
64
- });
65
-
66
- _defineProperty(_assertThisInitialized(_this), "onFocus", function () {
67
- var _this$props = _this.props,
68
- contacts = _this$props.contacts,
69
- groups = _this$props.groups;
70
-
71
- if (contacts.hasMore || contacts.fetchStatus === 'loading' || groups.hasMore || groups.fetchStatus === 'loading') {
72
- _this.setState({
73
- loading: true
74
- });
75
- }
76
- });
77
-
78
- _defineProperty(_assertThisInitialized(_this), "getContactsAndGroups", function () {
79
- // we need contacts to be loaded to be able to add all group members to recipients
80
- var _this$props2 = _this.props,
81
- contacts = _this$props2.contacts,
82
- groups = _this$props2.groups;
83
-
84
- if (contacts.hasMore || contacts.fetchStatus === 'loading') {
85
- return contacts.data;
86
- } else {
87
- return [].concat(_toConsumableArray(contacts.data), _toConsumableArray(groups.data));
88
- }
89
- });
90
-
91
- return _this;
92
- }
93
-
94
- _createClass(ShareRecipientsInput, [{
95
- key: "componentDidUpdate",
96
- value: function componentDidUpdate() {
97
- var _this$props3 = this.props,
98
- contacts = _this$props3.contacts,
99
- groups = _this$props3.groups;
100
-
101
- if (this.state.loading && !contacts.hasMore && contacts.fetchStatus === 'loaded' && !groups.hasMore && groups.fetchStatus === 'loaded') {
102
- this.setState({
103
- loading: false
104
- });
105
- }
27
+ var onShareAutosuggestFocus = function onShareAutosuggestFocus() {
28
+ if (contacts.hasMore || contacts.fetchStatus === 'loading' || groups.hasMore || groups.fetchStatus === 'loading') {
29
+ setLoading(true);
106
30
  }
107
- }, {
108
- key: "render",
109
- value: function render() {
110
- var _this$props4 = this.props,
111
- label = _this$props4.label,
112
- onPick = _this$props4.onPick,
113
- onRemove = _this$props4.onRemove,
114
- placeholder = _this$props4.placeholder,
115
- recipients = _this$props4.recipients;
116
- var loading = this.state.loading;
117
- return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("label", {
118
- className: styles['coz-form-label'],
119
- htmlFor: "email"
120
- }, label), /*#__PURE__*/React.createElement(ShareAutosuggest, {
121
- loading: loading,
122
- contactsAndGroups: this.getContactsAndGroups(),
123
- recipients: recipients,
124
- onFocus: this.onFocus,
125
- onPick: onPick,
126
- onRemove: onRemove,
127
- placeholder: placeholder
128
- }));
31
+ };
32
+
33
+ var getContactsAndGroups = function getContactsAndGroups() {
34
+ // we need contacts to be loaded to be able to add all group members to recipients
35
+ if (contacts.hasMore || contacts.fetchStatus === 'loading') {
36
+ return contacts.data;
37
+ } else {
38
+ return [].concat(_toConsumableArray(contacts.data), _toConsumableArray(groups.data));
129
39
  }
130
- }]);
131
-
132
- return ShareRecipientsInput;
133
- }(Component);
40
+ };
41
+
42
+ return /*#__PURE__*/React.createElement(ShareAutosuggest, {
43
+ loading: loading,
44
+ contactsAndGroups: getContactsAndGroups(),
45
+ recipients: recipients,
46
+ onFocus: onShareAutosuggestFocus,
47
+ onPick: onPick,
48
+ onRemove: onRemove,
49
+ placeholder: placeholder
50
+ });
51
+ };
134
52
 
135
53
  ShareRecipientsInput.propTypes = {
136
- label: PropTypes.string,
137
54
  contacts: contactsResponseType.isRequired,
138
55
  groups: groupsResponseType.isRequired,
139
56
  recipients: PropTypes.array,
57
+ placeholder: PropTypes.string,
140
58
  onPick: PropTypes.func.isRequired,
141
- onRemove: PropTypes.func.isRequired,
142
- placeholder: PropTypes.string
59
+ onRemove: PropTypes.func.isRequired
143
60
  };
144
61
  ShareRecipientsInput.defaultProps = {
145
- label: 'To:',
146
62
  recipients: []
147
63
  };
148
64
  export default ShareRecipientsInput;
@@ -1,8 +1,14 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React from 'react';
3
3
  import PropTypes from 'prop-types';
4
- import Recipient from './Recipient';
4
+ import { useClient, useQuery, hasQueryBeenLoaded } from 'cozy-client';
5
+ import Recipient from './Recipient/Recipient';
6
+ import LinkRecipient from './Recipient/LinkRecipient';
5
7
  import { useI18n } from 'cozy-ui/transpiled/react/I18n';
8
+ import List from 'cozy-ui/transpiled/react/MuiCozyTheme/List';
9
+ import { buildInstanceSettingsQuery } from '../queries/queries';
10
+ import { filterAndReworkRecipients } from '../helpers/recipients';
11
+ import { usePrevious } from '../helpers/hooks';
6
12
  /**
7
13
  * Displays a warning if some contacts are waiting for confirmation of their sharing
8
14
  *
@@ -25,6 +31,8 @@ var RecipientWaitingForConfirmationAlert = function RecipientWaitingForConfirmat
25
31
  };
26
32
 
27
33
  var WhoHasAccess = function WhoHasAccess(_ref2) {
34
+ var _instanceSettingsResu, _instanceSettingsResu2;
35
+
28
36
  var _ref2$isOwner = _ref2.isOwner,
29
37
  isOwner = _ref2$isOwner === void 0 ? false : _ref2$isOwner,
30
38
  recipients = _ref2.recipients,
@@ -35,12 +43,41 @@ var WhoHasAccess = function WhoHasAccess(_ref2) {
35
43
  onRevoke = _ref2.onRevoke,
36
44
  className = _ref2.className,
37
45
  onRevokeSelf = _ref2.onRevokeSelf,
38
- verifyRecipient = _ref2.verifyRecipient;
46
+ verifyRecipient = _ref2.verifyRecipient,
47
+ link = _ref2.link,
48
+ permissions = _ref2.permissions,
49
+ onUpdateShareLinkPermissions = _ref2.onUpdateShareLinkPermissions,
50
+ onRevokeLink = _ref2.onRevokeLink;
51
+ var client = useClient();
52
+ var instanceSettingsQuery = buildInstanceSettingsQuery();
53
+ var instanceSettingsResult = useQuery(instanceSettingsQuery.definition, instanceSettingsQuery.options);
54
+ var previousLink = usePrevious(link);
55
+ var previousRecipients = usePrevious(recipients);
56
+ var linkHasBeenJustCreated = link && previousLink === null;
57
+ var recipientsToDisplay = filterAndReworkRecipients(recipients, previousRecipients);
58
+ var public_name = instanceSettingsResult === null || instanceSettingsResult === void 0 ? void 0 : (_instanceSettingsResu = instanceSettingsResult.data) === null || _instanceSettingsResu === void 0 ? void 0 : (_instanceSettingsResu2 = _instanceSettingsResu.attributes) === null || _instanceSettingsResu2 === void 0 ? void 0 : _instanceSettingsResu2.public_name;
39
59
  return /*#__PURE__*/React.createElement("div", {
40
60
  className: className
41
61
  }, /*#__PURE__*/React.createElement(RecipientWaitingForConfirmationAlert, {
42
62
  recipientsToBeConfirmed: recipientsToBeConfirmed
43
- }), recipients.map(function (recipient) {
63
+ }), /*#__PURE__*/React.createElement(List, {
64
+ disablePadding: true
65
+ }, link && /*#__PURE__*/React.createElement(LinkRecipient, {
66
+ document: document,
67
+ documentType: documentType,
68
+ onRevoke: onRevoke,
69
+ onRevokeSelf: onRevokeSelf,
70
+ link: link,
71
+ permissions: permissions,
72
+ onChangePermissions: onUpdateShareLinkPermissions,
73
+ onDisable: onRevokeLink,
74
+ fadeIn: linkHasBeenJustCreated
75
+ }), hasQueryBeenLoaded(instanceSettingsResult) && /*#__PURE__*/React.createElement(Recipient, {
76
+ isOwner: true,
77
+ status: "owner",
78
+ instance: client.options.uri,
79
+ public_name: public_name
80
+ }), recipientsToDisplay.map(function (recipient) {
44
81
  var recipientConfirmationData = recipientsToBeConfirmed.find(function (user) {
45
82
  return user.email === recipient.email;
46
83
  });
@@ -52,9 +89,10 @@ var WhoHasAccess = function WhoHasAccess(_ref2) {
52
89
  onRevoke: onRevoke,
53
90
  onRevokeSelf: onRevokeSelf,
54
91
  recipientConfirmationData: recipientConfirmationData,
55
- verifyRecipient: verifyRecipient
92
+ verifyRecipient: verifyRecipient,
93
+ fadeIn: recipient.hasBeenJustAdded
56
94
  }));
57
- }));
95
+ })));
58
96
  };
59
97
 
60
98
  WhoHasAccess.propTypes = {
@@ -1,25 +1,9 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React from 'react';
3
3
  import cx from 'classnames';
4
- import { RecipientWithoutStatus, RecipientPlusX } from './Recipient';
5
- var styles = {
6
- "CozyTheme--inverted": "recipient__CozyTheme--inverted___2anJa",
7
- "CozyTheme--normal": "recipient__CozyTheme--normal___994FQ",
8
- "recipient": "recipient__recipient___2FlkK",
9
- "recipients-list-light": "recipient__recipients-list-light___1Rt5q",
10
- "recipient-idents": "recipient__recipient-idents___3-fjp",
11
- "recipient-status-icon": "recipient__recipient-status-icon___J4sIm",
12
- "recipient-user": "recipient__recipient-user___2cNHW",
13
- "recipient-details": "recipient__recipient-details___4SMW5",
14
- "avatar": "recipient__avatar___pPmxN",
15
- "recipients-avatars": "recipient__recipients-avatars___2Qth2",
16
- "--interactive": "recipient__--interactive___1V89N",
17
- "recipients-avatars--link": "recipient__recipients-avatars--link___12LyR",
18
- "recipients-avatars--plusX": "recipient__recipients-avatars--plusX___28dFs",
19
- "recipients-avatars--avatar": "recipient__recipients-avatars--avatar___15hBo",
20
- "spin": "recipient__spin___2cogO",
21
- "shake": "recipient__shake___3lxk5"
22
- };
4
+ import RecipientWithoutStatus from './Recipient/RecipientWithoutStatus';
5
+ import RecipientPlusX from './Recipient/RecipientPlusX';
6
+ var styles = {};
23
7
  var MAX_DISPLAYED_RECIPIENTS = 2;
24
8
 
25
9
  var WhoHasAccessLight = function WhoHasAccessLight(_ref) {
@@ -8,13 +8,12 @@
8
8
  box-sizing border-box
9
9
  position absolute
10
10
  top 100%
11
- margin-top .0625rem
11
+ margin-top .25rem
12
12
  z-index $alert-index-mobile
13
13
  width 100%
14
- max-height 10.625rem
15
- overflow auto
16
- border .0625rem solid var(--silver)
17
- border-radius .25rem
14
+ overflow hidden
15
+ box-shadow 0px 0px 0px 0.5px rgba(29, 33, 42, 0.12), 0px 2px 4px rgba(29, 33, 42, 0.0793047), 0px 4px 16px rgba(29, 33, 42, 0.06)
16
+ border-radius .5rem
18
17
  background var(--white)
19
18
  display none
20
19
 
@@ -25,56 +24,42 @@
25
24
  width 100%
26
25
 
27
26
  .suggestionsList
28
- margin 0
29
- padding .625rem 0
27
+ max-height 9rem
28
+ overflow auto
29
+ margin 0 -1px 0 0
30
+ padding .5rem 0
30
31
  list-style none
31
32
 
32
- .suggestion
33
- padding 0 .625rem .625rem .625rem
34
-
35
33
  .suggestionHighlighted
36
- background var(--paleGrey)
34
+ background var(--actionColorSelected)
37
35
 
38
36
  .recipientsContainer
39
37
  display flex
40
38
  flex-wrap wrap
41
- padding .2rem .5rem
42
- border-radius .125rem
43
- border 1px solid var(--silver)
39
+ padding .25rem .5rem
40
+ border-radius .25rem
41
+ border 1px solid var(--borderMainColor)
42
+ min-height 2.5rem
44
43
  max-height 6.75rem
45
44
  overflow auto
46
45
 
47
46
  &:hover
48
- border .0625rem solid var(--coolGrey)
47
+ border 1px solid var(--coolGrey)
48
+
49
+ &:focus-within
50
+ border 1px solid var(--primaryColor)
49
51
 
50
52
  input[type=email]
51
53
  width auto
52
54
  flex-grow 1
53
55
  padding .5rem 0
56
+ margin auto
54
57
  border none
55
58
  &:hover
56
59
  &:focus
57
60
  border none
61
+ &:only-child
62
+ padding .25rem .5rem
58
63
 
59
64
  .recipientChip
60
- display inline-flex
61
- align-items center
62
- flex 0 0 auto
63
- background-color var(--paleGrey)
64
- border-radius .125rem
65
- height 1.75rem
66
- line-height 1.75rem
67
- padding 0 .5rem
68
- margin .25rem .5rem .25rem 0
69
-
70
-
71
- .removeRecipient
72
- border 0
73
- background-color transparent
74
- padding .15rem 0 0 0
75
- margin-left .3rem
76
- cursor pointer
77
- color var(--coolGrey)
78
-
79
- &:hover
80
- color var(--slateGrey)
65
+ margin .25rem .5rem .25rem 0
@@ -0,0 +1,6 @@
1
+ export var DOCUMENT_TYPE = {
2
+ ALBUMS: 'Albums',
3
+ FILES: 'Files',
4
+ NOTES: 'Notes',
5
+ ORGANIZATIONS: 'Organizations'
6
+ };
@@ -1,6 +1,13 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import React, { useCallback, useRef } from 'react';
2
+ import React, { useCallback, useRef, useEffect } from 'react';
3
3
  export var isServer = typeof window === 'undefined';
4
+ export function usePrevious(value) {
5
+ var ref = useRef();
6
+ useEffect(function () {
7
+ ref.current = value;
8
+ }, [value]);
9
+ return ref.current;
10
+ }
4
11
  /**
5
12
  * based on : https://github.com/tannerlinsley/react-query/blob/79ad5a9ccbce1486c10e7e364d8fc28bef3fa19f/src/devtools/utils.ts#L61
6
13
  */
@@ -0,0 +1,5 @@
1
+ import { DOCUMENT_TYPE } from './documentType';
2
+ export var isOnlyReadOnlyLinkAllowed = function isOnlyReadOnlyLinkAllowed(_ref) {
3
+ var documentType = _ref.documentType;
4
+ return documentType === DOCUMENT_TYPE.ALBUMS;
5
+ };
@@ -0,0 +1,8 @@
1
+ import get from 'lodash/get';
2
+ import { models } from 'cozy-client';
3
+ export var checkIsReadOnlyPermissions = function checkIsReadOnlyPermissions(permissions) {
4
+ var permissionCategories = get(permissions, '[0].attributes.permissions', {});
5
+ return Object.values(permissionCategories).filter(function (permissionCategory) {
6
+ return models.permission.isReadOnly(permissionCategory);
7
+ }).length > 0;
8
+ };
@@ -0,0 +1,24 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
+
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
+
7
+ export var filterAndReworkRecipients = function filterAndReworkRecipients(recipients, previousRecipients) {
8
+ return recipients.filter(function (recipient) {
9
+ return recipient.status !== 'owner';
10
+ }).map(function (recipient) {
11
+ var recipientHasChanged = previousRecipients && !previousRecipients.find(function (previousRecipient) {
12
+ return previousRecipient.name === recipient.name && previousRecipient.email === recipient.email;
13
+ });
14
+
15
+ if (recipientHasChanged) {
16
+ return _objectSpread(_objectSpread({}, recipient), {}, {
17
+ hasBeenJustAdded: true
18
+ });
19
+ }
20
+
21
+ return recipient;
22
+ });
23
+ };
24
+ export var FADE_IN_DURATION = 600;