cozy-sharing 18.0.0 → 20.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +57 -0
- package/dist/SharingProvider.js +16 -9
- package/dist/components/Recipient/LinkRecipient.js +20 -4
- package/dist/components/Recipient/LinkRecipientPermissions.js +18 -129
- package/dist/components/Recipient/actions/editPermissionLink.js +71 -0
- package/dist/components/Recipient/actions/readOnlyPermissionLink.js +63 -0
- package/dist/components/ShareByLink.js +45 -185
- package/dist/components/ShareDialogCozyToCozy.js +2 -6
- package/dist/components/ShareDialogOnlyByLink.js +2 -8
- package/dist/components/ShareDialogTwoStepsConfirmationContainer.js +1 -3
- package/dist/components/ShareModal/EditableSharingModal.js +1 -7
- package/dist/components/ShareModal.js +0 -12
- package/dist/components/ShareRestrictionModal/BoxDate.js +77 -0
- package/dist/components/ShareRestrictionModal/BoxEditingRights.js +83 -0
- package/dist/components/ShareRestrictionModal/BoxPassword.js +155 -0
- package/dist/components/ShareRestrictionModal/ShareRestrictionContentModal.js +118 -0
- package/dist/components/ShareRestrictionModal/ShareRestrictionModal.js +256 -0
- package/dist/components/ShareRestrictionModal/helpers.js +310 -0
- package/dist/components/ShareRestrictionModal/helpers.spec.js +232 -0
- package/dist/components/WhoHasAccess.js +1 -5
- package/dist/helpers/permissions.js +15 -0
- package/locales/en.json +30 -0
- package/locales/fr.json +31 -0
- package/package.json +11 -7
- package/src/SharingProvider.jsx +10 -5
- package/src/components/Recipient/LinkRecipient.jsx +28 -4
- package/src/components/Recipient/LinkRecipientPermissions.jsx +28 -137
- package/src/components/Recipient/actions/editPermissionLink.js +63 -0
- package/src/components/Recipient/actions/readOnlyPermissionLink.js +59 -0
- package/src/components/ShareByLink.jsx +20 -96
- package/src/components/ShareDialogCozyToCozy.jsx +1 -5
- package/src/components/ShareDialogOnlyByLink.jsx +0 -6
- package/src/components/ShareDialogTwoStepsConfirmationContainer.jsx +0 -2
- package/src/components/ShareModal/EditableSharingModal.jsx +1 -7
- package/src/components/ShareModal.jsx +0 -12
- package/src/components/ShareRestrictionModal/BoxDate.jsx +76 -0
- package/src/components/ShareRestrictionModal/BoxEditingRights.jsx +91 -0
- package/src/components/ShareRestrictionModal/BoxPassword.jsx +126 -0
- package/src/components/ShareRestrictionModal/ShareRestrictionContentModal.jsx +124 -0
- package/src/components/ShareRestrictionModal/ShareRestrictionModal.jsx +186 -0
- package/src/components/ShareRestrictionModal/helpers.js +227 -0
- package/src/components/ShareRestrictionModal/helpers.spec.js +159 -0
- package/src/components/WhoHasAccess.jsx +1 -5
- package/src/helpers/permissions.js +12 -0
- package/dist/components/EditLinkPermissionDialog.js +0 -72
- package/dist/components/EditLinkPermissionDialog.spec.js +0 -48
- package/src/components/EditLinkPermissionDialog.jsx +0 -89
- package/src/components/EditLinkPermissionDialog.spec.jsx +0 -53
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
import { getSharingLink } from 'cozy-client/dist/models/sharing';
|
|
4
|
+
import minilog from 'cozy-minilog';
|
|
5
|
+
var log = minilog('ShareRestrictionModal/helpers');
|
|
6
|
+
export var WRITE_PERMS = ['GET', 'POST', 'PUT', 'PATCH'];
|
|
7
|
+
export var READ_ONLY_PERMS = ['GET'];
|
|
8
|
+
/**
|
|
9
|
+
* Copy a string to the clipboard
|
|
10
|
+
*
|
|
11
|
+
* @param {string} value - The string saved to the clipboard
|
|
12
|
+
* @param {object} [options]
|
|
13
|
+
* @param {number} options.t - Translation function
|
|
14
|
+
* @param {Function} options.showAlert - Function to display an alert
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export var copyToClipboard = /*#__PURE__*/function () {
|
|
18
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(value) {
|
|
19
|
+
var _ref2,
|
|
20
|
+
t,
|
|
21
|
+
showAlert,
|
|
22
|
+
_args = arguments;
|
|
23
|
+
|
|
24
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
25
|
+
while (1) switch (_context.prev = _context.next) {
|
|
26
|
+
case 0:
|
|
27
|
+
_ref2 = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}, t = _ref2.t, showAlert = _ref2.showAlert;
|
|
28
|
+
|
|
29
|
+
if (value) {
|
|
30
|
+
_context.next = 3;
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return _context.abrupt("return", false);
|
|
35
|
+
|
|
36
|
+
case 3:
|
|
37
|
+
_context.prev = 3;
|
|
38
|
+
_context.next = 6;
|
|
39
|
+
return navigator.clipboard.writeText(value);
|
|
40
|
+
|
|
41
|
+
case 6:
|
|
42
|
+
showAlert({
|
|
43
|
+
message: t('copyReminderContent.success'),
|
|
44
|
+
severity: 'success',
|
|
45
|
+
variant: 'filled'
|
|
46
|
+
});
|
|
47
|
+
_context.next = 13;
|
|
48
|
+
break;
|
|
49
|
+
|
|
50
|
+
case 9:
|
|
51
|
+
_context.prev = 9;
|
|
52
|
+
_context.t0 = _context["catch"](3);
|
|
53
|
+
showAlert({
|
|
54
|
+
message: t('copyReminderContent.error'),
|
|
55
|
+
severity: 'error',
|
|
56
|
+
variant: 'filled'
|
|
57
|
+
});
|
|
58
|
+
log.error("Error in 'copyToClipboard' function when trying to copy to clipboard", _context.t0);
|
|
59
|
+
|
|
60
|
+
case 13:
|
|
61
|
+
case "end":
|
|
62
|
+
return _context.stop();
|
|
63
|
+
}
|
|
64
|
+
}, _callee, null, [[3, 9]]);
|
|
65
|
+
}));
|
|
66
|
+
|
|
67
|
+
return function copyToClipboard(_x) {
|
|
68
|
+
return _ref.apply(this, arguments);
|
|
69
|
+
};
|
|
70
|
+
}();
|
|
71
|
+
/**
|
|
72
|
+
* Make a TTL string from a date
|
|
73
|
+
* @param {Date|string} selectedDate
|
|
74
|
+
* @returns {string} - TTL string in seconds (e.g. '1234s')
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
export var makeTTL = function makeTTL(selectedDate) {
|
|
78
|
+
if (!selectedDate) return;
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
var selectedDateConverted = selectedDate;
|
|
82
|
+
|
|
83
|
+
if (typeof selectedDate === 'string') {
|
|
84
|
+
var _selectedDateConverte;
|
|
85
|
+
|
|
86
|
+
selectedDateConverted = new Date(selectedDate);
|
|
87
|
+
|
|
88
|
+
if (((_selectedDateConverte = selectedDateConverted) === null || _selectedDateConverte === void 0 ? void 0 : _selectedDateConverte.toString()) === 'Invalid Date') {
|
|
89
|
+
throw new Error("Invalid date: ".concat(selectedDate));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (selectedDateConverted instanceof Date) {
|
|
94
|
+
var now = new Date();
|
|
95
|
+
var ttl = selectedDateConverted > now ? "".concat(Math.round((selectedDateConverted - now) / 1000), "s") : undefined;
|
|
96
|
+
return ttl;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
throw new Error("Invalid date: ".concat(selectedDate));
|
|
100
|
+
} catch (error) {
|
|
101
|
+
log.error(error);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* forwardFile - Triggers the download of one or multiple files by the browser
|
|
107
|
+
* @param {object} options
|
|
108
|
+
* @param {import('cozy-client/types/CozyClient').default} options.client
|
|
109
|
+
* @param {import('cozy-client/types/types').IOCozyFile} options.file File to download
|
|
110
|
+
* @param {Function} options.t i18n function
|
|
111
|
+
* @param {string} options.ttl Time to live of the sharing link
|
|
112
|
+
* @param {string} options.password Password of the sharing link
|
|
113
|
+
* @param {Function} options.showAlert - Function to display an alert
|
|
114
|
+
*/
|
|
115
|
+
|
|
116
|
+
export var forwardFile = /*#__PURE__*/function () {
|
|
117
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3) {
|
|
118
|
+
var client, file, t, ttl, password, showAlert, url, isZipFile, shareData;
|
|
119
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
120
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
121
|
+
case 0:
|
|
122
|
+
client = _ref3.client, file = _ref3.file, t = _ref3.t, ttl = _ref3.ttl, password = _ref3.password, showAlert = _ref3.showAlert;
|
|
123
|
+
_context2.prev = 1;
|
|
124
|
+
_context2.next = 4;
|
|
125
|
+
return getSharingLink(client, [file._id], {
|
|
126
|
+
ttl: ttl,
|
|
127
|
+
password: password
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
case 4:
|
|
131
|
+
url = _context2.sent;
|
|
132
|
+
isZipFile = file.class === 'zip';
|
|
133
|
+
shareData = {
|
|
134
|
+
title: t('shareFile.title', {
|
|
135
|
+
name: file.name,
|
|
136
|
+
smart_count: isZipFile ? 2 : 1
|
|
137
|
+
}),
|
|
138
|
+
text: t('shareFile.text', {
|
|
139
|
+
name: file.name,
|
|
140
|
+
smart_count: isZipFile ? 2 : 1
|
|
141
|
+
}),
|
|
142
|
+
url: url
|
|
143
|
+
};
|
|
144
|
+
navigator.share(shareData);
|
|
145
|
+
_context2.next = 13;
|
|
146
|
+
break;
|
|
147
|
+
|
|
148
|
+
case 10:
|
|
149
|
+
_context2.prev = 10;
|
|
150
|
+
_context2.t0 = _context2["catch"](1);
|
|
151
|
+
showAlert({
|
|
152
|
+
message: t('shareFile.error'),
|
|
153
|
+
severity: 'error',
|
|
154
|
+
variant: 'filled'
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
case 13:
|
|
158
|
+
case "end":
|
|
159
|
+
return _context2.stop();
|
|
160
|
+
}
|
|
161
|
+
}, _callee2, null, [[1, 10]]);
|
|
162
|
+
}));
|
|
163
|
+
|
|
164
|
+
return function forwardFile(_x2) {
|
|
165
|
+
return _ref4.apply(this, arguments);
|
|
166
|
+
};
|
|
167
|
+
}();
|
|
168
|
+
/**
|
|
169
|
+
* createPermissions - Create the permissions of a file
|
|
170
|
+
* @param {object} options
|
|
171
|
+
* @param {import('cozy-client/types/types').IOCozyFile} options.file File to update permissions
|
|
172
|
+
* @param {Function} options.t i18n function
|
|
173
|
+
* @param {Date|string} options.ttl - Time to live of the sharing link
|
|
174
|
+
* @param {string} options.password - Password
|
|
175
|
+
* @param {'readOnly'|'write'} options.editingRights - Editing rights
|
|
176
|
+
* @param {string} options.documentType - Type of the document
|
|
177
|
+
* @param {Function} options.shareByLink - Function to create permissions
|
|
178
|
+
* @param {Function} options.showAlert - Function to display an alert
|
|
179
|
+
*/
|
|
180
|
+
|
|
181
|
+
export var createPermissions = /*#__PURE__*/function () {
|
|
182
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref5) {
|
|
183
|
+
var file, t, ttl, password, editingRights, documentType, shareByLink, showAlert, verbs;
|
|
184
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
185
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
186
|
+
case 0:
|
|
187
|
+
file = _ref5.file, t = _ref5.t, ttl = _ref5.ttl, password = _ref5.password, editingRights = _ref5.editingRights, documentType = _ref5.documentType, shareByLink = _ref5.shareByLink, showAlert = _ref5.showAlert;
|
|
188
|
+
_context3.prev = 1;
|
|
189
|
+
verbs = editingRights === 'readOnly' ? READ_ONLY_PERMS : WRITE_PERMS;
|
|
190
|
+
return _context3.abrupt("return", shareByLink(file, {
|
|
191
|
+
verbs: verbs,
|
|
192
|
+
ttl: ttl,
|
|
193
|
+
password: password
|
|
194
|
+
}));
|
|
195
|
+
|
|
196
|
+
case 6:
|
|
197
|
+
_context3.prev = 6;
|
|
198
|
+
_context3.t0 = _context3["catch"](1);
|
|
199
|
+
showAlert({
|
|
200
|
+
message: t("".concat(documentType, ".share.shareByLink.permserror")),
|
|
201
|
+
severity: 'error',
|
|
202
|
+
variant: 'filled'
|
|
203
|
+
});
|
|
204
|
+
log.error("Error in 'readOnlyPermissionLink' function when trying to change permission", _context3.t0);
|
|
205
|
+
|
|
206
|
+
case 10:
|
|
207
|
+
case "end":
|
|
208
|
+
return _context3.stop();
|
|
209
|
+
}
|
|
210
|
+
}, _callee3, null, [[1, 6]]);
|
|
211
|
+
}));
|
|
212
|
+
|
|
213
|
+
return function createPermissions(_x3) {
|
|
214
|
+
return _ref6.apply(this, arguments);
|
|
215
|
+
};
|
|
216
|
+
}();
|
|
217
|
+
/**
|
|
218
|
+
* updatePermissions - Updates the permissions of a file
|
|
219
|
+
* @param {object} options
|
|
220
|
+
* @param {import('cozy-client/types/types').IOCozyFile} options.file File to update permissions
|
|
221
|
+
* @param {Function} options.t i18n function
|
|
222
|
+
* @param {boolean} options.dateToggle - Expiration date toggle
|
|
223
|
+
* @param {Date|null} options.selectedDate - Expiration date
|
|
224
|
+
* @param {boolean} options.passwordToggle - Password toggle
|
|
225
|
+
* @param {string} options.password - Password
|
|
226
|
+
* @param {string} options.documentType - Type of the document
|
|
227
|
+
* @param {'readOnly'|'write'} options.editingRights - Editing rights
|
|
228
|
+
* @param {Function} options.updateDocumentPermissions - Function to update permissions
|
|
229
|
+
* @param {Function} options.showAlert - Function to display an alert
|
|
230
|
+
*/
|
|
231
|
+
|
|
232
|
+
export var updatePermissions = /*#__PURE__*/function () {
|
|
233
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref7) {
|
|
234
|
+
var file, t, dateToggle, selectedDate, passwordToggle, password, editingRights, documentType, updateDocumentPermissions, showAlert, expiresAt, ensurePassword, verbs;
|
|
235
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
236
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
237
|
+
case 0:
|
|
238
|
+
file = _ref7.file, t = _ref7.t, dateToggle = _ref7.dateToggle, selectedDate = _ref7.selectedDate, passwordToggle = _ref7.passwordToggle, password = _ref7.password, editingRights = _ref7.editingRights, documentType = _ref7.documentType, updateDocumentPermissions = _ref7.updateDocumentPermissions, showAlert = _ref7.showAlert;
|
|
239
|
+
_context4.prev = 1;
|
|
240
|
+
expiresAt = dateToggle ? (selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate.toISOString()) || undefined : '';
|
|
241
|
+
ensurePassword = passwordToggle ? password || undefined : '';
|
|
242
|
+
verbs = editingRights === 'readOnly' ? READ_ONLY_PERMS : WRITE_PERMS;
|
|
243
|
+
return _context4.abrupt("return", updateDocumentPermissions(file, {
|
|
244
|
+
verbs: verbs,
|
|
245
|
+
expiresAt: expiresAt,
|
|
246
|
+
password: ensurePassword
|
|
247
|
+
}));
|
|
248
|
+
|
|
249
|
+
case 8:
|
|
250
|
+
_context4.prev = 8;
|
|
251
|
+
_context4.t0 = _context4["catch"](1);
|
|
252
|
+
showAlert({
|
|
253
|
+
message: t("".concat(documentType, ".share.shareByLink.permserror")),
|
|
254
|
+
severity: 'error',
|
|
255
|
+
variant: 'filled'
|
|
256
|
+
});
|
|
257
|
+
log.error("Error in 'updateDocumentPermissions' function when trying to change permission", _context4.t0);
|
|
258
|
+
|
|
259
|
+
case 12:
|
|
260
|
+
case "end":
|
|
261
|
+
return _context4.stop();
|
|
262
|
+
}
|
|
263
|
+
}, _callee4, null, [[1, 8]]);
|
|
264
|
+
}));
|
|
265
|
+
|
|
266
|
+
return function updatePermissions(_x4) {
|
|
267
|
+
return _ref8.apply(this, arguments);
|
|
268
|
+
};
|
|
269
|
+
}();
|
|
270
|
+
/**
|
|
271
|
+
* revokePermissions - Revokes the permissions of a file
|
|
272
|
+
* @param {object} options
|
|
273
|
+
* @param {import('cozy-client/types/types').IOCozyFile} options.file File to revoke permissions
|
|
274
|
+
* @param {Function} options.t i18n function
|
|
275
|
+
* @param {string} options.documentType - Type of the document
|
|
276
|
+
* @param {Function} options.revokeSharingLink - Function to revoke permissions
|
|
277
|
+
* @param {Function} options.showAlert - Function to display an alert
|
|
278
|
+
*/
|
|
279
|
+
|
|
280
|
+
export var revokePermissions = /*#__PURE__*/function () {
|
|
281
|
+
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref9) {
|
|
282
|
+
var file, t, documentType, revokeSharingLink, showAlert;
|
|
283
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
284
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
285
|
+
case 0:
|
|
286
|
+
file = _ref9.file, t = _ref9.t, documentType = _ref9.documentType, revokeSharingLink = _ref9.revokeSharingLink, showAlert = _ref9.showAlert;
|
|
287
|
+
_context5.prev = 1;
|
|
288
|
+
return _context5.abrupt("return", revokeSharingLink(file));
|
|
289
|
+
|
|
290
|
+
case 5:
|
|
291
|
+
_context5.prev = 5;
|
|
292
|
+
_context5.t0 = _context5["catch"](1);
|
|
293
|
+
showAlert({
|
|
294
|
+
message: t("".concat(documentType, ".share.error.revoke")),
|
|
295
|
+
severity: 'error',
|
|
296
|
+
variant: 'filled'
|
|
297
|
+
});
|
|
298
|
+
log.error("Error in 'revokePermissions' function when trying to revoke sharing link", _context5.t0);
|
|
299
|
+
|
|
300
|
+
case 9:
|
|
301
|
+
case "end":
|
|
302
|
+
return _context5.stop();
|
|
303
|
+
}
|
|
304
|
+
}, _callee5, null, [[1, 5]]);
|
|
305
|
+
}));
|
|
306
|
+
|
|
307
|
+
return function revokePermissions(_x5) {
|
|
308
|
+
return _ref10.apply(this, arguments);
|
|
309
|
+
};
|
|
310
|
+
}();
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
import { makeTTL, revokePermissions, updatePermissions } from './helpers';
|
|
4
|
+
describe('ShareRestrictionModal/helpers', function () {
|
|
5
|
+
describe('makeTTL', function () {
|
|
6
|
+
it('sould return undefined', function () {
|
|
7
|
+
expect(makeTTL()).toBeUndefined();
|
|
8
|
+
expect(makeTTL(123)).toBeUndefined();
|
|
9
|
+
expect(makeTTL('abc')).toBeUndefined();
|
|
10
|
+
expect(makeTTL(new Date('2023-01-01T00:00:00.000Z'))).toBeUndefined();
|
|
11
|
+
expect(makeTTL(new Date('abc'))).toBeUndefined();
|
|
12
|
+
expect(makeTTL('2023-01-01T00:00:00.000Z')).toBeUndefined();
|
|
13
|
+
});
|
|
14
|
+
it('sould return TTL in seconds', function () {
|
|
15
|
+
expect(makeTTL(new Date('2100-01-01T00:00:00.000Z'))).toBeDefined();
|
|
16
|
+
expect(makeTTL('2100-01-01T00:00:00.000Z')).toBeDefined();
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
describe('updatePermissions', function () {
|
|
20
|
+
var documentType = 'Files';
|
|
21
|
+
it('should call updateDocumentPermissions with "readOnly" permission', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
22
|
+
var updateDocumentPermissions, file;
|
|
23
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
24
|
+
while (1) switch (_context.prev = _context.next) {
|
|
25
|
+
case 0:
|
|
26
|
+
updateDocumentPermissions = jest.fn();
|
|
27
|
+
file = {
|
|
28
|
+
_id: '123'
|
|
29
|
+
};
|
|
30
|
+
_context.next = 4;
|
|
31
|
+
return updatePermissions({
|
|
32
|
+
file: file,
|
|
33
|
+
t: jest.fn(),
|
|
34
|
+
dateToggle: false,
|
|
35
|
+
selectedDate: null,
|
|
36
|
+
passwordToggle: false,
|
|
37
|
+
password: '',
|
|
38
|
+
editingRights: 'readOnly',
|
|
39
|
+
documentType: documentType,
|
|
40
|
+
updateDocumentPermissions: updateDocumentPermissions,
|
|
41
|
+
showAlert: jest.fn()
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
case 4:
|
|
45
|
+
expect(updateDocumentPermissions).toHaveBeenCalledWith(file, {
|
|
46
|
+
expiresAt: '',
|
|
47
|
+
password: '',
|
|
48
|
+
verbs: ['GET']
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
case 5:
|
|
52
|
+
case "end":
|
|
53
|
+
return _context.stop();
|
|
54
|
+
}
|
|
55
|
+
}, _callee);
|
|
56
|
+
})));
|
|
57
|
+
it('should call updateDocumentPermissions with "write" permissions', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
58
|
+
var updateDocumentPermissions, file;
|
|
59
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
60
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
61
|
+
case 0:
|
|
62
|
+
updateDocumentPermissions = jest.fn();
|
|
63
|
+
file = {
|
|
64
|
+
_id: '123'
|
|
65
|
+
};
|
|
66
|
+
_context2.next = 4;
|
|
67
|
+
return updatePermissions({
|
|
68
|
+
file: file,
|
|
69
|
+
t: jest.fn(),
|
|
70
|
+
dateToggle: false,
|
|
71
|
+
selectedDate: null,
|
|
72
|
+
passwordToggle: false,
|
|
73
|
+
password: '',
|
|
74
|
+
editingRights: 'write',
|
|
75
|
+
documentType: documentType,
|
|
76
|
+
updateDocumentPermissions: updateDocumentPermissions,
|
|
77
|
+
showAlert: jest.fn()
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
case 4:
|
|
81
|
+
expect(updateDocumentPermissions).toHaveBeenCalledWith(file, {
|
|
82
|
+
expiresAt: '',
|
|
83
|
+
password: '',
|
|
84
|
+
verbs: ['GET', 'POST', 'PUT', 'PATCH']
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
case 5:
|
|
88
|
+
case "end":
|
|
89
|
+
return _context2.stop();
|
|
90
|
+
}
|
|
91
|
+
}, _callee2);
|
|
92
|
+
})));
|
|
93
|
+
it('should call updateDocumentPermissions with empty date & password if their switches are false', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
94
|
+
var updateDocumentPermissions, file;
|
|
95
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
96
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
97
|
+
case 0:
|
|
98
|
+
updateDocumentPermissions = jest.fn();
|
|
99
|
+
file = {
|
|
100
|
+
_id: '123'
|
|
101
|
+
};
|
|
102
|
+
_context3.next = 4;
|
|
103
|
+
return updatePermissions({
|
|
104
|
+
file: file,
|
|
105
|
+
t: jest.fn(),
|
|
106
|
+
dateToggle: false,
|
|
107
|
+
selectedDate: null,
|
|
108
|
+
passwordToggle: false,
|
|
109
|
+
password: '',
|
|
110
|
+
editingRights: 'readOnly',
|
|
111
|
+
documentType: documentType,
|
|
112
|
+
updateDocumentPermissions: updateDocumentPermissions,
|
|
113
|
+
showAlert: jest.fn()
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
case 4:
|
|
117
|
+
expect(updateDocumentPermissions).toHaveBeenCalledWith(file, {
|
|
118
|
+
expiresAt: '',
|
|
119
|
+
password: '',
|
|
120
|
+
verbs: ['GET']
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
case 5:
|
|
124
|
+
case "end":
|
|
125
|
+
return _context3.stop();
|
|
126
|
+
}
|
|
127
|
+
}, _callee3);
|
|
128
|
+
})));
|
|
129
|
+
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() {
|
|
130
|
+
var updateDocumentPermissions, file;
|
|
131
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
132
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
133
|
+
case 0:
|
|
134
|
+
updateDocumentPermissions = jest.fn();
|
|
135
|
+
file = {
|
|
136
|
+
_id: '123'
|
|
137
|
+
};
|
|
138
|
+
_context4.next = 4;
|
|
139
|
+
return updatePermissions({
|
|
140
|
+
file: file,
|
|
141
|
+
t: jest.fn(),
|
|
142
|
+
dateToggle: true,
|
|
143
|
+
selectedDate: null,
|
|
144
|
+
passwordToggle: true,
|
|
145
|
+
password: '',
|
|
146
|
+
editingRights: 'readOnly',
|
|
147
|
+
documentType: documentType,
|
|
148
|
+
updateDocumentPermissions: updateDocumentPermissions,
|
|
149
|
+
showAlert: jest.fn()
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
case 4:
|
|
153
|
+
expect(updateDocumentPermissions).toHaveBeenCalledWith(file, {
|
|
154
|
+
expiresAt: undefined,
|
|
155
|
+
password: undefined,
|
|
156
|
+
verbs: ['GET']
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
case 5:
|
|
160
|
+
case "end":
|
|
161
|
+
return _context4.stop();
|
|
162
|
+
}
|
|
163
|
+
}, _callee4);
|
|
164
|
+
})));
|
|
165
|
+
it('should call updateDocumentPermissions with expected date & password if their switches are true', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
166
|
+
var updateDocumentPermissions, file;
|
|
167
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
168
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
169
|
+
case 0:
|
|
170
|
+
updateDocumentPermissions = jest.fn();
|
|
171
|
+
file = {
|
|
172
|
+
_id: '123'
|
|
173
|
+
};
|
|
174
|
+
_context5.next = 4;
|
|
175
|
+
return updatePermissions({
|
|
176
|
+
file: file,
|
|
177
|
+
t: jest.fn(),
|
|
178
|
+
dateToggle: true,
|
|
179
|
+
selectedDate: new Date('2100-01-01T00:00:00.000Z'),
|
|
180
|
+
passwordToggle: true,
|
|
181
|
+
password: '1234',
|
|
182
|
+
editingRights: 'readOnly',
|
|
183
|
+
documentType: documentType,
|
|
184
|
+
updateDocumentPermissions: updateDocumentPermissions,
|
|
185
|
+
showAlert: jest.fn()
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
case 4:
|
|
189
|
+
expect(updateDocumentPermissions).toHaveBeenCalledWith(file, {
|
|
190
|
+
expiresAt: '2100-01-01T00:00:00.000Z',
|
|
191
|
+
password: '1234',
|
|
192
|
+
verbs: ['GET']
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
case 5:
|
|
196
|
+
case "end":
|
|
197
|
+
return _context5.stop();
|
|
198
|
+
}
|
|
199
|
+
}, _callee5);
|
|
200
|
+
})));
|
|
201
|
+
});
|
|
202
|
+
describe('revokePermissions', function () {
|
|
203
|
+
var documentType = 'Files';
|
|
204
|
+
it('should call revokeSharingLink', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
205
|
+
var revokeSharingLink, file;
|
|
206
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
207
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
208
|
+
case 0:
|
|
209
|
+
revokeSharingLink = jest.fn();
|
|
210
|
+
file = {
|
|
211
|
+
_id: '123'
|
|
212
|
+
};
|
|
213
|
+
_context6.next = 4;
|
|
214
|
+
return revokePermissions({
|
|
215
|
+
file: file,
|
|
216
|
+
t: jest.fn(),
|
|
217
|
+
documentType: documentType,
|
|
218
|
+
revokeSharingLink: revokeSharingLink,
|
|
219
|
+
showAlert: jest.fn()
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
case 4:
|
|
223
|
+
expect(revokeSharingLink).toHaveBeenCalledWith(file);
|
|
224
|
+
|
|
225
|
+
case 5:
|
|
226
|
+
case "end":
|
|
227
|
+
return _context6.stop();
|
|
228
|
+
}
|
|
229
|
+
}, _callee6);
|
|
230
|
+
})));
|
|
231
|
+
});
|
|
232
|
+
});
|
|
@@ -40,9 +40,7 @@ var WhoHasAccess = function WhoHasAccess(_ref2) {
|
|
|
40
40
|
onRevokeSelf = _ref2.onRevokeSelf,
|
|
41
41
|
verifyRecipient = _ref2.verifyRecipient,
|
|
42
42
|
link = _ref2.link,
|
|
43
|
-
permissions = _ref2.permissions
|
|
44
|
-
onUpdateShareLinkPermissions = _ref2.onUpdateShareLinkPermissions,
|
|
45
|
-
onRevokeLink = _ref2.onRevokeLink;
|
|
43
|
+
permissions = _ref2.permissions;
|
|
46
44
|
var previousLink = usePrevious(link);
|
|
47
45
|
var linkHasBeenJustCreated = link && previousLink === null;
|
|
48
46
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -56,8 +54,6 @@ var WhoHasAccess = function WhoHasAccess(_ref2) {
|
|
|
56
54
|
onRevokeSelf: onRevokeSelf,
|
|
57
55
|
link: link,
|
|
58
56
|
permissions: permissions,
|
|
59
|
-
onChangePermissions: onUpdateShareLinkPermissions,
|
|
60
|
-
onDisable: onRevokeLink,
|
|
61
57
|
fadeIn: linkHasBeenJustCreated
|
|
62
58
|
}), /*#__PURE__*/React.createElement(OwnerRecipient, {
|
|
63
59
|
recipients: recipients
|
|
@@ -5,4 +5,19 @@ export var checkIsReadOnlyPermissions = function checkIsReadOnlyPermissions(perm
|
|
|
5
5
|
return Object.values(permissionCategories).filter(function (permissionCategory) {
|
|
6
6
|
return models.permission.isReadOnly(permissionCategory);
|
|
7
7
|
}).length > 0;
|
|
8
|
+
};
|
|
9
|
+
export var checkIsPermissionHasExpiresDate = function checkIsPermissionHasExpiresDate(permissions) {
|
|
10
|
+
var _permissions$;
|
|
11
|
+
|
|
12
|
+
return Boolean(permissions === null || permissions === void 0 || (_permissions$ = permissions[0]) === null || _permissions$ === void 0 || (_permissions$ = _permissions$.attributes) === null || _permissions$ === void 0 ? void 0 : _permissions$.expires_at);
|
|
13
|
+
};
|
|
14
|
+
export var getPermissionExpiresDate = function getPermissionExpiresDate(permissions) {
|
|
15
|
+
var _permissions$2;
|
|
16
|
+
|
|
17
|
+
return permissions === null || permissions === void 0 || (_permissions$2 = permissions[0]) === null || _permissions$2 === void 0 || (_permissions$2 = _permissions$2.attributes) === null || _permissions$2 === void 0 ? void 0 : _permissions$2.expires_at;
|
|
18
|
+
};
|
|
19
|
+
export var checkIsPermissionHasPassword = function checkIsPermissionHasPassword(permissions) {
|
|
20
|
+
var _permissions$3;
|
|
21
|
+
|
|
22
|
+
return Boolean(permissions === null || permissions === void 0 || (_permissions$3 = permissions[0]) === null || _permissions$3 === void 0 || (_permissions$3 = _permissions$3.attributes) === null || _permissions$3 === void 0 ? void 0 : _permissions$3.password);
|
|
8
23
|
};
|
package/locales/en.json
CHANGED
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
"recipients": {
|
|
27
27
|
"you": "You",
|
|
28
28
|
"anyoneWithTheLink": "Anyone with the link",
|
|
29
|
+
"linkWithPassword": "Anyone with a password",
|
|
30
|
+
"expires": "Until %{date}",
|
|
29
31
|
"accessCount": "%{count} people have access"
|
|
30
32
|
},
|
|
31
33
|
"create-cozy": "Create |||| Create my cozy",
|
|
@@ -416,5 +418,33 @@
|
|
|
416
418
|
},
|
|
417
419
|
"addEmail": "Enter an email address to invite the contact"
|
|
418
420
|
}
|
|
421
|
+
},
|
|
422
|
+
"ShareRestrictionModal": {
|
|
423
|
+
"action": {
|
|
424
|
+
"confirm": "Confirm"
|
|
425
|
+
},
|
|
426
|
+
"invalidPasswordMessage": "%{smart_count} character is missing |||| %{smart_count} characters are missings"
|
|
427
|
+
},
|
|
428
|
+
"BoxDate": {
|
|
429
|
+
"label": "Deadline",
|
|
430
|
+
"text": "Remove access after a deadline"
|
|
431
|
+
},
|
|
432
|
+
"BoxPassword": {
|
|
433
|
+
"label": "Password",
|
|
434
|
+
"text": "Limit access with a password"
|
|
435
|
+
},
|
|
436
|
+
"BoxEditingRights": {
|
|
437
|
+
"editSubText": "People with access to the link can modify the content",
|
|
438
|
+
"readOnlySubText": "People who have access to the link can only view the content",
|
|
439
|
+
"text": "Editing rights"
|
|
440
|
+
},
|
|
441
|
+
"copyReminderContent": {
|
|
442
|
+
"success": "Copied to clipboard",
|
|
443
|
+
"error": "Cannot copy to clipboard"
|
|
444
|
+
},
|
|
445
|
+
"shareFile": {
|
|
446
|
+
"error": "Problem with link recovery: %{error}",
|
|
447
|
+
"text": "Link to my document %{name}: |||| Link to my documents %{name}: ",
|
|
448
|
+
"title": "Link to my document %{name} |||| Link to my documents %{name}"
|
|
419
449
|
}
|
|
420
450
|
}
|
package/locales/fr.json
CHANGED
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
"recipients": {
|
|
27
27
|
"you": "Vous",
|
|
28
28
|
"anyoneWithTheLink": "N'importe qui avec le lien",
|
|
29
|
+
"linkWithPassword": "N'importe qui avec un mot de passe",
|
|
30
|
+
"expires": "Jusqu'au %{date}",
|
|
29
31
|
"accessCount": "%{count} personnes y ont accès"
|
|
30
32
|
},
|
|
31
33
|
"create-cozy": "Créer |||| Créer mon Cozy",
|
|
@@ -414,5 +416,34 @@
|
|
|
414
416
|
},
|
|
415
417
|
"addEmail": "Renseigner un email pour pouvoir inviter le contact"
|
|
416
418
|
}
|
|
419
|
+
},
|
|
420
|
+
"ShareRestrictionModal": {
|
|
421
|
+
"title": "Lien de partage",
|
|
422
|
+
"action": {
|
|
423
|
+
"confirm": "Valider"
|
|
424
|
+
},
|
|
425
|
+
"invalidPasswordMessage": "Il manque %{smart_count} caractère |||| Il manque %{smart_count} caractères"
|
|
426
|
+
},
|
|
427
|
+
"BoxDate": {
|
|
428
|
+
"label": "Date limite",
|
|
429
|
+
"text": "Restreindre l'accès après une date limite"
|
|
430
|
+
},
|
|
431
|
+
"BoxPassword": {
|
|
432
|
+
"label": "Mot de passe",
|
|
433
|
+
"text": "Limiter l'accès par un mot de passe"
|
|
434
|
+
},
|
|
435
|
+
"BoxEditingRights": {
|
|
436
|
+
"editSubText": "Les personnes ayant accès au lien peuvent modifier le contenu",
|
|
437
|
+
"readOnlySubText": "Les personnes ayant accès au lien peuvent uniquement consulter le contenu",
|
|
438
|
+
"text": "Droit d’édition"
|
|
439
|
+
},
|
|
440
|
+
"copyReminderContent": {
|
|
441
|
+
"success": "Copié dans le presse-papier",
|
|
442
|
+
"error": "Impossible de copier dans le presse-papier"
|
|
443
|
+
},
|
|
444
|
+
"shareFile": {
|
|
445
|
+
"error": "Problème avec la récupération du lien : %{error}",
|
|
446
|
+
"text": "Voici un lien vers mon document %{name} : |||| Voici un lien contenant mes documents %{name} : ",
|
|
447
|
+
"title": "Lien vers mon document %{name} |||| Lien vers mes documents %{name}"
|
|
417
448
|
}
|
|
418
449
|
}
|