cozy-sharing 10.4.1 → 11.0.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/.storybook/fixtures/recipients.js +30 -0
- package/.storybook/main.js +18 -0
- package/.storybook/manager.js +6 -0
- package/.storybook/preview-head.html +21 -0
- package/.storybook/preview.jsx +64 -0
- package/.storybook/public/Lato-Bold.immutable.woff2 +0 -0
- package/.storybook/public/Lato-Regular.immutable.woff2 +0 -0
- package/CHANGELOG.md +38 -0
- package/dist/SharedRecipients.js +2 -2
- package/dist/SharedStatus.js +2 -2
- package/dist/SharingOwnerAvatar.js +2 -2
- package/dist/components/{Recipient/RecipientsAvatars.js → Avatar/AvatarList.js} +11 -11
- package/dist/components/{Recipient/RecipientsAvatars.spec.js → Avatar/AvatarList.spec.js} +10 -10
- package/dist/components/Avatar/AvatarList.stories.js +14 -0
- package/dist/components/{Recipient/AvatarPlusX.js → Avatar/ExtraAvatar.js} +4 -4
- package/dist/components/Avatar/ExtraAvatar.stories.js +10 -0
- package/dist/components/Avatar/MemberAvatar.js +52 -0
- package/dist/components/Avatar/MemberAvatar.stories.js +15 -0
- package/dist/components/ConfirmTrustedRecipientsDialog.js +2 -2
- package/dist/components/{Recipient/RecipientPlusX.js → Identity/ExtraIdentity.js} +5 -5
- package/dist/components/Identity/ExtraIdentity.stories.js +13 -0
- package/dist/components/Identity/Identity.stories.js +13 -0
- package/dist/components/{Recipient/RecipientWithoutStatus.js → Identity/MemberIdentity.js} +2 -2
- package/dist/components/Identity/MemberIdentity.stories.js +10 -0
- package/dist/components/Identity/OwnerIdentity.stories.js +10 -0
- package/dist/components/Recipient/LinkRecipient.stories.js +16 -0
- package/dist/components/Recipient/LinkRecipientPermissions.stories.js +10 -0
- package/dist/components/Recipient/{Recipient.js → MemberRecipient.js} +9 -9
- package/dist/components/Recipient/{Recipient.spec.js → MemberRecipient.spec.js} +3 -3
- package/dist/components/Recipient/MemberRecipient.stories.js +39 -0
- package/dist/components/Recipient/{RecipientPermissions.js → MemberRecipientPermissions.js} +2 -2
- package/dist/components/Recipient/MemberRecipientPermissions.stories.js +10 -0
- package/dist/components/Recipient/{RecipientStatus.js → MemberRecipientStatus.js} +2 -2
- package/dist/components/Recipient/MemberRecipientStatus.stories.js +10 -0
- package/dist/components/Recipient/OwnerRecipient.js +2 -2
- package/dist/components/Recipient/OwnerRecipient.stories.js +13 -0
- package/dist/components/Recipient/OwnerRecipientDefault.js +2 -2
- package/dist/components/Recipient/OwnerRecipientDefault.stories.js +10 -0
- package/dist/components/Recipient/RecipientConfirm.js +2 -2
- package/dist/components/Recipient/RecipientConfirm.stories.js +10 -0
- package/dist/components/Recipient/RecipientList.js +2 -2
- package/dist/components/Recipient/RecipientList.stories.js +26 -0
- package/dist/components/ShareModal/SharingDetailsModal.js +1 -1
- package/dist/components/WhoHasAccessLight.js +4 -4
- package/dist/stylesheet.css +10 -10
- package/package.json +14 -4
- package/src/SharedRecipients.jsx +2 -2
- package/src/SharedStatus.jsx +2 -2
- package/src/SharingOwnerAvatar.jsx +2 -2
- package/src/components/{Recipient/RecipientsAvatars.jsx → Avatar/AvatarList.jsx} +12 -11
- package/src/components/{Recipient/RecipientsAvatars.spec.jsx → Avatar/AvatarList.spec.jsx} +12 -11
- package/src/components/Avatar/AvatarList.stories.jsx +16 -0
- package/src/components/{Recipient/AvatarPlusX.jsx → Avatar/ExtraAvatar.jsx} +4 -4
- package/src/components/Avatar/ExtraAvatar.stories.jsx +13 -0
- package/src/components/{Recipient/RecipientAvatar.jsx → Avatar/MemberAvatar.jsx} +13 -2
- package/src/components/Avatar/MemberAvatar.stories.jsx +18 -0
- package/src/components/ConfirmTrustedRecipientsDialog.jsx +2 -2
- package/src/components/{Recipient/RecipientPlusX.jsx → Identity/ExtraIdentity.jsx} +5 -5
- package/src/components/Identity/ExtraIdentity.stories.jsx +16 -0
- package/src/components/Identity/Identity.stories.jsx +16 -0
- package/src/components/{Recipient/RecipientWithoutStatus.jsx → Identity/MemberIdentity.jsx} +2 -2
- package/src/components/Identity/MemberIdentity.stories.jsx +13 -0
- package/src/components/Identity/OwnerIdentity.stories.jsx +13 -0
- package/src/components/Recipient/LinkRecipient.stories.jsx +17 -0
- package/src/components/Recipient/LinkRecipientPermissions.stories.jsx +13 -0
- package/src/components/Recipient/{Recipient.jsx → MemberRecipient.jsx} +14 -10
- package/src/components/Recipient/{Recipient.spec.jsx → MemberRecipient.spec.jsx} +3 -3
- package/src/components/Recipient/MemberRecipient.stories.jsx +44 -0
- package/src/components/Recipient/{RecipientPermissions.jsx → MemberRecipientPermissions.jsx} +2 -2
- package/src/components/Recipient/MemberRecipientPermissions.stories.jsx +13 -0
- package/src/components/Recipient/{RecipientStatus.jsx → MemberRecipientStatus.jsx} +2 -2
- package/src/components/Recipient/MemberRecipientStatus.stories.jsx +13 -0
- package/src/components/Recipient/OwnerRecipient.jsx +2 -2
- package/src/components/Recipient/OwnerRecipient.stories.jsx +16 -0
- package/src/components/Recipient/OwnerRecipientDefault.jsx +2 -2
- package/src/components/Recipient/OwnerRecipientDefault.stories.jsx +13 -0
- package/src/components/Recipient/RecipientConfirm.jsx +7 -9
- package/src/components/Recipient/RecipientConfirm.stories.jsx +13 -0
- package/src/components/Recipient/RecipientList.jsx +2 -2
- package/src/components/Recipient/RecipientList.stories.jsx +28 -0
- package/src/components/ShareModal/SharingDetailsModal.jsx +1 -1
- package/src/components/WhoHasAccessLight.jsx +4 -4
- package/dist/components/Recipient/RecipientAvatar.js +0 -33
- /package/dist/components/{Recipient → Identity}/Identity.js +0 -0
- /package/dist/components/{Recipient → Identity}/OwnerIdentity.js +0 -0
- /package/src/components/{Recipient → Identity}/Identity.jsx +0 -0
- /package/src/components/{Recipient → Identity}/OwnerIdentity.jsx +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const recipients = [
|
|
2
|
+
{
|
|
3
|
+
status: 'owner',
|
|
4
|
+
public_name: 'Alice',
|
|
5
|
+
email: 'alice@cozy.localhost',
|
|
6
|
+
instance: 'http://alice.cozy.localhost:8080',
|
|
7
|
+
type: 'two-way',
|
|
8
|
+
index: 0
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
status: 'pending',
|
|
12
|
+
email: 'bob@cozy.localhost',
|
|
13
|
+
type: 'two-way',
|
|
14
|
+
index: 1
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: 'Paul',
|
|
18
|
+
status: 'mail-not-sent',
|
|
19
|
+
email: 'paul@cozy.localhost',
|
|
20
|
+
index: 2
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'Eve',
|
|
24
|
+
status: 'ready',
|
|
25
|
+
email: 'eve@cozy.localhost',
|
|
26
|
+
index: 2
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
export { recipients }
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const config = {
|
|
2
|
+
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
|
|
3
|
+
addons: [
|
|
4
|
+
"@storybook/addon-links",
|
|
5
|
+
"@storybook/addon-essentials",
|
|
6
|
+
"@storybook/addon-interactions",
|
|
7
|
+
],
|
|
8
|
+
framework: {
|
|
9
|
+
name: "@storybook/react-webpack5",
|
|
10
|
+
options: {},
|
|
11
|
+
},
|
|
12
|
+
docs: {
|
|
13
|
+
autodocs: true
|
|
14
|
+
},
|
|
15
|
+
staticDirs: ['./public'],
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default config;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<!-- This is the `head` of the preview iframe -->
|
|
2
|
+
<!-- Pull in static files served from your Static directory or the internet -->
|
|
3
|
+
|
|
4
|
+
<meta name="color-scheme" content="only light" />
|
|
5
|
+
<style>
|
|
6
|
+
@font-face {
|
|
7
|
+
font-family: Lato;
|
|
8
|
+
font-style: normal;
|
|
9
|
+
font-weight: normal;
|
|
10
|
+
src: url("/Lato-Regular.immutable.woff2") format("woff2");
|
|
11
|
+
font-display: fallback;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@font-face {
|
|
15
|
+
font-family: Lato;
|
|
16
|
+
font-style: normal;
|
|
17
|
+
font-weight: bold;
|
|
18
|
+
src: url("/Lato-Bold.immutable.woff2") format("woff2");
|
|
19
|
+
font-display: fallback;
|
|
20
|
+
}
|
|
21
|
+
</style>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import 'cozy-ui/dist/cozy-ui.min.css'
|
|
4
|
+
import 'cozy-ui/dist/cozy-ui.utils.min.css'
|
|
5
|
+
import 'cozy-ui/transpiled/react/stylesheet.css'
|
|
6
|
+
|
|
7
|
+
import I18n from 'cozy-ui/transpiled/react/providers/I18n'
|
|
8
|
+
import { BreakpointsProvider } from 'cozy-ui/transpiled/react/providers/Breakpoints'
|
|
9
|
+
import CozyTheme from 'cozy-ui/transpiled/react/providers/CozyTheme'
|
|
10
|
+
import { CozyProvider, createFakeClient } from 'cozy-client'
|
|
11
|
+
|
|
12
|
+
import enLocale from '../locales/en.json'
|
|
13
|
+
|
|
14
|
+
const preview = {
|
|
15
|
+
decorators: [
|
|
16
|
+
(Story) => {
|
|
17
|
+
const fakeClient = createFakeClient({
|
|
18
|
+
queries: {
|
|
19
|
+
'io.cozy.settings/instance': {
|
|
20
|
+
doctype: 'io.cozy.settings',
|
|
21
|
+
definition: {
|
|
22
|
+
doctype: 'io.cozy.settings',
|
|
23
|
+
id: 'io.cozy.settings/io.cozy.settings.instance'
|
|
24
|
+
},
|
|
25
|
+
data: [
|
|
26
|
+
{
|
|
27
|
+
id: 'io.cozy.settings/io.cozy.settings.instance',
|
|
28
|
+
attributes: {
|
|
29
|
+
public_name: 'Alice'
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
clientOptions: {
|
|
36
|
+
uri: 'http://alice.cozy.localhost:8080'
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
return (
|
|
40
|
+
<CozyProvider client={fakeClient}>
|
|
41
|
+
<CozyTheme>
|
|
42
|
+
<BreakpointsProvider>
|
|
43
|
+
<I18n lang="en" dictRequire={() => enLocale}>
|
|
44
|
+
<div style={{position: "relative"}}>
|
|
45
|
+
<Story />
|
|
46
|
+
</div>
|
|
47
|
+
</I18n>
|
|
48
|
+
</BreakpointsProvider>
|
|
49
|
+
</CozyTheme>
|
|
50
|
+
</CozyProvider>
|
|
51
|
+
)},
|
|
52
|
+
],
|
|
53
|
+
parameters: {
|
|
54
|
+
actions: { argTypesRegex: "^on[A-Z].*" },
|
|
55
|
+
controls: {
|
|
56
|
+
matchers: {
|
|
57
|
+
color: /(background|color)$/i,
|
|
58
|
+
date: /Date$/,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export default preview;
|
|
Binary file
|
|
Binary file
|
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
|
+
## [11.0.1](https://github.com/cozy/cozy-libs/compare/cozy-sharing@11.0.0...cozy-sharing@11.0.1) (2024-03-12)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **sharing:** Handle memory leak in self removal ([f9a9384](https://github.com/cozy/cozy-libs/commit/f9a9384fabb8892e35be0a270452ee501bd6b1a6))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [11.0.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@10.4.1...cozy-sharing@11.0.0) (2024-03-11)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* Add missing args into stories ([3658ead](https://github.com/cozy/cozy-libs/commit/3658ead89344c20f59d4c8693522c73d40c20761))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Code Refactoring
|
|
26
|
+
|
|
27
|
+
* Rename RecipientsAvatars into AvatarList ([abef583](https://github.com/cozy/cozy-libs/commit/abef5830bf774855e39e8cf0149e26b49f53a367))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Features
|
|
31
|
+
|
|
32
|
+
* Add stories to recipient components ([b32f881](https://github.com/cozy/cozy-libs/commit/b32f881e031d61676097f94a2015227e99e1fb67))
|
|
33
|
+
* **sharing:** Add storybook ([fa7a028](https://github.com/cozy/cozy-libs/commit/fa7a0286ee18421ead00a061d9a1aa8f6d755978))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### BREAKING CHANGES
|
|
37
|
+
|
|
38
|
+
* If you were importing RecipientsAvatars directly you should now use `import { AvatarList as RecipientsAvatars } from 'cozy-sharing/dist/components/Avatar/AvatarList'`
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
6
44
|
## [10.4.1](https://github.com/cozy/cozy-libs/compare/cozy-sharing@10.4.0...cozy-sharing@10.4.1) (2024-03-01)
|
|
7
45
|
|
|
8
46
|
|
package/dist/SharedRecipients.js
CHANGED
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
3
|
var _excluded = ["docId", "onClick"];
|
|
4
4
|
import React from 'react';
|
|
5
|
-
import
|
|
5
|
+
import { AvatarList } from './components/Avatar/AvatarList';
|
|
6
6
|
import SharingContext from './context';
|
|
7
7
|
import withLocales from './hoc/withLocales';
|
|
8
8
|
export var SharedRecipients = withLocales(function (_ref) {
|
|
@@ -17,7 +17,7 @@ export var SharedRecipients = withLocales(function (_ref) {
|
|
|
17
17
|
getSharingLink = _ref2.getSharingLink,
|
|
18
18
|
isOwner = _ref2.isOwner;
|
|
19
19
|
|
|
20
|
-
return !byDocId || !byDocId[docId] ? null : /*#__PURE__*/React.createElement(
|
|
20
|
+
return !byDocId || !byDocId[docId] ? null : /*#__PURE__*/React.createElement(AvatarList, _extends({
|
|
21
21
|
recipients: getRecipients(docId),
|
|
22
22
|
link: getSharingLink(docId) !== null,
|
|
23
23
|
onClick: onClick,
|
package/dist/SharedStatus.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { AvatarList } from './components/Avatar/AvatarList';
|
|
3
3
|
import SharingContext from './context';
|
|
4
4
|
import withLocales from './hoc/withLocales';
|
|
5
5
|
export var SharedStatus = withLocales(function (_ref) {
|
|
@@ -17,7 +17,7 @@ export var SharedStatus = withLocales(function (_ref) {
|
|
|
17
17
|
|
|
18
18
|
return !byDocId || !byDocId[docId] ? /*#__PURE__*/React.createElement("span", {
|
|
19
19
|
className: className + ' ' + noSharedClassName
|
|
20
|
-
}, "\u2014") : /*#__PURE__*/React.createElement(
|
|
20
|
+
}, "\u2014") : /*#__PURE__*/React.createElement(AvatarList, {
|
|
21
21
|
className: className,
|
|
22
22
|
recipients: getRecipients(docId),
|
|
23
23
|
link: getSharingLink(docId) !== null,
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
3
|
var _excluded = ["docId"];
|
|
4
4
|
import React from 'react';
|
|
5
|
-
import
|
|
5
|
+
import { MemberAvatar } from './components/Avatar/MemberAvatar';
|
|
6
6
|
import SharingContext from './context';
|
|
7
7
|
import withLocales from './hoc/withLocales';
|
|
8
8
|
export var SharingOwnerAvatar = withLocales(function (_ref) {
|
|
@@ -14,7 +14,7 @@ export var SharingOwnerAvatar = withLocales(function (_ref) {
|
|
|
14
14
|
byDocId = _ref2.byDocId,
|
|
15
15
|
getOwner = _ref2.getOwner;
|
|
16
16
|
|
|
17
|
-
return !byDocId || !byDocId[docId] ? null : /*#__PURE__*/React.createElement(
|
|
17
|
+
return !byDocId || !byDocId[docId] ? null : /*#__PURE__*/React.createElement(MemberAvatar, _extends({
|
|
18
18
|
recipient: getOwner(docId)
|
|
19
19
|
}, rest));
|
|
20
20
|
});
|
|
@@ -4,8 +4,8 @@ import React from 'react';
|
|
|
4
4
|
import { useClient } from 'cozy-client';
|
|
5
5
|
import Avatar from 'cozy-ui/transpiled/react/Avatar';
|
|
6
6
|
import LinkIcon from 'cozy-ui/transpiled/react/Icons/Link';
|
|
7
|
-
import
|
|
8
|
-
import
|
|
7
|
+
import { ExtraAvatar } from './ExtraAvatar';
|
|
8
|
+
import { MemberAvatar } from './MemberAvatar';
|
|
9
9
|
import { getDisplayName } from '../../models';
|
|
10
10
|
var styles = {
|
|
11
11
|
"recipient": "recipient__recipient___2DmZI",
|
|
@@ -47,7 +47,7 @@ export var excludeMeAsOwnerFromRecipients = function excludeMeAsOwnerFromRecipie
|
|
|
47
47
|
});
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
var
|
|
50
|
+
var AvatarList = function AvatarList(_ref2) {
|
|
51
51
|
var recipients = _ref2.recipients,
|
|
52
52
|
link = _ref2.link,
|
|
53
53
|
size = _ref2.size,
|
|
@@ -63,7 +63,7 @@ var RecipientsAvatars = function RecipientsAvatars(_ref2) {
|
|
|
63
63
|
client: client
|
|
64
64
|
}).reverse(); // we reverse the recipients array because we use `flex-direction: row-reverse` to display them correctly
|
|
65
65
|
|
|
66
|
-
var
|
|
66
|
+
var hasExtraRecipients = filteredRecipients.length > MAX_DISPLAYED_RECIPIENTS;
|
|
67
67
|
var extraRecipients = filteredRecipients.slice(MAX_DISPLAYED_RECIPIENTS).map(function (recipient) {
|
|
68
68
|
return getDisplayName(recipient);
|
|
69
69
|
});
|
|
@@ -72,22 +72,22 @@ var RecipientsAvatars = function RecipientsAvatars(_ref2) {
|
|
|
72
72
|
className: cx(styles['recipients-avatars'], _defineProperty({}, styles['--interactive'], onClick), className),
|
|
73
73
|
onClick: onClick
|
|
74
74
|
}, link && /*#__PURE__*/React.createElement("span", {
|
|
75
|
-
"data-testid": "
|
|
75
|
+
"data-testid": "AvatarList-link"
|
|
76
76
|
}, /*#__PURE__*/React.createElement(Avatar, {
|
|
77
77
|
className: styles['recipients-avatars--link'],
|
|
78
78
|
icon: LinkIcon,
|
|
79
79
|
size: size
|
|
80
|
-
})),
|
|
81
|
-
"data-testid": "
|
|
82
|
-
}, /*#__PURE__*/React.createElement(
|
|
80
|
+
})), hasExtraRecipients && /*#__PURE__*/React.createElement("span", {
|
|
81
|
+
"data-testid": "AvatarList-plusX"
|
|
82
|
+
}, /*#__PURE__*/React.createElement(ExtraAvatar, {
|
|
83
83
|
className: styles['recipients-avatars--plusX'],
|
|
84
84
|
extraRecipients: extraRecipients,
|
|
85
85
|
size: size
|
|
86
86
|
})), shownRecipients.map(function (recipient, idx) {
|
|
87
87
|
return /*#__PURE__*/React.createElement("span", {
|
|
88
|
-
"data-testid": "
|
|
88
|
+
"data-testid": "AvatarList-avatar".concat(recipient.status === 'owner' ? '-owner' : ''),
|
|
89
89
|
key: idx
|
|
90
|
-
}, /*#__PURE__*/React.createElement(
|
|
90
|
+
}, /*#__PURE__*/React.createElement(MemberAvatar, {
|
|
91
91
|
recipient: recipient,
|
|
92
92
|
size: size,
|
|
93
93
|
className: cx(styles['recipients-avatars--avatar'])
|
|
@@ -95,4 +95,4 @@ var RecipientsAvatars = function RecipientsAvatars(_ref2) {
|
|
|
95
95
|
}));
|
|
96
96
|
};
|
|
97
97
|
|
|
98
|
-
export
|
|
98
|
+
export { AvatarList };
|
|
@@ -5,7 +5,7 @@ var _excluded = ["recipients", "link", "isOwner", "onClick"];
|
|
|
5
5
|
import { render } from '@testing-library/react';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { createMockClient } from 'cozy-client';
|
|
8
|
-
import
|
|
8
|
+
import { AvatarList, MAX_DISPLAYED_RECIPIENTS, excludeMeAsOwnerFromRecipients } from './AvatarList';
|
|
9
9
|
import AppLike from '../../../test/AppLike';
|
|
10
10
|
var mockRecipients = new Array(MAX_DISPLAYED_RECIPIENTS - 1).fill({
|
|
11
11
|
status: 'owner',
|
|
@@ -24,7 +24,7 @@ var mockMoreRecipientsThanMaxDisplayed = [].concat(_toConsumableArray(mockRecipi
|
|
|
24
24
|
status: 'ready',
|
|
25
25
|
name: 'John Connor'
|
|
26
26
|
}]);
|
|
27
|
-
describe('
|
|
27
|
+
describe('AvatarList', function () {
|
|
28
28
|
var client = createMockClient({});
|
|
29
29
|
|
|
30
30
|
var setup = function setup(_ref) {
|
|
@@ -42,7 +42,7 @@ describe('RecipientsAvatars', function () {
|
|
|
42
42
|
|
|
43
43
|
return render( /*#__PURE__*/React.createElement(AppLike, {
|
|
44
44
|
client: client
|
|
45
|
-
}, /*#__PURE__*/React.createElement(
|
|
45
|
+
}, /*#__PURE__*/React.createElement(AvatarList, _extends({
|
|
46
46
|
recipients: recipients,
|
|
47
47
|
onClick: onClick,
|
|
48
48
|
isOwner: isOwner,
|
|
@@ -56,19 +56,19 @@ describe('RecipientsAvatars', function () {
|
|
|
56
56
|
}),
|
|
57
57
|
getByTestId = _setup.getByTestId;
|
|
58
58
|
|
|
59
|
-
expect(getByTestId('
|
|
59
|
+
expect(getByTestId('AvatarList-link')).toBeTruthy();
|
|
60
60
|
});
|
|
61
61
|
it('should not render link icon if a link is not generated', function () {
|
|
62
62
|
var _setup2 = setup({}),
|
|
63
63
|
queryByTestId = _setup2.queryByTestId;
|
|
64
64
|
|
|
65
|
-
expect(queryByTestId('
|
|
65
|
+
expect(queryByTestId('AvatarList-link')).toBeNull();
|
|
66
66
|
});
|
|
67
67
|
it('should hide me as owner by default', function () {
|
|
68
68
|
var _setup3 = setup({}),
|
|
69
69
|
queryByTestId = _setup3.queryByTestId;
|
|
70
70
|
|
|
71
|
-
expect(queryByTestId('
|
|
71
|
+
expect(queryByTestId('AvatarList-avatar-owner')).toBeNull();
|
|
72
72
|
});
|
|
73
73
|
it('should show me as owner if required', function () {
|
|
74
74
|
var _setup4 = setup({
|
|
@@ -76,7 +76,7 @@ describe('RecipientsAvatars', function () {
|
|
|
76
76
|
}),
|
|
77
77
|
getByTestId = _setup4.getByTestId;
|
|
78
78
|
|
|
79
|
-
expect(getByTestId('
|
|
79
|
+
expect(getByTestId('AvatarList-avatar-owner')).toBeTruthy();
|
|
80
80
|
});
|
|
81
81
|
it('should show a +X icon with the correct number if there is more avatars than expected', function () {
|
|
82
82
|
var _setup5 = setup({
|
|
@@ -87,7 +87,7 @@ describe('RecipientsAvatars', function () {
|
|
|
87
87
|
getByText = _setup5.getByText;
|
|
88
88
|
|
|
89
89
|
var delta = mockMoreRecipientsThanMaxDisplayed.length - MAX_DISPLAYED_RECIPIENTS;
|
|
90
|
-
expect(getByTestId('
|
|
90
|
+
expect(getByTestId('AvatarList-plusX')).toBeTruthy();
|
|
91
91
|
expect(getByText("+".concat(delta))).toBeTruthy();
|
|
92
92
|
});
|
|
93
93
|
it('should show both +X and link icon if necessary', function () {
|
|
@@ -98,8 +98,8 @@ describe('RecipientsAvatars', function () {
|
|
|
98
98
|
}),
|
|
99
99
|
getByTestId = _setup6.getByTestId;
|
|
100
100
|
|
|
101
|
-
expect(getByTestId('
|
|
102
|
-
expect(getByTestId('
|
|
101
|
+
expect(getByTestId('AvatarList-plusX')).toBeTruthy();
|
|
102
|
+
expect(getByTestId('AvatarList-link')).toBeTruthy();
|
|
103
103
|
});
|
|
104
104
|
});
|
|
105
105
|
describe('excludeMeAsOwnerFromRecipients', function () {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import { AvatarList } from './AvatarList';
|
|
3
|
+
import { recipients } from '../../../.storybook/fixtures/recipients';
|
|
4
|
+
var meta = {
|
|
5
|
+
component: AvatarList,
|
|
6
|
+
args: {
|
|
7
|
+
recipients: [].concat(_toConsumableArray(recipients), _toConsumableArray(recipients))
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
export var Default = {
|
|
12
|
+
name: 'Default',
|
|
13
|
+
args: {}
|
|
14
|
+
};
|
|
@@ -4,7 +4,7 @@ import React from 'react';
|
|
|
4
4
|
import Avatar from 'cozy-ui/transpiled/react/Avatar';
|
|
5
5
|
import { SharingTooltip, TooltipRecipientList } from '../Tooltip';
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var ExtraAvatar = function ExtraAvatar(_ref) {
|
|
8
8
|
var className = _ref.className,
|
|
9
9
|
size = _ref.size,
|
|
10
10
|
_ref$extraRecipients = _ref.extraRecipients,
|
|
@@ -29,13 +29,13 @@ var AvatarPlusX = function AvatarPlusX(_ref) {
|
|
|
29
29
|
})));
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
ExtraAvatar.propTypes = {
|
|
33
33
|
extraRecipients: PropTypes.arrayOf(PropTypes.string),
|
|
34
34
|
size: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
35
35
|
className: PropTypes.string
|
|
36
36
|
};
|
|
37
|
-
|
|
37
|
+
ExtraAvatar.defaultProps = {
|
|
38
38
|
extraRecipients: [],
|
|
39
39
|
size: 'medium'
|
|
40
40
|
};
|
|
41
|
-
export
|
|
41
|
+
export { ExtraAvatar };
|
|
@@ -0,0 +1,52 @@
|
|
|
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 = ["recipient"];
|
|
5
|
+
|
|
6
|
+
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; }
|
|
7
|
+
|
|
8
|
+
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
|
+
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import { useClient } from 'cozy-client';
|
|
12
|
+
import Avatar from 'cozy-ui/transpiled/react/Avatar';
|
|
13
|
+
import { getDisplayName, getInitials } from '../../models';
|
|
14
|
+
import logger from '../../logger';
|
|
15
|
+
|
|
16
|
+
var MemberAvatar = function MemberAvatar(_ref) {
|
|
17
|
+
var recipient = _ref.recipient,
|
|
18
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
19
|
+
|
|
20
|
+
var client = useClient(); // There are cases when due to apparent memory leaks, the recipient does not exist
|
|
21
|
+
// This will trigger an unhanded error in the Avatar component and crash the app
|
|
22
|
+
// At the moment, we are not sure where is the root cause of this cascading undefined props
|
|
23
|
+
// Nevertheless, we can prevent the crash by returning null if the recipient is undefined
|
|
24
|
+
|
|
25
|
+
if (!recipient) {
|
|
26
|
+
// eslint-disable-next-line
|
|
27
|
+
logger.warn('RecipientAvatar: recipient is missing, see props:', _objectSpread({
|
|
28
|
+
recipient: recipient
|
|
29
|
+
}, rest));
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* avatarPath is always the same for a recipient, but image
|
|
34
|
+
* can be different since the stack generate it on the fly.
|
|
35
|
+
* It can be "gray" during the first load depending of the
|
|
36
|
+
* status' sharing, but can become active (from the realtime)
|
|
37
|
+
* so we need a way to "refresh" the image. Passing the
|
|
38
|
+
* status in the url force the refresh of the image when the
|
|
39
|
+
* status changes
|
|
40
|
+
*/
|
|
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, _extends({
|
|
45
|
+
image: image,
|
|
46
|
+
text: getInitials(recipient),
|
|
47
|
+
textId: getDisplayName(recipient),
|
|
48
|
+
disabled: recipient.status === 'pending' || recipient.status === 'mail-not-send'
|
|
49
|
+
}, rest));
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export { MemberAvatar };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { MemberAvatar } from './MemberAvatar';
|
|
2
|
+
var meta = {
|
|
3
|
+
component: MemberAvatar,
|
|
4
|
+
args: {
|
|
5
|
+
recipient: {
|
|
6
|
+
avatarPath: null,
|
|
7
|
+
name: 'John Doe'
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
export default meta;
|
|
12
|
+
export var Default = {
|
|
13
|
+
name: 'Default',
|
|
14
|
+
args: {}
|
|
15
|
+
};
|
|
@@ -3,7 +3,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
5
5
|
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
|
|
6
|
-
import
|
|
6
|
+
import MemberRecipient from './Recipient/MemberRecipient';
|
|
7
7
|
import ShareDialogTwoStepsConfirmationContainer from './ShareDialogTwoStepsConfirmationContainer';
|
|
8
8
|
/**
|
|
9
9
|
* Displays the sharing interface that can be used when ConfirmTrustedRecipientsDialog is in sharing state
|
|
@@ -20,7 +20,7 @@ var SharingContent = function SharingContent(_ref) {
|
|
|
20
20
|
variant: "body1",
|
|
21
21
|
className: "u-mb-2"
|
|
22
22
|
}, t("ConfirmRecipientModal.intruction")), recipientsToBeConfirmed.map(function (recipientConfirmationData) {
|
|
23
|
-
return /*#__PURE__*/React.createElement(
|
|
23
|
+
return /*#__PURE__*/React.createElement(MemberRecipient, _extends({}, recipientConfirmationData, {
|
|
24
24
|
key: "key_r_".concat(recipientConfirmationData.id),
|
|
25
25
|
isOwner: false,
|
|
26
26
|
recipientConfirmationData: recipientConfirmationData,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import AvatarPlusX from './AvatarPlusX';
|
|
4
3
|
import Identity from './Identity';
|
|
5
4
|
import { getDisplayName } from '../../models';
|
|
6
5
|
var styles = {
|
|
@@ -20,13 +19,14 @@ var styles = {
|
|
|
20
19
|
"spin": "recipient__spin___2tYv3",
|
|
21
20
|
"shake": "recipient__shake___TGyPp"
|
|
22
21
|
};
|
|
22
|
+
import { ExtraAvatar } from '../Avatar/ExtraAvatar';
|
|
23
23
|
|
|
24
|
-
var
|
|
24
|
+
var ExtraIdentity = function ExtraIdentity(_ref, _ref2) {
|
|
25
25
|
var extraRecipients = _ref.extraRecipients;
|
|
26
26
|
var t = _ref2.t;
|
|
27
27
|
return /*#__PURE__*/React.createElement("div", {
|
|
28
28
|
className: styles['recipient']
|
|
29
|
-
}, /*#__PURE__*/React.createElement(
|
|
29
|
+
}, /*#__PURE__*/React.createElement(ExtraAvatar, {
|
|
30
30
|
extraRecipients: extraRecipients.map(function (recipient) {
|
|
31
31
|
return getDisplayName(recipient);
|
|
32
32
|
})
|
|
@@ -37,7 +37,7 @@ var RecipientPlusX = function RecipientPlusX(_ref, _ref2) {
|
|
|
37
37
|
})));
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
ExtraIdentity.contextTypes = {
|
|
41
41
|
t: PropTypes.func.isRequired
|
|
42
42
|
};
|
|
43
|
-
export
|
|
43
|
+
export { ExtraIdentity };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ExtraIdentity } from './ExtraIdentity';
|
|
2
|
+
import { recipients } from '../../../.storybook/fixtures/recipients';
|
|
3
|
+
var meta = {
|
|
4
|
+
component: ExtraIdentity,
|
|
5
|
+
args: {
|
|
6
|
+
extraRecipients: recipients
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
export default meta;
|
|
10
|
+
export var Default = {
|
|
11
|
+
name: 'Default',
|
|
12
|
+
args: {}
|
|
13
|
+
};
|
|
@@ -22,7 +22,7 @@ var styles = {
|
|
|
22
22
|
"shake": "recipient__shake___TGyPp"
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
var
|
|
25
|
+
var MemberIdentity = function MemberIdentity(_ref) {
|
|
26
26
|
var instance = _ref.instance,
|
|
27
27
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
28
28
|
|
|
@@ -40,4 +40,4 @@ var RecipientWithoutStatus = function RecipientWithoutStatus(_ref) {
|
|
|
40
40
|
})));
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
export
|
|
43
|
+
export { MemberIdentity };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import LinkRecipient from './LinkRecipient';
|
|
2
|
+
var meta = {
|
|
3
|
+
component: LinkRecipient,
|
|
4
|
+
args: {
|
|
5
|
+
recipientConfirmationData: false,
|
|
6
|
+
verifyRecipient: function verifyRecipient() {
|
|
7
|
+
return true;
|
|
8
|
+
},
|
|
9
|
+
link: 'test',
|
|
10
|
+
fadeIn: false
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
export default meta;
|
|
14
|
+
export var Default = {
|
|
15
|
+
name: 'Default'
|
|
16
|
+
};
|