cozy-sharing 18.0.0 → 19.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 +31 -0
- 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 +138 -0
- package/dist/components/ShareRestrictionModal/ShareRestrictionContentModal.js +94 -0
- package/dist/components/ShareRestrictionModal/ShareRestrictionModal.js +260 -0
- package/dist/components/ShareRestrictionModal/helpers.js +275 -0
- package/dist/components/ShareRestrictionModal/helpers.spec.js +110 -0
- package/dist/components/WhoHasAccess.js +1 -5
- package/locales/en.json +28 -0
- package/locales/fr.json +29 -0
- package/package.json +11 -7
- 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 +112 -0
- package/src/components/ShareRestrictionModal/ShareRestrictionContentModal.jsx +102 -0
- package/src/components/ShareRestrictionModal/ShareRestrictionModal.jsx +177 -0
- package/src/components/ShareRestrictionModal/helpers.js +193 -0
- package/src/components/ShareRestrictionModal/helpers.spec.js +78 -0
- package/src/components/WhoHasAccess.jsx +1 -5
- 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
|
@@ -56,9 +56,7 @@ var SharingContent = function SharingContent(_ref) {
|
|
|
56
56
|
recipientsToBeConfirmed = _ref.recipientsToBeConfirmed,
|
|
57
57
|
verifyRecipient = _ref.verifyRecipient,
|
|
58
58
|
link = _ref.link,
|
|
59
|
-
permissions = _ref.permissions
|
|
60
|
-
onUpdateShareLinkPermissions = _ref.onUpdateShareLinkPermissions,
|
|
61
|
-
onRevokeLink = _ref.onRevokeLink;
|
|
59
|
+
permissions = _ref.permissions;
|
|
62
60
|
|
|
63
61
|
var _useI18n = useI18n(),
|
|
64
62
|
t = _useI18n.t;
|
|
@@ -96,9 +94,7 @@ var SharingContent = function SharingContent(_ref) {
|
|
|
96
94
|
recipientsToBeConfirmed: recipientsToBeConfirmed,
|
|
97
95
|
verifyRecipient: verifyRecipient,
|
|
98
96
|
link: link,
|
|
99
|
-
permissions: permissions
|
|
100
|
-
onUpdateShareLinkPermissions: onUpdateShareLinkPermissions,
|
|
101
|
-
onRevokeLink: onRevokeLink
|
|
97
|
+
permissions: permissions
|
|
102
98
|
}));
|
|
103
99
|
};
|
|
104
100
|
/**
|
|
@@ -16,9 +16,6 @@ var ShareDialogOnlyByLink = function ShareDialogOnlyByLink(_ref) {
|
|
|
16
16
|
documentType = _ref.documentType,
|
|
17
17
|
link = _ref.link,
|
|
18
18
|
onClose = _ref.onClose,
|
|
19
|
-
onRevokeLink = _ref.onRevokeLink,
|
|
20
|
-
onShareByLink = _ref.onShareByLink,
|
|
21
|
-
onUpdateShareLinkPermissions = _ref.onUpdateShareLinkPermissions,
|
|
22
19
|
permissions = _ref.permissions;
|
|
23
20
|
|
|
24
21
|
var _useI18n = useI18n(),
|
|
@@ -46,16 +43,13 @@ var ShareDialogOnlyByLink = function ShareDialogOnlyByLink(_ref) {
|
|
|
46
43
|
onRevokeSelf: onRevokeSelf,
|
|
47
44
|
recipients: recipients,
|
|
48
45
|
link: link,
|
|
49
|
-
permissions: permissions
|
|
50
|
-
onUpdateShareLinkPermissions: onUpdateShareLinkPermissions,
|
|
51
|
-
onRevokeLink: onRevokeLink
|
|
46
|
+
permissions: permissions
|
|
52
47
|
}), /*#__PURE__*/React.createElement("div", {
|
|
53
48
|
className: cx('u-mt-half', isMobile ? 'u-ph-1 u-mb-1' : 'u-ph-2 u-mb-1-half')
|
|
54
49
|
}, /*#__PURE__*/React.createElement(DumbShareByLink, {
|
|
55
50
|
link: link,
|
|
56
51
|
document: document,
|
|
57
|
-
documentType: documentType
|
|
58
|
-
onEnable: onShareByLink
|
|
52
|
+
documentType: documentType
|
|
59
53
|
})))
|
|
60
54
|
});
|
|
61
55
|
};
|
|
@@ -109,7 +109,6 @@ var ShareDialogTwoStepsConfirmationContainer = function ShareDialogTwoStepsConfi
|
|
|
109
109
|
onRevokeLink = _ref4.onRevokeLink,
|
|
110
110
|
onRevokeSelf = _ref4.onRevokeSelf,
|
|
111
111
|
onShare = _ref4.onShare,
|
|
112
|
-
onShareByLink = _ref4.onShareByLink,
|
|
113
112
|
onUpdateShareLinkPermissions = _ref4.onUpdateShareLinkPermissions,
|
|
114
113
|
permissions = _ref4.permissions,
|
|
115
114
|
recipients = _ref4.recipients,
|
|
@@ -262,8 +261,7 @@ var ShareDialogTwoStepsConfirmationContainer = function ShareDialogTwoStepsConfi
|
|
|
262
261
|
dialogActions = DialogActionsOnShare ? /*#__PURE__*/React.createElement(DialogActionsOnShare, {
|
|
263
262
|
link: link,
|
|
264
263
|
document: document,
|
|
265
|
-
documentType: documentType
|
|
266
|
-
onEnable: onShareByLink
|
|
264
|
+
documentType: documentType
|
|
267
265
|
}) : null;
|
|
268
266
|
} else if (status === 'confirmingRecipient') {
|
|
269
267
|
dialogTitle = t("Share.twoStepsConfirmation.title");
|
|
@@ -26,10 +26,7 @@ export var EditableSharingModal = function EditableSharingModal(_ref) {
|
|
|
26
26
|
isOwner = _useSharingContext.isOwner,
|
|
27
27
|
revoke = _useSharingContext.revoke,
|
|
28
28
|
revokeSelf = _useSharingContext.revokeSelf,
|
|
29
|
-
|
|
30
|
-
share = _useSharingContext.share,
|
|
31
|
-
shareByLink = _useSharingContext.shareByLink,
|
|
32
|
-
updateDocumentPermissions = _useSharingContext.updateDocumentPermissions;
|
|
29
|
+
share = _useSharingContext.share;
|
|
33
30
|
|
|
34
31
|
return /*#__PURE__*/React.createElement(ShareModal, _extends({
|
|
35
32
|
createContact: function createContact(contact) {
|
|
@@ -42,11 +39,8 @@ export var EditableSharingModal = function EditableSharingModal(_ref) {
|
|
|
42
39
|
isOwner: isOwner(document.id),
|
|
43
40
|
link: getSharingLink(document.id),
|
|
44
41
|
onRevoke: revoke,
|
|
45
|
-
onRevokeLink: revokeSharingLink,
|
|
46
42
|
onRevokeSelf: revokeSelf,
|
|
47
43
|
onShare: share,
|
|
48
|
-
onShareByLink: shareByLink,
|
|
49
|
-
onUpdateShareLinkPermissions: updateDocumentPermissions,
|
|
50
44
|
permissions: getDocumentPermissions(document.id),
|
|
51
45
|
recipients: getRecipients(document.id),
|
|
52
46
|
sharing: getSharingForSelf(document.id)
|
|
@@ -14,11 +14,8 @@ export var ShareModal = function ShareModal(_ref) {
|
|
|
14
14
|
needsContactsPermission = _ref.needsContactsPermission,
|
|
15
15
|
onClose = _ref.onClose,
|
|
16
16
|
onRevoke = _ref.onRevoke,
|
|
17
|
-
onRevokeLink = _ref.onRevokeLink,
|
|
18
17
|
onRevokeSelf = _ref.onRevokeSelf,
|
|
19
18
|
onShare = _ref.onShare,
|
|
20
|
-
onShareByLink = _ref.onShareByLink,
|
|
21
|
-
onUpdateShareLinkPermissions = _ref.onUpdateShareLinkPermissions,
|
|
22
19
|
permissions = _ref.permissions,
|
|
23
20
|
recipients = _ref.recipients,
|
|
24
21
|
sharing = _ref.sharing,
|
|
@@ -38,9 +35,6 @@ export var ShareModal = function ShareModal(_ref) {
|
|
|
38
35
|
documentType: documentType,
|
|
39
36
|
link: link,
|
|
40
37
|
onClose: onClose,
|
|
41
|
-
onRevokeLink: onRevokeLink,
|
|
42
|
-
onShareByLink: onShareByLink,
|
|
43
|
-
onUpdateShareLinkPermissions: onUpdateShareLinkPermissions,
|
|
44
38
|
permissions: permissions
|
|
45
39
|
}) : /*#__PURE__*/React.createElement(ShareDialogCozyToCozy, {
|
|
46
40
|
createContact: createContact,
|
|
@@ -52,11 +46,8 @@ export var ShareModal = function ShareModal(_ref) {
|
|
|
52
46
|
needsContactsPermission: needsContactsPermission,
|
|
53
47
|
onClose: onClose,
|
|
54
48
|
onRevoke: onRevoke,
|
|
55
|
-
onRevokeLink: onRevokeLink,
|
|
56
49
|
onRevokeSelf: onRevokeSelf,
|
|
57
50
|
onShare: onShare,
|
|
58
|
-
onShareByLink: onShareByLink,
|
|
59
|
-
onUpdateShareLinkPermissions: onUpdateShareLinkPermissions,
|
|
60
51
|
permissions: permissions,
|
|
61
52
|
recipients: recipients,
|
|
62
53
|
sharing: sharing,
|
|
@@ -80,10 +71,7 @@ ShareModal.propTypes = {
|
|
|
80
71
|
needsContactsPermission: PropTypes.bool,
|
|
81
72
|
onClose: PropTypes.func.isRequired,
|
|
82
73
|
onRevoke: PropTypes.func.isRequired,
|
|
83
|
-
onRevokeLink: PropTypes.func.isRequired,
|
|
84
74
|
onShare: PropTypes.func.isRequired,
|
|
85
|
-
onShareByLink: PropTypes.func.isRequired,
|
|
86
|
-
onUpdateShareLinkPermissions: PropTypes.func.isRequired,
|
|
87
75
|
permissions: PropTypes.array.isRequired,
|
|
88
76
|
recipients: PropTypes.array.isRequired,
|
|
89
77
|
sharingDesc: PropTypes.string,
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { format } from 'date-fns';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import Box from 'cozy-ui/transpiled/react/Box';
|
|
5
|
+
import DatePicker from 'cozy-ui/transpiled/react/DatePicker';
|
|
6
|
+
import Icon from 'cozy-ui/transpiled/react/Icon';
|
|
7
|
+
import List from 'cozy-ui/transpiled/react/List';
|
|
8
|
+
import ListItem from 'cozy-ui/transpiled/react/ListItem';
|
|
9
|
+
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
|
|
10
|
+
import ListItemSecondaryAction from 'cozy-ui/transpiled/react/ListItemSecondaryAction';
|
|
11
|
+
import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
|
|
12
|
+
import Switch from 'cozy-ui/transpiled/react/Switch';
|
|
13
|
+
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
|
|
14
|
+
export var BoxDate = function BoxDate(_ref) {
|
|
15
|
+
var onChange = _ref.onChange,
|
|
16
|
+
date = _ref.date,
|
|
17
|
+
toggle = _ref.toggle,
|
|
18
|
+
onToggle = _ref.onToggle;
|
|
19
|
+
|
|
20
|
+
var _useI18n = useI18n(),
|
|
21
|
+
t = _useI18n.t,
|
|
22
|
+
lang = _useI18n.lang;
|
|
23
|
+
|
|
24
|
+
var formatDate = lang === 'fr' ? 'dd/MM/yyyy' : 'MM/dd/yyyy';
|
|
25
|
+
|
|
26
|
+
var handleDateToggle = function handleDateToggle(val) {
|
|
27
|
+
var _val$target$checked, _val$target;
|
|
28
|
+
|
|
29
|
+
var value = (_val$target$checked = val === null || val === void 0 || (_val$target = val.target) === null || _val$target === void 0 ? void 0 : _val$target.checked) !== null && _val$target$checked !== void 0 ? _val$target$checked : val;
|
|
30
|
+
onToggle(value);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
34
|
+
borderRadius: "0.5rem",
|
|
35
|
+
border: "1px solid var(--borderMainColor)"
|
|
36
|
+
}, /*#__PURE__*/React.createElement(List, {
|
|
37
|
+
className: "u-p-0"
|
|
38
|
+
}, /*#__PURE__*/React.createElement(ListItem, {
|
|
39
|
+
button: true,
|
|
40
|
+
size: "large",
|
|
41
|
+
ellipsis: false,
|
|
42
|
+
onClick: function onClick() {
|
|
43
|
+
return handleDateToggle(!toggle);
|
|
44
|
+
}
|
|
45
|
+
}, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Icon, {
|
|
46
|
+
icon: "calendar"
|
|
47
|
+
})), /*#__PURE__*/React.createElement(ListItemText, {
|
|
48
|
+
primary: t('BoxDate.text')
|
|
49
|
+
}), /*#__PURE__*/React.createElement(ListItemSecondaryAction, null, /*#__PURE__*/React.createElement(Switch, {
|
|
50
|
+
edge: "end",
|
|
51
|
+
color: "primary",
|
|
52
|
+
checked: toggle,
|
|
53
|
+
onChange: handleDateToggle
|
|
54
|
+
})))), toggle && /*#__PURE__*/React.createElement("div", {
|
|
55
|
+
className: "u-pt-half u-ph-1 u-pb-1"
|
|
56
|
+
}, /*#__PURE__*/React.createElement(DatePicker, {
|
|
57
|
+
className: "u-w-100",
|
|
58
|
+
enableKeyboard: true,
|
|
59
|
+
label: t('BoxDate.label'),
|
|
60
|
+
placeholder: format(new Date(), formatDate),
|
|
61
|
+
value: date,
|
|
62
|
+
minDate: new Date(),
|
|
63
|
+
onChange: onChange,
|
|
64
|
+
inputProps: {
|
|
65
|
+
inputMode: 'numeric'
|
|
66
|
+
},
|
|
67
|
+
KeyboardButtonProps: {
|
|
68
|
+
'aria-label': t('BoxDate.label')
|
|
69
|
+
}
|
|
70
|
+
})));
|
|
71
|
+
};
|
|
72
|
+
BoxDate.propTypes = {
|
|
73
|
+
onChange: PropTypes.func.isRequired,
|
|
74
|
+
date: PropTypes.instanceOf(Date),
|
|
75
|
+
toggle: PropTypes.bool.isRequired,
|
|
76
|
+
onToggle: PropTypes.func.isRequired
|
|
77
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import React, { useReducer, useRef } from 'react';
|
|
4
|
+
import { isDirectory as isDir } from 'cozy-client/dist/models/file';
|
|
5
|
+
import ActionsMenu from 'cozy-ui/transpiled/react/ActionsMenu';
|
|
6
|
+
import { makeActions } from 'cozy-ui/transpiled/react/ActionsMenu/Actions';
|
|
7
|
+
import Box from 'cozy-ui/transpiled/react/Box';
|
|
8
|
+
import Icon from 'cozy-ui/transpiled/react/Icon';
|
|
9
|
+
import List from 'cozy-ui/transpiled/react/List';
|
|
10
|
+
import ListItem from 'cozy-ui/transpiled/react/ListItem';
|
|
11
|
+
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
|
|
12
|
+
import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
|
|
13
|
+
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
|
|
14
|
+
import { useSharingContext } from '../../hooks/useSharingContext';
|
|
15
|
+
import { editPermissionLink } from '../Recipient/actions/editPermissionLink';
|
|
16
|
+
import { readOnlyPermissionLink } from '../Recipient/actions/readOnlyPermissionLink';
|
|
17
|
+
export var BoxEditingRights = function BoxEditingRights(_ref) {
|
|
18
|
+
var file = _ref.file,
|
|
19
|
+
editingRights = _ref.editingRights,
|
|
20
|
+
setEditingRights = _ref.setEditingRights;
|
|
21
|
+
|
|
22
|
+
var _useReducer = useReducer(function (state) {
|
|
23
|
+
return !state;
|
|
24
|
+
}, false),
|
|
25
|
+
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
26
|
+
isMenuDisplayed = _useReducer2[0],
|
|
27
|
+
toggleMenuDisplayed = _useReducer2[1];
|
|
28
|
+
|
|
29
|
+
var buttonRef = useRef();
|
|
30
|
+
|
|
31
|
+
var _useI18n = useI18n(),
|
|
32
|
+
t = _useI18n.t;
|
|
33
|
+
|
|
34
|
+
var _useSharingContext = useSharingContext(),
|
|
35
|
+
documentType = _useSharingContext.documentType;
|
|
36
|
+
|
|
37
|
+
var isDirectory = isDir(file);
|
|
38
|
+
var actions = makeActions([readOnlyPermissionLink, editPermissionLink], {
|
|
39
|
+
t: t,
|
|
40
|
+
editingRights: editingRights,
|
|
41
|
+
setEditingRights: setEditingRights,
|
|
42
|
+
documentType: documentType,
|
|
43
|
+
isDirectory: isDirectory
|
|
44
|
+
});
|
|
45
|
+
var textSecondary = editingRights === 'readOnly' ? t('Share.permissionLink.readDescription') : t('Share.permissionLink.writeDescription');
|
|
46
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Box, {
|
|
47
|
+
borderRadius: "0.5rem",
|
|
48
|
+
border: "1px solid var(--borderMainColor)",
|
|
49
|
+
ref: buttonRef
|
|
50
|
+
}, /*#__PURE__*/React.createElement(List, {
|
|
51
|
+
className: "u-p-0"
|
|
52
|
+
}, /*#__PURE__*/React.createElement(ListItem, {
|
|
53
|
+
button: true,
|
|
54
|
+
size: "large",
|
|
55
|
+
ellipsis: false,
|
|
56
|
+
onClick: toggleMenuDisplayed
|
|
57
|
+
}, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Icon, {
|
|
58
|
+
icon: "people"
|
|
59
|
+
})), /*#__PURE__*/React.createElement(ListItemText, {
|
|
60
|
+
primary: t('BoxEditingRights.text'),
|
|
61
|
+
secondary: textSecondary
|
|
62
|
+
}), /*#__PURE__*/React.createElement(ListItemIcon, {
|
|
63
|
+
className: "u-mr-half"
|
|
64
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
65
|
+
icon: "bottom"
|
|
66
|
+
}))))), /*#__PURE__*/React.createElement(ActionsMenu, {
|
|
67
|
+
ref: buttonRef,
|
|
68
|
+
open: isMenuDisplayed,
|
|
69
|
+
docs: [file],
|
|
70
|
+
actions: actions,
|
|
71
|
+
anchorOrigin: {
|
|
72
|
+
vertical: 'bottom',
|
|
73
|
+
horizontal: 'right'
|
|
74
|
+
},
|
|
75
|
+
autoClose: true,
|
|
76
|
+
onClose: toggleMenuDisplayed
|
|
77
|
+
}));
|
|
78
|
+
};
|
|
79
|
+
BoxEditingRights.propTypes = {
|
|
80
|
+
file: PropTypes.object.isRequired,
|
|
81
|
+
editingRights: PropTypes.oneOf(['readOnly', 'write']).isRequired,
|
|
82
|
+
setEditingRights: PropTypes.func.isRequired
|
|
83
|
+
};
|
|
@@ -0,0 +1,138 @@
|
|
|
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 Box from 'cozy-ui/transpiled/react/Box';
|
|
7
|
+
import Icon from 'cozy-ui/transpiled/react/Icon';
|
|
8
|
+
import IconButton from 'cozy-ui/transpiled/react/IconButton';
|
|
9
|
+
import List from 'cozy-ui/transpiled/react/List';
|
|
10
|
+
import ListItem from 'cozy-ui/transpiled/react/ListItem';
|
|
11
|
+
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
|
|
12
|
+
import ListItemSecondaryAction from 'cozy-ui/transpiled/react/ListItemSecondaryAction';
|
|
13
|
+
import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
|
|
14
|
+
import Switch from 'cozy-ui/transpiled/react/Switch';
|
|
15
|
+
import TextField from 'cozy-ui/transpiled/react/TextField';
|
|
16
|
+
import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert';
|
|
17
|
+
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
|
|
18
|
+
import { copyToClipboard } from './helpers';
|
|
19
|
+
export var BoxPassword = function BoxPassword(_ref) {
|
|
20
|
+
var onChange = _ref.onChange,
|
|
21
|
+
password = _ref.password,
|
|
22
|
+
onToggle = _ref.onToggle,
|
|
23
|
+
toggle = _ref.toggle,
|
|
24
|
+
helperText = _ref.helperText,
|
|
25
|
+
inputProps = _ref.inputProps;
|
|
26
|
+
|
|
27
|
+
var _useI18n = useI18n(),
|
|
28
|
+
t = _useI18n.t;
|
|
29
|
+
|
|
30
|
+
var _useAlert = useAlert(),
|
|
31
|
+
showAlert = _useAlert.showAlert;
|
|
32
|
+
|
|
33
|
+
var _useState = useState(false),
|
|
34
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
35
|
+
displayHelper = _useState2[0],
|
|
36
|
+
setDisplayHelper = _useState2[1];
|
|
37
|
+
|
|
38
|
+
var inputRef = React.useRef();
|
|
39
|
+
|
|
40
|
+
var handlePasswordToggle = function handlePasswordToggle(val) {
|
|
41
|
+
var _val$target$checked, _val$target;
|
|
42
|
+
|
|
43
|
+
var value = (_val$target$checked = val === null || val === void 0 || (_val$target = val.target) === null || _val$target === void 0 ? void 0 : _val$target.checked) !== null && _val$target$checked !== void 0 ? _val$target$checked : val;
|
|
44
|
+
onToggle(value);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
var handleChange = function handleChange(val) {
|
|
48
|
+
var _val$target$value, _val$target2;
|
|
49
|
+
|
|
50
|
+
var value = (_val$target$value = val === null || val === void 0 || (_val$target2 = val.target) === null || _val$target2 === void 0 ? void 0 : _val$target2.value) !== null && _val$target$value !== void 0 ? _val$target$value : val;
|
|
51
|
+
onChange(value);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
var handleOnFocus = function handleOnFocus() {
|
|
55
|
+
setDisplayHelper(false);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
var handleOnBlur = function handleOnBlur() {
|
|
59
|
+
handleChange(inputRef.current.value.trim());
|
|
60
|
+
setDisplayHelper(true);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
var handleCopy = /*#__PURE__*/function () {
|
|
64
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
65
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
66
|
+
while (1) switch (_context.prev = _context.next) {
|
|
67
|
+
case 0:
|
|
68
|
+
_context.next = 2;
|
|
69
|
+
return copyToClipboard(password, {
|
|
70
|
+
t: t,
|
|
71
|
+
showAlert: showAlert
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
case 2:
|
|
75
|
+
case "end":
|
|
76
|
+
return _context.stop();
|
|
77
|
+
}
|
|
78
|
+
}, _callee);
|
|
79
|
+
}));
|
|
80
|
+
|
|
81
|
+
return function handleCopy() {
|
|
82
|
+
return _ref2.apply(this, arguments);
|
|
83
|
+
};
|
|
84
|
+
}();
|
|
85
|
+
|
|
86
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
87
|
+
borderRadius: "0.5rem",
|
|
88
|
+
border: "1px solid var(--borderMainColor)"
|
|
89
|
+
}, /*#__PURE__*/React.createElement(List, {
|
|
90
|
+
className: "u-p-0"
|
|
91
|
+
}, /*#__PURE__*/React.createElement(ListItem, {
|
|
92
|
+
button: true,
|
|
93
|
+
size: "large",
|
|
94
|
+
ellipsis: false,
|
|
95
|
+
onClick: function onClick() {
|
|
96
|
+
return handlePasswordToggle(!toggle);
|
|
97
|
+
}
|
|
98
|
+
}, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Icon, {
|
|
99
|
+
icon: "password"
|
|
100
|
+
})), /*#__PURE__*/React.createElement(ListItemText, {
|
|
101
|
+
primary: t('BoxPassword.text')
|
|
102
|
+
}), /*#__PURE__*/React.createElement(ListItemSecondaryAction, null, /*#__PURE__*/React.createElement(Switch, {
|
|
103
|
+
edge: "end",
|
|
104
|
+
color: "primary",
|
|
105
|
+
checked: toggle,
|
|
106
|
+
onChange: handlePasswordToggle
|
|
107
|
+
})))), toggle && /*#__PURE__*/React.createElement("div", {
|
|
108
|
+
className: "u-pt-half u-ph-1 u-pb-1"
|
|
109
|
+
}, /*#__PURE__*/React.createElement(TextField, {
|
|
110
|
+
inputRef: inputRef,
|
|
111
|
+
label: t('BoxPassword.label'),
|
|
112
|
+
value: password,
|
|
113
|
+
error: displayHelper && !!helperText,
|
|
114
|
+
helperText: displayHelper && helperText,
|
|
115
|
+
onChange: handleChange,
|
|
116
|
+
onFocus: handleOnFocus,
|
|
117
|
+
onBlur: handleOnBlur,
|
|
118
|
+
fullWidth: true,
|
|
119
|
+
type: "text",
|
|
120
|
+
variant: "outlined",
|
|
121
|
+
InputProps: {
|
|
122
|
+
endAdornment: /*#__PURE__*/React.createElement(IconButton, {
|
|
123
|
+
onClick: handleCopy
|
|
124
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
125
|
+
icon: "copy"
|
|
126
|
+
}))
|
|
127
|
+
},
|
|
128
|
+
inputProps: inputProps
|
|
129
|
+
})));
|
|
130
|
+
};
|
|
131
|
+
BoxPassword.propTypes = {
|
|
132
|
+
onChange: PropTypes.func.isRequired,
|
|
133
|
+
password: PropTypes.string,
|
|
134
|
+
onToggle: PropTypes.func.isRequired,
|
|
135
|
+
toggle: PropTypes.bool.isRequired,
|
|
136
|
+
helperText: PropTypes.string,
|
|
137
|
+
inputProps: PropTypes.object
|
|
138
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { addDays } from 'date-fns';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import Box from 'cozy-ui/transpiled/react/Box';
|
|
5
|
+
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
6
|
+
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
|
|
7
|
+
import { BoxDate } from './BoxDate';
|
|
8
|
+
import { BoxEditingRights } from './BoxEditingRights';
|
|
9
|
+
import { BoxPassword } from './BoxPassword';
|
|
10
|
+
var PASSWORD_MIN_LENGTH = 4;
|
|
11
|
+
export var ShareRestrictionContentModal = function ShareRestrictionContentModal(_ref) {
|
|
12
|
+
var file = _ref.file,
|
|
13
|
+
selectedDate = _ref.selectedDate,
|
|
14
|
+
setSelectedDate = _ref.setSelectedDate,
|
|
15
|
+
dateToggle = _ref.dateToggle,
|
|
16
|
+
setDateToggle = _ref.setDateToggle,
|
|
17
|
+
setIsValidDate = _ref.setIsValidDate,
|
|
18
|
+
helperTextPassword = _ref.helperTextPassword,
|
|
19
|
+
password = _ref.password,
|
|
20
|
+
setPassword = _ref.setPassword,
|
|
21
|
+
passwordToggle = _ref.passwordToggle,
|
|
22
|
+
setPasswordToggle = _ref.setPasswordToggle,
|
|
23
|
+
setIsValidPassword = _ref.setIsValidPassword,
|
|
24
|
+
editingRights = _ref.editingRights,
|
|
25
|
+
setEditingRights = _ref.setEditingRights;
|
|
26
|
+
|
|
27
|
+
var _useI18n = useI18n(),
|
|
28
|
+
t = _useI18n.t;
|
|
29
|
+
|
|
30
|
+
var handlePasswordToggle = function handlePasswordToggle(val) {
|
|
31
|
+
setPasswordToggle(val);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
var handlePassword = function handlePassword(value) {
|
|
35
|
+
setPassword(value);
|
|
36
|
+
setIsValidPassword(value.trim().length === 0 || value.trim().length >= PASSWORD_MIN_LENGTH);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
var handleDateToggle = function handleDateToggle(val) {
|
|
40
|
+
if (!val) {
|
|
41
|
+
setIsValidDate(true);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
var defaultValue = val ? addDays(new Date(), 30) : null;
|
|
45
|
+
setSelectedDate(defaultValue, true);
|
|
46
|
+
setDateToggle(val);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
50
|
+
display: "flex",
|
|
51
|
+
flexDirection: "column",
|
|
52
|
+
gridGap: "1rem"
|
|
53
|
+
}, /*#__PURE__*/React.createElement(Typography, {
|
|
54
|
+
variant: "h4",
|
|
55
|
+
className: "u-mb-half u-ml-half"
|
|
56
|
+
}, t('ShareRestrictionModal.title')), /*#__PURE__*/React.createElement(BoxEditingRights, {
|
|
57
|
+
file: file,
|
|
58
|
+
editingRights: editingRights,
|
|
59
|
+
setEditingRights: setEditingRights
|
|
60
|
+
}), /*#__PURE__*/React.createElement(BoxDate, {
|
|
61
|
+
onChange: setSelectedDate,
|
|
62
|
+
date: selectedDate,
|
|
63
|
+
onToggle: handleDateToggle,
|
|
64
|
+
toggle: dateToggle
|
|
65
|
+
}), /*#__PURE__*/React.createElement(BoxPassword, {
|
|
66
|
+
onChange: handlePassword,
|
|
67
|
+
password: password,
|
|
68
|
+
onToggle: handlePasswordToggle,
|
|
69
|
+
toggle: passwordToggle,
|
|
70
|
+
helperText: helperTextPassword,
|
|
71
|
+
inputProps: {
|
|
72
|
+
minLength: PASSWORD_MIN_LENGTH
|
|
73
|
+
}
|
|
74
|
+
}));
|
|
75
|
+
};
|
|
76
|
+
ShareRestrictionContentModal.propTypes = {
|
|
77
|
+
file: PropTypes.object.isRequired,
|
|
78
|
+
// Date
|
|
79
|
+
selectedDate: PropTypes.object,
|
|
80
|
+
setSelectedDate: PropTypes.func.isRequired,
|
|
81
|
+
dateToggle: PropTypes.bool,
|
|
82
|
+
setDateToggle: PropTypes.func.isRequired,
|
|
83
|
+
setIsValidDate: PropTypes.func.isRequired,
|
|
84
|
+
// Password
|
|
85
|
+
helperTextPassword: PropTypes.string,
|
|
86
|
+
password: PropTypes.string,
|
|
87
|
+
setPassword: PropTypes.func.isRequired,
|
|
88
|
+
passwordToggle: PropTypes.bool.isRequired,
|
|
89
|
+
setPasswordToggle: PropTypes.func.isRequired,
|
|
90
|
+
setIsValidPassword: PropTypes.func.isRequired,
|
|
91
|
+
// Editing rights
|
|
92
|
+
editingRights: PropTypes.oneOf(['readOnly', 'write']),
|
|
93
|
+
setEditingRights: PropTypes.func.isRequired
|
|
94
|
+
};
|