cozy-sharing 4.1.1 → 4.1.4
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 +33 -0
- package/dist/SharingBanner/components/PublicBanner.js +8 -6
- package/dist/SharingBanner/components/PublicBanner.spec.js +47 -0
- package/package.json +7 -7
- package/src/SharingBanner/components/PublicBanner.jsx +9 -5
- package/src/SharingBanner/components/PublicBanner.spec.jsx +45 -0
- package/src/components/__snapshots__/ContactSuggestion.spec.jsx.snap +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,39 @@
|
|
|
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
|
+
## [4.1.4](https://github.com/cozy/cozy-libs/compare/cozy-sharing@4.1.3...cozy-sharing@4.1.4) (2022-03-01)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **sharing:** Upgrade cozy-ui to remove justifyContent warning ([eb6318f](https://github.com/cozy/cozy-libs/commit/eb6318f0d0cd2e39e47b80b35e30efb766d6e553))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [4.1.3](https://github.com/cozy/cozy-libs/compare/cozy-sharing@4.1.2...cozy-sharing@4.1.3) (2022-02-21)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **sharing:** Escape public name in public cozy2cozy view ([b5af978](https://github.com/cozy/cozy-libs/commit/b5af978e6f349819b8f76e097f328a87a6c18912))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## [4.1.2](https://github.com/cozy/cozy-libs/compare/cozy-sharing@4.1.1...cozy-sharing@4.1.2) (2022-02-18)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Bug Fixes
|
|
32
|
+
|
|
33
|
+
* **deps:** pin dependencies ([e53d065](https://github.com/cozy/cozy-libs/commit/e53d065090224ea340b2c25c3afd14f223f4d119))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
6
39
|
## [4.1.1](https://github.com/cozy/cozy-libs/compare/cozy-sharing@4.1.0...cozy-sharing@4.1.1) (2022-02-15)
|
|
7
40
|
|
|
8
41
|
|
|
@@ -29,19 +29,21 @@ var PublicBannerCozyToCozyContent = function PublicBannerCozyToCozyContent(_ref)
|
|
|
29
29
|
var knowMore = /*#__PURE__*/React.createElement("a", {
|
|
30
30
|
href: "https://cozy.io",
|
|
31
31
|
target: "_blank",
|
|
32
|
-
className:
|
|
32
|
+
className: "u-link",
|
|
33
33
|
rel: "noopener noreferrer"
|
|
34
34
|
}, t('Share.banner.know_more'));
|
|
35
35
|
var withAvatar = snarkdown(t('Share.banner.shared_from', {
|
|
36
36
|
name: name,
|
|
37
37
|
image: avatarURL
|
|
38
38
|
}));
|
|
39
|
+
var beginning = withAvatar.split('<img src');
|
|
40
|
+
var translated = beginning[1].split('alt="avatar">');
|
|
39
41
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
40
|
-
className: styles['bannermarkdown']
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}), /*#__PURE__*/React.createElement("span", null, ' ', text, " ", knowMore));
|
|
42
|
+
className: styles['bannermarkdown']
|
|
43
|
+
}, beginning[0], /*#__PURE__*/React.createElement("img", {
|
|
44
|
+
src: avatarURL,
|
|
45
|
+
alt: "avatar"
|
|
46
|
+
}), translated[1]), /*#__PURE__*/React.createElement("span", null, ' ', text, " ", knowMore));
|
|
45
47
|
};
|
|
46
48
|
|
|
47
49
|
PublicBannerCozyToCozyContent.propTypes = {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import { SharingBannerCozyToCozy } from './PublicBanner';
|
|
4
|
+
import { useI18n } from 'cozy-ui/transpiled/react/I18n';
|
|
5
|
+
import { useClient } from 'cozy-client';
|
|
6
|
+
jest.mock('cozy-ui/transpiled/react/I18n');
|
|
7
|
+
jest.mock('cozy-client');
|
|
8
|
+
describe('PublicBanner', function () {
|
|
9
|
+
beforeEach(function () {
|
|
10
|
+
useClient.mockReturnValue({
|
|
11
|
+
options: {
|
|
12
|
+
uri: 'http://cozy.localhost:8080'
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
it('should not add dangerous html', function () {
|
|
17
|
+
// Given
|
|
18
|
+
useI18n.mockReturnValue({
|
|
19
|
+
t: function t(localeToTranslate, options) {
|
|
20
|
+
if (localeToTranslate === 'Share.banner.shared_from') {
|
|
21
|
+
return "Shared from  ").concat(options.name, "'s cozy.");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return localeToTranslate;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
var publicName = '[Click me!](https://evil.com)';
|
|
28
|
+
var sharing = {
|
|
29
|
+
attributes: {
|
|
30
|
+
members: [{
|
|
31
|
+
public_name: publicName
|
|
32
|
+
}]
|
|
33
|
+
}
|
|
34
|
+
}; // When
|
|
35
|
+
|
|
36
|
+
var _render = render( /*#__PURE__*/React.createElement(SharingBannerCozyToCozy, {
|
|
37
|
+
sharing: sharing,
|
|
38
|
+
isSharingShortcutCreated: true,
|
|
39
|
+
discoveryLink: 'discoveryLink',
|
|
40
|
+
onClose: function onClose() {}
|
|
41
|
+
})),
|
|
42
|
+
container = _render.container; // Then
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
expect(container.querySelector('.bannermarkdown').innerHTML).toEqual("Shared from <img src=\"http://cozy.localhost:8080/public/avatar?fallback=initials\" alt=\"avatar\"> <a href=\"https://evil.com\">Click me!</a>'s cozy.");
|
|
46
|
+
});
|
|
47
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-sharing",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.4",
|
|
4
4
|
"description": "Provides sharing login for React applications.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "Cozy",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"classnames": "^2.2.6",
|
|
30
30
|
"copy-text-to-clipboard": "^2.1.1",
|
|
31
31
|
"cozy-device-helper": "^1.17.0",
|
|
32
|
-
"cozy-doctypes": "^1.83.
|
|
32
|
+
"cozy-doctypes": "^1.83.6",
|
|
33
33
|
"lodash": "^4.17.19",
|
|
34
34
|
"react-autosuggest": "^9.4.3",
|
|
35
35
|
"react-tooltip": "^3.11.1",
|
|
@@ -39,16 +39,16 @@
|
|
|
39
39
|
"@babel/core": "7.16.12",
|
|
40
40
|
"@material-ui/core": "4.12.3",
|
|
41
41
|
"babel-jest": "26.6.3",
|
|
42
|
-
"babel-plugin-css-modules-transform": "
|
|
42
|
+
"babel-plugin-css-modules-transform": "1.6.2",
|
|
43
43
|
"babel-plugin-inline-react-svg": "1.1.2",
|
|
44
44
|
"cozy-client": "23.19.1",
|
|
45
|
-
"cozy-ui": "62.
|
|
45
|
+
"cozy-ui": "62.1.2",
|
|
46
46
|
"enzyme": "3.11.0",
|
|
47
47
|
"enzyme-adapter-react-16": "1.15.6",
|
|
48
48
|
"enzyme-to-json": "3.6.2",
|
|
49
49
|
"jest": "26.6.3",
|
|
50
|
-
"react": "
|
|
51
|
-
"react-dom": "
|
|
50
|
+
"react": "16.12.0",
|
|
51
|
+
"react-dom": "16.12.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@material-ui/core": "4",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"sideEffects": [
|
|
62
62
|
"*.css"
|
|
63
63
|
],
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "b5e309bdcc2cb816a3cfe5aca22267285afd76ae"
|
|
65
65
|
}
|
|
@@ -30,24 +30,28 @@ const PublicBannerCozyToCozyContent = ({
|
|
|
30
30
|
<a
|
|
31
31
|
href="https://cozy.io"
|
|
32
32
|
target="_blank"
|
|
33
|
-
className=
|
|
33
|
+
className="u-link"
|
|
34
34
|
rel="noopener noreferrer"
|
|
35
35
|
>
|
|
36
36
|
{t('Share.banner.know_more')}
|
|
37
37
|
</a>
|
|
38
38
|
)
|
|
39
|
+
|
|
39
40
|
const withAvatar = snarkdown(
|
|
40
41
|
t('Share.banner.shared_from', {
|
|
41
42
|
name: name,
|
|
42
43
|
image: avatarURL
|
|
43
44
|
})
|
|
44
45
|
)
|
|
46
|
+
const beginning = withAvatar.split('<img src')
|
|
47
|
+
const translated = beginning[1].split('alt="avatar">')
|
|
45
48
|
return (
|
|
46
49
|
<>
|
|
47
|
-
<span
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
<span className={styles['bannermarkdown']}>
|
|
51
|
+
{beginning[0]}
|
|
52
|
+
<img src={avatarURL} alt="avatar" />
|
|
53
|
+
{translated[1]}
|
|
54
|
+
</span>
|
|
51
55
|
<span>
|
|
52
56
|
{' '}
|
|
53
57
|
{text} {knowMore}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { render } from '@testing-library/react'
|
|
3
|
+
import { SharingBannerCozyToCozy } from './PublicBanner'
|
|
4
|
+
import { useI18n } from 'cozy-ui/transpiled/react/I18n'
|
|
5
|
+
import { useClient } from 'cozy-client'
|
|
6
|
+
|
|
7
|
+
jest.mock('cozy-ui/transpiled/react/I18n')
|
|
8
|
+
jest.mock('cozy-client')
|
|
9
|
+
|
|
10
|
+
describe('PublicBanner', () => {
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
useClient.mockReturnValue({
|
|
13
|
+
options: { uri: 'http://cozy.localhost:8080' }
|
|
14
|
+
})
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it('should not add dangerous html', () => {
|
|
18
|
+
// Given
|
|
19
|
+
useI18n.mockReturnValue({
|
|
20
|
+
t: (localeToTranslate, options) => {
|
|
21
|
+
if (localeToTranslate === 'Share.banner.shared_from') {
|
|
22
|
+
return `Shared from  ${options.name}'s cozy.`
|
|
23
|
+
}
|
|
24
|
+
return localeToTranslate
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
const publicName = '[Click me!](https://evil.com)'
|
|
28
|
+
const sharing = { attributes: { members: [{ public_name: publicName }] } }
|
|
29
|
+
|
|
30
|
+
// When
|
|
31
|
+
const { container } = render(
|
|
32
|
+
<SharingBannerCozyToCozy
|
|
33
|
+
sharing={sharing}
|
|
34
|
+
isSharingShortcutCreated={true}
|
|
35
|
+
discoveryLink={'discoveryLink'}
|
|
36
|
+
onClose={() => {}}
|
|
37
|
+
/>
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
// Then
|
|
41
|
+
expect(container.querySelector('.bannermarkdown').innerHTML).toEqual(
|
|
42
|
+
`Shared from <img src="http://cozy.localhost:8080/public/avatar?fallback=initials" alt="avatar"> <a href="https://evil.com">Click me!</a>'s cozy.`
|
|
43
|
+
)
|
|
44
|
+
})
|
|
45
|
+
})
|
|
@@ -58,6 +58,7 @@ exports[`ContactSuggestion component should display contact suggestion for a con
|
|
|
58
58
|
<Avatar
|
|
59
59
|
className=""
|
|
60
60
|
disabled={false}
|
|
61
|
+
ghost={false}
|
|
61
62
|
icon={[Function]}
|
|
62
63
|
image=""
|
|
63
64
|
size="small"
|
|
@@ -143,6 +144,7 @@ exports[`ContactSuggestion component should display contact suggestion for a con
|
|
|
143
144
|
<Avatar
|
|
144
145
|
className=""
|
|
145
146
|
disabled={false}
|
|
147
|
+
ghost={false}
|
|
146
148
|
icon={[Function]}
|
|
147
149
|
image=""
|
|
148
150
|
size="small"
|
|
@@ -279,6 +281,7 @@ exports[`ContactSuggestion component should display contact suggestion for a gro
|
|
|
279
281
|
<Avatar
|
|
280
282
|
className=""
|
|
281
283
|
disabled={false}
|
|
284
|
+
ghost={false}
|
|
282
285
|
icon={[Function]}
|
|
283
286
|
image=""
|
|
284
287
|
size="small"
|