cozy-sharing 32.3.1 → 32.3.2
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 +6 -0
- package/dist/components/FederatedFolder/FederatedFolderModal.js +56 -19
- package/dist/components/FederatedFolder/FederatedFolderModal.spec.js +101 -254
- package/dist/components/Recipient/RecipientList.js +0 -15
- package/dist/components/ShareModal/ShareModal.js +8 -8
- package/dist/state.js +6 -1
- package/package.json +2 -2
- package/src/components/FederatedFolder/FederatedFolderModal.jsx +65 -19
- package/src/components/FederatedFolder/FederatedFolderModal.spec.jsx +28 -150
- package/src/components/Recipient/RecipientList.jsx +0 -18
- package/src/components/ShareModal/ShareModal.jsx +5 -5
- package/src/state.js +5 -1
- package/.claude/settings.local.json +0 -27
- package/AGENTS.md +0 -7
- package/dist/RefreshableSharings.spec.js +0 -40
- package/dist/assets/illustrations/illustration-shared-drives.svg +0 -1
- package/dist/components/EditLinkPermissionDialog.js +0 -72
- package/dist/components/EditLinkPermissionDialog.spec.js +0 -48
- package/dist/components/FederatedFolder/DumbFederatedFolderModal.js +0 -65
- package/dist/components/FederatedFolder/DumbFederatedFolderModal.spec.js +0 -107
- package/dist/components/FederatedFolder/FederatedFolderModal.jsx.tmp.179197.1773939270471 +0 -172
- package/dist/components/Recipient/actions/revokeGroup.js +0 -42
- package/dist/components/Recipient/actions/revokeMember.js +0 -42
- package/dist/components/Recipient/actions/revokeSharedDriveMember.js +0 -41
- package/dist/components/ShareModal/ShareModal copy.js +0 -43
- package/dist/components/ShareModal/ShareModal.spec.js +0 -197
- package/dist/components/ShareModal/ShareModalBatchContainer.js +0 -276
- package/dist/components/ShareModal/ShareModalBatchContainer.spec.js +0 -131
- package/dist/components/ShareModal/SharedDriveEditModal.js +0 -59
- package/dist/components/SharedDrive/DumbSharedDriveModal.js +0 -78
- package/dist/components/SharedDrive/DumbSharedDriveModal.spec.js +0 -126
- package/dist/components/SharedDrive/SharedDriveEditModal.js +0 -110
- package/dist/components/SharedDrive/SharedDriveModal copy.js +0 -356
- package/dist/components/SharedDrive/SharedDriveRecipient.js +0 -61
- package/dist/components/SharedDrive/SharedDriveRecipientPermissions.js +0 -109
- package/dist/components/SharedDrive/SharedDriveRecipientStatus.js +0 -22
- package/dist/components/SharedDrive/helpers.js +0 -102
- package/dist/components/SharedDrive/helpers.spec.js +0 -208
- package/dist/components/SharedDriveEditModal.js +0 -43
- package/dist/components/SharedFolder/DumbBatchSharedFolderModal.js +0 -145
- package/dist/components/SharedFolder/DumbBatchSharedFolderModal.spec.js +0 -321
- package/dist/components/SharedStatus.js +0 -61
- package/dist/components/SharedStatus.spec.js +0 -44
- package/dist/components/Sharesubmit.js +0 -28
- package/dist/components/__snapshots__/SharedStatus.spec.js.snap +0 -94
- package/dist/helpers/owner.js +0 -14
- package/dist/helpers/owner.spec.js +0 -34
- package/dist/hooks/useConfirmDiscardChanges.js +0 -33
- package/dist/hooks/useContactsAndGroups.js +0 -65
- package/dist/hooks/useSharedDrive.js +0 -130
- package/dist/hooks/useSharedDriveContactsAndGroups.js +0 -65
- package/dist/propTypes.js +0 -26
- package/dist/styles/shareddrive.styl +0 -8
- package/src/components/SharedDrive/SharedDriveRecipient.jsx +0 -62
- package/src/components/SharedDrive/SharedDriveRecipientPermissions.jsx +0 -78
- package/src/components/SharedDrive/SharedDriveRecipientStatus.jsx +0 -23
- package/src/components/SharedFolder/DumbBatchSharedFolderModal.jsx +0 -161
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["fadeIn", "members"];
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import Fade from 'cozy-ui/transpiled/react/Fade';
|
|
7
|
-
import ListItem from 'cozy-ui/transpiled/react/ListItem';
|
|
8
|
-
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
|
|
9
|
-
import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
|
|
10
|
-
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
11
|
-
import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints';
|
|
12
|
-
import { useI18n } from 'twake-i18n';
|
|
13
|
-
import SharedDriveRecipientPermissions from './SharedDriveRecipientPermissions';
|
|
14
|
-
import SharedDriveRecipientStatus from './SharedDriveRecipientStatus';
|
|
15
|
-
import { FADE_IN_DURATION, DEFAULT_DISPLAY_NAME } from '../../helpers/recipients';
|
|
16
|
-
import { getDisplayName } from '../../models';
|
|
17
|
-
import { GroupAvatar } from '../Avatar/GroupAvatar';
|
|
18
|
-
import { MemberAvatar } from '../Avatar/MemberAvatar';
|
|
19
|
-
|
|
20
|
-
var SharedDriveRecipient = function SharedDriveRecipient(props) {
|
|
21
|
-
var _useI18n = useI18n(),
|
|
22
|
-
t = _useI18n.t;
|
|
23
|
-
|
|
24
|
-
var _useBreakpoints = useBreakpoints(),
|
|
25
|
-
isMobile = _useBreakpoints.isMobile;
|
|
26
|
-
|
|
27
|
-
var fadeIn = props.fadeIn,
|
|
28
|
-
members = props.members,
|
|
29
|
-
rest = _objectWithoutProperties(props, _excluded);
|
|
30
|
-
|
|
31
|
-
var defaultDisplayName = t(DEFAULT_DISPLAY_NAME);
|
|
32
|
-
var name = getDisplayName(rest, defaultDisplayName);
|
|
33
|
-
return /*#__PURE__*/React.createElement(Fade, {
|
|
34
|
-
in: true,
|
|
35
|
-
timeout: fadeIn ? FADE_IN_DURATION : 0
|
|
36
|
-
}, /*#__PURE__*/React.createElement(ListItem, {
|
|
37
|
-
gutters: isMobile ? 'default' : 'double',
|
|
38
|
-
size: "small"
|
|
39
|
-
}, /*#__PURE__*/React.createElement(ListItemIcon, null, members ? /*#__PURE__*/React.createElement(GroupAvatar, {
|
|
40
|
-
size: "m"
|
|
41
|
-
}) : /*#__PURE__*/React.createElement(MemberAvatar, {
|
|
42
|
-
size: "m",
|
|
43
|
-
recipient: props
|
|
44
|
-
})), /*#__PURE__*/React.createElement(ListItemText, {
|
|
45
|
-
primary: /*#__PURE__*/React.createElement(Typography, {
|
|
46
|
-
variant: "body1"
|
|
47
|
-
}, name),
|
|
48
|
-
secondary: /*#__PURE__*/React.createElement(SharedDriveRecipientStatus, props)
|
|
49
|
-
}), /*#__PURE__*/React.createElement(SharedDriveRecipientPermissions, _extends({}, props, {
|
|
50
|
-
className: "u-flex-shrink-0"
|
|
51
|
-
}))));
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
SharedDriveRecipient.propTypes = {
|
|
55
|
-
instance: PropTypes.string,
|
|
56
|
-
isOwner: PropTypes.bool,
|
|
57
|
-
status: PropTypes.string,
|
|
58
|
-
recipientConfirmationData: PropTypes.object,
|
|
59
|
-
verifyRecipient: PropTypes.func
|
|
60
|
-
};
|
|
61
|
-
export default SharedDriveRecipient;
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
-
import React, { useState, useRef } from 'react';
|
|
5
|
-
import ActionsMenu from 'cozy-ui/transpiled/react/ActionsMenu';
|
|
6
|
-
import { makeActions } from 'cozy-ui/transpiled/react/ActionsMenu/Actions';
|
|
7
|
-
import DropdownButton from 'cozy-ui/transpiled/react/DropdownButton';
|
|
8
|
-
import Icon from 'cozy-ui/transpiled/react/Icon';
|
|
9
|
-
import IconButton from 'cozy-ui/transpiled/react/IconButton';
|
|
10
|
-
import CrossCircleOutlineIcon from 'cozy-ui/transpiled/react/Icons/CrossCircleOutline';
|
|
11
|
-
import { useI18n } from 'twake-i18n';
|
|
12
|
-
import { setReadOnlySharedPermission } from '../Recipient/actions/setReadOnlySharedPermission';
|
|
13
|
-
import { setReadWriteSharedPermission } from '../Recipient/actions/setReadWriteSharedPermission';
|
|
14
|
-
|
|
15
|
-
var ShareDriveRecipientPermissions = function ShareDriveRecipientPermissions(_ref) {
|
|
16
|
-
var index = _ref.index,
|
|
17
|
-
onSetType = _ref.onSetType,
|
|
18
|
-
type = _ref.type,
|
|
19
|
-
onRevoke = _ref.onRevoke;
|
|
20
|
-
|
|
21
|
-
var _useI18n = useI18n(),
|
|
22
|
-
t = _useI18n.t;
|
|
23
|
-
|
|
24
|
-
var buttonRef = useRef();
|
|
25
|
-
|
|
26
|
-
var _useState = useState(false),
|
|
27
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
28
|
-
isMenuDisplayed = _useState2[0],
|
|
29
|
-
setMenuDisplayed = _useState2[1];
|
|
30
|
-
|
|
31
|
-
var toggleMenu = function toggleMenu() {
|
|
32
|
-
return setMenuDisplayed(!isMenuDisplayed);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
var hideMenu = function hideMenu() {
|
|
36
|
-
return setMenuDisplayed(false);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
var handleRevocation = /*#__PURE__*/function () {
|
|
40
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
41
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
42
|
-
while (1) switch (_context.prev = _context.next) {
|
|
43
|
-
case 0:
|
|
44
|
-
onRevoke(index);
|
|
45
|
-
hideMenu();
|
|
46
|
-
|
|
47
|
-
case 2:
|
|
48
|
-
case "end":
|
|
49
|
-
return _context.stop();
|
|
50
|
-
}
|
|
51
|
-
}, _callee);
|
|
52
|
-
}));
|
|
53
|
-
|
|
54
|
-
return function handleRevocation() {
|
|
55
|
-
return _ref2.apply(this, arguments);
|
|
56
|
-
};
|
|
57
|
-
}();
|
|
58
|
-
|
|
59
|
-
var setType = /*#__PURE__*/function () {
|
|
60
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(newType) {
|
|
61
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
62
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
63
|
-
case 0:
|
|
64
|
-
if (newType !== type) {
|
|
65
|
-
onSetType(index, newType);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
hideMenu();
|
|
69
|
-
|
|
70
|
-
case 2:
|
|
71
|
-
case "end":
|
|
72
|
-
return _context2.stop();
|
|
73
|
-
}
|
|
74
|
-
}, _callee2);
|
|
75
|
-
}));
|
|
76
|
-
|
|
77
|
-
return function setType(_x) {
|
|
78
|
-
return _ref3.apply(this, arguments);
|
|
79
|
-
};
|
|
80
|
-
}();
|
|
81
|
-
|
|
82
|
-
var actions = makeActions([setReadOnlySharedPermission, setReadWriteSharedPermission], {
|
|
83
|
-
t: t,
|
|
84
|
-
type: type,
|
|
85
|
-
setType: setType
|
|
86
|
-
});
|
|
87
|
-
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(DropdownButton, {
|
|
88
|
-
ref: buttonRef,
|
|
89
|
-
"aria-controls": "simple-menu",
|
|
90
|
-
"aria-haspopup": "true",
|
|
91
|
-
onClick: toggleMenu,
|
|
92
|
-
textVariant: "body2"
|
|
93
|
-
}, t("Share.type.".concat(type))), /*#__PURE__*/React.createElement(ActionsMenu, {
|
|
94
|
-
ref: buttonRef,
|
|
95
|
-
open: isMenuDisplayed,
|
|
96
|
-
actions: actions,
|
|
97
|
-
autoClose: true,
|
|
98
|
-
onClose: hideMenu
|
|
99
|
-
}), /*#__PURE__*/React.createElement(IconButton, {
|
|
100
|
-
onClick: handleRevocation,
|
|
101
|
-
size: "small",
|
|
102
|
-
className: "u-ml-half",
|
|
103
|
-
"aria-label": t('Share.members.revoke')
|
|
104
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
105
|
-
icon: CrossCircleOutlineIcon
|
|
106
|
-
})));
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
export default ShareDriveRecipientPermissions;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
3
|
-
import { useI18n } from 'twake-i18n';
|
|
4
|
-
|
|
5
|
-
var SharedDriveRecipientStatus = function SharedDriveRecipientStatus(_ref) {
|
|
6
|
-
var members = _ref.members,
|
|
7
|
-
email = _ref.email;
|
|
8
|
-
|
|
9
|
-
var _useI18n = useI18n(),
|
|
10
|
-
t = _useI18n.t;
|
|
11
|
-
|
|
12
|
-
var text = members ? t('GroupRecipient.secondary', {
|
|
13
|
-
memberCount: members.length,
|
|
14
|
-
smart_count: members.length
|
|
15
|
-
}) : email;
|
|
16
|
-
return /*#__PURE__*/React.createElement(Typography, {
|
|
17
|
-
variant: "caption",
|
|
18
|
-
color: "textSecondary"
|
|
19
|
-
}, text);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default SharedDriveRecipientStatus;
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
|
|
4
|
-
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; }
|
|
5
|
-
|
|
6
|
-
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; }
|
|
7
|
-
|
|
8
|
-
import { models } from 'cozy-client';
|
|
9
|
-
var ContactModel = models.contact;
|
|
10
|
-
export var RECIPIENT_INDEX_PREFIX = 'virtual-shared-drive-sharing-';
|
|
11
|
-
export var mergeAndDeduplicateRecipients = function mergeAndDeduplicateRecipients(arrays) {
|
|
12
|
-
var combinedArray = arrays.flat().map(function (item) {
|
|
13
|
-
return _objectSpread(_objectSpread({}, item), {}, {
|
|
14
|
-
id: item.id || item._id
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var seenIds = new Set();
|
|
18
|
-
var uniqueArray = combinedArray.reduce(function (acc, item) {
|
|
19
|
-
var id = item.id || item._id;
|
|
20
|
-
|
|
21
|
-
if (id == null) {
|
|
22
|
-
// Recipients without any identifier are kept as-is to avoid silent data loss
|
|
23
|
-
acc.push(item);
|
|
24
|
-
return acc;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (!seenIds.has(id)) {
|
|
28
|
-
seenIds.add(id); // Ensure both id and _id exist for downstream compatibility
|
|
29
|
-
|
|
30
|
-
var normalizedItem = !item.id || !item._id ? _objectSpread(_objectSpread({}, item), {}, {
|
|
31
|
-
id: item.id || item._id,
|
|
32
|
-
_id: item._id || item.id
|
|
33
|
-
}) : item;
|
|
34
|
-
acc.push(normalizedItem);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return acc;
|
|
38
|
-
}, []);
|
|
39
|
-
return uniqueArray;
|
|
40
|
-
};
|
|
41
|
-
export var moveRecipientToReadWrite = function moveRecipientToReadWrite(federatedRecipients, _id) {
|
|
42
|
-
var recipientToMove = federatedRecipients.readOnlyRecipients.find(function (r) {
|
|
43
|
-
return r._id === _id;
|
|
44
|
-
});
|
|
45
|
-
if (!recipientToMove) return federatedRecipients;
|
|
46
|
-
return {
|
|
47
|
-
recipients: [].concat(_toConsumableArray(federatedRecipients.recipients), [recipientToMove]),
|
|
48
|
-
readOnlyRecipients: federatedRecipients.readOnlyRecipients.filter(function (r) {
|
|
49
|
-
return r._id !== _id;
|
|
50
|
-
})
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
export var moveRecipientToReadOnly = function moveRecipientToReadOnly(federatedRecipients, _id) {
|
|
54
|
-
var recipientToMove = federatedRecipients.recipients.find(function (r) {
|
|
55
|
-
return r._id === _id;
|
|
56
|
-
});
|
|
57
|
-
if (!recipientToMove) return federatedRecipients;
|
|
58
|
-
return {
|
|
59
|
-
recipients: federatedRecipients.recipients.filter(function (r) {
|
|
60
|
-
return r._id !== _id;
|
|
61
|
-
}),
|
|
62
|
-
readOnlyRecipients: [].concat(_toConsumableArray(federatedRecipients.readOnlyRecipients), [recipientToMove])
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
export var formatRecipients = function formatRecipients(sharedDriveRecipients) {
|
|
66
|
-
var recipients = [];
|
|
67
|
-
sharedDriveRecipients.recipients.forEach(function (r) {
|
|
68
|
-
recipients.push({
|
|
69
|
-
index: "".concat(RECIPIENT_INDEX_PREFIX).concat(r._id),
|
|
70
|
-
email: ContactModel.getPrimaryEmail(r),
|
|
71
|
-
public_name: r.displayName || r.name,
|
|
72
|
-
memberIndex: r._id,
|
|
73
|
-
type: 'two-way',
|
|
74
|
-
members: r.members
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
sharedDriveRecipients.readOnlyRecipients.forEach(function (r) {
|
|
78
|
-
recipients.push({
|
|
79
|
-
index: "".concat(RECIPIENT_INDEX_PREFIX).concat(r._id),
|
|
80
|
-
email: ContactModel.getPrimaryEmail(r),
|
|
81
|
-
public_name: r.displayName || r.name,
|
|
82
|
-
memberIndex: r._id,
|
|
83
|
-
type: 'one-way',
|
|
84
|
-
members: r.members
|
|
85
|
-
});
|
|
86
|
-
}); // We need to sort recipients by public_name
|
|
87
|
-
// to avoid reording them every time we change
|
|
88
|
-
// them from read only to read write.
|
|
89
|
-
|
|
90
|
-
recipients.sort(function (a, b) {
|
|
91
|
-
if (a.public_name < b.public_name) {
|
|
92
|
-
return -1;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (a.public_name > b.public_name) {
|
|
96
|
-
return 1;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return 0;
|
|
100
|
-
});
|
|
101
|
-
return recipients;
|
|
102
|
-
};
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import { mergeAndDeduplicateRecipients, moveRecipientToReadWrite, moveRecipientToReadOnly, formatRecipients, RECIPIENT_INDEX_PREFIX } from './helpers';
|
|
2
|
-
describe('mergeAndDeduplicateRecipients', function () {
|
|
3
|
-
it('should merge multiple arrays into one', function () {
|
|
4
|
-
var result = mergeAndDeduplicateRecipients([[{
|
|
5
|
-
id: '1',
|
|
6
|
-
name: 'Alice'
|
|
7
|
-
}], [{
|
|
8
|
-
id: '2',
|
|
9
|
-
name: 'Bob'
|
|
10
|
-
}]]);
|
|
11
|
-
expect(result).toEqual([{
|
|
12
|
-
id: '1',
|
|
13
|
-
_id: '1',
|
|
14
|
-
name: 'Alice'
|
|
15
|
-
}, {
|
|
16
|
-
id: '2',
|
|
17
|
-
_id: '2',
|
|
18
|
-
name: 'Bob'
|
|
19
|
-
}]);
|
|
20
|
-
});
|
|
21
|
-
it('should deduplicate recipients with the same id', function () {
|
|
22
|
-
var result = mergeAndDeduplicateRecipients([[{
|
|
23
|
-
id: '1',
|
|
24
|
-
name: 'Alice'
|
|
25
|
-
}], [{
|
|
26
|
-
id: '1',
|
|
27
|
-
name: 'Alice'
|
|
28
|
-
}]]);
|
|
29
|
-
expect(result).toEqual([{
|
|
30
|
-
id: '1',
|
|
31
|
-
_id: '1',
|
|
32
|
-
name: 'Alice'
|
|
33
|
-
}]);
|
|
34
|
-
});
|
|
35
|
-
it('should normalize _id to id for deduplication', function () {
|
|
36
|
-
var result = mergeAndDeduplicateRecipients([[{
|
|
37
|
-
_id: '1',
|
|
38
|
-
name: 'Alice'
|
|
39
|
-
}], [{
|
|
40
|
-
_id: '2',
|
|
41
|
-
name: 'Bob'
|
|
42
|
-
}]]);
|
|
43
|
-
expect(result).toEqual([{
|
|
44
|
-
_id: '1',
|
|
45
|
-
id: '1',
|
|
46
|
-
name: 'Alice'
|
|
47
|
-
}, {
|
|
48
|
-
_id: '2',
|
|
49
|
-
id: '2',
|
|
50
|
-
name: 'Bob'
|
|
51
|
-
}]);
|
|
52
|
-
});
|
|
53
|
-
it('should deduplicate recipients when one has id and the other has _id', function () {
|
|
54
|
-
var result = mergeAndDeduplicateRecipients([[{
|
|
55
|
-
id: '1',
|
|
56
|
-
name: 'Alice'
|
|
57
|
-
}], [{
|
|
58
|
-
_id: '1',
|
|
59
|
-
name: 'Alice'
|
|
60
|
-
}]]);
|
|
61
|
-
expect(result).toEqual([{
|
|
62
|
-
id: '1',
|
|
63
|
-
_id: '1',
|
|
64
|
-
name: 'Alice'
|
|
65
|
-
}]);
|
|
66
|
-
});
|
|
67
|
-
it('should prefer existing id over _id when both are present', function () {
|
|
68
|
-
var result = mergeAndDeduplicateRecipients([[{
|
|
69
|
-
id: 'real-id',
|
|
70
|
-
_id: 'other-id',
|
|
71
|
-
name: 'Alice'
|
|
72
|
-
}]]);
|
|
73
|
-
expect(result).toEqual([{
|
|
74
|
-
id: 'real-id',
|
|
75
|
-
_id: 'other-id',
|
|
76
|
-
name: 'Alice'
|
|
77
|
-
}]);
|
|
78
|
-
});
|
|
79
|
-
it('should handle empty arrays', function () {
|
|
80
|
-
var result = mergeAndDeduplicateRecipients([[], []]);
|
|
81
|
-
expect(result).toEqual([]);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
describe('moveRecipientToReadWrite', function () {
|
|
85
|
-
it('should move a recipient from readOnly to readWrite', function () {
|
|
86
|
-
var state = {
|
|
87
|
-
recipients: [{
|
|
88
|
-
_id: '1',
|
|
89
|
-
name: 'Alice'
|
|
90
|
-
}],
|
|
91
|
-
readOnlyRecipients: [{
|
|
92
|
-
_id: '2',
|
|
93
|
-
name: 'Bob'
|
|
94
|
-
}]
|
|
95
|
-
};
|
|
96
|
-
var result = moveRecipientToReadWrite(state, '2');
|
|
97
|
-
expect(result.recipients).toEqual([{
|
|
98
|
-
_id: '1',
|
|
99
|
-
name: 'Alice'
|
|
100
|
-
}, {
|
|
101
|
-
_id: '2',
|
|
102
|
-
name: 'Bob'
|
|
103
|
-
}]);
|
|
104
|
-
expect(result.readOnlyRecipients).toEqual([]);
|
|
105
|
-
});
|
|
106
|
-
it('should return unchanged state if recipient not found', function () {
|
|
107
|
-
var state = {
|
|
108
|
-
recipients: [{
|
|
109
|
-
_id: '1',
|
|
110
|
-
name: 'Alice'
|
|
111
|
-
}],
|
|
112
|
-
readOnlyRecipients: []
|
|
113
|
-
};
|
|
114
|
-
var result = moveRecipientToReadWrite(state, '999');
|
|
115
|
-
expect(result).toBe(state);
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
describe('moveRecipientToReadOnly', function () {
|
|
119
|
-
it('should move a recipient from readWrite to readOnly', function () {
|
|
120
|
-
var state = {
|
|
121
|
-
recipients: [{
|
|
122
|
-
_id: '1',
|
|
123
|
-
name: 'Alice'
|
|
124
|
-
}],
|
|
125
|
-
readOnlyRecipients: [{
|
|
126
|
-
_id: '2',
|
|
127
|
-
name: 'Bob'
|
|
128
|
-
}]
|
|
129
|
-
};
|
|
130
|
-
var result = moveRecipientToReadOnly(state, '1');
|
|
131
|
-
expect(result.recipients).toEqual([]);
|
|
132
|
-
expect(result.readOnlyRecipients).toEqual([{
|
|
133
|
-
_id: '2',
|
|
134
|
-
name: 'Bob'
|
|
135
|
-
}, {
|
|
136
|
-
_id: '1',
|
|
137
|
-
name: 'Alice'
|
|
138
|
-
}]);
|
|
139
|
-
});
|
|
140
|
-
it('should return unchanged state if recipient not found', function () {
|
|
141
|
-
var state = {
|
|
142
|
-
recipients: [],
|
|
143
|
-
readOnlyRecipients: [{
|
|
144
|
-
_id: '1',
|
|
145
|
-
name: 'Alice'
|
|
146
|
-
}]
|
|
147
|
-
};
|
|
148
|
-
var result = moveRecipientToReadOnly(state, '999');
|
|
149
|
-
expect(result).toBe(state);
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
describe('formatRecipients', function () {
|
|
153
|
-
it('should format readWrite and readOnly recipients with correct types', function () {
|
|
154
|
-
var input = {
|
|
155
|
-
recipients: [{
|
|
156
|
-
_id: '1',
|
|
157
|
-
displayName: 'Alice',
|
|
158
|
-
email: [{
|
|
159
|
-
address: 'alice@example.com',
|
|
160
|
-
primary: true
|
|
161
|
-
}]
|
|
162
|
-
}],
|
|
163
|
-
readOnlyRecipients: [{
|
|
164
|
-
_id: '2',
|
|
165
|
-
displayName: 'Bob',
|
|
166
|
-
email: [{
|
|
167
|
-
address: 'bob@example.com',
|
|
168
|
-
primary: true
|
|
169
|
-
}]
|
|
170
|
-
}]
|
|
171
|
-
};
|
|
172
|
-
var result = formatRecipients(input);
|
|
173
|
-
expect(result).toHaveLength(2);
|
|
174
|
-
expect(result[0]).toMatchObject({
|
|
175
|
-
index: "".concat(RECIPIENT_INDEX_PREFIX, "1"),
|
|
176
|
-
type: 'two-way',
|
|
177
|
-
public_name: 'Alice'
|
|
178
|
-
});
|
|
179
|
-
expect(result[1]).toMatchObject({
|
|
180
|
-
index: "".concat(RECIPIENT_INDEX_PREFIX, "2"),
|
|
181
|
-
type: 'one-way',
|
|
182
|
-
public_name: 'Bob'
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
it('should sort recipients by public_name', function () {
|
|
186
|
-
var input = {
|
|
187
|
-
recipients: [{
|
|
188
|
-
_id: '1',
|
|
189
|
-
displayName: 'Zara',
|
|
190
|
-
email: [{
|
|
191
|
-
address: 'zara@example.com',
|
|
192
|
-
primary: true
|
|
193
|
-
}]
|
|
194
|
-
}, {
|
|
195
|
-
_id: '2',
|
|
196
|
-
displayName: 'Alice',
|
|
197
|
-
email: [{
|
|
198
|
-
address: 'alice@example.com',
|
|
199
|
-
primary: true
|
|
200
|
-
}]
|
|
201
|
-
}],
|
|
202
|
-
readOnlyRecipients: []
|
|
203
|
-
};
|
|
204
|
-
var result = formatRecipients(input);
|
|
205
|
-
expect(result[0].public_name).toBe('Alice');
|
|
206
|
-
expect(result[1].public_name).toBe('Zara');
|
|
207
|
-
});
|
|
208
|
-
});
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import omit from "lodash/omit";
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { useLocation } from "react-router";
|
|
5
|
-
import EditableSharingModal from "./EditableSharingModal";
|
|
6
|
-
import { SharingDetailsModal } from "./SharingDetailsModal";
|
|
7
|
-
import withLocales from "../../hoc/withLocales";
|
|
8
|
-
import { useSharingContext } from "../../hooks/useSharingContext";
|
|
9
|
-
export var SharedDriveEditModal = withLocales(function (props) {
|
|
10
|
-
var _location$state;
|
|
11
|
-
|
|
12
|
-
var location = useLocation === null || useLocation === void 0 ? void 0 : useLocation();
|
|
13
|
-
var locationProps = location === null || location === void 0 || (_location$state = location.state) === null || _location$state === void 0 ? void 0 : _location$state.modalProps;
|
|
14
|
-
var document = (locationProps === null || locationProps === void 0 ? void 0 : locationProps.document) || props.document;
|
|
15
|
-
var rest = omit(locationProps || props, "document");
|
|
16
|
-
|
|
17
|
-
var _useSharingContext = useSharingContext(),
|
|
18
|
-
byDocId = _useSharingContext.byDocId,
|
|
19
|
-
isOwner = _useSharingContext.isOwner,
|
|
20
|
-
canReshare = _useSharingContext.canReshare,
|
|
21
|
-
documentType = _useSharingContext.documentType,
|
|
22
|
-
getOwner = _useSharingContext.getOwner,
|
|
23
|
-
getSharingType = _useSharingContext.getSharingType,
|
|
24
|
-
getRecipients = _useSharingContext.getRecipients,
|
|
25
|
-
revokeSelf = _useSharingContext.revokeSelf;
|
|
26
|
-
|
|
27
|
-
var isEditable = !byDocId[document.id] || isOwner(document.id) || canReshare(document.id);
|
|
28
|
-
|
|
29
|
-
if (isEditable) {
|
|
30
|
-
return /*#__PURE__*/React.createElement(EditableSharingModal, _extends({
|
|
31
|
-
document: document
|
|
32
|
-
}, rest));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return /*#__PURE__*/React.createElement(SharingDetailsModal, _extends({
|
|
36
|
-
document: document,
|
|
37
|
-
documentType: documentType,
|
|
38
|
-
owner: getOwner(document.id),
|
|
39
|
-
sharingType: getSharingType(document.id),
|
|
40
|
-
recipients: getRecipients(document.id),
|
|
41
|
-
onRevoke: revokeSelf
|
|
42
|
-
}, rest));
|
|
43
|
-
});
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import Button from 'cozy-ui/transpiled/react/Buttons';
|
|
4
|
-
import { FixedDialog } from 'cozy-ui/transpiled/react/CozyDialogs';
|
|
5
|
-
import TextField from 'cozy-ui/transpiled/react/TextField';
|
|
6
|
-
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
7
|
-
import { useI18n } from 'twake-i18n';
|
|
8
|
-
import withLocales from '../../hoc/withLocales';
|
|
9
|
-
import AntivirusAlert from '../AntivirusAlert';
|
|
10
|
-
import { default as DumbShareByEmail } from '../ShareByEmail';
|
|
11
|
-
import ShareByLink from '../ShareByLink';
|
|
12
|
-
import WhoHasAccess from '../WhoHasAccess';
|
|
13
|
-
export var DumbBatchSharedFolderModal = withLocales(function (_ref) {
|
|
14
|
-
var title = _ref.title,
|
|
15
|
-
document = _ref.document,
|
|
16
|
-
folderName = _ref.folderName,
|
|
17
|
-
handleFolderNameChange = _ref.handleFolderNameChange,
|
|
18
|
-
recipients = _ref.recipients,
|
|
19
|
-
currentRecipients = _ref.currentRecipients,
|
|
20
|
-
onRevoke = _ref.onRevoke,
|
|
21
|
-
onSend = _ref.onSend,
|
|
22
|
-
onClose = _ref.onClose,
|
|
23
|
-
_ref$showNameField = _ref.showNameField,
|
|
24
|
-
showNameField = _ref$showNameField === void 0 ? false : _ref$showNameField,
|
|
25
|
-
sharingLink = _ref.sharingLink,
|
|
26
|
-
nameLabel = _ref.nameLabel,
|
|
27
|
-
shareLabel = _ref.shareLabel,
|
|
28
|
-
_ref$showShareByEmail = _ref.showShareByEmail,
|
|
29
|
-
showShareByEmail = _ref$showShareByEmail === void 0 ? true : _ref$showShareByEmail,
|
|
30
|
-
autoOpenShareRestriction = _ref.autoOpenShareRestriction,
|
|
31
|
-
showGenerateLinkButton = _ref.showGenerateLinkButton,
|
|
32
|
-
pendingRecipients = _ref.pendingRecipients,
|
|
33
|
-
onPendingRecipientsChange = _ref.onPendingRecipientsChange,
|
|
34
|
-
selectedOption = _ref.selectedOption,
|
|
35
|
-
onSelectedOptionChange = _ref.onSelectedOptionChange;
|
|
36
|
-
|
|
37
|
-
var _useI18n = useI18n(),
|
|
38
|
-
t = _useI18n.t;
|
|
39
|
-
|
|
40
|
-
var actionButtons = function () {
|
|
41
|
-
if (!showShareByEmail) {
|
|
42
|
-
return /*#__PURE__*/React.createElement(ShareByLink, {
|
|
43
|
-
link: sharingLink,
|
|
44
|
-
document: document,
|
|
45
|
-
documentType: "Files",
|
|
46
|
-
showGenerateLinkButton: showGenerateLinkButton,
|
|
47
|
-
autoOpenShareRestriction: autoOpenShareRestriction
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (!showNameField) {
|
|
52
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ShareByLink, {
|
|
53
|
-
link: sharingLink,
|
|
54
|
-
document: document,
|
|
55
|
-
documentType: "Files",
|
|
56
|
-
showGenerateLinkButton: showGenerateLinkButton,
|
|
57
|
-
autoOpenShareRestriction: autoOpenShareRestriction
|
|
58
|
-
}), /*#__PURE__*/React.createElement(Button, {
|
|
59
|
-
variant: "primary",
|
|
60
|
-
label: shareLabel,
|
|
61
|
-
disabled: !onSend,
|
|
62
|
-
onClick: onSend
|
|
63
|
-
}));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return null;
|
|
67
|
-
}();
|
|
68
|
-
|
|
69
|
-
return /*#__PURE__*/React.createElement(FixedDialog, {
|
|
70
|
-
open: true,
|
|
71
|
-
disableGutters: true,
|
|
72
|
-
onClose: onClose,
|
|
73
|
-
title: title,
|
|
74
|
-
classes: {
|
|
75
|
-
paper: 'u-ov-visible'
|
|
76
|
-
},
|
|
77
|
-
componentsProps: {
|
|
78
|
-
dialogContent: {
|
|
79
|
-
className: 'u-ov-visible'
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
content: /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
83
|
-
className: "u-ph-2"
|
|
84
|
-
}, /*#__PURE__*/React.createElement(AntivirusAlert, {
|
|
85
|
-
document: document
|
|
86
|
-
}), showNameField && handleFolderNameChange && /*#__PURE__*/React.createElement(TextField, {
|
|
87
|
-
required: true,
|
|
88
|
-
label: nameLabel,
|
|
89
|
-
variant: "outlined",
|
|
90
|
-
size: "small",
|
|
91
|
-
className: "u-w-100 u-mt-1-half",
|
|
92
|
-
value: folderName !== null && folderName !== void 0 ? folderName : '',
|
|
93
|
-
onChange: handleFolderNameChange
|
|
94
|
-
}), /*#__PURE__*/React.createElement(Typography, {
|
|
95
|
-
variant: "h6",
|
|
96
|
-
className: "u-mt-1-half u-mb-half"
|
|
97
|
-
}, t('Share.contacts.addUsers')), showShareByEmail && /*#__PURE__*/React.createElement(DumbShareByEmail, {
|
|
98
|
-
currentRecipients: currentRecipients,
|
|
99
|
-
document: document,
|
|
100
|
-
documentType: "Files",
|
|
101
|
-
pendingRecipients: pendingRecipients,
|
|
102
|
-
onPendingRecipientsChange: onPendingRecipientsChange,
|
|
103
|
-
selectedOption: selectedOption,
|
|
104
|
-
onSelectedOptionChange: onSelectedOptionChange
|
|
105
|
-
})), /*#__PURE__*/React.createElement(WhoHasAccess, {
|
|
106
|
-
isOwner: true,
|
|
107
|
-
isSharedDrive: true,
|
|
108
|
-
recipients: recipients,
|
|
109
|
-
document: document,
|
|
110
|
-
documentType: "Files",
|
|
111
|
-
className: "u-w-100",
|
|
112
|
-
onRevoke: onRevoke,
|
|
113
|
-
link: sharingLink
|
|
114
|
-
})),
|
|
115
|
-
actions: actionButtons
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
DumbBatchSharedFolderModal.propTypes = {
|
|
119
|
-
title: PropTypes.string,
|
|
120
|
-
document: PropTypes.object,
|
|
121
|
-
folderName: PropTypes.string,
|
|
122
|
-
handleFolderNameChange: PropTypes.func,
|
|
123
|
-
recipients: PropTypes.array,
|
|
124
|
-
currentRecipients: PropTypes.array,
|
|
125
|
-
onRevoke: PropTypes.func.isRequired,
|
|
126
|
-
onCreate: PropTypes.func,
|
|
127
|
-
onSend: PropTypes.func,
|
|
128
|
-
onClose: PropTypes.func.isRequired,
|
|
129
|
-
onRename: PropTypes.func,
|
|
130
|
-
showNameField: PropTypes.bool,
|
|
131
|
-
sharingLink: PropTypes.string,
|
|
132
|
-
nameLabel: PropTypes.string,
|
|
133
|
-
addPeopleLabel: PropTypes.string,
|
|
134
|
-
cancelLabel: PropTypes.string,
|
|
135
|
-
createLabel: PropTypes.string,
|
|
136
|
-
shareLabel: PropTypes.string,
|
|
137
|
-
saveLabel: PropTypes.string,
|
|
138
|
-
showShareByEmail: PropTypes.bool,
|
|
139
|
-
autoOpenShareRestriction: PropTypes.bool,
|
|
140
|
-
showGenerateLinkButton: PropTypes.bool,
|
|
141
|
-
pendingRecipients: PropTypes.array,
|
|
142
|
-
onPendingRecipientsChange: PropTypes.func,
|
|
143
|
-
selectedOption: PropTypes.oneOf(['readWrite', 'readOnly']),
|
|
144
|
-
onSelectedOptionChange: PropTypes.func
|
|
145
|
-
};
|