cozy-sharing 32.1.2 → 32.3.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/.claude/settings.local.json +27 -0
- package/AGENTS.md +7 -0
- package/CHANGELOG.md +18 -0
- package/dist/RefreshableSharings.spec.js +40 -0
- package/dist/assets/illustrations/illustration-shared-drives.svg +1 -0
- package/dist/components/EditLinkPermissionDialog.js +72 -0
- package/dist/components/EditLinkPermissionDialog.spec.js +48 -0
- package/dist/components/FederatedFolder/DumbFederatedFolderModal.js +65 -0
- package/dist/components/FederatedFolder/DumbFederatedFolderModal.spec.js +107 -0
- package/dist/components/FederatedFolder/FederatedFolderModal.js +41 -4
- package/dist/components/FederatedFolder/FederatedFolderModal.jsx.tmp.179197.1773939270471 +172 -0
- package/dist/components/FederatedFolder/FederatedFolderModal.spec.js +79 -8
- package/dist/components/Recipient/actions/revokeGroup.js +42 -0
- package/dist/components/Recipient/actions/revokeMember.js +42 -0
- package/dist/components/Recipient/actions/revokeSharedDriveMember.js +41 -0
- package/dist/components/ShareAutosuggest.js +1 -0
- package/dist/components/ShareAutosuggest.spec.js +12 -4
- package/dist/components/ShareDialogCozyToCozy.spec.js +55 -8
- package/dist/components/ShareDiscardChangesModal.js +35 -0
- package/dist/components/ShareModal/ShareModal copy.js +43 -0
- package/dist/components/ShareModal/ShareModal.spec.js +197 -0
- package/dist/components/ShareModal/ShareModalBatchContainer.js +276 -0
- package/dist/components/ShareModal/ShareModalBatchContainer.spec.js +131 -0
- package/dist/components/ShareModal/SharedDriveEditModal.js +59 -0
- package/dist/components/ShareRecipientsInput.js +13 -3
- package/dist/components/ShareRecipientsInput.spec.js +63 -4
- package/dist/components/SharedDrive/DumbSharedDriveModal.js +78 -0
- package/dist/components/SharedDrive/DumbSharedDriveModal.spec.js +126 -0
- package/dist/components/SharedDrive/SharedDriveEditModal.js +110 -0
- package/dist/components/SharedDrive/SharedDriveModal copy.js +356 -0
- package/dist/components/SharedDrive/helpers.js +102 -0
- package/dist/components/SharedDrive/helpers.spec.js +208 -0
- package/dist/components/SharedDriveEditModal.js +43 -0
- package/dist/components/SharedFolder/DumbBatchSharedFolderModal.spec.js +321 -0
- package/dist/components/SharedStatus.js +61 -0
- package/dist/components/SharedStatus.spec.js +44 -0
- package/dist/components/Sharesubmit.js +28 -0
- package/dist/components/__snapshots__/SharedStatus.spec.js.snap +94 -0
- package/dist/helpers/owner.js +14 -0
- package/dist/helpers/owner.spec.js +34 -0
- package/dist/hooks/useConfirmDiscardChanges.js +33 -0
- package/dist/hooks/useContactsAndGroups.js +65 -0
- package/dist/hooks/useSharedDrive.js +130 -0
- package/dist/hooks/useSharedDriveContactsAndGroups.js +65 -0
- package/dist/propTypes.js +26 -0
- package/dist/styles/shareddrive.styl +8 -0
- package/locales/en.json +10 -5
- package/locales/fr.json +10 -5
- package/locales/ru.json +10 -5
- package/locales/vi.json +10 -5
- package/package.json +2 -2
- package/src/components/FederatedFolder/FederatedFolderModal.jsx +184 -138
- package/src/components/FederatedFolder/FederatedFolderModal.spec.jsx +47 -0
- package/src/components/ShareAutosuggest.jsx +1 -0
- package/src/components/ShareAutosuggest.spec.jsx +10 -5
- package/src/components/ShareDialogCozyToCozy.spec.jsx +50 -4
- package/src/components/ShareDiscardChangesModal.jsx +40 -0
- package/src/components/ShareRecipientsInput.jsx +11 -6
- package/src/components/ShareRecipientsInput.spec.jsx +59 -0
|
@@ -18,6 +18,10 @@ import { buildReachableContactsQuery, buildContactGroupsQuery, buildUnreachableC
|
|
|
18
18
|
* In order to display the total number of members in each group, we also retrieve the contacts that are not reachable.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
+
var isCurrentUser = function isCurrentUser(contact) {
|
|
22
|
+
return contact.me === true;
|
|
23
|
+
};
|
|
24
|
+
|
|
21
25
|
var ShareRecipientsInput = function ShareRecipientsInput(_ref) {
|
|
22
26
|
var currentRecipients = _ref.currentRecipients,
|
|
23
27
|
recipients = _ref.recipients,
|
|
@@ -35,6 +39,12 @@ var ShareRecipientsInput = function ShareRecipientsInput(_ref) {
|
|
|
35
39
|
var contactGroupsQuery = buildContactGroupsQuery();
|
|
36
40
|
var contactGroupsResult = useQueryAll(contactGroupsQuery.definition, contactGroupsQuery.options);
|
|
37
41
|
var isLoading = isQueryLoading(reachableContactsResult) || reachableContactsResult.hasMore || isQueryLoading(contactGroupsResult) || contactGroupsResult.hasMore || flag('sharing.show-recipient-groups') && (isQueryLoading(unreachableContactsWithGroupsResult) || unreachableContactsWithGroupsResult.hasMore);
|
|
42
|
+
var reachableContacts = (reachableContactsResult.data || []).filter(function (contact) {
|
|
43
|
+
return !isCurrentUser(contact);
|
|
44
|
+
});
|
|
45
|
+
var unreachableContactsWithGroups = (unreachableContactsWithGroupsResult.data || []).filter(function (contact) {
|
|
46
|
+
return !isCurrentUser(contact);
|
|
47
|
+
});
|
|
38
48
|
var currentRecipientGroups = currentRecipients.map(function (_ref2) {
|
|
39
49
|
var id = _ref2.id;
|
|
40
50
|
return id;
|
|
@@ -43,7 +53,7 @@ var ShareRecipientsInput = function ShareRecipientsInput(_ref) {
|
|
|
43
53
|
var _id = _ref3._id;
|
|
44
54
|
return !flag('sharing.show-recipient-groups') || !currentRecipientGroups.includes(_id);
|
|
45
55
|
}).map(function (contactGroup) {
|
|
46
|
-
var reachableMembers = getContactsFromGroupId(
|
|
56
|
+
var reachableMembers = getContactsFromGroupId(reachableContacts, contactGroup.id).map(function (contact) {
|
|
47
57
|
return _objectSpread(_objectSpread({}, contact), {}, {
|
|
48
58
|
isReachable: true
|
|
49
59
|
});
|
|
@@ -55,7 +65,7 @@ var ShareRecipientsInput = function ShareRecipientsInput(_ref) {
|
|
|
55
65
|
});
|
|
56
66
|
}
|
|
57
67
|
|
|
58
|
-
var unreachableMembers = getContactsFromGroupId(
|
|
68
|
+
var unreachableMembers = getContactsFromGroupId(unreachableContactsWithGroups, contactGroup.id).map(function (contact) {
|
|
59
69
|
return _objectSpread(_objectSpread({}, contact), {}, {
|
|
60
70
|
isReachable: false
|
|
61
71
|
});
|
|
@@ -64,7 +74,7 @@ var ShareRecipientsInput = function ShareRecipientsInput(_ref) {
|
|
|
64
74
|
members: [].concat(_toConsumableArray(reachableMembers), _toConsumableArray(unreachableMembers))
|
|
65
75
|
});
|
|
66
76
|
});
|
|
67
|
-
var contactsAndGroups = [].concat(_toConsumableArray(
|
|
77
|
+
var contactsAndGroups = [].concat(_toConsumableArray(reachableContacts), _toConsumableArray(contactGroups));
|
|
68
78
|
return /*#__PURE__*/React.createElement(ShareAutosuggest, {
|
|
69
79
|
loading: isLoading,
|
|
70
80
|
disabled: disabled,
|
|
@@ -113,10 +113,69 @@ describe('ShareRecipientsInput component', function () {
|
|
|
113
113
|
}
|
|
114
114
|
}, _callee);
|
|
115
115
|
})));
|
|
116
|
-
it('should
|
|
117
|
-
var contacts, contactGroups
|
|
116
|
+
it('should exclude current user from suggestions when me is true', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
117
|
+
var contacts, contactGroups;
|
|
118
118
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
119
119
|
while (1) switch (_context2.prev = _context2.next) {
|
|
120
|
+
case 0:
|
|
121
|
+
contacts = [{
|
|
122
|
+
id: 'df563cc4-6440',
|
|
123
|
+
_id: 'df563cc4-6440',
|
|
124
|
+
_type: 'io.cozy.contacts',
|
|
125
|
+
me: true,
|
|
126
|
+
name: {
|
|
127
|
+
givenName: 'My',
|
|
128
|
+
familyName: 'Self'
|
|
129
|
+
},
|
|
130
|
+
relationships: {
|
|
131
|
+
groups: {
|
|
132
|
+
data: [{
|
|
133
|
+
_id: 'group-id',
|
|
134
|
+
_type: 'io.cozy.contacts.groups'
|
|
135
|
+
}]
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}, {
|
|
139
|
+
id: '5a3b4ccf-c257',
|
|
140
|
+
_id: '5a3b4ccf-c257',
|
|
141
|
+
_type: 'io.cozy.contacts',
|
|
142
|
+
name: {
|
|
143
|
+
givenName: 'Teagan',
|
|
144
|
+
familyName: 'Wolf'
|
|
145
|
+
},
|
|
146
|
+
relationships: {
|
|
147
|
+
groups: {
|
|
148
|
+
data: [{
|
|
149
|
+
_id: 'group-id',
|
|
150
|
+
_type: 'io.cozy.contacts.groups'
|
|
151
|
+
}]
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}];
|
|
155
|
+
contactGroups = [{
|
|
156
|
+
id: 'group-id',
|
|
157
|
+
name: 'Friends',
|
|
158
|
+
_id: 'group-id',
|
|
159
|
+
_type: 'io.cozy.contacts.groups'
|
|
160
|
+
}];
|
|
161
|
+
setup({
|
|
162
|
+
contacts: contacts,
|
|
163
|
+
contactGroups: contactGroups
|
|
164
|
+
});
|
|
165
|
+
expect(screen.queryByText('My Self')).not.toBeInTheDocument();
|
|
166
|
+
expect(screen.getByText('Teagan Wolf')).toBeInTheDocument();
|
|
167
|
+
expect(screen.getByText('Friends - 1 members')).toBeInTheDocument();
|
|
168
|
+
|
|
169
|
+
case 6:
|
|
170
|
+
case "end":
|
|
171
|
+
return _context2.stop();
|
|
172
|
+
}
|
|
173
|
+
}, _callee2);
|
|
174
|
+
})));
|
|
175
|
+
it('should include unreachable members when flag sharing.show-recipient-groups is activated', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
176
|
+
var contacts, contactGroups, unreachableContact;
|
|
177
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
178
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
120
179
|
case 0:
|
|
121
180
|
flag.mockReturnValue(true);
|
|
122
181
|
contacts = [{
|
|
@@ -181,8 +240,8 @@ describe('ShareRecipientsInput component', function () {
|
|
|
181
240
|
|
|
182
241
|
case 8:
|
|
183
242
|
case "end":
|
|
184
|
-
return
|
|
243
|
+
return _context3.stop();
|
|
185
244
|
}
|
|
186
|
-
},
|
|
245
|
+
}, _callee3);
|
|
187
246
|
})));
|
|
188
247
|
});
|
|
@@ -0,0 +1,78 @@
|
|
|
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 DumbSharedDriveModal = withLocales(function (_ref) {
|
|
7
|
+
var title = _ref.title,
|
|
8
|
+
document = _ref.document,
|
|
9
|
+
sharedDriveName = _ref.sharedDriveName,
|
|
10
|
+
handleSharedDriveNameChange = _ref.handleSharedDriveNameChange,
|
|
11
|
+
createContact = _ref.createContact,
|
|
12
|
+
recipients = _ref.recipients,
|
|
13
|
+
currentRecipients = _ref.currentRecipients,
|
|
14
|
+
onRevoke = _ref.onRevoke,
|
|
15
|
+
onSetType = _ref.onSetType,
|
|
16
|
+
onCreate = _ref.onCreate,
|
|
17
|
+
onSend = _ref.onSend,
|
|
18
|
+
onClose = _ref.onClose,
|
|
19
|
+
onShare = _ref.onShare,
|
|
20
|
+
onRename = _ref.onRename,
|
|
21
|
+
_ref$showNameField = _ref.showNameField,
|
|
22
|
+
showNameField = _ref$showNameField === void 0 ? true : _ref$showNameField,
|
|
23
|
+
sharingLink = _ref.sharingLink,
|
|
24
|
+
autoOpenShareRestriction = _ref.autoOpenShareRestriction,
|
|
25
|
+
showGenerateLinkButton = _ref.showGenerateLinkButton;
|
|
26
|
+
|
|
27
|
+
var _useI18n = useI18n(),
|
|
28
|
+
t = _useI18n.t;
|
|
29
|
+
|
|
30
|
+
return /*#__PURE__*/React.createElement(DumbBatchSharedFolderModal, {
|
|
31
|
+
title: title,
|
|
32
|
+
document: document,
|
|
33
|
+
folderName: sharedDriveName,
|
|
34
|
+
handleFolderNameChange: handleSharedDriveNameChange,
|
|
35
|
+
createContact: createContact,
|
|
36
|
+
recipients: recipients,
|
|
37
|
+
currentRecipients: currentRecipients,
|
|
38
|
+
onRevoke: onRevoke,
|
|
39
|
+
onSetType: onSetType,
|
|
40
|
+
onCreate: onCreate,
|
|
41
|
+
onSend: onSend,
|
|
42
|
+
onClose: onClose,
|
|
43
|
+
onShare: onShare,
|
|
44
|
+
onRename: onRename,
|
|
45
|
+
showNameField: showNameField,
|
|
46
|
+
sharingLink: sharingLink,
|
|
47
|
+
nameLabel: t('SharedDrive.sharedDriveModal.nameLabel'),
|
|
48
|
+
addPeopleLabel: t('SharedDrive.sharedDriveModal.addPeople'),
|
|
49
|
+
addButtonLabel: t('SharedDrive.sharedDriveModal.add'),
|
|
50
|
+
cancelLabel: t('SharedDrive.sharedDriveModal.cancel'),
|
|
51
|
+
createLabel: t('SharedDrive.sharedDriveModal.create'),
|
|
52
|
+
shareLabel: t('FederatedFolder.share'),
|
|
53
|
+
saveLabel: t('SharedDrive.sharedDriveModal.save'),
|
|
54
|
+
autoOpenShareRestriction: autoOpenShareRestriction,
|
|
55
|
+
showGenerateLinkButton: showGenerateLinkButton
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
DumbSharedDriveModal.propTypes = {
|
|
59
|
+
title: PropTypes.string,
|
|
60
|
+
document: PropTypes.object,
|
|
61
|
+
sharedDriveName: PropTypes.string,
|
|
62
|
+
handleSharedDriveNameChange: PropTypes.func,
|
|
63
|
+
createContact: PropTypes.func.isRequired,
|
|
64
|
+
recipients: PropTypes.array,
|
|
65
|
+
currentRecipients: PropTypes.array,
|
|
66
|
+
onRevoke: PropTypes.func.isRequired,
|
|
67
|
+
onSetType: PropTypes.func.isRequired,
|
|
68
|
+
onCreate: PropTypes.func,
|
|
69
|
+
onSend: PropTypes.func,
|
|
70
|
+
onClose: PropTypes.func.isRequired,
|
|
71
|
+
onShare: PropTypes.func.isRequired,
|
|
72
|
+
onRename: PropTypes.func,
|
|
73
|
+
showNameField: PropTypes.bool,
|
|
74
|
+
sharingLink: PropTypes.string,
|
|
75
|
+
autoOpenShareRestriction: PropTypes.bool,
|
|
76
|
+
showGenerateLinkButton: PropTypes.bool
|
|
77
|
+
};
|
|
78
|
+
export default DumbSharedDriveModal;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { DumbSharedDriveModal } from './DumbSharedDriveModal';
|
|
5
|
+
var mockDumbBatchSharedFolderModal = jest.fn();
|
|
6
|
+
jest.mock('../SharedFolder/DumbBatchSharedFolderModal', function () {
|
|
7
|
+
return {
|
|
8
|
+
__esModule: true,
|
|
9
|
+
default: function _default(props) {
|
|
10
|
+
mockDumbBatchSharedFolderModal(props);
|
|
11
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
12
|
+
"data-testid": "dumb-batch-shared-folder-modal"
|
|
13
|
+
}, "DumbBatchSharedFolderModal");
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
jest.mock('../../hoc/withLocales', function () {
|
|
18
|
+
return {
|
|
19
|
+
__esModule: true,
|
|
20
|
+
default: function _default(Component) {
|
|
21
|
+
return Component;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
jest.mock('twake-i18n', function () {
|
|
26
|
+
return {
|
|
27
|
+
useI18n: jest.fn().mockReturnValue({
|
|
28
|
+
t: jest.fn(function (key) {
|
|
29
|
+
return key;
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
describe('DumbSharedDriveModal', function () {
|
|
35
|
+
var defaultProps = {
|
|
36
|
+
title: 'Test Shared Drive',
|
|
37
|
+
document: {
|
|
38
|
+
_id: 'doc-123',
|
|
39
|
+
name: 'Test'
|
|
40
|
+
},
|
|
41
|
+
sharedDriveName: 'My Drive',
|
|
42
|
+
handleSharedDriveNameChange: jest.fn(),
|
|
43
|
+
createContact: jest.fn(),
|
|
44
|
+
recipients: [{
|
|
45
|
+
_id: 'r1',
|
|
46
|
+
email: 'test@test.com'
|
|
47
|
+
}],
|
|
48
|
+
currentRecipients: [],
|
|
49
|
+
onRevoke: jest.fn(),
|
|
50
|
+
onSetType: jest.fn(),
|
|
51
|
+
onCreate: jest.fn(),
|
|
52
|
+
onSend: jest.fn(),
|
|
53
|
+
onClose: jest.fn(),
|
|
54
|
+
onShare: jest.fn(),
|
|
55
|
+
onRename: jest.fn(),
|
|
56
|
+
showNameField: true,
|
|
57
|
+
sharingLink: 'https://share.link/123',
|
|
58
|
+
hasRecipientsInitially: false
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
var setup = function setup() {
|
|
62
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
63
|
+
mockDumbBatchSharedFolderModal.mockClear();
|
|
64
|
+
return render( /*#__PURE__*/React.createElement(DumbSharedDriveModal, _extends({}, defaultProps, props)));
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
it('should render DumbBatchSharedFolderModal with correct props', function () {
|
|
68
|
+
setup();
|
|
69
|
+
expect(mockDumbBatchSharedFolderModal).toHaveBeenCalledWith(expect.objectContaining({
|
|
70
|
+
title: 'Test Shared Drive',
|
|
71
|
+
document: defaultProps.document,
|
|
72
|
+
folderName: 'My Drive',
|
|
73
|
+
handleFolderNameChange: defaultProps.handleSharedDriveNameChange,
|
|
74
|
+
createContact: defaultProps.createContact,
|
|
75
|
+
recipients: defaultProps.recipients,
|
|
76
|
+
currentRecipients: defaultProps.currentRecipients,
|
|
77
|
+
onRevoke: defaultProps.onRevoke,
|
|
78
|
+
onSetType: defaultProps.onSetType,
|
|
79
|
+
onCreate: defaultProps.onCreate,
|
|
80
|
+
onSend: defaultProps.onSend,
|
|
81
|
+
onClose: defaultProps.onClose,
|
|
82
|
+
onShare: defaultProps.onShare,
|
|
83
|
+
onRename: defaultProps.onRename,
|
|
84
|
+
showNameField: true,
|
|
85
|
+
sharingLink: 'https://share.link/123',
|
|
86
|
+
hasRecipientsInitially: false
|
|
87
|
+
}));
|
|
88
|
+
});
|
|
89
|
+
it('should pass correct i18n labels to DumbBatchSharedFolderModal', function () {
|
|
90
|
+
setup();
|
|
91
|
+
var passedProps = mockDumbBatchSharedFolderModal.mock.calls[0][0];
|
|
92
|
+
expect(passedProps.nameLabel).toBe('SharedDrive.sharedDriveModal.nameLabel');
|
|
93
|
+
expect(passedProps.addPeopleLabel).toBe('SharedDrive.sharedDriveModal.addPeople');
|
|
94
|
+
expect(passedProps.addButtonLabel).toBe('SharedDrive.sharedDriveModal.add');
|
|
95
|
+
expect(passedProps.cancelLabel).toBe('SharedDrive.sharedDriveModal.cancel');
|
|
96
|
+
expect(passedProps.createLabel).toBe('SharedDrive.sharedDriveModal.create');
|
|
97
|
+
expect(passedProps.shareLabel).toBe('SharedDrive.sharedDriveModal.share');
|
|
98
|
+
expect(passedProps.saveLabel).toBe('SharedDrive.sharedDriveModal.save');
|
|
99
|
+
});
|
|
100
|
+
it('should default showNameField to true', function () {
|
|
101
|
+
var _setup = setup({
|
|
102
|
+
showNameField: undefined
|
|
103
|
+
}),
|
|
104
|
+
rerender = _setup.rerender; // Re-render without showNameField
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
rerender( /*#__PURE__*/React.createElement(DumbSharedDriveModal, _extends({}, defaultProps, {
|
|
108
|
+
showNameField: undefined
|
|
109
|
+
})));
|
|
110
|
+
var passedProps = mockDumbBatchSharedFolderModal.mock.calls[mockDumbBatchSharedFolderModal.mock.calls.length - 1][0];
|
|
111
|
+
expect(passedProps.showNameField).toBe(true);
|
|
112
|
+
});
|
|
113
|
+
it('should handle hasRecipientsInitially correctly', function () {
|
|
114
|
+
setup({
|
|
115
|
+
hasRecipientsInitially: true
|
|
116
|
+
});
|
|
117
|
+
var passedProps = mockDumbBatchSharedFolderModal.mock.calls[0][0];
|
|
118
|
+
expect(passedProps.hasRecipientsInitially).toBe(true);
|
|
119
|
+
});
|
|
120
|
+
it('should render the mocked component', function () {
|
|
121
|
+
var _setup2 = setup(),
|
|
122
|
+
getByTestId = _setup2.getByTestId;
|
|
123
|
+
|
|
124
|
+
expect(getByTestId('dumb-batch-shared-folder-modal')).toBeInTheDocument();
|
|
125
|
+
});
|
|
126
|
+
});
|
|
@@ -0,0 +1,110 @@
|
|
|
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
|
+
};
|