cozy-sharing 19.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 +26 -0
- package/dist/SharingProvider.js +16 -9
- package/dist/components/Recipient/LinkRecipient.js +20 -4
- package/dist/components/ShareRestrictionModal/BoxPassword.js +21 -4
- package/dist/components/ShareRestrictionModal/ShareRestrictionContentModal.js +33 -9
- package/dist/components/ShareRestrictionModal/ShareRestrictionModal.js +74 -78
- package/dist/components/ShareRestrictionModal/helpers.js +82 -47
- package/dist/components/ShareRestrictionModal/helpers.spec.js +142 -20
- package/dist/helpers/permissions.js +15 -0
- package/locales/en.json +2 -0
- package/locales/fr.json +2 -0
- package/package.json +4 -4
- package/src/SharingProvider.jsx +10 -5
- package/src/components/Recipient/LinkRecipient.jsx +28 -4
- package/src/components/ShareRestrictionModal/BoxPassword.jsx +14 -0
- package/src/components/ShareRestrictionModal/ShareRestrictionContentModal.jsx +31 -9
- package/src/components/ShareRestrictionModal/ShareRestrictionModal.jsx +55 -46
- package/src/components/ShareRestrictionModal/helpers.js +65 -31
- package/src/components/ShareRestrictionModal/helpers.spec.js +92 -11
- package/src/helpers/permissions.js +12 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,32 @@
|
|
|
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
|
+
# [20.0.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@19.0.0...cozy-sharing@20.0.0) (2025-01-22)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **sharing:** Dispatch correct value ([4f2d17c](https://github.com/cozy/cozy-libs/commit/4f2d17cec7ce51fae97c825e3bb605c204dff330))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* **sharing:** Auto focus password input ([614da3c](https://github.com/cozy/cozy-libs/commit/614da3cceae6f207ced87ae0bc81886224c83a24))
|
|
17
|
+
* **sharing:** Change ShareRestrictionModal validity ([00fb730](https://github.com/cozy/cozy-libs/commit/00fb730160e7f80ea57f6ebf7f47afadff9c0945))
|
|
18
|
+
* **sharing:** Improve BoxPassword ([7e39d7f](https://github.com/cozy/cozy-libs/commit/7e39d7fe16c021c9902a905f7dbdba92b2787eaf))
|
|
19
|
+
* **sharing:** Improve ShareDialogOnlyByLink UX ([4287e74](https://github.com/cozy/cozy-libs/commit/4287e74dc32aa7541e861939c4405a20426640e6))
|
|
20
|
+
* **sharing:** Rework logic of ShareRestrictionModal ([e33df9f](https://github.com/cozy/cozy-libs/commit/e33df9f5bb737dab6db738b435d2d0492698c8e9))
|
|
21
|
+
* **sharing:** Upgrade cozy-client to 53.0.0 ([fd6294f](https://github.com/cozy/cozy-libs/commit/fd6294f0870499a928795a73f099f3885e090a0a))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### BREAKING CHANGES
|
|
25
|
+
|
|
26
|
+
* **sharing:** You must have `cozy-client >= 53.0.0`
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
6
32
|
# [19.0.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@18.0.0...cozy-sharing@19.0.0) (2025-01-08)
|
|
7
33
|
|
|
8
34
|
|
package/dist/SharingProvider.js
CHANGED
|
@@ -465,18 +465,22 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
465
465
|
* updateDocumentPermissions - Description
|
|
466
466
|
*
|
|
467
467
|
* @param {Object} document A shared document
|
|
468
|
-
* @param {
|
|
468
|
+
* @param {object} options The new verbs to use for the permission, eg. ['GET']
|
|
469
|
+
* @param {string[]} options.verbs The new verbs to use for the permission, eg. ['GET']
|
|
470
|
+
* @param {string} [options.expiresAt] The new expiration date for the permission
|
|
471
|
+
* @param {string} [options.password] The new password for the permission
|
|
469
472
|
*
|
|
470
473
|
* @return {Array}
|
|
471
474
|
*/
|
|
472
475
|
_defineProperty(_this2, "updateDocumentPermissions", /*#__PURE__*/function () {
|
|
473
|
-
var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(document,
|
|
474
|
-
var permissions, responses;
|
|
476
|
+
var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(document, options) {
|
|
477
|
+
var verbs, expiresAt, password, permissions, responses;
|
|
475
478
|
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
476
479
|
while (1) switch (_context11.prev = _context11.next) {
|
|
477
480
|
case 0:
|
|
481
|
+
verbs = options.verbs, expiresAt = options.expiresAt, password = options.password;
|
|
478
482
|
permissions = _getDocumentPermissions(_this2.state, document.id);
|
|
479
|
-
_context11.next =
|
|
483
|
+
_context11.next = 4;
|
|
480
484
|
return Promise.all(permissions.map( /*#__PURE__*/function () {
|
|
481
485
|
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(permissionDocument) {
|
|
482
486
|
var updatedPermissions, resp;
|
|
@@ -485,15 +489,18 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
485
489
|
case 0:
|
|
486
490
|
updatedPermissions = permissionDocument.attributes.permissions;
|
|
487
491
|
Object.keys(updatedPermissions).map(function (permType) {
|
|
488
|
-
updatedPermissions[permType].verbs =
|
|
492
|
+
updatedPermissions[permType].verbs = verbs;
|
|
489
493
|
});
|
|
490
494
|
_context10.next = 4;
|
|
491
|
-
return _this2.permissionCol.add(permissionDocument, updatedPermissions
|
|
495
|
+
return _this2.permissionCol.add(permissionDocument, updatedPermissions, {
|
|
496
|
+
expiresAt: expiresAt,
|
|
497
|
+
password: password
|
|
498
|
+
});
|
|
492
499
|
|
|
493
500
|
case 4:
|
|
494
501
|
resp = _context10.sent;
|
|
495
502
|
|
|
496
|
-
_this2.dispatch(updateSharingLink(resp));
|
|
503
|
+
_this2.dispatch(updateSharingLink(resp.data));
|
|
497
504
|
|
|
498
505
|
return _context10.abrupt("return", resp);
|
|
499
506
|
|
|
@@ -509,11 +516,11 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
|
509
516
|
};
|
|
510
517
|
}()));
|
|
511
518
|
|
|
512
|
-
case
|
|
519
|
+
case 4:
|
|
513
520
|
responses = _context11.sent;
|
|
514
521
|
return _context11.abrupt("return", responses);
|
|
515
522
|
|
|
516
|
-
case
|
|
523
|
+
case 6:
|
|
517
524
|
case "end":
|
|
518
525
|
return _context11.stop();
|
|
519
526
|
}
|
|
@@ -13,7 +13,9 @@ import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints';
|
|
|
13
13
|
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
|
|
14
14
|
import LinkRecipientPermissions from './LinkRecipientPermissions';
|
|
15
15
|
import RecipientConfirm from './RecipientConfirm';
|
|
16
|
+
import { checkIsPermissionHasPassword, getPermissionExpiresDate } from '../../helpers/permissions';
|
|
16
17
|
import { FADE_IN_DURATION } from '../../helpers/recipients';
|
|
18
|
+
import { useSharingContext } from '../../hooks/useSharingContext';
|
|
17
19
|
var styles = {
|
|
18
20
|
"recipient": "recipient__recipient___2DmZI",
|
|
19
21
|
"recipients-list-light": "recipient__recipients-list-light___Vq4op",
|
|
@@ -34,15 +36,29 @@ var styles = {
|
|
|
34
36
|
|
|
35
37
|
var LinkRecipient = function LinkRecipient(props) {
|
|
36
38
|
var _useI18n = useI18n(),
|
|
37
|
-
t = _useI18n.t
|
|
39
|
+
t = _useI18n.t,
|
|
40
|
+
f = _useI18n.f,
|
|
41
|
+
lang = _useI18n.lang;
|
|
38
42
|
|
|
39
43
|
var _useBreakpoints = useBreakpoints(),
|
|
40
44
|
isMobile = _useBreakpoints.isMobile;
|
|
41
45
|
|
|
46
|
+
var _useSharingContext = useSharingContext(),
|
|
47
|
+
getDocumentPermissions = _useSharingContext.getDocumentPermissions;
|
|
48
|
+
|
|
42
49
|
var recipientConfirmationData = props.recipientConfirmationData,
|
|
43
50
|
verifyRecipient = props.verifyRecipient,
|
|
44
51
|
link = props.link,
|
|
45
|
-
fadeIn = props.fadeIn
|
|
52
|
+
fadeIn = props.fadeIn,
|
|
53
|
+
document = props.document;
|
|
54
|
+
var permissions = getDocumentPermissions(document._id);
|
|
55
|
+
var hasPassword = checkIsPermissionHasPassword(permissions);
|
|
56
|
+
var expiresDate = getPermissionExpiresDate(permissions);
|
|
57
|
+
var dateFormatted = expiresDate ? f(expiresDate, lang === 'fr' ? 'dd/LL/yyyy' : 'LL/dd/yyyy') : null;
|
|
58
|
+
var textPrimary = hasPassword ? t('Share.recipients.linkWithPassword') : t('Share.recipients.anyoneWithTheLink');
|
|
59
|
+
var textSecondary = expiresDate ? t('Share.recipients.expires', {
|
|
60
|
+
date: dateFormatted
|
|
61
|
+
}) : link;
|
|
46
62
|
var RightPart = recipientConfirmationData ? /*#__PURE__*/React.createElement(RecipientConfirm, {
|
|
47
63
|
recipientConfirmationData: recipientConfirmationData,
|
|
48
64
|
verifyRecipient: verifyRecipient
|
|
@@ -64,8 +80,8 @@ var LinkRecipient = function LinkRecipient(props) {
|
|
|
64
80
|
primary: /*#__PURE__*/React.createElement(Typography, {
|
|
65
81
|
className: "u-ellipsis",
|
|
66
82
|
variant: "body1"
|
|
67
|
-
},
|
|
68
|
-
secondary:
|
|
83
|
+
}, textPrimary),
|
|
84
|
+
secondary: textSecondary
|
|
69
85
|
}), RightPart));
|
|
70
86
|
};
|
|
71
87
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
4
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
@@ -16,8 +17,11 @@ import TextField from 'cozy-ui/transpiled/react/TextField';
|
|
|
16
17
|
import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert';
|
|
17
18
|
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
|
|
18
19
|
import { copyToClipboard } from './helpers';
|
|
20
|
+
import { checkIsPermissionHasPassword } from '../../helpers/permissions';
|
|
21
|
+
import { useSharingContext } from '../../hooks/useSharingContext';
|
|
19
22
|
export var BoxPassword = function BoxPassword(_ref) {
|
|
20
|
-
var
|
|
23
|
+
var file = _ref.file,
|
|
24
|
+
onChange = _ref.onChange,
|
|
21
25
|
password = _ref.password,
|
|
22
26
|
onToggle = _ref.onToggle,
|
|
23
27
|
toggle = _ref.toggle,
|
|
@@ -37,6 +41,12 @@ export var BoxPassword = function BoxPassword(_ref) {
|
|
|
37
41
|
|
|
38
42
|
var inputRef = React.useRef();
|
|
39
43
|
|
|
44
|
+
var _useSharingContext = useSharingContext(),
|
|
45
|
+
getDocumentPermissions = _useSharingContext.getDocumentPermissions;
|
|
46
|
+
|
|
47
|
+
var permissions = getDocumentPermissions(file._id);
|
|
48
|
+
var hasPassword = checkIsPermissionHasPassword(permissions);
|
|
49
|
+
|
|
40
50
|
var handlePasswordToggle = function handlePasswordToggle(val) {
|
|
41
51
|
var _val$target$checked, _val$target;
|
|
42
52
|
|
|
@@ -106,9 +116,16 @@ export var BoxPassword = function BoxPassword(_ref) {
|
|
|
106
116
|
onChange: handlePasswordToggle
|
|
107
117
|
})))), toggle && /*#__PURE__*/React.createElement("div", {
|
|
108
118
|
className: "u-pt-half u-ph-1 u-pb-1"
|
|
109
|
-
}, /*#__PURE__*/React.createElement(TextField, {
|
|
119
|
+
}, /*#__PURE__*/React.createElement(TextField, _extends({
|
|
110
120
|
inputRef: inputRef,
|
|
111
|
-
|
|
121
|
+
autoFocus: true,
|
|
122
|
+
label: t('BoxPassword.label')
|
|
123
|
+
}, hasPassword && {
|
|
124
|
+
placeholder: '****',
|
|
125
|
+
InputLabelProps: {
|
|
126
|
+
shrink: true
|
|
127
|
+
}
|
|
128
|
+
}, {
|
|
112
129
|
value: password,
|
|
113
130
|
error: displayHelper && !!helperText,
|
|
114
131
|
helperText: displayHelper && helperText,
|
|
@@ -126,7 +143,7 @@ export var BoxPassword = function BoxPassword(_ref) {
|
|
|
126
143
|
}))
|
|
127
144
|
},
|
|
128
145
|
inputProps: inputProps
|
|
129
|
-
})));
|
|
146
|
+
}))));
|
|
130
147
|
};
|
|
131
148
|
BoxPassword.propTypes = {
|
|
132
149
|
onChange: PropTypes.func.isRequired,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addDays } from 'date-fns';
|
|
1
|
+
import { addDays, isValid } from 'date-fns';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import Box from 'cozy-ui/transpiled/react/Box';
|
|
@@ -7,6 +7,8 @@ import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
|
|
|
7
7
|
import { BoxDate } from './BoxDate';
|
|
8
8
|
import { BoxEditingRights } from './BoxEditingRights';
|
|
9
9
|
import { BoxPassword } from './BoxPassword';
|
|
10
|
+
import { checkIsPermissionHasPassword } from '../../helpers/permissions';
|
|
11
|
+
import { useSharingContext } from '../../hooks/useSharingContext';
|
|
10
12
|
var PASSWORD_MIN_LENGTH = 4;
|
|
11
13
|
export var ShareRestrictionContentModal = function ShareRestrictionContentModal(_ref) {
|
|
12
14
|
var file = _ref.file,
|
|
@@ -27,23 +29,44 @@ export var ShareRestrictionContentModal = function ShareRestrictionContentModal(
|
|
|
27
29
|
var _useI18n = useI18n(),
|
|
28
30
|
t = _useI18n.t;
|
|
29
31
|
|
|
32
|
+
var _useSharingContext = useSharingContext(),
|
|
33
|
+
getDocumentPermissions = _useSharingContext.getDocumentPermissions;
|
|
34
|
+
|
|
35
|
+
var permissions = getDocumentPermissions(file._id);
|
|
36
|
+
var hasPassword = checkIsPermissionHasPassword(permissions);
|
|
37
|
+
|
|
38
|
+
var handlePassword = function handlePassword(value) {
|
|
39
|
+
setPassword(value);
|
|
40
|
+
setIsValidPassword(hasPassword && value.trim().length === 0 || value.trim().length >= PASSWORD_MIN_LENGTH);
|
|
41
|
+
};
|
|
42
|
+
|
|
30
43
|
var handlePasswordToggle = function handlePasswordToggle(val) {
|
|
31
44
|
setPasswordToggle(val);
|
|
45
|
+
setPassword('');
|
|
46
|
+
|
|
47
|
+
if (val && !password) {
|
|
48
|
+
setIsValidPassword(hasPassword);
|
|
49
|
+
} else {
|
|
50
|
+
setIsValidPassword(true);
|
|
51
|
+
}
|
|
32
52
|
};
|
|
33
53
|
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
54
|
+
var handleDate = function handleDate(date) {
|
|
55
|
+
setSelectedDate(date);
|
|
56
|
+
setIsValidDate(isValid(date));
|
|
37
57
|
};
|
|
38
58
|
|
|
39
59
|
var handleDateToggle = function handleDateToggle(val) {
|
|
60
|
+
setDateToggle(val);
|
|
61
|
+
|
|
40
62
|
if (!val) {
|
|
63
|
+
setSelectedDate(null);
|
|
64
|
+
setIsValidDate(true);
|
|
65
|
+
} else {
|
|
66
|
+
var defaultValue = val ? addDays(new Date(), 30) : null;
|
|
67
|
+
setSelectedDate(defaultValue);
|
|
41
68
|
setIsValidDate(true);
|
|
42
69
|
}
|
|
43
|
-
|
|
44
|
-
var defaultValue = val ? addDays(new Date(), 30) : null;
|
|
45
|
-
setSelectedDate(defaultValue, true);
|
|
46
|
-
setDateToggle(val);
|
|
47
70
|
};
|
|
48
71
|
|
|
49
72
|
return /*#__PURE__*/React.createElement(Box, {
|
|
@@ -58,11 +81,12 @@ export var ShareRestrictionContentModal = function ShareRestrictionContentModal(
|
|
|
58
81
|
editingRights: editingRights,
|
|
59
82
|
setEditingRights: setEditingRights
|
|
60
83
|
}), /*#__PURE__*/React.createElement(BoxDate, {
|
|
61
|
-
onChange:
|
|
84
|
+
onChange: handleDate,
|
|
62
85
|
date: selectedDate,
|
|
63
86
|
onToggle: handleDateToggle,
|
|
64
87
|
toggle: dateToggle
|
|
65
88
|
}), /*#__PURE__*/React.createElement(BoxPassword, {
|
|
89
|
+
file: file,
|
|
66
90
|
onChange: handlePassword,
|
|
67
91
|
password: password,
|
|
68
92
|
onToggle: handlePasswordToggle,
|
|
@@ -4,17 +4,15 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
4
4
|
import { addDays } from 'date-fns';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import React, { useState } from 'react';
|
|
7
|
-
import { useClient } from 'cozy-client';
|
|
8
|
-
import { getSharingLink as makeSharingLink } from 'cozy-client/dist/models/sharing';
|
|
9
|
-
import { isMobile } from 'cozy-device-helper';
|
|
7
|
+
import { generateWebLink, useClient } from 'cozy-client';
|
|
10
8
|
import Button from 'cozy-ui/transpiled/react/Buttons';
|
|
11
9
|
import { ConfirmDialog } from 'cozy-ui/transpiled/react/CozyDialogs';
|
|
12
10
|
import Icon from 'cozy-ui/transpiled/react/Icon';
|
|
13
11
|
import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert';
|
|
14
12
|
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
|
|
15
13
|
import { ShareRestrictionContentModal } from './ShareRestrictionContentModal';
|
|
16
|
-
import { copyToClipboard,
|
|
17
|
-
import { checkIsReadOnlyPermissions } from '../../helpers/permissions';
|
|
14
|
+
import { copyToClipboard, updatePermissions, makeTTL, revokePermissions, createPermissions } from './helpers';
|
|
15
|
+
import { checkIsPermissionHasExpiresDate, checkIsPermissionHasPassword, checkIsReadOnlyPermissions, getPermissionExpiresDate } from '../../helpers/permissions';
|
|
18
16
|
import { useSharingContext } from '../../hooks/useSharingContext';
|
|
19
17
|
var PASSWORD_MIN_LENGTH = 4;
|
|
20
18
|
export var ShareRestrictionModal = function ShareRestrictionModal(_ref) {
|
|
@@ -33,35 +31,20 @@ export var ShareRestrictionModal = function ShareRestrictionModal(_ref) {
|
|
|
33
31
|
password = _useState2[0],
|
|
34
32
|
setPassword = _useState2[1];
|
|
35
33
|
|
|
36
|
-
var _useState3 = useState(
|
|
34
|
+
var _useState3 = useState(true),
|
|
37
35
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
isValidDate = _useState4[0],
|
|
37
|
+
setIsValidDate = _useState4[1];
|
|
40
38
|
|
|
41
39
|
var _useState5 = useState(true),
|
|
42
40
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
isValidPassword = _useState6[0],
|
|
42
|
+
setIsValidPassword = _useState6[1];
|
|
45
43
|
|
|
46
|
-
var _useState7 = useState(
|
|
44
|
+
var _useState7 = useState(false),
|
|
47
45
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
var _useState9 = useState(true),
|
|
52
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
53
|
-
dateToggle = _useState10[0],
|
|
54
|
-
setDateToggle = _useState10[1];
|
|
55
|
-
|
|
56
|
-
var _useState11 = useState(false),
|
|
57
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
|
58
|
-
passwordToggle = _useState12[0],
|
|
59
|
-
setPasswordToggle = _useState12[1];
|
|
60
|
-
|
|
61
|
-
var _useState13 = useState(false),
|
|
62
|
-
_useState14 = _slicedToArray(_useState13, 2),
|
|
63
|
-
loading = _useState14[0],
|
|
64
|
-
setLoading = _useState14[1];
|
|
46
|
+
loading = _useState8[0],
|
|
47
|
+
setLoading = _useState8[1];
|
|
65
48
|
|
|
66
49
|
var _useSharingContext = useSharingContext(),
|
|
67
50
|
documentType = _useSharingContext.documentType,
|
|
@@ -74,25 +57,38 @@ export var ShareRestrictionModal = function ShareRestrictionModal(_ref) {
|
|
|
74
57
|
var hasSharingLink = getSharingLink(file._id) !== null;
|
|
75
58
|
var permissions = getDocumentPermissions(file._id);
|
|
76
59
|
var isReadOnlyPermissions = checkIsReadOnlyPermissions(permissions);
|
|
60
|
+
var hasPassword = checkIsPermissionHasPassword(permissions);
|
|
61
|
+
var hasExpiresDate = checkIsPermissionHasExpiresDate(permissions);
|
|
62
|
+
var expiresDate = getPermissionExpiresDate(permissions);
|
|
63
|
+
var defaultDate = expiresDate ? new Date(expiresDate) : addDays(new Date(), 30);
|
|
64
|
+
|
|
65
|
+
var _useState9 = useState(defaultDate),
|
|
66
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
67
|
+
selectedDate = _useState10[0],
|
|
68
|
+
setSelectedDate = _useState10[1];
|
|
69
|
+
|
|
70
|
+
var _useState11 = useState(permissions.length > 0 ? hasExpiresDate : true),
|
|
71
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
72
|
+
dateToggle = _useState12[0],
|
|
73
|
+
setDateToggle = _useState12[1];
|
|
74
|
+
|
|
75
|
+
var _useState13 = useState(hasPassword),
|
|
76
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
77
|
+
passwordToggle = _useState14[0],
|
|
78
|
+
setPasswordToggle = _useState14[1];
|
|
77
79
|
|
|
78
80
|
var _useState15 = useState(isReadOnlyPermissions || permissions.length === 0 ? 'readOnly' : 'write'),
|
|
79
81
|
_useState16 = _slicedToArray(_useState15, 2),
|
|
80
82
|
editingRights = _useState16[0],
|
|
81
83
|
setEditingRights = _useState16[1];
|
|
82
84
|
|
|
83
|
-
var isDesktopOrMobileWithoutShareAPI = isMobile() && !navigator.share || !isMobile();
|
|
84
85
|
var helperTextPassword = !isValidPassword ? t('ShareRestrictionModal.invalidPasswordMessage', {
|
|
85
86
|
smart_count: PASSWORD_MIN_LENGTH - password.length
|
|
86
87
|
}) : null;
|
|
87
88
|
|
|
88
|
-
var handleDateChange = function handleDateChange(date, isValid) {
|
|
89
|
-
setSelectedDate(date);
|
|
90
|
-
setIsValidDate(isValid);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
89
|
var handleClick = /*#__PURE__*/function () {
|
|
94
90
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
95
|
-
var
|
|
91
|
+
var ttl, _yield$createPermissi2, perms, url, _yield$updatePermissi3, _yield$updatePermissi4, _perms, _url;
|
|
96
92
|
|
|
97
93
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
98
94
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -100,80 +96,80 @@ export var ShareRestrictionModal = function ShareRestrictionModal(_ref) {
|
|
|
100
96
|
setLoading(true); // If the file is not shared, we create a new sharing link
|
|
101
97
|
|
|
102
98
|
if (hasSharingLink) {
|
|
103
|
-
_context.next =
|
|
99
|
+
_context.next = 13;
|
|
104
100
|
break;
|
|
105
101
|
}
|
|
106
102
|
|
|
107
|
-
|
|
103
|
+
ttl = makeTTL(dateToggle && selectedDate);
|
|
108
104
|
_context.next = 5;
|
|
109
|
-
return
|
|
110
|
-
|
|
105
|
+
return createPermissions({
|
|
106
|
+
file: file,
|
|
107
|
+
t: t,
|
|
108
|
+
ttl: ttl,
|
|
109
|
+
password: password,
|
|
110
|
+
editingRights: editingRights,
|
|
111
|
+
documentType: documentType,
|
|
112
|
+
shareByLink: shareByLink,
|
|
113
|
+
showAlert: showAlert
|
|
111
114
|
});
|
|
112
115
|
|
|
113
116
|
case 5:
|
|
114
|
-
|
|
115
|
-
|
|
117
|
+
_yield$createPermissi2 = _context.sent;
|
|
118
|
+
perms = _yield$createPermissi2.data;
|
|
119
|
+
url = generateWebLink({
|
|
120
|
+
cozyUrl: client.getStackClient().uri,
|
|
121
|
+
searchParams: [['sharecode', perms.attributes.shortcodes.code]],
|
|
122
|
+
pathname: '/public',
|
|
123
|
+
slug: 'drive',
|
|
124
|
+
subDomainType: client.capabilities.flat_subdomains ? 'flat' : 'nested'
|
|
125
|
+
});
|
|
126
|
+
_context.next = 10;
|
|
116
127
|
return copyToClipboard(url, {
|
|
117
128
|
t: t,
|
|
118
129
|
showAlert: showAlert
|
|
119
130
|
});
|
|
120
131
|
|
|
121
|
-
case
|
|
132
|
+
case 10:
|
|
122
133
|
onClose();
|
|
123
|
-
|
|
134
|
+
_context.next = 22;
|
|
135
|
+
break;
|
|
124
136
|
|
|
125
|
-
case
|
|
126
|
-
_context.next =
|
|
137
|
+
case 13:
|
|
138
|
+
_context.next = 15;
|
|
127
139
|
return updatePermissions({
|
|
128
140
|
file: file,
|
|
129
141
|
t: t,
|
|
142
|
+
dateToggle: dateToggle,
|
|
143
|
+
selectedDate: selectedDate,
|
|
144
|
+
passwordToggle: passwordToggle,
|
|
145
|
+
password: password,
|
|
130
146
|
editingRights: editingRights,
|
|
131
147
|
documentType: documentType,
|
|
132
148
|
updateDocumentPermissions: updateDocumentPermissions,
|
|
133
149
|
showAlert: showAlert
|
|
134
150
|
});
|
|
135
151
|
|
|
136
|
-
case
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
ttl: ttl,
|
|
147
|
-
password: password
|
|
152
|
+
case 15:
|
|
153
|
+
_yield$updatePermissi3 = _context.sent;
|
|
154
|
+
_yield$updatePermissi4 = _slicedToArray(_yield$updatePermissi3, 1);
|
|
155
|
+
_perms = _yield$updatePermissi4[0].data;
|
|
156
|
+
_url = generateWebLink({
|
|
157
|
+
cozyUrl: client.getStackClient().uri,
|
|
158
|
+
searchParams: [['sharecode', _perms.attributes.shortcodes.code]],
|
|
159
|
+
pathname: '/public',
|
|
160
|
+
slug: 'drive',
|
|
161
|
+
subDomainType: client.capabilities.flat_subdomains ? 'flat' : 'nested'
|
|
148
162
|
});
|
|
149
|
-
|
|
150
|
-
case 16:
|
|
151
|
-
_url = _context.sent;
|
|
152
|
-
_context.next = 19;
|
|
163
|
+
_context.next = 21;
|
|
153
164
|
return copyToClipboard(_url, {
|
|
154
165
|
t: t,
|
|
155
166
|
showAlert: showAlert
|
|
156
167
|
});
|
|
157
168
|
|
|
158
|
-
case 19:
|
|
159
|
-
_context.next = 23;
|
|
160
|
-
break;
|
|
161
|
-
|
|
162
169
|
case 21:
|
|
163
|
-
_context.next = 23;
|
|
164
|
-
return forwardFile({
|
|
165
|
-
client: client,
|
|
166
|
-
file: file,
|
|
167
|
-
t: t,
|
|
168
|
-
ttl: ttl,
|
|
169
|
-
password: password,
|
|
170
|
-
showAlert: showAlert
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
case 23:
|
|
174
170
|
onClose();
|
|
175
171
|
|
|
176
|
-
case
|
|
172
|
+
case 22:
|
|
177
173
|
case "end":
|
|
178
174
|
return _context.stop();
|
|
179
175
|
}
|
|
@@ -223,7 +219,7 @@ export var ShareRestrictionModal = function ShareRestrictionModal(_ref) {
|
|
|
223
219
|
,
|
|
224
220
|
dateToggle: dateToggle,
|
|
225
221
|
setDateToggle: setDateToggle,
|
|
226
|
-
setSelectedDate:
|
|
222
|
+
setSelectedDate: setSelectedDate,
|
|
227
223
|
selectedDate: selectedDate,
|
|
228
224
|
setIsValidDate: setIsValidDate // Password
|
|
229
225
|
,
|