cozy-sharing 16.11.0 → 16.13.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 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
+ # [16.13.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@16.12.0...cozy-sharing@16.13.0) (2024-12-06)
7
+
8
+
9
+ ### Features
10
+
11
+ * Use Sharing locales instead apps ([55265c9](https://github.com/cozy/cozy-libs/commit/55265c9366e8ee98664503a6a62500e4ec986606))
12
+
13
+
14
+
15
+
16
+
17
+ # [16.12.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@16.11.0...cozy-sharing@16.12.0) (2024-12-06)
18
+
19
+
20
+ ### Features
21
+
22
+ * Add openSharingLink action ([de97967](https://github.com/cozy/cozy-libs/commit/de979676b43ab73e412683895437f108740ab5e2))
23
+ * Add OpenSharingLinkButton & OpenSharingLinkFabButton components ([ffc603c](https://github.com/cozy/cozy-libs/commit/ffc603c798954b5ebffb4a860c82f231765bda8d))
24
+ * Upgrade cozy-ui to 113.5.0 ([9bbd797](https://github.com/cozy/cozy-libs/commit/9bbd797056e085f00d1d867641abb12695fbf52b))
25
+
26
+
27
+
28
+
29
+
6
30
  # [16.11.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@16.10.0...cozy-sharing@16.11.0) (2024-12-05)
7
31
 
8
32
 
@@ -0,0 +1,55 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["link", "isSharingShortcutCreated"];
4
+ import PropTypes from 'prop-types';
5
+ import React from 'react';
6
+ import Button from 'cozy-ui/transpiled/react/Buttons';
7
+ import Icon from 'cozy-ui/transpiled/react/Icon';
8
+ import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
9
+ import { getIconWithlabel, openExternalLink } from './helpers/sharings';
10
+ import withLocales from './hoc/withLocales';
11
+ /**
12
+ * OpenSharingLinkButton component renders a Button
13
+ * that opens an link for Add/Synchronize/Create Cozy when clicked.
14
+ *
15
+ * @param {Object} props - The props for the component.
16
+ * @param {string} props.link - The URL to be opened when the button is clicked.
17
+ * @param {boolean} [props.isSharingShortcutCreated=false] - Indicates if a sharing shortcut has been created. (default false)
18
+ * @param {Object} [props] - Additional props to be passed to the Button component.
19
+ */
20
+
21
+ var OpenSharingLinkButton = function OpenSharingLinkButton(_ref) {
22
+ var link = _ref.link,
23
+ _ref$isSharingShortcu = _ref.isSharingShortcutCreated,
24
+ isSharingShortcutCreated = _ref$isSharingShortcu === void 0 ? false : _ref$isSharingShortcu,
25
+ props = _objectWithoutProperties(_ref, _excluded);
26
+
27
+ var _useI18n = useI18n(),
28
+ t = _useI18n.t;
29
+
30
+ var handleClick = function handleClick() {
31
+ openExternalLink(link);
32
+ };
33
+
34
+ var _getIconWithlabel = getIconWithlabel({
35
+ link: link,
36
+ isSharingShortcutCreated: isSharingShortcutCreated,
37
+ t: t
38
+ }),
39
+ icon = _getIconWithlabel.icon,
40
+ label = _getIconWithlabel.label;
41
+
42
+ return /*#__PURE__*/React.createElement(Button, _extends({
43
+ onClick: handleClick,
44
+ startIcon: /*#__PURE__*/React.createElement(Icon, {
45
+ icon: icon
46
+ }),
47
+ label: label
48
+ }, props));
49
+ };
50
+
51
+ OpenSharingLinkButton.propTypes = {
52
+ link: PropTypes.string,
53
+ isSharingShortcutCreated: PropTypes.bool
54
+ };
55
+ export default withLocales(OpenSharingLinkButton);
@@ -0,0 +1,83 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
+ var _excluded = ["position", "right", "bottom"],
5
+ _excluded2 = ["link", "isSharingShortcutCreated"],
6
+ _excluded3 = ["style"];
7
+
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; }
9
+
10
+ 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; }
11
+
12
+ import PropTypes from 'prop-types';
13
+ import React from 'react';
14
+ import { ExtendableFab } from 'cozy-ui/transpiled/react/Fab';
15
+ import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
16
+ import { getIconWithlabel, openExternalLink } from './helpers/sharings';
17
+ import withLocales from './hoc/withLocales';
18
+
19
+ var makeStyles = function makeStyles(customStyle) {
20
+ var position = customStyle.position,
21
+ right = customStyle.right,
22
+ bottom = customStyle.bottom,
23
+ rest = _objectWithoutProperties(customStyle, _excluded);
24
+
25
+ return _objectSpread({
26
+ position: position !== null && position !== void 0 ? position : 'fixed',
27
+ right: right !== null && right !== void 0 ? right : '1rem',
28
+ bottom: bottom !== null && bottom !== void 0 ? bottom : '1rem'
29
+ }, rest);
30
+ };
31
+ /**
32
+ * OpenSharingLinkFabButton component renders a ExtendableFab button
33
+ * that opens an link for Add/Synchronize/Create Cozy when clicked.
34
+ *
35
+ * @param {Object} props - The props for the component.
36
+ * @param {string} props.link - The URL to be opened when the button is clicked.
37
+ * @param {boolean} [props.isSharingShortcutCreated=false] - Indicates if a sharing shortcut has been created. (default false)
38
+ * @param {Object} [props] - Additional props to be passed to the ExtendableFab component.
39
+ */
40
+
41
+
42
+ var OpenSharingLinkFabButton = function OpenSharingLinkFabButton(_ref) {
43
+ var link = _ref.link,
44
+ _ref$isSharingShortcu = _ref.isSharingShortcutCreated,
45
+ isSharingShortcutCreated = _ref$isSharingShortcu === void 0 ? false : _ref$isSharingShortcu,
46
+ props = _objectWithoutProperties(_ref, _excluded2);
47
+
48
+ var _props$style = props.style,
49
+ style = _props$style === void 0 ? {} : _props$style,
50
+ rest = _objectWithoutProperties(props, _excluded3);
51
+
52
+ var _useI18n = useI18n(),
53
+ t = _useI18n.t;
54
+
55
+ var fabStyles = makeStyles(style);
56
+
57
+ var handleClick = function handleClick() {
58
+ openExternalLink(link);
59
+ };
60
+
61
+ var _getIconWithlabel = getIconWithlabel({
62
+ link: link,
63
+ isSharingShortcutCreated: isSharingShortcutCreated,
64
+ t: t
65
+ }),
66
+ icon = _getIconWithlabel.icon,
67
+ label = _getIconWithlabel.label;
68
+
69
+ return /*#__PURE__*/React.createElement(ExtendableFab, _extends({
70
+ color: "primary",
71
+ label: label,
72
+ style: fabStyles,
73
+ icon: icon,
74
+ follow: window,
75
+ onClick: handleClick
76
+ }, rest));
77
+ };
78
+
79
+ OpenSharingLinkFabButton.propTypes = {
80
+ link: PropTypes.string.isRequired,
81
+ isSharingShortcutCreated: PropTypes.bool
82
+ };
83
+ export default withLocales(OpenSharingLinkFabButton);
@@ -0,0 +1,48 @@
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 ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
6
+ import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
7
+ import { getIconWithlabel, openExternalLink } from '../helpers/sharings';
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 = 'OpenSharingLink';
21
+ return Component;
22
+ };
23
+
24
+ export var openSharingLink = function openSharingLink(_ref) {
25
+ var isSharingShortcutCreated = _ref.isSharingShortcutCreated,
26
+ link = _ref.link;
27
+
28
+ var _getActionsI18n = getActionsI18n(),
29
+ t = _getActionsI18n.t;
30
+
31
+ var _getIconWithlabel = getIconWithlabel({
32
+ link: link,
33
+ isSharingShortcutCreated: isSharingShortcutCreated,
34
+ t: t
35
+ }),
36
+ icon = _getIconWithlabel.icon,
37
+ label = _getIconWithlabel.label;
38
+
39
+ return {
40
+ name: 'openSharingLink',
41
+ label: label,
42
+ icon: icon,
43
+ action: function action() {
44
+ openExternalLink(link);
45
+ },
46
+ Component: makeComponent(label, icon)
47
+ };
48
+ };
@@ -1,10 +1,14 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  import { Q } from 'cozy-client';
4
+ import CloudPlusOutlinedIcon from 'cozy-ui/transpiled/react/Icons/CloudPlusOutlined';
5
+ import SyncIcon from 'cozy-ui/transpiled/react/Icons/Sync';
6
+ import ToTheCloudIcon from 'cozy-ui/transpiled/react/Icons/ToTheCloud';
4
7
  import { fetchFilesPaths } from './files';
5
8
  import { updateInternalObjectFromRealtime, normalizeDocFromRealtime } from './realtime';
6
9
  import logger from '../logger';
7
10
  import { addSharing, updateSharing } from '../state';
11
+ var CREATE_COZY_HREF = 'https://manager.cozycloud.cc/cozy/create';
8
12
  export var getSharingObject = function getSharingObject(internalSharing, sharing) {
9
13
  if (internalSharing) {
10
14
  return updateInternalObjectFromRealtime(internalSharing, sharing);
@@ -105,4 +109,45 @@ export var createSharingInStore = /*#__PURE__*/function () {
105
109
  }();
106
110
  export var updateSharingInStore = function updateSharingInStore(dispatch, sharing) {
107
111
  dispatch(updateSharing(sharing));
112
+ };
113
+ /**
114
+ * Open the link in a new tab
115
+ * @param {string} url
116
+ */
117
+
118
+ export var openExternalLink = function openExternalLink(url) {
119
+ window.open(url, '_blank');
120
+ };
121
+ /**
122
+ * Get the icon and label to display in the button
123
+ * @param {object} params
124
+ * @param {string} params.link
125
+ * @param {boolean} params.isSharingShortcutCreated
126
+ * @param {object} params.t
127
+ * @returns {{ icon: React.Component, label: string }}
128
+ */
129
+
130
+ export var getIconWithlabel = function getIconWithlabel(_ref4) {
131
+ var link = _ref4.link,
132
+ isSharingShortcutCreated = _ref4.isSharingShortcutCreated,
133
+ t = _ref4.t;
134
+
135
+ if (link === CREATE_COZY_HREF) {
136
+ return {
137
+ icon: ToTheCloudIcon,
138
+ label: t('Share.create-cozy')
139
+ };
140
+ }
141
+
142
+ if (!isSharingShortcutCreated) {
143
+ return {
144
+ icon: CloudPlusOutlinedIcon,
145
+ label: t('Share.banner.add_to_mine')
146
+ };
147
+ }
148
+
149
+ return {
150
+ icon: SyncIcon,
151
+ label: t('Share.banner.sync_to_mine')
152
+ };
108
153
  };
@@ -1,9 +1,15 @@
1
1
  import React from 'react';
2
2
  import { I18n, translate } from 'cozy-ui/transpiled/react/providers/I18n';
3
+ import { getI18n } from 'cozy-ui/transpiled/react/providers/I18n/helpers';
3
4
  var locales = {
4
5
  en: require("../../locales/en.json"),
5
6
  fr: require("../../locales/fr.json")
6
7
  };
8
+ export var getActionsI18n = function getActionsI18n() {
9
+ return getI18n(undefined, function (lang) {
10
+ return locales[lang];
11
+ });
12
+ };
7
13
  /**
8
14
  * Adds cozy-sharing translations in the React context
9
15
  *
package/dist/index.js CHANGED
@@ -22,4 +22,7 @@ export { SharingBannerPlugin } from './components/SharingBanner';
22
22
  export { useSharingInfos } from './components/SharingBanner/hooks/useSharingInfos';
23
23
  export { ConfirmTrustedRecipientsDialog } from './ConfirmTrustedRecipientsDialog';
24
24
  export { ShareButtonWithRecipients } from './ShareButtonWithRecipients';
25
- export { DOCUMENT_TYPE } from './helpers/documentType';
25
+ export { DOCUMENT_TYPE } from './helpers/documentType';
26
+ export { default as OpenSharingLinkButton } from './OpenSharingLinkButton';
27
+ export { default as OpenSharingLinkFabButton } from './OpenSharingLinkFabButton';
28
+ export { openSharingLink } from './actions/openSharingLink';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-sharing",
3
- "version": "16.11.0",
3
+ "version": "16.13.0",
4
4
  "description": "Provides sharing login for React applications.",
5
5
  "main": "dist/index.js",
6
6
  "author": "Cozy",
@@ -46,11 +46,14 @@
46
46
  "@storybook/react": "7.6.0",
47
47
  "@storybook/react-webpack5": "7.6.0",
48
48
  "@storybook/testing-library": "0.2.2",
49
+ "@testing-library/jest-dom": "5.16.4",
50
+ "@testing-library/react": "10.4.9",
51
+ "@testing-library/react-hooks": "8.0.1",
49
52
  "babel-jest": "26.6.3",
50
53
  "babel-plugin-css-modules-transform": "1.6.2",
51
54
  "babel-plugin-inline-react-svg": "1.1.2",
52
- "cozy-client": "^48.25.0",
53
- "cozy-ui": "^111.12.0",
55
+ "cozy-client": "^51.4.0",
56
+ "cozy-ui": "113.5.0",
54
57
  "enzyme": "3.11.0",
55
58
  "enzyme-adapter-react-16": "1.15.6",
56
59
  "enzyme-to-json": "3.6.2",
@@ -61,9 +64,9 @@
61
64
  "storybook": "7.6.0"
62
65
  },
63
66
  "peerDependencies": {
64
- "cozy-client": ">=48.25.0",
67
+ "cozy-client": ">=51.4.0",
65
68
  "cozy-realtime": "^3.11.0",
66
- "cozy-ui": ">=111.12.0",
69
+ "cozy-ui": ">=113.5.0",
67
70
  "prop-types": "^15.7.2",
68
71
  "react": "^16.12.0",
69
72
  "react-router": "^5.0.1"
@@ -71,5 +74,5 @@
71
74
  "sideEffects": [
72
75
  "*.css"
73
76
  ],
74
- "gitHead": "99210fddf08b4701afcf0390c0042d3f7cfb97ec"
77
+ "gitHead": "881a7c6ce006d5fb515b2a5264ebf1a6f5a3b6b6"
75
78
  }
@@ -0,0 +1,52 @@
1
+ import PropTypes from 'prop-types'
2
+ import React from 'react'
3
+
4
+ import Button from 'cozy-ui/transpiled/react/Buttons'
5
+ import Icon from 'cozy-ui/transpiled/react/Icon'
6
+ import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
7
+
8
+ import { getIconWithlabel, openExternalLink } from './helpers/sharings'
9
+ import withLocales from './hoc/withLocales'
10
+
11
+ /**
12
+ * OpenSharingLinkButton component renders a Button
13
+ * that opens an link for Add/Synchronize/Create Cozy when clicked.
14
+ *
15
+ * @param {Object} props - The props for the component.
16
+ * @param {string} props.link - The URL to be opened when the button is clicked.
17
+ * @param {boolean} [props.isSharingShortcutCreated=false] - Indicates if a sharing shortcut has been created. (default false)
18
+ * @param {Object} [props] - Additional props to be passed to the Button component.
19
+ */
20
+ const OpenSharingLinkButton = ({
21
+ link,
22
+ isSharingShortcutCreated = false,
23
+ ...props
24
+ }) => {
25
+ const { t } = useI18n()
26
+
27
+ const handleClick = () => {
28
+ openExternalLink(link)
29
+ }
30
+
31
+ const { icon, label } = getIconWithlabel({
32
+ link,
33
+ isSharingShortcutCreated,
34
+ t
35
+ })
36
+
37
+ return (
38
+ <Button
39
+ onClick={handleClick}
40
+ startIcon={<Icon icon={icon} />}
41
+ label={label}
42
+ {...props}
43
+ />
44
+ )
45
+ }
46
+
47
+ OpenSharingLinkButton.propTypes = {
48
+ link: PropTypes.string,
49
+ isSharingShortcutCreated: PropTypes.bool
50
+ }
51
+
52
+ export default withLocales(OpenSharingLinkButton)
@@ -0,0 +1,66 @@
1
+ import PropTypes from 'prop-types'
2
+ import React from 'react'
3
+
4
+ import { ExtendableFab } from 'cozy-ui/transpiled/react/Fab'
5
+ import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
6
+
7
+ import { getIconWithlabel, openExternalLink } from './helpers/sharings'
8
+ import withLocales from './hoc/withLocales'
9
+
10
+ const makeStyles = customStyle => {
11
+ const { position, right, bottom, ...rest } = customStyle
12
+ return {
13
+ position: position ?? 'fixed',
14
+ right: right ?? '1rem',
15
+ bottom: bottom ?? '1rem',
16
+ ...rest
17
+ }
18
+ }
19
+
20
+ /**
21
+ * OpenSharingLinkFabButton component renders a ExtendableFab button
22
+ * that opens an link for Add/Synchronize/Create Cozy when clicked.
23
+ *
24
+ * @param {Object} props - The props for the component.
25
+ * @param {string} props.link - The URL to be opened when the button is clicked.
26
+ * @param {boolean} [props.isSharingShortcutCreated=false] - Indicates if a sharing shortcut has been created. (default false)
27
+ * @param {Object} [props] - Additional props to be passed to the ExtendableFab component.
28
+ */
29
+ const OpenSharingLinkFabButton = ({
30
+ link,
31
+ isSharingShortcutCreated = false,
32
+ ...props
33
+ }) => {
34
+ const { style = {}, ...rest } = props
35
+ const { t } = useI18n()
36
+ const fabStyles = makeStyles(style)
37
+
38
+ const handleClick = () => {
39
+ openExternalLink(link)
40
+ }
41
+
42
+ const { icon, label } = getIconWithlabel({
43
+ link,
44
+ isSharingShortcutCreated,
45
+ t
46
+ })
47
+
48
+ return (
49
+ <ExtendableFab
50
+ color="primary"
51
+ label={label}
52
+ style={fabStyles}
53
+ icon={icon}
54
+ follow={window}
55
+ onClick={handleClick}
56
+ {...rest}
57
+ />
58
+ )
59
+ }
60
+
61
+ OpenSharingLinkFabButton.propTypes = {
62
+ link: PropTypes.string.isRequired,
63
+ isSharingShortcutCreated: PropTypes.bool
64
+ }
65
+
66
+ export default withLocales(OpenSharingLinkFabButton)
@@ -0,0 +1,44 @@
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 ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
6
+ import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
7
+
8
+ import { getIconWithlabel, openExternalLink } from '../helpers/sharings'
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 = 'OpenSharingLink'
23
+
24
+ return Component
25
+ }
26
+
27
+ export const openSharingLink = ({ isSharingShortcutCreated, link }) => {
28
+ const { t } = getActionsI18n()
29
+ const { icon, label } = getIconWithlabel({
30
+ link,
31
+ isSharingShortcutCreated,
32
+ t
33
+ })
34
+
35
+ return {
36
+ name: 'openSharingLink',
37
+ label,
38
+ icon,
39
+ action: () => {
40
+ openExternalLink(link)
41
+ },
42
+ Component: makeComponent(label, icon)
43
+ }
44
+ }
@@ -1,4 +1,7 @@
1
1
  import { Q } from 'cozy-client'
2
+ import CloudPlusOutlinedIcon from 'cozy-ui/transpiled/react/Icons/CloudPlusOutlined'
3
+ import SyncIcon from 'cozy-ui/transpiled/react/Icons/Sync'
4
+ import ToTheCloudIcon from 'cozy-ui/transpiled/react/Icons/ToTheCloud'
2
5
 
3
6
  import { fetchFilesPaths } from './files'
4
7
  import {
@@ -8,6 +11,8 @@ import {
8
11
  import logger from '../logger'
9
12
  import { addSharing, updateSharing } from '../state'
10
13
 
14
+ const CREATE_COZY_HREF = 'https://manager.cozycloud.cc/cozy/create'
15
+
11
16
  export const getSharingObject = (internalSharing, sharing) => {
12
17
  if (internalSharing) {
13
18
  return updateInternalObjectFromRealtime(internalSharing, sharing)
@@ -48,3 +53,29 @@ export const createSharingInStore = async ({
48
53
  export const updateSharingInStore = (dispatch, sharing) => {
49
54
  dispatch(updateSharing(sharing))
50
55
  }
56
+
57
+ /**
58
+ * Open the link in a new tab
59
+ * @param {string} url
60
+ */
61
+ export const openExternalLink = url => {
62
+ window.open(url, '_blank')
63
+ }
64
+
65
+ /**
66
+ * Get the icon and label to display in the button
67
+ * @param {object} params
68
+ * @param {string} params.link
69
+ * @param {boolean} params.isSharingShortcutCreated
70
+ * @param {object} params.t
71
+ * @returns {{ icon: React.Component, label: string }}
72
+ */
73
+ export const getIconWithlabel = ({ link, isSharingShortcutCreated, t }) => {
74
+ if (link === CREATE_COZY_HREF) {
75
+ return { icon: ToTheCloudIcon, label: t('Share.create-cozy') }
76
+ }
77
+ if (!isSharingShortcutCreated) {
78
+ return { icon: CloudPlusOutlinedIcon, label: t('Share.banner.add_to_mine') }
79
+ }
80
+ return { icon: SyncIcon, label: t('Share.banner.sync_to_mine') }
81
+ }
@@ -1,12 +1,15 @@
1
1
  import React from 'react'
2
2
 
3
3
  import { I18n, translate } from 'cozy-ui/transpiled/react/providers/I18n'
4
+ import { getI18n } from 'cozy-ui/transpiled/react/providers/I18n/helpers'
4
5
 
5
6
  const locales = {
6
7
  en: require(`../../locales/en.json`),
7
8
  fr: require(`../../locales/fr.json`)
8
9
  }
9
10
 
11
+ export const getActionsI18n = () => getI18n(undefined, lang => locales[lang])
12
+
10
13
  /**
11
14
  * Adds cozy-sharing translations in the React context
12
15
  *
package/src/index.jsx CHANGED
@@ -27,3 +27,6 @@ export { useSharingInfos } from './components/SharingBanner/hooks/useSharingInfo
27
27
  export { ConfirmTrustedRecipientsDialog } from './ConfirmTrustedRecipientsDialog'
28
28
  export { ShareButtonWithRecipients } from './ShareButtonWithRecipients'
29
29
  export { DOCUMENT_TYPE } from './helpers/documentType'
30
+ export { default as OpenSharingLinkButton } from './OpenSharingLinkButton'
31
+ export { default as OpenSharingLinkFabButton } from './OpenSharingLinkFabButton'
32
+ export { openSharingLink } from './actions/openSharingLink'