cozy-sharing 25.2.0 → 25.3.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 +7 -0
- package/dist/components/Avatar/MemberAvatar.js +11 -14
- package/dist/components/ShareModal.js +2 -1
- package/dist/components/ShareModal.spec.js +8 -2
- package/package.json +2 -2
- package/src/components/Avatar/MemberAvatar.jsx +13 -14
- package/src/components/ShareModal.jsx +4 -1
- package/src/components/ShareModal.spec.js +8 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,13 @@
|
|
|
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
|
+
# [25.3.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@25.2.0...cozy-sharing@25.3.0) (2025-04-28)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- Allow to hide cozy to cozy sharing with a flag ([3836c83](https://github.com/cozy/cozy-libs/commit/3836c837713f3122b8657b4cff8a9274c7d949ed))
|
|
11
|
+
- Enable again avatar display from cozy-stack ([9d716ab](https://github.com/cozy/cozy-libs/commit/9d716ab8eb64e0254386e1c572317a9f49fe21db))
|
|
12
|
+
|
|
6
13
|
# [25.2.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@25.1.1...cozy-sharing@25.2.0) (2025-04-22)
|
|
7
14
|
|
|
8
15
|
### Features
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
3
|
var _excluded = ["recipient"];
|
|
@@ -8,6 +7,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
8
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; }
|
|
9
8
|
|
|
10
9
|
import React from 'react';
|
|
10
|
+
import { useClient } from 'cozy-client';
|
|
11
11
|
import Avatar from 'cozy-ui/transpiled/react/Avatar';
|
|
12
12
|
import logger from '../../logger';
|
|
13
13
|
import { getInitials } from '../../models';
|
|
@@ -16,10 +16,11 @@ var MemberAvatar = function MemberAvatar(_ref) {
|
|
|
16
16
|
var recipient = _ref.recipient,
|
|
17
17
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
18
18
|
|
|
19
|
-
// There are cases when due to apparent memory leaks, the recipient does not exist
|
|
19
|
+
var client = useClient(); // There are cases when due to apparent memory leaks, the recipient does not exist
|
|
20
20
|
// This will trigger an unhanded error in the Avatar component and crash the app
|
|
21
21
|
// At the moment, we are not sure where is the root cause of this cascading undefined props
|
|
22
22
|
// Nevertheless, we can prevent the crash by returning null if the recipient is undefined
|
|
23
|
+
|
|
23
24
|
if (!recipient) {
|
|
24
25
|
// eslint-disable-next-line
|
|
25
26
|
logger.warn('RecipientAvatar: recipient is missing, see props:', _objectSpread({
|
|
@@ -37,18 +38,14 @@ var MemberAvatar = function MemberAvatar(_ref) {
|
|
|
37
38
|
* status in the url force the refresh of the image when the
|
|
38
39
|
* status changes
|
|
39
40
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
, _extends({
|
|
49
|
-
border: true,
|
|
50
|
-
disabled: recipient.status === 'pending' || recipient.status === 'mail-not-send'
|
|
51
|
-
}, rest), getInitials(recipient));
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
var image = recipient.avatarPath && recipient.status ? "".concat(client.options.uri).concat(recipient.avatarPath, "?v=").concat(recipient.status) : null;
|
|
44
|
+
return /*#__PURE__*/React.createElement(Avatar, rest, image ? /*#__PURE__*/React.createElement("img", {
|
|
45
|
+
width: "100%",
|
|
46
|
+
height: "100%",
|
|
47
|
+
src: image
|
|
48
|
+
}) : getInitials(recipient));
|
|
52
49
|
};
|
|
53
50
|
|
|
54
51
|
export { MemberAvatar };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import flag from 'cozy-flags';
|
|
3
4
|
import ShareDialogCozyToCozy from './ShareDialogCozyToCozy';
|
|
4
5
|
import ShareDialogOnlyByLink from './ShareDialogOnlyByLink';
|
|
5
6
|
export var ShareModal = function ShareModal(_ref) {
|
|
@@ -20,7 +21,7 @@ export var ShareModal = function ShareModal(_ref) {
|
|
|
20
21
|
sharing = _ref.sharing,
|
|
21
22
|
sharingDesc = _ref.sharingDesc,
|
|
22
23
|
twoStepsConfirmationMethods = _ref.twoStepsConfirmationMethods;
|
|
23
|
-
var shareDialogOnlyByLink = documentType === 'Albums';
|
|
24
|
+
var shareDialogOnlyByLink = flag('cozy.hide-sharing-cozy-to-cozy') || documentType === 'Albums';
|
|
24
25
|
var showShareByEmail = !hasSharedParent && !hasSharedChild;
|
|
25
26
|
var showShareByLink = documentType !== 'Organizations';
|
|
26
27
|
var showShareOnlyByLink = hasSharedParent || hasSharedChild;
|
|
@@ -37,12 +37,18 @@ describe('ShareModal component', function () {
|
|
|
37
37
|
expect(root.getByText('ShareDialogOnlyByLink'));
|
|
38
38
|
});
|
|
39
39
|
it('should render ShareDialogCozyToCozy if type is Notes', function () {
|
|
40
|
+
var root = setup({
|
|
41
|
+
documentType: 'Notes'
|
|
42
|
+
});
|
|
43
|
+
expect(root.getByText('ShareDialogCozyToCozy'));
|
|
44
|
+
});
|
|
45
|
+
it('should render ShareDialogOnlyByLink if flag cozy.hide-sharing-cozy-to-cozy is true', function () {
|
|
40
46
|
flag.mockImplementation(function () {
|
|
41
47
|
return true;
|
|
42
48
|
});
|
|
43
49
|
var root = setup({
|
|
44
|
-
documentType: '
|
|
50
|
+
documentType: 'Document'
|
|
45
51
|
});
|
|
46
|
-
expect(root.getByText('
|
|
52
|
+
expect(root.getByText('ShareDialogOnlyByLink'));
|
|
47
53
|
});
|
|
48
54
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-sharing",
|
|
3
|
-
"version": "25.
|
|
3
|
+
"version": "25.3.0",
|
|
4
4
|
"description": "Provides sharing login for React applications.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "Cozy",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"sideEffects": [
|
|
80
80
|
"*.css"
|
|
81
81
|
],
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "0b4c6250306923e1107739de17d8541aba51a425"
|
|
83
83
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
|
|
3
|
+
import { useClient } from 'cozy-client'
|
|
3
4
|
import Avatar from 'cozy-ui/transpiled/react/Avatar'
|
|
4
5
|
|
|
5
6
|
import logger from '../../logger'
|
|
6
7
|
import { getInitials } from '../../models'
|
|
7
8
|
|
|
8
9
|
const MemberAvatar = ({ recipient, ...rest }) => {
|
|
10
|
+
const client = useClient()
|
|
11
|
+
|
|
9
12
|
// There are cases when due to apparent memory leaks, the recipient does not exist
|
|
10
13
|
// This will trigger an unhanded error in the Avatar component and crash the app
|
|
11
14
|
// At the moment, we are not sure where is the root cause of this cascading undefined props
|
|
@@ -26,22 +29,18 @@ const MemberAvatar = ({ recipient, ...rest }) => {
|
|
|
26
29
|
* status in the url force the refresh of the image when the
|
|
27
30
|
* status changes
|
|
28
31
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// : null
|
|
32
|
+
const image =
|
|
33
|
+
recipient.avatarPath && recipient.status
|
|
34
|
+
? `${client.options.uri}${recipient.avatarPath}?v=${recipient.status}`
|
|
35
|
+
: null
|
|
34
36
|
|
|
35
37
|
return (
|
|
36
|
-
<Avatar
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
recipient
|
|
41
|
-
}
|
|
42
|
-
{...rest}
|
|
43
|
-
>
|
|
44
|
-
{getInitials(recipient)}
|
|
38
|
+
<Avatar {...rest}>
|
|
39
|
+
{image ? (
|
|
40
|
+
<img width="100%" height="100%" src={image} />
|
|
41
|
+
) : (
|
|
42
|
+
getInitials(recipient)
|
|
43
|
+
)}
|
|
45
44
|
</Avatar>
|
|
46
45
|
)
|
|
47
46
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import PropTypes from 'prop-types'
|
|
2
2
|
import React from 'react'
|
|
3
3
|
|
|
4
|
+
import flag from 'cozy-flags'
|
|
5
|
+
|
|
4
6
|
import ShareDialogCozyToCozy from './ShareDialogCozyToCozy'
|
|
5
7
|
import ShareDialogOnlyByLink from './ShareDialogOnlyByLink'
|
|
6
8
|
|
|
@@ -22,7 +24,8 @@ export const ShareModal = ({
|
|
|
22
24
|
sharingDesc,
|
|
23
25
|
twoStepsConfirmationMethods
|
|
24
26
|
}) => {
|
|
25
|
-
const shareDialogOnlyByLink =
|
|
27
|
+
const shareDialogOnlyByLink =
|
|
28
|
+
flag('cozy.hide-sharing-cozy-to-cozy') || documentType === 'Albums'
|
|
26
29
|
|
|
27
30
|
const showShareByEmail = !hasSharedParent && !hasSharedChild
|
|
28
31
|
const showShareByLink = documentType !== 'Organizations'
|
|
@@ -37,9 +37,16 @@ describe('ShareModal component', () => {
|
|
|
37
37
|
})
|
|
38
38
|
|
|
39
39
|
it('should render ShareDialogCozyToCozy if type is Notes', () => {
|
|
40
|
-
flag.mockImplementation(() => true)
|
|
41
40
|
const root = setup({ documentType: 'Notes' })
|
|
42
41
|
|
|
43
42
|
expect(root.getByText('ShareDialogCozyToCozy'))
|
|
44
43
|
})
|
|
44
|
+
|
|
45
|
+
it('should render ShareDialogOnlyByLink if flag cozy.hide-sharing-cozy-to-cozy is true', () => {
|
|
46
|
+
flag.mockImplementation(() => true)
|
|
47
|
+
|
|
48
|
+
const root = setup({ documentType: 'Document' })
|
|
49
|
+
|
|
50
|
+
expect(root.getByText('ShareDialogOnlyByLink'))
|
|
51
|
+
})
|
|
45
52
|
})
|