cozy-sharing 13.2.0 → 13.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 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
+ ## [13.3.1](https://github.com/cozy/cozy-libs/compare/cozy-sharing@13.3.0...cozy-sharing@13.3.1) (2024-05-27)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **sharing:** Improve size inside recipient list ([747605a](https://github.com/cozy/cozy-libs/commit/747605a944e740bdea32b07d0199df17abc75fb0))
12
+
13
+
14
+
15
+
16
+
17
+ # [13.3.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@13.2.0...cozy-sharing@13.3.0) (2024-05-02)
18
+
19
+
20
+ ### Features
21
+
22
+ * **share:** Manage the case of a contact that is already in ([7c979af](https://github.com/cozy/cozy-libs/commit/7c979af7efebd906e45f1e83b43414bf2cb5b984))
23
+
24
+
25
+
26
+
27
+
6
28
  # [13.2.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@13.1.2...cozy-sharing@13.2.0) (2024-04-18)
7
29
 
8
30
 
@@ -57,7 +57,8 @@ var GroupRecipient = function GroupRecipient(props) {
57
57
  }, /*#__PURE__*/React.createElement(ListItem, {
58
58
  button: true,
59
59
  onClick: toogleDetailOpened,
60
- gutters: isMobile ? 'default' : 'double'
60
+ gutters: isMobile ? 'default' : 'double',
61
+ size: "small"
61
62
  }, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(GroupAvatar, {
62
63
  size: "small"
63
64
  })), /*#__PURE__*/React.createElement(ListItemText, {
@@ -24,8 +24,10 @@ var GroupRecipientDetailWithAccess = function GroupRecipientDetailWithAccess(_re
24
24
  var isMe = recipient.instance === client.options.uri;
25
25
  return /*#__PURE__*/React.createElement(ListItem, {
26
26
  disableGutters: true,
27
- key: recipient.index
27
+ key: recipient.index,
28
+ size: "small"
28
29
  }, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Avatar, {
30
+ size: "small",
29
31
  text: getInitials(recipient),
30
32
  textId: name
31
33
  })), /*#__PURE__*/React.createElement(ListItemText, {
@@ -27,8 +27,10 @@ var GroupRecipientDetailWithoutAccess = function GroupRecipientDetailWithoutAcce
27
27
  return /*#__PURE__*/React.createElement(ListItem, {
28
28
  disableGutters: true,
29
29
  key: recipient.index,
30
- ellipsis: false
30
+ ellipsis: false,
31
+ size: "small"
31
32
  }, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Avatar, {
33
+ size: "small",
32
34
  text: getInitials(recipient),
33
35
  textId: name
34
36
  })), /*#__PURE__*/React.createElement(ListItemText, {
@@ -53,7 +53,8 @@ var LinkRecipient = function LinkRecipient(props) {
53
53
  in: true,
54
54
  timeout: fadeIn ? FADE_IN_DURATION : 0
55
55
  }, /*#__PURE__*/React.createElement(ListItem, {
56
- gutters: isMobile ? 'default' : 'double'
56
+ gutters: isMobile ? 'default' : 'double',
57
+ size: "small"
57
58
  }, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Circle, {
58
59
  size: "small",
59
60
  className: styles['link-recipient-icon-circle']
@@ -48,7 +48,8 @@ var MemberRecipient = function MemberRecipient(props) {
48
48
  in: true,
49
49
  timeout: fadeIn ? FADE_IN_DURATION : 0
50
50
  }, /*#__PURE__*/React.createElement(ListItem, {
51
- gutters: isMobile ? 'default' : 'double'
51
+ gutters: isMobile ? 'default' : 'double',
52
+ size: "small"
52
53
  }, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(MemberAvatar, {
53
54
  size: "small",
54
55
  recipient: props
@@ -14,7 +14,7 @@ import ShareSubmit from './Sharesubmit';
14
14
  import ShareTypeSelect from './Sharetypeselect';
15
15
  import { getOrCreateFromArray } from '../helpers/contacts';
16
16
  import { mergeRecipients, spreadGroupAndMergeRecipients, hasReachRecipientsLimit } from '../helpers/recipients';
17
- import { getSuccessMessage } from '../helpers/successMessage';
17
+ import { getSuccessMessage, getErrorMessage } from '../helpers/share';
18
18
  import { isReadOnlySharing } from '../state';
19
19
  var styles = {
20
20
  "share-modal-content": "share__share-modal-content___1iqEq",
@@ -99,7 +99,7 @@ export var ShareByEmail = function ShareByEmail(_ref) {
99
99
 
100
100
  var share = /*#__PURE__*/function () {
101
101
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
102
- var recipientsBefore, contacts, readWriteRecipients, readOnlyRecipients, showGenericAlert, detail, sharingRights;
102
+ var recipientsBefore, contacts, readWriteRecipients, readOnlyRecipients;
103
103
  return _regeneratorRuntime.wrap(function _callee$(_context) {
104
104
  while (1) switch (_context.prev = _context.next) {
105
105
  case 0:
@@ -155,54 +155,34 @@ export var ShareByEmail = function ShareByEmail(_ref) {
155
155
  severity: 'success',
156
156
  variant: 'filled'
157
157
  });
158
- _context.next = 25;
158
+ _context.next = 22;
159
159
  break;
160
160
 
161
161
  case 19:
162
162
  _context.prev = 19;
163
163
  _context.t0 = _context["catch"](7);
164
- showGenericAlert = true;
165
-
166
- if (_context.t0.name === 'FetchError' && _context.t0.status === 400) {
167
- detail = JSON.parse(_context.t0.message).errors[0].detail;
168
-
169
- if (detail.startsWith('A group member cannot be added as they are already in')) {
170
- // To know the sharing rights of the other group
171
- sharingRights = selectedOption === 'readOnly' ? 'readWrite' : 'readOnly';
172
- showAlert({
173
- message: t('Share.errors.groupMemberAlreadyInSharing', {
174
- smart_count: recipients.length,
175
- groupName: recipients[0].name,
176
- sharingRights: t("Share.errors.sharingRights.".concat(sharingRights)),
177
- icon: false
178
- }),
179
- severity: 'error',
180
- variant: 'filled'
181
- });
182
- showGenericAlert = false;
183
- }
184
- }
185
-
186
- if (showGenericAlert) {
187
- showAlert({
188
- message: t("".concat(documentType, ".share.error.generic")),
189
- severity: 'error',
190
- variant: 'filled'
191
- });
192
- }
193
-
194
- throw _context.t0;
164
+ showAlert({
165
+ message: t.apply(void 0, _toConsumableArray(getErrorMessage({
166
+ t: t,
167
+ err: _context.t0,
168
+ documentType: documentType,
169
+ recipients: recipients,
170
+ selectedOption: selectedOption
171
+ }))),
172
+ severity: 'error',
173
+ variant: 'filled'
174
+ });
195
175
 
196
- case 25:
197
- _context.prev = 25;
176
+ case 22:
177
+ _context.prev = 22;
198
178
  reset();
199
- return _context.finish(25);
179
+ return _context.finish(22);
200
180
 
201
- case 28:
181
+ case 25:
202
182
  case "end":
203
183
  return _context.stop();
204
184
  }
205
- }, _callee, null, [[7, 19, 25, 28]]);
185
+ }, _callee, null, [[7, 19, 22, 25]]);
206
186
  }));
207
187
 
208
188
  return function share() {
@@ -5,7 +5,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
5
5
  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; }
6
6
 
7
7
  import { models } from 'cozy-client';
8
- import { Contact, Group } from '../models';
8
+ import { Contact, Group, getDisplayName } from '../models';
9
9
  export var countNewRecipients = function countNewRecipients(currentRecipients, newRecipients) {
10
10
  var newRecipientsNotAlreadyIncluded = newRecipients.filter(function (recipient) {
11
11
  if (Contact.isContact(recipient)) {
@@ -75,4 +75,37 @@ export var getSuccessMessage = function getSuccessMessage(recipientsBefore, reci
75
75
  }];
76
76
  }
77
77
  }
78
+ };
79
+ export var getErrorMessage = function getErrorMessage(_ref) {
80
+ var t = _ref.t,
81
+ err = _ref.err,
82
+ documentType = _ref.documentType,
83
+ recipients = _ref.recipients,
84
+ selectedOption = _ref.selectedOption;
85
+
86
+ if (err.name === 'FetchError' && err.status === 400) {
87
+ var detail = JSON.parse(err.message).errors[0].detail;
88
+
89
+ if (detail.startsWith('A group member cannot be added as they are already in')) {
90
+ var sharingRights = t("Share.errors.sharingRights.".concat(selectedOption === 'readOnly' ? 'readWrite' : 'readOnly'));
91
+
92
+ if (recipients.length === 1 && recipients[0]._type === Contact.doctype) {
93
+ return ['Share.errors.contactAlreadyInSharing', {
94
+ smart_count: recipients.length,
95
+ contactName: getDisplayName(recipients[0]),
96
+ sharingRights: sharingRights,
97
+ icon: false
98
+ }];
99
+ }
100
+
101
+ return ['Share.errors.groupMemberAlreadyInSharing', {
102
+ smart_count: recipients.length,
103
+ groupName: recipients[0].name,
104
+ sharingRights: sharingRights,
105
+ icon: false
106
+ }];
107
+ }
108
+ }
109
+
110
+ return ["".concat(documentType, ".share.error.generic")];
78
111
  };
@@ -0,0 +1,385 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import { getSuccessMessage, countNewRecipients, getErrorMessage } from './share';
3
+ describe('share', function () {
4
+ describe('getSuccessMessage', function () {
5
+ var props = {
6
+ currentRecipients: [{
7
+ email: 'sansa.stark@winterfell.westeros'
8
+ }],
9
+ documentType: 'Files',
10
+ sharingDesc: 'fake-doc.odt',
11
+ onShare: jest.fn(),
12
+ createContact: jest.fn()
13
+ };
14
+ it('should return a success message and its params for multiple recipients', function () {
15
+ var recipientsAfter = [{
16
+ _type: 'io.cozy.contacts',
17
+ email: 'jon.snow@thewall.westeros'
18
+ }, {
19
+ _type: 'io.cozy.contacts',
20
+ email: 'arya.stark@winterfell.westeros'
21
+ }, {
22
+ _type: 'io.cozy.contacts',
23
+ email: 'sansa.stark@winterfell.westeros'
24
+ }];
25
+
26
+ var _getSuccessMessage = getSuccessMessage(props.currentRecipients, recipientsAfter, props.documentType),
27
+ _getSuccessMessage2 = _slicedToArray(_getSuccessMessage, 2),
28
+ message = _getSuccessMessage2[0],
29
+ params = _getSuccessMessage2[1];
30
+
31
+ expect(message).toEqual('Files.share.shareByEmail.contactSuccess');
32
+ expect(params).toEqual({
33
+ smart_count: 2
34
+ });
35
+ });
36
+ it('should return a success message and its params for one recipient with email', function () {
37
+ var recipientsBefore = props.currentRecipients;
38
+
39
+ var _getSuccessMessage3 = getSuccessMessage(recipientsBefore, [{
40
+ email: 'jon.snow@thewall.westeros'
41
+ }], props.documentType),
42
+ _getSuccessMessage4 = _slicedToArray(_getSuccessMessage3, 2),
43
+ message = _getSuccessMessage4[0],
44
+ params = _getSuccessMessage4[1];
45
+
46
+ expect(message).toEqual('Files.share.shareByEmail.singleContactSuccess');
47
+ expect(params).toEqual({
48
+ email: 'jon.snow@thewall.westeros'
49
+ });
50
+ });
51
+ it('should return a success message and its params for one recipient (contact) with email', function () {
52
+ var recipientsBefore = props.currentRecipients;
53
+
54
+ var _getSuccessMessage5 = getSuccessMessage(recipientsBefore, [{
55
+ _id: 'e8c0e15f-da7d',
56
+ _type: 'io.cozy.contacts',
57
+ fullname: 'Jon Snow',
58
+ email: [{
59
+ address: 'jon.snow@thewall.westeros',
60
+ primary: true
61
+ }, {
62
+ address: 'jon.snow@winterfell.westeros',
63
+ primary: false
64
+ }]
65
+ }], props.documentType),
66
+ _getSuccessMessage6 = _slicedToArray(_getSuccessMessage5, 2),
67
+ message = _getSuccessMessage6[0],
68
+ params = _getSuccessMessage6[1];
69
+
70
+ expect(message).toEqual('Files.share.shareByEmail.singleContactSuccess');
71
+ expect(params).toEqual({
72
+ email: 'jon.snow@thewall.westeros'
73
+ });
74
+ });
75
+ it('should return a success message and its params for one recipient with cozy', function () {
76
+ var recipientsBefore = props.currentRecipients;
77
+
78
+ var _getSuccessMessage7 = getSuccessMessage(recipientsBefore, [{
79
+ cozy: [{
80
+ url: 'https://doranmartell.mycozy.cloud'
81
+ }]
82
+ }], props.documentType),
83
+ _getSuccessMessage8 = _slicedToArray(_getSuccessMessage7, 2),
84
+ message = _getSuccessMessage8[0],
85
+ params = _getSuccessMessage8[1];
86
+
87
+ expect(message).toEqual('Files.share.shareByEmail.singleContactSuccess');
88
+ expect(params).toEqual({
89
+ email: 'https://doranmartell.mycozy.cloud'
90
+ });
91
+ });
92
+ it('should use contact success message if recipient has no email and no cozy', function () {
93
+ var recipientsBefore = props.currentRecipients;
94
+
95
+ var _getSuccessMessage9 = getSuccessMessage(recipientsBefore, [{
96
+ _id: 'fcb16b9e-7421'
97
+ }], props.documentType),
98
+ _getSuccessMessage10 = _slicedToArray(_getSuccessMessage9, 2),
99
+ message = _getSuccessMessage10[0],
100
+ params = _getSuccessMessage10[1];
101
+
102
+ expect(message).toEqual('Files.share.shareByEmail.contactSuccess');
103
+ expect(params).toEqual({
104
+ smart_count: 1
105
+ });
106
+ });
107
+ it('should use single group success message if recipient is a group', function () {
108
+ var recipientsBefore = props.currentRecipients;
109
+
110
+ var _getSuccessMessage11 = getSuccessMessage(recipientsBefore, [{
111
+ _type: 'io.cozy.contacts.groups',
112
+ name: 'Stark family'
113
+ }], props.documentType),
114
+ _getSuccessMessage12 = _slicedToArray(_getSuccessMessage11, 2),
115
+ message = _getSuccessMessage12[0],
116
+ params = _getSuccessMessage12[1];
117
+
118
+ expect(message).toEqual('Files.share.shareByEmail.singleGroupSuccess');
119
+ expect(params).toEqual({
120
+ groupName: 'Stark family'
121
+ });
122
+ });
123
+ it('should use contact success message if recipient has only multiple contacts', function () {
124
+ var recipientsBefore = props.currentRecipients;
125
+
126
+ var _getSuccessMessage13 = getSuccessMessage(recipientsBefore, [{
127
+ _type: 'io.cozy.contacts'
128
+ }, {
129
+ _type: 'io.cozy.contacts'
130
+ }, {
131
+ _type: 'io.cozy.contacts'
132
+ }], props.documentType),
133
+ _getSuccessMessage14 = _slicedToArray(_getSuccessMessage13, 2),
134
+ message = _getSuccessMessage14[0],
135
+ params = _getSuccessMessage14[1];
136
+
137
+ expect(message).toEqual('Files.share.shareByEmail.contactSuccess');
138
+ expect(params).toEqual({
139
+ smart_count: 3
140
+ });
141
+ });
142
+ it('should use group success message if recipient has only multiple groups', function () {
143
+ var recipientsBefore = props.currentRecipients;
144
+
145
+ var _getSuccessMessage15 = getSuccessMessage(recipientsBefore, [{
146
+ _type: 'io.cozy.contacts.groups'
147
+ }, {
148
+ _type: 'io.cozy.contacts.groups'
149
+ }], props.documentType),
150
+ _getSuccessMessage16 = _slicedToArray(_getSuccessMessage15, 2),
151
+ message = _getSuccessMessage16[0],
152
+ params = _getSuccessMessage16[1];
153
+
154
+ expect(message).toEqual('Files.share.shareByEmail.groupSuccess');
155
+ expect(params).toEqual({
156
+ smart_count: 2
157
+ });
158
+ });
159
+ it('should use contact and group success message if recipient has multiple contacts and groups', function () {
160
+ var recipientsBefore = props.currentRecipients;
161
+
162
+ var _getSuccessMessage17 = getSuccessMessage(recipientsBefore, [{
163
+ _type: 'io.cozy.contacts'
164
+ }, {
165
+ _id: 'fcb16b9e-7421',
166
+ _type: 'io.cozy.contacts.groups'
167
+ }, {
168
+ _id: 'f45b16be-7523',
169
+ _type: 'io.cozy.contacts.groups'
170
+ }], props.documentType),
171
+ _getSuccessMessage18 = _slicedToArray(_getSuccessMessage17, 2),
172
+ message = _getSuccessMessage18[0],
173
+ params = _getSuccessMessage18[1];
174
+
175
+ expect(message).toEqual('Files.share.shareByEmail.contactAndGroupSuccess');
176
+ expect(params).toEqual({
177
+ nbContact: 1,
178
+ nbGroup: 2
179
+ });
180
+ });
181
+ });
182
+ describe('countNewRecipients', function () {
183
+ var currentRecipients = [{
184
+ email: 'arya.stark@winterfell.westeros'
185
+ }, {
186
+ email: 'sansa.stark@winterfell.westeros'
187
+ }, {
188
+ email: 'jon.snow@thewall.westeros'
189
+ }];
190
+ var addedRecipients = [{
191
+ _id: 'e8c0e15f-da7d',
192
+ _type: 'io.cozy.contacts',
193
+ fullname: 'Jon Snow',
194
+ email: [{
195
+ address: 'jon.snow@thewall.westeros',
196
+ primary: true
197
+ }, {
198
+ address: 'jon.snow@winterfell.westeros',
199
+ primary: false
200
+ }]
201
+ }, {
202
+ _id: 'fcb16b9e-7421',
203
+ _type: 'io.cozy.contacts'
204
+ }, {
205
+ _id: 'f45b16be-7523',
206
+ _type: 'io.cozy.contacts',
207
+ cozy: [{
208
+ url: 'https://doranmartell.mycozy.cloud'
209
+ }]
210
+ }];
211
+ it('should count the new recipients with email', function () {
212
+ var result = countNewRecipients(currentRecipients, addedRecipients);
213
+ expect(result.contact).toEqual(2);
214
+ expect(result.group).toEqual(0);
215
+ });
216
+ it('should count the new recipients with cozy url', function () {
217
+ var currentRecipients = [{
218
+ instance: 'https://bran.mycozy.cloud'
219
+ }, {
220
+ instance: 'https://jon.mycozy.cloud'
221
+ }];
222
+ var addedRecipients = [{
223
+ _type: 'io.cozy.contacts',
224
+ cozy: [{
225
+ url: 'https://jon.mycozy.cloud',
226
+ type: 'primary'
227
+ }]
228
+ }, {
229
+ _type: 'io.cozy.contacts',
230
+ cozy: [{
231
+ url: 'https://sansa.mycozy.cloud',
232
+ type: 'primary'
233
+ }]
234
+ }, {
235
+ _type: 'io.cozy.contacts',
236
+ cozy: [{
237
+ url: 'https://bran.mycozy.cloud',
238
+ type: 'primary'
239
+ }]
240
+ }, {
241
+ _type: 'io.cozy.contacts',
242
+ cozy: [{
243
+ url: 'https://arya.mycozy.cloud',
244
+ type: 'primary'
245
+ }]
246
+ }];
247
+ var result = countNewRecipients(currentRecipients, addedRecipients);
248
+ expect(result.contact).toEqual(2);
249
+ expect(result.group).toEqual(0);
250
+ });
251
+ it('should count the new recipients with groups', function () {
252
+ var result = countNewRecipients(currentRecipients, [].concat(addedRecipients, [{
253
+ _id: 'f45b16be-7523',
254
+ _type: 'io.cozy.contacts.groups'
255
+ }]));
256
+ expect(result.contact).toEqual(2);
257
+ expect(result.group).toEqual(1);
258
+ });
259
+ it('should return 0 if there are no new recipients', function () {
260
+ var result = countNewRecipients(currentRecipients, []);
261
+ expect(result.contact).toEqual(0);
262
+ expect(result.group).toEqual(0);
263
+ });
264
+ });
265
+ describe('getErrorMessage', function () {
266
+ var t = function t(key) {
267
+ return key;
268
+ }; // Mock translation function
269
+
270
+
271
+ var documentType = 'document';
272
+ var recipients = [{
273
+ name: 'John Doe'
274
+ }];
275
+ var selectedOption = 'readOnly';
276
+ it('should return generic error message for non-FetchError', function () {
277
+ var err = new Error('Some error');
278
+ var result = getErrorMessage({
279
+ t: t,
280
+ err: err,
281
+ documentType: documentType,
282
+ recipients: recipients,
283
+ selectedOption: selectedOption
284
+ });
285
+ expect(result).toEqual(["".concat(documentType, ".share.error.generic")]);
286
+ });
287
+ it('should return specific error message for FetchError with status 400 and specific detail', function () {
288
+ var err = {
289
+ name: 'FetchError',
290
+ status: 400,
291
+ message: JSON.stringify({
292
+ errors: [{
293
+ detail: 'A group member cannot be added as they are already in'
294
+ }]
295
+ })
296
+ };
297
+ var result = getErrorMessage({
298
+ t: t,
299
+ err: err,
300
+ documentType: documentType,
301
+ recipients: recipients,
302
+ selectedOption: selectedOption
303
+ });
304
+ expect(result).toEqual(['Share.errors.groupMemberAlreadyInSharing', {
305
+ smart_count: recipients.length,
306
+ groupName: recipients[0].name,
307
+ sharingRights: 'Share.errors.sharingRights.readWrite',
308
+ icon: false
309
+ }]);
310
+ });
311
+ it('should return opposite sharingRights for the other group when the group member already in sharing', function () {
312
+ var err = {
313
+ name: 'FetchError',
314
+ status: 400,
315
+ message: JSON.stringify({
316
+ errors: [{
317
+ detail: 'A group member cannot be added as they are already in'
318
+ }]
319
+ })
320
+ };
321
+ var result = getErrorMessage({
322
+ t: t,
323
+ err: err,
324
+ documentType: documentType,
325
+ recipients: recipients,
326
+ selectedOption: 'readWrite'
327
+ });
328
+ expect(result).toEqual(['Share.errors.groupMemberAlreadyInSharing', {
329
+ smart_count: recipients.length,
330
+ groupName: recipients[0].name,
331
+ sharingRights: 'Share.errors.sharingRights.readOnly',
332
+ icon: false
333
+ }]);
334
+ });
335
+ it('should return specific text if there is only one recipient and it is a contact', function () {
336
+ var err = {
337
+ name: 'FetchError',
338
+ status: 400,
339
+ message: JSON.stringify({
340
+ errors: [{
341
+ detail: 'A group member cannot be added as they are already in'
342
+ }]
343
+ })
344
+ };
345
+ var result = getErrorMessage({
346
+ t: t,
347
+ err: err,
348
+ documentType: documentType,
349
+ recipients: [{
350
+ _type: 'io.cozy.contacts',
351
+ name: {
352
+ givenName: 'John',
353
+ familyName: 'Doe'
354
+ }
355
+ }],
356
+ selectedOption: selectedOption
357
+ });
358
+ expect(result).toEqual(['Share.errors.contactAlreadyInSharing', {
359
+ smart_count: recipients.length,
360
+ contactName: 'John Doe',
361
+ sharingRights: 'Share.errors.sharingRights.readWrite',
362
+ icon: false
363
+ }]);
364
+ });
365
+ it('should return generic error message for FetchError with status 400 and different detail', function () {
366
+ var err = {
367
+ name: 'FetchError',
368
+ status: 400,
369
+ message: JSON.stringify({
370
+ errors: [{
371
+ detail: 'Some other detail'
372
+ }]
373
+ })
374
+ };
375
+ var result = getErrorMessage({
376
+ t: t,
377
+ err: err,
378
+ documentType: documentType,
379
+ recipients: recipients,
380
+ selectedOption: selectedOption
381
+ });
382
+ expect(result).toEqual(["".concat(documentType, ".share.error.generic")]);
383
+ });
384
+ });
385
+ });
package/locales/en.json CHANGED
@@ -79,6 +79,7 @@
79
79
  "errors": {
80
80
  "errors": {
81
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
+ "contactAlreadyInSharing": "%{contactName} has already been invited in a group 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
83
  "sharingRights": {
83
84
  "readOnly": "read",
84
85
  "readWrite": "write"
package/locales/fr.json CHANGED
@@ -78,6 +78,7 @@
78
78
  },
79
79
  "errors": {
80
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
+ "contactAlreadyInSharing": "%{contactName} a déjà été invité dans un groupe 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
82
  "sharingRights": {
82
83
  "readOnly": "lecture",
83
84
  "readWrite": "modification"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-sharing",
3
- "version": "13.2.0",
3
+ "version": "13.3.1",
4
4
  "description": "Provides sharing login for React applications.",
5
5
  "main": "dist/index.js",
6
6
  "author": "Cozy",
@@ -71,5 +71,5 @@
71
71
  "sideEffects": [
72
72
  "*.css"
73
73
  ],
74
- "gitHead": "bbc3235a02eab7e59b21a739816258618fffdf86"
74
+ "gitHead": "e3d4b47af3dabff895386dbc237ab5b81963d1f6"
75
75
  }
@@ -49,6 +49,7 @@ const GroupRecipient = props => {
49
49
  button
50
50
  onClick={toogleDetailOpened}
51
51
  gutters={isMobile ? 'default' : 'double'}
52
+ size="small"
52
53
  >
53
54
  <ListItemIcon>
54
55
  <GroupAvatar size="small" />
@@ -27,9 +27,13 @@ const GroupRecipientDetailWithAccess = ({ withAccess }) => {
27
27
  const isMe = recipient.instance === client.options.uri
28
28
 
29
29
  return (
30
- <ListItem disableGutters key={recipient.index}>
30
+ <ListItem disableGutters key={recipient.index} size="small">
31
31
  <ListItemIcon>
32
- <Avatar text={getInitials(recipient)} textId={name} />
32
+ <Avatar
33
+ size="small"
34
+ text={getInitials(recipient)}
35
+ textId={name}
36
+ />
33
37
  </ListItemIcon>
34
38
  <ListItemText
35
39
  primary={name}