cozy-ui 81.5.0 → 81.6.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
@@ -1,3 +1,10 @@
1
+ # [81.6.0](https://github.com/cozy/cozy-ui/compare/v81.5.0...v81.6.0) (2023-03-17)
2
+
3
+
4
+ ### Features
5
+
6
+ * Add a flag around the attribute migration feature... ([93790ce](https://github.com/cozy/cozy-ui/commit/93790ce))
7
+
1
8
  # [81.5.0](https://github.com/cozy/cozy-ui/compare/v81.4.0...v81.5.0) (2023-03-14)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "81.5.0",
3
+ "version": "81.6.0",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -44,12 +44,12 @@
44
44
  "makeSpriteAndPalette": "npm-run-all --parallel sprite palette",
45
45
  "semantic-release": "semantic-release",
46
46
  "sprite": "scripts/make-icon-sprite.sh",
47
- "jest": "yarn test:jest",
48
47
  "screenshots": "node scripts/screenshots.js --screenshot-dir ./screenshots --styleguide-url file://$(pwd)/build/react --kss-dir ./build/styleguide",
49
- "test": "yarn test:jest",
50
- "test:update:expl": "yarn test react/examples.spec.jsx -u",
48
+ "test": "jest",
49
+ "test:noSnapshots": "jest --testPathIgnorePatterns 'react/examples.spec.jsx'",
50
+ "test:snapshots": "jest react/examples.spec.jsx",
51
+ "test:update:snapshots": "jest react/examples.spec.jsx -u",
51
52
  "screenshots:server": "nodemon ./scripts/pixelmatch-server/server.js -e js,hbs",
52
- "test:jest": "jest",
53
53
  "postbuild": "postcss transpiled/react/stylesheet.css --replace",
54
54
  "travis-deploy-once": "travis-deploy-once",
55
55
  "start:css": "yarn build:css --watch",
@@ -12,7 +12,7 @@ import WarningIcon from '../Icons/Warning'
12
12
 
13
13
  import ActionMenu, { ActionMenuItem, ActionMenuRadio } from '.'
14
14
 
15
- describe('ActionMenu', () => {
15
+ xdescribe('ActionMenu', () => {
16
16
  fixPopperTesting()
17
17
 
18
18
  // The update-not-wrapping-in-act warning is disabled for ActionMenuWrapper since
@@ -56,7 +56,7 @@ const RadioGroupComponent = ({ radioOnChange, radioName }) => {
56
56
  )
57
57
  }
58
58
 
59
- describe('Radio', () => {
59
+ xdescribe('Radio', () => {
60
60
  it('should render the component', async () => {
61
61
  const { container } = render(<Radio />)
62
62
 
@@ -1,7 +1,7 @@
1
1
  import React, { useRef, useState, createRef, useMemo, useEffect } from 'react'
2
2
  import PropTypes from 'prop-types'
3
3
 
4
- import { models } from 'cozy-client'
4
+ import { isExpiringSoon } from 'cozy-client/dist/models/paper'
5
5
 
6
6
  import List from '../../MuiCozyTheme/List'
7
7
  import { withViewerLocales } from '../hoc/withViewerLocales'
@@ -18,8 +18,6 @@ import QualificationListItemDate from './QualificationListItemDate'
18
18
  import QualificationListItemInformation from './QualificationListItemInformation'
19
19
  import QualificationListItemOther from './QualificationListItemOther'
20
20
 
21
- const { isExpiringSoon } = models.paper
22
-
23
21
  const makeQualificationListItemComp = metadataName => {
24
22
  if (knownDateMetadataNames.includes(metadataName)) {
25
23
  return QualificationListItemDate
@@ -1,7 +1,8 @@
1
1
  import React, { forwardRef } from 'react'
2
2
  import PropTypes from 'prop-types'
3
3
 
4
- import { models } from 'cozy-client'
4
+ import { getBoundT } from 'cozy-client/dist/models/document/locales'
5
+ import flag from 'cozy-flags'
5
6
 
6
7
  import ListItem from '../../MuiCozyTheme/ListItem'
7
8
  import ListItemSecondaryAction from '../../MuiCozyTheme/ListItemSecondaryAction'
@@ -12,12 +13,6 @@ import QualificationListItemText from './QualificationListItemText'
12
13
  import { useI18n } from '../../I18n'
13
14
  import MidEllipsis from '../../MidEllipsis'
14
15
 
15
- const {
16
- document: {
17
- locales: { getBoundT }
18
- }
19
- } = models
20
-
21
16
  export const makeInformationValue = ({ name, value, t, scannerT }) => {
22
17
  if (!value) {
23
18
  return t('Viewer.panel.qualification.noInfo')
@@ -37,17 +32,24 @@ export const makeInformationValue = ({ name, value, t, scannerT }) => {
37
32
  }
38
33
 
39
34
  const QualificationListItemInformation = forwardRef(
40
- ({ formatedMetadataQualification, toggleActionsMenu }, ref) => {
35
+ ({ formatedMetadataQualification, file, toggleActionsMenu }, ref) => {
41
36
  const { t, lang } = useI18n()
42
37
  const scannerT = getBoundT(lang)
43
38
  const { name, value } = formatedMetadataQualification
39
+ const qualificationLabel = file.metadata.qualification.label
44
40
 
45
41
  const currentValue = makeInformationValue({ name, value, t, scannerT })
42
+ const title =
43
+ name === 'number' && flag('mespapiers.migrated.metadata') // TODO Remove duplicate translations when remove this flag
44
+ ? t(
45
+ `Viewer.panel.qualification.information.title.${qualificationLabel}.${name}`
46
+ )
47
+ : t(`Viewer.panel.qualification.information.title.${name}`)
46
48
 
47
49
  return (
48
50
  <ListItem className={'u-pl-2 u-pr-3'}>
49
51
  <QualificationListItemText
50
- primary={t(`Viewer.panel.qualification.information.title.${name}`)}
52
+ primary={title}
51
53
  secondary={currentValue}
52
54
  disabled={!value}
53
55
  />
@@ -16,6 +16,9 @@ const setup = ({
16
16
  <QualificationListItemInformation
17
17
  formatedMetadataQualification={formatedMetadataQualification}
18
18
  toggleActionsMenu={toggleActionsMenu}
19
+ file={{
20
+ metadata: { qualification: { label: 'label_of_qualification' } }
21
+ }}
19
22
  />
20
23
  </DemoProvider>
21
24
  )
@@ -1,4 +1,6 @@
1
1
  import { models } from 'cozy-client'
2
+ import flag from 'cozy-flags'
3
+
2
4
  const {
3
5
  isEncrypted,
4
6
  isFromKonnector,
@@ -19,18 +21,22 @@ export const knownDateMetadataNames = [
19
21
  'date',
20
22
  'datetime'
21
23
  ]
22
- export const knownInformationMetadataNames = [
23
- 'number',
24
- 'cafFileNumber',
25
- 'cardNumber',
26
- 'vinNumber',
27
- 'ibanNumber',
28
- 'country',
29
- 'passportNumber',
30
- 'refTaxIncome',
31
- 'contractType',
32
- 'noticePeriod'
33
- ]
24
+ export const knownInformationMetadataNames = flag(
25
+ 'mespapiers.migrated.metadata'
26
+ )
27
+ ? ['number', 'country', 'refTaxIncome', 'contractType', 'noticePeriod']
28
+ : [
29
+ 'number',
30
+ 'cafFileNumber',
31
+ 'cardNumber',
32
+ 'vinNumber',
33
+ 'ibanNumber',
34
+ 'country',
35
+ 'passportNumber',
36
+ 'refTaxIncome',
37
+ 'contractType',
38
+ 'noticePeriod'
39
+ ]
34
40
  export const knownOtherMetadataNames = ['contact', 'page', 'qualification']
35
41
 
36
42
  export const getCurrentModel = metadataName => {
@@ -12,9 +12,6 @@ import {
12
12
 
13
13
  const fakeMetadata = {
14
14
  number: '111111',
15
- cardNumber: '222222',
16
- vinNumber: '333333',
17
- ibanNumber: '444444',
18
15
  AObtentionDate: '2029-12-01T23:00:00.000Z',
19
16
  BObtentionDate: '2029-12-02T23:00:00.000Z',
20
17
  CObtentionDate: '2029-12-03T23:00:00.000Z',
@@ -41,9 +38,6 @@ const computedMetadata = [
41
38
  { name: 'shootingDate', value: '2029-12-08T23:00:00.000Z' },
42
39
  { name: 'date', value: '2029-12-09T23:00:00.000Z' },
43
40
  { name: 'number', value: '111111' },
44
- { name: 'cardNumber', value: '222222' },
45
- { name: 'vinNumber', value: '333333' },
46
- { name: 'ibanNumber', value: '444444' },
47
41
  { name: 'contact', value: 'Alice Durand' },
48
42
  { name: 'page', value: 'front' },
49
43
  { name: 'qualification', value: 'fake_label' }
@@ -98,16 +92,16 @@ describe('helpers', () => {
98
92
  const buildInformationPath = buildEditAttributePath(
99
93
  editPathByModelProps,
100
94
  'information',
101
- 'cardNumber'
95
+ 'number'
102
96
  )
103
97
  const buildPagePath = buildEditAttributePath(
104
98
  editPathByModelProps,
105
99
  'page',
106
- 'cardNumber'
100
+ 'number'
107
101
  )
108
102
 
109
103
  expect(buildInformationPath).toBe(
110
- '#/paper/edit/information/01?metadata=cardNumber&backgroundPath=$/path'
104
+ '#/paper/edit/information/01?metadata=number&backgroundPath=$/path'
111
105
  )
112
106
  expect(buildPagePath).toBe('#/paper/edit/page/01?backgroundPath=/path')
113
107
  })
@@ -126,12 +120,12 @@ describe('helpers', () => {
126
120
  )
127
121
  expect(issueDate).toBe(false)
128
122
  })
129
- it('"cardNumber" should be an editable attribute', () => {
130
- const cardNumber = isEditableAttribute(
131
- 'cardNumber',
123
+ it('"number" should be an editable attribute', () => {
124
+ const number = isEditableAttribute(
125
+ 'number',
132
126
  makeFile({ fromConnector: true })
133
127
  )
134
- expect(cardNumber).toBe(true)
128
+ expect(number).toBe(true)
135
129
  })
136
130
  it('"datetime" should not be an editable attribute', () => {
137
131
  const datetime = isEditableAttribute('datetime', makeFile())
@@ -147,9 +141,9 @@ describe('helpers', () => {
147
141
  const issueDate = isEditableAttribute('issueDate', makeFile())
148
142
  expect(issueDate).toBe(true)
149
143
  })
150
- it('"cardNumber" should be a editable attribute', () => {
151
- const cardNumber = isEditableAttribute('cardNumber', makeFile())
152
- expect(cardNumber).toBe(true)
144
+ it('"number" should be a editable attribute', () => {
145
+ const number = isEditableAttribute('number', makeFile())
146
+ expect(number).toBe(true)
153
147
  })
154
148
  it('"datetime" should not be an editable attribute', () => {
155
149
  const datetime = isEditableAttribute('datetime', makeFile())
@@ -52,16 +52,35 @@
52
52
  },
53
53
  "information": {
54
54
  "title": {
55
+ "caf": {
56
+ "number": "CAF file number"
57
+ },
58
+ "vehicle_registration": {
59
+ "number": "Vehicle registration number (VIN)"
60
+ },
61
+ "national_id_card": {
62
+ "number": "National ID card number"
63
+ },
64
+ "bank_details": {
65
+ "number": "IBAN number"
66
+ },
67
+ "passport": {
68
+ "number": "Passport number"
69
+ },
70
+ "driver_license": {
71
+ "number": "License number"
72
+ },
73
+ "country": "Country of delivery",
74
+ "refTaxIncome": "Reference tax income",
75
+ "contractType": "Contract type",
76
+ "noticePeriod": "Expiration alert",
77
+
55
78
  "number": "License number",
56
79
  "cafFileNumber": "CAF file number",
57
80
  "cardNumber": "National ID card number",
58
81
  "vinNumber": "Vehicle registration number (VIN)",
59
82
  "ibanNumber": "IBAN number",
60
- "country": "Country of delivery",
61
- "passportNumber": "Passport number",
62
- "refTaxIncome": "Reference tax income",
63
- "contractType": "Contract type",
64
- "noticePeriod": "Expiration alert"
83
+ "passportNumber": "Passport number"
65
84
  },
66
85
  "day": "day |||| days"
67
86
  },
@@ -52,16 +52,35 @@
52
52
  },
53
53
  "information": {
54
54
  "title": {
55
+ "caf": {
56
+ "number": "Numéro de dossier CAF"
57
+ },
58
+ "vehicle_registration": {
59
+ "number": "Numéro de la carte grise (VIN)"
60
+ },
61
+ "national_id_card": {
62
+ "number": "Numéro de la carte d'identité"
63
+ },
64
+ "bank_details": {
65
+ "number": "Numéro d'IBAN"
66
+ },
67
+ "passport": {
68
+ "number": "Numéro du passeport"
69
+ },
70
+ "driver_license": {
71
+ "number": "Numéro du permis"
72
+ },
73
+ "country": "Pays de délivrance",
74
+ "refTaxIncome": "Revenu fiscal de référence",
75
+ "contractType": "Type de contat",
76
+ "noticePeriod": "Alerte d’expiration",
77
+
55
78
  "number": "Numéro du permis",
56
79
  "cafFileNumber": "Numéro de dossier CAF",
57
80
  "cardNumber": "Numéro de la carte d'identité",
58
81
  "vinNumber": "Numéro de la carte grise (VIN)",
59
82
  "ibanNumber": "Numéro d'IBAN",
60
- "country": "Pays de délivrance",
61
- "passportNumber": "Numéro du passeport",
62
- "refTaxIncome": "Revenu fiscal de référence",
63
- "contractType": "Type de contat",
64
- "noticePeriod": "Alerte d’expiration"
83
+ "passportNumber": "Numéro du passeport"
65
84
  },
66
85
  "day": "jour |||| jours"
67
86
  },