cozy-sharing 12.3.0 → 13.1.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.
Files changed (65) hide show
  1. package/.storybook/preview.jsx +1 -0
  2. package/CHANGELOG.md +46 -0
  3. package/dist/components/ContactSuggestion.js +7 -3
  4. package/dist/components/ContactSuggestion.spec.js +7 -1
  5. package/dist/components/Recipient/GroupRecipient.js +14 -7
  6. package/dist/components/Recipient/GroupRecipientDetail.js +4 -2
  7. package/dist/components/Recipient/GroupRecipientDetailWithAccess.js +9 -11
  8. package/dist/components/Recipient/GroupRecipientDetailWithoutAccess.js +8 -4
  9. package/dist/components/Recipient/GroupRecipientPermissions.js +3 -6
  10. package/dist/components/Recipient/MemberRecipient.js +1 -2
  11. package/dist/components/Recipient/MemberRecipientPermissions.js +1 -1
  12. package/dist/components/ShareAutosuggest.js +16 -9
  13. package/dist/components/ShareAutosuggest.spec.js +38 -13
  14. package/dist/components/ShareAutosuggest.stories.js +61 -0
  15. package/dist/components/ShareByEmail.js +57 -23
  16. package/dist/components/ShareByEmail.spec.js +0 -6
  17. package/dist/components/ShareDialogCozyToCozy.js +1 -5
  18. package/dist/components/ShareDialogCozyToCozy.spec.js +0 -61
  19. package/dist/components/ShareDialogTwoStepsConfirmationContainer.js +1 -5
  20. package/dist/components/ShareDialogTwoStepsConfirmationContainer.spec.js +0 -61
  21. package/dist/components/ShareModal/EditableSharingModal.js +3 -10
  22. package/dist/components/ShareModal/EditableSharingModal.spec.js +0 -6
  23. package/dist/components/ShareModal.js +1 -8
  24. package/dist/components/ShareRecipientsInput.js +55 -48
  25. package/dist/components/ShareRecipientsInput.spec.js +122 -144
  26. package/dist/helpers/contacts.js +12 -1
  27. package/dist/helpers/recipients.js +16 -9
  28. package/dist/helpers/successMessage.js +58 -16
  29. package/dist/helpers/successMessage.spec.js +122 -57
  30. package/dist/queries/queries.js +37 -5
  31. package/dist/styles/autosuggest.styl +2 -1
  32. package/dist/stylesheet.css +2 -1
  33. package/locales/en.json +32 -10
  34. package/locales/fr.json +30 -8
  35. package/package.json +4 -4
  36. package/src/components/ContactSuggestion.jsx +9 -3
  37. package/src/components/ContactSuggestion.spec.jsx +10 -1
  38. package/src/components/Recipient/GroupRecipient.jsx +17 -10
  39. package/src/components/Recipient/GroupRecipientDetail.jsx +5 -2
  40. package/src/components/Recipient/GroupRecipientDetailWithAccess.jsx +9 -14
  41. package/src/components/Recipient/GroupRecipientDetailWithoutAccess.jsx +8 -3
  42. package/src/components/Recipient/GroupRecipientPermissions.jsx +3 -8
  43. package/src/components/Recipient/MemberRecipient.jsx +4 -3
  44. package/src/components/Recipient/MemberRecipientPermissions.jsx +1 -1
  45. package/src/components/ShareAutosuggest.jsx +16 -11
  46. package/src/components/ShareAutosuggest.spec.jsx +31 -10
  47. package/src/components/ShareAutosuggest.stories.jsx +63 -0
  48. package/src/components/ShareByEmail.jsx +54 -17
  49. package/src/components/ShareByEmail.spec.jsx +0 -4
  50. package/src/components/ShareDialogCozyToCozy.jsx +0 -4
  51. package/src/components/ShareDialogCozyToCozy.spec.jsx +0 -67
  52. package/src/components/ShareDialogTwoStepsConfirmationContainer.jsx +0 -4
  53. package/src/components/ShareDialogTwoStepsConfirmationContainer.spec.jsx +0 -67
  54. package/src/components/ShareModal/EditableSharingModal.jsx +3 -21
  55. package/src/components/ShareModal/EditableSharingModal.spec.jsx +0 -2
  56. package/src/components/ShareModal.jsx +1 -7
  57. package/src/components/ShareRecipientsInput.jsx +95 -53
  58. package/src/components/ShareRecipientsInput.spec.jsx +140 -145
  59. package/src/helpers/contacts.js +8 -0
  60. package/src/helpers/recipients.js +24 -15
  61. package/src/helpers/successMessage.js +71 -21
  62. package/src/helpers/successMessage.spec.js +129 -69
  63. package/src/queries/queries.js +36 -5
  64. package/src/styles/autosuggest.styl +2 -1
  65. package/test/AppLike.jsx +6 -3
@@ -2,18 +2,6 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import { getSuccessMessage, countNewRecipients } from './successMessage';
3
3
  describe('getSuccessMessage method', function () {
4
4
  var props = {
5
- contacts: {
6
- id: 'contacts',
7
- data: [],
8
- hasMore: false,
9
- fetchStatus: 'loaded'
10
- },
11
- contactGroups: {
12
- id: 'groups',
13
- data: [],
14
- hasMore: false,
15
- fetchStatus: 'loaded'
16
- },
17
5
  currentRecipients: [{
18
6
  email: 'sansa.stark@winterfell.westeros'
19
7
  }],
@@ -24,10 +12,13 @@ describe('getSuccessMessage method', function () {
24
12
  };
25
13
  it('should return a success message and its params for multiple recipients', function () {
26
14
  var recipientsAfter = [{
15
+ _type: 'io.cozy.contacts',
27
16
  email: 'jon.snow@thewall.westeros'
28
17
  }, {
18
+ _type: 'io.cozy.contacts',
29
19
  email: 'arya.stark@winterfell.westeros'
30
20
  }, {
21
+ _type: 'io.cozy.contacts',
31
22
  email: 'sansa.stark@winterfell.westeros'
32
23
  }];
33
24
 
@@ -36,9 +27,9 @@ describe('getSuccessMessage method', function () {
36
27
  message = _getSuccessMessage2[0],
37
28
  params = _getSuccessMessage2[1];
38
29
 
39
- expect(message).toEqual('Files.share.shareByEmail.genericSuccess');
30
+ expect(message).toEqual('Files.share.shareByEmail.contactSuccess');
40
31
  expect(params).toEqual({
41
- count: 2
32
+ smart_count: 2
42
33
  });
43
34
  });
44
35
  it('should return a success message and its params for one recipient with email', function () {
@@ -51,7 +42,7 @@ describe('getSuccessMessage method', function () {
51
42
  message = _getSuccessMessage4[0],
52
43
  params = _getSuccessMessage4[1];
53
44
 
54
- expect(message).toEqual('Files.share.shareByEmail.success');
45
+ expect(message).toEqual('Files.share.shareByEmail.singleContactSuccess');
55
46
  expect(params).toEqual({
56
47
  email: 'jon.snow@thewall.westeros'
57
48
  });
@@ -75,7 +66,7 @@ describe('getSuccessMessage method', function () {
75
66
  message = _getSuccessMessage6[0],
76
67
  params = _getSuccessMessage6[1];
77
68
 
78
- expect(message).toEqual('Files.share.shareByEmail.success');
69
+ expect(message).toEqual('Files.share.shareByEmail.singleContactSuccess');
79
70
  expect(params).toEqual({
80
71
  email: 'jon.snow@thewall.westeros'
81
72
  });
@@ -92,12 +83,12 @@ describe('getSuccessMessage method', function () {
92
83
  message = _getSuccessMessage8[0],
93
84
  params = _getSuccessMessage8[1];
94
85
 
95
- expect(message).toEqual('Files.share.shareByEmail.success');
86
+ expect(message).toEqual('Files.share.shareByEmail.singleContactSuccess');
96
87
  expect(params).toEqual({
97
88
  email: 'https://doranmartell.mycozy.cloud'
98
89
  });
99
90
  });
100
- it('should use generic success message if recipient has no email and no cozy', function () {
91
+ it('should use contact success message if recipient has no email and no cozy', function () {
101
92
  var recipientsBefore = props.currentRecipients;
102
93
 
103
94
  var _getSuccessMessage9 = getSuccessMessage(recipientsBefore, [{
@@ -107,13 +98,87 @@ describe('getSuccessMessage method', function () {
107
98
  message = _getSuccessMessage10[0],
108
99
  params = _getSuccessMessage10[1];
109
100
 
110
- expect(message).toEqual('Files.share.shareByEmail.genericSuccess');
101
+ expect(message).toEqual('Files.share.shareByEmail.contactSuccess');
111
102
  expect(params).toEqual({
112
- count: 1
103
+ smart_count: 1
104
+ });
105
+ });
106
+ it('should use single group success message if recipient is a group', function () {
107
+ var recipientsBefore = props.currentRecipients;
108
+
109
+ var _getSuccessMessage11 = getSuccessMessage(recipientsBefore, [{
110
+ _type: 'io.cozy.contacts.groups',
111
+ name: 'Stark family'
112
+ }], props.documentType),
113
+ _getSuccessMessage12 = _slicedToArray(_getSuccessMessage11, 2),
114
+ message = _getSuccessMessage12[0],
115
+ params = _getSuccessMessage12[1];
116
+
117
+ expect(message).toEqual('Files.share.shareByEmail.singleGroupSuccess');
118
+ expect(params).toEqual({
119
+ groupName: 'Stark family'
120
+ });
121
+ });
122
+ it('should use contact success message if recipient has only multiple contacts', function () {
123
+ var recipientsBefore = props.currentRecipients;
124
+
125
+ var _getSuccessMessage13 = getSuccessMessage(recipientsBefore, [{
126
+ _type: 'io.cozy.contacts'
127
+ }, {
128
+ _type: 'io.cozy.contacts'
129
+ }, {
130
+ _type: 'io.cozy.contacts'
131
+ }], props.documentType),
132
+ _getSuccessMessage14 = _slicedToArray(_getSuccessMessage13, 2),
133
+ message = _getSuccessMessage14[0],
134
+ params = _getSuccessMessage14[1];
135
+
136
+ expect(message).toEqual('Files.share.shareByEmail.contactSuccess');
137
+ expect(params).toEqual({
138
+ smart_count: 3
139
+ });
140
+ });
141
+ it('should use group success message if recipient has only multiple groups', function () {
142
+ var recipientsBefore = props.currentRecipients;
143
+
144
+ var _getSuccessMessage15 = getSuccessMessage(recipientsBefore, [{
145
+ _type: 'io.cozy.contacts.groups'
146
+ }, {
147
+ _type: 'io.cozy.contacts.groups'
148
+ }], props.documentType),
149
+ _getSuccessMessage16 = _slicedToArray(_getSuccessMessage15, 2),
150
+ message = _getSuccessMessage16[0],
151
+ params = _getSuccessMessage16[1];
152
+
153
+ expect(message).toEqual('Files.share.shareByEmail.groupSuccess');
154
+ expect(params).toEqual({
155
+ smart_count: 2
156
+ });
157
+ });
158
+ it('should use contact and group success message if recipient has multiple contacts and groups', function () {
159
+ var recipientsBefore = props.currentRecipients;
160
+
161
+ var _getSuccessMessage17 = getSuccessMessage(recipientsBefore, [{
162
+ _type: 'io.cozy.contacts'
163
+ }, {
164
+ _id: 'fcb16b9e-7421',
165
+ _type: 'io.cozy.contacts.groups'
166
+ }, {
167
+ _id: 'f45b16be-7523',
168
+ _type: 'io.cozy.contacts.groups'
169
+ }], props.documentType),
170
+ _getSuccessMessage18 = _slicedToArray(_getSuccessMessage17, 2),
171
+ message = _getSuccessMessage18[0],
172
+ params = _getSuccessMessage18[1];
173
+
174
+ expect(message).toEqual('Files.share.shareByEmail.contactAndGroupSuccess');
175
+ expect(params).toEqual({
176
+ nbContact: 1,
177
+ nbGroup: 2
113
178
  });
114
179
  });
115
180
  });
116
- describe('countNewRecipients function', function () {
181
+ describe('countNewRecipients', function () {
117
182
  var currentRecipients = [{
118
183
  email: 'arya.stark@winterfell.westeros'
119
184
  }, {
@@ -122,77 +187,77 @@ describe('countNewRecipients function', function () {
122
187
  email: 'jon.snow@thewall.westeros'
123
188
  }];
124
189
  var addedRecipients = [{
125
- id: '5d4916fa-e193',
190
+ _id: 'e8c0e15f-da7d',
191
+ _type: 'io.cozy.contacts',
192
+ fullname: 'Jon Snow',
126
193
  email: [{
127
194
  address: 'jon.snow@thewall.westeros',
128
- type: 'primary'
195
+ primary: true
196
+ }, {
197
+ address: 'jon.snow@winterfell.westeros',
198
+ primary: false
129
199
  }]
130
200
  }, {
131
- id: '4df64228-ce84',
132
- email: [{
133
- address: 'sansa.stark@winterfell.westeros',
134
- type: 'primary'
135
- }]
201
+ _id: 'fcb16b9e-7421',
202
+ _type: 'io.cozy.contacts'
136
203
  }, {
137
- id: 'ff955bb1-f696',
138
- email: [{
139
- address: 'bran.stark@winterfell.westeros',
140
- type: 'primary'
204
+ _id: 'f45b16be-7523',
205
+ _type: 'io.cozy.contacts',
206
+ cozy: [{
207
+ url: 'https://doranmartell.mycozy.cloud'
141
208
  }]
142
209
  }];
143
- it('should count only the new recipients using email', function () {
144
- var result = countNewRecipients(currentRecipients, addedRecipients);
145
- expect(result).toEqual(1);
146
- });
147
- it('should count the new recipients when there are no current recipients', function () {
148
- var result = countNewRecipients([], addedRecipients);
149
- expect(result).toEqual(3);
150
- });
151
- it('should return 0 if there is no new recipients', function () {
152
- var currentRecipients = [{
153
- email: 'arya.stark@winterfell.westeros'
154
- }, {
155
- email: 'sansa.stark@winterfell.westeros'
156
- }, {
157
- email: 'jon.snow@thewall.westeros'
158
- }, {
159
- email: 'bran.stark@winterfell.westeros'
160
- }];
210
+ it('should count the new recipients with email', function () {
161
211
  var result = countNewRecipients(currentRecipients, addedRecipients);
162
- expect(result).toEqual(0);
212
+ expect(result.contact).toEqual(2);
213
+ expect(result.group).toEqual(0);
163
214
  });
164
- it('should count the new recipients using cozy url', function () {
215
+ it('should count the new recipients with cozy url', function () {
165
216
  var currentRecipients = [{
166
217
  instance: 'https://bran.mycozy.cloud'
167
218
  }, {
168
219
  instance: 'https://jon.mycozy.cloud'
169
220
  }];
170
221
  var addedRecipients = [{
171
- id: '5d4916fa-e193',
222
+ _type: 'io.cozy.contacts',
172
223
  cozy: [{
173
224
  url: 'https://jon.mycozy.cloud',
174
225
  type: 'primary'
175
226
  }]
176
227
  }, {
177
- id: '4df64228-ce84',
228
+ _type: 'io.cozy.contacts',
178
229
  cozy: [{
179
230
  url: 'https://sansa.mycozy.cloud',
180
231
  type: 'primary'
181
232
  }]
182
233
  }, {
183
- id: 'ff955bb1-f696',
234
+ _type: 'io.cozy.contacts',
184
235
  cozy: [{
185
236
  url: 'https://bran.mycozy.cloud',
186
237
  type: 'primary'
187
238
  }]
188
239
  }, {
189
- id: '0761944a-c740',
240
+ _type: 'io.cozy.contacts',
190
241
  cozy: [{
191
242
  url: 'https://arya.mycozy.cloud',
192
243
  type: 'primary'
193
244
  }]
194
245
  }];
195
246
  var result = countNewRecipients(currentRecipients, addedRecipients);
196
- expect(result).toEqual(2);
247
+ expect(result.contact).toEqual(2);
248
+ expect(result.group).toEqual(0);
249
+ });
250
+ it('should count the new recipients with groups', function () {
251
+ var result = countNewRecipients(currentRecipients, [].concat(addedRecipients, [{
252
+ _id: 'f45b16be-7523',
253
+ _type: 'io.cozy.contacts.groups'
254
+ }]));
255
+ expect(result.contact).toEqual(2);
256
+ expect(result.group).toEqual(1);
257
+ });
258
+ it('should return 0 if there are no new recipients', function () {
259
+ var result = countNewRecipients(currentRecipients, []);
260
+ expect(result.contact).toEqual(0);
261
+ expect(result.group).toEqual(0);
197
262
  });
198
263
  });
@@ -20,7 +20,7 @@ export var buildSharingsByIdQuery = function buildSharingsByIdQuery(sharingId) {
20
20
  }
21
21
  };
22
22
  };
23
- export var buildContactsQuery = function buildContactsQuery() {
23
+ export var buildReachableContactsQuery = function buildReachableContactsQuery() {
24
24
  return {
25
25
  definition: Q(Contact.doctype).where({
26
26
  _id: {
@@ -49,15 +49,47 @@ export var buildContactsQuery = function buildContactsQuery() {
49
49
  }]
50
50
  }).indexFields(['_id']).limitBy(1000),
51
51
  options: {
52
- as: 'io.cozy.contacts'
52
+ as: 'io.cozy.contacts/reachable'
53
53
  }
54
54
  };
55
55
  };
56
- export var buildContactGroupsQuery = function buildContactGroupsQuery() {
56
+ export var buildContactGroupsByIdsQuery = function buildContactGroupsByIdsQuery(ids) {
57
57
  return {
58
- definition: Q(Group.doctype),
58
+ definition: Q(Group.doctype).getByIds(ids),
59
59
  options: {
60
- as: 'io.cozy.contacts.groups'
60
+ as: "io.cozy.contacts.groups/by-ids/".concat(ids.join('/')),
61
+ fetchPolicy: defaultFetchPolicy,
62
+ enabled: ids.length > 0
63
+ }
64
+ };
65
+ };
66
+ export var buildUnreachableContactsWithGroupsQuery = function buildUnreachableContactsWithGroupsQuery() {
67
+ return {
68
+ definition: Q(Contact.doctype).where({
69
+ _id: {
70
+ $gt: null
71
+ }
72
+ }).partialIndex({
73
+ trashed: {
74
+ $or: [{
75
+ $eq: false
76
+ }, {
77
+ $exists: false
78
+ }]
79
+ },
80
+ cozy: {
81
+ $size: 0
82
+ },
83
+ email: {
84
+ $size: 0
85
+ },
86
+ 'relationships.groups.data': {
87
+ $exists: true
88
+ }
89
+ }).indexFields(['_id']).limitBy(1000),
90
+ options: {
91
+ as: 'io.cozy.contacts/unreachable-with-groups',
92
+ fetchPolicy: defaultFetchPolicy
61
93
  }
62
94
  };
63
95
  };
@@ -33,6 +33,7 @@
33
33
  .recipientsContainer
34
34
  display flex
35
35
  flex-wrap wrap
36
+ align-items center
36
37
  padding .25rem .5rem
37
38
  border-radius .25rem
38
39
  border 1px solid var(--borderMainColor)
@@ -55,7 +56,7 @@
55
56
  &:hover
56
57
  &:focus
57
58
  border none
58
- &:only-child
59
+ &:first-child
59
60
  padding .25rem .5rem
60
61
 
61
62
  .recipientChip
@@ -425,6 +425,7 @@ input[type=text] {
425
425
  .autosuggest__recipientsContainer___1JYxA {
426
426
  display: flex;
427
427
  flex-wrap: wrap;
428
+ align-items: center;
428
429
  padding: 0.25rem 0.5rem;
429
430
  border-radius: 0.25rem;
430
431
  border: 1px solid var(--borderMainColor);
@@ -449,7 +450,7 @@ input[type=text] {
449
450
  .autosuggest__recipientsContainer___1JYxA input[type=email]:focus {
450
451
  border: none;
451
452
  }
452
- .autosuggest__recipientsContainer___1JYxA input[type=email]:only-child {
453
+ .autosuggest__recipientsContainer___1JYxA input[type=email]:first-child {
453
454
  padding: 0.25rem 0.5rem;
454
455
  }
455
456
  .autosuggest__recipientChip___d5I3R {
package/locales/en.json CHANGED
@@ -75,6 +75,15 @@
75
75
  "deactivate": "Deactivate link",
76
76
  "cancel": "Cancel",
77
77
  "confirm": "OK"
78
+ },
79
+ "errors": {
80
+ "errors": {
81
+ "groupMemberAlreadyInSharing": "%{groupName} members have already been invited with %{sharingRights} rights. It is not possible to invite the same contact twice with different rights. |||| Contacts have already been invited with %{sharingRights} rights. It is not possible to invite the same contact twice with different rights.",
82
+ "sharingRights": {
83
+ "readOnly": "read",
84
+ "readWrite": "write"
85
+ }
86
+ }
78
87
  }
79
88
  },
80
89
  "Sharings": {
@@ -115,8 +124,11 @@
115
124
  "subtitle": "By email",
116
125
  "emailPlaceholder": "Add contacts or groups",
117
126
  "send": "Send",
118
- "genericSuccess": "You sent an invite to %{count} contacts.",
119
- "success": "You sent an invite to %{email}.",
127
+ "singleContactSuccess": "You sent an invite to %{email}.",
128
+ "contactSuccess": "You sent an invite to %{smart_count} contact. |||| You sent an invite to %{smart_count} contacts.",
129
+ "singleGroupSuccess": "You sent an invite to the members of the %{groupName} group.",
130
+ "groupSuccess": "You sent an invite to the members of %{smart_count} group. |||| You sent an invite to the members of %{smart_count} groups.",
131
+ "contactAndGroupSuccess": "You sent an invite to %{nbContact} contacts and the members of %{nbGroup} groups.",
120
132
  "comingsoon": "Coming soon! You will be able to share documents and photos in a single click with your family, your friends, and even your coworkers. Don't worry, we'll let you know when it's ready!",
121
133
  "onlyByLink": "This %{type} can only be shared by link, because",
122
134
  "type": {
@@ -180,8 +192,11 @@
180
192
  "email": "To:",
181
193
  "emailPlaceholder": "Enter the email address or name of the recipient",
182
194
  "send": "Send",
183
- "genericSuccess": "You sent an invite to %{count} contacts.",
184
- "success": "You sent an invite to %{email}.",
195
+ "singleContactSuccess": "You sent an invite to %{email}.",
196
+ "contactSuccess": "You sent an invite to %{smart_count} contact. |||| You sent an invite to %{smart_count} contacts.",
197
+ "singleGroupSuccess": "You sent an invite to the members of the %{groupName} group.",
198
+ "groupSuccess": "You sent an invite to the members of %{smart_count} group. |||| You sent an invite to the members of %{smart_count} groups.",
199
+ "contactAndGroupSuccess": "You sent an invite to %{nbContact} contacts and the members of %{nbGroup} groups.",
185
200
  "comingsoon": "Coming soon! You will be able to share documents and photos in a single click with your family, your friends, and even your coworkers. Don't worry, we'll let you know when it's ready!",
186
201
  "onlyByLink": "This %{type} can only be shared by link, because",
187
202
  "type": {
@@ -246,8 +261,11 @@
246
261
  "email": "email",
247
262
  "emailPlaceholder": "Enter the email address or name of the recipient",
248
263
  "send": "Send",
249
- "genericSuccess": "You sent an invite to %{count} contacts.",
250
- "success": "You sent an invite to %{email}.",
264
+ "singleContactSuccess": "You sent an invite to %{email}.",
265
+ "contactSuccess": "You sent an invite to %{smart_count} contact. |||| You sent an invite to %{smart_count} contacts.",
266
+ "singleGroupSuccess": "You sent an invite to the members of the %{groupName} group.",
267
+ "groupSuccess": "You sent an invite to the members of %{smart_count} group. |||| You sent an invite to the members of %{smart_count} groups.",
268
+ "contactAndGroupSuccess": "You sent an invite to %{nbContact} contacts and the members of %{nbGroup} groups.",
251
269
  "comingsoon": "Coming soon! You will be able to share documents and photos in a single click with your family, your friends, and even your coworkers. Don't worry, we'll let you know when it's ready!"
252
270
  },
253
271
  "unshare": {
@@ -307,8 +325,11 @@
307
325
  "email": "Send to:",
308
326
  "emailPlaceholder": "Enter the email address or name of the recipient",
309
327
  "send": "Send",
310
- "genericSuccess": "You sent an invite to %{count} contacts.",
311
- "success": "You sent an invite to %{email}.",
328
+ "singleContactSuccess": "You sent an invite to %{email}.",
329
+ "contactSuccess": "You sent an invite to %{smart_count} contact. |||| You sent an invite to %{smart_count} contacts.",
330
+ "singleGroupSuccess": "You sent an invite to the members of the %{groupName} group.",
331
+ "groupSuccess": "You sent an invite to the members of %{smart_count} group. |||| You sent an invite to the members of %{smart_count} groups.",
332
+ "contactAndGroupSuccess": "You sent an invite to %{nbContact} contacts and the members of %{nbGroup} groups.",
312
333
  "comingsoon": "Coming soon! You will be able to share documents and photos in a single click with your family, your friends, and even your coworkers. Don't worry, we'll let you know when it's ready!",
313
334
  "onlyByLink": "This %{type} can only be shared by link, because",
314
335
  "type": {
@@ -364,7 +385,7 @@
364
385
  }
365
386
  },
366
387
  "GroupRecipient": {
367
- "secondary": "%{nbMemberReady}/%{nbMember} members",
388
+ "secondary": "%{memberCount} member |||| %{memberCount} members",
368
389
  "secondary_you": "including you"
369
390
  },
370
391
  "RevokeGroupItem": {
@@ -387,7 +408,8 @@
387
408
  "status": {
388
409
  "mail-not-sent": "Invitation failed",
389
410
  "revoked": "Sharing revoked"
390
- }
411
+ },
412
+ "addEmail": "Enter an email address to invite the contact"
391
413
  }
392
414
  }
393
415
  }
package/locales/fr.json CHANGED
@@ -75,6 +75,13 @@
75
75
  "deactivate": "Désactiver le lien",
76
76
  "cancel": "Annuler",
77
77
  "confirm": "OK"
78
+ },
79
+ "errors": {
80
+ "groupMemberAlreadyInSharing": "Des membres de %{groupName} ont déjà été invités avec des droits de %{sharingRights}. Impossible d’inviter 2 fois le même contact avec des droits différents. |||| Des contacts ont déjà été invités avec des droits de %{sharingRights}. Impossible d’inviter 2 fois le même contact avec des droits différents.",
81
+ "sharingRights": {
82
+ "readOnly": "lecture",
83
+ "readWrite": "modification"
84
+ }
78
85
  }
79
86
  },
80
87
  "Sharings": {
@@ -114,8 +121,11 @@
114
121
  "subtitle": "Par email",
115
122
  "emailPlaceholder": "Ajouter des contacts ou des groupes",
116
123
  "send": "Envoyer",
117
- "genericSuccess": "Vous avez invité %{count} contacts.",
118
- "success": "Vous avez envoyé une invitation à %{email}.",
124
+ "singleContactSuccess": "Vous avez envoyé une invitation à %{email}.",
125
+ "contactSuccess": "Vous avez invité %{smart_count} contact. |||| Vous avez invité %{smart_count} contacts.",
126
+ "singleGroupSuccess": "Vous avez invité les membres du groupe %{groupName}.",
127
+ "groupSuccess": "Vous avez invité les membres de %{smart_count} groupe. |||| Vous avez invité les membres de %{smart_count} groupes.",
128
+ "contactAndGroupSuccess": "Vous avez invité %{nbContact} contacts et les membres de %{nbGroup} groupes.",
119
129
  "comingsoon": "Bientôt disponible ! Vous pourrez partager un document et vos photos en un seul clic avec votre famille, vos amis, et même vos collaborateurs. Ne vous inquiétez pas, on vous prévient quand ce sera prêt !",
120
130
  "onlyByLink": "Ce %{type} ne peut être partagé que sous la forme d'un lien, car il",
121
131
  "type": {
@@ -179,7 +189,11 @@
179
189
  "email": "À :",
180
190
  "emailPlaceholder": "Saisissez le courriel ou le nom du destinataire.",
181
191
  "send": "Envoyer",
182
- "genericSuccess": "Vous avez invité %{count} contacts.",
192
+ "singleContactSuccess": "Vous avez envoyé une invitation à %{email}.",
193
+ "contactSuccess": "Vous avez invité %{smart_count} contact. |||| Vous avez invité %{smart_count} contacts.",
194
+ "singleGroupSuccess": "Vous avez invité les membres du groupe %{groupName}.",
195
+ "groupSuccess": "Vous avez invité les membres de %{smart_count} groupe. |||| Vous avez invité les membres de %{smart_count} groupes.",
196
+ "contactAndGroupSuccess": "Vous avez invité %{nbContact} contacts et les membres de %{nbGroup} groupes.",
183
197
  "success": "Vous avez envoyé une invitation à %{email}.",
184
198
  "comingsoon": "Bientôt disponible ! Vous pourrez partager un document et vos photos en un seul clic avec votre famille, vos amis, et même vos collaborateurs. Ne vous inquiétez pas, on vous prévient quand ce sera prêt !",
185
199
  "onlyByLink": "Ce %{type} ne peut être partagé que sous la forme d'un lien, car il",
@@ -245,7 +259,11 @@
245
259
  "email": "e-mail",
246
260
  "emailPlaceholder": "Saisissez l'email ou le nom du destinataire.",
247
261
  "send": "Envoyer",
248
- "genericSuccess": "Vous avez envoyé une invitation à %{count} contacts.",
262
+ "singleContactSuccess": "Vous avez envoyé une invitation à %{email}.",
263
+ "contactSuccess": "Vous avez invité %{smart_count} contact. |||| Vous avez invité %{smart_count} contacts.",
264
+ "singleGroupSuccess": "Vous avez invité les membres du groupe %{groupName}.",
265
+ "groupSuccess": "Vous avez invité les membres de %{smart_count} groupe. |||| Vous avez invité les membres de %{smart_count} groupes.",
266
+ "contactAndGroupSuccess": "Vous avez invité %{nbContact} contacts et les membres de %{nbGroup} groupes.",
249
267
  "success": "Vous avez envoyé une invitation à %{email}.",
250
268
  "comingsoon": "Bientôt disponible ! Vous pourrez partager vos documents et vos photos en un seul clic avec votre famille, vos amis et même vos collaborateurs. Ne vous inquiétez pas, on vous préviendra quand ce sera prêt !\n"
251
269
  },
@@ -305,8 +323,11 @@
305
323
  "email": "Envoyer à :",
306
324
  "emailPlaceholder": "Saisissez le courriel ou le nom du destinataire.",
307
325
  "send": "Envoyer",
308
- "genericSuccess": "Vous avez invité %{count} contacts.",
309
- "success": "Vous avez envoyé une invitation à %{email}.",
326
+ "singleContactSuccess": "Vous avez envoyé une invitation à %{email}.",
327
+ "contactSuccess": "Vous avez invité %{smart_count} contact. |||| Vous avez invité %{smart_count} contacts.",
328
+ "singleGroupSuccess": "Vous avez invité les membres du groupe %{groupName}.",
329
+ "groupSuccess": "Vous avez invité les membres de %{smart_count} groupe. |||| Vous avez invité les membres de %{smart_count} groupes.",
330
+ "contactAndGroupSuccess": "Vous avez invité %{nbContact} contacts et les membres de %{nbGroup} groupes.",
310
331
  "comingsoon": "Bientôt disponible ! Vous pourrez partager un document et vos photos en un seul clic avec votre famille, vos amis, et même vos collaborateurs. Ne vous inquiétez pas, on vous prévient quand ce sera prêt !",
311
332
  "onlyByLink": "Ce %{type} ne peut être partagé que sous la forme d'un lien, car il",
312
333
  "type": {
@@ -362,7 +383,7 @@
362
383
  }
363
384
  },
364
385
  "GroupRecipient": {
365
- "secondary": "%{nbMemberReady}/%{nbMember} membres",
386
+ "secondary": "%{memberCount} membre |||| %{memberCount} membres",
366
387
  "secondary_you": "dont vous"
367
388
  },
368
389
  "RevokeGroupItem": {
@@ -385,7 +406,8 @@
385
406
  "status": {
386
407
  "mail-not-sent": "Echec de l’invitation",
387
408
  "revoked": "Partage révoqué"
388
- }
409
+ },
410
+ "addEmail": "Renseigner un email pour pouvoir inviter le contact"
389
411
  }
390
412
  }
391
413
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-sharing",
3
- "version": "12.3.0",
3
+ "version": "13.1.0",
4
4
  "description": "Provides sharing login for React applications.",
5
5
  "main": "dist/index.js",
6
6
  "author": "Cozy",
@@ -50,7 +50,7 @@
50
50
  "babel-plugin-css-modules-transform": "1.6.2",
51
51
  "babel-plugin-inline-react-svg": "1.1.2",
52
52
  "cozy-client": "46.1.0",
53
- "cozy-ui": "^103.8.2",
53
+ "cozy-ui": "105.3.1",
54
54
  "enzyme": "3.11.0",
55
55
  "enzyme-adapter-react-16": "1.15.6",
56
56
  "enzyme-to-json": "3.6.2",
@@ -63,7 +63,7 @@
63
63
  "peerDependencies": {
64
64
  "cozy-client": ">=46.1.0",
65
65
  "cozy-realtime": "^3.11.0",
66
- "cozy-ui": ">=103.8.1",
66
+ "cozy-ui": ">=105.3.1",
67
67
  "prop-types": "^15.7.2",
68
68
  "react": "^16.12.0",
69
69
  "react-router": "^5.0.1"
@@ -71,5 +71,5 @@
71
71
  "sideEffects": [
72
72
  "*.css"
73
73
  ],
74
- "gitHead": "b1ad6f5933b463878f641d9fbb63eddd4c45b0d0"
74
+ "gitHead": "2adcaf791db8f6760bd6e0067068ca2e92d8bb6a"
75
75
  }
@@ -8,6 +8,7 @@ import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
8
8
  import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
9
9
  import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
10
10
 
11
+ import { GroupAvatar } from './Avatar/GroupAvatar'
11
12
  import { Contact, Group, getDisplayName, getInitials } from '../models'
12
13
 
13
14
  const ContactModel = models.contact
@@ -15,11 +16,12 @@ const ContactModel = models.contact
15
16
  export const ContactSuggestion = ({ contactOrGroup }) => {
16
17
  const { t } = useI18n()
17
18
  let avatarText, name, details
18
- if (contactOrGroup._type === Group.doctype) {
19
+ const isContactGroup = contactOrGroup._type === Group.doctype
20
+ if (isContactGroup) {
19
21
  name = contactOrGroup.name
20
22
  avatarText = 'G'
21
23
  details = t('Share.members.count', {
22
- smart_count: contactOrGroup.membersCount.toString()
24
+ smart_count: contactOrGroup.members.length.toString()
23
25
  })
24
26
  } else {
25
27
  name = getDisplayName(contactOrGroup)
@@ -30,7 +32,11 @@ export const ContactSuggestion = ({ contactOrGroup }) => {
30
32
  return (
31
33
  <ListItem button>
32
34
  <ListItemIcon>
33
- <Avatar text={avatarText} size="small" />
35
+ {isContactGroup ? (
36
+ <GroupAvatar size="small" />
37
+ ) : (
38
+ <Avatar text={avatarText} size="small" />
39
+ )}
34
40
  </ListItemIcon>
35
41
  <ListItemText
36
42
  primary={name}
@@ -60,7 +60,16 @@ describe('ContactSuggestion component', () => {
60
60
  _id: '610718e6-2d7a',
61
61
  name: "The Night's Watch",
62
62
  _type: 'io.cozy.contacts.groups',
63
- membersCount: 2
63
+ members: [
64
+ {
65
+ _id: 'f3a4e501-abbd',
66
+ fullname: 'Jon Snow'
67
+ },
68
+ {
69
+ _id: 'ab23a451-tzas',
70
+ fullname: 'Samwell Tarly'
71
+ }
72
+ ]
64
73
  }
65
74
  setup({ contactOrGroup: theNightsWatch })
66
75
  expect(screen.getByText("The Night's Watch")).toBeInTheDocument()