cozy-sharing 5.0.0 → 6.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 +69 -0
- package/dist/SharedRecipients.js +1 -1
- package/dist/SharedStatus.js +1 -1
- package/dist/SharingBanner/hooks/useSharingInfos.js +1 -1
- package/dist/SharingDetailsModal.js +1 -1
- package/dist/SharingOwnerAvatar.js +1 -1
- package/dist/SharingProvider.js +21 -8
- package/dist/components/ContactSuggestion.js +15 -27
- package/dist/components/EditLinkPermissionDialog.js +72 -0
- package/dist/components/EditLinkPermissionDialog.spec.js +48 -0
- package/dist/components/EditableSharingModal.js +15 -62
- package/dist/components/{AvatarPlusX.js → Recipient/AvatarPlusX.js} +1 -1
- package/dist/components/{Identity.js → Recipient/Identity.js} +17 -16
- package/dist/components/Recipient/LinkRecipient.js +72 -0
- package/dist/components/Recipient/LinkRecipientPermissions.js +159 -0
- package/dist/components/Recipient/OwnerIdentity.js +44 -0
- package/dist/components/Recipient/Recipient.js +72 -0
- package/dist/components/{Recipient.spec.js → Recipient/Recipient.spec.js} +4 -45
- package/dist/components/Recipient/RecipientAvatar.js +33 -0
- package/dist/components/Recipient/RecipientConfirm.js +63 -0
- package/dist/components/Recipient/RecipientPermissions.js +126 -0
- package/dist/components/Recipient/RecipientPlusX.js +45 -0
- package/dist/components/Recipient/RecipientStatus.js +64 -0
- package/dist/components/Recipient/RecipientWithoutStatus.js +45 -0
- package/dist/components/Recipient/RecipientsAvatars.js +100 -0
- package/dist/components/{RecipientsAvatars.spec.js → Recipient/RecipientsAvatars.spec.js} +43 -2
- package/dist/components/{recipient.styl → Recipient/recipient.styl} +6 -2
- package/dist/components/ShareAutosuggest.js +176 -252
- package/dist/components/ShareAutosuggest.spec.js +3 -2
- package/dist/components/ShareByEmail.js +142 -193
- package/dist/components/ShareByEmail.spec.js +42 -23
- package/dist/components/ShareByLink.js +251 -357
- package/dist/components/ShareDialogCozyToCozy.js +16 -4
- package/dist/components/ShareDialogCozyToCozy.spec.js +12 -1
- package/dist/components/ShareDialogOnlyByLink.js +23 -10
- package/dist/components/ShareDialogTwoStepsConfirmationContainer.js +7 -7
- package/dist/components/ShareModal.js +5 -1
- package/dist/components/ShareRecipientsInput.js +44 -128
- package/dist/components/WhoHasAccess.js +43 -5
- package/dist/components/WhoHasAccessLight.js +3 -19
- package/dist/components/autosuggest.styl +21 -36
- package/dist/helpers/documentType.js +6 -0
- package/dist/helpers/hooks.js +8 -1
- package/dist/helpers/link.js +5 -0
- package/dist/helpers/permissions.js +8 -0
- package/dist/helpers/recipients.js +24 -0
- package/dist/helpers/sharings.js +72 -53
- package/dist/helpers/synchronousJobQueue.js +67 -0
- package/dist/helpers/synchronousJobQueue.spec.js +97 -0
- package/dist/index.js +2 -1
- package/dist/queries/queries.js +72 -0
- package/dist/share.styl +0 -15
- package/dist/stylesheet.css +67 -92
- package/locales/en.json +29 -41
- package/locales/fr.json +26 -39
- package/package.json +10 -10
- package/src/SharedRecipients.jsx +1 -1
- package/src/SharedStatus.jsx +1 -1
- package/src/SharingBanner/hooks/useSharingInfos.jsx +1 -1
- package/src/SharingDetailsModal.jsx +1 -1
- package/src/SharingOwnerAvatar.jsx +1 -1
- package/src/SharingProvider.jsx +17 -4
- package/src/components/ContactSuggestion.jsx +25 -10
- package/src/components/EditLinkPermissionDialog.jsx +89 -0
- package/src/components/EditLinkPermissionDialog.spec.jsx +52 -0
- package/src/components/EditableSharingModal.jsx +58 -100
- package/src/components/{AvatarPlusX.jsx → Recipient/AvatarPlusX.jsx} +1 -1
- package/src/components/{Identity.jsx → Recipient/Identity.jsx} +0 -0
- package/src/components/Recipient/LinkRecipient.jsx +59 -0
- package/src/components/Recipient/LinkRecipientPermissions.jsx +157 -0
- package/src/components/Recipient/OwnerIdentity.jsx +20 -0
- package/src/components/Recipient/Recipient.jsx +79 -0
- package/src/components/{Recipient.spec.jsx → Recipient/Recipient.spec.jsx} +4 -42
- package/src/components/Recipient/RecipientAvatar.jsx +38 -0
- package/src/components/Recipient/RecipientConfirm.jsx +37 -0
- package/src/components/Recipient/RecipientPermissions.jsx +114 -0
- package/src/components/Recipient/RecipientPlusX.jsx +28 -0
- package/src/components/Recipient/RecipientStatus.jsx +48 -0
- package/src/components/Recipient/RecipientWithoutStatus.jsx +21 -0
- package/src/components/Recipient/RecipientsAvatars.jsx +108 -0
- package/src/components/{RecipientsAvatars.spec.jsx → Recipient/RecipientsAvatars.spec.jsx} +43 -2
- package/src/components/{recipient.styl → Recipient/recipient.styl} +6 -2
- package/src/components/ShareAutosuggest.jsx +136 -127
- package/src/components/ShareAutosuggest.spec.jsx +12 -8
- package/src/components/ShareByEmail.jsx +65 -90
- package/src/components/ShareByEmail.spec.jsx +39 -11
- package/src/components/ShareByLink.jsx +146 -238
- package/src/components/ShareDialogCozyToCozy.jsx +14 -2
- package/src/components/ShareDialogCozyToCozy.spec.jsx +8 -1
- package/src/components/ShareDialogOnlyByLink.jsx +30 -13
- package/src/components/ShareDialogTwoStepsConfirmationContainer.jsx +5 -5
- package/src/components/ShareModal.jsx +5 -1
- package/src/components/ShareRecipientsInput.jsx +30 -44
- package/src/components/WhoHasAccess.jsx +85 -27
- package/src/components/WhoHasAccessLight.jsx +2 -1
- package/src/components/__snapshots__/ContactSuggestion.spec.jsx.snap +915 -132
- package/src/components/__snapshots__/ShareRecipientsInput.spec.jsx.snap +86 -102
- package/src/components/autosuggest.styl +21 -36
- package/src/helpers/documentType.js +6 -0
- package/src/helpers/hooks.js +11 -1
- package/src/helpers/link.js +4 -0
- package/src/helpers/permissions.js +15 -0
- package/src/helpers/recipients.js +21 -0
- package/src/helpers/sharings.js +15 -12
- package/src/helpers/synchronousJobQueue.js +22 -0
- package/src/helpers/synchronousJobQueue.spec.js +75 -0
- package/src/index.jsx +1 -0
- package/src/queries/queries.js +75 -0
- package/src/share.styl +0 -15
- package/dist/SharingBanner/helpers/queries.js +0 -12
- package/dist/components/ContactsAndGroupsDataLoader.js +0 -50
- package/dist/components/Recipient.js +0 -450
- package/src/SharingBanner/helpers/queries.js +0 -14
- package/src/components/ContactsAndGroupsDataLoader.jsx +0 -30
- package/src/components/Recipient.jsx +0 -415
|
@@ -1,382 +1,276 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
import
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
10
4
|
|
|
11
5
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
12
6
|
|
|
13
7
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
14
8
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
18
|
-
|
|
19
|
-
import React from 'react';
|
|
9
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
10
|
+
import React, { useState, useEffect, useCallback } from 'react';
|
|
20
11
|
import PropTypes from 'prop-types';
|
|
21
12
|
import copy from 'copy-text-to-clipboard';
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import Button from 'cozy-ui/transpiled/react/Button';
|
|
25
|
-
import CompositeRow from 'cozy-ui/transpiled/react/CompositeRow';
|
|
26
|
-
import Circle from 'cozy-ui/transpiled/react/Circle';
|
|
13
|
+
import useBreakpoints from 'cozy-ui/transpiled/react/hooks/useBreakpoints';
|
|
14
|
+
import Button from 'cozy-ui/transpiled/react/Buttons';
|
|
27
15
|
import Icon from 'cozy-ui/transpiled/react/Icon';
|
|
28
|
-
import Radio from 'cozy-ui/transpiled/react/Radio';
|
|
29
|
-
import DropdownButton from 'cozy-ui/transpiled/react/DropdownButton';
|
|
30
|
-
import ActionMenu, { ActionMenuItem } from 'cozy-ui/transpiled/react/ActionMenu';
|
|
31
|
-
import { translate } from 'cozy-ui/transpiled/react/I18n';
|
|
32
|
-
import get from 'lodash/get';
|
|
33
|
-
import logger from '../logger';
|
|
34
|
-
var styles = {
|
|
35
|
-
"share-modal-content": "share__share-modal-content___XTtaK",
|
|
36
|
-
"coz-form": "share__coz-form___33NYF",
|
|
37
|
-
"coz-form-group": "share__coz-form-group___1PLAZ",
|
|
38
|
-
"coz-form-desc": "share__coz-form-desc___-pmK5",
|
|
39
|
-
"coz-form-label": "share__coz-form-label___31jb0",
|
|
40
|
-
"coz-form-label--error": "share__coz-form-label--error___2EXCl",
|
|
41
|
-
"coz-form-errors": "share__coz-form-errors___1rk2R",
|
|
42
|
-
"coz-form-controls": "share__coz-form-controls___39Uwg",
|
|
43
|
-
"coz-form-controls--full": "share__coz-form-controls--full___1YpNp",
|
|
44
|
-
"coz-form-controls--dispatch": "share__coz-form-controls--dispatch___3JXzz",
|
|
45
|
-
"error": "share__error___6Ycal",
|
|
46
|
-
"CozyTheme--inverted": "share__CozyTheme--inverted___2pLD2",
|
|
47
|
-
"CozyTheme--normal": "share__CozyTheme--normal___qSFyr",
|
|
48
|
-
"share-byemail-onlybylink": "share__share-byemail-onlybylink___C_7b_",
|
|
49
|
-
"aligned-dropdown-button": "share__aligned-dropdown-button___CeTDs",
|
|
50
|
-
"share-type-control": "share__share-type-control___KcpDf",
|
|
51
|
-
"select-wrapper": "share__select-wrapper___3FfiH",
|
|
52
|
-
"select-option": "share__select-option___13o6b",
|
|
53
|
-
"select-option-label": "share__select-option-label___Zj_RU",
|
|
54
|
-
"select-option-desc": "share__select-option-desc___6uaQq",
|
|
55
|
-
"share-details-created": "share__share-details-created___13BO0",
|
|
56
|
-
"share-details-perm": "share__share-details-perm___23_VF",
|
|
57
|
-
"share-details-perm-desc": "share__share-details-perm-desc___tqfXx",
|
|
58
|
-
"spin": "share__spin___1P7nU",
|
|
59
|
-
"shake": "share__shake___1EeCI"
|
|
60
|
-
};
|
|
61
16
|
import LinkIcon from 'cozy-ui/transpiled/react/Icons/Link';
|
|
62
|
-
import
|
|
63
|
-
import
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return permissionModel.isReadOnly(permissionCategory);
|
|
70
|
-
}).length > 0;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
var ShareByLink = /*#__PURE__*/function (_React$Component) {
|
|
74
|
-
_inherits(ShareByLink, _React$Component);
|
|
75
|
-
|
|
76
|
-
var _super = _createSuper(ShareByLink);
|
|
77
|
-
|
|
78
|
-
function ShareByLink(props) {
|
|
79
|
-
var _this;
|
|
80
|
-
|
|
81
|
-
_classCallCheck(this, ShareByLink);
|
|
82
|
-
|
|
83
|
-
_this = _super.call(this, props);
|
|
84
|
-
|
|
85
|
-
_defineProperty(_assertThisInitialized(_this), "toggleShareLink", function (checked) {
|
|
86
|
-
if (checked) {
|
|
87
|
-
_this.createShareLink();
|
|
88
|
-
} else {
|
|
89
|
-
_this.deleteShareLink();
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
_defineProperty(_assertThisInitialized(_this), "copyLinkToClipboard", function (_ref) {
|
|
94
|
-
var isAutomaticCopy = _ref.isAutomaticCopy;
|
|
95
|
-
if (copy(_this.props.link)) Alerter.success(_this.props.t("".concat(_this.props.documentType, ".share.shareByLink.copied")));else if (!isAutomaticCopy) // In case of automatic copy, the browser can block the copy request. This is not shown to the user since it is expected and can be circumvented by clicking directly on the copy link
|
|
96
|
-
Alerter.error(_this.props.t("".concat(_this.props.documentType, ".share.shareByLink.failed")));
|
|
97
|
-
});
|
|
17
|
+
import CopyIcon from 'cozy-ui/transpiled/react/Icons/Copy';
|
|
18
|
+
import Snackbar from 'cozy-ui/transpiled/react/Snackbar';
|
|
19
|
+
import Alert from 'cozy-ui/transpiled/react/Alert';
|
|
20
|
+
import { useI18n } from 'cozy-ui/transpiled/react/I18n';
|
|
21
|
+
import { isOnlyReadOnlyLinkAllowed } from '../helpers/link';
|
|
22
|
+
import EditLinkPermissionDialog from './EditLinkPermissionDialog';
|
|
23
|
+
import logger from '../logger';
|
|
98
24
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
25
|
+
var ShareByLink = function ShareByLink(_ref) {
|
|
26
|
+
var link = _ref.link,
|
|
27
|
+
document = _ref.document,
|
|
28
|
+
documentType = _ref.documentType,
|
|
29
|
+
onEnable = _ref.onEnable;
|
|
30
|
+
|
|
31
|
+
var _useI18n = useI18n(),
|
|
32
|
+
t = _useI18n.t;
|
|
33
|
+
|
|
34
|
+
var _useBreakpoints = useBreakpoints(),
|
|
35
|
+
isMobile = _useBreakpoints.isMobile;
|
|
36
|
+
|
|
37
|
+
var _useState = useState(false),
|
|
38
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
39
|
+
loading = _useState2[0],
|
|
40
|
+
setLoading = _useState2[1];
|
|
41
|
+
|
|
42
|
+
var _useState3 = useState(false),
|
|
43
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
44
|
+
shouldCopyToClipboard = _useState4[0],
|
|
45
|
+
setShouldCopyToClipboard = _useState4[1];
|
|
46
|
+
|
|
47
|
+
var _useState5 = useState(false),
|
|
48
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
49
|
+
alert = _useState6[0],
|
|
50
|
+
setAlert = _useState6[1];
|
|
51
|
+
|
|
52
|
+
var _useState7 = useState(false),
|
|
53
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
54
|
+
isEditDialogOpen = _useState8[0],
|
|
55
|
+
setIsEditDialogOpen = _useState8[1];
|
|
56
|
+
|
|
57
|
+
var copyLinkToClipboard = useCallback(function (_ref2) {
|
|
58
|
+
var isAutomaticCopy = _ref2.isAutomaticCopy;
|
|
59
|
+
|
|
60
|
+
if (copy(link)) {
|
|
61
|
+
setAlert({
|
|
62
|
+
open: true,
|
|
63
|
+
severity: 'success',
|
|
64
|
+
message: t("".concat(documentType, ".share.shareByLink.copied"))
|
|
65
|
+
});
|
|
66
|
+
} else if (!isAutomaticCopy) {
|
|
67
|
+
// In case of automatic copy, the browser can block the copy request. This is not shown to the user since it is expected and can be circumvented by clicking directly on the copy link
|
|
68
|
+
setAlert({
|
|
69
|
+
open: true,
|
|
70
|
+
severity: 'error',
|
|
71
|
+
message: t("".concat(documentType, ".share.shareByLink.failed"))
|
|
104
72
|
});
|
|
105
|
-
}
|
|
73
|
+
}
|
|
74
|
+
}, [documentType, link, t]);
|
|
75
|
+
|
|
76
|
+
var onPermissionsSelected = /*#__PURE__*/function () {
|
|
77
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
|
|
78
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
79
|
+
while (1) {
|
|
80
|
+
switch (_context.prev = _context.next) {
|
|
81
|
+
case 0:
|
|
82
|
+
_context.prev = 0;
|
|
83
|
+
setLoading(true);
|
|
84
|
+
_context.next = 4;
|
|
85
|
+
return onEnable(document, options);
|
|
86
|
+
|
|
87
|
+
case 4:
|
|
88
|
+
_context.next = 10;
|
|
89
|
+
break;
|
|
90
|
+
|
|
91
|
+
case 6:
|
|
92
|
+
_context.prev = 6;
|
|
93
|
+
_context.t0 = _context["catch"](0);
|
|
94
|
+
setAlert({
|
|
95
|
+
open: true,
|
|
96
|
+
severity: 'error',
|
|
97
|
+
message: t("".concat(documentType, ".share.error.generic"))
|
|
98
|
+
});
|
|
99
|
+
logger.log(_context.t0);
|
|
100
|
+
|
|
101
|
+
case 10:
|
|
102
|
+
_context.prev = 10;
|
|
103
|
+
setLoading(false);
|
|
104
|
+
setShouldCopyToClipboard(true);
|
|
105
|
+
return _context.finish(10);
|
|
106
|
+
|
|
107
|
+
case 14:
|
|
108
|
+
case "end":
|
|
109
|
+
return _context.stop();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}, _callee, null, [[0, 6, 10, 14]]);
|
|
113
|
+
}));
|
|
106
114
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
menuIsOpen: false
|
|
115
|
+
return function onPermissionsSelected(_x) {
|
|
116
|
+
return _ref3.apply(this, arguments);
|
|
110
117
|
};
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
this.setState(function (state) {
|
|
125
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
126
|
-
loading: true
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
_context.next = 4;
|
|
130
|
-
return this.props.onEnable(this.props.document);
|
|
131
|
-
|
|
132
|
-
case 4:
|
|
133
|
-
_context.next = 10;
|
|
134
|
-
break;
|
|
135
|
-
|
|
136
|
-
case 6:
|
|
137
|
-
_context.prev = 6;
|
|
138
|
-
_context.t0 = _context["catch"](0);
|
|
139
|
-
Alerter.error(this.props.t("".concat(this.props.documentType, ".share.error.generic")));
|
|
140
|
-
logger.log(_context.t0);
|
|
141
|
-
|
|
142
|
-
case 10:
|
|
143
|
-
_context.prev = 10;
|
|
144
|
-
this.setState(function (state) {
|
|
145
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
146
|
-
loading: false
|
|
147
|
-
});
|
|
118
|
+
}();
|
|
119
|
+
|
|
120
|
+
var onCreate = /*#__PURE__*/function () {
|
|
121
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
122
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
123
|
+
while (1) {
|
|
124
|
+
switch (_context2.prev = _context2.next) {
|
|
125
|
+
case 0:
|
|
126
|
+
if (isOnlyReadOnlyLinkAllowed({
|
|
127
|
+
documentType: documentType
|
|
128
|
+
})) {
|
|
129
|
+
onPermissionsSelected({
|
|
130
|
+
verbs: ['GET']
|
|
148
131
|
});
|
|
149
|
-
|
|
132
|
+
} else {
|
|
133
|
+
setIsEditDialogOpen(true);
|
|
134
|
+
}
|
|
150
135
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
136
|
+
case 1:
|
|
137
|
+
case "end":
|
|
138
|
+
return _context2.stop();
|
|
155
139
|
}
|
|
156
|
-
}
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
function createShareLink() {
|
|
160
|
-
return _createShareLink.apply(this, arguments);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return createShareLink;
|
|
164
|
-
}()
|
|
165
|
-
}, {
|
|
166
|
-
key: "deleteShareLink",
|
|
167
|
-
value: function () {
|
|
168
|
-
var _deleteShareLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
169
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
170
|
-
while (1) {
|
|
171
|
-
switch (_context2.prev = _context2.next) {
|
|
172
|
-
case 0:
|
|
173
|
-
_context2.prev = 0;
|
|
174
|
-
this.setState(function (state) {
|
|
175
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
176
|
-
loading: true
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
_context2.next = 4;
|
|
180
|
-
return this.props.onDisable(this.props.document);
|
|
181
|
-
|
|
182
|
-
case 4:
|
|
183
|
-
_context2.next = 10;
|
|
184
|
-
break;
|
|
185
|
-
|
|
186
|
-
case 6:
|
|
187
|
-
_context2.prev = 6;
|
|
188
|
-
_context2.t0 = _context2["catch"](0);
|
|
189
|
-
Alerter.error(this.props.t("".concat(this.props.documentType, ".share.error.revoke")));
|
|
190
|
-
logger.log(_context2.t0);
|
|
191
|
-
|
|
192
|
-
case 10:
|
|
193
|
-
_context2.prev = 10;
|
|
194
|
-
this.setState(function (state) {
|
|
195
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
196
|
-
loading: false
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
return _context2.finish(10);
|
|
140
|
+
}
|
|
141
|
+
}, _callee2);
|
|
142
|
+
}));
|
|
200
143
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
return deleteShareLink;
|
|
214
|
-
}()
|
|
215
|
-
}, {
|
|
216
|
-
key: "updateLinkPermissions",
|
|
217
|
-
value: function updateLinkPermissions(_ref2) {
|
|
218
|
-
var isReadOnly = _ref2.isReadOnly;
|
|
219
|
-
var _this$props = this.props,
|
|
220
|
-
document = _this$props.document,
|
|
221
|
-
documentType = _this$props.documentType,
|
|
222
|
-
onChangePermissions = _this$props.onChangePermissions,
|
|
223
|
-
t = _this$props.t;
|
|
224
|
-
var verbs = isReadOnly ? ['GET'] : ['GET', 'POST', 'PUT', 'PATCH'];
|
|
225
|
-
|
|
226
|
-
try {
|
|
227
|
-
onChangePermissions(document, verbs);
|
|
228
|
-
} catch (err) {
|
|
229
|
-
Alerter.error(t("".concat(documentType, ".share.shareByLink.permserror")));
|
|
230
|
-
logger.log(err);
|
|
231
|
-
}
|
|
144
|
+
return function onCreate() {
|
|
145
|
+
return _ref4.apply(this, arguments);
|
|
146
|
+
};
|
|
147
|
+
}();
|
|
148
|
+
|
|
149
|
+
useEffect(function () {
|
|
150
|
+
if (link && shouldCopyToClipboard) {
|
|
151
|
+
copyLinkToClipboard({
|
|
152
|
+
isAutomaticCopy: true
|
|
153
|
+
});
|
|
154
|
+
setShouldCopyToClipboard(false);
|
|
232
155
|
}
|
|
233
|
-
},
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
busy: loading,
|
|
282
|
-
label: t("".concat(documentType, ".share.shareByLink.create"))
|
|
283
|
-
})), checked && /*#__PURE__*/React.createElement(CompositeRow, {
|
|
284
|
-
className: "u-ph-0",
|
|
285
|
-
primaryText: /*#__PURE__*/React.createElement(Typography, {
|
|
286
|
-
onClick: this.copyLinkToClipboard,
|
|
287
|
-
className: "u-c-pointer",
|
|
288
|
-
variant: "body1"
|
|
289
|
-
}, t("".concat(documentType, ".share.shareByLink.activated"))),
|
|
290
|
-
secondaryText: /*#__PURE__*/React.createElement(Typography, {
|
|
291
|
-
className: "u-primaryColor u-fz-tiny u-c-pointer",
|
|
292
|
-
onClick: this.copyLinkToClipboard,
|
|
293
|
-
variant: "body1"
|
|
294
|
-
}, t("".concat(documentType, ".share.shareByLink.copy"))),
|
|
295
|
-
image: /*#__PURE__*/React.createElement(Circle, {
|
|
296
|
-
backgroundColor: "var(--silver)"
|
|
297
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
298
|
-
icon: LinkIcon,
|
|
299
|
-
color: "var(--charcoalGrey)"
|
|
300
|
-
})),
|
|
301
|
-
right: /*#__PURE__*/React.createElement("div", {
|
|
302
|
-
ref: this.containerRef
|
|
303
|
-
}, /*#__PURE__*/React.createElement(DropdownButton, {
|
|
304
|
-
onClick: this.toggleMenu
|
|
305
|
-
}, /*#__PURE__*/React.createElement(Typography, {
|
|
306
|
-
variant: "body1"
|
|
307
|
-
}, t("".concat(documentType, ".share.shareByLink.").concat(hasReadOnlyPermissions ? 'ro' : 'rw')))), menuIsOpen && /*#__PURE__*/React.createElement(ActionMenu, {
|
|
308
|
-
onClose: this.toggleMenu,
|
|
309
|
-
popperOptions: _objectSpread(_objectSpread({}, popperOptions), {}, {
|
|
310
|
-
placement: 'bottom-end'
|
|
311
|
-
}),
|
|
312
|
-
containerElRef: this.containerRef,
|
|
313
|
-
anchorElRef: this.containerRef
|
|
314
|
-
}, /*#__PURE__*/React.createElement(ActionMenuItem, {
|
|
315
|
-
left: /*#__PURE__*/React.createElement(Radio, {
|
|
316
|
-
name: "permissions",
|
|
317
|
-
value: "ro",
|
|
318
|
-
className: "u-w-1 u-h-1",
|
|
319
|
-
checked: hasReadOnlyPermissions,
|
|
320
|
-
readOnly: true
|
|
321
|
-
}),
|
|
322
|
-
onClick: function onClick() {
|
|
323
|
-
_this2.toggleMenu();
|
|
324
|
-
|
|
325
|
-
_this2.updateLinkPermissions({
|
|
326
|
-
isReadOnly: true
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
}, /*#__PURE__*/React.createElement(React.Fragment, null, t("".concat(documentType, ".share.shareByLink.ro")), /*#__PURE__*/React.createElement(Typography, {
|
|
330
|
-
className: "u-mt-half",
|
|
331
|
-
variant: "caption",
|
|
332
|
-
color: "textSecondary"
|
|
333
|
-
}, t("".concat(documentType, ".share.shareByLink.desc.ro"))))), /*#__PURE__*/React.createElement(ActionMenuItem, {
|
|
334
|
-
left: /*#__PURE__*/React.createElement(Radio, {
|
|
335
|
-
name: "permissions",
|
|
336
|
-
value: "rw",
|
|
337
|
-
className: "u-w-1 u-h-1",
|
|
338
|
-
checked: !hasReadOnlyPermissions,
|
|
339
|
-
readOnly: true
|
|
340
|
-
}),
|
|
341
|
-
onClick: function onClick() {
|
|
342
|
-
_this2.toggleMenu();
|
|
343
|
-
|
|
344
|
-
_this2.updateLinkPermissions({
|
|
345
|
-
isReadOnly: false
|
|
346
|
-
});
|
|
156
|
+
}, [link, shouldCopyToClipboard, copyLinkToClipboard]);
|
|
157
|
+
|
|
158
|
+
var onClose = function onClose() {
|
|
159
|
+
setIsEditDialogOpen(false);
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
var onCloseAlert = function onCloseAlert() {
|
|
163
|
+
setAlert(_objectSpread(_objectSpread({}, alert), {}, {
|
|
164
|
+
open: false
|
|
165
|
+
}));
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
var showCopyAndSendButtons = link && isMobile && navigator.share;
|
|
169
|
+
var showOnlyCopyButton = link && !isMobile || link && isMobile && !navigator.share;
|
|
170
|
+
|
|
171
|
+
var shareLink = /*#__PURE__*/function () {
|
|
172
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
173
|
+
var shareData;
|
|
174
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
175
|
+
while (1) {
|
|
176
|
+
switch (_context3.prev = _context3.next) {
|
|
177
|
+
case 0:
|
|
178
|
+
_context3.prev = 0;
|
|
179
|
+
shareData = {
|
|
180
|
+
text: t("".concat(documentType, ".share.shareByLink.shareDescription"), {
|
|
181
|
+
name: document.name || ''
|
|
182
|
+
}),
|
|
183
|
+
url: link
|
|
184
|
+
};
|
|
185
|
+
_context3.next = 4;
|
|
186
|
+
return navigator.share(shareData);
|
|
187
|
+
|
|
188
|
+
case 4:
|
|
189
|
+
_context3.next = 9;
|
|
190
|
+
break;
|
|
191
|
+
|
|
192
|
+
case 6:
|
|
193
|
+
_context3.prev = 6;
|
|
194
|
+
_context3.t0 = _context3["catch"](0);
|
|
195
|
+
setAlert({
|
|
196
|
+
open: true,
|
|
197
|
+
severity: 'error',
|
|
198
|
+
message: t("".concat(documentType, ".share.error.generic"))
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
case 9:
|
|
202
|
+
case "end":
|
|
203
|
+
return _context3.stop();
|
|
347
204
|
}
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
color: "textSecondary"
|
|
352
|
-
}, t("".concat(documentType, ".share.shareByLink.desc.rw"))))), /*#__PURE__*/React.createElement("hr", null), /*#__PURE__*/React.createElement(ActionMenuItem, {
|
|
353
|
-
left: /*#__PURE__*/React.createElement(Icon, {
|
|
354
|
-
icon: TrashIcon,
|
|
355
|
-
color: "var(--errorColor)"
|
|
356
|
-
}),
|
|
357
|
-
onClick: function onClick() {
|
|
358
|
-
_this2.toggleMenu();
|
|
359
|
-
|
|
360
|
-
_this2.deleteShareLink();
|
|
361
|
-
}
|
|
362
|
-
}, /*#__PURE__*/React.createElement(Typography, {
|
|
363
|
-
className: "u-error",
|
|
364
|
-
variant: "body1"
|
|
365
|
-
}, t("".concat(documentType, ".share.shareByLink.deactivate"))))))
|
|
366
|
-
}));
|
|
367
|
-
}
|
|
368
|
-
}]);
|
|
205
|
+
}
|
|
206
|
+
}, _callee3, null, [[0, 6]]);
|
|
207
|
+
}));
|
|
369
208
|
|
|
370
|
-
|
|
371
|
-
|
|
209
|
+
return function shareLink() {
|
|
210
|
+
return _ref5.apply(this, arguments);
|
|
211
|
+
};
|
|
212
|
+
}();
|
|
213
|
+
|
|
214
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
215
|
+
className: "u-w-100 u-flex u-flex-justify-center"
|
|
216
|
+
}, !link && /*#__PURE__*/React.createElement(Button, {
|
|
217
|
+
label: t("".concat(documentType, ".share.shareByLink.create")),
|
|
218
|
+
variant: "secondary",
|
|
219
|
+
size: "medium",
|
|
220
|
+
startIcon: /*#__PURE__*/React.createElement(Icon, {
|
|
221
|
+
icon: LinkIcon
|
|
222
|
+
}),
|
|
223
|
+
className: "u-flex-auto",
|
|
224
|
+
busy: loading,
|
|
225
|
+
style: {
|
|
226
|
+
position: 'initial'
|
|
227
|
+
} // fix z-index bug on iOS when under a BottomDrawer due to relative position
|
|
228
|
+
,
|
|
229
|
+
onClick: onCreate
|
|
230
|
+
}), showCopyAndSendButtons && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
|
|
231
|
+
label: t("".concat(documentType, ".share.shareByLink.send")),
|
|
232
|
+
variant: "secondary",
|
|
233
|
+
size: "medium",
|
|
234
|
+
startIcon: /*#__PURE__*/React.createElement(Icon, {
|
|
235
|
+
icon: LinkIcon
|
|
236
|
+
}),
|
|
237
|
+
className: "u-flex-auto u-mr-half",
|
|
238
|
+
onClick: shareLink
|
|
239
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
240
|
+
label: /*#__PURE__*/React.createElement(Icon, {
|
|
241
|
+
icon: CopyIcon
|
|
242
|
+
}),
|
|
243
|
+
variant: "secondary",
|
|
244
|
+
size: "medium",
|
|
245
|
+
onClick: copyLinkToClipboard
|
|
246
|
+
})), showOnlyCopyButton && /*#__PURE__*/React.createElement(Button, {
|
|
247
|
+
label: t("".concat(documentType, ".share.shareByLink.copy")),
|
|
248
|
+
variant: "secondary",
|
|
249
|
+
size: "medium",
|
|
250
|
+
startIcon: /*#__PURE__*/React.createElement(Icon, {
|
|
251
|
+
icon: LinkIcon
|
|
252
|
+
}),
|
|
253
|
+
className: "u-flex-auto u-mr-half",
|
|
254
|
+
onClick: copyLinkToClipboard
|
|
255
|
+
}), isEditDialogOpen && /*#__PURE__*/React.createElement(EditLinkPermissionDialog, {
|
|
256
|
+
open: true,
|
|
257
|
+
onClose: onClose,
|
|
258
|
+
document: document,
|
|
259
|
+
onPermissionsSelected: onPermissionsSelected
|
|
260
|
+
}), /*#__PURE__*/React.createElement(Snackbar, {
|
|
261
|
+
open: alert.open,
|
|
262
|
+
onClose: onCloseAlert
|
|
263
|
+
}, /*#__PURE__*/React.createElement(Alert, {
|
|
264
|
+
variant: "filled",
|
|
265
|
+
severity: alert.severity,
|
|
266
|
+
onClose: onCloseAlert
|
|
267
|
+
}, alert.message)));
|
|
268
|
+
};
|
|
372
269
|
|
|
373
270
|
ShareByLink.propTypes = {
|
|
374
|
-
|
|
375
|
-
checked: PropTypes.bool.isRequired,
|
|
376
|
-
documentType: PropTypes.string.isRequired,
|
|
271
|
+
link: PropTypes.string,
|
|
377
272
|
document: PropTypes.object.isRequired,
|
|
378
|
-
|
|
379
|
-
onEnable: PropTypes.func.isRequired
|
|
380
|
-
onDisable: PropTypes.func.isRequired
|
|
273
|
+
documentType: PropTypes.string.isRequired,
|
|
274
|
+
onEnable: PropTypes.func.isRequired
|
|
381
275
|
};
|
|
382
|
-
export default
|
|
276
|
+
export default ShareByLink;
|