cozy-ui 77.8.0 → 77.9.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
+ # [77.9.0](https://github.com/cozy/cozy-ui/compare/v77.8.0...v77.9.0) (2022-11-28)
2
+
3
+
4
+ ### Features
5
+
6
+ * **Viewer:** Add notice period metadata ([956fd83](https://github.com/cozy/cozy-ui/commit/956fd83))
7
+
1
8
  # [77.8.0](https://github.com/cozy/cozy-ui/compare/v77.7.1...v77.8.0) (2022-11-28)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "77.8.0",
3
+ "version": "77.9.0",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -10,16 +10,26 @@ import QualificationListItemText from './QualificationListItemText'
10
10
  import { useI18n } from '../../I18n'
11
11
  import MidEllipsis from '../../MidEllipsis'
12
12
 
13
+ export const makeInformationValue = (name, value, t) => {
14
+ if (!value) {
15
+ return t('Viewer.panel.qualification.noInfo')
16
+ }
17
+
18
+ if (name === 'noticePeriod') {
19
+ return `${value} ${t('Viewer.panel.qualification.information.day', {
20
+ smart_count: value
21
+ })}`
22
+ }
23
+
24
+ return <MidEllipsis text={value} />
25
+ }
26
+
13
27
  const QualificationListItemInformation = forwardRef(
14
28
  ({ formatedMetadataQualification, toggleActionsMenu }, ref) => {
15
29
  const { t } = useI18n()
16
30
  const { name, value } = formatedMetadataQualification
17
31
 
18
- const currentValue = value ? (
19
- <MidEllipsis text={value} />
20
- ) : (
21
- t('Viewer.panel.qualification.noInfo')
22
- )
32
+ const currentValue = makeInformationValue(name, value, t)
23
33
 
24
34
  return (
25
35
  <ListItem className={'u-pl-2 u-pr-3'}>
@@ -2,7 +2,10 @@ import React from 'react'
2
2
  import { fireEvent, render } from '@testing-library/react'
3
3
  import DemoProvider from '../docs/DemoProvider'
4
4
 
5
- import QualificationListItemInformation from './QualificationListItemInformation'
5
+ import QualificationListItemInformation, {
6
+ makeInformationValue
7
+ } from './QualificationListItemInformation'
8
+ import MidEllipsis from '../../MidEllipsis'
6
9
 
7
10
  const setup = ({
8
11
  formatedMetadataQualification = {},
@@ -49,4 +52,34 @@ describe('QualificationListItemInformation', () => {
49
52
  expect(toggleActionsMenu).toBeCalledWith('Italie')
50
53
  })
51
54
  })
55
+ describe('makeInformationValue', () => {
56
+ let mockT
57
+ beforeEach(() => {
58
+ mockT = jest.fn(key => key)
59
+ })
60
+ afterEach(() => {
61
+ mockT = jest.fn(key => key)
62
+ })
63
+
64
+ it('should return "MidEllipsis" component with the value', () => {
65
+ const res = makeInformationValue('metadataName', 'metadataValue', mockT)
66
+
67
+ expect(res).toEqual(<MidEllipsis text="metadataValue" />)
68
+ })
69
+ it('should return value with suffix locale', () => {
70
+ const res = makeInformationValue('noticePeriod', '88', mockT)
71
+
72
+ expect(res).toEqual('88 Viewer.panel.qualification.information.day')
73
+ })
74
+ it('should return "noInfo" value', () => {
75
+ const res = makeInformationValue('metadataName', '', mockT)
76
+
77
+ expect(res).toEqual('Viewer.panel.qualification.noInfo')
78
+ })
79
+ it('should return noInfo value with "noticePeriod" metadata name', () => {
80
+ const res = makeInformationValue('noticePeriod', '', mockT)
81
+
82
+ expect(res).toEqual('Viewer.panel.qualification.noInfo')
83
+ })
84
+ })
52
85
  })
@@ -25,7 +25,8 @@ export const knownInformationMetadataNames = [
25
25
  'vinNumber',
26
26
  'ibanNumber',
27
27
  'country',
28
- 'passportNumber'
28
+ 'passportNumber',
29
+ 'noticePeriod'
29
30
  ]
30
31
  export const knownOtherMetadataNames = ['contact', 'page', 'qualification']
31
32
 
@@ -57,8 +57,10 @@
57
57
  "vinNumber": "Vehicle registration number (VIN)",
58
58
  "ibanNumber": "IBAN number",
59
59
  "country": "Country of delivery",
60
- "passportNumber": "Passport number"
61
- }
60
+ "passportNumber": "Passport number",
61
+ "noticePeriod": "Time to expiration alert"
62
+ },
63
+ "day": "day |||| days"
62
64
  },
63
65
  "contact": "Owner",
64
66
  "page": "Side of the document",
@@ -57,8 +57,10 @@
57
57
  "vinNumber": "Numéro de la carte grise (VIN)",
58
58
  "ibanNumber": "Numéro d'IBAN",
59
59
  "country": "Pays de délivrance",
60
- "passportNumber": "Numéro du passeport"
61
- }
60
+ "passportNumber": "Numéro du passeport",
61
+ "noticePeriod": "Délai avant l’alerte d’expiration"
62
+ },
63
+ "day": "jour |||| jours"
62
64
  },
63
65
  "contact": "Titulaire",
64
66
  "page": "Face du document",
@@ -8,6 +8,21 @@ import Dots from "cozy-ui/transpiled/react/Icons/Dots";
8
8
  import QualificationListItemText from "cozy-ui/transpiled/react/Viewer/Panel/QualificationListItemText";
9
9
  import { useI18n } from "cozy-ui/transpiled/react/I18n";
10
10
  import MidEllipsis from "cozy-ui/transpiled/react/MidEllipsis";
11
+ export var makeInformationValue = function makeInformationValue(name, value, t) {
12
+ if (!value) {
13
+ return t('Viewer.panel.qualification.noInfo');
14
+ }
15
+
16
+ if (name === 'noticePeriod') {
17
+ return "".concat(value, " ").concat(t('Viewer.panel.qualification.information.day', {
18
+ smart_count: value
19
+ }));
20
+ }
21
+
22
+ return /*#__PURE__*/React.createElement(MidEllipsis, {
23
+ text: value
24
+ });
25
+ };
11
26
  var QualificationListItemInformation = /*#__PURE__*/forwardRef(function (_ref, ref) {
12
27
  var formatedMetadataQualification = _ref.formatedMetadataQualification,
13
28
  toggleActionsMenu = _ref.toggleActionsMenu;
@@ -17,9 +32,7 @@ var QualificationListItemInformation = /*#__PURE__*/forwardRef(function (_ref, r
17
32
 
18
33
  var name = formatedMetadataQualification.name,
19
34
  value = formatedMetadataQualification.value;
20
- var currentValue = value ? /*#__PURE__*/React.createElement(MidEllipsis, {
21
- text: value
22
- }) : t('Viewer.panel.qualification.noInfo');
35
+ var currentValue = makeInformationValue(name, value, t);
23
36
  return /*#__PURE__*/React.createElement(ListItem, {
24
37
  className: 'u-pl-2 u-pr-3'
25
38
  }, /*#__PURE__*/React.createElement(QualificationListItemText, {
@@ -8,7 +8,7 @@ var _models$file = models.file,
8
8
  hasQualifications = _models$file.hasQualifications,
9
9
  hasCertifications = _models$file.hasCertifications;
10
10
  export var knownDateMetadataNames = ['AObtentionDate', 'BObtentionDate', 'CObtentionDate', 'DObtentionDate', 'obtentionDate', 'expirationDate', 'referencedDate', 'issueDate', 'shootingDate', 'date', 'datetime'];
11
- export var knownInformationMetadataNames = ['number', 'cardNumber', 'vinNumber', 'ibanNumber', 'country', 'passportNumber'];
11
+ export var knownInformationMetadataNames = ['number', 'cardNumber', 'vinNumber', 'ibanNumber', 'country', 'passportNumber', 'noticePeriod'];
12
12
  export var knownOtherMetadataNames = ['contact', 'page', 'qualification'];
13
13
  export var getCurrentModel = function getCurrentModel(metadataName) {
14
14
  if (knownDateMetadataNames.includes(metadataName) || knownInformationMetadataNames.includes(metadataName)) {
@@ -58,8 +58,10 @@ var en = {
58
58
  vinNumber: "Vehicle registration number (VIN)",
59
59
  ibanNumber: "IBAN number",
60
60
  country: "Country of delivery",
61
- passportNumber: "Passport number"
62
- }
61
+ passportNumber: "Passport number",
62
+ noticePeriod: "Time to expiration alert"
63
+ },
64
+ day: "day |||| days"
63
65
  },
64
66
  contact: "Owner",
65
67
  page: "Side of the document",
@@ -152,8 +154,10 @@ var fr = {
152
154
  vinNumber: "Num\xE9ro de la carte grise (VIN)",
153
155
  ibanNumber: "Num\xE9ro d'IBAN",
154
156
  country: "Pays de d\xE9livrance",
155
- passportNumber: "Num\xE9ro du passeport"
156
- }
157
+ passportNumber: "Num\xE9ro du passeport",
158
+ noticePeriod: "D\xE9lai avant l\u2019alerte d\u2019expiration"
159
+ },
160
+ day: "jour |||| jours"
157
161
  },
158
162
  contact: "Titulaire",
159
163
  page: "Face du document",