cozy-sharing 28.3.5 → 28.4.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 +6 -0
- package/dist/components/FederatedFolder/DumbFederatedFolderModal.js +56 -0
- package/dist/components/FederatedFolder/FederatedFolderModal.js +150 -0
- package/dist/components/FederatedFolder/FederatedFolderModal.spec.js +543 -0
- package/dist/components/Recipient/LinkRecipient.js +1 -1
- package/dist/components/ShareAutosuggest.js +4 -1
- package/dist/components/ShareByEmail.js +105 -33
- package/dist/components/ShareByEmail.spec.js +111 -9
- package/dist/components/ShareByLink.js +3 -3
- package/dist/components/ShareModal/ShareModal.js +18 -2
- package/dist/components/ShareModal.js +1 -1
- package/dist/components/ShareRecipientsInput.js +5 -2
- package/dist/components/SharedDrive/DumbSharedDriveModal.js +39 -72
- package/dist/components/SharedDrive/SharedDriveModal.js +11 -5
- package/dist/components/SharedDrive/helpers.js +28 -2
- package/dist/components/SharedFolder/DumbBatchSharedFolderModal.js +159 -0
- package/dist/components/WhoHasAccess.js +1 -1
- package/dist/index.js +1 -0
- package/locales/en.json +13 -1
- package/locales/fr.json +15 -3
- package/locales/ru.json +13 -1
- package/locales/vi.json +13 -1
- package/package.json +2 -2
- package/src/components/FederatedFolder/DumbFederatedFolderModal.jsx +62 -0
- package/src/components/FederatedFolder/FederatedFolderModal.jsx +119 -0
- package/src/components/FederatedFolder/FederatedFolderModal.spec.jsx +376 -0
- package/src/components/Recipient/LinkRecipient.jsx +1 -1
- package/src/components/ShareAutosuggest.jsx +4 -1
- package/src/components/ShareByEmail.jsx +47 -8
- package/src/components/ShareByEmail.spec.jsx +96 -6
- package/src/components/ShareByLink.jsx +7 -3
- package/src/components/ShareModal/ShareModal.jsx +16 -1
- package/src/components/ShareModal.jsx +1 -1
- package/src/components/ShareRecipientsInput.jsx +5 -2
- package/src/components/SharedDrive/DumbSharedDriveModal.jsx +38 -88
- package/src/components/SharedDrive/SharedDriveModal.jsx +14 -4
- package/src/components/SharedDrive/helpers.js +33 -2
- package/src/components/SharedFolder/DumbBatchSharedFolderModal.jsx +174 -0
- package/src/components/WhoHasAccess.jsx +1 -1
- package/src/index.jsx +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [28.4.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@28.3.5...cozy-sharing@28.4.0) (2026-02-24)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **cozy-sharing:** Implement federated folder sharing modal ([94d52b1](https://github.com/cozy/cozy-libs/commit/94d52b1801f4ddc3253e26a8eb5cfdccfbb5388d))
|
|
11
|
+
|
|
6
12
|
## [28.3.5](https://github.com/cozy/cozy-libs/compare/cozy-sharing@28.3.4...cozy-sharing@28.3.5) (2026-02-23)
|
|
7
13
|
|
|
8
14
|
**Note:** Version bump only for package cozy-sharing
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useI18n } from 'twake-i18n';
|
|
4
|
+
import withLocales from '../../hoc/withLocales';
|
|
5
|
+
import DumbBatchSharedFolderModal from '../SharedFolder/DumbBatchSharedFolderModal';
|
|
6
|
+
export var DumbFederatedFolderModal = withLocales(function (_ref) {
|
|
7
|
+
var title = _ref.title,
|
|
8
|
+
document = _ref.document,
|
|
9
|
+
createContact = _ref.createContact,
|
|
10
|
+
recipients = _ref.recipients,
|
|
11
|
+
readOnlyRecipients = _ref.readOnlyRecipients,
|
|
12
|
+
currentRecipients = _ref.currentRecipients,
|
|
13
|
+
onRevoke = _ref.onRevoke,
|
|
14
|
+
onSetType = _ref.onSetType,
|
|
15
|
+
onSend = _ref.onSend,
|
|
16
|
+
onClose = _ref.onClose,
|
|
17
|
+
onShare = _ref.onShare,
|
|
18
|
+
sharingLink = _ref.sharingLink;
|
|
19
|
+
|
|
20
|
+
var _useI18n = useI18n(),
|
|
21
|
+
t = _useI18n.t;
|
|
22
|
+
|
|
23
|
+
return /*#__PURE__*/React.createElement(DumbBatchSharedFolderModal, {
|
|
24
|
+
title: title,
|
|
25
|
+
document: document,
|
|
26
|
+
createContact: createContact,
|
|
27
|
+
recipients: recipients,
|
|
28
|
+
readOnlyRecipients: readOnlyRecipients,
|
|
29
|
+
currentRecipients: currentRecipients,
|
|
30
|
+
onRevoke: onRevoke,
|
|
31
|
+
onSetType: onSetType,
|
|
32
|
+
onSend: onSend,
|
|
33
|
+
onClose: onClose,
|
|
34
|
+
onShare: onShare,
|
|
35
|
+
sharingLink: sharingLink,
|
|
36
|
+
showNameField: false,
|
|
37
|
+
addPeopleLabel: t('FederatedFolder.addPeople'),
|
|
38
|
+
addButtonLabel: t('FederatedFolder.add'),
|
|
39
|
+
shareLabel: t('FederatedFolder.share')
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
DumbFederatedFolderModal.propTypes = {
|
|
43
|
+
title: PropTypes.string,
|
|
44
|
+
document: PropTypes.object,
|
|
45
|
+
createContact: PropTypes.func.isRequired,
|
|
46
|
+
recipients: PropTypes.array,
|
|
47
|
+
readOnlyRecipients: PropTypes.array,
|
|
48
|
+
currentRecipients: PropTypes.array,
|
|
49
|
+
onRevoke: PropTypes.func.isRequired,
|
|
50
|
+
onSetType: PropTypes.func.isRequired,
|
|
51
|
+
onSend: PropTypes.func.isRequired,
|
|
52
|
+
onClose: PropTypes.func.isRequired,
|
|
53
|
+
onShare: PropTypes.func.isRequired,
|
|
54
|
+
sharingLink: PropTypes.string
|
|
55
|
+
};
|
|
56
|
+
export default DumbFederatedFolderModal;
|
|
@@ -0,0 +1,150 @@
|
|
|
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 { useI18n } from 'twake-i18n';
|
|
7
|
+
import { useClient } from 'cozy-client';
|
|
8
|
+
import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert';
|
|
9
|
+
import { DumbFederatedFolderModal } from './DumbFederatedFolderModal';
|
|
10
|
+
import withLocales from '../../hoc/withLocales';
|
|
11
|
+
import { useSharingContext } from '../../hooks/useSharingContext';
|
|
12
|
+
import { formatRecipients, moveRecipientToReadWrite, moveRecipientToReadOnly, RECIPIENT_INDEX_PREFIX } from '../SharedDrive/helpers';
|
|
13
|
+
export var FederatedFolderModal = withLocales(function (_ref) {
|
|
14
|
+
var onClose = _ref.onClose,
|
|
15
|
+
existingDocument = _ref.document;
|
|
16
|
+
var client = useClient();
|
|
17
|
+
|
|
18
|
+
var _useI18n = useI18n(),
|
|
19
|
+
t = _useI18n.t;
|
|
20
|
+
|
|
21
|
+
var _useSharingContext = useSharingContext(),
|
|
22
|
+
share = _useSharingContext.share,
|
|
23
|
+
getSharingLink = _useSharingContext.getSharingLink;
|
|
24
|
+
|
|
25
|
+
var _useAlert = useAlert(),
|
|
26
|
+
showAlert = _useAlert.showAlert; // Get sharing link
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
var sharingLink = existingDocument ? getSharingLink(existingDocument._id) : null;
|
|
30
|
+
|
|
31
|
+
var _useState = useState({
|
|
32
|
+
recipients: [],
|
|
33
|
+
readOnlyRecipients: []
|
|
34
|
+
}),
|
|
35
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
36
|
+
federatedRecipients = _useState2[0],
|
|
37
|
+
setFederatedRecipients = _useState2[1];
|
|
38
|
+
|
|
39
|
+
var _useState3 = useState((existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument.name) || ''),
|
|
40
|
+
_useState4 = _slicedToArray(_useState3, 1),
|
|
41
|
+
folderName = _useState4[0];
|
|
42
|
+
|
|
43
|
+
var onShare = function onShare(params) {
|
|
44
|
+
setFederatedRecipients({
|
|
45
|
+
recipients: params.recipients || [],
|
|
46
|
+
readOnlyRecipients: params.readOnlyRecipients || []
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
var onSend = /*#__PURE__*/function () {
|
|
51
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
52
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
53
|
+
while (1) switch (_context.prev = _context.next) {
|
|
54
|
+
case 0:
|
|
55
|
+
_context.prev = 0;
|
|
56
|
+
_context.next = 3;
|
|
57
|
+
return share({
|
|
58
|
+
description: folderName,
|
|
59
|
+
document: existingDocument,
|
|
60
|
+
recipients: federatedRecipients.recipients,
|
|
61
|
+
readOnlyRecipients: federatedRecipients.readOnlyRecipients,
|
|
62
|
+
sharedDrive: true,
|
|
63
|
+
openSharing: false
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
case 3:
|
|
67
|
+
showAlert({
|
|
68
|
+
message: t('FederatedFolder.successNotification'),
|
|
69
|
+
severity: 'success',
|
|
70
|
+
variant: 'filled'
|
|
71
|
+
});
|
|
72
|
+
onClose();
|
|
73
|
+
_context.next = 10;
|
|
74
|
+
break;
|
|
75
|
+
|
|
76
|
+
case 7:
|
|
77
|
+
_context.prev = 7;
|
|
78
|
+
_context.t0 = _context["catch"](0);
|
|
79
|
+
showAlert({
|
|
80
|
+
message: t('FederatedFolder.errorNotification'),
|
|
81
|
+
severity: 'error',
|
|
82
|
+
variant: 'filled'
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
case 10:
|
|
86
|
+
case "end":
|
|
87
|
+
return _context.stop();
|
|
88
|
+
}
|
|
89
|
+
}, _callee, null, [[0, 7]]);
|
|
90
|
+
}));
|
|
91
|
+
|
|
92
|
+
return function onSend() {
|
|
93
|
+
return _ref2.apply(this, arguments);
|
|
94
|
+
};
|
|
95
|
+
}();
|
|
96
|
+
|
|
97
|
+
var onSetType = function onSetType(index, newType) {
|
|
98
|
+
var _id = index.split(RECIPIENT_INDEX_PREFIX)[1];
|
|
99
|
+
|
|
100
|
+
if (newType === 'two-way') {
|
|
101
|
+
setFederatedRecipients(function (prev) {
|
|
102
|
+
return moveRecipientToReadWrite(prev, _id);
|
|
103
|
+
});
|
|
104
|
+
} else {
|
|
105
|
+
setFederatedRecipients(function (prev) {
|
|
106
|
+
return moveRecipientToReadOnly(prev, _id);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
var onRevoke = function onRevoke(index) {
|
|
112
|
+
var _id = index.split(RECIPIENT_INDEX_PREFIX)[1];
|
|
113
|
+
setFederatedRecipients(function (prev) {
|
|
114
|
+
return {
|
|
115
|
+
recipients: prev.recipients.filter(function (r) {
|
|
116
|
+
return r._id !== _id;
|
|
117
|
+
}),
|
|
118
|
+
readOnlyRecipients: prev.readOnlyRecipients.filter(function (r) {
|
|
119
|
+
return r._id !== _id;
|
|
120
|
+
})
|
|
121
|
+
};
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
var recipients = formatRecipients(federatedRecipients);
|
|
126
|
+
var modalTitle = t('FederatedFolder.shareTitle', {
|
|
127
|
+
name: folderName
|
|
128
|
+
});
|
|
129
|
+
return /*#__PURE__*/React.createElement(DumbFederatedFolderModal, {
|
|
130
|
+
title: modalTitle,
|
|
131
|
+
document: existingDocument,
|
|
132
|
+
createContact: function createContact(contact) {
|
|
133
|
+
return client.create('io.cozy.contacts', contact);
|
|
134
|
+
},
|
|
135
|
+
recipients: recipients,
|
|
136
|
+
readOnlyRecipients: federatedRecipients.readOnlyRecipients,
|
|
137
|
+
currentRecipients: [],
|
|
138
|
+
onRevoke: onRevoke,
|
|
139
|
+
onSetType: onSetType,
|
|
140
|
+
onSend: onSend,
|
|
141
|
+
onClose: onClose,
|
|
142
|
+
onShare: onShare,
|
|
143
|
+
sharingLink: sharingLink
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
FederatedFolderModal.propTypes = {
|
|
147
|
+
onClose: PropTypes.func.isRequired,
|
|
148
|
+
document: PropTypes.object.isRequired
|
|
149
|
+
};
|
|
150
|
+
export default FederatedFolderModal;
|