cozy-sharing 32.3.2 → 33.0.1
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 +2 -1
- package/dist/components/ShareAutosuggest.js +15 -5
- package/dist/components/ShareAutosuggest.spec.js +26 -2
- package/dist/components/ShareByEmail.js +3 -0
- package/dist/components/ShareByEmail.spec.js +2 -1
- package/dist/components/ShareDialogCozyToCozy.js +2 -1
- package/dist/components/ShareDialogCozyToCozy.spec.js +2 -2
- package/dist/components/ShareRecipientsInput.js +3 -0
- 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/helpers/contacts.js +12 -0
- package/package.json +4 -4
- package/src/components/FederatedFolder/FederatedFolderModal.jsx +1 -0
- package/src/components/ShareAutosuggest.jsx +17 -11
- package/src/components/ShareAutosuggest.spec.jsx +20 -1
- package/src/components/ShareByEmail.jsx +3 -0
- package/src/components/ShareByEmail.spec.jsx +1 -0
- package/src/components/ShareDialogCozyToCozy.jsx +1 -0
- package/src/components/ShareDialogCozyToCozy.spec.jsx +1 -0
- package/src/components/ShareRecipientsInput.jsx +3 -0
- 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/helpers/contacts.js +12 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
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
|
+
## [33.0.1](https://github.com/cozy/cozy-libs/compare/cozy-sharing@33.0.0...cozy-sharing@33.0.1) (2026-06-02)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- Disable new contact creation for shared drives forms ([08abf8a](https://github.com/cozy/cozy-libs/commit/08abf8a21a8d37db190866d68a73744b8bcbf0aa))
|
|
11
|
+
|
|
12
|
+
# [33.0.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@32.3.2...cozy-sharing@33.0.0) (2026-06-02)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
- Avoid adding an already added recipients in EditSharedDriveModal ([d24e01c](https://github.com/cozy/cozy-libs/commit/d24e01c999a2c09fe87e59a0c7a26c3555c96557))
|
|
17
|
+
- Hide owner in EditSharedDriveModal ([9c2b060](https://github.com/cozy/cozy-libs/commit/9c2b060fc3f55c44cf35831298879d3fe0a7a403))
|
|
18
|
+
|
|
19
|
+
### Features
|
|
20
|
+
|
|
21
|
+
- Add spinner to create shared drive form ([4112e7c](https://github.com/cozy/cozy-libs/commit/4112e7c7f592115ed2689ded3f45d876ee12f9dc))
|
|
22
|
+
- Add spinner to edit shared drive form ([f135ff5](https://github.com/cozy/cozy-libs/commit/f135ff5bae8e9fbe6b510a3114af363159ced7af))
|
|
23
|
+
|
|
24
|
+
### BREAKING CHANGES
|
|
25
|
+
|
|
26
|
+
- You need cozy-ui >= 139.0.2
|
|
27
|
+
|
|
6
28
|
## [32.3.2](https://github.com/cozy/cozy-libs/compare/cozy-sharing@32.3.1...cozy-sharing@32.3.2) (2026-05-26)
|
|
7
29
|
|
|
8
30
|
### Bug Fixes
|
|
@@ -258,7 +258,8 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
|
|
|
258
258
|
pendingRecipients: pendingRecipients,
|
|
259
259
|
onPendingRecipientsChange: setPendingRecipients,
|
|
260
260
|
selectedOption: selectedOption,
|
|
261
|
-
onSelectedOptionChange: setSelectedOption
|
|
261
|
+
onSelectedOptionChange: setSelectedOption,
|
|
262
|
+
enableCreateContact: true
|
|
262
263
|
})), /*#__PURE__*/React.createElement(WhoHasAccess, {
|
|
263
264
|
isOwner: true,
|
|
264
265
|
isSharedDrive: true,
|
|
@@ -8,6 +8,7 @@ import Chip from 'cozy-ui/transpiled/react/Chips';
|
|
|
8
8
|
import { Spinner } from 'cozy-ui/transpiled/react/Spinner';
|
|
9
9
|
import { GroupAvatar } from './Avatar/GroupAvatar';
|
|
10
10
|
import ContactSuggestion from './ContactSuggestion';
|
|
11
|
+
import { isContactToBeCreated } from '../helpers/contacts';
|
|
11
12
|
import { extractEmails, validateEmail } from '../helpers/email';
|
|
12
13
|
import { getDisplayName, getInitials, Contact, Group } from '../models';
|
|
13
14
|
var styles = {
|
|
@@ -31,6 +32,7 @@ var ShareAutocomplete = function ShareAutocomplete(_ref) {
|
|
|
31
32
|
recipients = _ref.recipients,
|
|
32
33
|
onPick = _ref.onPick,
|
|
33
34
|
onRemove = _ref.onRemove,
|
|
35
|
+
enableCreateContact = _ref.enableCreateContact,
|
|
34
36
|
placeholder = _ref.placeholder,
|
|
35
37
|
endAdornment = _ref.endAdornment;
|
|
36
38
|
|
|
@@ -67,11 +69,17 @@ var ShareAutocomplete = function ShareAutocomplete(_ref) {
|
|
|
67
69
|
var onSuggestionsFetchRequested = function onSuggestionsFetchRequested(_ref2) {
|
|
68
70
|
var value = _ref2.value;
|
|
69
71
|
var computedSuggestions = computeSuggestions(value);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
72
|
+
|
|
73
|
+
if (computedSuggestions.length > 0) {
|
|
74
|
+
setSuggestions(computedSuggestions);
|
|
75
|
+
} else if (enableCreateContact && validateEmail(value)) {
|
|
76
|
+
setSuggestions([{
|
|
77
|
+
email: value,
|
|
78
|
+
_type: Contact.doctype
|
|
79
|
+
}]);
|
|
80
|
+
} else {
|
|
81
|
+
setSuggestions([]);
|
|
82
|
+
}
|
|
75
83
|
};
|
|
76
84
|
|
|
77
85
|
var onSuggestionsClearRequested = function onSuggestionsClearRequested() {
|
|
@@ -142,6 +150,7 @@ var ShareAutocomplete = function ShareAutocomplete(_ref) {
|
|
|
142
150
|
var onAutosuggestPick = function onAutosuggestPick(value) {
|
|
143
151
|
var _autosuggestRef$curre;
|
|
144
152
|
|
|
153
|
+
if (isContactToBeCreated(value) && !enableCreateContact) return;
|
|
145
154
|
onPick(value);
|
|
146
155
|
setInputValue('');
|
|
147
156
|
autosuggestRef === null || autosuggestRef === void 0 || (_autosuggestRef$curre = autosuggestRef.current) === null || _autosuggestRef$curre === void 0 || (_autosuggestRef$curre = _autosuggestRef$curre.input) === null || _autosuggestRef$curre === void 0 || _autosuggestRef$curre.focus();
|
|
@@ -241,6 +250,7 @@ ShareAutocomplete.propTypes = {
|
|
|
241
250
|
recipients: PropTypes.array.isRequired,
|
|
242
251
|
onPick: PropTypes.func.isRequired,
|
|
243
252
|
onRemove: PropTypes.func.isRequired,
|
|
253
|
+
enableCreateContact: PropTypes.bool,
|
|
244
254
|
placeholder: PropTypes.string,
|
|
245
255
|
endAdornment: PropTypes.node
|
|
246
256
|
};
|
|
@@ -14,14 +14,17 @@ describe('ShareAutosuggest', function () {
|
|
|
14
14
|
var onPick = _ref.onPick,
|
|
15
15
|
onRemove = _ref.onRemove,
|
|
16
16
|
_ref$loading = _ref.loading,
|
|
17
|
-
loading = _ref$loading === void 0 ? false : _ref$loading
|
|
17
|
+
loading = _ref$loading === void 0 ? false : _ref$loading,
|
|
18
|
+
_ref$enableCreateCont = _ref.enableCreateContact,
|
|
19
|
+
enableCreateContact = _ref$enableCreateCont === void 0 ? true : _ref$enableCreateCont;
|
|
18
20
|
render( /*#__PURE__*/React.createElement(AppLike, null, /*#__PURE__*/React.createElement(ShareAutosuggest, {
|
|
19
21
|
loading: loading,
|
|
20
22
|
contactsAndGroups: [],
|
|
21
23
|
placeholder: "myPlaceHolder",
|
|
22
24
|
onPick: onPick,
|
|
23
25
|
recipients: [],
|
|
24
|
-
onRemove: onRemove
|
|
26
|
+
onRemove: onRemove,
|
|
27
|
+
enableCreateContact: enableCreateContact
|
|
25
28
|
})));
|
|
26
29
|
};
|
|
27
30
|
|
|
@@ -78,6 +81,27 @@ describe('ShareAutosuggest', function () {
|
|
|
78
81
|
email: 'quentin.valmori@cozycloud.cc'
|
|
79
82
|
});
|
|
80
83
|
});
|
|
84
|
+
it('should not call onPick for new contacts when enableCreateContact is false', function () {
|
|
85
|
+
var onPick = jest.fn();
|
|
86
|
+
var onRemove = jest.fn();
|
|
87
|
+
setup({
|
|
88
|
+
onPick: onPick,
|
|
89
|
+
onRemove: onRemove,
|
|
90
|
+
enableCreateContact: false
|
|
91
|
+
});
|
|
92
|
+
var inputNode = screen.getByPlaceholderText('myPlaceHolder');
|
|
93
|
+
fireEvent.change(inputNode, {
|
|
94
|
+
target: {
|
|
95
|
+
value: 'new@cozycloud.cc'
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
fireEvent.keyPress(inputNode, {
|
|
99
|
+
key: 'Enter',
|
|
100
|
+
keyCode: 13,
|
|
101
|
+
charCode: 13
|
|
102
|
+
});
|
|
103
|
+
expect(onPick).not.toHaveBeenCalled();
|
|
104
|
+
});
|
|
81
105
|
it('should show loading indicator when loading prop is true (autoFocus triggers onFocus on mount)', function () {
|
|
82
106
|
var onPick = jest.fn();
|
|
83
107
|
var onRemove = jest.fn();
|
|
@@ -33,6 +33,7 @@ export var ShareByEmail = function ShareByEmail(_ref) {
|
|
|
33
33
|
onPendingRecipientsChange = _ref.onPendingRecipientsChange,
|
|
34
34
|
selectedOption = _ref.selectedOption,
|
|
35
35
|
onSelectedOptionChange = _ref.onSelectedOptionChange,
|
|
36
|
+
enableCreateContact = _ref.enableCreateContact,
|
|
36
37
|
sharing = _ref.sharing;
|
|
37
38
|
|
|
38
39
|
var _useI18n = useI18n(),
|
|
@@ -71,6 +72,7 @@ export var ShareByEmail = function ShareByEmail(_ref) {
|
|
|
71
72
|
placeholder: pendingRecipients.length === 0 ? t("".concat(documentType, ".share.shareByEmail.emailPlaceholder")) : '',
|
|
72
73
|
onPick: onRecipientPick,
|
|
73
74
|
onRemove: onRecipientRemove,
|
|
75
|
+
enableCreateContact: enableCreateContact,
|
|
74
76
|
currentRecipients: currentRecipients,
|
|
75
77
|
recipients: pendingRecipients,
|
|
76
78
|
endAdornment: /*#__PURE__*/React.createElement(ShareTypeSelect, {
|
|
@@ -88,6 +90,7 @@ ShareByEmail.propTypes = {
|
|
|
88
90
|
onPendingRecipientsChange: PropTypes.func.isRequired,
|
|
89
91
|
selectedOption: PropTypes.oneOf(['readWrite', 'readOnly']).isRequired,
|
|
90
92
|
onSelectedOptionChange: PropTypes.func.isRequired,
|
|
93
|
+
enableCreateContact: PropTypes.bool,
|
|
91
94
|
sharing: PropTypes.object
|
|
92
95
|
};
|
|
93
96
|
export default ShareByEmail;
|
|
@@ -25,7 +25,8 @@ describe('ShareByEmail (controlled)', function () {
|
|
|
25
25
|
pendingRecipients: [],
|
|
26
26
|
onPendingRecipientsChange: onPendingRecipientsChange,
|
|
27
27
|
selectedOption: 'readWrite',
|
|
28
|
-
onSelectedOptionChange: onSelectedOptionChange
|
|
28
|
+
onSelectedOptionChange: onSelectedOptionChange,
|
|
29
|
+
enableCreateContact: true
|
|
29
30
|
}, overrides);
|
|
30
31
|
|
|
31
32
|
var utils = render( /*#__PURE__*/React.createElement(AppLike, null, /*#__PURE__*/React.createElement(ShareByEmail, props)));
|
|
@@ -91,7 +91,8 @@ var SharingContent = function SharingContent(_ref) {
|
|
|
91
91
|
pendingRecipients: pendingRecipients,
|
|
92
92
|
onPendingRecipientsChange: onPendingRecipientsChange,
|
|
93
93
|
selectedOption: selectedOption,
|
|
94
|
-
onSelectedOptionChange: onSelectedOptionChange
|
|
94
|
+
onSelectedOptionChange: onSelectedOptionChange,
|
|
95
|
+
enableCreateContact: true
|
|
95
96
|
})), showWhoHasAccess && /*#__PURE__*/React.createElement(WhoHasAccess, {
|
|
96
97
|
document: document,
|
|
97
98
|
documentType: documentType,
|
|
@@ -39,11 +39,11 @@ jest.mock('../hooks/useSharingContext', function () {
|
|
|
39
39
|
};
|
|
40
40
|
});
|
|
41
41
|
jest.mock('../helpers/contacts', function () {
|
|
42
|
-
return {
|
|
42
|
+
return _objectSpread(_objectSpread({}, jest.requireActual('../helpers/contacts')), {}, {
|
|
43
43
|
getOrCreateFromArray: jest.fn(function (client, recipients) {
|
|
44
44
|
return Promise.resolve(recipients);
|
|
45
45
|
})
|
|
46
|
-
};
|
|
46
|
+
});
|
|
47
47
|
});
|
|
48
48
|
describe('ShareDialogCozyToCozy', function () {
|
|
49
49
|
var client = createMockClient({});
|
|
@@ -28,6 +28,7 @@ var ShareRecipientsInput = function ShareRecipientsInput(_ref) {
|
|
|
28
28
|
placeholder = _ref.placeholder,
|
|
29
29
|
onPick = _ref.onPick,
|
|
30
30
|
onRemove = _ref.onRemove,
|
|
31
|
+
enableCreateContact = _ref.enableCreateContact,
|
|
31
32
|
disabled = _ref.disabled,
|
|
32
33
|
endAdornment = _ref.endAdornment;
|
|
33
34
|
var reachableContactsQuery = buildReachableContactsQuery();
|
|
@@ -82,6 +83,7 @@ var ShareRecipientsInput = function ShareRecipientsInput(_ref) {
|
|
|
82
83
|
recipients: recipients,
|
|
83
84
|
onPick: onPick,
|
|
84
85
|
onRemove: onRemove,
|
|
86
|
+
enableCreateContact: enableCreateContact,
|
|
85
87
|
placeholder: placeholder,
|
|
86
88
|
endAdornment: endAdornment
|
|
87
89
|
});
|
|
@@ -93,6 +95,7 @@ ShareRecipientsInput.propTypes = {
|
|
|
93
95
|
placeholder: PropTypes.string,
|
|
94
96
|
onPick: PropTypes.func.isRequired,
|
|
95
97
|
onRemove: PropTypes.func.isRequired,
|
|
98
|
+
enableCreateContact: PropTypes.bool,
|
|
96
99
|
disabled: PropTypes.bool,
|
|
97
100
|
endAdornment: PropTypes.node
|
|
98
101
|
};
|
|
@@ -14,7 +14,7 @@ import Button from 'cozy-ui/transpiled/react/Buttons';
|
|
|
14
14
|
import { FixedDialog } from 'cozy-ui/transpiled/react/CozyDialogs';
|
|
15
15
|
import TextField from 'cozy-ui/transpiled/react/TextField';
|
|
16
16
|
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
17
|
-
import {
|
|
17
|
+
import { useSubmitWithLoader } from 'cozy-ui/transpiled/react/hooks/useSubmitWithLoader';
|
|
18
18
|
import { useI18n } from 'twake-i18n';
|
|
19
19
|
import SharedDriveHeader from './SharedDriveHeader';
|
|
20
20
|
import { getOrCreateFromArray } from '../../helpers/contacts';
|
|
@@ -36,51 +36,37 @@ export var EditSharedDriveModal = withLocales(function (_ref) {
|
|
|
36
36
|
getRecipients = _useSharingContext.getRecipients,
|
|
37
37
|
revoke = _useSharingContext.revoke;
|
|
38
38
|
|
|
39
|
-
var _useAlert = useAlert(),
|
|
40
|
-
showAlert = _useAlert.showAlert;
|
|
41
|
-
|
|
42
39
|
var _usePendingRecipients = usePendingRecipients(),
|
|
43
40
|
pendingRecipients = _usePendingRecipients.pendingRecipients,
|
|
44
41
|
setPendingRecipients = _usePendingRecipients.setPendingRecipients,
|
|
45
42
|
selectedOption = _usePendingRecipients.selectedOption,
|
|
46
43
|
setSelectedOption = _usePendingRecipients.setSelectedOption;
|
|
47
44
|
|
|
45
|
+
var _useSubmitWithLoader = useSubmitWithLoader(),
|
|
46
|
+
onSubmit = _useSubmitWithLoader.onSubmit,
|
|
47
|
+
isLoading = _useSubmitWithLoader.isLoading;
|
|
48
|
+
|
|
48
49
|
var _useState = useState(document.name),
|
|
49
50
|
_useState2 = _slicedToArray(_useState, 2),
|
|
50
51
|
driveName = _useState2[0],
|
|
51
52
|
setDriveName = _useState2[1];
|
|
52
53
|
|
|
53
|
-
var _useState3 = useState(false),
|
|
54
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
55
|
-
isSaving = _useState4[0],
|
|
56
|
-
setIsSaving = _useState4[1];
|
|
57
|
-
|
|
58
54
|
var onSave = /*#__PURE__*/function () {
|
|
59
55
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
60
56
|
var contacts, readWriteRecipients, readOnlyRecipients;
|
|
61
57
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
62
58
|
while (1) switch (_context.prev = _context.next) {
|
|
63
59
|
case 0:
|
|
64
|
-
|
|
65
|
-
_context.next = 2;
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return _context.abrupt("return");
|
|
70
|
-
|
|
71
|
-
case 2:
|
|
72
|
-
setIsSaving(true);
|
|
73
|
-
_context.prev = 3;
|
|
74
|
-
_context.next = 6;
|
|
60
|
+
_context.next = 2;
|
|
75
61
|
return getOrCreateFromArray(client, pendingRecipients, function (contact) {
|
|
76
62
|
return client.create('io.cozy.contacts', contact);
|
|
77
63
|
});
|
|
78
64
|
|
|
79
|
-
case
|
|
65
|
+
case 2:
|
|
80
66
|
contacts = _context.sent;
|
|
81
67
|
readWriteRecipients = selectedOption === 'readOnly' ? [] : contacts;
|
|
82
68
|
readOnlyRecipients = selectedOption === 'readOnly' ? contacts : [];
|
|
83
|
-
_context.next =
|
|
69
|
+
_context.next = 7;
|
|
84
70
|
return share({
|
|
85
71
|
document: document,
|
|
86
72
|
recipients: readWriteRecipients,
|
|
@@ -89,47 +75,23 @@ export var EditSharedDriveModal = withLocales(function (_ref) {
|
|
|
89
75
|
openSharing: false
|
|
90
76
|
});
|
|
91
77
|
|
|
92
|
-
case
|
|
78
|
+
case 7:
|
|
93
79
|
if (!((document === null || document === void 0 ? void 0 : document.name) !== driveName)) {
|
|
94
|
-
_context.next =
|
|
80
|
+
_context.next = 10;
|
|
95
81
|
break;
|
|
96
82
|
}
|
|
97
83
|
|
|
98
|
-
_context.next =
|
|
84
|
+
_context.next = 10;
|
|
99
85
|
return client.collection('io.cozy.files').update(_objectSpread(_objectSpread({}, document), {}, {
|
|
100
86
|
name: driveName,
|
|
101
87
|
_rev: document._rev || document.meta.rev
|
|
102
88
|
}));
|
|
103
89
|
|
|
104
|
-
case
|
|
105
|
-
showAlert({
|
|
106
|
-
message: t('SharedDrive.editSharedDriveModal.successNotification'),
|
|
107
|
-
severity: 'success',
|
|
108
|
-
variant: 'filled'
|
|
109
|
-
});
|
|
110
|
-
onClose();
|
|
111
|
-
_context.next = 21;
|
|
112
|
-
break;
|
|
113
|
-
|
|
114
|
-
case 18:
|
|
115
|
-
_context.prev = 18;
|
|
116
|
-
_context.t0 = _context["catch"](3);
|
|
117
|
-
showAlert({
|
|
118
|
-
message: t('SharedDrive.editSharedDriveModal.errorNotification'),
|
|
119
|
-
severity: 'error',
|
|
120
|
-
variant: 'filled'
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
case 21:
|
|
124
|
-
_context.prev = 21;
|
|
125
|
-
setIsSaving(false);
|
|
126
|
-
return _context.finish(21);
|
|
127
|
-
|
|
128
|
-
case 24:
|
|
90
|
+
case 10:
|
|
129
91
|
case "end":
|
|
130
92
|
return _context.stop();
|
|
131
93
|
}
|
|
132
|
-
}, _callee
|
|
94
|
+
}, _callee);
|
|
133
95
|
}));
|
|
134
96
|
|
|
135
97
|
return function onSave() {
|
|
@@ -168,8 +130,8 @@ export var EditSharedDriveModal = withLocales(function (_ref) {
|
|
|
168
130
|
variant: "h6",
|
|
169
131
|
className: "u-mb-half"
|
|
170
132
|
}, t('Share.contacts.addUsers')), /*#__PURE__*/React.createElement(DumbShareByEmail, {
|
|
171
|
-
currentRecipients: [],
|
|
172
133
|
documentType: "Files",
|
|
134
|
+
currentRecipients: existingRecipients,
|
|
173
135
|
pendingRecipients: pendingRecipients,
|
|
174
136
|
onPendingRecipientsChange: setPendingRecipients,
|
|
175
137
|
selectedOption: selectedOption,
|
|
@@ -177,6 +139,7 @@ export var EditSharedDriveModal = withLocales(function (_ref) {
|
|
|
177
139
|
})), /*#__PURE__*/React.createElement(WhoHasAccess, {
|
|
178
140
|
isOwner: true,
|
|
179
141
|
isSharedDrive: true,
|
|
142
|
+
showOwner: false,
|
|
180
143
|
recipients: existingRecipients,
|
|
181
144
|
document: document,
|
|
182
145
|
documentType: "Files",
|
|
@@ -189,14 +152,28 @@ export var EditSharedDriveModal = withLocales(function (_ref) {
|
|
|
189
152
|
label: t('SharedDrive.sharedDriveModal.cancel'),
|
|
190
153
|
className: "u-w-100 u-m-1",
|
|
191
154
|
size: "large",
|
|
192
|
-
onClick: onClose
|
|
155
|
+
onClick: onClose,
|
|
156
|
+
disabled: isLoading
|
|
193
157
|
}), /*#__PURE__*/React.createElement(Button, {
|
|
194
158
|
variant: "primary",
|
|
195
159
|
label: t('SharedDrive.sharedDriveModal.save'),
|
|
196
160
|
className: "u-w-100 u-m-1",
|
|
197
161
|
size: "large",
|
|
198
|
-
|
|
199
|
-
|
|
162
|
+
onClick: function onClick() {
|
|
163
|
+
return onSubmit({
|
|
164
|
+
submit: onSave,
|
|
165
|
+
success: {
|
|
166
|
+
action: onClose,
|
|
167
|
+
message: t('SharedDrive.editSharedDriveModal.successNotification')
|
|
168
|
+
},
|
|
169
|
+
error: {
|
|
170
|
+
message: function message() {
|
|
171
|
+
return t('SharedDrive.editSharedDriveModal.errorNotification');
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
},
|
|
176
|
+
busy: isLoading
|
|
200
177
|
})))
|
|
201
178
|
});
|
|
202
179
|
});
|
|
@@ -3,6 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import Button from 'cozy-ui/transpiled/react/Buttons';
|
|
4
4
|
import TextField from 'cozy-ui/transpiled/react/TextField';
|
|
5
5
|
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
6
|
+
import { useSubmitWithLoader } from 'cozy-ui/transpiled/react/hooks/useSubmitWithLoader';
|
|
6
7
|
import { useI18n } from 'twake-i18n';
|
|
7
8
|
import withLocales from '../../hoc/withLocales';
|
|
8
9
|
import { default as DumbShareByEmail } from '../ShareByEmail';
|
|
@@ -15,9 +16,7 @@ export var SharedDriveForm = withLocales(function (_ref) {
|
|
|
15
16
|
var _useI18n = useI18n(),
|
|
16
17
|
t = _useI18n.t;
|
|
17
18
|
|
|
18
|
-
var _useSharedDrive = useSharedDrive(
|
|
19
|
-
onSuccess: onSuccess
|
|
20
|
-
}),
|
|
19
|
+
var _useSharedDrive = useSharedDrive(),
|
|
21
20
|
sharedDriveName = _useSharedDrive.sharedDriveName,
|
|
22
21
|
handleSharedDriveNameChange = _useSharedDrive.handleSharedDriveNameChange,
|
|
23
22
|
pendingRecipients = _useSharedDrive.pendingRecipients,
|
|
@@ -26,6 +25,10 @@ export var SharedDriveForm = withLocales(function (_ref) {
|
|
|
26
25
|
setSelectedOption = _useSharedDrive.setSelectedOption,
|
|
27
26
|
onCreate = _useSharedDrive.onCreate;
|
|
28
27
|
|
|
28
|
+
var _useSubmitWithLoader = useSubmitWithLoader(),
|
|
29
|
+
onSubmit = _useSubmitWithLoader.onSubmit,
|
|
30
|
+
isLoading = _useSubmitWithLoader.isLoading;
|
|
31
|
+
|
|
29
32
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
30
33
|
className: "u-ph-2"
|
|
31
34
|
}, /*#__PURE__*/React.createElement(SharedDriveHeader, {
|
|
@@ -55,13 +58,28 @@ export var SharedDriveForm = withLocales(function (_ref) {
|
|
|
55
58
|
label: t('SharedDrive.sharedDriveModal.cancel'),
|
|
56
59
|
className: "u-w-100 u-m-1",
|
|
57
60
|
size: "large",
|
|
58
|
-
onClick: onCancel
|
|
61
|
+
onClick: onCancel,
|
|
62
|
+
disabled: isLoading
|
|
59
63
|
}), /*#__PURE__*/React.createElement(Button, {
|
|
60
64
|
variant: "primary",
|
|
61
65
|
label: t('SharedDrive.sharedDriveModal.create'),
|
|
62
66
|
className: "u-w-100 u-m-1",
|
|
63
67
|
size: "large",
|
|
64
|
-
onClick:
|
|
68
|
+
onClick: function onClick() {
|
|
69
|
+
return onSubmit({
|
|
70
|
+
submit: onCreate,
|
|
71
|
+
success: {
|
|
72
|
+
action: onSuccess,
|
|
73
|
+
message: t('SharedDrive.sharedDriveModal.successNotification')
|
|
74
|
+
},
|
|
75
|
+
error: {
|
|
76
|
+
message: function message() {
|
|
77
|
+
return t('SharedDrive.sharedDriveModal.errorNotification');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
busy: isLoading
|
|
65
83
|
})));
|
|
66
84
|
});
|
|
67
85
|
SharedDriveForm.propTypes = {
|
|
@@ -3,21 +3,12 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
4
|
import { useState } from 'react';
|
|
5
5
|
import { useClient } from 'cozy-client';
|
|
6
|
-
import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert';
|
|
7
|
-
import { useI18n } from 'twake-i18n';
|
|
8
6
|
import { getOrCreateFromArray } from '../../helpers/contacts';
|
|
9
7
|
import { usePendingRecipients } from '../../hooks/usePendingRecipients';
|
|
10
8
|
import { Contact } from '../../models';
|
|
11
|
-
export var useSharedDrive = function useSharedDrive(
|
|
12
|
-
var onSuccess = _ref.onSuccess;
|
|
9
|
+
export var useSharedDrive = function useSharedDrive() {
|
|
13
10
|
var client = useClient();
|
|
14
11
|
|
|
15
|
-
var _useI18n = useI18n(),
|
|
16
|
-
t = _useI18n.t;
|
|
17
|
-
|
|
18
|
-
var _useAlert = useAlert(),
|
|
19
|
-
showAlert = _useAlert.showAlert;
|
|
20
|
-
|
|
21
12
|
var _useState = useState(''),
|
|
22
13
|
_useState2 = _slicedToArray(_useState, 2),
|
|
23
14
|
sharedDriveName = _useState2[0],
|
|
@@ -38,20 +29,19 @@ export var useSharedDrive = function useSharedDrive(_ref) {
|
|
|
38
29
|
};
|
|
39
30
|
|
|
40
31
|
var onCreate = /*#__PURE__*/function () {
|
|
41
|
-
var
|
|
32
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
42
33
|
var contacts, readWriteRecipients, readOnlyRecipients;
|
|
43
34
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
44
35
|
while (1) switch (_context.prev = _context.next) {
|
|
45
36
|
case 0:
|
|
46
|
-
_context.
|
|
47
|
-
_context.next = 3;
|
|
37
|
+
_context.next = 2;
|
|
48
38
|
return getOrCreateFromArray(client, pendingRecipients, createContact);
|
|
49
39
|
|
|
50
|
-
case
|
|
40
|
+
case 2:
|
|
51
41
|
contacts = _context.sent;
|
|
52
42
|
readWriteRecipients = selectedOption === 'readOnly' ? [] : contacts;
|
|
53
43
|
readOnlyRecipients = selectedOption === 'readOnly' ? contacts : [];
|
|
54
|
-
_context.next =
|
|
44
|
+
_context.next = 7;
|
|
55
45
|
return client.collection('io.cozy.sharings').createSharedDrive({
|
|
56
46
|
name: sharedDriveName,
|
|
57
47
|
description: sharedDriveName,
|
|
@@ -59,34 +49,15 @@ export var useSharedDrive = function useSharedDrive(_ref) {
|
|
|
59
49
|
readOnlyRecipients: readOnlyRecipients
|
|
60
50
|
});
|
|
61
51
|
|
|
62
|
-
case
|
|
63
|
-
showAlert({
|
|
64
|
-
message: t('SharedDrive.sharedDriveModal.successNotification'),
|
|
65
|
-
severity: 'success',
|
|
66
|
-
variant: 'filled'
|
|
67
|
-
});
|
|
68
|
-
onSuccess();
|
|
69
|
-
_context.next = 15;
|
|
70
|
-
break;
|
|
71
|
-
|
|
72
|
-
case 12:
|
|
73
|
-
_context.prev = 12;
|
|
74
|
-
_context.t0 = _context["catch"](0);
|
|
75
|
-
showAlert({
|
|
76
|
-
message: t('SharedDrive.sharedDriveModal.errorNotification'),
|
|
77
|
-
severity: 'error',
|
|
78
|
-
variant: 'filled'
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
case 15:
|
|
52
|
+
case 7:
|
|
82
53
|
case "end":
|
|
83
54
|
return _context.stop();
|
|
84
55
|
}
|
|
85
|
-
}, _callee
|
|
56
|
+
}, _callee);
|
|
86
57
|
}));
|
|
87
58
|
|
|
88
59
|
return function onCreate() {
|
|
89
|
-
return
|
|
60
|
+
return _ref.apply(this, arguments);
|
|
90
61
|
};
|
|
91
62
|
}();
|
|
92
63
|
|