cozy-ui 104.0.0 → 104.2.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 +36 -0
- package/package.json +3 -3
- package/react/ListItem/locales/en.json +4 -0
- package/react/ListItem/locales/fr.json +4 -0
- package/react/Viewer/Footer/DownloadButton.jsx +37 -8
- package/react/Viewer/Footer/FooterContent.jsx +33 -17
- package/react/Viewer/Footer/ForwardButton.jsx +32 -5
- package/react/Viewer/Footer/ForwardOrDownloadButton.jsx +2 -2
- package/react/Viewer/Footer/Sharing.jsx +26 -8
- package/react/Viewer/Footer/helpers.js +15 -0
- package/react/Viewer/NoViewer/DownloadButton.jsx +12 -13
- package/react/Viewer/Panel/Qualification.jsx +14 -24
- package/react/Viewer/Panel/QualificationListItemContact.jsx +14 -6
- package/react/Viewer/Panel/QualificationListItemDate.jsx +13 -9
- package/react/Viewer/Panel/QualificationListItemInformation.jsx +17 -46
- package/react/Viewer/Panel/QualificationListItemInformation.spec.jsx +17 -69
- package/react/Viewer/Panel/QualificationListItemOther.jsx +15 -16
- package/react/Viewer/Readme.md +18 -3
- package/react/Viewer/Viewer.jsx +2 -0
- package/react/Viewer/ViewerContainer.jsx +38 -30
- package/react/Viewer/ViewersByFile/PdfMobileViewer.spec.jsx +1 -1
- package/react/Viewer/components/PrintButton.jsx +73 -0
- package/react/Viewer/components/Toolbar.jsx +26 -19
- package/react/Viewer/components/ToolbarButtons.jsx +11 -0
- package/react/Viewer/components/ViewerByFile.jsx +40 -36
- package/react/Viewer/components/ViewerControls.jsx +17 -7
- package/react/Viewer/components/styles.styl +2 -2
- package/react/Viewer/helpers.js +6 -83
- package/react/Viewer/helpers.spec.js +10 -48
- package/react/Viewer/hoc/withViewerLocales.jsx +1 -7
- package/react/Viewer/hooks/useReferencedContactName.jsx +2 -11
- package/react/Viewer/index.jsx +6 -0
- package/react/Viewer/locales/index.js +4 -0
- package/react/providers/I18n/index.jsx +3 -1
- package/react/providers/I18n/translation.jsx +34 -2
- package/transpiled/react/ListItem/hoc/withListItemLocales.js +8 -0
- package/transpiled/react/Viewer/Footer/DownloadButton.js +39 -13
- package/transpiled/react/Viewer/Footer/FooterContent.js +35 -15
- package/transpiled/react/Viewer/Footer/ForwardButton.js +30 -6
- package/transpiled/react/Viewer/Footer/ForwardOrDownloadButton.js +8 -3
- package/transpiled/react/Viewer/Footer/Sharing.js +26 -10
- package/transpiled/react/Viewer/Footer/helpers.js +12 -0
- package/transpiled/react/Viewer/NoViewer/DownloadButton.js +7 -6
- package/transpiled/react/Viewer/Panel/Qualification.js +9 -21
- package/transpiled/react/Viewer/Panel/QualificationListItemContact.js +12 -6
- package/transpiled/react/Viewer/Panel/QualificationListItemDate.js +8 -11
- package/transpiled/react/Viewer/Panel/QualificationListItemInformation.js +17 -46
- package/transpiled/react/Viewer/Panel/QualificationListItemOther.js +11 -8
- package/transpiled/react/Viewer/Viewer.js +2 -1
- package/transpiled/react/Viewer/ViewerContainer.js +8 -4
- package/transpiled/react/Viewer/components/PrintButton.js +147 -0
- package/transpiled/react/Viewer/components/Toolbar.js +24 -15
- package/transpiled/react/Viewer/components/ToolbarButtons.js +9 -0
- package/transpiled/react/Viewer/components/ViewerByFile.js +4 -5
- package/transpiled/react/Viewer/components/ViewerControls.js +15 -9
- package/transpiled/react/Viewer/helpers.js +12 -63
- package/transpiled/react/Viewer/hoc/withViewerLocales.js +1 -300
- package/transpiled/react/Viewer/hooks/useReferencedContactName.js +2 -6
- package/transpiled/react/Viewer/index.js +4 -0
- package/transpiled/react/Viewer/locales/index.js +300 -0
- package/transpiled/react/providers/I18n/index.js +3 -1
- package/transpiled/react/providers/I18n/translation.js +36 -3
- package/transpiled/react/stylesheet.css +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
|
+
# [104.2.0](https://github.com/cozy/cozy-ui/compare/v104.1.0...v104.2.0) (2024-03-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **Viewer:** Adjust toolbar spacing and button size ([6a2f8fe](https://github.com/cozy/cozy-ui/commit/6a2f8fe))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **I18n:** Add useExtendI18n to be able to add locales to existing ones ([ad388b4](https://github.com/cozy/cozy-ui/commit/ad388b4))
|
|
12
|
+
* **I18n:** Expose polyglot, so can be get with useI18n ([7770e7b](https://github.com/cozy/cozy-ui/commit/7770e7b))
|
|
13
|
+
* Update cozy-client to 45.15.0 ([c5f2649](https://github.com/cozy/cozy-ui/commit/c5f2649))
|
|
14
|
+
* **Viewer:** Add Print button, based on print action definition ([ba80052](https://github.com/cozy/cozy-ui/commit/ba80052))
|
|
15
|
+
* **Viewer:** Add ToolbarButtons component ([e0b014c](https://github.com/cozy/cozy-ui/commit/e0b014c))
|
|
16
|
+
* **Viewer:** Add variants on Download/Forward/Sharing buttons ([594b79a](https://github.com/cozy/cozy-ui/commit/594b79a))
|
|
17
|
+
* **Viewer:** Add WebviewIntentProvider ([97f28ff](https://github.com/cozy/cozy-ui/commit/97f28ff))
|
|
18
|
+
* **Viewer:** Expose Toolbarbutton, FooterActionsButtons and ForwardButton ([2b9130f](https://github.com/cozy/cozy-ui/commit/2b9130f))
|
|
19
|
+
* **Viewer:** Modify default buttons on toolbar and footer ([d82013d](https://github.com/cozy/cozy-ui/commit/d82013d))
|
|
20
|
+
* **Viewer:** Remove HOC for locals on no viewer DownloadButton ([edda4a9](https://github.com/cozy/cozy-ui/commit/edda4a9))
|
|
21
|
+
* **Viewer:** Replace toolbar download button by icon button ([6f59eda](https://github.com/cozy/cozy-ui/commit/6f59eda))
|
|
22
|
+
* **Viewer:** Use contact formatting from cozy-client ([eb9c596](https://github.com/cozy/cozy-ui/commit/eb9c596))
|
|
23
|
+
* **Viewer:** Use date metadata qualification formatting from cozy-client ([14bc95d](https://github.com/cozy/cozy-ui/commit/14bc95d))
|
|
24
|
+
* **Viewer:** Use formatMetadataQualification and METADATA_NAMES from ([450fb74](https://github.com/cozy/cozy-ui/commit/450fb74))
|
|
25
|
+
* **Viewer:** Use getMetadataQualificationType from cozy-client ([ae133f4](https://github.com/cozy/cozy-ui/commit/ae133f4))
|
|
26
|
+
* **Viewer:** Use information metadata qualification formatting from cozy-client ([1d106ef](https://github.com/cozy/cozy-ui/commit/1d106ef))
|
|
27
|
+
* **Viewer:** Use other metadata qualification formatting from cozy-client ([98b6510](https://github.com/cozy/cozy-ui/commit/98b6510))
|
|
28
|
+
* **Viewer:** Use useExtendI18n ([d93b97d](https://github.com/cozy/cozy-ui/commit/d93b97d))
|
|
29
|
+
|
|
30
|
+
# [104.1.0](https://github.com/cozy/cozy-ui/compare/v104.0.0...v104.1.0) (2024-03-12)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Features
|
|
34
|
+
|
|
35
|
+
* **ListItem:** Add locales for reference tax numbers ([a7d66d2](https://github.com/cozy/cozy-ui/commit/a7d66d2))
|
|
36
|
+
|
|
1
37
|
# [104.0.0](https://github.com/cozy/cozy-ui/compare/v103.12.0...v104.0.0) (2024-03-12)
|
|
2
38
|
|
|
3
39
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-ui",
|
|
3
|
-
"version": "104.
|
|
3
|
+
"version": "104.2.0",
|
|
4
4
|
"description": "Cozy apps UI SDK",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"bin": {
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"babel-preset-cozy-app": "2.0.2",
|
|
92
92
|
"browserslist-config-cozy": "0.4.0",
|
|
93
93
|
"copyfiles": "2.4.1",
|
|
94
|
-
"cozy-client": "^45.
|
|
94
|
+
"cozy-client": "^45.15.0",
|
|
95
95
|
"cozy-device-helper": "2.0.0",
|
|
96
96
|
"cozy-flags": "^2.10.1",
|
|
97
97
|
"cozy-harvest-lib": "^6.7.3",
|
|
@@ -182,7 +182,7 @@
|
|
|
182
182
|
"rooks": "^5.11.2"
|
|
183
183
|
},
|
|
184
184
|
"peerDependencies": {
|
|
185
|
-
"cozy-client": ">=45.
|
|
185
|
+
"cozy-client": ">=45.15.0",
|
|
186
186
|
"cozy-device-helper": "^2.0.0",
|
|
187
187
|
"cozy-harvest-lib": "^6.7.3",
|
|
188
188
|
"cozy-intent": ">=1.3.0",
|
|
@@ -32,6 +32,10 @@
|
|
|
32
32
|
"netSocialAmount": "Net social amount",
|
|
33
33
|
"number": {
|
|
34
34
|
"pay_sheet": "Gross remuneration",
|
|
35
|
+
"tax_return": "Reference tax number",
|
|
36
|
+
"tax_notice": "Reference tax number",
|
|
37
|
+
"real_estate_tax": "Reference tax number",
|
|
38
|
+
"tax_timetable": "Reference tax number",
|
|
35
39
|
"fine": "Amount of the fine",
|
|
36
40
|
"fidelity_card": "Card number",
|
|
37
41
|
"driver_license": "License number",
|
|
@@ -32,6 +32,10 @@
|
|
|
32
32
|
"netSocialAmount": "Montant net social",
|
|
33
33
|
"number": {
|
|
34
34
|
"pay_sheet": "Rémunération brute",
|
|
35
|
+
"tax_return": "Numéro fiscal de référence",
|
|
36
|
+
"tax_notice": "Numéro fiscal de référence",
|
|
37
|
+
"real_estate_tax": "Numéro fiscal de référence",
|
|
38
|
+
"tax_timetable": "Numéro fiscal de référence",
|
|
35
39
|
"fine": "Montant de l'amende",
|
|
36
40
|
"fidelity_card": "Numéro de la carte",
|
|
37
41
|
"driver_license": "Numéro du permis",
|
|
@@ -3,16 +3,21 @@ import PropTypes from 'prop-types'
|
|
|
3
3
|
|
|
4
4
|
import { useClient } from 'cozy-client'
|
|
5
5
|
|
|
6
|
+
import { useI18n } from '../../providers/I18n'
|
|
6
7
|
import Icon from '../../Icon'
|
|
8
|
+
import IconButton from '../../IconButton'
|
|
7
9
|
import DownloadIcon from '../../Icons/Download'
|
|
8
10
|
import Button from '../../Buttons'
|
|
9
11
|
import Alerter from '../../deprecated/Alerter'
|
|
10
|
-
import { withViewerLocales } from '../hoc/withViewerLocales'
|
|
11
12
|
|
|
12
|
-
const DownloadButton = ({ file,
|
|
13
|
+
const DownloadButton = ({ file, variant }) => {
|
|
13
14
|
const client = useClient()
|
|
15
|
+
const { t } = useI18n()
|
|
14
16
|
|
|
15
|
-
const
|
|
17
|
+
const icon = <Icon icon={DownloadIcon} />
|
|
18
|
+
const label = t('Viewer.download')
|
|
19
|
+
|
|
20
|
+
const handleClick = async () => {
|
|
16
21
|
try {
|
|
17
22
|
await client.collection('io.cozy.files').download(file)
|
|
18
23
|
} catch (error) {
|
|
@@ -20,19 +25,43 @@ const DownloadButton = ({ file, t }) => {
|
|
|
20
25
|
}
|
|
21
26
|
}
|
|
22
27
|
|
|
28
|
+
if (variant === 'iconButton') {
|
|
29
|
+
return (
|
|
30
|
+
<IconButton className="u-white" aria-label={label} onClick={handleClick}>
|
|
31
|
+
{icon}
|
|
32
|
+
</IconButton>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (variant === 'buttonIcon') {
|
|
37
|
+
return (
|
|
38
|
+
<Button
|
|
39
|
+
variant="secondary"
|
|
40
|
+
label={icon}
|
|
41
|
+
aria-label={label}
|
|
42
|
+
onClick={handleClick}
|
|
43
|
+
/>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
23
47
|
return (
|
|
24
48
|
<Button
|
|
25
49
|
fullWidth
|
|
26
50
|
variant="secondary"
|
|
27
|
-
startIcon={
|
|
28
|
-
label={
|
|
29
|
-
onClick={
|
|
51
|
+
startIcon={icon}
|
|
52
|
+
label={label}
|
|
53
|
+
onClick={handleClick}
|
|
30
54
|
/>
|
|
31
55
|
)
|
|
32
56
|
}
|
|
33
57
|
|
|
34
58
|
DownloadButton.propTypes = {
|
|
35
|
-
file: PropTypes.object
|
|
59
|
+
file: PropTypes.object,
|
|
60
|
+
variant: PropTypes.oneOf(['default', 'iconButton', 'buttonIcon'])
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
DownloadButton.defaultProptypes = {
|
|
64
|
+
variant: 'default'
|
|
36
65
|
}
|
|
37
66
|
|
|
38
|
-
export default
|
|
67
|
+
export default DownloadButton
|
|
@@ -1,12 +1,26 @@
|
|
|
1
|
-
import React, { useMemo
|
|
1
|
+
import React, { useMemo } from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import cx from 'classnames'
|
|
4
4
|
|
|
5
5
|
import BottomSheet, { BottomSheetHeader } from '../../BottomSheet'
|
|
6
6
|
import { makeStyles } from '../../styles'
|
|
7
7
|
import { isValidForPanel } from '../helpers'
|
|
8
|
+
import PrintButton from '../components/PrintButton'
|
|
9
|
+
import { extractChildrenCompByName } from './helpers'
|
|
8
10
|
import BottomSheetContent from './BottomSheetContent'
|
|
9
11
|
|
|
12
|
+
const FooterButtons = ({
|
|
13
|
+
file,
|
|
14
|
+
FooterActionButtonsWithFile = { FooterActionButtonsWithFile }
|
|
15
|
+
}) => {
|
|
16
|
+
return (
|
|
17
|
+
<>
|
|
18
|
+
{FooterActionButtonsWithFile}
|
|
19
|
+
<PrintButton file={file} variant="button" />
|
|
20
|
+
</>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
10
24
|
const useStyles = makeStyles(theme => ({
|
|
11
25
|
footer: {
|
|
12
26
|
display: 'flex',
|
|
@@ -28,19 +42,11 @@ const FooterContent = ({ file, toolbarRef, children, isPublic }) => {
|
|
|
28
42
|
|
|
29
43
|
const toolbarProps = useMemo(() => ({ ref: toolbarRef }), [toolbarRef])
|
|
30
44
|
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
)
|
|
37
|
-
}) || null
|
|
38
|
-
|
|
39
|
-
const FooterActionButtonsWithFile = isValidElement(FooterActionButtons)
|
|
40
|
-
? cloneElement(FooterActionButtons, {
|
|
41
|
-
file
|
|
42
|
-
})
|
|
43
|
-
: null
|
|
45
|
+
const FooterActionButtonsWithFile = extractChildrenCompByName({
|
|
46
|
+
children,
|
|
47
|
+
file,
|
|
48
|
+
name: 'FooterActionButtons'
|
|
49
|
+
})
|
|
44
50
|
|
|
45
51
|
if (isValidForPanel({ file })) {
|
|
46
52
|
return (
|
|
@@ -52,7 +58,10 @@ const FooterContent = ({ file, toolbarRef, children, isPublic }) => {
|
|
|
52
58
|
<BottomSheetHeader
|
|
53
59
|
className={cx('u-ph-1 u-pb-1', styles.bottomSheetHeader)}
|
|
54
60
|
>
|
|
55
|
-
|
|
61
|
+
<FooterButtons
|
|
62
|
+
file={file}
|
|
63
|
+
FooterActionButtonsWithFile={FooterActionButtonsWithFile}
|
|
64
|
+
/>
|
|
56
65
|
</BottomSheetHeader>
|
|
57
66
|
<BottomSheetContent file={file} isPublic={isPublic} />
|
|
58
67
|
</BottomSheet>
|
|
@@ -60,9 +69,16 @@ const FooterContent = ({ file, toolbarRef, children, isPublic }) => {
|
|
|
60
69
|
}
|
|
61
70
|
|
|
62
71
|
// If `FooterActionButtons` hasn't children
|
|
63
|
-
if (!
|
|
72
|
+
if (!FooterActionButtonsWithFile) return null
|
|
64
73
|
|
|
65
|
-
return
|
|
74
|
+
return (
|
|
75
|
+
<div className={styles.footer}>
|
|
76
|
+
<FooterButtons
|
|
77
|
+
file={file}
|
|
78
|
+
FooterActionButtonsWithFile={FooterActionButtonsWithFile}
|
|
79
|
+
/>
|
|
80
|
+
</div>
|
|
81
|
+
)
|
|
66
82
|
}
|
|
67
83
|
|
|
68
84
|
FooterContent.propTypes = {
|
|
@@ -6,20 +6,23 @@ import { isIOS, isMobileApp } from 'cozy-device-helper'
|
|
|
6
6
|
|
|
7
7
|
import { useI18n } from '../../providers/I18n'
|
|
8
8
|
import Icon from '../../Icon'
|
|
9
|
+
import IconButton from '../../IconButton'
|
|
9
10
|
import ReplyIcon from '../../Icons/Reply'
|
|
10
11
|
import ShareIosIcon from '../../Icons/ShareIos'
|
|
11
12
|
import Button from '../../Buttons'
|
|
12
13
|
import Alerter from '../../deprecated/Alerter'
|
|
13
|
-
import { withViewerLocales } from '../hoc/withViewerLocales'
|
|
14
14
|
import { exportFilesNative } from './helpers'
|
|
15
15
|
import { getSharingLink } from 'cozy-client/dist/models/sharing'
|
|
16
16
|
|
|
17
17
|
const ForwardIcon = isIOS() ? ShareIosIcon : ReplyIcon
|
|
18
18
|
|
|
19
|
-
const ForwardButton = ({ file, onClick }) => {
|
|
19
|
+
const ForwardButton = ({ file, variant, onClick }) => {
|
|
20
20
|
const { t } = useI18n()
|
|
21
21
|
const client = useClient()
|
|
22
22
|
|
|
23
|
+
const icon = <Icon icon={ForwardIcon} />
|
|
24
|
+
const label = t('Viewer.actions.forward')
|
|
25
|
+
|
|
23
26
|
const onFileOpen = async file => {
|
|
24
27
|
if (isMobileApp()) {
|
|
25
28
|
try {
|
|
@@ -47,13 +50,32 @@ const ForwardButton = ({ file, onClick }) => {
|
|
|
47
50
|
else onFileOpen(file)
|
|
48
51
|
}
|
|
49
52
|
|
|
53
|
+
if (variant === 'iconButton') {
|
|
54
|
+
return (
|
|
55
|
+
<IconButton className="u-white" aria-label={label} onClick={handleClick}>
|
|
56
|
+
{icon}
|
|
57
|
+
</IconButton>
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (variant === 'buttonIcon') {
|
|
62
|
+
return (
|
|
63
|
+
<Button
|
|
64
|
+
variant="secondary"
|
|
65
|
+
label={icon}
|
|
66
|
+
aria-label={label}
|
|
67
|
+
onClick={handleClick}
|
|
68
|
+
/>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
50
72
|
return (
|
|
51
73
|
<Button
|
|
52
74
|
fullWidth
|
|
53
75
|
variant="secondary"
|
|
54
|
-
startIcon={
|
|
76
|
+
startIcon={icon}
|
|
55
77
|
data-testid="openFileButton"
|
|
56
|
-
label={
|
|
78
|
+
label={label}
|
|
57
79
|
onClick={handleClick}
|
|
58
80
|
/>
|
|
59
81
|
)
|
|
@@ -61,8 +83,13 @@ const ForwardButton = ({ file, onClick }) => {
|
|
|
61
83
|
|
|
62
84
|
ForwardButton.propTypes = {
|
|
63
85
|
file: PropTypes.object.isRequired,
|
|
86
|
+
variant: PropTypes.oneOf(['default', 'iconButton', 'buttonIcon']),
|
|
64
87
|
onClick: PropTypes.func
|
|
65
88
|
}
|
|
66
89
|
|
|
90
|
+
ForwardButton.defaultProptypes = {
|
|
91
|
+
variant: 'default'
|
|
92
|
+
}
|
|
93
|
+
|
|
67
94
|
export { exportFilesNative }
|
|
68
|
-
export default
|
|
95
|
+
export default ForwardButton
|
|
@@ -7,14 +7,14 @@ import ForwardButton from './ForwardButton'
|
|
|
7
7
|
import DownloadButton from './DownloadButton'
|
|
8
8
|
import { shouldBeForwardButton } from './helpers'
|
|
9
9
|
|
|
10
|
-
const ForwardOrDownloadButton = ({ file }) => {
|
|
10
|
+
const ForwardOrDownloadButton = ({ file, ...props }) => {
|
|
11
11
|
const client = useClient()
|
|
12
12
|
|
|
13
13
|
const FileActionButton = shouldBeForwardButton(client)
|
|
14
14
|
? ForwardButton
|
|
15
15
|
: DownloadButton
|
|
16
16
|
|
|
17
|
-
return <FileActionButton file={file} />
|
|
17
|
+
return <FileActionButton file={file} {...props} />
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
ForwardOrDownloadButton.propTypes = {
|
|
@@ -5,10 +5,28 @@ import { useClient } from 'cozy-client'
|
|
|
5
5
|
import { ShareModal, ShareButton } from 'cozy-sharing'
|
|
6
6
|
import { SharingProvider } from 'cozy-sharing/dist/SharingProvider'
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
import IconButton from '../../IconButton'
|
|
9
|
+
import Icon from '../../Icon'
|
|
10
|
+
import ShareIcon from '../../Icons/Share'
|
|
11
|
+
|
|
12
|
+
const Sharing = ({ file, variant }) => {
|
|
9
13
|
const client = useClient()
|
|
10
14
|
const [showShareModal, setShowShareModal] = useState(false)
|
|
11
15
|
|
|
16
|
+
const SharingButton =
|
|
17
|
+
variant === 'iconButton' ? (
|
|
18
|
+
<IconButton className="u-white" onClick={() => setShowShareModal(true)}>
|
|
19
|
+
<Icon icon={ShareIcon} />
|
|
20
|
+
</IconButton>
|
|
21
|
+
) : (
|
|
22
|
+
<ShareButton
|
|
23
|
+
extension="full"
|
|
24
|
+
useShortLabel
|
|
25
|
+
docId={file.id}
|
|
26
|
+
onClick={() => setShowShareModal(true)}
|
|
27
|
+
/>
|
|
28
|
+
)
|
|
29
|
+
|
|
12
30
|
return (
|
|
13
31
|
<>
|
|
14
32
|
<SharingProvider
|
|
@@ -24,19 +42,19 @@ const Sharing = ({ file }) => {
|
|
|
24
42
|
onClose={() => setShowShareModal(false)}
|
|
25
43
|
/>
|
|
26
44
|
)}
|
|
27
|
-
|
|
28
|
-
extension="full"
|
|
29
|
-
useShortLabel
|
|
30
|
-
docId={file.id}
|
|
31
|
-
onClick={() => setShowShareModal(true)}
|
|
32
|
-
/>
|
|
45
|
+
{SharingButton}
|
|
33
46
|
</SharingProvider>
|
|
34
47
|
</>
|
|
35
48
|
)
|
|
36
49
|
}
|
|
37
50
|
|
|
38
51
|
Sharing.propTypes = {
|
|
39
|
-
file: PropTypes.object
|
|
52
|
+
file: PropTypes.object,
|
|
53
|
+
variant: PropTypes.oneOf(['default', 'iconButton'])
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
Sharing.defaultProptypes = {
|
|
57
|
+
variant: 'default'
|
|
40
58
|
}
|
|
41
59
|
|
|
42
60
|
export default Sharing
|
|
@@ -89,3 +89,18 @@ export const mapToAllChildren = (children, cb) => {
|
|
|
89
89
|
return cb(child)
|
|
90
90
|
})
|
|
91
91
|
}
|
|
92
|
+
|
|
93
|
+
export const extractChildrenCompByName = ({ children, file, name }) => {
|
|
94
|
+
const ChildrenComp =
|
|
95
|
+
Children.toArray(children).find(child => {
|
|
96
|
+
return child.type.name === name || child.type.displayName === name
|
|
97
|
+
}) || null
|
|
98
|
+
|
|
99
|
+
const ChildrenCompWithFile = isValidElement(ChildrenComp)
|
|
100
|
+
? cloneElement(ChildrenComp, {
|
|
101
|
+
file
|
|
102
|
+
})
|
|
103
|
+
: null
|
|
104
|
+
|
|
105
|
+
return ChildrenCompWithFile
|
|
106
|
+
}
|
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
|
-
import flow from 'lodash/flow'
|
|
4
3
|
|
|
5
4
|
import { withClient } from 'cozy-client'
|
|
6
5
|
|
|
6
|
+
import { useI18n } from '../../providers/I18n'
|
|
7
7
|
import { FileDoctype } from '../../proptypes'
|
|
8
8
|
import Button from '../../deprecated/Button'
|
|
9
9
|
|
|
10
|
-
import { withViewerLocales } from '../hoc/withViewerLocales'
|
|
11
10
|
import { downloadFile } from '../helpers'
|
|
12
11
|
|
|
13
|
-
const DownloadButton = ({
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
)
|
|
12
|
+
const DownloadButton = ({ client, file, url }) => {
|
|
13
|
+
const { t } = useI18n()
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Button
|
|
17
|
+
onClick={() => downloadFile({ client, file, url })}
|
|
18
|
+
label={t('Viewer.download')}
|
|
19
|
+
/>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
19
22
|
|
|
20
23
|
DownloadButton.propTypes = {
|
|
21
|
-
t: PropTypes.func.isRequired,
|
|
22
24
|
client: PropTypes.object.isRequired,
|
|
23
25
|
file: FileDoctype,
|
|
24
26
|
url: PropTypes.string
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
export default
|
|
28
|
-
withClient,
|
|
29
|
-
withViewerLocales
|
|
30
|
-
)(DownloadButton)
|
|
29
|
+
export default withClient(DownloadButton)
|
|
@@ -1,38 +1,26 @@
|
|
|
1
1
|
import React, { useRef, useState, createRef, useMemo, useEffect } from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
isExpiringSoon,
|
|
6
|
+
formatMetadataQualification,
|
|
7
|
+
getMetadataQualificationType
|
|
8
|
+
} from 'cozy-client/dist/models/paper'
|
|
5
9
|
|
|
6
10
|
import List from '../../List'
|
|
7
11
|
import { withViewerLocales } from '../hoc/withViewerLocales'
|
|
8
|
-
import {
|
|
9
|
-
formatMetadataQualification,
|
|
10
|
-
knownDateMetadataNames,
|
|
11
|
-
knownInformationMetadataNames,
|
|
12
|
-
knownOtherMetadataNames
|
|
13
|
-
} from '../helpers'
|
|
14
12
|
import ExpirationAlert from '../components/ExpirationAlert'
|
|
15
|
-
import QualificationListItemContact from './QualificationListItemContact'
|
|
16
13
|
import ActionMenuWrapper from './ActionMenuWrapper'
|
|
14
|
+
import QualificationListItemContact from './QualificationListItemContact'
|
|
17
15
|
import QualificationListItemDate from './QualificationListItemDate'
|
|
18
16
|
import QualificationListItemInformation from './QualificationListItemInformation'
|
|
19
17
|
import QualificationListItemOther from './QualificationListItemOther'
|
|
20
18
|
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (knownInformationMetadataNames.includes(metadataName)) {
|
|
27
|
-
return QualificationListItemInformation
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (knownOtherMetadataNames.includes(metadataName)) {
|
|
31
|
-
if (metadataName === 'contact') {
|
|
32
|
-
return QualificationListItemContact
|
|
33
|
-
}
|
|
34
|
-
return QualificationListItemOther
|
|
35
|
-
}
|
|
19
|
+
const ComponentFromMetadataQualificationType = {
|
|
20
|
+
contact: QualificationListItemContact,
|
|
21
|
+
date: QualificationListItemDate,
|
|
22
|
+
information: QualificationListItemInformation,
|
|
23
|
+
other: QualificationListItemOther
|
|
36
24
|
}
|
|
37
25
|
|
|
38
26
|
const isExpirationAlertHidden = file => {
|
|
@@ -77,7 +65,9 @@ const Qualification = ({ file }) => {
|
|
|
77
65
|
<List className={'u-pv-1'}>
|
|
78
66
|
{formatedMetadataQualification.map((meta, idx) => {
|
|
79
67
|
const { name } = meta
|
|
80
|
-
const
|
|
68
|
+
const metadataQualificationType = getMetadataQualificationType(name)
|
|
69
|
+
const QualificationListItemComp =
|
|
70
|
+
ComponentFromMetadataQualificationType[metadataQualificationType]
|
|
81
71
|
|
|
82
72
|
return (
|
|
83
73
|
<QualificationListItemComp
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import React, { useRef, useState } from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
|
|
4
|
+
import {
|
|
5
|
+
getTranslatedNameForContact,
|
|
6
|
+
formatContactValue
|
|
7
|
+
} from 'cozy-client/dist/models/paper'
|
|
8
|
+
|
|
4
9
|
import ListItem from '../../ListItem'
|
|
5
10
|
import ListItemSecondaryAction from '../../ListItemSecondaryAction'
|
|
6
11
|
import IconButton from '../../IconButton'
|
|
@@ -13,7 +18,7 @@ import { useI18n } from '../../providers/I18n'
|
|
|
13
18
|
import ActionMenuWrapper from './ActionMenuWrapper'
|
|
14
19
|
|
|
15
20
|
const QualificationListItemContact = ({ file }) => {
|
|
16
|
-
const {
|
|
21
|
+
const { lang } = useI18n()
|
|
17
22
|
const actionBtnRef = useRef()
|
|
18
23
|
const [optionFile, setOptionFile] = useState({
|
|
19
24
|
name: '',
|
|
@@ -27,7 +32,7 @@ const QualificationListItemContact = ({ file }) => {
|
|
|
27
32
|
return { name, value }
|
|
28
33
|
})
|
|
29
34
|
|
|
30
|
-
const {
|
|
35
|
+
const { contacts, isLoadingContacts } = useReferencedContactName(file)
|
|
31
36
|
|
|
32
37
|
if (isLoadingContacts) {
|
|
33
38
|
return (
|
|
@@ -37,7 +42,10 @@ const QualificationListItemContact = ({ file }) => {
|
|
|
37
42
|
)
|
|
38
43
|
}
|
|
39
44
|
|
|
40
|
-
|
|
45
|
+
const formattedTitle = getTranslatedNameForContact({ lang })
|
|
46
|
+
const formattedValue = formatContactValue(contacts)
|
|
47
|
+
|
|
48
|
+
if (!isLoadingContacts && !formattedValue) {
|
|
41
49
|
return null
|
|
42
50
|
}
|
|
43
51
|
|
|
@@ -45,13 +53,13 @@ const QualificationListItemContact = ({ file }) => {
|
|
|
45
53
|
<>
|
|
46
54
|
<ListItem className={'u-ph-2'}>
|
|
47
55
|
<QualificationListItemText
|
|
48
|
-
primary={
|
|
49
|
-
secondary={
|
|
56
|
+
primary={formattedTitle}
|
|
57
|
+
secondary={formattedValue}
|
|
50
58
|
/>
|
|
51
59
|
<ListItemSecondaryAction>
|
|
52
60
|
<IconButton
|
|
53
61
|
ref={actionBtnRef}
|
|
54
|
-
onClick={() => toggleActionsMenu('contact',
|
|
62
|
+
onClick={() => toggleActionsMenu('contact', formattedValue)}
|
|
55
63
|
>
|
|
56
64
|
<Icon icon={Dots} />
|
|
57
65
|
</IconButton>
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
isExpired,
|
|
6
|
+
isExpiringSoon,
|
|
7
|
+
getTranslatedNameForDateMetadata,
|
|
8
|
+
formatDateMetadataValue
|
|
9
|
+
} from 'cozy-client/dist/models/paper'
|
|
5
10
|
|
|
6
11
|
import ListItem from '../../ListItem'
|
|
7
12
|
import ListItemSecondaryAction from '../../ListItemSecondaryAction'
|
|
@@ -12,23 +17,22 @@ import Typography from '../../Typography'
|
|
|
12
17
|
import ExpirationAnnotation from '../components/ExpirationAnnotation'
|
|
13
18
|
import QualificationListItemText from './QualificationListItemText'
|
|
14
19
|
import { useI18n } from '../../providers/I18n'
|
|
15
|
-
import { formatDate } from '../helpers'
|
|
16
|
-
|
|
17
|
-
const { isExpired, isExpiringSoon } = models.paper
|
|
18
20
|
|
|
19
21
|
const QualificationListItemDate = forwardRef(
|
|
20
22
|
({ file, formatedMetadataQualification, toggleActionsMenu }, ref) => {
|
|
21
|
-
const {
|
|
23
|
+
const { f, lang } = useI18n()
|
|
22
24
|
const { name, value } = formatedMetadataQualification
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
const formattedTitle = getTranslatedNameForDateMetadata(name, { lang })
|
|
26
|
+
const formattedDate = formatDateMetadataValue(value, {
|
|
27
|
+
f,
|
|
28
|
+
lang
|
|
29
|
+
})
|
|
26
30
|
const isExpirationDate = name === 'expirationDate'
|
|
27
31
|
|
|
28
32
|
return (
|
|
29
33
|
<ListItem className={'u-pl-2 u-pr-3'}>
|
|
30
34
|
<QualificationListItemText
|
|
31
|
-
primary={
|
|
35
|
+
primary={formattedTitle}
|
|
32
36
|
secondary={
|
|
33
37
|
<>
|
|
34
38
|
<Typography component="span" variant="inherit">
|