cozy-sharing 12.2.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 CHANGED
@@ -3,6 +3,17 @@
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
+
6
17
  # [12.2.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@12.1.0...cozy-sharing@12.2.0) (2024-03-22)
7
18
 
8
19
 
@@ -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, idx) {
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: idx
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
- test('excludeMeAsOwnerFromRecipients behavior', function () {
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: [].concat(_toConsumableArray(recipients), _toConsumableArray(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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-sharing",
3
- "version": "12.2.0",
3
+ "version": "12.3.0",
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": "e48ad9475627e2be13c46e6b7be8a9f82215a392"
74
+ "gitHead": "b1ad6f5933b463878f641d9fbb63eddd4c45b0d0"
75
75
  }
@@ -6,6 +6,7 @@ import Avatar from 'cozy-ui/transpiled/react/Avatar'
6
6
  import LinkIcon from 'cozy-ui/transpiled/react/Icons/Link'
7
7
 
8
8
  import { ExtraAvatar } from './ExtraAvatar'
9
+ import { GroupAvatar } from './GroupAvatar'
9
10
  import { MemberAvatar } from './MemberAvatar'
10
11
  import { getDisplayName } from '../../models'
11
12
  import styles from '../../styles/recipient.styl'
@@ -88,20 +89,38 @@ const AvatarList = ({
88
89
  />
89
90
  </span>
90
91
  )}
91
- {shownRecipients.map((recipient, idx) => (
92
- <span
93
- data-testid={`AvatarList-avatar${
94
- recipient.status === 'owner' ? '-owner' : ''
95
- }`}
96
- key={idx}
97
- >
98
- <MemberAvatar
99
- recipient={recipient}
100
- size={size}
101
- className={cx(styles['recipients-avatars--avatar'])}
102
- />
103
- </span>
104
- ))}
92
+ {shownRecipients.map(recipient => {
93
+ if (recipient.members) {
94
+ return (
95
+ <span
96
+ data-testid={`AvatarList-avatar${
97
+ recipient.status === 'owner' ? '-owner' : ''
98
+ }`}
99
+ key={recipient.index}
100
+ >
101
+ <GroupAvatar
102
+ size={size}
103
+ className={cx(styles['recipients-avatars--avatar'])}
104
+ />
105
+ </span>
106
+ )
107
+ }
108
+
109
+ return (
110
+ <span
111
+ data-testid={`AvatarList-avatar${
112
+ recipient.status === 'owner' ? '-owner' : ''
113
+ }`}
114
+ key={recipient.index}
115
+ >
116
+ <MemberAvatar
117
+ recipient={recipient}
118
+ size={size}
119
+ className={cx(styles['recipients-avatars--avatar'])}
120
+ />
121
+ </span>
122
+ )
123
+ })}
105
124
  </div>
106
125
  )
107
126
  }
@@ -14,7 +14,8 @@ const mockRecipients = new Array(MAX_DISPLAYED_RECIPIENTS - 1)
14
14
  .fill(
15
15
  {
16
16
  status: 'owner',
17
- public_name: 'cozy'
17
+ public_name: 'cozy',
18
+ index: 'sharing-123-member-0'
18
19
  },
19
20
  0,
20
21
  1
@@ -22,7 +23,8 @@ const mockRecipients = new Array(MAX_DISPLAYED_RECIPIENTS - 1)
22
23
  .fill(
23
24
  {
24
25
  status: 'pending',
25
- name: 'Mitch Young'
26
+ name: 'Mitch Young',
27
+ index: 'sharing-123-member-1'
26
28
  },
27
29
  1
28
30
  )
@@ -31,15 +33,18 @@ const mockMoreRecipientsThanMaxDisplayed = [
31
33
  ...mockRecipients,
32
34
  {
33
35
  status: 'mail-not-send',
34
- name: 'Lyn Webster'
36
+ name: 'Lyn Webster',
37
+ index: 'sharing-123-member-2'
35
38
  },
36
39
  {
37
40
  status: 'ready',
38
- name: 'Richelle Young'
41
+ name: 'Richelle Young',
42
+ index: 'sharing-123-member-3'
39
43
  },
40
44
  {
41
45
  status: 'ready',
42
- name: 'John Connor'
46
+ name: 'John Connor',
47
+ index: 'sharing-123-member-4'
43
48
  }
44
49
  ]
45
50
 
@@ -120,7 +125,7 @@ describe('AvatarList', () => {
120
125
  })
121
126
 
122
127
  describe('excludeMeAsOwnerFromRecipients', () => {
123
- test('excludeMeAsOwnerFromRecipients behavior', () => {
128
+ it('excludeMeAsOwnerFromRecipients behavior', () => {
124
129
  const recipients = [
125
130
  {
126
131
  status: 'owner',
@@ -4,7 +4,7 @@ import { recipients } from '../../../.storybook/fixtures/recipients'
4
4
  const meta = {
5
5
  component: AvatarList,
6
6
  args: {
7
- recipients: [...recipients, ...recipients]
7
+ recipients: [...recipients]
8
8
  }
9
9
  }
10
10
 
@@ -14,3 +14,21 @@ export const Default = {
14
14
  name: 'Default',
15
15
  args: {}
16
16
  }
17
+
18
+ export const WithGroups = {
19
+ name: 'With groups',
20
+ args: {
21
+ recipients: [
22
+ ...recipients,
23
+ {
24
+ name: 'Group 1',
25
+ type: 'group',
26
+ members: [
27
+ {
28
+ public_name: 'Alice'
29
+ }
30
+ ]
31
+ }
32
+ ]
33
+ }
34
+ }
@@ -3,8 +3,8 @@ import React from 'react'
3
3
  import Avatar from 'cozy-ui/transpiled/react/Avatar'
4
4
  import TeamIcon from 'cozy-ui/transpiled/react/Icons/Team'
5
5
 
6
- const GroupAvatar = ({ size }) => {
7
- return <Avatar icon={TeamIcon} size={size} />
6
+ const GroupAvatar = ({ size, className }) => {
7
+ return <Avatar icon={TeamIcon} size={size} className={className} />
8
8
  }
9
9
 
10
10
  export { GroupAvatar }