cozy-sharing 12.1.0 → 12.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 +22 -0
- package/dist/components/Avatar/AvatarList.js +13 -2
- package/dist/components/Avatar/AvatarList.spec.js +11 -6
- package/dist/components/Avatar/AvatarList.stories.js +13 -1
- package/dist/components/Avatar/GroupAvatar.js +4 -2
- package/dist/components/ContactSuggestion.js +3 -14
- package/dist/components/ContactSuggestion.spec.js +22 -104
- package/dist/components/ShareAutosuggest.js +0 -3
- package/dist/components/ShareRecipientsInput.js +23 -1
- package/dist/components/ShareRecipientsInput.spec.js +206 -115
- package/jest.config.js +2 -1
- package/package.json +2 -2
- package/src/components/Avatar/AvatarList.jsx +33 -14
- package/src/components/Avatar/AvatarList.spec.jsx +11 -6
- package/src/components/Avatar/AvatarList.stories.jsx +19 -1
- package/src/components/Avatar/GroupAvatar.jsx +2 -2
- package/src/components/ContactSuggestion.jsx +3 -17
- package/src/components/ContactSuggestion.spec.jsx +16 -99
- package/src/components/ShareAutosuggest.jsx +1 -6
- package/src/components/ShareRecipientsInput.jsx +19 -1
- package/src/components/ShareRecipientsInput.spec.jsx +170 -108
- package/src/components/__snapshots__/ContactSuggestion.spec.jsx.snap +0 -1192
- package/src/components/__snapshots__/ShareRecipientsInput.spec.jsx.snap +0 -99
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
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
|
+
# [12.3.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@12.2.0...cozy-sharing@12.3.0) (2024-03-25)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Add GroupAvatar into AvatarList ([1c66999](https://github.com/cozy/cozy-libs/commit/1c669995b08d84a3aa8d6dd950fa4abf22566395))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [12.2.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@12.1.0...cozy-sharing@12.2.0) (2024-03-22)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* Allow to add group with only more than one member ([177dc4a](https://github.com/cozy/cozy-libs/commit/177dc4a4fbceefed1ce52f2a5275c67e46b6430f))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
# [12.1.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@12.0.0...cozy-sharing@12.1.0) (2024-03-22)
|
|
7
29
|
|
|
8
30
|
|
|
@@ -5,6 +5,7 @@ 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
7
|
import { ExtraAvatar } from './ExtraAvatar';
|
|
8
|
+
import { GroupAvatar } from './GroupAvatar';
|
|
8
9
|
import { MemberAvatar } from './MemberAvatar';
|
|
9
10
|
import { getDisplayName } from '../../models';
|
|
10
11
|
var styles = {
|
|
@@ -83,10 +84,20 @@ var AvatarList = function AvatarList(_ref2) {
|
|
|
83
84
|
className: styles['recipients-avatars--plusX'],
|
|
84
85
|
extraRecipients: extraRecipients,
|
|
85
86
|
size: size
|
|
86
|
-
})), shownRecipients.map(function (recipient
|
|
87
|
+
})), shownRecipients.map(function (recipient) {
|
|
88
|
+
if (recipient.members) {
|
|
89
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
90
|
+
"data-testid": "AvatarList-avatar".concat(recipient.status === 'owner' ? '-owner' : ''),
|
|
91
|
+
key: recipient.index
|
|
92
|
+
}, /*#__PURE__*/React.createElement(GroupAvatar, {
|
|
93
|
+
size: size,
|
|
94
|
+
className: cx(styles['recipients-avatars--avatar'])
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
|
|
87
98
|
return /*#__PURE__*/React.createElement("span", {
|
|
88
99
|
"data-testid": "AvatarList-avatar".concat(recipient.status === 'owner' ? '-owner' : ''),
|
|
89
|
-
key:
|
|
100
|
+
key: recipient.index
|
|
90
101
|
}, /*#__PURE__*/React.createElement(MemberAvatar, {
|
|
91
102
|
recipient: recipient,
|
|
92
103
|
size: size,
|
|
@@ -9,20 +9,25 @@ import { AvatarList, MAX_DISPLAYED_RECIPIENTS, excludeMeAsOwnerFromRecipients }
|
|
|
9
9
|
import AppLike from '../../../test/AppLike';
|
|
10
10
|
var mockRecipients = new Array(MAX_DISPLAYED_RECIPIENTS - 1).fill({
|
|
11
11
|
status: 'owner',
|
|
12
|
-
public_name: 'cozy'
|
|
12
|
+
public_name: 'cozy',
|
|
13
|
+
index: 'sharing-123-member-0'
|
|
13
14
|
}, 0, 1).fill({
|
|
14
15
|
status: 'pending',
|
|
15
|
-
name: 'Mitch Young'
|
|
16
|
+
name: 'Mitch Young',
|
|
17
|
+
index: 'sharing-123-member-1'
|
|
16
18
|
}, 1);
|
|
17
19
|
var mockMoreRecipientsThanMaxDisplayed = [].concat(_toConsumableArray(mockRecipients), [{
|
|
18
20
|
status: 'mail-not-send',
|
|
19
|
-
name: 'Lyn Webster'
|
|
21
|
+
name: 'Lyn Webster',
|
|
22
|
+
index: 'sharing-123-member-2'
|
|
20
23
|
}, {
|
|
21
24
|
status: 'ready',
|
|
22
|
-
name: 'Richelle Young'
|
|
25
|
+
name: 'Richelle Young',
|
|
26
|
+
index: 'sharing-123-member-3'
|
|
23
27
|
}, {
|
|
24
28
|
status: 'ready',
|
|
25
|
-
name: 'John Connor'
|
|
29
|
+
name: 'John Connor',
|
|
30
|
+
index: 'sharing-123-member-4'
|
|
26
31
|
}]);
|
|
27
32
|
describe('AvatarList', function () {
|
|
28
33
|
var client = createMockClient({});
|
|
@@ -103,7 +108,7 @@ describe('AvatarList', function () {
|
|
|
103
108
|
});
|
|
104
109
|
});
|
|
105
110
|
describe('excludeMeAsOwnerFromRecipients', function () {
|
|
106
|
-
|
|
111
|
+
it('excludeMeAsOwnerFromRecipients behavior', function () {
|
|
107
112
|
var recipients = [{
|
|
108
113
|
status: 'owner',
|
|
109
114
|
instance: 'http://foo1.cozy.bar'
|
|
@@ -4,11 +4,23 @@ import { recipients } from '../../../.storybook/fixtures/recipients';
|
|
|
4
4
|
var meta = {
|
|
5
5
|
component: AvatarList,
|
|
6
6
|
args: {
|
|
7
|
-
recipients:
|
|
7
|
+
recipients: _toConsumableArray(recipients)
|
|
8
8
|
}
|
|
9
9
|
};
|
|
10
10
|
export default meta;
|
|
11
11
|
export var Default = {
|
|
12
12
|
name: 'Default',
|
|
13
13
|
args: {}
|
|
14
|
+
};
|
|
15
|
+
export var WithGroups = {
|
|
16
|
+
name: 'With groups',
|
|
17
|
+
args: {
|
|
18
|
+
recipients: [].concat(_toConsumableArray(recipients), [{
|
|
19
|
+
name: 'Group 1',
|
|
20
|
+
type: 'group',
|
|
21
|
+
members: [{
|
|
22
|
+
public_name: 'Alice'
|
|
23
|
+
}]
|
|
24
|
+
}])
|
|
25
|
+
}
|
|
14
26
|
};
|
|
@@ -3,10 +3,12 @@ import Avatar from 'cozy-ui/transpiled/react/Avatar';
|
|
|
3
3
|
import TeamIcon from 'cozy-ui/transpiled/react/Icons/Team';
|
|
4
4
|
|
|
5
5
|
var GroupAvatar = function GroupAvatar(_ref) {
|
|
6
|
-
var size = _ref.size
|
|
6
|
+
var size = _ref.size,
|
|
7
|
+
className = _ref.className;
|
|
7
8
|
return /*#__PURE__*/React.createElement(Avatar, {
|
|
8
9
|
icon: TeamIcon,
|
|
9
|
-
size: size
|
|
10
|
+
size: size,
|
|
11
|
+
className: className
|
|
10
12
|
});
|
|
11
13
|
};
|
|
12
14
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import get from 'lodash/get';
|
|
2
1
|
import PropTypes from 'prop-types';
|
|
3
2
|
import React from 'react';
|
|
4
3
|
import { models } from 'cozy-client';
|
|
@@ -10,8 +9,7 @@ import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
|
|
|
10
9
|
import { Contact, Group, getDisplayName, getInitials } from '../models';
|
|
11
10
|
var ContactModel = models.contact;
|
|
12
11
|
export var ContactSuggestion = function ContactSuggestion(_ref) {
|
|
13
|
-
var contactOrGroup = _ref.contactOrGroup
|
|
14
|
-
contacts = _ref.contacts;
|
|
12
|
+
var contactOrGroup = _ref.contactOrGroup;
|
|
15
13
|
|
|
16
14
|
var _useI18n = useI18n(),
|
|
17
15
|
t = _useI18n.t;
|
|
@@ -20,19 +18,10 @@ export var ContactSuggestion = function ContactSuggestion(_ref) {
|
|
|
20
18
|
|
|
21
19
|
if (contactOrGroup._type === Group.doctype) {
|
|
22
20
|
name = contactOrGroup.name;
|
|
23
|
-
|
|
24
|
-
if (get(contact, 'relationships.groups.data', []).map(function (group) {
|
|
25
|
-
return group._id;
|
|
26
|
-
}).includes(contactOrGroup._id)) {
|
|
27
|
-
return total + 1;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return total;
|
|
31
|
-
}, 0).toString();
|
|
21
|
+
avatarText = 'G';
|
|
32
22
|
details = t('Share.members.count', {
|
|
33
|
-
smart_count: membersCount
|
|
23
|
+
smart_count: contactOrGroup.membersCount.toString()
|
|
34
24
|
});
|
|
35
|
-
avatarText = 'G';
|
|
36
25
|
} else {
|
|
37
26
|
name = getDisplayName(contactOrGroup);
|
|
38
27
|
avatarText = getInitials(contactOrGroup);
|
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { ContactSuggestion } from './ContactSuggestion';
|
|
4
4
|
import AppLike from '../../test/AppLike';
|
|
5
|
-
|
|
6
|
-
var WrappingComponent = function WrappingComponent(_ref) {
|
|
7
|
-
var children = _ref.children;
|
|
8
|
-
return /*#__PURE__*/React.createElement(AppLike, null, children);
|
|
9
|
-
};
|
|
10
|
-
|
|
11
5
|
describe('ContactSuggestion component', function () {
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
var setup = function setup(_ref) {
|
|
7
|
+
var contactOrGroup = _ref.contactOrGroup;
|
|
8
|
+
return render( /*#__PURE__*/React.createElement(ContactSuggestion, {
|
|
9
|
+
contactOrGroup: contactOrGroup
|
|
10
|
+
}), {
|
|
11
|
+
wrapper: AppLike
|
|
12
|
+
});
|
|
13
|
+
};
|
|
16
14
|
|
|
17
|
-
return s;
|
|
18
|
-
});
|
|
19
15
|
it('should display contact suggestion for a contact', function () {
|
|
20
16
|
var jonSnow = {
|
|
21
17
|
_id: 'f3a4e501-abbd',
|
|
@@ -34,17 +30,11 @@ describe('ContactSuggestion component', function () {
|
|
|
34
30
|
}],
|
|
35
31
|
_type: 'io.cozy.contacts'
|
|
36
32
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
contactOrGroup: jonSnow,
|
|
40
|
-
contacts: contacts,
|
|
41
|
-
t: fakeT
|
|
42
|
-
};
|
|
43
|
-
var jsx = /*#__PURE__*/React.createElement(ContactSuggestion, props);
|
|
44
|
-
var wrapper = mount(jsx, {
|
|
45
|
-
wrappingComponent: WrappingComponent
|
|
33
|
+
setup({
|
|
34
|
+
contactOrGroup: jonSnow
|
|
46
35
|
});
|
|
47
|
-
expect(
|
|
36
|
+
expect(screen.getByText('Jon Snow')).toBeInTheDocument();
|
|
37
|
+
expect(screen.getByText('https://jonsnow.mycozy.cloud')).toBeInTheDocument();
|
|
48
38
|
});
|
|
49
39
|
it('should display contact suggestion for a contact without fullname (for example created by a share modal)', function () {
|
|
50
40
|
var jonSnow = {
|
|
@@ -57,94 +47,22 @@ describe('ContactSuggestion component', function () {
|
|
|
57
47
|
name: undefined,
|
|
58
48
|
_type: 'io.cozy.contacts'
|
|
59
49
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
contactOrGroup: jonSnow,
|
|
63
|
-
contacts: contacts,
|
|
64
|
-
t: fakeT
|
|
65
|
-
};
|
|
66
|
-
var jsx = /*#__PURE__*/React.createElement(ContactSuggestion, props);
|
|
67
|
-
var wrapper = mount(jsx, {
|
|
68
|
-
wrappingComponent: WrappingComponent
|
|
50
|
+
setup({
|
|
51
|
+
contactOrGroup: jonSnow
|
|
69
52
|
});
|
|
70
|
-
expect(
|
|
53
|
+
expect(screen.getByText('jon.snow@email.com')).toBeInTheDocument();
|
|
71
54
|
});
|
|
72
55
|
it('should display contact suggestion for a group', function () {
|
|
73
|
-
var jon = {
|
|
74
|
-
_id: 'f3a4e501-abbd',
|
|
75
|
-
fullname: 'Jon Snow',
|
|
76
|
-
name: {
|
|
77
|
-
givenName: 'Jon',
|
|
78
|
-
familyName: 'Snow'
|
|
79
|
-
},
|
|
80
|
-
email: [{
|
|
81
|
-
address: 'jon.snow@email.com',
|
|
82
|
-
type: 'primary'
|
|
83
|
-
}],
|
|
84
|
-
_type: 'io.cozy.contacts',
|
|
85
|
-
relationships: {
|
|
86
|
-
groups: {
|
|
87
|
-
data: [{
|
|
88
|
-
_id: '610718e6-2d7a',
|
|
89
|
-
_type: 'io.cozy.contacts.groups'
|
|
90
|
-
}]
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
var cersei = {
|
|
95
|
-
_id: '42dc490a-7878',
|
|
96
|
-
fullname: 'Cersei Lannister',
|
|
97
|
-
name: {
|
|
98
|
-
givenName: 'Cersei',
|
|
99
|
-
familyName: 'Lannister'
|
|
100
|
-
},
|
|
101
|
-
email: [{
|
|
102
|
-
address: 'cersei@email.com',
|
|
103
|
-
type: 'primary'
|
|
104
|
-
}],
|
|
105
|
-
_type: 'io.cozy.contacts',
|
|
106
|
-
relationships: {
|
|
107
|
-
groups: {
|
|
108
|
-
data: []
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
var sam = {
|
|
113
|
-
_id: 'b5bed853-93da',
|
|
114
|
-
fullname: 'Samwell Tarly',
|
|
115
|
-
name: {
|
|
116
|
-
givenName: 'Samwell',
|
|
117
|
-
familyName: 'Tarly'
|
|
118
|
-
},
|
|
119
|
-
email: [{
|
|
120
|
-
address: 'samwell@email.com',
|
|
121
|
-
type: 'primary'
|
|
122
|
-
}],
|
|
123
|
-
_type: 'io.cozy.contacts',
|
|
124
|
-
relationships: {
|
|
125
|
-
groups: {
|
|
126
|
-
data: [{
|
|
127
|
-
_id: '610718e6-2d7a',
|
|
128
|
-
_type: 'io.cozy.contacts.groups'
|
|
129
|
-
}]
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
var contacts = [jon, cersei, sam];
|
|
134
56
|
var theNightsWatch = {
|
|
135
57
|
_id: '610718e6-2d7a',
|
|
136
58
|
name: "The Night's Watch",
|
|
137
|
-
_type: 'io.cozy.contacts.groups'
|
|
138
|
-
|
|
139
|
-
var props = {
|
|
140
|
-
contactOrGroup: theNightsWatch,
|
|
141
|
-
contacts: contacts,
|
|
142
|
-
t: fakeT
|
|
59
|
+
_type: 'io.cozy.contacts.groups',
|
|
60
|
+
membersCount: 2
|
|
143
61
|
};
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
wrappingComponent: WrappingComponent
|
|
62
|
+
setup({
|
|
63
|
+
contactOrGroup: theNightsWatch
|
|
147
64
|
});
|
|
148
|
-
expect(
|
|
65
|
+
expect(screen.getByText("The Night's Watch")).toBeInTheDocument();
|
|
66
|
+
expect(screen.getByText('2 members')).toBeInTheDocument();
|
|
149
67
|
});
|
|
150
68
|
});
|
|
@@ -174,9 +174,6 @@ var ShareAutocomplete = function ShareAutocomplete(_ref) {
|
|
|
174
174
|
|
|
175
175
|
var renderSuggestion = function renderSuggestion(contactOrGroup) {
|
|
176
176
|
return /*#__PURE__*/React.createElement(ContactSuggestion, {
|
|
177
|
-
contacts: contactsAndGroups.filter(function (item) {
|
|
178
|
-
return item._type === Contact.doctype;
|
|
179
|
-
}),
|
|
180
177
|
contactOrGroup: contactOrGroup
|
|
181
178
|
});
|
|
182
179
|
};
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
+
|
|
5
|
+
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; }
|
|
6
|
+
|
|
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; }
|
|
8
|
+
|
|
9
|
+
import get from 'lodash/get';
|
|
3
10
|
import PropTypes from 'prop-types';
|
|
4
11
|
import React, { useState, useEffect } from 'react';
|
|
5
12
|
import ShareAutosuggest from './ShareAutosuggest';
|
|
@@ -35,7 +42,22 @@ var ShareRecipientsInput = function ShareRecipientsInput(_ref) {
|
|
|
35
42
|
if (contacts.hasMore || contacts.fetchStatus === 'loading') {
|
|
36
43
|
return contacts.data;
|
|
37
44
|
} else {
|
|
38
|
-
|
|
45
|
+
var contactGroupsWithCount = contactGroups.data.map(function (contactGroup) {
|
|
46
|
+
return _objectSpread(_objectSpread({}, contactGroup), {}, {
|
|
47
|
+
membersCount: contacts.data.reduce(function (total, contact) {
|
|
48
|
+
if (get(contact, 'relationships.groups.data', []).map(function (group) {
|
|
49
|
+
return group._id;
|
|
50
|
+
}).includes(contactGroup._id)) {
|
|
51
|
+
return total + 1;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return total;
|
|
55
|
+
}, 0)
|
|
56
|
+
});
|
|
57
|
+
}).filter(function (contactGroup) {
|
|
58
|
+
return contactGroup.membersCount > 0;
|
|
59
|
+
});
|
|
60
|
+
return [].concat(_toConsumableArray(contacts.data), _toConsumableArray(contactGroupsWithCount));
|
|
39
61
|
}
|
|
40
62
|
};
|
|
41
63
|
|