cozy-sharing 32.3.1 → 33.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.
- package/CHANGELOG.md +22 -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/components/SharedDrive/EditSharedDriveModal.js +32 -55
- package/dist/components/SharedDrive/SharedDriveForm.js +23 -5
- package/dist/components/SharedDrive/useSharedDrive.js +8 -37
- package/dist/components/SharedDrive/useSharedDrive.spec.js +8 -81
- package/dist/components/WhoHasAccess.js +4 -1
- package/dist/state.js +6 -1
- package/package.json +4 -4
- 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/components/SharedDrive/EditSharedDriveModal.jsx +42 -47
- package/src/components/SharedDrive/SharedDriveForm.jsx +18 -2
- package/src/components/SharedDrive/useSharedDrive.js +15 -35
- package/src/components/SharedDrive/useSharedDrive.spec.js +4 -39
- package/src/components/WhoHasAccess.jsx +3 -1
- 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,110 +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 PropTypes from 'prop-types';
|
|
5
|
-
import React, { useState } from 'react';
|
|
6
|
-
import { useClient } from 'cozy-client';
|
|
7
|
-
import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert';
|
|
8
|
-
import { useI18n } from 'twake-i18n';
|
|
9
|
-
import { DumbSharedDriveModal } from './DumbSharedDriveModal';
|
|
10
|
-
import withLocales from '../../hoc/withLocales';
|
|
11
|
-
import { useSharingContext } from '../../hooks/useSharingContext';
|
|
12
|
-
import { Contact } from '../../models';
|
|
13
|
-
export var SharedDriveEditModal = withLocales(function (_ref) {
|
|
14
|
-
var document = _ref.document,
|
|
15
|
-
sharing = _ref.sharing,
|
|
16
|
-
recipients = _ref.recipients,
|
|
17
|
-
onShare = _ref.onShare,
|
|
18
|
-
onRevoke = _ref.onRevoke,
|
|
19
|
-
onClose = _ref.onClose,
|
|
20
|
-
autoOpenShareRestriction = _ref.autoOpenShareRestriction,
|
|
21
|
-
showGenerateLinkButton = _ref.showGenerateLinkButton;
|
|
22
|
-
var client = useClient();
|
|
23
|
-
|
|
24
|
-
var _useI18n = useI18n(),
|
|
25
|
-
t = _useI18n.t;
|
|
26
|
-
|
|
27
|
-
var _useAlert = useAlert(),
|
|
28
|
-
showAlert = _useAlert.showAlert;
|
|
29
|
-
|
|
30
|
-
var _useSharingContext = useSharingContext(),
|
|
31
|
-
renameSharedDrive = _useSharingContext.renameSharedDrive;
|
|
32
|
-
|
|
33
|
-
var createContact = function createContact(contact) {
|
|
34
|
-
return client.create(Contact.doctype, contact);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
var _useState = useState(sharing === null || sharing === void 0 ? void 0 : sharing.description),
|
|
38
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
39
|
-
name = _useState2[0],
|
|
40
|
-
setName = _useState2[1];
|
|
41
|
-
|
|
42
|
-
var handleNameChange = function handleNameChange(event) {
|
|
43
|
-
setName(event.target.value);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
var onRename = /*#__PURE__*/function () {
|
|
47
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(value) {
|
|
48
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
49
|
-
while (1) switch (_context.prev = _context.next) {
|
|
50
|
-
case 0:
|
|
51
|
-
_context.prev = 0;
|
|
52
|
-
_context.next = 3;
|
|
53
|
-
return renameSharedDrive(document, value);
|
|
54
|
-
|
|
55
|
-
case 3:
|
|
56
|
-
showAlert({
|
|
57
|
-
message: t('SharedDrive.sharedDriveModal.successNotificationUpdate'),
|
|
58
|
-
severity: 'success'
|
|
59
|
-
});
|
|
60
|
-
onClose();
|
|
61
|
-
_context.next = 10;
|
|
62
|
-
break;
|
|
63
|
-
|
|
64
|
-
case 7:
|
|
65
|
-
_context.prev = 7;
|
|
66
|
-
_context.t0 = _context["catch"](0);
|
|
67
|
-
showAlert({
|
|
68
|
-
message: t('SharedDrive.sharedDriveModal.errorNotificationUpdate'),
|
|
69
|
-
severity: 'error'
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
case 10:
|
|
73
|
-
case "end":
|
|
74
|
-
return _context.stop();
|
|
75
|
-
}
|
|
76
|
-
}, _callee, null, [[0, 7]]);
|
|
77
|
-
}));
|
|
78
|
-
|
|
79
|
-
return function onRename(_x) {
|
|
80
|
-
return _ref2.apply(this, arguments);
|
|
81
|
-
};
|
|
82
|
-
}();
|
|
83
|
-
|
|
84
|
-
return /*#__PURE__*/React.createElement(DumbSharedDriveModal, {
|
|
85
|
-
title: t('Files.share.title', {
|
|
86
|
-
name: sharing === null || sharing === void 0 ? void 0 : sharing.description
|
|
87
|
-
}),
|
|
88
|
-
document: document,
|
|
89
|
-
createContact: createContact,
|
|
90
|
-
recipients: recipients,
|
|
91
|
-
onRevoke: onRevoke,
|
|
92
|
-
onClose: onClose,
|
|
93
|
-
onShare: onShare,
|
|
94
|
-
sharedDriveName: name,
|
|
95
|
-
handleSharedDriveNameChange: handleNameChange,
|
|
96
|
-
onRename: onRename,
|
|
97
|
-
autoOpenShareRestriction: autoOpenShareRestriction,
|
|
98
|
-
showGenerateLinkButton: showGenerateLinkButton
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
SharedDriveEditModal.propTypes = {
|
|
102
|
-
document: PropTypes.object,
|
|
103
|
-
sharing: PropTypes.object,
|
|
104
|
-
recipients: PropTypes.array,
|
|
105
|
-
onShare: PropTypes.func.isRequired,
|
|
106
|
-
onRevoke: PropTypes.func.isRequired,
|
|
107
|
-
onClose: PropTypes.func.isRequired,
|
|
108
|
-
autoOpenShareRestriction: PropTypes.bool,
|
|
109
|
-
showGenerateLinkButton: PropTypes.bool
|
|
110
|
-
};
|
|
@@ -1,356 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
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
|
-
|
|
16
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
17
|
-
import PropTypes from 'prop-types';
|
|
18
|
-
import React, { useState, useEffect } from 'react';
|
|
19
|
-
import { useClient } from 'cozy-client';
|
|
20
|
-
import Button from 'cozy-ui/transpiled/react/Buttons';
|
|
21
|
-
import { FixedDialog } from 'cozy-ui/transpiled/react/CozyDialogs';
|
|
22
|
-
import TextField from 'cozy-ui/transpiled/react/TextField';
|
|
23
|
-
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
24
|
-
import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert';
|
|
25
|
-
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
|
|
26
|
-
import { mergeAndDeduplicateRecipients, formatRecipients } from './helpers';
|
|
27
|
-
import withLocales from '../../hoc/withLocales';
|
|
28
|
-
import useContactsAndGroups from '../../hooks/useSharedDriveContactsAndGroups';
|
|
29
|
-
import { useSharingContext } from '../../hooks/useSharingContext';
|
|
30
|
-
import { Contact } from '../../models';
|
|
31
|
-
import { buildSharingsByIdQuery } from '../../queries/queries';
|
|
32
|
-
import { default as DumbShareByEmail } from '../ShareByEmail';
|
|
33
|
-
import WhoHasAccess from '../WhoHasAccess';
|
|
34
|
-
export var SharedDriveModal = withLocales( // ({ onClose, sharedDriveId = '59ee1637e38f3dbab1cbb7eb5f0a922a' }) => {
|
|
35
|
-
function (_ref) {
|
|
36
|
-
var onClose = _ref.onClose,
|
|
37
|
-
sharedDrive = _ref.sharedDrive;
|
|
38
|
-
// ({ onClose, sharedDrive
|
|
39
|
-
var client = useClient();
|
|
40
|
-
|
|
41
|
-
var _useI18n = useI18n(),
|
|
42
|
-
t = _useI18n.t;
|
|
43
|
-
|
|
44
|
-
var _useSharingContext = useSharingContext(),
|
|
45
|
-
share = _useSharingContext.share,
|
|
46
|
-
revoke = _useSharingContext.revoke;
|
|
47
|
-
|
|
48
|
-
var _useAlert = useAlert(),
|
|
49
|
-
showAlert = _useAlert.showAlert;
|
|
50
|
-
|
|
51
|
-
var isUpdate = Boolean(sharedDrive);
|
|
52
|
-
|
|
53
|
-
var _useContactsAndGroups = useContactsAndGroups([]),
|
|
54
|
-
contactsAndGroups = _useContactsAndGroups.contactsAndGroups,
|
|
55
|
-
isLoadingContactsAndGroups = _useContactsAndGroups.isLoading;
|
|
56
|
-
|
|
57
|
-
var _useState = useState({
|
|
58
|
-
recipients: [],
|
|
59
|
-
readOnlyRecipients: []
|
|
60
|
-
}),
|
|
61
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
62
|
-
sharedDriveRecipients = _useState2[0],
|
|
63
|
-
setSharedDriveRecipients = _useState2[1];
|
|
64
|
-
|
|
65
|
-
var _useState3 = useState((sharedDrive === null || sharedDrive === void 0 ? void 0 : sharedDrive.name) || ''),
|
|
66
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
67
|
-
sharedDriveName = _useState4[0],
|
|
68
|
-
setSharedDriveName = _useState4[1];
|
|
69
|
-
|
|
70
|
-
useEffect(function () {
|
|
71
|
-
if (sharedDrive && !isLoadingContactsAndGroups) {
|
|
72
|
-
setSharedDriveName(sharedDrive.rules[0].title);
|
|
73
|
-
setSharedDriveRecipients(separateMembersByPermission(associateToContacts(sharedDrive.members, contactsAndGroups)));
|
|
74
|
-
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
75
|
-
|
|
76
|
-
}, [sharedDrive === null || sharedDrive === void 0 ? void 0 : sharedDrive._id, isLoadingContactsAndGroups]);
|
|
77
|
-
|
|
78
|
-
var onShare = function onShare(params) {
|
|
79
|
-
setSharedDriveRecipients({
|
|
80
|
-
recipients: mergeAndDeduplicateRecipients([sharedDriveRecipients.recipients, params.recipients]),
|
|
81
|
-
readOnlyRecipients: mergeAndDeduplicateRecipients([sharedDriveRecipients.readOnlyRecipients, params.readOnlyRecipients])
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
var handleSharedDriveNameChange = function handleSharedDriveNameChange(event) {
|
|
86
|
-
setSharedDriveName(event.target.value);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
var onUpdate = /*#__PURE__*/function () {
|
|
90
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
91
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
92
|
-
while (1) switch (_context.prev = _context.next) {
|
|
93
|
-
case 0:
|
|
94
|
-
// TODO rename the shared drive
|
|
95
|
-
onClose();
|
|
96
|
-
|
|
97
|
-
case 1:
|
|
98
|
-
case "end":
|
|
99
|
-
return _context.stop();
|
|
100
|
-
}
|
|
101
|
-
}, _callee);
|
|
102
|
-
}));
|
|
103
|
-
|
|
104
|
-
return function onUpdate() {
|
|
105
|
-
return _ref2.apply(this, arguments);
|
|
106
|
-
};
|
|
107
|
-
}();
|
|
108
|
-
|
|
109
|
-
var onCreate = /*#__PURE__*/function () {
|
|
110
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
111
|
-
var _yield$client$create2, sharedDriveFolder;
|
|
112
|
-
|
|
113
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
114
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
115
|
-
case 0:
|
|
116
|
-
_context2.prev = 0;
|
|
117
|
-
_context2.next = 3;
|
|
118
|
-
return client.collection('io.cozy.files').getOrCreateSharedDrivesDirectory();
|
|
119
|
-
|
|
120
|
-
case 3:
|
|
121
|
-
_context2.next = 5;
|
|
122
|
-
return client.create('io.cozy.files', {
|
|
123
|
-
name: sharedDriveName,
|
|
124
|
-
dirId: 'io.cozy.files.shared-drives-dir',
|
|
125
|
-
type: 'directory'
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
case 5:
|
|
129
|
-
_yield$client$create2 = _context2.sent;
|
|
130
|
-
sharedDriveFolder = _yield$client$create2.data;
|
|
131
|
-
_context2.next = 9;
|
|
132
|
-
return share({
|
|
133
|
-
document: sharedDriveFolder,
|
|
134
|
-
recipients: sharedDriveRecipients.recipients,
|
|
135
|
-
readOnlyRecipients: sharedDriveRecipients.readOnlyRecipients,
|
|
136
|
-
sharedDrive: true
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
case 9:
|
|
140
|
-
showAlert({
|
|
141
|
-
message: t('SharedDrive.sharedDriveModal.successNotification'),
|
|
142
|
-
severity: 'success',
|
|
143
|
-
variant: 'filled'
|
|
144
|
-
});
|
|
145
|
-
onClose();
|
|
146
|
-
_context2.next = 16;
|
|
147
|
-
break;
|
|
148
|
-
|
|
149
|
-
case 13:
|
|
150
|
-
_context2.prev = 13;
|
|
151
|
-
_context2.t0 = _context2["catch"](0);
|
|
152
|
-
showAlert({
|
|
153
|
-
message: t('SharedDrive.sharedDriveModal.errorNotification'),
|
|
154
|
-
severity: 'error',
|
|
155
|
-
variant: 'filled'
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
case 16:
|
|
159
|
-
case "end":
|
|
160
|
-
return _context2.stop();
|
|
161
|
-
}
|
|
162
|
-
}, _callee2, null, [[0, 13]]);
|
|
163
|
-
}));
|
|
164
|
-
|
|
165
|
-
return function onCreate() {
|
|
166
|
-
return _ref3.apply(this, arguments);
|
|
167
|
-
};
|
|
168
|
-
}();
|
|
169
|
-
|
|
170
|
-
var onSetType = function onSetType(index, newType) {
|
|
171
|
-
var _id = index.split('virtual-shared-drive-sharing-')[1];
|
|
172
|
-
|
|
173
|
-
if (newType === 'two-way') {
|
|
174
|
-
setSharedDriveRecipients(function (prev) {
|
|
175
|
-
var recipientToMove = prev.readOnlyRecipients.find(function (r) {
|
|
176
|
-
return r._id === _id;
|
|
177
|
-
});
|
|
178
|
-
return {
|
|
179
|
-
recipients: [].concat(_toConsumableArray(prev.recipients), [recipientToMove]),
|
|
180
|
-
readOnlyRecipients: prev.readOnlyRecipients.filter(function (r) {
|
|
181
|
-
return r._id !== _id;
|
|
182
|
-
})
|
|
183
|
-
};
|
|
184
|
-
});
|
|
185
|
-
} else {
|
|
186
|
-
setSharedDriveRecipients(function (prev) {
|
|
187
|
-
var recipientToMove = prev.recipients.find(function (r) {
|
|
188
|
-
return r._id === _id;
|
|
189
|
-
});
|
|
190
|
-
return {
|
|
191
|
-
recipients: prev.recipients.filter(function (r) {
|
|
192
|
-
return r._id !== _id;
|
|
193
|
-
}),
|
|
194
|
-
readOnlyRecipients: [].concat(_toConsumableArray(prev.readOnlyRecipients), [recipientToMove])
|
|
195
|
-
};
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
var onRevoke = /*#__PURE__*/function () {
|
|
201
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(index) {
|
|
202
|
-
var _id;
|
|
203
|
-
|
|
204
|
-
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
205
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
206
|
-
case 0:
|
|
207
|
-
_id = index.split('virtual-shared-drive-sharing-')[1];
|
|
208
|
-
console.log('onRevoke', _id);
|
|
209
|
-
_context3.next = 4;
|
|
210
|
-
return revoke({
|
|
211
|
-
_id: _id
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
case 4:
|
|
215
|
-
console.log('onRevoke after revoke', _id);
|
|
216
|
-
setSharedDriveRecipients(function (prev) {
|
|
217
|
-
return {
|
|
218
|
-
recipients: prev.recipients.filter(function (r) {
|
|
219
|
-
return r._id !== _id;
|
|
220
|
-
}),
|
|
221
|
-
readOnlyRecipients: prev.readOnlyRecipients.filter(function (r) {
|
|
222
|
-
return r._id !== _id;
|
|
223
|
-
})
|
|
224
|
-
};
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
case 6:
|
|
228
|
-
case "end":
|
|
229
|
-
return _context3.stop();
|
|
230
|
-
}
|
|
231
|
-
}, _callee3);
|
|
232
|
-
}));
|
|
233
|
-
|
|
234
|
-
return function onRevoke(_x) {
|
|
235
|
-
return _ref4.apply(this, arguments);
|
|
236
|
-
};
|
|
237
|
-
}();
|
|
238
|
-
|
|
239
|
-
var recipients = formatRecipients(sharedDriveRecipients);
|
|
240
|
-
return /*#__PURE__*/React.createElement(FixedDialog, {
|
|
241
|
-
open: true,
|
|
242
|
-
disableGutters: true,
|
|
243
|
-
onClose: onClose,
|
|
244
|
-
title: t("SharedDrive.sharedDriveModal.".concat(isUpdate ? 'updateTitle' : 'title')),
|
|
245
|
-
content: /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
246
|
-
className: "u-ph-2"
|
|
247
|
-
}, /*#__PURE__*/React.createElement(TextField, {
|
|
248
|
-
required: true,
|
|
249
|
-
label: t('SharedDrive.sharedDriveModal.nameLabel'),
|
|
250
|
-
variant: "outlined",
|
|
251
|
-
size: "small",
|
|
252
|
-
className: "u-w-100 u-mt-1-half",
|
|
253
|
-
value: sharedDriveName,
|
|
254
|
-
onChange: handleSharedDriveNameChange
|
|
255
|
-
}), /*#__PURE__*/React.createElement(Typography, {
|
|
256
|
-
variant: "h6",
|
|
257
|
-
className: "u-mt-1-half u-mb-half"
|
|
258
|
-
}, t('SharedDrive.sharedDriveModal.addPeople')), /*#__PURE__*/React.createElement(DumbShareByEmail, {
|
|
259
|
-
createContact: function createContact(contact) {
|
|
260
|
-
return client.create(Contact.doctype, contact);
|
|
261
|
-
},
|
|
262
|
-
currentRecipients: [],
|
|
263
|
-
document: document,
|
|
264
|
-
documentType: "Files",
|
|
265
|
-
onShare: onShare,
|
|
266
|
-
submitLabel: t('SharedDrive.sharedDriveModal.add'),
|
|
267
|
-
showNotifications: false
|
|
268
|
-
})), /*#__PURE__*/React.createElement(WhoHasAccess, {
|
|
269
|
-
isOwner: true,
|
|
270
|
-
recipients: recipients,
|
|
271
|
-
document: document,
|
|
272
|
-
documentType: "Files",
|
|
273
|
-
className: "u-w-100",
|
|
274
|
-
onRevoke: onRevoke,
|
|
275
|
-
onSetType: onSetType
|
|
276
|
-
})),
|
|
277
|
-
actions: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
|
|
278
|
-
variant: "secondary",
|
|
279
|
-
label: t('SharedDrive.sharedDriveModal.cancel'),
|
|
280
|
-
onClick: onClose
|
|
281
|
-
}), /*#__PURE__*/React.createElement(Button, {
|
|
282
|
-
variant: "primary",
|
|
283
|
-
label: t('SharedDrive.sharedDriveModal.update'),
|
|
284
|
-
onClick: onUpdate
|
|
285
|
-
}), /*#__PURE__*/React.createElement(Button, {
|
|
286
|
-
variant: "primary",
|
|
287
|
-
label: t('SharedDrive.sharedDriveModal.create'),
|
|
288
|
-
onClick: onCreate
|
|
289
|
-
}))
|
|
290
|
-
});
|
|
291
|
-
});
|
|
292
|
-
SharedDriveModal.propTypes = {
|
|
293
|
-
onClose: PropTypes.func.isRequired
|
|
294
|
-
};
|
|
295
|
-
/**
|
|
296
|
-
* Separates sharing members into recipients and read-only recipients
|
|
297
|
-
* @param {Array} members - Array of sharing members
|
|
298
|
-
* @returns {Object} Object containing recipients and readOnlyRecipients arrays
|
|
299
|
-
*/
|
|
300
|
-
|
|
301
|
-
var separateMembersByPermission = function separateMembersByPermission(members) {
|
|
302
|
-
return members.reduce(function (acc, member) {
|
|
303
|
-
if (member.status !== 'owner') {
|
|
304
|
-
if (member.read_only === true) {
|
|
305
|
-
acc.readOnlyRecipients.push(member);
|
|
306
|
-
} else {
|
|
307
|
-
acc.recipients.push(member);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
return acc;
|
|
312
|
-
}, {
|
|
313
|
-
recipients: [],
|
|
314
|
-
readOnlyRecipients: []
|
|
315
|
-
});
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
var associateToContacts = function associateToContacts(members, contacts) {
|
|
319
|
-
console.log('members', members);
|
|
320
|
-
console.log('contacts', contacts);
|
|
321
|
-
var result = [];
|
|
322
|
-
|
|
323
|
-
var _iterator = _createForOfIteratorHelper(members),
|
|
324
|
-
_step;
|
|
325
|
-
|
|
326
|
-
try {
|
|
327
|
-
var _loop = function _loop() {
|
|
328
|
-
var member = _step.value;
|
|
329
|
-
|
|
330
|
-
if (member.status !== 'owner' && member.email && member.instance) {
|
|
331
|
-
console.log('member', member);
|
|
332
|
-
var contact = contacts.find(function (c) {
|
|
333
|
-
var _c$email, _c$cozy;
|
|
334
|
-
|
|
335
|
-
return ((_c$email = c.email) === null || _c$email === void 0 ? void 0 : _c$email[0].address) === member.email && ((_c$cozy = c.cozy) === null || _c$cozy === void 0 || (_c$cozy = _c$cozy[0]) === null || _c$cozy === void 0 ? void 0 : _c$cozy.url) === member.instance;
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
if (contact) {
|
|
339
|
-
result.push(_objectSpread(_objectSpread({}, member), {}, {
|
|
340
|
-
_id: contact._id
|
|
341
|
-
}));
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
};
|
|
345
|
-
|
|
346
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
347
|
-
_loop();
|
|
348
|
-
}
|
|
349
|
-
} catch (err) {
|
|
350
|
-
_iterator.e(err);
|
|
351
|
-
} finally {
|
|
352
|
-
_iterator.f();
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
return result;
|
|
356
|
-
};
|
|
@@ -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;
|