cozy-sharing 16.16.0 → 17.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 +28 -0
- package/dist/OpenSharingLinkButton.js +7 -2
- package/dist/OpenSharingLinkFabButton.js +6 -2
- package/dist/actions/openSharingLink.js +3 -0
- package/dist/actions/shareNative.js +50 -0
- package/dist/components/SharingBanner/components/PublicBanner.js +9 -3
- package/dist/helpers/sharings.js +10 -3
- package/dist/index.js +3 -1
- package/dist/providers/NativeFileSharingProvider.js +95 -0
- package/locales/en.json +5 -4
- package/locales/fr.json +5 -4
- package/package.json +4 -2
- package/src/OpenSharingLinkButton.jsx +5 -1
- package/src/OpenSharingLinkFabButton.jsx +5 -1
- package/src/actions/openSharingLink.js +2 -0
- package/src/actions/shareNative.js +52 -0
- package/src/components/SharingBanner/components/PublicBanner.jsx +3 -3
- package/src/helpers/sharings.js +20 -4
- package/src/index.jsx +5 -0
- package/src/providers/NativeFileSharingProvider.jsx +47 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,34 @@
|
|
|
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
|
+
# [17.0.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@16.17.0...cozy-sharing@17.0.0) (2024-12-18)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Add NativeFileSharingProvider and shareNative action ([71ba4e1](https://github.com/cozy/cozy-libs/commit/71ba4e120a5518534867cd1f1541502652f9b979))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### BREAKING CHANGES
|
|
15
|
+
|
|
16
|
+
* you now need cozy-intent >=2.29.1
|
|
17
|
+
and cozy-device-helper >= 3.7.1 with cozy-sharing
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# [16.17.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@16.16.0...cozy-sharing@16.17.0) (2024-12-12)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Features
|
|
27
|
+
|
|
28
|
+
* **cozy-sharing:** Add isShortLabel prop to OpenSharing's buttons ([1085567](https://github.com/cozy/cozy-libs/commit/108556765800f6972a6b4c801fa09fd7c5d08c65))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
6
34
|
# [16.16.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@16.15.1...cozy-sharing@16.16.0) (2024-12-12)
|
|
7
35
|
|
|
8
36
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["link", "isSharingShortcutCreated"];
|
|
3
|
+
var _excluded = ["link", "isSharingShortcutCreated", "isShortLabel"];
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import Button from 'cozy-ui/transpiled/react/Buttons';
|
|
@@ -15,6 +15,7 @@ import withLocales from './hoc/withLocales';
|
|
|
15
15
|
* @param {Object} props - The props for the component.
|
|
16
16
|
* @param {string} props.link - The URL to be opened when the button is clicked.
|
|
17
17
|
* @param {boolean} [props.isSharingShortcutCreated=false] - Indicates if a sharing shortcut has been created. (default false)
|
|
18
|
+
* @param {boolean} [props.isShortLabel] - Display a short label for the button.
|
|
18
19
|
* @param {Object} [props] - Additional props to be passed to the Button component.
|
|
19
20
|
*/
|
|
20
21
|
|
|
@@ -22,6 +23,8 @@ var OpenSharingLinkButton = function OpenSharingLinkButton(_ref) {
|
|
|
22
23
|
var link = _ref.link,
|
|
23
24
|
_ref$isSharingShortcu = _ref.isSharingShortcutCreated,
|
|
24
25
|
isSharingShortcutCreated = _ref$isSharingShortcu === void 0 ? false : _ref$isSharingShortcu,
|
|
26
|
+
_ref$isShortLabel = _ref.isShortLabel,
|
|
27
|
+
isShortLabel = _ref$isShortLabel === void 0 ? false : _ref$isShortLabel,
|
|
25
28
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
26
29
|
|
|
27
30
|
var _useI18n = useI18n(),
|
|
@@ -34,6 +37,7 @@ var OpenSharingLinkButton = function OpenSharingLinkButton(_ref) {
|
|
|
34
37
|
var _getIconWithlabel = getIconWithlabel({
|
|
35
38
|
link: link,
|
|
36
39
|
isSharingShortcutCreated: isSharingShortcutCreated,
|
|
40
|
+
isShortLabel: isShortLabel,
|
|
37
41
|
t: t
|
|
38
42
|
}),
|
|
39
43
|
icon = _getIconWithlabel.icon,
|
|
@@ -50,6 +54,7 @@ var OpenSharingLinkButton = function OpenSharingLinkButton(_ref) {
|
|
|
50
54
|
|
|
51
55
|
OpenSharingLinkButton.propTypes = {
|
|
52
56
|
link: PropTypes.string,
|
|
53
|
-
isSharingShortcutCreated: PropTypes.bool
|
|
57
|
+
isSharingShortcutCreated: PropTypes.bool,
|
|
58
|
+
isShortLabel: PropTypes.bool
|
|
54
59
|
};
|
|
55
60
|
export default withLocales(OpenSharingLinkButton);
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
4
|
var _excluded = ["position", "right", "bottom"],
|
|
5
|
-
_excluded2 = ["link", "isSharingShortcutCreated"],
|
|
5
|
+
_excluded2 = ["link", "isSharingShortcutCreated", "isShortLabel"],
|
|
6
6
|
_excluded3 = ["style"];
|
|
7
7
|
|
|
8
8
|
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; }
|
|
@@ -35,6 +35,7 @@ var makeStyles = function makeStyles(customStyle) {
|
|
|
35
35
|
* @param {Object} props - The props for the component.
|
|
36
36
|
* @param {string} props.link - The URL to be opened when the button is clicked.
|
|
37
37
|
* @param {boolean} [props.isSharingShortcutCreated=false] - Indicates if a sharing shortcut has been created. (default false)
|
|
38
|
+
* @param {boolean} [props.isShortLabel] - Display a short label for the button.
|
|
38
39
|
* @param {Object} [props] - Additional props to be passed to the ExtendableFab component.
|
|
39
40
|
*/
|
|
40
41
|
|
|
@@ -43,6 +44,7 @@ var OpenSharingLinkFabButton = function OpenSharingLinkFabButton(_ref) {
|
|
|
43
44
|
var link = _ref.link,
|
|
44
45
|
_ref$isSharingShortcu = _ref.isSharingShortcutCreated,
|
|
45
46
|
isSharingShortcutCreated = _ref$isSharingShortcu === void 0 ? false : _ref$isSharingShortcu,
|
|
47
|
+
isShortLabel = _ref.isShortLabel,
|
|
46
48
|
props = _objectWithoutProperties(_ref, _excluded2);
|
|
47
49
|
|
|
48
50
|
var _props$style = props.style,
|
|
@@ -61,6 +63,7 @@ var OpenSharingLinkFabButton = function OpenSharingLinkFabButton(_ref) {
|
|
|
61
63
|
var _getIconWithlabel = getIconWithlabel({
|
|
62
64
|
link: link,
|
|
63
65
|
isSharingShortcutCreated: isSharingShortcutCreated,
|
|
66
|
+
isShortLabel: isShortLabel,
|
|
64
67
|
t: t
|
|
65
68
|
}),
|
|
66
69
|
icon = _getIconWithlabel.icon,
|
|
@@ -78,6 +81,7 @@ var OpenSharingLinkFabButton = function OpenSharingLinkFabButton(_ref) {
|
|
|
78
81
|
|
|
79
82
|
OpenSharingLinkFabButton.propTypes = {
|
|
80
83
|
link: PropTypes.string.isRequired,
|
|
81
|
-
isSharingShortcutCreated: PropTypes.bool
|
|
84
|
+
isSharingShortcutCreated: PropTypes.bool,
|
|
85
|
+
isShortLabel: PropTypes.bool
|
|
82
86
|
};
|
|
83
87
|
export default withLocales(OpenSharingLinkFabButton);
|
|
@@ -25,6 +25,8 @@ export var openSharingLink = function openSharingLink(_ref) {
|
|
|
25
25
|
var isSharingShortcutCreated = _ref.isSharingShortcutCreated,
|
|
26
26
|
_ref$openSharingLinkD = _ref.openSharingLinkDisplayed,
|
|
27
27
|
openSharingLinkDisplayed = _ref$openSharingLinkD === void 0 ? true : _ref$openSharingLinkD,
|
|
28
|
+
_ref$isShortLabel = _ref.isShortLabel,
|
|
29
|
+
isShortLabel = _ref$isShortLabel === void 0 ? false : _ref$isShortLabel,
|
|
28
30
|
link = _ref.link;
|
|
29
31
|
|
|
30
32
|
var _getActionsI18n = getActionsI18n(),
|
|
@@ -33,6 +35,7 @@ export var openSharingLink = function openSharingLink(_ref) {
|
|
|
33
35
|
var _getIconWithlabel = getIconWithlabel({
|
|
34
36
|
link: link,
|
|
35
37
|
isSharingShortcutCreated: isSharingShortcutCreated,
|
|
38
|
+
isShortLabel: isShortLabel,
|
|
36
39
|
t: t
|
|
37
40
|
}),
|
|
38
41
|
icon = _getIconWithlabel.icon,
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem';
|
|
4
|
+
import Icon from 'cozy-ui/transpiled/react/Icon';
|
|
5
|
+
import ReplyIcon from 'cozy-ui/transpiled/react/Icons/Reply';
|
|
6
|
+
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
|
|
7
|
+
import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
|
|
8
|
+
import { getActionsI18n } from '../hoc/withLocales';
|
|
9
|
+
|
|
10
|
+
var makeComponent = function makeComponent(label, icon) {
|
|
11
|
+
var Component = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
12
|
+
return /*#__PURE__*/React.createElement(ActionsMenuItem, _extends({}, props, {
|
|
13
|
+
ref: ref
|
|
14
|
+
}), /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Icon, {
|
|
15
|
+
icon: icon
|
|
16
|
+
})), /*#__PURE__*/React.createElement(ListItemText, {
|
|
17
|
+
primary: label
|
|
18
|
+
}));
|
|
19
|
+
});
|
|
20
|
+
Component.displayName = 'ShareNative';
|
|
21
|
+
return Component;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export var shareNative = function shareNative(_ref) {
|
|
25
|
+
var shareFilesNative = _ref.shareFilesNative,
|
|
26
|
+
isNativeFileSharingAvailable = _ref.isNativeFileSharingAvailable;
|
|
27
|
+
|
|
28
|
+
var _getActionsI18n = getActionsI18n(),
|
|
29
|
+
t = _getActionsI18n.t;
|
|
30
|
+
|
|
31
|
+
var label = t('Share.send');
|
|
32
|
+
var icon = ReplyIcon;
|
|
33
|
+
return {
|
|
34
|
+
name: 'shareNative',
|
|
35
|
+
label: label,
|
|
36
|
+
icon: icon,
|
|
37
|
+
displayCondition: function displayCondition(selectedFiles) {
|
|
38
|
+
return isNativeFileSharingAvailable && selectedFiles.every(function (selectedFile) {
|
|
39
|
+
return selectedFile.type === 'file';
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
action: function action(data) {
|
|
43
|
+
var idsToShare = data.map(function (d) {
|
|
44
|
+
return d._id;
|
|
45
|
+
});
|
|
46
|
+
shareFilesNative(idsToShare);
|
|
47
|
+
},
|
|
48
|
+
Component: makeComponent(label, icon)
|
|
49
|
+
};
|
|
50
|
+
};
|
|
@@ -66,11 +66,15 @@ var SharingBannerCozyToCozy = function SharingBannerCozyToCozy(_ref2) {
|
|
|
66
66
|
};
|
|
67
67
|
|
|
68
68
|
var buttonOne = isSharingShortcutCreated ? {
|
|
69
|
-
label: t('Share.banner.sync_to_mine'
|
|
69
|
+
label: t('Share.banner.sync_to_mine', {
|
|
70
|
+
smart_count: 2
|
|
71
|
+
}),
|
|
70
72
|
icon: 'sync-cozy',
|
|
71
73
|
action: action
|
|
72
74
|
} : {
|
|
73
|
-
label: t('Share.banner.add_to_mine'
|
|
75
|
+
label: t('Share.banner.add_to_mine', {
|
|
76
|
+
smart_count: 2
|
|
77
|
+
}),
|
|
74
78
|
icon: 'to-the-cloud',
|
|
75
79
|
action: action
|
|
76
80
|
};
|
|
@@ -124,7 +128,9 @@ var SharingBannerByLink = function SharingBannerByLink(_ref3) {
|
|
|
124
128
|
buttonOne: /*#__PURE__*/React.createElement(Button, {
|
|
125
129
|
component: "a",
|
|
126
130
|
variant: "text",
|
|
127
|
-
label: t('Share.create-cozy'
|
|
131
|
+
label: t('Share.create-cozy', {
|
|
132
|
+
smart_count: 2
|
|
133
|
+
}),
|
|
128
134
|
icon: CozyHomeLinkIcon,
|
|
129
135
|
href: HOME_LINK_HREF
|
|
130
136
|
}),
|
package/dist/helpers/sharings.js
CHANGED
|
@@ -130,24 +130,31 @@ export var openExternalLink = function openExternalLink(url) {
|
|
|
130
130
|
export var getIconWithlabel = function getIconWithlabel(_ref4) {
|
|
131
131
|
var link = _ref4.link,
|
|
132
132
|
isSharingShortcutCreated = _ref4.isSharingShortcutCreated,
|
|
133
|
+
isShortLabel = _ref4.isShortLabel,
|
|
133
134
|
t = _ref4.t;
|
|
134
135
|
|
|
135
136
|
if (link === CREATE_COZY_HREF) {
|
|
136
137
|
return {
|
|
137
138
|
icon: ToTheCloudIcon,
|
|
138
|
-
label: t('Share.create-cozy'
|
|
139
|
+
label: t('Share.create-cozy', {
|
|
140
|
+
smart_count: isShortLabel ? 1 : 2
|
|
141
|
+
})
|
|
139
142
|
};
|
|
140
143
|
}
|
|
141
144
|
|
|
142
145
|
if (!isSharingShortcutCreated) {
|
|
143
146
|
return {
|
|
144
147
|
icon: CloudPlusOutlinedIcon,
|
|
145
|
-
label: t('Share.banner.add_to_mine'
|
|
148
|
+
label: t('Share.banner.add_to_mine', {
|
|
149
|
+
smart_count: isShortLabel ? 1 : 2
|
|
150
|
+
})
|
|
146
151
|
};
|
|
147
152
|
}
|
|
148
153
|
|
|
149
154
|
return {
|
|
150
155
|
icon: SyncIcon,
|
|
151
|
-
label: t('Share.banner.sync_to_mine'
|
|
156
|
+
label: t('Share.banner.sync_to_mine', {
|
|
157
|
+
smart_count: isShortLabel ? 1 : 2
|
|
158
|
+
})
|
|
152
159
|
};
|
|
153
160
|
};
|
package/dist/index.js
CHANGED
|
@@ -25,4 +25,6 @@ export { ShareButtonWithRecipients } from './ShareButtonWithRecipients';
|
|
|
25
25
|
export { DOCUMENT_TYPE } from './helpers/documentType';
|
|
26
26
|
export { default as OpenSharingLinkButton } from './OpenSharingLinkButton';
|
|
27
27
|
export { default as OpenSharingLinkFabButton } from './OpenSharingLinkFabButton';
|
|
28
|
-
export {
|
|
28
|
+
export { NativeFileSharingProvider, useNativeFileSharing } from './providers/NativeFileSharingProvider';
|
|
29
|
+
export { openSharingLink } from './actions/openSharingLink';
|
|
30
|
+
export { shareNative } from './actions/shareNative';
|
|
@@ -0,0 +1,95 @@
|
|
|
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 React, { useState, useEffect, createContext, useContext } from 'react';
|
|
5
|
+
import { isFlagshipApp } from 'cozy-device-helper';
|
|
6
|
+
import { useWebviewIntent } from 'cozy-intent';
|
|
7
|
+
var NativeFileSharingContext = /*#__PURE__*/createContext();
|
|
8
|
+
export var useNativeFileSharing = function useNativeFileSharing() {
|
|
9
|
+
var context = useContext(NativeFileSharingContext);
|
|
10
|
+
|
|
11
|
+
if (!context) {
|
|
12
|
+
throw new Error('useFileSharing must be used within a FileSharingProvider');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return context;
|
|
16
|
+
};
|
|
17
|
+
export var NativeFileSharingProvider = function NativeFileSharingProvider(_ref) {
|
|
18
|
+
var children = _ref.children;
|
|
19
|
+
var webviewIntent = useWebviewIntent();
|
|
20
|
+
|
|
21
|
+
var _useState = useState(false),
|
|
22
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
23
|
+
isNativeFileSharingAvailable = _useState2[0],
|
|
24
|
+
setIsNativeFileSharingAvailable = _useState2[1];
|
|
25
|
+
|
|
26
|
+
useEffect(function () {
|
|
27
|
+
var checkNativeFileSharingAvailability = /*#__PURE__*/function () {
|
|
28
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
29
|
+
var availability;
|
|
30
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
31
|
+
while (1) switch (_context.prev = _context.next) {
|
|
32
|
+
case 0:
|
|
33
|
+
_context.t0 = isFlagshipApp();
|
|
34
|
+
|
|
35
|
+
if (!_context.t0) {
|
|
36
|
+
_context.next = 5;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
_context.next = 4;
|
|
41
|
+
return webviewIntent.call('isAvailable', 'shareFiles');
|
|
42
|
+
|
|
43
|
+
case 4:
|
|
44
|
+
_context.t0 = _context.sent;
|
|
45
|
+
|
|
46
|
+
case 5:
|
|
47
|
+
availability = _context.t0;
|
|
48
|
+
setIsNativeFileSharingAvailable(availability);
|
|
49
|
+
|
|
50
|
+
case 7:
|
|
51
|
+
case "end":
|
|
52
|
+
return _context.stop();
|
|
53
|
+
}
|
|
54
|
+
}, _callee);
|
|
55
|
+
}));
|
|
56
|
+
|
|
57
|
+
return function checkNativeFileSharingAvailability() {
|
|
58
|
+
return _ref2.apply(this, arguments);
|
|
59
|
+
};
|
|
60
|
+
}();
|
|
61
|
+
|
|
62
|
+
checkNativeFileSharingAvailability();
|
|
63
|
+
}, [webviewIntent]);
|
|
64
|
+
|
|
65
|
+
var shareFilesNative = /*#__PURE__*/function () {
|
|
66
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(filesIds) {
|
|
67
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
68
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
69
|
+
case 0:
|
|
70
|
+
_context2.next = 2;
|
|
71
|
+
return webviewIntent.call('shareFiles', filesIds);
|
|
72
|
+
|
|
73
|
+
case 2:
|
|
74
|
+
return _context2.abrupt("return", _context2.sent);
|
|
75
|
+
|
|
76
|
+
case 3:
|
|
77
|
+
case "end":
|
|
78
|
+
return _context2.stop();
|
|
79
|
+
}
|
|
80
|
+
}, _callee2);
|
|
81
|
+
}));
|
|
82
|
+
|
|
83
|
+
return function shareFilesNative(_x) {
|
|
84
|
+
return _ref3.apply(this, arguments);
|
|
85
|
+
};
|
|
86
|
+
}();
|
|
87
|
+
|
|
88
|
+
return /*#__PURE__*/React.createElement(NativeFileSharingContext.Provider, {
|
|
89
|
+
value: {
|
|
90
|
+
isNativeFileSharingAvailable: isNativeFileSharingAvailable,
|
|
91
|
+
shareFilesNative: shareFilesNative
|
|
92
|
+
}
|
|
93
|
+
}, children);
|
|
94
|
+
};
|
|
95
|
+
export default NativeFileSharingProvider;
|
package/locales/en.json
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"anyoneWithTheLink": "Anyone with the link",
|
|
29
29
|
"accessCount": "%{count} people have access"
|
|
30
30
|
},
|
|
31
|
-
"create-cozy": "Create my cozy",
|
|
31
|
+
"create-cozy": "Create |||| Create my cozy",
|
|
32
32
|
"members": {
|
|
33
33
|
"count": "%{smart_count} member |||| %{smart_count} members",
|
|
34
34
|
"others": "and 1 other… |||| and %{smart_count} others…",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
"shared_from": "The items below are displayed from  **%{name}**'s Cozy. You can add a link to this share in your Cozy",
|
|
60
60
|
"whats_cozy": "Cozy is a secure digital home for all your data, hosted in France - ",
|
|
61
61
|
"know_more": "More information",
|
|
62
|
-
"sync_to_mine": "Synchronise in my Cozy",
|
|
63
|
-
"add_to_mine": "Add to my Cozy",
|
|
62
|
+
"sync_to_mine": "Synchronise |||| Synchronise in my Cozy",
|
|
63
|
+
"add_to_mine": "Add |||| Add to my Cozy",
|
|
64
64
|
"close": "Close"
|
|
65
65
|
},
|
|
66
66
|
"permissionLink": {
|
|
@@ -84,7 +84,8 @@
|
|
|
84
84
|
"readWrite": "write"
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
}
|
|
87
|
+
},
|
|
88
|
+
"send": "Send..."
|
|
88
89
|
},
|
|
89
90
|
"Sharings": {
|
|
90
91
|
"unavailable": {
|
package/locales/fr.json
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"anyoneWithTheLink": "N'importe qui avec le lien",
|
|
29
29
|
"accessCount": "%{count} personnes y ont accès"
|
|
30
30
|
},
|
|
31
|
-
"create-cozy": "Créer mon Cozy",
|
|
31
|
+
"create-cozy": "Créer |||| Créer mon Cozy",
|
|
32
32
|
"members": {
|
|
33
33
|
"count": "%{smart_count} membre |||| %{smart_count} membres",
|
|
34
34
|
"others": "et 1 autre… |||| et %{smart_count} autres…",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
"shared_from": "Les éléments ci-dessous sont affichés depuis le Cozy de  **%{name}**. Vous pouvez ajouter un lien vers ce partage dans votre Cozy.",
|
|
60
60
|
"whats_cozy": "Cozy est un domicile numérique sécurisé pour toutes vos données, hébergé en France - ",
|
|
61
61
|
"know_more": "En savoir plus",
|
|
62
|
-
"sync_to_mine": "Synchroniser dans mon Cozy",
|
|
63
|
-
"add_to_mine": "Ajouter à mon Cozy",
|
|
62
|
+
"sync_to_mine": "Synchroniser |||| Synchroniser dans mon Cozy",
|
|
63
|
+
"add_to_mine": "Ajouter |||| Ajouter à mon Cozy",
|
|
64
64
|
"close": "Fermer"
|
|
65
65
|
},
|
|
66
66
|
"permissionLink": {
|
|
@@ -82,7 +82,8 @@
|
|
|
82
82
|
"readOnly": "lecture",
|
|
83
83
|
"readWrite": "modification"
|
|
84
84
|
}
|
|
85
|
-
}
|
|
85
|
+
},
|
|
86
|
+
"send": "Envoyer..."
|
|
86
87
|
},
|
|
87
88
|
"Sharings": {
|
|
88
89
|
"unavailable": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-sharing",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "17.0.0",
|
|
4
4
|
"description": "Provides sharing login for React applications.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "Cozy",
|
|
@@ -65,6 +65,8 @@
|
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"cozy-client": ">=51.4.0",
|
|
68
|
+
"cozy-device-helper": ">=3.7.1",
|
|
69
|
+
"cozy-intent": ">=2.29.1",
|
|
68
70
|
"cozy-realtime": "^3.11.0",
|
|
69
71
|
"cozy-ui": ">=113.5.0",
|
|
70
72
|
"prop-types": "^15.7.2",
|
|
@@ -74,5 +76,5 @@
|
|
|
74
76
|
"sideEffects": [
|
|
75
77
|
"*.css"
|
|
76
78
|
],
|
|
77
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "e119955a4934470d07c763ac51e95149f469f55f"
|
|
78
80
|
}
|
|
@@ -15,11 +15,13 @@ import withLocales from './hoc/withLocales'
|
|
|
15
15
|
* @param {Object} props - The props for the component.
|
|
16
16
|
* @param {string} props.link - The URL to be opened when the button is clicked.
|
|
17
17
|
* @param {boolean} [props.isSharingShortcutCreated=false] - Indicates if a sharing shortcut has been created. (default false)
|
|
18
|
+
* @param {boolean} [props.isShortLabel] - Display a short label for the button.
|
|
18
19
|
* @param {Object} [props] - Additional props to be passed to the Button component.
|
|
19
20
|
*/
|
|
20
21
|
const OpenSharingLinkButton = ({
|
|
21
22
|
link,
|
|
22
23
|
isSharingShortcutCreated = false,
|
|
24
|
+
isShortLabel = false,
|
|
23
25
|
...props
|
|
24
26
|
}) => {
|
|
25
27
|
const { t } = useI18n()
|
|
@@ -31,6 +33,7 @@ const OpenSharingLinkButton = ({
|
|
|
31
33
|
const { icon, label } = getIconWithlabel({
|
|
32
34
|
link,
|
|
33
35
|
isSharingShortcutCreated,
|
|
36
|
+
isShortLabel,
|
|
34
37
|
t
|
|
35
38
|
})
|
|
36
39
|
|
|
@@ -46,7 +49,8 @@ const OpenSharingLinkButton = ({
|
|
|
46
49
|
|
|
47
50
|
OpenSharingLinkButton.propTypes = {
|
|
48
51
|
link: PropTypes.string,
|
|
49
|
-
isSharingShortcutCreated: PropTypes.bool
|
|
52
|
+
isSharingShortcutCreated: PropTypes.bool,
|
|
53
|
+
isShortLabel: PropTypes.bool
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
export default withLocales(OpenSharingLinkButton)
|
|
@@ -24,11 +24,13 @@ const makeStyles = customStyle => {
|
|
|
24
24
|
* @param {Object} props - The props for the component.
|
|
25
25
|
* @param {string} props.link - The URL to be opened when the button is clicked.
|
|
26
26
|
* @param {boolean} [props.isSharingShortcutCreated=false] - Indicates if a sharing shortcut has been created. (default false)
|
|
27
|
+
* @param {boolean} [props.isShortLabel] - Display a short label for the button.
|
|
27
28
|
* @param {Object} [props] - Additional props to be passed to the ExtendableFab component.
|
|
28
29
|
*/
|
|
29
30
|
const OpenSharingLinkFabButton = ({
|
|
30
31
|
link,
|
|
31
32
|
isSharingShortcutCreated = false,
|
|
33
|
+
isShortLabel,
|
|
32
34
|
...props
|
|
33
35
|
}) => {
|
|
34
36
|
const { style = {}, ...rest } = props
|
|
@@ -42,6 +44,7 @@ const OpenSharingLinkFabButton = ({
|
|
|
42
44
|
const { icon, label } = getIconWithlabel({
|
|
43
45
|
link,
|
|
44
46
|
isSharingShortcutCreated,
|
|
47
|
+
isShortLabel,
|
|
45
48
|
t
|
|
46
49
|
})
|
|
47
50
|
|
|
@@ -60,7 +63,8 @@ const OpenSharingLinkFabButton = ({
|
|
|
60
63
|
|
|
61
64
|
OpenSharingLinkFabButton.propTypes = {
|
|
62
65
|
link: PropTypes.string.isRequired,
|
|
63
|
-
isSharingShortcutCreated: PropTypes.bool
|
|
66
|
+
isSharingShortcutCreated: PropTypes.bool,
|
|
67
|
+
isShortLabel: PropTypes.bool
|
|
64
68
|
}
|
|
65
69
|
|
|
66
70
|
export default withLocales(OpenSharingLinkFabButton)
|
|
@@ -27,12 +27,14 @@ const makeComponent = (label, icon) => {
|
|
|
27
27
|
export const openSharingLink = ({
|
|
28
28
|
isSharingShortcutCreated,
|
|
29
29
|
openSharingLinkDisplayed = true,
|
|
30
|
+
isShortLabel = false,
|
|
30
31
|
link
|
|
31
32
|
}) => {
|
|
32
33
|
const { t } = getActionsI18n()
|
|
33
34
|
const { icon, label } = getIconWithlabel({
|
|
34
35
|
link,
|
|
35
36
|
isSharingShortcutCreated,
|
|
37
|
+
isShortLabel,
|
|
36
38
|
t
|
|
37
39
|
})
|
|
38
40
|
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react'
|
|
2
|
+
|
|
3
|
+
import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem'
|
|
4
|
+
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
5
|
+
import ReplyIcon from 'cozy-ui/transpiled/react/Icons/Reply'
|
|
6
|
+
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
|
|
7
|
+
import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
|
|
8
|
+
|
|
9
|
+
import { getActionsI18n } from '../hoc/withLocales'
|
|
10
|
+
|
|
11
|
+
const makeComponent = (label, icon) => {
|
|
12
|
+
const Component = forwardRef((props, ref) => {
|
|
13
|
+
return (
|
|
14
|
+
<ActionsMenuItem {...props} ref={ref}>
|
|
15
|
+
<ListItemIcon>
|
|
16
|
+
<Icon icon={icon} />
|
|
17
|
+
</ListItemIcon>
|
|
18
|
+
<ListItemText primary={label} />
|
|
19
|
+
</ActionsMenuItem>
|
|
20
|
+
)
|
|
21
|
+
})
|
|
22
|
+
Component.displayName = 'ShareNative'
|
|
23
|
+
|
|
24
|
+
return Component
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const shareNative = ({
|
|
28
|
+
shareFilesNative,
|
|
29
|
+
isNativeFileSharingAvailable
|
|
30
|
+
}) => {
|
|
31
|
+
const { t } = getActionsI18n()
|
|
32
|
+
|
|
33
|
+
const label = t('Share.send')
|
|
34
|
+
const icon = ReplyIcon
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
name: 'shareNative',
|
|
38
|
+
label,
|
|
39
|
+
icon,
|
|
40
|
+
displayCondition: selectedFiles => {
|
|
41
|
+
return (
|
|
42
|
+
isNativeFileSharingAvailable &&
|
|
43
|
+
selectedFiles.every(selectedFile => selectedFile.type === 'file')
|
|
44
|
+
)
|
|
45
|
+
},
|
|
46
|
+
action: data => {
|
|
47
|
+
const idsToShare = data.map(d => d._id)
|
|
48
|
+
shareFilesNative(idsToShare)
|
|
49
|
+
},
|
|
50
|
+
Component: makeComponent(label, icon)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -57,12 +57,12 @@ const SharingBannerCozyToCozy = ({
|
|
|
57
57
|
const action = () => openExternalLink(discoveryLink)
|
|
58
58
|
const buttonOne = isSharingShortcutCreated
|
|
59
59
|
? {
|
|
60
|
-
label: t('Share.banner.sync_to_mine'),
|
|
60
|
+
label: t('Share.banner.sync_to_mine', { smart_count: 2 }),
|
|
61
61
|
icon: 'sync-cozy',
|
|
62
62
|
action
|
|
63
63
|
}
|
|
64
64
|
: {
|
|
65
|
-
label: t('Share.banner.add_to_mine'),
|
|
65
|
+
label: t('Share.banner.add_to_mine', { smart_count: 2 }),
|
|
66
66
|
icon: 'to-the-cloud',
|
|
67
67
|
action
|
|
68
68
|
}
|
|
@@ -120,7 +120,7 @@ const SharingBannerByLink = ({ onClose }) => {
|
|
|
120
120
|
<Button
|
|
121
121
|
component="a"
|
|
122
122
|
variant="text"
|
|
123
|
-
label={t('Share.create-cozy')}
|
|
123
|
+
label={t('Share.create-cozy', { smart_count: 2 })}
|
|
124
124
|
icon={CozyHomeLinkIcon}
|
|
125
125
|
href={HOME_LINK_HREF}
|
|
126
126
|
/>
|
package/src/helpers/sharings.js
CHANGED
|
@@ -70,12 +70,28 @@ export const openExternalLink = url => {
|
|
|
70
70
|
* @param {object} params.t
|
|
71
71
|
* @returns {{ icon: React.Component, label: string }}
|
|
72
72
|
*/
|
|
73
|
-
export const getIconWithlabel = ({
|
|
73
|
+
export const getIconWithlabel = ({
|
|
74
|
+
link,
|
|
75
|
+
isSharingShortcutCreated,
|
|
76
|
+
isShortLabel,
|
|
77
|
+
t
|
|
78
|
+
}) => {
|
|
74
79
|
if (link === CREATE_COZY_HREF) {
|
|
75
|
-
return {
|
|
80
|
+
return {
|
|
81
|
+
icon: ToTheCloudIcon,
|
|
82
|
+
label: t('Share.create-cozy', { smart_count: isShortLabel ? 1 : 2 })
|
|
83
|
+
}
|
|
76
84
|
}
|
|
77
85
|
if (!isSharingShortcutCreated) {
|
|
78
|
-
return {
|
|
86
|
+
return {
|
|
87
|
+
icon: CloudPlusOutlinedIcon,
|
|
88
|
+
label: t('Share.banner.add_to_mine', {
|
|
89
|
+
smart_count: isShortLabel ? 1 : 2
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
icon: SyncIcon,
|
|
95
|
+
label: t('Share.banner.sync_to_mine', { smart_count: isShortLabel ? 1 : 2 })
|
|
79
96
|
}
|
|
80
|
-
return { icon: SyncIcon, label: t('Share.banner.sync_to_mine') }
|
|
81
97
|
}
|
package/src/index.jsx
CHANGED
|
@@ -29,4 +29,9 @@ export { ShareButtonWithRecipients } from './ShareButtonWithRecipients'
|
|
|
29
29
|
export { DOCUMENT_TYPE } from './helpers/documentType'
|
|
30
30
|
export { default as OpenSharingLinkButton } from './OpenSharingLinkButton'
|
|
31
31
|
export { default as OpenSharingLinkFabButton } from './OpenSharingLinkFabButton'
|
|
32
|
+
export {
|
|
33
|
+
NativeFileSharingProvider,
|
|
34
|
+
useNativeFileSharing
|
|
35
|
+
} from './providers/NativeFileSharingProvider'
|
|
32
36
|
export { openSharingLink } from './actions/openSharingLink'
|
|
37
|
+
export { shareNative } from './actions/shareNative'
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React, { useState, useEffect, createContext, useContext } from 'react'
|
|
2
|
+
|
|
3
|
+
import { isFlagshipApp } from 'cozy-device-helper'
|
|
4
|
+
import { useWebviewIntent } from 'cozy-intent'
|
|
5
|
+
|
|
6
|
+
const NativeFileSharingContext = createContext()
|
|
7
|
+
|
|
8
|
+
export const useNativeFileSharing = () => {
|
|
9
|
+
const context = useContext(NativeFileSharingContext)
|
|
10
|
+
|
|
11
|
+
if (!context) {
|
|
12
|
+
throw new Error('useFileSharing must be used within a FileSharingProvider')
|
|
13
|
+
}
|
|
14
|
+
return context
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const NativeFileSharingProvider = ({ children }) => {
|
|
18
|
+
const webviewIntent = useWebviewIntent()
|
|
19
|
+
|
|
20
|
+
const [isNativeFileSharingAvailable, setIsNativeFileSharingAvailable] =
|
|
21
|
+
useState(false)
|
|
22
|
+
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const checkNativeFileSharingAvailability = async () => {
|
|
25
|
+
const availability =
|
|
26
|
+
isFlagshipApp() &&
|
|
27
|
+
(await webviewIntent.call('isAvailable', 'shareFiles'))
|
|
28
|
+
|
|
29
|
+
setIsNativeFileSharingAvailable(availability)
|
|
30
|
+
}
|
|
31
|
+
checkNativeFileSharingAvailability()
|
|
32
|
+
}, [webviewIntent])
|
|
33
|
+
|
|
34
|
+
const shareFilesNative = async filesIds => {
|
|
35
|
+
return await webviewIntent.call('shareFiles', filesIds)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<NativeFileSharingContext.Provider
|
|
40
|
+
value={{ isNativeFileSharingAvailable, shareFilesNative }}
|
|
41
|
+
>
|
|
42
|
+
{children}
|
|
43
|
+
</NativeFileSharingContext.Provider>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default NativeFileSharingProvider
|