cozy-ui 128.9.0 → 128.10.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 +15 -0
- package/assets/icons/ui/matrix.svg +1 -0
- package/package.json +1 -1
- package/react/Contacts/AddModal/ContactForm/FieldInput.jsx +5 -2
- package/react/Contacts/AddModal/ContactForm/FieldInputAccordion.jsx +2 -2
- package/react/Contacts/AddModal/ContactForm/FieldInputLayout.jsx +2 -1
- package/react/Contacts/AddModal/ContactForm/contactToFormValues.js +7 -0
- package/react/Contacts/AddModal/ContactForm/contactToFormValues.spec.js +5 -0
- package/react/Contacts/AddModal/ContactForm/fieldsConfig.jsx +6 -0
- package/react/Contacts/AddModal/ContactForm/formValuesToContact.js +3 -0
- package/react/Contacts/AddModal/ContactForm/formValuesToContact.spec.js +57 -0
- package/react/Contacts/AddModal/ContactForm/helpers.js +41 -0
- package/react/Contacts/AddModal/ContactForm/helpers.spec.js +138 -0
- package/react/Contacts/AddModal/ContactForm/index.spec.jsx +12 -0
- package/react/Contacts/AddModal/ContactForm/locales/en.json +1 -0
- package/react/Contacts/AddModal/ContactForm/locales/fr.json +1 -0
- package/react/Contacts/AddModal/Readme.md +1 -1
- package/react/Contacts/AddModal/mocks.js +40 -1
- package/react/Icon/Readme.md +3 -1
- package/react/Icons/Matrix.jsx +12 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/FieldInput.d.ts +3 -1
- package/transpiled/react/Contacts/AddModal/ContactForm/FieldInput.js +8 -1
- package/transpiled/react/Contacts/AddModal/ContactForm/FieldInputAccordion.js +2 -4
- package/transpiled/react/Contacts/AddModal/ContactForm/FieldInputLayout.js +2 -1
- package/transpiled/react/Contacts/AddModal/ContactForm/contactToFormValues.js +7 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/fieldsConfig.js +5 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/formValuesToContact.js +3 -1
- package/transpiled/react/Contacts/AddModal/ContactForm/helpers.d.ts +6 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/helpers.js +39 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/locales/index.js +2 -0
- package/transpiled/react/Contacts/AddModal/mocks.d.ts +19 -0
- package/transpiled/react/Contacts/AddModal/mocks.js +32 -0
- package/transpiled/react/Icon/icons-sprite.d.ts +1 -1
- package/transpiled/react/Icon/icons-sprite.js +1 -1
- package/transpiled/react/Icons/Matrix.d.ts +2 -0
- package/transpiled/react/Icons/Matrix.js +13 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## [128.10.1](https://github.com/cozy/cozy-ui/compare/v128.10.0...v128.10.1) (2025-09-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **AddModal/ContactForm:** Secondary input wasn't hide correctly ([b1fd6b0](https://github.com/cozy/cozy-ui/commit/b1fd6b0))
|
|
7
|
+
|
|
8
|
+
# [128.10.0](https://github.com/cozy/cozy-ui/compare/v128.9.0...v128.10.0) (2025-09-16)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **Contacts/AddModal:** Add matrix ID input ([db8f522](https://github.com/cozy/cozy-ui/commit/db8f522))
|
|
14
|
+
* **Icons:** Add matrix ([4838a1f](https://github.com/cozy/cozy-ui/commit/4838a1f))
|
|
15
|
+
|
|
1
16
|
# [128.9.0](https://github.com/cozy/cozy-ui/compare/v128.8.0...v128.9.0) (2025-09-16)
|
|
2
17
|
|
|
3
18
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg width="16" height="10" viewBox="0 0 16 10" xmlns="http://www.w3.org/2000/svg"><path d="M3 1.111H1.333V8.89H3V10H0V0h3v1.111ZM16 10h-3V8.889h1.667V1.11H13V0h3v10ZM9.807 3.667c.587 0 1.043.167 1.368.503.328.332.492.79.492 1.374V9h-1.23V5.72c0-.688-.311-1.032-.931-1.032a.983.983 0 0 0-.531.162.945.945 0 0 0-.36.372V9h-1.23V5.53c0-.258-.08-.462-.241-.612-.161-.153-.387-.23-.68-.23-.153 0-.323.057-.507.171-.18.114-.312.24-.394.377V9h-1.23V3.765h.847l.25.459c.342-.372.784-.557 1.325-.557.699 0 1.226.188 1.58.566.154-.172.369-.309.644-.41.276-.104.552-.156.828-.156Z"/></svg>
|
package/package.json
CHANGED
|
@@ -22,6 +22,7 @@ const FieldInput = ({
|
|
|
22
22
|
error,
|
|
23
23
|
helperText,
|
|
24
24
|
label,
|
|
25
|
+
isInvisible,
|
|
25
26
|
required
|
|
26
27
|
}) => {
|
|
27
28
|
const [id] = useState(uniqueId('field_')) // state only use to generate id once and not at each render
|
|
@@ -51,8 +52,8 @@ const FieldInput = ({
|
|
|
51
52
|
className={cx(
|
|
52
53
|
className,
|
|
53
54
|
styles['contact-form-field__wrapper'],
|
|
54
|
-
'u-flex',
|
|
55
|
-
'u-flex-
|
|
55
|
+
'u-flex-column-s',
|
|
56
|
+
{ 'u-flex': !isInvisible, 'u-dn': isInvisible }
|
|
56
57
|
)}
|
|
57
58
|
>
|
|
58
59
|
<Field
|
|
@@ -103,6 +104,8 @@ FieldInput.propTypes = {
|
|
|
103
104
|
className: PropTypes.string,
|
|
104
105
|
labelProps: labelPropTypes,
|
|
105
106
|
attributes: fieldInputAttributesTypes,
|
|
107
|
+
/** Whether the field is visible by the user or not (still in the DOM anyway) */
|
|
108
|
+
isInvisible: PropTypes.bool,
|
|
106
109
|
contacts: PropTypes.shape({
|
|
107
110
|
data: PropTypes.arrayOf(PropTypes.object)
|
|
108
111
|
}),
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import cx from 'classnames'
|
|
2
1
|
import React, { useState } from 'react'
|
|
3
2
|
|
|
4
3
|
import FieldInput from './FieldInput'
|
|
@@ -43,9 +42,10 @@ const FieldInputAccordion = ({
|
|
|
43
42
|
return (
|
|
44
43
|
<FieldInput
|
|
45
44
|
key={index}
|
|
46
|
-
className=
|
|
45
|
+
className="u-mt-1"
|
|
47
46
|
attributes={attributes}
|
|
48
47
|
name={name}
|
|
48
|
+
isInvisible={!showExtended}
|
|
49
49
|
label={t(`Contacts.AddModal.ContactForm.fields.${name}`)}
|
|
50
50
|
/>
|
|
51
51
|
)
|
|
@@ -25,9 +25,10 @@ const FieldInputLayout = ({
|
|
|
25
25
|
|
|
26
26
|
return (
|
|
27
27
|
<div
|
|
28
|
-
className={cx('u-
|
|
28
|
+
className={cx('u-mt-1', {
|
|
29
29
|
'u-flex-items-center': !layout,
|
|
30
30
|
'u-flex-items-baseline': !!layout,
|
|
31
|
+
'u-flex': !isSecondary || showSecondaryFields,
|
|
31
32
|
'u-dn': isSecondary && !showSecondaryFields
|
|
32
33
|
})}
|
|
33
34
|
>
|
|
@@ -25,6 +25,7 @@ const contactToFormValues = (contact, t) => {
|
|
|
25
25
|
jobTitle,
|
|
26
26
|
cozy,
|
|
27
27
|
email,
|
|
28
|
+
impp,
|
|
28
29
|
name,
|
|
29
30
|
note,
|
|
30
31
|
phone
|
|
@@ -62,6 +63,11 @@ const contactToFormValues = (contact, t) => {
|
|
|
62
63
|
emailLabel: makeItemLabel(item)
|
|
63
64
|
}))
|
|
64
65
|
: [undefined]
|
|
66
|
+
const matrixValue =
|
|
67
|
+
impp && impp.length > 0
|
|
68
|
+
? impp.find(item => item.label === 'work' && item.protocol === 'matrix')
|
|
69
|
+
?.uri || undefined
|
|
70
|
+
: undefined
|
|
65
71
|
const phoneValue =
|
|
66
72
|
phone && phone.length > 0
|
|
67
73
|
? movePrimaryToHead(phone).map(item => ({
|
|
@@ -81,6 +87,7 @@ const contactToFormValues = (contact, t) => {
|
|
|
81
87
|
familyName: name?.familyName,
|
|
82
88
|
phone: phoneValue,
|
|
83
89
|
email: emailValue,
|
|
90
|
+
matrix: matrixValue,
|
|
84
91
|
address: addressValue,
|
|
85
92
|
cozy: cozyValue,
|
|
86
93
|
cozyLabel: cozyLabel,
|
|
@@ -16,6 +16,7 @@ describe('contactToFormValues function', () => {
|
|
|
16
16
|
cozy: undefined,
|
|
17
17
|
cozyLabel: undefined,
|
|
18
18
|
email: [undefined],
|
|
19
|
+
matrix: undefined,
|
|
19
20
|
familyName: undefined,
|
|
20
21
|
givenName: undefined,
|
|
21
22
|
note: undefined,
|
|
@@ -59,6 +60,7 @@ describe('contactToFormValues function', () => {
|
|
|
59
60
|
jobTitle: undefined,
|
|
60
61
|
cozy: undefined,
|
|
61
62
|
email: undefined,
|
|
63
|
+
impp: undefined,
|
|
62
64
|
name: {
|
|
63
65
|
givenName: 'Jane',
|
|
64
66
|
familyName: 'Doe'
|
|
@@ -76,6 +78,7 @@ describe('contactToFormValues function', () => {
|
|
|
76
78
|
cozy: undefined,
|
|
77
79
|
cozyLabel: undefined,
|
|
78
80
|
email: [undefined],
|
|
81
|
+
matrix: undefined,
|
|
79
82
|
givenName: 'Jane',
|
|
80
83
|
familyName: 'Doe',
|
|
81
84
|
note: undefined,
|
|
@@ -101,6 +104,7 @@ describe('contactToFormValues function', () => {
|
|
|
101
104
|
jobTitle: undefined,
|
|
102
105
|
cozy: undefined,
|
|
103
106
|
email: undefined,
|
|
107
|
+
impp: undefined,
|
|
104
108
|
name: undefined,
|
|
105
109
|
note: 'Eligendi velit eos ab libero molestiae consequatur autem sed.',
|
|
106
110
|
phone: []
|
|
@@ -115,6 +119,7 @@ describe('contactToFormValues function', () => {
|
|
|
115
119
|
cozy: undefined,
|
|
116
120
|
cozyLabel: undefined,
|
|
117
121
|
email: [undefined],
|
|
122
|
+
matrix: undefined,
|
|
118
123
|
givenName: undefined,
|
|
119
124
|
familyName: undefined,
|
|
120
125
|
note: 'Eligendi velit eos ab libero molestiae consequatur autem sed.',
|
|
@@ -8,6 +8,7 @@ import CommentIcon from '../../../Icons/Comment'
|
|
|
8
8
|
import CompanyIcon from '../../../Icons/Company'
|
|
9
9
|
import EmailIcon from '../../../Icons/Email'
|
|
10
10
|
import LocationIcon from '../../../Icons/Location'
|
|
11
|
+
import MatrixIcon from '../../../Icons/Matrix'
|
|
11
12
|
import PeopleIcon from '../../../Icons/People'
|
|
12
13
|
import RelationshipIcon from '../../../Icons/Relationship'
|
|
13
14
|
import TelephoneIcon from '../../../Icons/Telephone'
|
|
@@ -140,6 +141,11 @@ export const fields = [
|
|
|
140
141
|
]
|
|
141
142
|
}
|
|
142
143
|
},
|
|
144
|
+
{
|
|
145
|
+
name: 'matrix',
|
|
146
|
+
icon: MatrixIcon,
|
|
147
|
+
type: 'text'
|
|
148
|
+
},
|
|
143
149
|
{
|
|
144
150
|
name: 'address',
|
|
145
151
|
icon: LocationIcon,
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
removeRelatedContactRelationships,
|
|
6
6
|
createAddress,
|
|
7
7
|
getRelatedContactRelationships,
|
|
8
|
+
makeImppValues,
|
|
8
9
|
makeTypeAndLabel
|
|
9
10
|
} from './helpers'
|
|
10
11
|
|
|
@@ -18,6 +19,7 @@ const formValuesToContact = ({ formValues, oldContact, t }) => {
|
|
|
18
19
|
phone,
|
|
19
20
|
email,
|
|
20
21
|
address,
|
|
22
|
+
matrix,
|
|
21
23
|
cozy,
|
|
22
24
|
company,
|
|
23
25
|
jobTitle,
|
|
@@ -62,6 +64,7 @@ const formValuesToContact = ({ formValues, oldContact, t }) => {
|
|
|
62
64
|
primary: index === 0
|
|
63
65
|
}))
|
|
64
66
|
: [],
|
|
67
|
+
impp: makeImppValues(oldContactCleaned, matrix),
|
|
65
68
|
address: createAddress({ address, oldContact: oldContactCleaned, t }),
|
|
66
69
|
phone: phone
|
|
67
70
|
? phone
|
|
@@ -83,6 +83,14 @@ describe('formValuesToContact', () => {
|
|
|
83
83
|
label: undefined
|
|
84
84
|
}
|
|
85
85
|
],
|
|
86
|
+
impp: [
|
|
87
|
+
{
|
|
88
|
+
uri: 'john@doe.matrix.net',
|
|
89
|
+
protocol: 'matrix',
|
|
90
|
+
label: 'work',
|
|
91
|
+
primary: true
|
|
92
|
+
}
|
|
93
|
+
],
|
|
86
94
|
fullname: 'John J. Doe',
|
|
87
95
|
indexes: {
|
|
88
96
|
byFamilyNameGivenNameEmailCozyUrl:
|
|
@@ -160,6 +168,7 @@ describe('formValuesToContact', () => {
|
|
|
160
168
|
emailLabel: undefined
|
|
161
169
|
}
|
|
162
170
|
],
|
|
171
|
+
matrix: 'john@doe.matrix.net',
|
|
163
172
|
familyName: 'Doe',
|
|
164
173
|
givenName: 'Jane',
|
|
165
174
|
note: undefined,
|
|
@@ -182,6 +191,14 @@ describe('formValuesToContact', () => {
|
|
|
182
191
|
cozy: [],
|
|
183
192
|
displayName: 'Jane Doe',
|
|
184
193
|
email: [],
|
|
194
|
+
impp: [
|
|
195
|
+
{
|
|
196
|
+
uri: 'john@doe.matrix.net',
|
|
197
|
+
protocol: 'matrix',
|
|
198
|
+
label: 'work',
|
|
199
|
+
primary: true
|
|
200
|
+
}
|
|
201
|
+
],
|
|
185
202
|
fullname: 'Jane Doe',
|
|
186
203
|
indexes: { byFamilyNameGivenNameEmailCozyUrl: 'doejane' },
|
|
187
204
|
jobTitle: '',
|
|
@@ -294,6 +311,7 @@ describe('formValuesToContact', () => {
|
|
|
294
311
|
birthplace: undefined,
|
|
295
312
|
note: undefined,
|
|
296
313
|
address: [undefined],
|
|
314
|
+
matrix: undefined,
|
|
297
315
|
email: [undefined],
|
|
298
316
|
phone: [undefined],
|
|
299
317
|
cozy: undefined,
|
|
@@ -307,6 +325,25 @@ describe('formValuesToContact', () => {
|
|
|
307
325
|
jobTitle: '',
|
|
308
326
|
address: [],
|
|
309
327
|
email: [],
|
|
328
|
+
impp: [
|
|
329
|
+
{
|
|
330
|
+
uri: 'john.doe@xmpp.net',
|
|
331
|
+
protocol: 'xmpp',
|
|
332
|
+
label: 'home',
|
|
333
|
+
primary: false
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
uri: 'john.doe@xmpp.net',
|
|
337
|
+
protocol: 'xmpp',
|
|
338
|
+
label: 'work',
|
|
339
|
+
primary: false
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
uri: 'john@doe.matrix.home',
|
|
343
|
+
protocol: 'matrix',
|
|
344
|
+
label: 'home'
|
|
345
|
+
}
|
|
346
|
+
],
|
|
310
347
|
cozy: [],
|
|
311
348
|
phone: [],
|
|
312
349
|
birthday: '',
|
|
@@ -335,6 +372,7 @@ describe('formValuesToContact', () => {
|
|
|
335
372
|
birthplace: '',
|
|
336
373
|
note: '',
|
|
337
374
|
address: [{}],
|
|
375
|
+
matrix: '',
|
|
338
376
|
email: [{}],
|
|
339
377
|
phone: [{}],
|
|
340
378
|
cozy: '',
|
|
@@ -348,6 +386,25 @@ describe('formValuesToContact', () => {
|
|
|
348
386
|
jobTitle: '',
|
|
349
387
|
address: [],
|
|
350
388
|
email: [],
|
|
389
|
+
impp: [
|
|
390
|
+
{
|
|
391
|
+
uri: 'john.doe@xmpp.net',
|
|
392
|
+
protocol: 'xmpp',
|
|
393
|
+
label: 'home',
|
|
394
|
+
primary: false
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
uri: 'john.doe@xmpp.net',
|
|
398
|
+
protocol: 'xmpp',
|
|
399
|
+
label: 'work',
|
|
400
|
+
primary: false
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
uri: 'john@doe.matrix.home',
|
|
404
|
+
protocol: 'matrix',
|
|
405
|
+
label: 'home'
|
|
406
|
+
}
|
|
407
|
+
],
|
|
351
408
|
cozy: [],
|
|
352
409
|
phone: [],
|
|
353
410
|
birthday: '',
|
|
@@ -281,6 +281,47 @@ export const makeCustomLabel = (value, t) => {
|
|
|
281
281
|
return firstString + secondString || null
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
+
/**
|
|
285
|
+
*
|
|
286
|
+
* @param {import('cozy-client/types/types').IOCozyContact} oldContact - Contact to be modified
|
|
287
|
+
* @param {string?} value - New URI value to add to the Contact
|
|
288
|
+
* @returns {{ uri: string, protocol: string, label: string, primary?: boolean }[]}
|
|
289
|
+
*/
|
|
290
|
+
export const makeImppValues = (oldContact, value) => {
|
|
291
|
+
const _value = value?.trim() || ''
|
|
292
|
+
const oldImppValues = oldContact?.impp
|
|
293
|
+
|
|
294
|
+
if (_value) {
|
|
295
|
+
if (!oldImppValues || oldImppValues.length === 0) {
|
|
296
|
+
return [
|
|
297
|
+
{
|
|
298
|
+
uri: _value,
|
|
299
|
+
protocol: 'matrix',
|
|
300
|
+
label: 'work',
|
|
301
|
+
primary: true
|
|
302
|
+
}
|
|
303
|
+
]
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
return oldImppValues.map(el => {
|
|
307
|
+
if (el.protocol === 'matrix' && el.label === 'work') {
|
|
308
|
+
return { ...el, uri: _value }
|
|
309
|
+
}
|
|
310
|
+
return el
|
|
311
|
+
})
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
return (
|
|
315
|
+
oldImppValues
|
|
316
|
+
?.map(el => {
|
|
317
|
+
if (el.protocol !== 'matrix' || el.label !== 'work') {
|
|
318
|
+
return el
|
|
319
|
+
}
|
|
320
|
+
})
|
|
321
|
+
.filter(Boolean) || []
|
|
322
|
+
)
|
|
323
|
+
}
|
|
324
|
+
|
|
284
325
|
/**
|
|
285
326
|
*
|
|
286
327
|
* @param {string} name
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
moveToHead,
|
|
3
3
|
makeItemLabel,
|
|
4
4
|
makeTypeAndLabel,
|
|
5
|
+
makeImppValues,
|
|
5
6
|
makeInitialCustomValue
|
|
6
7
|
} from './helpers'
|
|
7
8
|
|
|
@@ -73,6 +74,143 @@ describe('makeTypeAndLabel', () => {
|
|
|
73
74
|
})
|
|
74
75
|
})
|
|
75
76
|
|
|
77
|
+
describe('makeImppValues', () => {
|
|
78
|
+
it('should replace only uri for {label: "work", protocol: "matrix"}', () => {
|
|
79
|
+
const res = makeImppValues(
|
|
80
|
+
{
|
|
81
|
+
impp: [
|
|
82
|
+
{
|
|
83
|
+
uri: 'john.doe@xmpp.net',
|
|
84
|
+
protocol: 'xmpp',
|
|
85
|
+
label: 'home',
|
|
86
|
+
primary: false
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
uri: 'john.doe@xmpp.net',
|
|
90
|
+
protocol: 'xmpp',
|
|
91
|
+
label: 'work',
|
|
92
|
+
primary: false
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
uri: 'john@doe.matrix.net',
|
|
96
|
+
protocol: 'matrix',
|
|
97
|
+
label: 'work',
|
|
98
|
+
primary: true
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
uri: 'john@doe.matrix.home',
|
|
102
|
+
protocol: 'matrix',
|
|
103
|
+
label: 'home'
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
'newMatrixURI'
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
expect(res).toStrictEqual([
|
|
111
|
+
{
|
|
112
|
+
uri: 'john.doe@xmpp.net',
|
|
113
|
+
protocol: 'xmpp',
|
|
114
|
+
label: 'home',
|
|
115
|
+
primary: false
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
uri: 'john.doe@xmpp.net',
|
|
119
|
+
protocol: 'xmpp',
|
|
120
|
+
label: 'work',
|
|
121
|
+
primary: false
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
uri: 'newMatrixURI',
|
|
125
|
+
protocol: 'matrix',
|
|
126
|
+
label: 'work',
|
|
127
|
+
primary: true
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
uri: 'john@doe.matrix.home',
|
|
131
|
+
protocol: 'matrix',
|
|
132
|
+
label: 'home'
|
|
133
|
+
}
|
|
134
|
+
])
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
it('should remove correctly', () => {
|
|
138
|
+
const res = makeImppValues(
|
|
139
|
+
{
|
|
140
|
+
impp: [
|
|
141
|
+
{
|
|
142
|
+
uri: 'john.doe@xmpp.net',
|
|
143
|
+
protocol: 'xmpp',
|
|
144
|
+
label: 'home',
|
|
145
|
+
primary: false
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
uri: 'john.doe@xmpp.net',
|
|
149
|
+
protocol: 'xmpp',
|
|
150
|
+
label: 'work',
|
|
151
|
+
primary: false
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
uri: 'john@doe.matrix.net',
|
|
155
|
+
protocol: 'matrix',
|
|
156
|
+
label: 'work',
|
|
157
|
+
primary: true
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
uri: 'john@doe.matrix.home',
|
|
161
|
+
protocol: 'matrix',
|
|
162
|
+
label: 'home'
|
|
163
|
+
}
|
|
164
|
+
]
|
|
165
|
+
},
|
|
166
|
+
''
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
expect(res).toStrictEqual([
|
|
170
|
+
{
|
|
171
|
+
uri: 'john.doe@xmpp.net',
|
|
172
|
+
protocol: 'xmpp',
|
|
173
|
+
label: 'home',
|
|
174
|
+
primary: false
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
uri: 'john.doe@xmpp.net',
|
|
178
|
+
protocol: 'xmpp',
|
|
179
|
+
label: 'work',
|
|
180
|
+
primary: false
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
uri: 'john@doe.matrix.home',
|
|
184
|
+
protocol: 'matrix',
|
|
185
|
+
label: 'home'
|
|
186
|
+
}
|
|
187
|
+
])
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
it('should add the matrix impp values for the first time if no impp attribute', () => {
|
|
191
|
+
const expected = [
|
|
192
|
+
{
|
|
193
|
+
uri: 'newMatrixURI',
|
|
194
|
+
protocol: 'matrix',
|
|
195
|
+
label: 'work',
|
|
196
|
+
primary: true
|
|
197
|
+
}
|
|
198
|
+
]
|
|
199
|
+
|
|
200
|
+
expect(makeImppValues({ impp: undefined }, 'newMatrixURI')).toStrictEqual(
|
|
201
|
+
expected
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
expect(makeImppValues({ impp: [] }, 'newMatrixURI')).toStrictEqual(expected)
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
it('should not add empty object if value is empty', () => {
|
|
208
|
+
expect(makeImppValues({ impp: undefined }, '')).toStrictEqual([])
|
|
209
|
+
|
|
210
|
+
expect(makeImppValues({ impp: [] }, '')).toStrictEqual([])
|
|
211
|
+
})
|
|
212
|
+
})
|
|
213
|
+
|
|
76
214
|
describe('makeInitialCustomValue', () => {
|
|
77
215
|
it('should return undefined if no name', () => {
|
|
78
216
|
const res = makeInitialCustomValue(
|
|
@@ -21,6 +21,7 @@ const labels = [
|
|
|
21
21
|
'Phone',
|
|
22
22
|
'Email',
|
|
23
23
|
'Address',
|
|
24
|
+
'Matrix ID',
|
|
24
25
|
'Twake URL',
|
|
25
26
|
'Company',
|
|
26
27
|
'Job title',
|
|
@@ -54,6 +55,7 @@ describe('ContactForm', () => {
|
|
|
54
55
|
expect(screen.queryByDisplayValue(contact.name.familyName)).not.toBeNull()
|
|
55
56
|
expect(screen.queryByDisplayValue(contact.phone[0].number)).not.toBeNull()
|
|
56
57
|
expect(screen.queryByDisplayValue(contact.email[0].address)).not.toBeNull()
|
|
58
|
+
expect(screen.queryByDisplayValue(contact.impp[2].uri)).not.toBeNull()
|
|
57
59
|
expect(
|
|
58
60
|
screen.queryByDisplayValue(contact.address[0].formattedAddress)
|
|
59
61
|
).not.toBeNull()
|
|
@@ -78,6 +80,14 @@ describe('ContactForm', () => {
|
|
|
78
80
|
type: undefined
|
|
79
81
|
}
|
|
80
82
|
],
|
|
83
|
+
impp: [
|
|
84
|
+
{
|
|
85
|
+
uri: '123-matrixID-456',
|
|
86
|
+
protocol: 'matrix',
|
|
87
|
+
label: 'work',
|
|
88
|
+
primary: true
|
|
89
|
+
}
|
|
90
|
+
],
|
|
81
91
|
birthday: '2015-12-31',
|
|
82
92
|
birthplace: 'somewhere',
|
|
83
93
|
gender: 'male',
|
|
@@ -124,6 +134,7 @@ describe('ContactForm', () => {
|
|
|
124
134
|
additionalName: '',
|
|
125
135
|
'phone[0].phone': '+33678987654',
|
|
126
136
|
'email[0].email': 'jcvc@cozy.cloud',
|
|
137
|
+
matrix: '123-matrixID-456',
|
|
127
138
|
cozy: 'https://jcvd.cozy.cloud',
|
|
128
139
|
company: 'Cozy CLoud',
|
|
129
140
|
jobTitle: 'Dreamer',
|
|
@@ -171,6 +182,7 @@ describe('ContactForm', () => {
|
|
|
171
182
|
Lastname: 'Van Cozy',
|
|
172
183
|
Phone: '+33678987654',
|
|
173
184
|
Email: 'jcvc@cozy.cloud',
|
|
185
|
+
Matrix: '123-matrixID-456',
|
|
174
186
|
Address: '18 rue des fleurs, Pecado',
|
|
175
187
|
'Twake URL': 'https://jcvd.cozy.cloud',
|
|
176
188
|
Company: 'Cozy CLoud',
|
|
@@ -8,7 +8,7 @@ import ContactsAddModal from 'cozy-ui/transpiled/react/Contacts/AddModal'
|
|
|
8
8
|
import DemoProvider from 'cozy-ui/docs/components/DemoProvider'
|
|
9
9
|
import AlertProvider from 'cozy-ui/transpiled/react/providers/Alert'
|
|
10
10
|
import Button from 'cozy-ui/transpiled/react/Buttons'
|
|
11
|
-
import { johnDoeContact
|
|
11
|
+
import { johnDoeContact } from 'cozy-ui/transpiled/react/Contacts/AddModal/mocks'
|
|
12
12
|
import contacts from 'cozy-ui/transpiled/react/ContactsList/_mockContacts.json'
|
|
13
13
|
import Variants from 'cozy-ui/docs/components/Variants'
|
|
14
14
|
|
|
@@ -30,6 +30,31 @@ export const johnDoeContact = {
|
|
|
30
30
|
primary: true
|
|
31
31
|
}
|
|
32
32
|
],
|
|
33
|
+
impp: [
|
|
34
|
+
{
|
|
35
|
+
uri: 'john.doe@xmpp.net',
|
|
36
|
+
protocol: 'xmpp',
|
|
37
|
+
label: 'home',
|
|
38
|
+
primary: false
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
uri: 'john.doe@xmpp.net',
|
|
42
|
+
protocol: 'xmpp',
|
|
43
|
+
label: 'work',
|
|
44
|
+
primary: false
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
uri: 'john@doe.matrix.net',
|
|
48
|
+
protocol: 'matrix',
|
|
49
|
+
label: 'work',
|
|
50
|
+
primary: true
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
uri: 'john@doe.matrix.home',
|
|
54
|
+
protocol: 'matrix',
|
|
55
|
+
label: 'home'
|
|
56
|
+
}
|
|
57
|
+
],
|
|
33
58
|
birthday: '1999-5-1',
|
|
34
59
|
birthplace: 'somewhere',
|
|
35
60
|
gender: 'male',
|
|
@@ -71,6 +96,7 @@ export const johnDoeFormValues = {
|
|
|
71
96
|
gender: 'male',
|
|
72
97
|
cozy: 'https://johndoe.mycozy.cloud',
|
|
73
98
|
cozyLabel: '{"type":"MyCozy"}',
|
|
99
|
+
matrix: 'john@doe.matrix.net',
|
|
74
100
|
address: [
|
|
75
101
|
{
|
|
76
102
|
fieldId: 'fieldId_1',
|
|
@@ -167,6 +193,20 @@ export const johnDoeContactWithRelated = {
|
|
|
167
193
|
type: 'Work'
|
|
168
194
|
}
|
|
169
195
|
],
|
|
196
|
+
impp: [
|
|
197
|
+
{
|
|
198
|
+
uri: 'john.doe@xmpp.net',
|
|
199
|
+
protocol: 'xmpp',
|
|
200
|
+
label: 'home',
|
|
201
|
+
primary: false
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
uri: 'john@doe.matrix.net',
|
|
205
|
+
protocol: 'matrix',
|
|
206
|
+
label: 'work',
|
|
207
|
+
primary: true
|
|
208
|
+
}
|
|
209
|
+
],
|
|
170
210
|
email: [
|
|
171
211
|
{
|
|
172
212
|
address: 'john.doe@posteo.net',
|
|
@@ -211,7 +251,6 @@ export const johnDoeContactWithRelated = {
|
|
|
211
251
|
primary: false
|
|
212
252
|
}
|
|
213
253
|
],
|
|
214
|
-
|
|
215
254
|
relationships: {
|
|
216
255
|
accounts: { data: [] },
|
|
217
256
|
groups: { data: [] },
|