cozy-sharing 3.12.5 → 3.12.9
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 +38 -0
- package/dist/ShareButton.js +15 -3
- package/dist/ShareButton.spec.js +60 -0
- package/locales/fr.json +2 -2
- package/package.json +4 -4
- package/src/ShareButton.jsx +7 -4
- package/src/ShareButton.spec.jsx +45 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,44 @@
|
|
|
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
|
+
## [3.12.9](https://github.com/cozy/cozy-libs/compare/cozy-sharing@3.12.8...cozy-sharing@3.12.9) (2021-12-31)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **sharing:** ShareButton should not pass I18n props to Cozy-UI Button ([587cd2e](https://github.com/cozy/cozy-libs/commit/587cd2e))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [3.12.8](https://github.com/cozy/cozy-libs/compare/cozy-sharing@3.12.7...cozy-sharing@3.12.8) (2021-12-28)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package cozy-sharing
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## [3.12.7](https://github.com/cozy/cozy-libs/compare/cozy-sharing@3.12.6...cozy-sharing@3.12.7) (2021-12-24)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* **sharing:** typo in fr language when sending email ([59e0266](https://github.com/cozy/cozy-libs/commit/59e0266))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## [3.12.6](https://github.com/cozy/cozy-libs/compare/cozy-sharing@3.12.5...cozy-sharing@3.12.6) (2021-12-20)
|
|
37
|
+
|
|
38
|
+
**Note:** Version bump only for package cozy-sharing
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
6
44
|
## [3.12.5](https://github.com/cozy/cozy-libs/compare/cozy-sharing@3.12.4...cozy-sharing@3.12.5) (2021-12-02)
|
|
7
45
|
|
|
8
46
|
**Note:** Version bump only for package cozy-sharing
|
package/dist/ShareButton.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
4
|
var _excluded = ["docId", "useShortLabel"];
|
|
5
|
+
|
|
6
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
7
|
+
|
|
8
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
9
|
+
|
|
4
10
|
import React from 'react';
|
|
5
11
|
import { useI18n } from 'cozy-ui/transpiled/react/I18n';
|
|
6
12
|
import SharingContext from './context';
|
|
@@ -14,16 +20,22 @@ export var ShareButton = withLocales(function (_ref) {
|
|
|
14
20
|
var _useI18n = useI18n(),
|
|
15
21
|
t = _useI18n.t;
|
|
16
22
|
|
|
23
|
+
var restProps = _objectSpread(_objectSpread({}, rest), {}, {
|
|
24
|
+
t: null,
|
|
25
|
+
f: null,
|
|
26
|
+
lang: null
|
|
27
|
+
});
|
|
28
|
+
|
|
17
29
|
return /*#__PURE__*/React.createElement(SharingContext.Consumer, null, function (_ref2) {
|
|
18
30
|
var byDocId = _ref2.byDocId,
|
|
19
31
|
documentType = _ref2.documentType,
|
|
20
32
|
isOwner = _ref2.isOwner;
|
|
21
33
|
return !byDocId[docId] ? /*#__PURE__*/React.createElement(DumbShareButton, _extends({
|
|
22
34
|
label: t("".concat(documentType, ".share.cta"))
|
|
23
|
-
},
|
|
35
|
+
}, restProps)) : isOwner(docId) ? /*#__PURE__*/React.createElement(SharedByMeButton, _extends({
|
|
24
36
|
label: useShortLabel ? t("".concat(documentType, ".share.shared")) : t("".concat(documentType, ".share.sharedByMe"))
|
|
25
|
-
},
|
|
37
|
+
}, restProps)) : /*#__PURE__*/React.createElement(SharedWithMeButton, _extends({
|
|
26
38
|
label: useShortLabel ? t("".concat(documentType, ".share.shared")) : t("".concat(documentType, ".share.sharedWithMe"))
|
|
27
|
-
},
|
|
39
|
+
}, restProps));
|
|
28
40
|
});
|
|
29
41
|
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import { ShareButton } from './ShareButton';
|
|
4
|
+
jest.mock('cozy-ui/transpiled/react', function () {
|
|
5
|
+
return {
|
|
6
|
+
Button: function Button(props) {
|
|
7
|
+
if (props.t || props.t || props.lang) {
|
|
8
|
+
throw 'do not pass html button invalid props';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
jest.mock('cozy-ui/transpiled/react/I18n', function () {
|
|
16
|
+
return {
|
|
17
|
+
useI18n: jest.fn().mockReturnValue({
|
|
18
|
+
t: jest.fn()
|
|
19
|
+
})
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
jest.mock('./withLocales', function () {
|
|
23
|
+
return (// eslint-disable-next-line react/display-name
|
|
24
|
+
function (Component) {
|
|
25
|
+
return function (props) {
|
|
26
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, Component(props));
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
jest.mock('./context', function () {
|
|
32
|
+
return {
|
|
33
|
+
// eslint-disable-next-line react/display-name
|
|
34
|
+
Consumer: function Consumer(props) {
|
|
35
|
+
var Component = function Component() {
|
|
36
|
+
return props.children({
|
|
37
|
+
byDocId: {
|
|
38
|
+
docId: false
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return /*#__PURE__*/React.createElement(Component, null);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
describe('ShareButton', function () {
|
|
48
|
+
it('should not send incorrect props to CozyUI button', function () {
|
|
49
|
+
// When
|
|
50
|
+
var _render = render( /*#__PURE__*/React.createElement(ShareButton, {
|
|
51
|
+
f: "incorrect prop",
|
|
52
|
+
t: "incorrect prop",
|
|
53
|
+
lang: "incorrect prop"
|
|
54
|
+
})),
|
|
55
|
+
container = _render.container; // Then
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
expect(container).toBeDefined();
|
|
59
|
+
});
|
|
60
|
+
});
|
package/locales/fr.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"seen": "Partage consulté",
|
|
10
10
|
"ready": "Accepté",
|
|
11
11
|
"refused": "Refusé",
|
|
12
|
-
"mail-not-sent": "
|
|
12
|
+
"mail-not-sent": "Envoi du mail d'invitation...",
|
|
13
13
|
"revoked": "Erreur",
|
|
14
14
|
"unregistered": "Erreur"
|
|
15
15
|
},
|
|
@@ -389,4 +389,4 @@
|
|
|
389
389
|
"title": "%{smart_count} contact en attente de vérification |||| %{smart_count} contacts en attente de vérification",
|
|
390
390
|
"intruction": "Vérifier l'identité de leur Cozy pour leur permettre d'accéder aux éléments que vous avez partagés avec eux."
|
|
391
391
|
}
|
|
392
|
-
}
|
|
392
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-sharing",
|
|
3
|
-
"version": "3.12.
|
|
3
|
+
"version": "3.12.9",
|
|
4
4
|
"description": "Provides sharing login for React applications.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "Cozy",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"@cozy/minilog": "^1.0.0",
|
|
29
29
|
"classnames": "^2.2.6",
|
|
30
30
|
"copy-text-to-clipboard": "^2.1.1",
|
|
31
|
-
"cozy-device-helper": "^1.
|
|
32
|
-
"cozy-doctypes": "^1.83.
|
|
31
|
+
"cozy-device-helper": "^1.14.0",
|
|
32
|
+
"cozy-doctypes": "^1.83.3",
|
|
33
33
|
"lodash": "^4.17.19",
|
|
34
34
|
"react-autosuggest": "^9.4.3",
|
|
35
35
|
"react-tooltip": "^3.11.1",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"sideEffects": [
|
|
62
62
|
"*.css"
|
|
63
63
|
],
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "3146fc70e1ada16ebf06a52594ae6f34ea67c9fa"
|
|
65
65
|
}
|
package/src/ShareButton.jsx
CHANGED
|
@@ -12,12 +12,15 @@ import {
|
|
|
12
12
|
|
|
13
13
|
export const ShareButton = withLocales(({ docId, useShortLabel, ...rest }) => {
|
|
14
14
|
const { t } = useI18n()
|
|
15
|
-
|
|
15
|
+
const restProps = { ...rest, t: null, f: null, lang: null }
|
|
16
16
|
return (
|
|
17
17
|
<SharingContext.Consumer>
|
|
18
18
|
{({ byDocId, documentType, isOwner }) => {
|
|
19
19
|
return !byDocId[docId] ? (
|
|
20
|
-
<DumbShareButton
|
|
20
|
+
<DumbShareButton
|
|
21
|
+
label={t(`${documentType}.share.cta`)}
|
|
22
|
+
{...restProps}
|
|
23
|
+
/>
|
|
21
24
|
) : isOwner(docId) ? (
|
|
22
25
|
<SharedByMeButton
|
|
23
26
|
label={
|
|
@@ -25,7 +28,7 @@ export const ShareButton = withLocales(({ docId, useShortLabel, ...rest }) => {
|
|
|
25
28
|
? t(`${documentType}.share.shared`)
|
|
26
29
|
: t(`${documentType}.share.sharedByMe`)
|
|
27
30
|
}
|
|
28
|
-
{...
|
|
31
|
+
{...restProps}
|
|
29
32
|
/>
|
|
30
33
|
) : (
|
|
31
34
|
<SharedWithMeButton
|
|
@@ -34,7 +37,7 @@ export const ShareButton = withLocales(({ docId, useShortLabel, ...rest }) => {
|
|
|
34
37
|
? t(`${documentType}.share.shared`)
|
|
35
38
|
: t(`${documentType}.share.sharedWithMe`)
|
|
36
39
|
}
|
|
37
|
-
{...
|
|
40
|
+
{...restProps}
|
|
38
41
|
/>
|
|
39
42
|
)
|
|
40
43
|
}}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { render } from '@testing-library/react'
|
|
3
|
+
import { ShareButton } from './ShareButton'
|
|
4
|
+
|
|
5
|
+
jest.mock('cozy-ui/transpiled/react', () => ({
|
|
6
|
+
Button: props => {
|
|
7
|
+
if (props.t || props.t || props.lang) {
|
|
8
|
+
throw 'do not pass html button invalid props'
|
|
9
|
+
}
|
|
10
|
+
return <></>
|
|
11
|
+
}
|
|
12
|
+
}))
|
|
13
|
+
|
|
14
|
+
jest.mock('cozy-ui/transpiled/react/I18n', () => ({
|
|
15
|
+
useI18n: jest.fn().mockReturnValue({ t: jest.fn() })
|
|
16
|
+
}))
|
|
17
|
+
|
|
18
|
+
jest.mock('./withLocales', () =>
|
|
19
|
+
// eslint-disable-next-line react/display-name
|
|
20
|
+
Component => props => <>{Component(props)}</>
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
jest.mock('./context', () => ({
|
|
24
|
+
// eslint-disable-next-line react/display-name
|
|
25
|
+
Consumer: props => {
|
|
26
|
+
const Component = () => props.children({ byDocId: { docId: false } })
|
|
27
|
+
return <Component />
|
|
28
|
+
}
|
|
29
|
+
}))
|
|
30
|
+
|
|
31
|
+
describe('ShareButton', () => {
|
|
32
|
+
it('should not send incorrect props to CozyUI button', () => {
|
|
33
|
+
// When
|
|
34
|
+
const { container } = render(
|
|
35
|
+
<ShareButton
|
|
36
|
+
f="incorrect prop"
|
|
37
|
+
t="incorrect prop"
|
|
38
|
+
lang="incorrect prop"
|
|
39
|
+
/>
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
// Then
|
|
43
|
+
expect(container).toBeDefined()
|
|
44
|
+
})
|
|
45
|
+
})
|