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
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import { Icon, CloudPlusOutlined } from '@linagora/twake-icons';
3
2
  import React, { forwardRef } from 'react';
3
+ import { Icon, CloudPlusOutlined } from '@linagora/twake-icons';
4
4
  import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem';
5
5
  import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
6
6
  import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import { Icon, ToTheCloud } from '@linagora/twake-icons';
3
2
  import React, { forwardRef } from 'react';
3
+ import { Icon, ToTheCloud } from '@linagora/twake-icons';
4
4
  import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem';
5
5
  import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
6
6
  import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import { Icon, Reply } from '@linagora/twake-icons';
3
2
  import React, { forwardRef } from 'react';
3
+ import { Icon, Reply } from '@linagora/twake-icons';
4
4
  import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem';
5
5
  import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
6
6
  import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import { Icon, Sync } from '@linagora/twake-icons';
3
2
  import React, { forwardRef } from 'react';
3
+ import { Icon, Sync } from '@linagora/twake-icons';
4
4
  import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem';
5
5
  import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
6
6
  import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
@@ -1,7 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import { Icon, Link } from '@linagora/twake-icons';
3
2
  import cx from 'classnames';
4
3
  import React from 'react';
4
+ import { Icon, Link } from '@linagora/twake-icons';
5
5
  import { useClient } from 'cozy-client';
6
6
  import Avatar from 'cozy-ui/transpiled/react/Avatar';
7
7
  import { ExtraAvatar } from './ExtraAvatar';
@@ -20,7 +20,6 @@ var GroupRecipient = function GroupRecipient(props) {
20
20
  color = props.color,
21
21
  members = props.members,
22
22
  fadeIn = props.fadeIn,
23
- owner = props.owner,
24
23
  isOwner = props.isOwner;
25
24
 
26
25
  var _useI18n = useI18n(),
@@ -79,7 +78,6 @@ var GroupRecipient = function GroupRecipient(props) {
79
78
  isUserInsideMembers: isUserInsideMembers
80
79
  }, props))))), isDetailOpened ? /*#__PURE__*/React.createElement(GroupRecipientDetail, {
81
80
  isOwner: isOwner,
82
- owner: owner,
83
81
  name: name,
84
82
  members: members,
85
83
  onClose: closeDetail
@@ -1,20 +1,15 @@
1
1
  import React from 'react';
2
- import { useClient, generateWebLink } from 'cozy-client';
3
- import Buttons from 'cozy-ui/transpiled/react/Buttons';
4
2
  import { Dialog } from 'cozy-ui/transpiled/react/CozyDialogs';
5
3
  import Empty from 'cozy-ui/transpiled/react/Empty';
6
- import Typography from 'cozy-ui/transpiled/react/Typography';
7
4
  import { useI18n } from 'twake-i18n';
8
5
  import { GroupRecipientDetailWithAccess } from './GroupRecipientDetailWithAccess';
9
6
  import { GroupRecipientDetailWithoutAccess } from './GroupRecipientDetailWithoutAccess';
10
7
 
11
8
  var GroupRecipientDetail = function GroupRecipientDetail(_ref) {
12
9
  var name = _ref.name,
13
- owner = _ref.owner,
14
10
  members = _ref.members,
15
11
  onClose = _ref.onClose,
16
12
  isOwner = _ref.isOwner;
17
- var client = useClient();
18
13
 
19
14
  var _useI18n = useI18n(),
20
15
  t = _useI18n.t;
@@ -25,34 +20,16 @@ var GroupRecipientDetail = function GroupRecipientDetail(_ref) {
25
20
  var withoutAccess = members.filter(function (member) {
26
21
  return ['revoked', 'mail-not-sent'].includes(member.status);
27
22
  });
28
- var ownerName = owner.public_name;
29
- var contactsLink = generateWebLink({
30
- cozyUrl: client.getStackClient().uri,
31
- slug: 'contacts',
32
- pathname: '/',
33
- subDomainType: client.getInstanceOptions().subdomain
34
- });
35
23
  return /*#__PURE__*/React.createElement(Dialog, {
36
24
  open: true,
37
25
  size: "small",
38
26
  onClose: onClose,
39
- title: /*#__PURE__*/React.createElement(React.Fragment, null, name, ownerName ? /*#__PURE__*/React.createElement(Typography, {
40
- variant: "caption"
41
- }, t('GroupRecipientDetail.subtitle', {
42
- ownerName: ownerName
43
- })) : null),
27
+ title: name,
44
28
  content: /*#__PURE__*/React.createElement("div", {
45
29
  className: "u-flex u-stack-xs u-flex-column"
46
30
  }, members.length === 0 ? /*#__PURE__*/React.createElement(Empty, {
47
31
  text: t('GroupRecipientDetail.empty.content')
48
- }, /*#__PURE__*/React.createElement(Buttons, {
49
- component: "a",
50
- className: "u-mt-1",
51
- href: contactsLink,
52
- target: "_blank",
53
- rel: "noopener noreferrer",
54
- label: t('GroupRecipientDetail.empty.action')
55
- })) : null, withAccess.length > 0 ? /*#__PURE__*/React.createElement(GroupRecipientDetailWithAccess, {
32
+ }) : null, withAccess.length > 0 ? /*#__PURE__*/React.createElement(GroupRecipientDetailWithAccess, {
56
33
  withAccess: withAccess
57
34
  }) : null, withoutAccess.length > 0 ? /*#__PURE__*/React.createElement(GroupRecipientDetailWithoutAccess, {
58
35
  withoutAccess: withoutAccess,
@@ -1,5 +1,5 @@
1
- import { Icon, Forbidden } from '@linagora/twake-icons';
2
1
  import React from 'react';
2
+ import { Icon, Forbidden } from '@linagora/twake-icons';
3
3
  import Avatar from 'cozy-ui/transpiled/react/Avatar';
4
4
  import List from 'cozy-ui/transpiled/react/List';
5
5
  import ListItem from 'cozy-ui/transpiled/react/ListItem';
@@ -1,7 +1,7 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import { Icon, Gear, Link } from '@linagora/twake-icons';
3
2
  import PropTypes from 'prop-types';
4
3
  import React, { useState } from 'react';
4
+ import { Icon, Gear, Link } from '@linagora/twake-icons';
5
5
  import Avatar from 'cozy-ui/transpiled/react/Avatar';
6
6
  import Fade from 'cozy-ui/transpiled/react/Fade';
7
7
  import IconButton from 'cozy-ui/transpiled/react/IconButton';
@@ -1,6 +1,6 @@
1
- import { Icon, Link } from '@linagora/twake-icons';
2
1
  import PropTypes from 'prop-types';
3
2
  import React from 'react';
3
+ import { Icon, Link } from '@linagora/twake-icons';
4
4
  import Avatar from 'cozy-ui/transpiled/react/Avatar';
5
5
  import ListItem from 'cozy-ui/transpiled/react/ListItem';
6
6
  import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import { Icon, Trash } from '@linagora/twake-icons';
3
2
  import React, { forwardRef } from 'react';
3
+ import { Icon, Trash } from '@linagora/twake-icons';
4
4
  import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem';
5
5
  import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
6
6
  import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
@@ -3,14 +3,14 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import PropTypes from 'prop-types';
4
4
  import React, { useState, useRef } from 'react';
5
5
  import Autosuggest from 'react-autosuggest';
6
- import Avatar from 'cozy-ui/transpiled/react/Avatar';
7
6
  import Chip from 'cozy-ui/transpiled/react/Chips';
8
7
  import { Spinner } from 'cozy-ui/transpiled/react/Spinner';
9
8
  import { GroupAvatar } from './Avatar/GroupAvatar';
9
+ import { MemberAvatar } from './Avatar/MemberAvatar';
10
10
  import ContactSuggestion from './ContactSuggestion';
11
11
  import { isContactToBeCreated } from '../helpers/contacts';
12
12
  import { extractEmails, validateEmail } from '../helpers/email';
13
- import { getDisplayName, getInitials, Contact, Group } from '../models';
13
+ import { getDisplayName, Contact, Group } from '../models';
14
14
  var styles = {
15
15
  "container": "autosuggest__container___1Yro7",
16
16
  "suggestionsContainer": "autosuggest__suggestionsContainer___3EDuG",
@@ -182,7 +182,6 @@ var ShareAutosuggest = function ShareAutosuggest(_ref) {
182
182
  className: styles['recipientsContainer']
183
183
  }, recipients.map(function (recipient, idx) {
184
184
  var isContactGroup = recipient._type === Group.doctype;
185
- var avatarText = getInitials(recipient);
186
185
  var name = getDisplayName(recipient);
187
186
  return /*#__PURE__*/React.createElement(Chip, {
188
187
  id: "recipient_".concat(idx),
@@ -190,9 +189,10 @@ var ShareAutosuggest = function ShareAutosuggest(_ref) {
190
189
  avatar: isContactGroup ? /*#__PURE__*/React.createElement(GroupAvatar, {
191
190
  size: "xs",
192
191
  color: recipient.color
193
- }) : /*#__PURE__*/React.createElement(Avatar, {
194
- size: "xs"
195
- }, avatarText),
192
+ }) : /*#__PURE__*/React.createElement(MemberAvatar, {
193
+ size: "xs",
194
+ recipient: recipient
195
+ }),
196
196
  label: name,
197
197
  onDelete: function onDelete() {
198
198
  onAutosuggestRemove(recipient);
@@ -3,9 +3,9 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
3
3
  var _excluded = ["label", "onClick", "className"],
4
4
  _excluded2 = ["label", "onClick", "className"],
5
5
  _excluded3 = ["label", "onClick", "className"];
6
- import { Icon, Share } from '@linagora/twake-icons';
7
6
  import classNames from 'classnames';
8
7
  import React from 'react';
8
+ import { Icon, Share } from '@linagora/twake-icons';
9
9
  import Button from 'cozy-ui/transpiled/react/Buttons';
10
10
  var styles = {
11
11
  "coz-btn-shared": "button__coz-btn-shared___9MFbY",
@@ -1,9 +1,9 @@
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, Copy, Link } from '@linagora/twake-icons';
5
4
  import PropTypes from 'prop-types';
6
5
  import React, { useReducer, useState } from 'react';
6
+ import { Icon, Copy, Link } from '@linagora/twake-icons';
7
7
  import { useClient } from 'cozy-client';
8
8
  import Button from 'cozy-ui/transpiled/react/Buttons';
9
9
  import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert';
@@ -0,0 +1,316 @@
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 { addDays } from 'date-fns';
5
+ import PropTypes from 'prop-types';
6
+ import React, { useState } from 'react';
7
+ import { Icon, Link as LinkIcon, Settings } from '@linagora/twake-icons';
8
+ import Alert from 'cozy-ui/transpiled/react/Alert';
9
+ import Box from 'cozy-ui/transpiled/react/Box';
10
+ import Button from 'cozy-ui/transpiled/react/Buttons';
11
+ import Chip from 'cozy-ui/transpiled/react/Chips';
12
+ import { ConfirmDialog } from 'cozy-ui/transpiled/react/CozyDialogs';
13
+ import DatePicker from 'cozy-ui/transpiled/react/DatePicker';
14
+ import DropdownButton from 'cozy-ui/transpiled/react/DropdownButton';
15
+ import FormControlLabel from 'cozy-ui/transpiled/react/FormControlLabel';
16
+ import Grid from 'cozy-ui/transpiled/react/Grid';
17
+ import IconButton from 'cozy-ui/transpiled/react/IconButton';
18
+ import Menu from 'cozy-ui/transpiled/react/Menu';
19
+ import MenuItem from 'cozy-ui/transpiled/react/MenuItem';
20
+ import Switch from 'cozy-ui/transpiled/react/Switch';
21
+ import TextField from 'cozy-ui/transpiled/react/TextField';
22
+ import Typography from 'cozy-ui/transpiled/react/Typography';
23
+ import { useI18n } from 'twake-i18n';
24
+ import withLocales from '../../hoc/withLocales';
25
+ import { useSharingContext } from '../../hooks/useSharingContext';
26
+ var DIALOG_CLASSES = {
27
+ paper: 'u-h-auto'
28
+ };
29
+ var DOCUMENT_ICON_SIZE = 18;
30
+ var PASSWORD_MIN_LENGTH = 4;
31
+ export var ShareLinkAccessModal = function ShareLinkAccessModal(_ref) {
32
+ var documents = _ref.documents,
33
+ onCancel = _ref.onCancel,
34
+ onSuccess = _ref.onSuccess,
35
+ renderDocumentIcon = _ref.renderDocumentIcon;
36
+
37
+ var _useI18n = useI18n(),
38
+ t = _useI18n.t;
39
+
40
+ var _useSharingContext = useSharingContext(),
41
+ ensureSharingLink = _useSharingContext.ensureSharingLink;
42
+
43
+ var _useState = useState('readOnly'),
44
+ _useState2 = _slicedToArray(_useState, 2),
45
+ editingRights = _useState2[0],
46
+ setEditingRights = _useState2[1];
47
+
48
+ var _useState3 = useState(null),
49
+ _useState4 = _slicedToArray(_useState3, 2),
50
+ accessAnchorEl = _useState4[0],
51
+ setAccessAnchorEl = _useState4[1];
52
+
53
+ var _useState5 = useState(false),
54
+ _useState6 = _slicedToArray(_useState5, 2),
55
+ isSettingsOpen = _useState6[0],
56
+ setIsSettingsOpen = _useState6[1];
57
+
58
+ var _useState7 = useState(false),
59
+ _useState8 = _slicedToArray(_useState7, 2),
60
+ dateEnabled = _useState8[0],
61
+ setDateEnabled = _useState8[1];
62
+
63
+ var _useState9 = useState(null),
64
+ _useState10 = _slicedToArray(_useState9, 2),
65
+ selectedDate = _useState10[0],
66
+ setSelectedDate = _useState10[1];
67
+
68
+ var _useState11 = useState(false),
69
+ _useState12 = _slicedToArray(_useState11, 2),
70
+ passwordEnabled = _useState12[0],
71
+ setPasswordEnabled = _useState12[1];
72
+
73
+ var _useState13 = useState(''),
74
+ _useState14 = _slicedToArray(_useState13, 2),
75
+ password = _useState14[0],
76
+ setPassword = _useState14[1];
77
+
78
+ var _useState15 = useState(false),
79
+ _useState16 = _slicedToArray(_useState15, 2),
80
+ busy = _useState16[0],
81
+ setBusy = _useState16[1];
82
+
83
+ var _useState17 = useState(null),
84
+ _useState18 = _slicedToArray(_useState17, 2),
85
+ error = _useState18[0],
86
+ setError = _useState18[1];
87
+
88
+ var isPasswordValid = !passwordEnabled || password.trim().length >= PASSWORD_MIN_LENGTH;
89
+
90
+ var handleAccessMenuClose = function handleAccessMenuClose() {
91
+ setAccessAnchorEl(null);
92
+ };
93
+
94
+ var handleDateEnabledChange = function handleDateEnabledChange(event) {
95
+ setDateEnabled(event.target.checked);
96
+ setSelectedDate(event.target.checked ? addDays(new Date(), 30) : null);
97
+ };
98
+
99
+ var handlePasswordEnabledChange = function handlePasswordEnabledChange(event) {
100
+ setPasswordEnabled(event.target.checked);
101
+ };
102
+
103
+ var handlePasswordChange = function handlePasswordChange(event) {
104
+ setPassword(event.target.value);
105
+ };
106
+
107
+ var handleSettingsOpen = function handleSettingsOpen() {
108
+ setIsSettingsOpen(true);
109
+ };
110
+
111
+ var handleSettingsBack = function handleSettingsBack() {
112
+ setIsSettingsOpen(false);
113
+ };
114
+
115
+ var handleSubmit = /*#__PURE__*/function () {
116
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
117
+ var results;
118
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
119
+ while (1) switch (_context.prev = _context.next) {
120
+ case 0:
121
+ setBusy(true);
122
+ setError(null);
123
+ _context.prev = 2;
124
+ _context.next = 5;
125
+ return Promise.all(documents.map(function (document) {
126
+ return ensureSharingLink(document, {
127
+ editingRights: editingRights,
128
+ dateEnabled: dateEnabled,
129
+ selectedDate: selectedDate,
130
+ passwordEnabled: passwordEnabled,
131
+ password: password.trim()
132
+ });
133
+ }));
134
+
135
+ case 5:
136
+ results = _context.sent;
137
+ onSuccess(results);
138
+ _context.next = 13;
139
+ break;
140
+
141
+ case 9:
142
+ _context.prev = 9;
143
+ _context.t0 = _context["catch"](2);
144
+ setError(t('ShareLinkAccessModal.error.persistence'));
145
+ setBusy(false);
146
+
147
+ case 13:
148
+ case "end":
149
+ return _context.stop();
150
+ }
151
+ }, _callee, null, [[2, 9]]);
152
+ }));
153
+
154
+ return function handleSubmit() {
155
+ return _ref2.apply(this, arguments);
156
+ };
157
+ }();
158
+
159
+ if (isSettingsOpen) {
160
+ return /*#__PURE__*/React.createElement(ConfirmDialog, {
161
+ open: true,
162
+ classes: DIALOG_CLASSES,
163
+ size: "small",
164
+ onBack: busy ? undefined : handleSettingsBack,
165
+ onClose: busy ? undefined : handleSettingsBack,
166
+ title: t('ShareLinkAccessModal.settingsTitle'),
167
+ content: /*#__PURE__*/React.createElement(Box, {
168
+ display: "flex",
169
+ flexDirection: "column",
170
+ gridGap: "1rem"
171
+ }, /*#__PURE__*/React.createElement(FormControlLabel, {
172
+ control: /*#__PURE__*/React.createElement(Switch, {
173
+ checked: dateEnabled,
174
+ onChange: handleDateEnabledChange,
175
+ disabled: busy,
176
+ color: "primary"
177
+ }),
178
+ label: t('ShareLinkAccessModal.expiry')
179
+ }), dateEnabled && /*#__PURE__*/React.createElement(DatePicker, {
180
+ label: t('ShareLinkAccessModal.expiryDate'),
181
+ value: selectedDate,
182
+ minDate: new Date(),
183
+ onChange: setSelectedDate,
184
+ disabled: busy,
185
+ className: "u-w-100"
186
+ }), /*#__PURE__*/React.createElement(FormControlLabel, {
187
+ control: /*#__PURE__*/React.createElement(Switch, {
188
+ checked: passwordEnabled,
189
+ onChange: handlePasswordEnabledChange,
190
+ disabled: busy,
191
+ color: "primary"
192
+ }),
193
+ label: t('ShareLinkAccessModal.password')
194
+ }), passwordEnabled && /*#__PURE__*/React.createElement(TextField, {
195
+ label: t('ShareLinkAccessModal.passwordLabel'),
196
+ value: password,
197
+ onChange: handlePasswordChange,
198
+ disabled: busy,
199
+ type: "password",
200
+ error: !isPasswordValid,
201
+ helperText: isPasswordValid ? null : t('ShareLinkAccessModal.passwordTooShort', {
202
+ count: PASSWORD_MIN_LENGTH
203
+ }),
204
+ fullWidth: true,
205
+ inputProps: {
206
+ minLength: PASSWORD_MIN_LENGTH
207
+ }
208
+ }))
209
+ });
210
+ }
211
+
212
+ return /*#__PURE__*/React.createElement(ConfirmDialog, {
213
+ open: true,
214
+ classes: DIALOG_CLASSES,
215
+ size: "small",
216
+ onBack: busy ? undefined : onCancel,
217
+ onClose: busy ? undefined : onCancel,
218
+ title: t('ShareLinkAccessModal.title'),
219
+ content: /*#__PURE__*/React.createElement(Box, {
220
+ display: "flex",
221
+ flexDirection: "column",
222
+ gridGap: "1rem"
223
+ }, /*#__PURE__*/React.createElement(Typography, null, t('ShareLinkAccessModal.introText')), /*#__PURE__*/React.createElement(Grid, {
224
+ container: true,
225
+ spacing: 1
226
+ }, documents.map(function (document) {
227
+ return /*#__PURE__*/React.createElement(Grid, {
228
+ item: true,
229
+ key: document._id || document.id,
230
+ xs: 12,
231
+ sm: 6
232
+ }, /*#__PURE__*/React.createElement(Chip, {
233
+ avatar: /*#__PURE__*/React.createElement(Box, {
234
+ component: "span",
235
+ className: "u-flex u-ov-hidden"
236
+ }, renderDocumentIcon(document, DOCUMENT_ICON_SIZE)),
237
+ className: "u-maw-100",
238
+ label: document.name,
239
+ size: "small"
240
+ }));
241
+ })), error && /*#__PURE__*/React.createElement(Alert, {
242
+ severity: "error"
243
+ }, error), /*#__PURE__*/React.createElement(Box, {
244
+ display: "flex",
245
+ alignItems: "center",
246
+ justifyContent: "space-between"
247
+ }, /*#__PURE__*/React.createElement(Box, {
248
+ display: "flex",
249
+ alignItems: "center",
250
+ gridGap: "0.5rem"
251
+ }, /*#__PURE__*/React.createElement(Icon, {
252
+ icon: LinkIcon
253
+ }), /*#__PURE__*/React.createElement(Typography, null, t('ShareLinkAccessModal.anyoneWithLink'))), /*#__PURE__*/React.createElement(Box, {
254
+ display: "flex",
255
+ alignItems: "center",
256
+ gridGap: "0.5rem",
257
+ className: "u-flex-shrink-0"
258
+ }, /*#__PURE__*/React.createElement(IconButton, {
259
+ "aria-label": t('ShareLinkAccessModal.settings'),
260
+ disabled: busy,
261
+ onClick: handleSettingsOpen
262
+ }, /*#__PURE__*/React.createElement(Icon, {
263
+ icon: Settings
264
+ })), /*#__PURE__*/React.createElement(DropdownButton, {
265
+ "aria-label": t('ShareLinkAccessModal.accessLevel'),
266
+ "aria-controls": "share-link-access-menu",
267
+ "aria-haspopup": "true",
268
+ disabled: busy,
269
+ onClick: function onClick(event) {
270
+ return setAccessAnchorEl(event.currentTarget);
271
+ },
272
+ spaceBetween: true,
273
+ textVariant: "body1"
274
+ }, t(editingRights === 'readOnly' ? 'ShareLinkAccessModal.viewer' : 'ShareLinkAccessModal.editor')), /*#__PURE__*/React.createElement(Menu, {
275
+ id: "share-link-access-menu",
276
+ anchorEl: accessAnchorEl,
277
+ open: Boolean(accessAnchorEl),
278
+ onClose: handleAccessMenuClose
279
+ }, /*#__PURE__*/React.createElement(MenuItem, {
280
+ selected: editingRights === 'readOnly',
281
+ onClick: function onClick() {
282
+ setEditingRights('readOnly');
283
+ handleAccessMenuClose();
284
+ }
285
+ }, t('ShareLinkAccessModal.viewer')), /*#__PURE__*/React.createElement(MenuItem, {
286
+ selected: editingRights === 'write',
287
+ onClick: function onClick() {
288
+ setEditingRights('write');
289
+ handleAccessMenuClose();
290
+ }
291
+ }, t('ShareLinkAccessModal.editor')))))),
292
+ actions: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
293
+ label: t('ShareLinkAccessModal.cancel'),
294
+ variant: "secondary",
295
+ onClick: onCancel,
296
+ disabled: busy
297
+ }), /*#__PURE__*/React.createElement(Button, {
298
+ label: t('ShareLinkAccessModal.addLinks'),
299
+ onClick: handleSubmit,
300
+ disabled: busy || !isPasswordValid,
301
+ busy: busy
302
+ }))
303
+ });
304
+ };
305
+ ShareLinkAccessModal.propTypes = {
306
+ documents: PropTypes.arrayOf(PropTypes.object).isRequired,
307
+ onCancel: PropTypes.func.isRequired,
308
+ onSuccess: PropTypes.func.isRequired,
309
+ renderDocumentIcon: PropTypes.func
310
+ };
311
+ ShareLinkAccessModal.defaultProps = {
312
+ renderDocumentIcon: function renderDocumentIcon() {
313
+ return null;
314
+ }
315
+ };
316
+ export default withLocales(ShareLinkAccessModal);