cozy-sharing 25.2.0 → 25.3.1
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 +13 -0
- package/__tests__/fixtures.js +16 -2
- package/dist/components/Avatar/MemberAvatar.js +11 -14
- package/dist/components/ShareModal.js +2 -1
- package/dist/components/ShareModal.spec.js +8 -2
- package/dist/state.js +1 -1
- 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/src/state.js +1 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,19 @@
|
|
|
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.1](https://github.com/cozy/cozy-libs/compare/cozy-sharing@25.3.0...cozy-sharing@25.3.1) (2025-05-07)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- Do not rely on attributes ([a77602c](https://github.com/cozy/cozy-libs/commit/a77602cfbbce6b08296578b12863c631251f99a4))
|
|
11
|
+
|
|
12
|
+
# [25.3.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@25.2.0...cozy-sharing@25.3.0) (2025-04-28)
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
- Allow to hide cozy to cozy sharing with a flag ([3836c83](https://github.com/cozy/cozy-libs/commit/3836c837713f3122b8657b4cff8a9274c7d949ed))
|
|
17
|
+
- Enable again avatar display from cozy-stack ([9d716ab](https://github.com/cozy/cozy-libs/commit/9d716ab8eb64e0254386e1c572317a9f49fe21db))
|
|
18
|
+
|
|
6
19
|
# [25.2.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@25.1.1...cozy-sharing@25.2.0) (2025-04-22)
|
|
7
20
|
|
|
8
21
|
### Features
|
package/__tests__/fixtures.js
CHANGED
|
@@ -326,8 +326,15 @@ export const PERM_WITHOUT_DOC = {
|
|
|
326
326
|
|
|
327
327
|
export const APPS = [
|
|
328
328
|
{
|
|
329
|
-
|
|
329
|
+
_type: 'io.cozy.apps',
|
|
330
330
|
id: 'io.cozy.apps/drive',
|
|
331
|
+
_id: 'io.cozy.apps/drive',
|
|
332
|
+
name: 'Drive',
|
|
333
|
+
name_prefix: 'Cozy',
|
|
334
|
+
editor: 'Cozy',
|
|
335
|
+
type: 'webapp',
|
|
336
|
+
slug: 'drive',
|
|
337
|
+
state: 'ready',
|
|
331
338
|
attributes: {
|
|
332
339
|
name: 'Drive',
|
|
333
340
|
name_prefix: 'Cozy',
|
|
@@ -343,8 +350,15 @@ export const APPS = [
|
|
|
343
350
|
}
|
|
344
351
|
},
|
|
345
352
|
{
|
|
346
|
-
|
|
353
|
+
_type: 'io.cozy.apps',
|
|
347
354
|
id: 'io.cozy.apps/photos',
|
|
355
|
+
_id: 'io.cozy.apps/photos',
|
|
356
|
+
name: 'Photos',
|
|
357
|
+
name_prefix: 'Cozy',
|
|
358
|
+
editor: 'Cozy',
|
|
359
|
+
type: 'webapp',
|
|
360
|
+
slug: 'photos',
|
|
361
|
+
state: 'ready',
|
|
348
362
|
attributes: {
|
|
349
363
|
name: 'Photos',
|
|
350
364
|
name_prefix: 'Cozy',
|
|
@@ -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/dist/state.js
CHANGED
|
@@ -743,7 +743,7 @@ var getAppUrlForDoctype = function getAppUrlForDoctype(state, documentType) {
|
|
|
743
743
|
|
|
744
744
|
var getAppUrl = function getAppUrl(apps, appName) {
|
|
745
745
|
var app = apps.find(function (a) {
|
|
746
|
-
return a.
|
|
746
|
+
return (a === null || a === void 0 ? void 0 : a.slug) === appName && (a === null || a === void 0 ? void 0 : a.state) === 'ready';
|
|
747
747
|
});
|
|
748
748
|
|
|
749
749
|
if (!app) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-sharing",
|
|
3
|
-
"version": "25.
|
|
3
|
+
"version": "25.3.1",
|
|
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": "61ca8961df0f9a50cf58348d90fbfdd67f36b22b"
|
|
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
|
})
|
package/src/state.js
CHANGED
|
@@ -621,9 +621,7 @@ const getAppUrlForDoctype = (state, documentType) => {
|
|
|
621
621
|
}
|
|
622
622
|
|
|
623
623
|
const getAppUrl = (apps, appName) => {
|
|
624
|
-
const app = apps.find(
|
|
625
|
-
a => a.attributes.slug === appName && a.attributes.state === 'ready'
|
|
626
|
-
)
|
|
624
|
+
const app = apps.find(a => a?.slug === appName && a?.state === 'ready')
|
|
627
625
|
if (!app) {
|
|
628
626
|
throw new Error(`Sharing link: app ${appName} not installed`)
|
|
629
627
|
}
|