cozy-sharing 40.1.6 → 40.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/components/FederatedFolder/FederatedFolderModal.js +10 -12
- package/dist/components/FederatedFolder/FederatedFolderModal.spec.js +2 -2
- package/dist/components/Recipient/DowngradePermissionConfirmDialog.js +3 -12
- package/dist/components/Recipient/GroupRecipient.js +1 -4
- package/dist/components/Recipient/GroupRecipient.stories.js +3 -1
- package/dist/components/Recipient/GroupRecipientDetailWithAccess.js +1 -4
- package/dist/components/Recipient/GroupRecipientPermissions.js +5 -8
- package/dist/components/Recipient/GroupRecipientPermissions.stories.js +2 -0
- package/dist/components/Recipient/LinkRecipient.js +2 -6
- package/dist/components/Recipient/LinkRecipient.stories.js +4 -0
- package/dist/components/Recipient/LinkRecipientPermissions.js +13 -12
- package/dist/components/Recipient/LinkRecipientPermissions.stories.js +5 -1
- package/dist/components/Recipient/MemberRecipient.js +7 -6
- package/dist/components/Recipient/MemberRecipient.spec.js +7 -12
- package/dist/components/Recipient/MemberRecipientPermissions.js +28 -13
- package/dist/components/Recipient/MemberRecipientPermissions.spec.js +5 -14
- package/dist/components/Recipient/MemberRecipientPermissions.stories.js +2 -1
- package/dist/components/Recipient/OwnerRecipient.js +4 -17
- package/dist/components/Recipient/OwnerRecipient.stories.js +3 -1
- package/dist/components/Recipient/OwnerRecipientDefaultLite.js +1 -1
- package/dist/components/Recipient/PermissionTypeMenu.js +32 -155
- package/dist/components/Recipient/PermissionTypeMenuWrapper.js +37 -0
- package/dist/components/Recipient/{PermissionTypeMenu.spec.js → PermissionTypeMenuWrapper.spec.js} +2 -2
- package/dist/components/Recipient/RecipientList.js +10 -0
- package/dist/components/Recipient/RecipientList.stories.js +3 -0
- package/dist/components/{ShareRecipientsInput.js → ShareAutosuggestWrapper.js} +12 -54
- package/dist/components/{ShareRecipientsInput.spec.js → ShareAutosuggestWrapper.spec.js} +3 -3
- package/dist/components/ShareByEmail.js +2 -2
- package/dist/components/ShareDialogCozyToCozy.js +20 -19
- package/dist/components/ShareDialogCozyToCozy.spec.js +3 -0
- package/dist/components/ShareDialogOnlyByLink.js +3 -5
- package/dist/components/ShareDialogOnlyByLink.spec.js +0 -1
- package/dist/components/ShareModal/SharingDetailsModal.js +2 -2
- package/dist/components/SharedDrive/EditSharedDriveModal.js +11 -10
- package/dist/components/SharedDrive/useSharedDrive.js +8 -11
- package/dist/components/SharingBanner/components/PublicBanner.js +8 -6
- package/dist/components/SharingBanner/components/PublicBanner.spec.js +1 -9
- package/dist/components/SharingBanner/components/SharingBanner.js +3 -0
- package/dist/components/SharingBanner/index.js +3 -0
- package/dist/components/SharingContent.js +3 -5
- package/dist/components/WhoHasAccess.js +27 -11
- package/dist/components/WhoHasAccessWrapper.js +122 -0
- package/dist/helpers/contacts.js +79 -1
- package/dist/helpers/contacts.spec.js +122 -1
- package/dist/helpers/recipients.js +46 -0
- package/dist/helpers/recipients.spec.js +89 -0
- package/dist/hooks/useMemberPermissionType.js +191 -0
- package/dist/hooks/useResolveRecipients.js +53 -0
- package/dist/hooks/useResolveRecipients.spec.js +140 -0
- package/dist/index.js +1 -1
- package/docs/share-modal-architecture.md +2 -2
- package/package.json +3 -3
- package/src/components/FederatedFolder/FederatedFolderModal.jsx +6 -12
- package/src/components/FederatedFolder/FederatedFolderModal.spec.jsx +1 -0
- package/src/components/Recipient/DowngradePermissionConfirmDialog.jsx +3 -10
- package/src/components/Recipient/GroupRecipient.jsx +1 -5
- package/src/components/Recipient/GroupRecipient.stories.jsx +3 -1
- package/src/components/Recipient/GroupRecipientDetailWithAccess.jsx +1 -4
- package/src/components/Recipient/GroupRecipientPermissions.jsx +5 -5
- package/src/components/Recipient/GroupRecipientPermissions.stories.jsx +2 -0
- package/src/components/Recipient/LinkRecipient.jsx +2 -4
- package/src/components/Recipient/LinkRecipient.stories.jsx +4 -0
- package/src/components/Recipient/LinkRecipientPermissions.jsx +16 -12
- package/src/components/Recipient/LinkRecipientPermissions.stories.jsx +5 -1
- package/src/components/Recipient/MemberRecipient.jsx +4 -4
- package/src/components/Recipient/MemberRecipient.spec.jsx +7 -10
- package/src/components/Recipient/MemberRecipientPermissions.jsx +29 -13
- package/src/components/Recipient/MemberRecipientPermissions.spec.jsx +5 -11
- package/src/components/Recipient/MemberRecipientPermissions.stories.jsx +2 -1
- package/src/components/Recipient/OwnerRecipient.jsx +4 -17
- package/src/components/Recipient/OwnerRecipient.stories.jsx +1 -1
- package/src/components/Recipient/OwnerRecipientDefaultLite.jsx +1 -1
- package/src/components/Recipient/PermissionTypeMenu.jsx +21 -81
- package/src/components/Recipient/PermissionTypeMenuWrapper.jsx +32 -0
- package/src/components/Recipient/{PermissionTypeMenu.spec.jsx → PermissionTypeMenuWrapper.spec.jsx} +2 -2
- package/src/components/Recipient/RecipientList.jsx +10 -0
- package/src/components/Recipient/RecipientList.stories.jsx +3 -0
- package/src/components/{ShareRecipientsInput.jsx → ShareAutosuggestWrapper.jsx} +14 -65
- package/src/components/{ShareRecipientsInput.spec.jsx → ShareAutosuggestWrapper.spec.jsx} +3 -3
- package/src/components/ShareByEmail.jsx +2 -2
- package/src/components/ShareDialogCozyToCozy.jsx +10 -11
- package/src/components/ShareDialogCozyToCozy.spec.jsx +1 -0
- package/src/components/ShareDialogOnlyByLink.jsx +2 -4
- package/src/components/ShareDialogOnlyByLink.spec.jsx +0 -1
- package/src/components/ShareModal/SharingDetailsModal.jsx +2 -2
- package/src/components/SharedDrive/EditSharedDriveModal.jsx +6 -11
- package/src/components/SharedDrive/useSharedDrive.js +4 -11
- package/src/components/SharingBanner/components/PublicBanner.jsx +6 -6
- package/src/components/SharingBanner/components/PublicBanner.spec.jsx +1 -8
- package/src/components/SharingBanner/components/SharingBanner.jsx +7 -1
- package/src/components/SharingBanner/index.jsx +4 -0
- package/src/components/SharingContent.jsx +2 -4
- package/src/components/WhoHasAccess.jsx +26 -12
- package/src/components/WhoHasAccessWrapper.jsx +117 -0
- package/src/helpers/contacts.js +83 -0
- package/src/helpers/contacts.spec.js +78 -1
- package/src/helpers/recipients.js +44 -0
- package/src/helpers/recipients.spec.js +82 -0
- package/src/hooks/useMemberPermissionType.js +110 -0
- package/src/hooks/useResolveRecipients.js +38 -0
- package/src/hooks/useResolveRecipients.spec.js +70 -0
- package/src/index.jsx +1 -1
- package/dist/components/Recipient/OwnerRecipientDefault.js +0 -27
- package/dist/components/Recipient/OwnerRecipientDefault.stories.js +0 -10
- package/src/components/Recipient/OwnerRecipientDefault.jsx +0 -37
- package/src/components/Recipient/OwnerRecipientDefault.stories.jsx +0 -13
|
@@ -4,17 +4,7 @@ import React from 'react';
|
|
|
4
4
|
import { createMockClient } from 'cozy-client';
|
|
5
5
|
import MemberRecipientPermissions from './MemberRecipientPermissions';
|
|
6
6
|
import AppLike from '../../../test/AppLike';
|
|
7
|
-
var mockUpdateSharingMemberType = jest.fn();
|
|
8
7
|
var mockShowAlert = jest.fn();
|
|
9
|
-
jest.mock('../../hooks/useSharingContext', function () {
|
|
10
|
-
return {
|
|
11
|
-
useSharingContext: function useSharingContext() {
|
|
12
|
-
return {
|
|
13
|
-
updateSharingMemberType: mockUpdateSharingMemberType
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
});
|
|
18
8
|
jest.mock('cozy-ui/transpiled/react/providers/Alert', function () {
|
|
19
9
|
return {
|
|
20
10
|
__esModule: true,
|
|
@@ -38,7 +28,7 @@ describe('MemberRecipientPermissions component', function () {
|
|
|
38
28
|
isOwner: true,
|
|
39
29
|
isSharedDrive: false,
|
|
40
30
|
status: 'ready',
|
|
41
|
-
|
|
31
|
+
isCurrentUser: true,
|
|
42
32
|
type: 'two-way',
|
|
43
33
|
document: {
|
|
44
34
|
id: 'doc-123',
|
|
@@ -48,7 +38,8 @@ describe('MemberRecipientPermissions component', function () {
|
|
|
48
38
|
sharingId: 'sharing-123',
|
|
49
39
|
memberIndex: 1,
|
|
50
40
|
onRevoke: jest.fn(),
|
|
51
|
-
onRevokeSelf: jest.fn()
|
|
41
|
+
onRevokeSelf: jest.fn(),
|
|
42
|
+
onSetMemberType: jest.fn()
|
|
52
43
|
};
|
|
53
44
|
beforeEach(function () {
|
|
54
45
|
jest.clearAllMocks();
|
|
@@ -80,7 +71,7 @@ describe('MemberRecipientPermissions component', function () {
|
|
|
80
71
|
it('should not render menu when user is not owner and not the shared drive contact', function () {
|
|
81
72
|
var _setup = setup({
|
|
82
73
|
isOwner: false,
|
|
83
|
-
|
|
74
|
+
isCurrentUser: false
|
|
84
75
|
}),
|
|
85
76
|
queryByRole = _setup.queryByRole;
|
|
86
77
|
|
|
@@ -104,7 +95,7 @@ describe('MemberRecipientPermissions component', function () {
|
|
|
104
95
|
it('should render menu for the user themselves', function () {
|
|
105
96
|
var _setup3 = setup({
|
|
106
97
|
isOwner: false,
|
|
107
|
-
|
|
98
|
+
isCurrentUser: true
|
|
108
99
|
}),
|
|
109
100
|
getByRole = _setup3.getByRole;
|
|
110
101
|
|
|
@@ -4,6 +4,7 @@ var meta = {
|
|
|
4
4
|
args: {
|
|
5
5
|
onRevoke: function onRevoke() {},
|
|
6
6
|
onRevokeSelf: function onRevokeSelf() {},
|
|
7
|
+
onSetMemberType: function onSetMemberType() {},
|
|
7
8
|
type: 'two-way',
|
|
8
9
|
status: 'ready'
|
|
9
10
|
},
|
|
@@ -31,6 +32,6 @@ export var Self = {
|
|
|
31
32
|
name: 'Self',
|
|
32
33
|
args: {
|
|
33
34
|
isOwner: false,
|
|
34
|
-
|
|
35
|
+
isCurrentUser: true
|
|
35
36
|
}
|
|
36
37
|
};
|
|
@@ -1,27 +1,14 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import PropTypes from 'prop-types';
|
|
3
2
|
import React from 'react';
|
|
4
3
|
import MemberRecipient from './MemberRecipient';
|
|
5
|
-
import OwnerRecipientDefault from './OwnerRecipientDefault';
|
|
6
4
|
|
|
7
5
|
var OwnerRecipient = function OwnerRecipient(_ref) {
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return recipient.status === 'owner';
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
if (ownerRecipient) {
|
|
15
|
-
return /*#__PURE__*/React.createElement(MemberRecipient, _extends({}, ownerRecipient, {
|
|
16
|
-
isOrgSharedDrive: isOrgSharedDrive
|
|
17
|
-
}));
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return /*#__PURE__*/React.createElement(OwnerRecipientDefault, null);
|
|
6
|
+
var owner = _ref.owner;
|
|
7
|
+
if (!owner) return null;
|
|
8
|
+
return /*#__PURE__*/React.createElement(MemberRecipient, owner);
|
|
21
9
|
};
|
|
22
10
|
|
|
23
11
|
OwnerRecipient.propTypes = {
|
|
24
|
-
|
|
25
|
-
isOrgSharedDrive: PropTypes.bool
|
|
12
|
+
owner: PropTypes.object
|
|
26
13
|
};
|
|
27
14
|
export default OwnerRecipient;
|
|
@@ -3,7 +3,9 @@ import { recipients } from '../../../.storybook/fixtures/recipients';
|
|
|
3
3
|
var meta = {
|
|
4
4
|
component: OwnerRecipient,
|
|
5
5
|
args: {
|
|
6
|
-
|
|
6
|
+
owner: recipients.find(function (recipient) {
|
|
7
|
+
return recipient.status === 'owner';
|
|
8
|
+
})
|
|
7
9
|
}
|
|
8
10
|
};
|
|
9
11
|
export default meta;
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { useClient, useQuery, hasQueryBeenLoaded } from 'cozy-client';
|
|
3
3
|
import MemberRecipientLite from './MemberRecipientLite';
|
|
4
4
|
import withLocales from '../../hoc/withLocales';
|
|
5
|
-
import { buildInstanceSettingsQuery } from '../../queries/queries'; // See
|
|
5
|
+
import { buildInstanceSettingsQuery } from '../../queries/queries'; // See containers/WhoHasAccess: show the instance public avatar (with an initials
|
|
6
6
|
// fallback) when the owner has no per-sharing avatar to reference.
|
|
7
7
|
|
|
8
8
|
var OWNER_PUBLIC_AVATAR_PATH = '/public/avatar?fallback=initials';
|
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
-
|
|
6
|
-
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; }
|
|
7
|
-
|
|
8
|
-
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; }
|
|
9
|
-
|
|
10
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
11
|
-
|
|
12
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
13
|
-
|
|
14
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
15
|
-
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
16
5
|
import React, { useCallback, useRef, useState } from 'react';
|
|
17
|
-
import { useClient } from 'cozy-client';
|
|
18
|
-
import flag from 'cozy-flags';
|
|
19
6
|
import minilog from 'cozy-minilog';
|
|
20
7
|
import ActionsMenu from 'cozy-ui/transpiled/react/ActionsMenu';
|
|
21
8
|
import { makeActions } from 'cozy-ui/transpiled/react/ActionsMenu/Actions';
|
|
@@ -25,32 +12,21 @@ import { useI18n } from 'twake-i18n';
|
|
|
25
12
|
import DowngradePermissionConfirmDialog from './DowngradePermissionConfirmDialog';
|
|
26
13
|
import { setReadOnlySharedPermission } from './actions/setReadOnlySharedPermission';
|
|
27
14
|
import { setReadWriteSharedPermission } from './actions/setReadWriteSharedPermission';
|
|
28
|
-
import { getOrCreateFromArray } from '../../helpers/contacts';
|
|
29
|
-
import withLocales from '../../hoc/withLocales';
|
|
30
|
-
import { useFetchDocumentPath } from '../../hooks/useFetchDocumentPath';
|
|
31
|
-
import { useSharingContext } from '../../hooks/useSharingContext';
|
|
32
|
-
import { getSharingDocIds } from '../../state';
|
|
33
15
|
var log = minilog('PermissionTypeMenu');
|
|
34
16
|
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
memberIndex = _ref.memberIndex,
|
|
38
|
-
type = _ref.type,
|
|
17
|
+
var PermissionTypeMenu = function PermissionTypeMenu(_ref) {
|
|
18
|
+
var type = _ref.type,
|
|
39
19
|
document = _ref.document,
|
|
40
|
-
recipient = _ref.recipient
|
|
20
|
+
recipient = _ref.recipient,
|
|
21
|
+
isInsideSharedParent = _ref.isInsideSharedParent,
|
|
22
|
+
sharedParentName = _ref.sharedParentName,
|
|
23
|
+
onSetType = _ref.onSetType;
|
|
41
24
|
|
|
42
25
|
var _useI18n = useI18n(),
|
|
43
26
|
t = _useI18n.t;
|
|
44
27
|
|
|
45
|
-
var client = useClient();
|
|
46
28
|
var buttonRef = useRef();
|
|
47
29
|
|
|
48
|
-
var _useSharingContext = useSharingContext(),
|
|
49
|
-
hasSharedParent = _useSharingContext.hasSharedParent,
|
|
50
|
-
updateSharingMemberType = _useSharingContext.updateSharingMemberType,
|
|
51
|
-
getSharingById = _useSharingContext.getSharingById,
|
|
52
|
-
share = _useSharingContext.share;
|
|
53
|
-
|
|
54
30
|
var _useAlert = useAlert(),
|
|
55
31
|
showAlert = _useAlert.showAlert;
|
|
56
32
|
|
|
@@ -64,154 +40,46 @@ var PermissionTypeMenuComponent = function PermissionTypeMenuComponent(_ref) {
|
|
|
64
40
|
pendingType = _useState4[0],
|
|
65
41
|
setPendingType = _useState4[1];
|
|
66
42
|
|
|
67
|
-
var documentPath = useFetchDocumentPath(client, document);
|
|
68
43
|
var hideMenu = useCallback(function () {
|
|
69
44
|
setMenuDisplayed(false);
|
|
70
45
|
}, []);
|
|
71
46
|
var applyType = useCallback( /*#__PURE__*/function () {
|
|
72
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(newType) {
|
|
73
|
-
var _ref3,
|
|
74
|
-
_ref3$withAncestors,
|
|
75
|
-
withAncestors,
|
|
76
|
-
ancestors,
|
|
77
|
-
_iterator,
|
|
78
|
-
_step,
|
|
79
|
-
ancestor,
|
|
80
|
-
documentId,
|
|
81
|
-
sourceSharing,
|
|
82
|
-
contacts,
|
|
83
|
-
_args = arguments;
|
|
84
|
-
|
|
47
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(newType, options) {
|
|
85
48
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
86
49
|
while (1) switch (_context.prev = _context.next) {
|
|
87
50
|
case 0:
|
|
88
|
-
|
|
89
|
-
_context.
|
|
90
|
-
|
|
91
|
-
if (!withAncestors) {
|
|
92
|
-
_context.next = 21;
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Ancestors first: only the target's own update refetches its
|
|
97
|
-
// effective recipients, which must already see them downgraded.
|
|
98
|
-
ancestors = ((recipient === null || recipient === void 0 ? void 0 : recipient.sources) || []).filter(function (s) {
|
|
99
|
-
return s.kind === 'ancestor' && !s.read_only;
|
|
100
|
-
});
|
|
101
|
-
_iterator = _createForOfIteratorHelper(ancestors);
|
|
102
|
-
_context.prev = 5;
|
|
103
|
-
|
|
104
|
-
_iterator.s();
|
|
105
|
-
|
|
106
|
-
case 7:
|
|
107
|
-
if ((_step = _iterator.n()).done) {
|
|
108
|
-
_context.next = 13;
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
ancestor = _step.value;
|
|
113
|
-
_context.next = 11;
|
|
114
|
-
return updateSharingMemberType(ancestor.sharing_id, ancestor.member_index, newType);
|
|
51
|
+
_context.prev = 0;
|
|
52
|
+
_context.next = 3;
|
|
53
|
+
return onSetType(newType, options);
|
|
115
54
|
|
|
116
|
-
case
|
|
117
|
-
_context.next =
|
|
55
|
+
case 3:
|
|
56
|
+
_context.next = 9;
|
|
118
57
|
break;
|
|
119
58
|
|
|
120
|
-
case
|
|
121
|
-
_context.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
case 15:
|
|
125
|
-
_context.prev = 15;
|
|
126
|
-
_context.t0 = _context["catch"](5);
|
|
127
|
-
|
|
128
|
-
_iterator.e(_context.t0);
|
|
129
|
-
|
|
130
|
-
case 18:
|
|
131
|
-
_context.prev = 18;
|
|
132
|
-
|
|
133
|
-
_iterator.f();
|
|
134
|
-
|
|
135
|
-
return _context.finish(18);
|
|
136
|
-
|
|
137
|
-
case 21:
|
|
138
|
-
documentId = (document === null || document === void 0 ? void 0 : document._id) || (document === null || document === void 0 ? void 0 : document.id);
|
|
139
|
-
|
|
140
|
-
if (!(flag('drive.federated-shared-folder.enabled') && type === 'one-way' && newType === 'two-way' && documentId)) {
|
|
141
|
-
_context.next = 33;
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
sourceSharing = getSharingById(sharingId);
|
|
146
|
-
|
|
147
|
-
if (!(sourceSharing && !getSharingDocIds(sourceSharing).includes(documentId))) {
|
|
148
|
-
_context.next = 33;
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
_context.next = 27;
|
|
153
|
-
return getOrCreateFromArray(client, [recipient], function (contact) {
|
|
154
|
-
return client.create('io.cozy.contacts', contact);
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
case 27:
|
|
158
|
-
contacts = _context.sent;
|
|
159
|
-
|
|
160
|
-
if (contacts[0]) {
|
|
161
|
-
_context.next = 30;
|
|
162
|
-
break;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
throw new Error('Recipient contact not found');
|
|
166
|
-
|
|
167
|
-
case 30:
|
|
168
|
-
_context.next = 32;
|
|
169
|
-
return share({
|
|
170
|
-
document: _objectSpread(_objectSpread({}, document), {}, {
|
|
171
|
-
id: documentId
|
|
172
|
-
}),
|
|
173
|
-
description: document.name,
|
|
174
|
-
recipients: contacts,
|
|
175
|
-
readOnlyRecipients: [],
|
|
176
|
-
sharedDrive: true,
|
|
177
|
-
openSharing: false
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
case 32:
|
|
181
|
-
return _context.abrupt("return");
|
|
182
|
-
|
|
183
|
-
case 33:
|
|
184
|
-
_context.next = 35;
|
|
185
|
-
return updateSharingMemberType(sharingId, memberIndex, newType, document);
|
|
186
|
-
|
|
187
|
-
case 35:
|
|
188
|
-
_context.next = 41;
|
|
189
|
-
break;
|
|
190
|
-
|
|
191
|
-
case 37:
|
|
192
|
-
_context.prev = 37;
|
|
193
|
-
_context.t1 = _context["catch"](1);
|
|
194
|
-
log.error('Failed to change member permission type', _context.t1);
|
|
59
|
+
case 5:
|
|
60
|
+
_context.prev = 5;
|
|
61
|
+
_context.t0 = _context["catch"](0);
|
|
62
|
+
log.error('Failed to change member permission type', _context.t0);
|
|
195
63
|
showAlert({
|
|
196
64
|
message: t('Share.members.error.changePermission'),
|
|
197
65
|
severity: 'error',
|
|
198
66
|
variant: 'filled'
|
|
199
67
|
});
|
|
200
68
|
|
|
201
|
-
case
|
|
69
|
+
case 9:
|
|
202
70
|
case "end":
|
|
203
71
|
return _context.stop();
|
|
204
72
|
}
|
|
205
|
-
}, _callee, null, [[
|
|
73
|
+
}, _callee, null, [[0, 5]]);
|
|
206
74
|
}));
|
|
207
75
|
|
|
208
|
-
return function (_x) {
|
|
76
|
+
return function (_x, _x2) {
|
|
209
77
|
return _ref2.apply(this, arguments);
|
|
210
78
|
};
|
|
211
|
-
}(), [
|
|
79
|
+
}(), [onSetType, showAlert, t]); // Downgrading to viewer on a folder inside a shared parent also reduces
|
|
212
80
|
// the member's rights on the parent: require explicit confirmation first.
|
|
213
81
|
|
|
214
|
-
var shouldConfirmDowngrade = type === 'two-way' &&
|
|
82
|
+
var shouldConfirmDowngrade = type === 'two-way' && isInsideSharedParent;
|
|
215
83
|
var setType = useCallback(function (newType) {
|
|
216
84
|
hideMenu();
|
|
217
85
|
if (newType === type) return;
|
|
@@ -255,9 +123,18 @@ var PermissionTypeMenuComponent = function PermissionTypeMenuComponent(_ref) {
|
|
|
255
123
|
}), pendingType && /*#__PURE__*/React.createElement(DowngradePermissionConfirmDialog, {
|
|
256
124
|
document: document,
|
|
257
125
|
recipient: recipient,
|
|
126
|
+
sharedParentName: sharedParentName,
|
|
258
127
|
onCancel: handleCancelDowngrade,
|
|
259
128
|
onConfirm: handleConfirmDowngrade
|
|
260
129
|
}));
|
|
261
130
|
};
|
|
262
131
|
|
|
263
|
-
|
|
132
|
+
PermissionTypeMenu.propTypes = {
|
|
133
|
+
type: PropTypes.oneOf(['one-way', 'two-way']),
|
|
134
|
+
document: PropTypes.object,
|
|
135
|
+
recipient: PropTypes.object,
|
|
136
|
+
isInsideSharedParent: PropTypes.bool,
|
|
137
|
+
sharedParentName: PropTypes.string,
|
|
138
|
+
onSetType: PropTypes.func.isRequired
|
|
139
|
+
};
|
|
140
|
+
export default PermissionTypeMenu;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PermissionTypeMenu from './PermissionTypeMenu';
|
|
3
|
+
import withLocales from '../../hoc/withLocales';
|
|
4
|
+
import { useMemberPermissionType } from '../../hooks/useMemberPermissionType';
|
|
5
|
+
|
|
6
|
+
var PermissionTypeMenuWrapper = function PermissionTypeMenuWrapper(_ref) {
|
|
7
|
+
var sharingId = _ref.sharingId,
|
|
8
|
+
memberIndex = _ref.memberIndex,
|
|
9
|
+
type = _ref.type,
|
|
10
|
+
document = _ref.document,
|
|
11
|
+
recipient = _ref.recipient;
|
|
12
|
+
|
|
13
|
+
var _useMemberPermissionT = useMemberPermissionType(document),
|
|
14
|
+
isInsideSharedParent = _useMemberPermissionT.isInsideSharedParent,
|
|
15
|
+
sharedParentName = _useMemberPermissionT.sharedParentName,
|
|
16
|
+
setMemberType = _useMemberPermissionT.setMemberType;
|
|
17
|
+
|
|
18
|
+
var handleSetType = function handleSetType(newType, options) {
|
|
19
|
+
return setMemberType({
|
|
20
|
+
sharingId: sharingId,
|
|
21
|
+
memberIndex: memberIndex,
|
|
22
|
+
type: type,
|
|
23
|
+
recipient: recipient
|
|
24
|
+
}, newType, options);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return /*#__PURE__*/React.createElement(PermissionTypeMenu, {
|
|
28
|
+
type: type,
|
|
29
|
+
document: document,
|
|
30
|
+
recipient: recipient,
|
|
31
|
+
isInsideSharedParent: isInsideSharedParent,
|
|
32
|
+
sharedParentName: sharedParentName,
|
|
33
|
+
onSetType: handleSetType
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default withLocales(PermissionTypeMenuWrapper);
|
package/dist/components/Recipient/{PermissionTypeMenu.spec.js → PermissionTypeMenuWrapper.spec.js}
RENAMED
|
@@ -5,7 +5,7 @@ import { render, fireEvent, screen, waitFor } from '@testing-library/react';
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { createMockClient } from 'cozy-client';
|
|
7
7
|
import flag from 'cozy-flags';
|
|
8
|
-
import
|
|
8
|
+
import PermissionTypeMenuWrapper from './PermissionTypeMenuWrapper';
|
|
9
9
|
import AppLike from '../../../test/AppLike';
|
|
10
10
|
var mockUpdateSharingMemberType = jest.fn();
|
|
11
11
|
var mockHasSharedParent = jest.fn();
|
|
@@ -63,7 +63,7 @@ describe('PermissionTypeMenu component', function () {
|
|
|
63
63
|
var setup = function setup(props) {
|
|
64
64
|
return render( /*#__PURE__*/React.createElement(AppLike, {
|
|
65
65
|
client: client
|
|
66
|
-
}, /*#__PURE__*/React.createElement(
|
|
66
|
+
}, /*#__PURE__*/React.createElement(PermissionTypeMenuWrapper, _extends({}, defaultProps, props))));
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
var createRangeBackup;
|
|
@@ -14,8 +14,13 @@ var RecipientList = function RecipientList(_ref) {
|
|
|
14
14
|
isSharedDrive = _ref.isSharedDrive,
|
|
15
15
|
document = _ref.document,
|
|
16
16
|
documentType = _ref.documentType,
|
|
17
|
+
isInsideSharedParent = _ref.isInsideSharedParent,
|
|
18
|
+
sharedParentName = _ref.sharedParentName,
|
|
17
19
|
onRevoke = _ref.onRevoke,
|
|
18
20
|
onRevokeSelf = _ref.onRevokeSelf,
|
|
21
|
+
onRevokeGroup = _ref.onRevokeGroup,
|
|
22
|
+
onLeaveGroup = _ref.onLeaveGroup,
|
|
23
|
+
onSetMemberType = _ref.onSetMemberType,
|
|
19
24
|
verifyRecipient = _ref.verifyRecipient;
|
|
20
25
|
var previousRecipients = usePrevious(recipients);
|
|
21
26
|
var recipientsToDisplay = filterAndReworkRecipients(recipients, previousRecipients);
|
|
@@ -34,6 +39,8 @@ var RecipientList = function RecipientList(_ref) {
|
|
|
34
39
|
documentType: documentType,
|
|
35
40
|
onRevoke: onRevoke,
|
|
36
41
|
onRevokeSelf: onRevokeSelf,
|
|
42
|
+
onRevokeGroup: onRevokeGroup,
|
|
43
|
+
onLeaveGroup: onLeaveGroup,
|
|
37
44
|
fadeIn: recipient.hasBeenJustAdded
|
|
38
45
|
}));
|
|
39
46
|
}
|
|
@@ -46,8 +53,11 @@ var RecipientList = function RecipientList(_ref) {
|
|
|
46
53
|
isSharedDrive: isSharedDrive,
|
|
47
54
|
document: document,
|
|
48
55
|
documentType: documentType,
|
|
56
|
+
isInsideSharedParent: isInsideSharedParent,
|
|
57
|
+
sharedParentName: sharedParentName,
|
|
49
58
|
onRevoke: onRevoke,
|
|
50
59
|
onRevokeSelf: onRevokeSelf,
|
|
60
|
+
onSetMemberType: onSetMemberType,
|
|
51
61
|
recipientConfirmationData: recipientConfirmationData,
|
|
52
62
|
verifyRecipient: verifyRecipient,
|
|
53
63
|
fadeIn: recipient.hasBeenJustAdded
|
|
@@ -9,6 +9,9 @@ var meta = {
|
|
|
9
9
|
isOwner: false,
|
|
10
10
|
onRevoke: function onRevoke() {},
|
|
11
11
|
onRevokeSelf: function onRevokeSelf() {},
|
|
12
|
+
onRevokeGroup: function onRevokeGroup() {},
|
|
13
|
+
onLeaveGroup: function onLeaveGroup() {},
|
|
14
|
+
onSetMemberType: function onSetMemberType() {},
|
|
12
15
|
verifyRecipient: function verifyRecipient() {
|
|
13
16
|
return true;
|
|
14
17
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
2
|
|
|
4
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; }
|
|
@@ -8,23 +7,17 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
8
7
|
import PropTypes from 'prop-types';
|
|
9
8
|
import React from 'react';
|
|
10
9
|
import { useQueryAll, isQueryLoading } from 'cozy-client';
|
|
11
|
-
import { models } from 'cozy-client';
|
|
12
10
|
import flag from 'cozy-flags';
|
|
13
11
|
import ShareAutosuggest from './ShareAutosuggest';
|
|
14
|
-
import {
|
|
12
|
+
import { computeContactsAndGroups } from '../helpers/contacts';
|
|
15
13
|
import { buildReachableContactsQuery, buildContactGroupsQuery, buildUnreachableContactsWithGroupsQuery } from '../queries/queries';
|
|
16
|
-
var ContactModel = models.contact;
|
|
17
14
|
/**
|
|
18
|
-
*
|
|
15
|
+
* ShareAutosuggestWrapper is responsible for fetching contacts and groups.
|
|
19
16
|
* We retrieve all the contacts that are reachable and the groups they belong to.
|
|
20
17
|
* In order to display the total number of members in each group, we also retrieve the contacts that are not reachable.
|
|
21
18
|
*/
|
|
22
19
|
|
|
23
|
-
var
|
|
24
|
-
return contact.me === true;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
var ShareRecipientsInput = function ShareRecipientsInput(_ref) {
|
|
20
|
+
var ShareAutosuggestWrapper = function ShareAutosuggestWrapper(_ref) {
|
|
28
21
|
var currentRecipients = _ref.currentRecipients,
|
|
29
22
|
recipients = _ref.recipients,
|
|
30
23
|
placeholder = _ref.placeholder,
|
|
@@ -43,48 +36,13 @@ var ShareRecipientsInput = function ShareRecipientsInput(_ref) {
|
|
|
43
36
|
var contactGroupsQuery = buildContactGroupsQuery();
|
|
44
37
|
var contactGroupsResult = useQueryAll(contactGroupsQuery.definition, contactGroupsQuery.options);
|
|
45
38
|
var isLoading = isQueryLoading(reachableContactsResult) || reachableContactsResult.hasMore || isQueryLoading(contactGroupsResult) || contactGroupsResult.hasMore || flag('sharing.show-recipient-groups') && (isQueryLoading(unreachableContactsWithGroupsResult) || unreachableContactsWithGroupsResult.hasMore);
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return r._id === contact._id;
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
var unreachableContactsWithGroups = (unreachableContactsWithGroupsResult.data || []).filter(function (contact) {
|
|
56
|
-
return !isCurrentUser(contact);
|
|
57
|
-
});
|
|
58
|
-
var currentRecipientGroups = currentRecipients.map(function (_ref2) {
|
|
59
|
-
var id = _ref2.id;
|
|
60
|
-
return id;
|
|
61
|
-
}).filter(Boolean);
|
|
62
|
-
var contactGroups = (contactGroupsResult.data || []).filter(function (_ref3) {
|
|
63
|
-
var _id = _ref3._id;
|
|
64
|
-
return !flag('sharing.show-recipient-groups') || !currentRecipientGroups.includes(_id);
|
|
65
|
-
}).map(function (contactGroup) {
|
|
66
|
-
var reachableMembers = getContactsFromGroupId(reachableContacts, contactGroup.id).map(function (contact) {
|
|
67
|
-
return _objectSpread(_objectSpread({}, contact), {}, {
|
|
68
|
-
isReachable: true
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
if (flag('sharing.show-recipient-groups') !== true) {
|
|
73
|
-
return _objectSpread(_objectSpread({}, contactGroup), {}, {
|
|
74
|
-
members: reachableMembers
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
var unreachableMembers = getContactsFromGroupId(unreachableContactsWithGroups, contactGroup.id).map(function (contact) {
|
|
79
|
-
return _objectSpread(_objectSpread({}, contact), {}, {
|
|
80
|
-
isReachable: false
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
return _objectSpread(_objectSpread({}, contactGroup), {}, {
|
|
84
|
-
members: [].concat(_toConsumableArray(reachableMembers), _toConsumableArray(unreachableMembers))
|
|
85
|
-
});
|
|
39
|
+
var contactsAndGroups = computeContactsAndGroups({
|
|
40
|
+
reachableContacts: reachableContactsResult.data || [],
|
|
41
|
+
unreachableContactsWithGroups: unreachableContactsWithGroupsResult.data || [],
|
|
42
|
+
contactGroups: contactGroupsResult.data || [],
|
|
43
|
+
currentRecipients: currentRecipients,
|
|
44
|
+
pendingRecipients: recipients
|
|
86
45
|
});
|
|
87
|
-
var contactsAndGroups = [].concat(_toConsumableArray(reachableContacts), _toConsumableArray(contactGroups));
|
|
88
46
|
return /*#__PURE__*/React.createElement(ShareAutosuggest, {
|
|
89
47
|
loading: isLoading,
|
|
90
48
|
disabled: disabled,
|
|
@@ -99,7 +57,7 @@ var ShareRecipientsInput = function ShareRecipientsInput(_ref) {
|
|
|
99
57
|
});
|
|
100
58
|
};
|
|
101
59
|
|
|
102
|
-
|
|
60
|
+
ShareAutosuggestWrapper.propTypes = {
|
|
103
61
|
currentRecipients: PropTypes.array,
|
|
104
62
|
recipients: PropTypes.array,
|
|
105
63
|
placeholder: PropTypes.string,
|
|
@@ -110,8 +68,8 @@ ShareRecipientsInput.propTypes = {
|
|
|
110
68
|
autoFocus: PropTypes.bool,
|
|
111
69
|
endAdornment: PropTypes.node
|
|
112
70
|
};
|
|
113
|
-
|
|
71
|
+
ShareAutosuggestWrapper.defaultProps = {
|
|
114
72
|
currentRecipients: [],
|
|
115
73
|
recipients: []
|
|
116
74
|
};
|
|
117
|
-
export default
|
|
75
|
+
export default ShareAutosuggestWrapper;
|
|
@@ -4,7 +4,7 @@ import { render, screen } from '@testing-library/react';
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { createMockClient } from 'cozy-client';
|
|
6
6
|
import flag from 'cozy-flags';
|
|
7
|
-
import
|
|
7
|
+
import ShareAutosuggestWrapper from './ShareAutosuggestWrapper';
|
|
8
8
|
import AppLike from './SharingBanner/test/AppLike';
|
|
9
9
|
jest.mock('cozy-flags', function () {
|
|
10
10
|
return {
|
|
@@ -33,7 +33,7 @@ jest.mock('./ShareAutosuggest', function () {
|
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
});
|
|
36
|
-
describe('
|
|
36
|
+
describe('ShareAutosuggestWrapper component', function () {
|
|
37
37
|
var setup = function setup(_ref2) {
|
|
38
38
|
var contacts = _ref2.contacts,
|
|
39
39
|
contactGroups = _ref2.contactGroups,
|
|
@@ -61,7 +61,7 @@ describe('ShareRecipientsInput component', function () {
|
|
|
61
61
|
});
|
|
62
62
|
render( /*#__PURE__*/React.createElement(AppLike, {
|
|
63
63
|
client: mockClient
|
|
64
|
-
}, /*#__PURE__*/React.createElement(
|
|
64
|
+
}, /*#__PURE__*/React.createElement(ShareAutosuggestWrapper, {
|
|
65
65
|
onPick: function onPick() {},
|
|
66
66
|
onRemove: function onRemove() {},
|
|
67
67
|
placeholder: "Enter recipients here",
|
|
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import flag from 'cozy-flags';
|
|
5
5
|
import { useI18n } from 'twake-i18n';
|
|
6
|
-
import
|
|
6
|
+
import ShareAutosuggestWrapper from './ShareAutosuggestWrapper';
|
|
7
7
|
import ShareTypeSelect from './Sharetypeselect';
|
|
8
8
|
import { mergeRecipients, spreadGroupAndMergeRecipients } from '../helpers/recipients';
|
|
9
9
|
import { isReadOnlySharing } from '../state';
|
|
@@ -69,7 +69,7 @@ export var ShareByEmail = function ShareByEmail(_ref) {
|
|
|
69
69
|
className: styles['coz-form-group']
|
|
70
70
|
}, /*#__PURE__*/React.createElement("div", {
|
|
71
71
|
className: styles['coz-form']
|
|
72
|
-
}, /*#__PURE__*/React.createElement(
|
|
72
|
+
}, /*#__PURE__*/React.createElement(ShareAutosuggestWrapper, {
|
|
73
73
|
placeholder: pendingRecipients.length === 0 ? t("".concat(documentType, ".share.shareByEmail.emailPlaceholder")) : '',
|
|
74
74
|
onPick: onRecipientPick,
|
|
75
75
|
onRemove: onRecipientRemove,
|