cozy-sharing 37.0.2 → 37.2.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.
Files changed (65) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/OpenSharingLinkButton.js +1 -1
  3. package/dist/SharingProvider.js +315 -138
  4. package/dist/SharingProvider.spec.js +454 -240
  5. package/dist/actions/addToCozySharingLink.js +1 -1
  6. package/dist/actions/createCozySharingLink.js +1 -1
  7. package/dist/actions/shareNative.js +1 -1
  8. package/dist/actions/syncToCozySharingLink.js +1 -1
  9. package/dist/components/Avatar/AvatarList.js +1 -1
  10. package/dist/components/Recipient/GroupRecipient.js +0 -2
  11. package/dist/components/Recipient/GroupRecipientDetail.js +2 -25
  12. package/dist/components/Recipient/GroupRecipientDetailWithoutAccess.js +1 -1
  13. package/dist/components/Recipient/LinkRecipient.js +1 -1
  14. package/dist/components/Recipient/LinkRecipientLite.js +1 -1
  15. package/dist/components/Recipient/actions/revokeLink.js +1 -1
  16. package/dist/components/ShareAutosuggest.js +6 -6
  17. package/dist/components/ShareButton.js +1 -1
  18. package/dist/components/ShareByLink.js +1 -1
  19. package/dist/components/ShareLinkAccessModal/ShareLinkAccessModal.js +316 -0
  20. package/dist/components/ShareLinkAccessModal/ShareLinkAccessModal.spec.js +372 -0
  21. package/dist/components/ShareLinkAccessModal/index.js +1 -0
  22. package/dist/components/ShareRestrictionModal/BoxDate.js +1 -1
  23. package/dist/components/ShareRestrictionModal/BoxEditingRights.js +1 -1
  24. package/dist/components/ShareRestrictionModal/BoxPassword.js +1 -1
  25. package/dist/components/ShareRestrictionModal/ShareRestrictionModal.js +1 -1
  26. package/dist/components/ShareRestrictionModal/helpers.js +36 -18
  27. package/dist/components/ShareRestrictionModal/helpers.spec.js +3 -3
  28. package/dist/components/SharedBadge.js +1 -1
  29. package/dist/components/SharedDrive/SharedDriveHeader.js +1 -1
  30. package/dist/index.js +1 -0
  31. package/locales/en.json +21 -3
  32. package/locales/fr.json +22 -4
  33. package/locales/ru.json +21 -3
  34. package/locales/vi.json +21 -3
  35. package/package.json +3 -3
  36. package/src/OpenSharingLinkButton.jsx +1 -1
  37. package/src/SharingProvider.jsx +91 -27
  38. package/src/SharingProvider.spec.jsx +212 -60
  39. package/src/actions/addToCozySharingLink.js +1 -1
  40. package/src/actions/createCozySharingLink.js +1 -1
  41. package/src/actions/shareNative.js +1 -1
  42. package/src/actions/syncToCozySharingLink.js +1 -1
  43. package/src/components/Avatar/AvatarList.jsx +1 -1
  44. package/src/components/Recipient/GroupRecipient.jsx +1 -2
  45. package/src/components/Recipient/GroupRecipientDetail.jsx +3 -33
  46. package/src/components/Recipient/GroupRecipientDetailWithoutAccess.jsx +1 -1
  47. package/src/components/Recipient/LinkRecipient.jsx +1 -1
  48. package/src/components/Recipient/LinkRecipientLite.jsx +1 -1
  49. package/src/components/Recipient/actions/revokeLink.js +1 -1
  50. package/src/components/ShareAutosuggest.jsx +3 -4
  51. package/src/components/ShareButton.jsx +1 -1
  52. package/src/components/ShareByLink.jsx +1 -1
  53. package/src/components/ShareLinkAccessModal/ShareLinkAccessModal.jsx +293 -0
  54. package/src/components/ShareLinkAccessModal/ShareLinkAccessModal.spec.jsx +291 -0
  55. package/src/components/ShareLinkAccessModal/index.js +1 -0
  56. package/src/components/ShareRestrictionModal/BoxDate.jsx +1 -1
  57. package/src/components/ShareRestrictionModal/BoxEditingRights.jsx +1 -1
  58. package/src/components/ShareRestrictionModal/BoxPassword.jsx +1 -1
  59. package/src/components/ShareRestrictionModal/ShareRestrictionModal.jsx +1 -1
  60. package/src/components/ShareRestrictionModal/helpers.js +30 -6
  61. package/src/components/ShareRestrictionModal/helpers.spec.js +3 -3
  62. package/src/components/SharedBadge.jsx +2 -1
  63. package/src/components/SharedDrive/SharedDriveHeader.jsx +1 -1
  64. package/src/helpers/sharings.js +0 -1
  65. package/src/index.jsx +1 -0
@@ -0,0 +1,372 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _extends from "@babel/runtime/helpers/extends";
3
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
+ import { fireEvent, render, screen, waitFor } from '@testing-library/react';
5
+ import React from 'react';
6
+ import { ShareLinkAccessModal } from './ShareLinkAccessModal';
7
+ import { useSharingContext } from '../../hooks/useSharingContext';
8
+ jest.mock('../../hooks/useSharingContext', function () {
9
+ return {
10
+ useSharingContext: jest.fn()
11
+ };
12
+ });
13
+ jest.mock('../../hoc/withLocales', function () {
14
+ return function (Component) {
15
+ return function (props) {
16
+ return /*#__PURE__*/React.createElement(Component, props);
17
+ };
18
+ };
19
+ });
20
+ jest.mock('cozy-ui/transpiled/react/CozyDialogs', function () {
21
+ return {
22
+ ConfirmDialog: function ConfirmDialog(_ref) {
23
+ var title = _ref.title,
24
+ content = _ref.content,
25
+ actions = _ref.actions,
26
+ onBack = _ref.onBack,
27
+ onClose = _ref.onClose,
28
+ size = _ref.size;
29
+ return /*#__PURE__*/React.createElement("div", {
30
+ role: "dialog",
31
+ "data-size": size
32
+ }, onBack && /*#__PURE__*/React.createElement("button", {
33
+ onClick: onBack
34
+ }, "Back"), onClose && /*#__PURE__*/React.createElement("button", {
35
+ onClick: onClose
36
+ }, "Close"), /*#__PURE__*/React.createElement("div", null, title), /*#__PURE__*/React.createElement("div", null, content), /*#__PURE__*/React.createElement("div", null, actions));
37
+ }
38
+ };
39
+ });
40
+ jest.mock('cozy-ui/transpiled/react/DropdownButton', function () {
41
+ var mockReact = require('react');
42
+
43
+ return {
44
+ __esModule: true,
45
+ default: mockReact.forwardRef(function (_ref2, ref) {
46
+ var children = _ref2.children,
47
+ onClick = _ref2.onClick,
48
+ disabled = _ref2.disabled,
49
+ ariaLabel = _ref2['aria-label'];
50
+ return /*#__PURE__*/React.createElement("button", {
51
+ ref: ref,
52
+ "aria-label": ariaLabel,
53
+ onClick: onClick,
54
+ disabled: disabled
55
+ }, children);
56
+ })
57
+ };
58
+ });
59
+ jest.mock('cozy-ui/transpiled/react/Menu', function () {
60
+ return {
61
+ __esModule: true,
62
+ default: function _default(_ref3) {
63
+ var open = _ref3.open,
64
+ children = _ref3.children;
65
+ return open ? /*#__PURE__*/React.createElement("div", {
66
+ role: "menu"
67
+ }, children) : null;
68
+ }
69
+ };
70
+ });
71
+ jest.mock('cozy-ui/transpiled/react/MenuItem', function () {
72
+ return {
73
+ __esModule: true,
74
+ default: function _default(_ref4) {
75
+ var children = _ref4.children,
76
+ onClick = _ref4.onClick;
77
+ return /*#__PURE__*/React.createElement("button", {
78
+ onClick: onClick
79
+ }, children);
80
+ }
81
+ };
82
+ });
83
+ jest.mock('cozy-ui/transpiled/react/DatePicker', function () {
84
+ return {
85
+ __esModule: true,
86
+ default: function _default(_ref5) {
87
+ var label = _ref5.label,
88
+ value = _ref5.value,
89
+ _onChange = _ref5.onChange,
90
+ disabled = _ref5.disabled;
91
+ return /*#__PURE__*/React.createElement("input", {
92
+ "aria-label": label,
93
+ type: "date",
94
+ value: value.toISOString().slice(0, 10),
95
+ onChange: function onChange(event) {
96
+ return _onChange(new Date(event.target.value));
97
+ },
98
+ disabled: disabled
99
+ });
100
+ }
101
+ };
102
+ });
103
+ jest.mock('cozy-ui/transpiled/react/TextField', function () {
104
+ return {
105
+ __esModule: true,
106
+ default: function _default(_ref6) {
107
+ var label = _ref6.label,
108
+ value = _ref6.value,
109
+ onChange = _ref6.onChange,
110
+ disabled = _ref6.disabled;
111
+ return /*#__PURE__*/React.createElement("input", {
112
+ "aria-label": label,
113
+ value: value,
114
+ onChange: onChange,
115
+ disabled: disabled
116
+ });
117
+ }
118
+ };
119
+ });
120
+ jest.mock('twake-i18n', function () {
121
+ return {
122
+ useI18n: function useI18n() {
123
+ return {
124
+ t: function t(key) {
125
+ return {
126
+ 'ShareLinkAccessModal.title': 'Set link access',
127
+ 'ShareLinkAccessModal.introText': 'Choose what recipients can do with these files.',
128
+ 'ShareLinkAccessModal.anyoneWithLink': 'Allow anyone with the link to access',
129
+ 'ShareLinkAccessModal.settings': 'Sharing settings',
130
+ 'ShareLinkAccessModal.accessLevel': 'Access level',
131
+ 'ShareLinkAccessModal.viewer': 'Viewer',
132
+ 'ShareLinkAccessModal.editor': 'Editor',
133
+ 'ShareLinkAccessModal.cancel': 'Cancel',
134
+ 'ShareLinkAccessModal.addLinks': 'Add links',
135
+ 'ShareLinkAccessModal.settingsTitle': 'Sharing settings',
136
+ 'ShareLinkAccessModal.expiry': 'Set an expiration date',
137
+ 'ShareLinkAccessModal.expiryDate': 'Expiration date',
138
+ 'ShareLinkAccessModal.password': 'Require a password',
139
+ 'ShareLinkAccessModal.passwordLabel': 'Password',
140
+ 'ShareLinkAccessModal.passwordTooShort': 'Password must contain at least 4 characters.',
141
+ 'ShareLinkAccessModal.error.persistence': 'Could not save link permissions. Please try again.'
142
+ }[key] || key;
143
+ }
144
+ };
145
+ }
146
+ };
147
+ });
148
+ describe('ShareLinkAccessModal', function () {
149
+ var documents = [{
150
+ _id: 'file-id',
151
+ name: 'invoice.pdf'
152
+ }, {
153
+ _id: 'folder-id',
154
+ name: 'Projects'
155
+ }];
156
+ var onCancel = jest.fn();
157
+ var onSuccess = jest.fn();
158
+ var ensureSharingLink = jest.fn();
159
+ beforeEach(function () {
160
+ jest.clearAllMocks();
161
+ useSharingContext.mockReturnValue({
162
+ ensureSharingLink: ensureSharingLink
163
+ });
164
+ });
165
+
166
+ var renderModal = function renderModal() {
167
+ var overrides = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
168
+ return render( /*#__PURE__*/React.createElement(ShareLinkAccessModal, _extends({
169
+ documents: documents,
170
+ onCancel: onCancel,
171
+ onSuccess: onSuccess
172
+ }, overrides)));
173
+ };
174
+
175
+ it('shows the selected documents with viewer access by default', function () {
176
+ renderModal();
177
+ expect(screen.getByRole('dialog')).toHaveTextContent('invoice.pdf');
178
+ expect(screen.getByRole('dialog')).toHaveTextContent('Projects');
179
+ expect(screen.getByText('invoice.pdf').parentElement).toHaveClass('u-maw-100');
180
+ expect(screen.getByLabelText('Access level')).toHaveTextContent('Viewer');
181
+ expect(screen.getByRole('dialog')).toHaveAttribute('data-size', 'small');
182
+ });
183
+ it('keeps document icons inside their chips', function () {
184
+ var renderDocumentIcon = jest.fn(function (document) {
185
+ return /*#__PURE__*/React.createElement("span", {
186
+ "data-testid": "icon-".concat(document._id)
187
+ }, "icon");
188
+ });
189
+ renderModal({
190
+ renderDocumentIcon: renderDocumentIcon
191
+ });
192
+ expect(renderDocumentIcon).toHaveBeenNthCalledWith(1, documents[0], 18);
193
+ expect(renderDocumentIcon).toHaveBeenNthCalledWith(2, documents[1], 18);
194
+ expect(screen.getByTestId('icon-file-id').parentElement).toHaveClass('u-flex', 'u-ov-hidden');
195
+ });
196
+ it('calls onCancel from the back button', function () {
197
+ renderModal();
198
+ fireEvent.click(screen.getByRole('button', {
199
+ name: 'Back'
200
+ }));
201
+ expect(onCancel).toHaveBeenCalledTimes(1);
202
+ });
203
+ it('preserves the access settings after returning from the settings screen', function () {
204
+ renderModal();
205
+ fireEvent.click(screen.getByLabelText('Access level'));
206
+ fireEvent.click(screen.getByRole('button', {
207
+ name: 'Editor'
208
+ }));
209
+ fireEvent.click(screen.getByRole('button', {
210
+ name: 'Sharing settings'
211
+ }));
212
+ fireEvent.click(screen.getByLabelText('Set an expiration date'));
213
+ fireEvent.click(screen.getByLabelText('Require a password'));
214
+ fireEvent.change(screen.getByLabelText('Password'), {
215
+ target: {
216
+ value: 'secret'
217
+ }
218
+ });
219
+ fireEvent.click(screen.getByRole('button', {
220
+ name: 'Back'
221
+ }));
222
+ expect(screen.getByLabelText('Access level')).toHaveTextContent('Editor');
223
+ fireEvent.click(screen.getByRole('button', {
224
+ name: 'Sharing settings'
225
+ }));
226
+ expect(screen.getByLabelText('Set an expiration date')).toBeChecked();
227
+ expect(screen.getByLabelText('Require a password')).toBeChecked();
228
+ expect(screen.getByLabelText('Password')).toHaveValue('secret');
229
+ });
230
+ it('requires a four-character password before adding links', function () {
231
+ renderModal();
232
+ fireEvent.click(screen.getByRole('button', {
233
+ name: 'Sharing settings'
234
+ }));
235
+ fireEvent.click(screen.getByLabelText('Require a password'));
236
+ fireEvent.change(screen.getByLabelText('Password'), {
237
+ target: {
238
+ value: 'abc'
239
+ }
240
+ });
241
+ fireEvent.click(screen.getByRole('button', {
242
+ name: 'Back'
243
+ }));
244
+ expect(screen.getByRole('button', {
245
+ name: 'Add links'
246
+ })).toBeDisabled();
247
+ });
248
+ it('disables every main action while links are being saved', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
249
+ var resolveSharingLink;
250
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
251
+ while (1) switch (_context.prev = _context.next) {
252
+ case 0:
253
+ ensureSharingLink.mockReturnValue(new Promise(function (resolve) {
254
+ resolveSharingLink = resolve;
255
+ }));
256
+ renderModal();
257
+ fireEvent.click(screen.getByRole('button', {
258
+ name: 'Add links'
259
+ }));
260
+ _context.next = 5;
261
+ return waitFor(function () {
262
+ expect(screen.getByRole('button', {
263
+ name: 'Cancel'
264
+ })).toBeDisabled();
265
+ expect(screen.getByRole('button', {
266
+ name: 'Sharing settings'
267
+ })).toBeDisabled();
268
+ expect(screen.getByLabelText('Access level')).toBeDisabled();
269
+ });
270
+
271
+ case 5:
272
+ resolveSharingLink({
273
+ documentId: 'file-id',
274
+ url: 'https://first'
275
+ });
276
+ _context.next = 8;
277
+ return waitFor(function () {
278
+ return expect(onSuccess).toHaveBeenCalledTimes(1);
279
+ });
280
+
281
+ case 8:
282
+ case "end":
283
+ return _context.stop();
284
+ }
285
+ }, _callee);
286
+ })));
287
+ it('starts every link concurrently and returns ordered results', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
288
+ var resolveFirst, resolveSecond;
289
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
290
+ while (1) switch (_context2.prev = _context2.next) {
291
+ case 0:
292
+ ensureSharingLink.mockReturnValueOnce(new Promise(function (resolve) {
293
+ resolveFirst = resolve;
294
+ })).mockReturnValueOnce(new Promise(function (resolve) {
295
+ resolveSecond = resolve;
296
+ }));
297
+ renderModal();
298
+ fireEvent.click(screen.getByRole('button', {
299
+ name: 'Add links'
300
+ }));
301
+ expect(ensureSharingLink).toHaveBeenCalledTimes(2);
302
+ resolveSecond({
303
+ documentId: 'folder-id',
304
+ url: 'https://second'
305
+ });
306
+ resolveFirst({
307
+ documentId: 'file-id',
308
+ url: 'https://first'
309
+ });
310
+ _context2.next = 8;
311
+ return waitFor(function () {
312
+ return expect(onSuccess).toHaveBeenCalledWith([{
313
+ documentId: 'file-id',
314
+ url: 'https://first'
315
+ }, {
316
+ documentId: 'folder-id',
317
+ url: 'https://second'
318
+ }]);
319
+ });
320
+
321
+ case 8:
322
+ expect(ensureSharingLink).toHaveBeenNthCalledWith(1, documents[0], {
323
+ editingRights: 'readOnly',
324
+ dateEnabled: false,
325
+ selectedDate: null,
326
+ passwordEnabled: false,
327
+ password: ''
328
+ });
329
+
330
+ case 9:
331
+ case "end":
332
+ return _context2.stop();
333
+ }
334
+ }, _callee2);
335
+ })));
336
+ it('keeps the draft open after a failed save so the user can retry', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
337
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
338
+ while (1) switch (_context3.prev = _context3.next) {
339
+ case 0:
340
+ ensureSharingLink.mockRejectedValueOnce(new Error('offline')).mockResolvedValueOnce({
341
+ documentId: 'file-id',
342
+ url: 'https://first'
343
+ }).mockResolvedValueOnce({
344
+ documentId: 'folder-id',
345
+ url: 'https://second'
346
+ });
347
+ renderModal();
348
+ fireEvent.click(screen.getByRole('button', {
349
+ name: 'Add links'
350
+ }));
351
+ _context3.next = 5;
352
+ return waitFor(function () {
353
+ return expect(screen.getByRole('dialog')).toHaveTextContent('Could not save link permissions. Please try again.');
354
+ });
355
+
356
+ case 5:
357
+ expect(onSuccess).not.toHaveBeenCalled();
358
+ fireEvent.click(screen.getByRole('button', {
359
+ name: 'Add links'
360
+ }));
361
+ _context3.next = 9;
362
+ return waitFor(function () {
363
+ return expect(onSuccess).toHaveBeenCalledTimes(1);
364
+ });
365
+
366
+ case 9:
367
+ case "end":
368
+ return _context3.stop();
369
+ }
370
+ }, _callee3);
371
+ })));
372
+ });
@@ -0,0 +1 @@
1
+ export { default as ShareLinkAccessModal } from './ShareLinkAccessModal';
@@ -1,7 +1,7 @@
1
- import { Icon, Calendar } from '@linagora/twake-icons';
2
1
  import { format } from 'date-fns';
3
2
  import PropTypes from 'prop-types';
4
3
  import React from 'react';
4
+ import { Icon, Calendar } from '@linagora/twake-icons';
5
5
  import Box from 'cozy-ui/transpiled/react/Box';
6
6
  import DatePicker from 'cozy-ui/transpiled/react/DatePicker';
7
7
  import List from 'cozy-ui/transpiled/react/List';
@@ -1,7 +1,7 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import { Icon, Bottom, People } from '@linagora/twake-icons';
3
2
  import PropTypes from 'prop-types';
4
3
  import React, { useReducer, useRef } from 'react';
4
+ import { Icon, Bottom, People } from '@linagora/twake-icons';
5
5
  import { useClient } from 'cozy-client';
6
6
  import { isDirectory as isDir } from 'cozy-client/dist/models/file';
7
7
  import flag from 'cozy-flags';
@@ -2,9 +2,9 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _regeneratorRuntime from "@babel/runtime/regenerator";
5
- import { Icon, Copy, Password } from '@linagora/twake-icons';
6
5
  import PropTypes from 'prop-types';
7
6
  import React, { useState } from 'react';
7
+ import { Icon, Copy, Password } from '@linagora/twake-icons';
8
8
  import Box from 'cozy-ui/transpiled/react/Box';
9
9
  import IconButton from 'cozy-ui/transpiled/react/IconButton';
10
10
  import List from 'cozy-ui/transpiled/react/List';
@@ -1,10 +1,10 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
4
- import { Icon, Trash } from '@linagora/twake-icons';
5
4
  import { addDays } from 'date-fns';
6
5
  import PropTypes from 'prop-types';
7
6
  import React, { useState } from 'react';
7
+ import { Icon, Trash } from '@linagora/twake-icons';
8
8
  import { generateWebLink, useClient } from 'cozy-client';
9
9
  import flag from 'cozy-flags';
10
10
  import Button from 'cozy-ui/transpiled/react/Buttons';
@@ -277,6 +277,20 @@ export var makeTTL = function makeTTL(selectedDate) {
277
277
  return;
278
278
  }
279
279
  };
280
+ export var getLinkAccessOptions = function getLinkAccessOptions(_ref6) {
281
+ var editingRights = _ref6.editingRights,
282
+ dateEnabled = _ref6.dateEnabled,
283
+ selectedDate = _ref6.selectedDate,
284
+ passwordEnabled = _ref6.passwordEnabled,
285
+ password = _ref6.password;
286
+ var expirationDate = dateEnabled && selectedDate ? toExpirationDate(selectedDate) : null;
287
+ return {
288
+ verbs: editingRights === 'write' ? WRITE_PERMS : READ_ONLY_PERMS,
289
+ expiresAt: (expirationDate === null || expirationDate === void 0 ? void 0 : expirationDate.toISOString()) || '',
290
+ ttl: expirationDate ? makeTTL(expirationDate) : undefined,
291
+ password: passwordEnabled ? password : ''
292
+ };
293
+ };
280
294
  /**
281
295
  * createPermissions - Create the permissions of a file
282
296
  * @param {object} options
@@ -291,12 +305,12 @@ export var makeTTL = function makeTTL(selectedDate) {
291
305
  */
292
306
 
293
307
  export var createPermissions = /*#__PURE__*/function () {
294
- var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref6) {
308
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref7) {
295
309
  var file, t, ttl, password, editingRights, documentType, shareByLink, showAlert, verbs;
296
310
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
297
311
  while (1) switch (_context3.prev = _context3.next) {
298
312
  case 0:
299
- file = _ref6.file, t = _ref6.t, ttl = _ref6.ttl, password = _ref6.password, editingRights = _ref6.editingRights, documentType = _ref6.documentType, shareByLink = _ref6.shareByLink, showAlert = _ref6.showAlert;
313
+ file = _ref7.file, t = _ref7.t, ttl = _ref7.ttl, password = _ref7.password, editingRights = _ref7.editingRights, documentType = _ref7.documentType, shareByLink = _ref7.shareByLink, showAlert = _ref7.showAlert;
300
314
  _context3.prev = 1;
301
315
  verbs = editingRights === 'readOnly' ? READ_ONLY_PERMS : WRITE_PERMS;
302
316
  return _context3.abrupt("return", shareByLink(file, {
@@ -323,7 +337,7 @@ export var createPermissions = /*#__PURE__*/function () {
323
337
  }));
324
338
 
325
339
  return function createPermissions(_x3) {
326
- return _ref7.apply(this, arguments);
340
+ return _ref8.apply(this, arguments);
327
341
  };
328
342
  }();
329
343
  /**
@@ -342,25 +356,29 @@ export var createPermissions = /*#__PURE__*/function () {
342
356
  */
343
357
 
344
358
  export var updatePermissions = /*#__PURE__*/function () {
345
- var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref8) {
346
- var file, t, dateToggle, selectedDate, passwordToggle, password, editingRights, documentType, updateDocumentPermissions, showAlert, _toExpirationDate, expiresAt, ensurePassword, verbs;
359
+ var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref9) {
360
+ var file, t, dateToggle, selectedDate, passwordToggle, password, editingRights, documentType, updateDocumentPermissions, showAlert, _getLinkAccessOptions2, verbs, expiresAt, ensuredPassword;
347
361
 
348
362
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
349
363
  while (1) switch (_context4.prev = _context4.next) {
350
364
  case 0:
351
- file = _ref8.file, t = _ref8.t, dateToggle = _ref8.dateToggle, selectedDate = _ref8.selectedDate, passwordToggle = _ref8.passwordToggle, password = _ref8.password, editingRights = _ref8.editingRights, documentType = _ref8.documentType, updateDocumentPermissions = _ref8.updateDocumentPermissions, showAlert = _ref8.showAlert;
365
+ file = _ref9.file, t = _ref9.t, dateToggle = _ref9.dateToggle, selectedDate = _ref9.selectedDate, passwordToggle = _ref9.passwordToggle, password = _ref9.password, editingRights = _ref9.editingRights, documentType = _ref9.documentType, updateDocumentPermissions = _ref9.updateDocumentPermissions, showAlert = _ref9.showAlert;
352
366
  _context4.prev = 1;
353
- expiresAt = dateToggle ? ((_toExpirationDate = toExpirationDate(selectedDate)) === null || _toExpirationDate === void 0 ? void 0 : _toExpirationDate.toISOString()) || undefined : '';
354
- ensurePassword = passwordToggle ? password || undefined : '';
355
- verbs = editingRights === 'readOnly' ? READ_ONLY_PERMS : WRITE_PERMS;
367
+ _getLinkAccessOptions2 = getLinkAccessOptions({
368
+ editingRights: editingRights,
369
+ dateEnabled: dateToggle,
370
+ selectedDate: selectedDate,
371
+ passwordEnabled: passwordToggle,
372
+ password: password
373
+ }), verbs = _getLinkAccessOptions2.verbs, expiresAt = _getLinkAccessOptions2.expiresAt, ensuredPassword = _getLinkAccessOptions2.password;
356
374
  return _context4.abrupt("return", updateDocumentPermissions(file, {
357
375
  verbs: verbs,
358
376
  expiresAt: expiresAt,
359
- password: ensurePassword
377
+ password: ensuredPassword
360
378
  }));
361
379
 
362
- case 8:
363
- _context4.prev = 8;
380
+ case 6:
381
+ _context4.prev = 6;
364
382
  _context4.t0 = _context4["catch"](1);
365
383
  showAlert({
366
384
  message: t("".concat(documentType, ".share.shareByLink.permserror")),
@@ -369,15 +387,15 @@ export var updatePermissions = /*#__PURE__*/function () {
369
387
  });
370
388
  log.error("Error in 'updateDocumentPermissions' function when trying to change permission", _context4.t0);
371
389
 
372
- case 12:
390
+ case 10:
373
391
  case "end":
374
392
  return _context4.stop();
375
393
  }
376
- }, _callee4, null, [[1, 8]]);
394
+ }, _callee4, null, [[1, 6]]);
377
395
  }));
378
396
 
379
397
  return function updatePermissions(_x4) {
380
- return _ref9.apply(this, arguments);
398
+ return _ref10.apply(this, arguments);
381
399
  };
382
400
  }();
383
401
  /**
@@ -391,12 +409,12 @@ export var updatePermissions = /*#__PURE__*/function () {
391
409
  */
392
410
 
393
411
  export var revokePermissions = /*#__PURE__*/function () {
394
- var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref10) {
412
+ var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref11) {
395
413
  var file, t, documentType, revokeSharingLink, showAlert;
396
414
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
397
415
  while (1) switch (_context5.prev = _context5.next) {
398
416
  case 0:
399
- file = _ref10.file, t = _ref10.t, documentType = _ref10.documentType, revokeSharingLink = _ref10.revokeSharingLink, showAlert = _ref10.showAlert;
417
+ file = _ref11.file, t = _ref11.t, documentType = _ref11.documentType, revokeSharingLink = _ref11.revokeSharingLink, showAlert = _ref11.showAlert;
400
418
  _context5.prev = 1;
401
419
  return _context5.abrupt("return", revokeSharingLink(file));
402
420
 
@@ -418,6 +436,6 @@ export var revokePermissions = /*#__PURE__*/function () {
418
436
  }));
419
437
 
420
438
  return function revokePermissions(_x5) {
421
- return _ref11.apply(this, arguments);
439
+ return _ref12.apply(this, arguments);
422
440
  };
423
441
  }();
@@ -154,7 +154,7 @@ describe('ShareRestrictionModal/helpers', function () {
154
154
  }
155
155
  }, _callee3);
156
156
  })));
157
- it('should call updateDocumentPermissions with "undefined" date & password if their switches are true but the permission doesn\'t yet have these values', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
157
+ it('should call updateDocumentPermissions with empty date & password if enabled without values', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
158
158
  var updateDocumentPermissions, file;
159
159
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
160
160
  while (1) switch (_context4.prev = _context4.next) {
@@ -179,8 +179,8 @@ describe('ShareRestrictionModal/helpers', function () {
179
179
 
180
180
  case 4:
181
181
  expect(updateDocumentPermissions).toHaveBeenCalledWith(file, {
182
- expiresAt: undefined,
183
- password: undefined,
182
+ expiresAt: '',
183
+ password: '',
184
184
  verbs: ['GET']
185
185
  });
186
186
 
@@ -1,7 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import { Icon, Share } from '@linagora/twake-icons';
3
2
  import classNames from 'classnames';
4
3
  import React from 'react';
4
+ import { Icon, Share } from '@linagora/twake-icons';
5
5
  var styles = {
6
6
  "shared-badge": "badge__shared-badge___2jGsy",
7
7
  "--small": "badge__--small___2VMyY",
@@ -1,5 +1,5 @@
1
- import { Icon } from '@linagora/twake-icons';
2
1
  import React from 'react';
2
+ import { Icon } from '@linagora/twake-icons';
3
3
  import Typography from 'cozy-ui/transpiled/react/Typography';
4
4
 
5
5
  var SharedDriveIcon = function SharedDriveIcon(props) {
package/dist/index.js CHANGED
@@ -21,6 +21,7 @@ export { SharedDriveModal } from './components/SharedDrive/SharedDriveModal';
21
21
  export { SharedDriveForm } from './components/SharedDrive/SharedDriveForm';
22
22
  export { FederatedFolderModal } from './components/FederatedFolder/FederatedFolderModal';
23
23
  export { ShareModal } from './components/ShareModal/ShareModal';
24
+ export { ShareLinkAccessModal } from './components/ShareLinkAccessModal';
24
25
  export { RefreshableSharings } from './RefreshableSharings';
25
26
  export { CozyPassFingerprintDialogContent } from './components/CozyPassFingerprintDialogContent';
26
27
  export { SharingBannerPlugin } from './components/SharingBanner';
package/locales/en.json CHANGED
@@ -391,10 +391,8 @@
391
391
  "secondary_you": "including you"
392
392
  },
393
393
  "GroupRecipientDetail": {
394
- "subtitle": "Managed by %{ownerName}",
395
394
  "empty": {
396
- "content": "Your contact group is empty! Quickly add members to start sharing your valuable documents with them!",
397
- "action": "Open Contacts"
395
+ "content": "This group is empty. To add some members in this group, contact your administrator."
398
396
  },
399
397
  "withAccess": {
400
398
  "title": "Access to item"
@@ -462,5 +460,25 @@
462
460
  "successNotification": "Team drive has been modified",
463
461
  "errorNotification": "Error during team drive modification"
464
462
  }
463
+ },
464
+ "ShareLinkAccessModal": {
465
+ "title": "Set link access",
466
+ "introText": "Choose what recipients can do with these files.",
467
+ "anyoneWithLink": "Allow anyone with the link to access",
468
+ "settings": "Sharing settings",
469
+ "accessLevel": "Access level",
470
+ "viewer": "Viewer",
471
+ "editor": "Editor",
472
+ "settingsTitle": "Sharing settings",
473
+ "expiry": "Set an expiration date",
474
+ "expiryDate": "Expiration date",
475
+ "password": "Require a password",
476
+ "passwordLabel": "Password",
477
+ "passwordTooShort": "Password must contain at least %{count} characters.",
478
+ "cancel": "Cancel",
479
+ "addLinks": "Add links",
480
+ "error": {
481
+ "persistence": "Could not save link permissions. Please try again."
482
+ }
465
483
  }
466
484
  }
package/locales/fr.json CHANGED
@@ -389,10 +389,8 @@
389
389
  "secondary_you": "dont vous"
390
390
  },
391
391
  "GroupRecipientDetail": {
392
- "subtitle": "Géré par %{ownerName}",
393
392
  "empty": {
394
- "content": "Votre groupe de contacts est vide ! Ajoutez rapidement des membres pour commencer à leur partager vos précieux documents !",
395
- "action": "Ouvrir Contacts"
393
+ "content": "Ce groupe est vide. Pour ajouter des membres à ce groupe, contactez votre administrateur."
396
394
  },
397
395
  "withAccess": {
398
396
  "title": "Accès à l’élément"
@@ -460,5 +458,25 @@
460
458
  "successNotification": "Le drive d'équipe a été modifié",
461
459
  "errorNotification": "Erreur lors de la modification du drive d'équipe"
462
460
  }
461
+ },
462
+ "ShareLinkAccessModal": {
463
+ "title": "Définir l'accès par lien",
464
+ "introText": "Choisissez ce que les destinataires peuvent faire avec ces fichiers.",
465
+ "anyoneWithLink": "Autoriser toute personne disposant du lien à accéder",
466
+ "settings": "Paramètres de partage",
467
+ "accessLevel": "Niveau d'accès",
468
+ "viewer": "Lecteur",
469
+ "editor": "Éditeur",
470
+ "settingsTitle": "Paramètres de partage",
471
+ "expiry": "Définir une date d'expiration",
472
+ "expiryDate": "Date d'expiration",
473
+ "password": "Exiger un mot de passe",
474
+ "passwordLabel": "Mot de passe",
475
+ "passwordTooShort": "Le mot de passe doit contenir au moins %{count} caractères.",
476
+ "cancel": "Annuler",
477
+ "addLinks": "Ajouter les liens",
478
+ "error": {
479
+ "persistence": "Impossible d'enregistrer les autorisations du lien. Veuillez réessayer."
480
+ }
463
481
  }
464
- }
482
+ }