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,7 +2,18 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  import { render, screen } from '@testing-library/react';
4
4
  import React from 'react';
5
+ import { createMockClient } from 'cozy-client';
6
+ import flag from 'cozy-flags';
5
7
  import ShareRecipientsInput from './ShareRecipientsInput';
8
+ import AppLike from './SharingBanner/test/AppLike';
9
+ jest.mock('cozy-flags', function () {
10
+ return {
11
+ __esModule: true,
12
+ default: jest.fn(function () {
13
+ return null;
14
+ })
15
+ };
16
+ });
6
17
  jest.mock('./ShareAutosuggest', function () {
7
18
  return {
8
19
  __esModule: true,
@@ -16,7 +27,7 @@ jest.mock('./ShareAutosuggest', function () {
16
27
  } else {
17
28
  return /*#__PURE__*/React.createElement("li", {
18
29
  key: contactOrGroup.id
19
- }, contactOrGroup.name);
30
+ }, contactOrGroup.name, " - ", contactOrGroup.members.length, " members");
20
31
  }
21
32
  }));
22
33
  }
@@ -25,14 +36,31 @@ jest.mock('./ShareAutosuggest', function () {
25
36
  describe('ShareRecipientsInput component', function () {
26
37
  var setup = function setup(_ref2) {
27
38
  var contacts = _ref2.contacts,
28
- contactGroups = _ref2.contactGroups;
29
- render( /*#__PURE__*/React.createElement(ShareRecipientsInput, {
30
- contacts: contacts,
31
- contactGroups: contactGroups,
39
+ contactGroups = _ref2.contactGroups,
40
+ unreachableContact = _ref2.unreachableContact;
41
+ var mockClient = createMockClient({
42
+ queries: {
43
+ 'io.cozy.contacts/reachable': {
44
+ doctype: 'io.cozy.contacts',
45
+ data: contacts
46
+ },
47
+ 'io.cozy.contacts.groups/by-ids/fe86af20-c6c5': {
48
+ doctype: 'io.cozy.contacts.groups',
49
+ data: contactGroups
50
+ },
51
+ 'io.cozy.contacts/unreachable-with-groups': {
52
+ doctype: 'io.cozy.contacts',
53
+ data: unreachableContact
54
+ }
55
+ }
56
+ });
57
+ render( /*#__PURE__*/React.createElement(AppLike, {
58
+ client: mockClient
59
+ }, /*#__PURE__*/React.createElement(ShareRecipientsInput, {
32
60
  onPick: function onPick() {},
33
61
  onRemove: function onRemove() {},
34
62
  placeholder: "Enter recipients here"
35
- }));
63
+ })));
36
64
  };
37
65
 
38
66
  it('should include groups and contacts when are loaded', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
@@ -40,54 +68,44 @@ describe('ShareRecipientsInput component', function () {
40
68
  return _regeneratorRuntime.wrap(function _callee$(_context) {
41
69
  while (1) switch (_context.prev = _context.next) {
42
70
  case 0:
43
- contacts = {
44
- id: 'contacts',
45
- fetchStatus: 'loaded',
46
- hasMore: false,
47
- data: [{
48
- id: 'df563cc4-6440',
49
- _id: 'df563cc4-6440',
50
- _type: 'io.cozy.contacts',
51
- name: {
52
- givenName: 'Michale',
53
- familyName: 'Russel'
54
- }
55
- }, {
56
- id: '5a3b4ccf-c257',
57
- _id: '5a3b4ccf-c257',
58
- _type: 'io.cozy.contacts',
59
- name: {
60
- givenName: 'Teagan',
61
- familyName: 'Wolf'
62
- },
63
- relationships: {
64
- groups: {
65
- data: [{
66
- _id: 'fe86af20-c6c5',
67
- _type: 'io.cozy.contacts.groups'
68
- }]
69
- }
71
+ contacts = [{
72
+ id: 'df563cc4-6440',
73
+ _id: 'df563cc4-6440',
74
+ _type: 'io.cozy.contacts',
75
+ name: {
76
+ givenName: 'Michale',
77
+ familyName: 'Russel'
78
+ }
79
+ }, {
80
+ id: '5a3b4ccf-c257',
81
+ _id: '5a3b4ccf-c257',
82
+ _type: 'io.cozy.contacts',
83
+ name: {
84
+ givenName: 'Teagan',
85
+ familyName: 'Wolf'
86
+ },
87
+ relationships: {
88
+ groups: {
89
+ data: [{
90
+ _id: 'fe86af20-c6c5',
91
+ _type: 'io.cozy.contacts.groups'
92
+ }]
70
93
  }
71
- }]
72
- };
73
- contactGroups = {
74
- id: 'groups',
75
- fetchStatus: 'loaded',
76
- hasMore: false,
77
- data: [{
78
- id: 'fe86af20-c6c5',
79
- name: "The Night's Watch",
80
- _id: 'fe86af20-c6c5',
81
- _type: 'io.cozy.contacts.groups'
82
- }]
83
- };
94
+ }
95
+ }];
96
+ contactGroups = [{
97
+ id: 'fe86af20-c6c5',
98
+ name: "The Night's Watch",
99
+ _id: 'fe86af20-c6c5',
100
+ _type: 'io.cozy.contacts.groups'
101
+ }];
84
102
  setup({
85
103
  contacts: contacts,
86
104
  contactGroups: contactGroups
87
105
  });
88
106
  expect(screen.getByText('Michale Russel')).toBeInTheDocument();
89
107
  expect(screen.getByText('Teagan Wolf')).toBeInTheDocument();
90
- expect(screen.getByText("The Night's Watch")).toBeInTheDocument();
108
+ expect(screen.getByText("The Night's Watch - 1 members")).toBeInTheDocument();
91
109
 
92
110
  case 6:
93
111
  case "end":
@@ -95,116 +113,76 @@ describe('ShareRecipientsInput component', function () {
95
113
  }
96
114
  }, _callee);
97
115
  })));
98
- it('should include groups only if all contacts are loaded', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
99
- var contacts, contactGroups;
116
+ it('should include unreachable members when flag sharing.show-recipient-groups is activated', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
117
+ var contacts, contactGroups, unreachableContact;
100
118
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
101
119
  while (1) switch (_context2.prev = _context2.next) {
102
120
  case 0:
103
- contacts = {
104
- id: 'contacts',
105
- fetchStatus: 'loading',
106
- hasMore: false,
107
- data: [{
108
- id: 'df563cc4-6440',
109
- _id: 'df563cc4-6440',
110
- _type: 'io.cozy.contacts',
111
- name: {
112
- givenName: 'Michale',
113
- familyName: 'Russel'
121
+ flag.mockReturnValue(true);
122
+ contacts = [{
123
+ id: 'df563cc4-6440',
124
+ _id: 'df563cc4-6440',
125
+ _type: 'io.cozy.contacts',
126
+ name: {
127
+ givenName: 'Michale',
128
+ familyName: 'Russel'
129
+ }
130
+ }, {
131
+ id: '5a3b4ccf-c257',
132
+ _id: '5a3b4ccf-c257',
133
+ _type: 'io.cozy.contacts',
134
+ name: {
135
+ givenName: 'Teagan',
136
+ familyName: 'Wolf'
137
+ },
138
+ relationships: {
139
+ groups: {
140
+ data: [{
141
+ _id: 'fe86af20-c6c5',
142
+ _type: 'io.cozy.contacts.groups'
143
+ }]
114
144
  }
115
- }, {
116
- id: '5a3b4ccf-c257',
117
- _id: '5a3b4ccf-c257',
118
- _type: 'io.cozy.contacts',
119
- name: {
120
- givenName: 'Teagan',
121
- familyName: 'Wolf'
122
- },
123
- relationships: {
124
- groups: {
125
- data: [{
126
- _id: 'fe86af20-c6c5',
127
- _type: 'io.cozy.contacts.groups'
128
- }]
129
- }
145
+ }
146
+ }];
147
+ contactGroups = [{
148
+ id: 'fe86af20-c6c5',
149
+ name: "The Night's Watch",
150
+ _id: 'fe86af20-c6c5',
151
+ _type: 'io.cozy.contacts.groups'
152
+ }];
153
+ unreachableContact = [{
154
+ id: 'df532cc4-6560',
155
+ _id: 'df532cc4-6560',
156
+ _type: 'io.cozy.contacts',
157
+ name: {
158
+ givenName: 'Tony',
159
+ familyName: 'Stark'
160
+ },
161
+ relationships: {
162
+ groups: {
163
+ data: [{
164
+ _id: 'fe86af20-c6c5',
165
+ _type: 'io.cozy.contacts.groups'
166
+ }]
130
167
  }
131
- }]
132
- };
133
- contactGroups = {
134
- id: 'groups',
135
- fetchStatus: 'loaded',
136
- hasMore: false,
137
- data: [{
138
- id: 'fe86af20-c6c5',
139
- name: "The Night's Watch",
140
- _id: 'fe86af20-c6c5',
141
- _type: 'io.cozy.contacts.groups'
142
- }]
143
- };
168
+ }
169
+ }];
144
170
  setup({
145
171
  contacts: contacts,
146
- contactGroups: contactGroups
172
+ contactGroups: contactGroups,
173
+ unreachableContact: unreachableContact
147
174
  });
148
175
  expect(screen.getByText('Michale Russel')).toBeInTheDocument();
149
- expect(screen.getByText('Teagan Wolf')).toBeInTheDocument();
150
- expect(screen.queryByText("The Night's Watch")).toBeNull();
176
+ expect(screen.getByText('Teagan Wolf')).toBeInTheDocument(); // 3 members because cozy-client replay the query with the new data
177
+ // so the unreachableContact is added to the reachable contact query
178
+ // TODO: improve createMockClient to handle this case
151
179
 
152
- case 6:
180
+ expect(screen.getByText("The Night's Watch - 3 members")).toBeInTheDocument();
181
+
182
+ case 8:
153
183
  case "end":
154
184
  return _context2.stop();
155
185
  }
156
186
  }, _callee2);
157
187
  })));
158
- it('should include groups only if they have more than one member', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
159
- var contacts, contactGroups;
160
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
161
- while (1) switch (_context3.prev = _context3.next) {
162
- case 0:
163
- contacts = {
164
- id: 'contacts',
165
- fetchStatus: 'loaded',
166
- hasMore: false,
167
- data: [{
168
- id: 'df563cc4-6440',
169
- _id: 'df563cc4-6440',
170
- _type: 'io.cozy.contacts',
171
- name: {
172
- givenName: 'Michale',
173
- familyName: 'Russel'
174
- }
175
- }, {
176
- id: '5a3b4ccf-c257',
177
- _id: '5a3b4ccf-c257',
178
- _type: 'io.cozy.contacts',
179
- name: {
180
- givenName: 'Teagan',
181
- familyName: 'Wolf'
182
- }
183
- }]
184
- };
185
- contactGroups = {
186
- id: 'groups',
187
- fetchStatus: 'loaded',
188
- hasMore: false,
189
- data: [{
190
- id: 'fe86af20-c6c5',
191
- name: "The Night's Watch",
192
- _id: 'fe86af20-c6c5',
193
- _type: 'io.cozy.contacts.groups'
194
- }]
195
- };
196
- setup({
197
- contacts: contacts,
198
- contactGroups: contactGroups
199
- });
200
- expect(screen.getByText('Michale Russel')).toBeInTheDocument();
201
- expect(screen.getByText('Teagan Wolf')).toBeInTheDocument();
202
- expect(screen.queryByText("The Night's Watch")).toBeNull();
203
-
204
- case 6:
205
- case "end":
206
- return _context3.stop();
207
- }
208
- }, _callee3);
209
- })));
210
188
  });
@@ -91,4 +91,15 @@ export var getOrCreateFromArray = /*#__PURE__*/function () {
91
91
  return function getOrCreateFromArray(_x, _x2, _x3) {
92
92
  return _ref.apply(this, arguments);
93
93
  };
94
- }();
94
+ }();
95
+ export var getContactsFromGroupId = function getContactsFromGroupId() {
96
+ var contacts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
97
+ var groupId = arguments.length > 1 ? arguments[1] : undefined;
98
+ return contacts.filter(function (contact) {
99
+ var _contact$relationship;
100
+
101
+ return (_contact$relationship = contact.relationships) === null || _contact$relationship === void 0 || (_contact$relationship = _contact$relationship.groups) === null || _contact$relationship === void 0 || (_contact$relationship = _contact$relationship.data) === null || _contact$relationship === void 0 ? void 0 : _contact$relationship.some(function (group) {
102
+ return group._id === groupId;
103
+ });
104
+ });
105
+ };
@@ -5,9 +5,9 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
5
5
 
6
6
  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; }
7
7
 
8
- import get from 'lodash/get';
9
8
  import flag from 'cozy-flags';
10
9
  import { Group } from '../models';
10
+ export var DEFAULT_DISPLAY_NAME = 'Share.contacts.defaultDisplayName';
11
11
  export var filterAndReworkRecipients = function filterAndReworkRecipients(recipients, previousRecipients) {
12
12
  return recipients.filter(function (recipient) {
13
13
  return recipient.status !== 'owner';
@@ -56,23 +56,18 @@ export var hasReachRecipientsLimit = function hasReachRecipientsLimit(current, n
56
56
  };
57
57
  /**
58
58
  * Merges the recipients list with a new recipient and their associated contacts.
59
+ * Only used when flag sharing.show-recipient-groups is not enabled.
59
60
  * @param {object[]} recipients - The list of recipients.
60
61
  * @param {object} recipient - The new recipient.
61
62
  * @param {object[]} contacts - The list of contacts.
62
63
  * @returns {object[]} - The merged recipients list.
63
64
  */
64
65
 
65
- export var spreadGroupAndMergeRecipients = function spreadGroupAndMergeRecipients(recipients, newRecipient, contacts) {
66
+ export var spreadGroupAndMergeRecipients = function spreadGroupAndMergeRecipients(recipients, newRecipient) {
66
67
  var contactsToAdd;
67
68
 
68
69
  if (newRecipient._type === Group.doctype) {
69
- var groupId = newRecipient.id;
70
- contactsToAdd = contacts.data.filter(function (contact) {
71
- var contactGroupIds = get(contact, 'relationships.groups.data', []).map(function (group) {
72
- return group._id;
73
- });
74
- return contactGroupIds.includes(groupId);
75
- });
70
+ contactsToAdd = newRecipient.members;
76
71
  } else {
77
72
  contactsToAdd = [newRecipient];
78
73
  }
@@ -88,4 +83,16 @@ export var spreadGroupAndMergeRecipients = function spreadGroupAndMergeRecipient
88
83
  };
89
84
  export var mergeRecipients = function mergeRecipients(recipients, newRecipient) {
90
85
  return [].concat(_toConsumableArray(recipients), [newRecipient]);
86
+ };
87
+ export var getGroupRecipientSecondaryText = function getGroupRecipientSecondaryText(_ref) {
88
+ var nbMember = _ref.nbMember,
89
+ nbMemberReady = _ref.nbMemberReady,
90
+ t = _ref.t,
91
+ isUserInsideMembers = _ref.isUserInsideMembers;
92
+ var memberCount = nbMember === nbMemberReady ? nbMember : [nbMemberReady, nbMember].join('/');
93
+ var secondary = t('GroupRecipient.secondary', {
94
+ memberCount: memberCount,
95
+ smart_count: nbMember
96
+ });
97
+ return secondary + (isUserInsideMembers ? " (".concat(t('GroupRecipient.secondary_you'), ")") : '');
91
98
  };
@@ -1,36 +1,78 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
3
+ 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; }
4
+
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
+
1
7
  import { models } from 'cozy-client';
2
- import { Contact } from '../models';
8
+ import { Contact, Group } from '../models';
3
9
  export var countNewRecipients = function countNewRecipients(currentRecipients, newRecipients) {
4
- return newRecipients.filter(function (contact) {
5
- var email = models.contact.getPrimaryEmail(contact);
6
- var cozyUrl = models.contact.getPrimaryCozy(contact);
7
- return !currentRecipients.find(function (r) {
8
- return email && r.email && r.email === email || cozyUrl && r.instance && r.instance === cozyUrl;
9
- });
10
- }).length;
10
+ var newRecipientsNotAlreadyIncluded = newRecipients.filter(function (recipient) {
11
+ if (Contact.isContact(recipient)) {
12
+ var email = models.contact.getPrimaryEmail(recipient);
13
+ var cozyUrl = models.contact.getPrimaryCozy(recipient);
14
+ return !currentRecipients.find(function (r) {
15
+ return email && r.email && r.email === email || cozyUrl && r.instance && r.instance === cozyUrl;
16
+ });
17
+ }
18
+
19
+ return true;
20
+ });
21
+ return newRecipientsNotAlreadyIncluded.reduce(function (acc, recipient) {
22
+ if (recipient._type === Group.doctype) {
23
+ return _objectSpread(_objectSpread({}, acc), {}, {
24
+ group: acc.group + 1
25
+ });
26
+ } else {
27
+ return _objectSpread(_objectSpread({}, acc), {}, {
28
+ contact: acc.contact + 1
29
+ });
30
+ }
31
+ }, {
32
+ group: 0,
33
+ contact: 0
34
+ });
11
35
  };
12
36
  export var getSuccessMessage = function getSuccessMessage(recipientsBefore, recipientsAfter, documentType) {
13
37
  if (recipientsAfter.length === 1) {
14
38
  var recipient = recipientsAfter[0];
15
39
  var email = Contact.isContact(recipient) ? models.contact.getPrimaryEmail(recipient) : recipient.email;
16
40
  var cozyUrl = models.contact.getPrimaryCozy(recipient);
41
+ var isContactGroup = recipient._type === Group.doctype;
17
42
 
18
- if (email) {
19
- return ["".concat(documentType, ".share.shareByEmail.success"), {
43
+ if (isContactGroup) {
44
+ return ["".concat(documentType, ".share.shareByEmail.singleGroupSuccess"), {
45
+ groupName: recipient.name
46
+ }];
47
+ } else if (email) {
48
+ return ["".concat(documentType, ".share.shareByEmail.singleContactSuccess"), {
20
49
  email: email
21
50
  }];
22
51
  } else if (cozyUrl) {
23
- return ["".concat(documentType, ".share.shareByEmail.success"), {
52
+ return ["".concat(documentType, ".share.shareByEmail.singleContactSuccess"), {
24
53
  email: cozyUrl
25
54
  }];
26
55
  } else {
27
- return ["".concat(documentType, ".share.shareByEmail.genericSuccess"), {
28
- count: 1
56
+ return ["".concat(documentType, ".share.shareByEmail.contactSuccess"), {
57
+ smart_count: 1
29
58
  }];
30
59
  }
31
60
  } else {
32
- return ["".concat(documentType, ".share.shareByEmail.genericSuccess"), {
33
- count: countNewRecipients(recipientsBefore, recipientsAfter)
34
- }];
61
+ var count = countNewRecipients(recipientsBefore, recipientsAfter);
62
+
63
+ if (count.contact > 0 && count.group > 0) {
64
+ return ["".concat(documentType, ".share.shareByEmail.contactAndGroupSuccess"), {
65
+ nbContact: count.contact,
66
+ nbGroup: count.group
67
+ }];
68
+ } else if (count.group > 0) {
69
+ return ["".concat(documentType, ".share.shareByEmail.groupSuccess"), {
70
+ smart_count: count.group
71
+ }];
72
+ } else {
73
+ return ["".concat(documentType, ".share.shareByEmail.contactSuccess"), {
74
+ smart_count: count.contact
75
+ }];
76
+ }
35
77
  }
36
78
  };