cozy-sharing 10.1.3 → 10.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.
- package/CHANGELOG.md +24 -0
- package/dist/ShareModal.js +1 -1
- package/dist/SharingProvider.js +18 -7
- package/dist/components/Recipient/OwnerRecipientDefault.js +2 -2
- package/dist/components/ShareAutosuggest.js +4 -4
- package/dist/components/ShareByLink.js +75 -50
- package/dist/components/Tooltip.js +17 -6
- package/package.json +3 -4
- package/src/components/ShareByLink.jsx +12 -10
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,30 @@
|
|
|
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
|
+
# 10.2.0 (2024-02-01)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Use navigator.clipboard instead of copy-text-to-clipboard ([6727c26](https://github.com/cozy/cozy-libs/commit/6727c26eaa796735d51300756ff617f999cc56dd))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* Remove copy-text-to-clipboard package ([53e46c8](https://github.com/cozy/cozy-libs/commit/53e46c8dedf33cca5f3a13be6d9d230bfaffa335))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [10.1.4](https://github.com/cozy/cozy-libs/compare/cozy-sharing@10.1.3...cozy-sharing@10.1.4) (2024-01-05)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package cozy-sharing
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
6
30
|
## [10.1.3](https://github.com/cozy/cozy-libs/compare/cozy-sharing@10.1.2...cozy-sharing@10.1.3) (2024-01-05)
|
|
7
31
|
|
|
8
32
|
**Note:** Version bump only for package cozy-sharing
|
package/dist/ShareModal.js
CHANGED
|
@@ -34,7 +34,7 @@ export var ShareModal = withLocales(function (props) {
|
|
|
34
34
|
var _location$state;
|
|
35
35
|
|
|
36
36
|
var location = useLocation === null || useLocation === void 0 ? void 0 : useLocation();
|
|
37
|
-
var locationProps = location === null || location === void 0
|
|
37
|
+
var locationProps = location === null || location === void 0 || (_location$state = location.state) === null || _location$state === void 0 ? void 0 : _location$state.modalProps;
|
|
38
38
|
var document = (locationProps === null || locationProps === void 0 ? void 0 : locationProps.document) || props.document;
|
|
39
39
|
var rest = omit(locationProps || props, 'document');
|
|
40
40
|
return /*#__PURE__*/React.createElement(SharingContext.Consumer, null, function (_ref3) {
|
package/dist/SharingProvider.js
CHANGED
|
@@ -3,10 +3,10 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
3
3
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
4
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
5
5
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
6
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
7
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
8
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
9
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
9
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
10
10
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
11
11
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
12
12
|
|
|
@@ -14,9 +14,22 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
14
14
|
|
|
15
15
|
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; }
|
|
16
16
|
|
|
17
|
-
function
|
|
17
|
+
function _callSuper(_this, derived, args) {
|
|
18
|
+
function isNativeReflectConstruct() {
|
|
19
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
20
|
+
if (Reflect.construct.sham) return false;
|
|
21
|
+
if (typeof Proxy === "function") return true;
|
|
18
22
|
|
|
19
|
-
|
|
23
|
+
try {
|
|
24
|
+
return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
25
|
+
} catch (e) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
derived = _getPrototypeOf(derived);
|
|
31
|
+
return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args));
|
|
32
|
+
}
|
|
20
33
|
|
|
21
34
|
import React, { Component } from 'react';
|
|
22
35
|
import { withClient } from 'cozy-client';
|
|
@@ -32,14 +45,12 @@ var PERMISSION_DOCTYPE = 'io.cozy.permissions';
|
|
|
32
45
|
export var SharingProvider = /*#__PURE__*/function (_Component) {
|
|
33
46
|
_inherits(SharingProvider, _Component);
|
|
34
47
|
|
|
35
|
-
var _super = _createSuper(SharingProvider);
|
|
36
|
-
|
|
37
48
|
function SharingProvider(props, context) {
|
|
38
49
|
var _this;
|
|
39
50
|
|
|
40
51
|
_classCallCheck(this, SharingProvider);
|
|
41
52
|
|
|
42
|
-
_this =
|
|
53
|
+
_this = _callSuper(this, SharingProvider, [props, context]);
|
|
43
54
|
|
|
44
55
|
_defineProperty(_assertThisInitialized(_this), "dispatch", function (action) {
|
|
45
56
|
return _this.setState(function (state) {
|
|
@@ -4,7 +4,7 @@ import Recipient from './Recipient';
|
|
|
4
4
|
import { buildInstanceSettingsQuery } from '../../queries/queries';
|
|
5
5
|
|
|
6
6
|
var OwnerRecipientDefault = function OwnerRecipientDefault() {
|
|
7
|
-
var _instanceSettingsResu
|
|
7
|
+
var _instanceSettingsResu;
|
|
8
8
|
|
|
9
9
|
var client = useClient();
|
|
10
10
|
var instanceSettingsQuery = buildInstanceSettingsQuery();
|
|
@@ -13,7 +13,7 @@ var OwnerRecipientDefault = function OwnerRecipientDefault() {
|
|
|
13
13
|
isOwner: true,
|
|
14
14
|
status: "owner",
|
|
15
15
|
instance: client.options.uri,
|
|
16
|
-
public_name: instanceSettingsResult === null || instanceSettingsResult === void 0
|
|
16
|
+
public_name: instanceSettingsResult === null || instanceSettingsResult === void 0 || (_instanceSettingsResu = instanceSettingsResult.data) === null || _instanceSettingsResu === void 0 || (_instanceSettingsResu = _instanceSettingsResu.attributes) === null || _instanceSettingsResu === void 0 ? void 0 : _instanceSettingsResu.public_name
|
|
17
17
|
});
|
|
18
18
|
};
|
|
19
19
|
|
|
@@ -132,18 +132,18 @@ var ShareAutocomplete = function ShareAutocomplete(_ref) {
|
|
|
132
132
|
};
|
|
133
133
|
|
|
134
134
|
var onAutosuggestPick = function onAutosuggestPick(value) {
|
|
135
|
-
var _autosuggestRef$curre
|
|
135
|
+
var _autosuggestRef$curre;
|
|
136
136
|
|
|
137
137
|
onPick(value);
|
|
138
138
|
setInputValue('');
|
|
139
|
-
autosuggestRef === null || autosuggestRef === void 0
|
|
139
|
+
autosuggestRef === null || autosuggestRef === void 0 || (_autosuggestRef$curre = autosuggestRef.current) === null || _autosuggestRef$curre === void 0 || (_autosuggestRef$curre = _autosuggestRef$curre.input) === null || _autosuggestRef$curre === void 0 || _autosuggestRef$curre.focus();
|
|
140
140
|
};
|
|
141
141
|
|
|
142
142
|
var onAutosuggestRemove = function onAutosuggestRemove(value) {
|
|
143
|
-
var _autosuggestRef$
|
|
143
|
+
var _autosuggestRef$curre2;
|
|
144
144
|
|
|
145
145
|
onRemove(value);
|
|
146
|
-
autosuggestRef === null || autosuggestRef === void 0
|
|
146
|
+
autosuggestRef === null || autosuggestRef === void 0 || (_autosuggestRef$curre2 = autosuggestRef.current) === null || _autosuggestRef$curre2 === void 0 || (_autosuggestRef$curre2 = _autosuggestRef$curre2.input) === null || _autosuggestRef$curre2 === void 0 || _autosuggestRef$curre2.focus();
|
|
147
147
|
};
|
|
148
148
|
|
|
149
149
|
var renderInput = function renderInput(inputProps) {
|
|
@@ -7,7 +7,6 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
7
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; }
|
|
8
8
|
|
|
9
9
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
10
|
-
import copy from 'copy-text-to-clipboard';
|
|
11
10
|
import PropTypes from 'prop-types';
|
|
12
11
|
import React, { useState, useEffect, useCallback } from 'react';
|
|
13
12
|
import Alert from 'cozy-ui/transpiled/react/Alert';
|
|
@@ -54,71 +53,97 @@ var ShareByLink = function ShareByLink(_ref) {
|
|
|
54
53
|
isEditDialogOpen = _useState8[0],
|
|
55
54
|
setIsEditDialogOpen = _useState8[1];
|
|
56
55
|
|
|
57
|
-
var copyLinkToClipboard = useCallback(function (
|
|
58
|
-
var
|
|
56
|
+
var copyLinkToClipboard = useCallback( /*#__PURE__*/function () {
|
|
57
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref2) {
|
|
58
|
+
var isAutomaticCopy;
|
|
59
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
60
|
+
while (1) switch (_context.prev = _context.next) {
|
|
61
|
+
case 0:
|
|
62
|
+
isAutomaticCopy = _ref2.isAutomaticCopy;
|
|
63
|
+
_context.prev = 1;
|
|
64
|
+
_context.next = 4;
|
|
65
|
+
return navigator.clipboard.writeText(link);
|
|
59
66
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
67
|
+
case 4:
|
|
68
|
+
setAlert({
|
|
69
|
+
open: true,
|
|
70
|
+
severity: 'success',
|
|
71
|
+
message: t("".concat(documentType, ".share.shareByLink.copied"))
|
|
72
|
+
});
|
|
73
|
+
_context.next = 10;
|
|
74
|
+
break;
|
|
75
|
+
|
|
76
|
+
case 7:
|
|
77
|
+
_context.prev = 7;
|
|
78
|
+
_context.t0 = _context["catch"](1);
|
|
79
|
+
|
|
80
|
+
if (!isAutomaticCopy) {
|
|
81
|
+
// 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
|
|
82
|
+
setAlert({
|
|
83
|
+
open: true,
|
|
84
|
+
severity: 'error',
|
|
85
|
+
message: t("".concat(documentType, ".share.shareByLink.failed"))
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
case 10:
|
|
90
|
+
case "end":
|
|
91
|
+
return _context.stop();
|
|
92
|
+
}
|
|
93
|
+
}, _callee, null, [[1, 7]]);
|
|
94
|
+
}));
|
|
95
|
+
|
|
96
|
+
return function (_x) {
|
|
97
|
+
return _ref3.apply(this, arguments);
|
|
98
|
+
};
|
|
99
|
+
}(), [documentType, link, t]);
|
|
75
100
|
|
|
76
101
|
var onPermissionsSelected = /*#__PURE__*/function () {
|
|
77
|
-
var
|
|
78
|
-
return _regeneratorRuntime.wrap(function
|
|
79
|
-
while (1) switch (
|
|
102
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(options) {
|
|
103
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
104
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
80
105
|
case 0:
|
|
81
|
-
|
|
106
|
+
_context2.prev = 0;
|
|
82
107
|
setLoading(true);
|
|
83
|
-
|
|
108
|
+
_context2.next = 4;
|
|
84
109
|
return onEnable(document, options);
|
|
85
110
|
|
|
86
111
|
case 4:
|
|
87
|
-
|
|
112
|
+
_context2.next = 10;
|
|
88
113
|
break;
|
|
89
114
|
|
|
90
115
|
case 6:
|
|
91
|
-
|
|
92
|
-
|
|
116
|
+
_context2.prev = 6;
|
|
117
|
+
_context2.t0 = _context2["catch"](0);
|
|
93
118
|
setAlert({
|
|
94
119
|
open: true,
|
|
95
120
|
severity: 'error',
|
|
96
121
|
message: t("".concat(documentType, ".share.error.generic"))
|
|
97
122
|
});
|
|
98
|
-
logger.log(
|
|
123
|
+
logger.log(_context2.t0);
|
|
99
124
|
|
|
100
125
|
case 10:
|
|
101
|
-
|
|
126
|
+
_context2.prev = 10;
|
|
102
127
|
setLoading(false);
|
|
103
128
|
setShouldCopyToClipboard(true);
|
|
104
|
-
return
|
|
129
|
+
return _context2.finish(10);
|
|
105
130
|
|
|
106
131
|
case 14:
|
|
107
132
|
case "end":
|
|
108
|
-
return
|
|
133
|
+
return _context2.stop();
|
|
109
134
|
}
|
|
110
|
-
},
|
|
135
|
+
}, _callee2, null, [[0, 6, 10, 14]]);
|
|
111
136
|
}));
|
|
112
137
|
|
|
113
|
-
return function onPermissionsSelected(
|
|
114
|
-
return
|
|
138
|
+
return function onPermissionsSelected(_x2) {
|
|
139
|
+
return _ref4.apply(this, arguments);
|
|
115
140
|
};
|
|
116
141
|
}();
|
|
117
142
|
|
|
118
143
|
var onCreate = /*#__PURE__*/function () {
|
|
119
|
-
var
|
|
120
|
-
return _regeneratorRuntime.wrap(function
|
|
121
|
-
while (1) switch (
|
|
144
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
145
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
146
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
122
147
|
case 0:
|
|
123
148
|
if (isOnlyReadOnlyLinkAllowed({
|
|
124
149
|
documentType: documentType
|
|
@@ -132,13 +157,13 @@ var ShareByLink = function ShareByLink(_ref) {
|
|
|
132
157
|
|
|
133
158
|
case 1:
|
|
134
159
|
case "end":
|
|
135
|
-
return
|
|
160
|
+
return _context3.stop();
|
|
136
161
|
}
|
|
137
|
-
},
|
|
162
|
+
}, _callee3);
|
|
138
163
|
}));
|
|
139
164
|
|
|
140
165
|
return function onCreate() {
|
|
141
|
-
return
|
|
166
|
+
return _ref5.apply(this, arguments);
|
|
142
167
|
};
|
|
143
168
|
}();
|
|
144
169
|
|
|
@@ -165,28 +190,28 @@ var ShareByLink = function ShareByLink(_ref) {
|
|
|
165
190
|
var showOnlyCopyButton = link && !isMobile || link && isMobile && !navigator.share;
|
|
166
191
|
|
|
167
192
|
var shareLink = /*#__PURE__*/function () {
|
|
168
|
-
var
|
|
193
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
169
194
|
var shareData;
|
|
170
|
-
return _regeneratorRuntime.wrap(function
|
|
171
|
-
while (1) switch (
|
|
195
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
196
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
172
197
|
case 0:
|
|
173
|
-
|
|
198
|
+
_context4.prev = 0;
|
|
174
199
|
shareData = {
|
|
175
200
|
text: t("".concat(documentType, ".share.shareByLink.shareDescription"), {
|
|
176
201
|
name: document.name || ''
|
|
177
202
|
}),
|
|
178
203
|
url: link
|
|
179
204
|
};
|
|
180
|
-
|
|
205
|
+
_context4.next = 4;
|
|
181
206
|
return navigator.share(shareData);
|
|
182
207
|
|
|
183
208
|
case 4:
|
|
184
|
-
|
|
209
|
+
_context4.next = 9;
|
|
185
210
|
break;
|
|
186
211
|
|
|
187
212
|
case 6:
|
|
188
|
-
|
|
189
|
-
|
|
213
|
+
_context4.prev = 6;
|
|
214
|
+
_context4.t0 = _context4["catch"](0);
|
|
190
215
|
setAlert({
|
|
191
216
|
open: true,
|
|
192
217
|
severity: 'error',
|
|
@@ -195,13 +220,13 @@ var ShareByLink = function ShareByLink(_ref) {
|
|
|
195
220
|
|
|
196
221
|
case 9:
|
|
197
222
|
case "end":
|
|
198
|
-
return
|
|
223
|
+
return _context4.stop();
|
|
199
224
|
}
|
|
200
|
-
},
|
|
225
|
+
}, _callee4, null, [[0, 6]]);
|
|
201
226
|
}));
|
|
202
227
|
|
|
203
228
|
return function shareLink() {
|
|
204
|
-
return
|
|
229
|
+
return _ref6.apply(this, arguments);
|
|
205
230
|
};
|
|
206
231
|
}();
|
|
207
232
|
|
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
3
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
4
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
6
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
7
|
import _extends from "@babel/runtime/helpers/extends";
|
|
8
8
|
|
|
9
|
-
function
|
|
9
|
+
function _callSuper(_this, derived, args) {
|
|
10
|
+
function isNativeReflectConstruct() {
|
|
11
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
12
|
+
if (Reflect.construct.sham) return false;
|
|
13
|
+
if (typeof Proxy === "function") return true;
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
17
|
+
} catch (e) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
10
21
|
|
|
11
|
-
|
|
22
|
+
derived = _getPrototypeOf(derived);
|
|
23
|
+
return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args));
|
|
24
|
+
}
|
|
12
25
|
|
|
13
26
|
import PropTypes from 'prop-types';
|
|
14
27
|
import React from 'react';
|
|
@@ -28,12 +41,10 @@ export var SharingTooltip = function SharingTooltip(props) {
|
|
|
28
41
|
export var TooltipRecipientList = /*#__PURE__*/function (_React$Component) {
|
|
29
42
|
_inherits(TooltipRecipientList, _React$Component);
|
|
30
43
|
|
|
31
|
-
var _super = _createSuper(TooltipRecipientList);
|
|
32
|
-
|
|
33
44
|
function TooltipRecipientList() {
|
|
34
45
|
_classCallCheck(this, TooltipRecipientList);
|
|
35
46
|
|
|
36
|
-
return
|
|
47
|
+
return _callSuper(this, TooltipRecipientList, arguments);
|
|
37
48
|
}
|
|
38
49
|
|
|
39
50
|
_createClass(TooltipRecipientList, [{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-sharing",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.2.0",
|
|
4
4
|
"description": "Provides sharing login for React applications.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "Cozy",
|
|
@@ -27,9 +27,8 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@cozy/minilog": "^1.0.0",
|
|
29
29
|
"classnames": "^2.2.6",
|
|
30
|
-
"copy-text-to-clipboard": "^2.1.1",
|
|
31
30
|
"cozy-device-helper": "^3.0.0",
|
|
32
|
-
"cozy-doctypes": "^1.89.
|
|
31
|
+
"cozy-doctypes": "^1.89.4",
|
|
33
32
|
"lodash": "^4.17.19",
|
|
34
33
|
"react-autosuggest": "^10.1.0",
|
|
35
34
|
"react-tooltip": "^3.11.1",
|
|
@@ -61,5 +60,5 @@
|
|
|
61
60
|
"sideEffects": [
|
|
62
61
|
"*.css"
|
|
63
62
|
],
|
|
64
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "b90bf90c604284a0f77a89ed394ee3a9b25be889"
|
|
65
64
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import copy from 'copy-text-to-clipboard'
|
|
2
1
|
import PropTypes from 'prop-types'
|
|
3
2
|
import React, { useState, useEffect, useCallback } from 'react'
|
|
4
3
|
|
|
@@ -25,20 +24,23 @@ const ShareByLink = ({ link, document, documentType, onEnable }) => {
|
|
|
25
24
|
const [isEditDialogOpen, setIsEditDialogOpen] = useState(false)
|
|
26
25
|
|
|
27
26
|
const copyLinkToClipboard = useCallback(
|
|
28
|
-
({ isAutomaticCopy }) => {
|
|
29
|
-
|
|
27
|
+
async ({ isAutomaticCopy }) => {
|
|
28
|
+
try {
|
|
29
|
+
await navigator.clipboard.writeText(link)
|
|
30
30
|
setAlert({
|
|
31
31
|
open: true,
|
|
32
32
|
severity: 'success',
|
|
33
33
|
message: t(`${documentType}.share.shareByLink.copied`)
|
|
34
34
|
})
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
} catch {
|
|
36
|
+
if (!isAutomaticCopy) {
|
|
37
|
+
// 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
|
|
38
|
+
setAlert({
|
|
39
|
+
open: true,
|
|
40
|
+
severity: 'error',
|
|
41
|
+
message: t(`${documentType}.share.shareByLink.failed`)
|
|
42
|
+
})
|
|
43
|
+
}
|
|
42
44
|
}
|
|
43
45
|
},
|
|
44
46
|
[documentType, link, t]
|