cozy-ui 111.21.0 → 112.1.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 +21 -0
- package/package.json +4 -3
- package/react/FileImageLoader/Readme.md +66 -3
- package/react/FileImageLoader/index.jsx +3 -3
- package/react/FileImageLoader/index.spec.jsx +1 -1
- package/react/hooks/useClientErrors.jsx +140 -0
- package/react/hooks/useClientErrors.spec.jsx +102 -0
- package/react/index.js +0 -1
- package/transpiled/react/FileImageLoader/index.js +3 -3
- package/transpiled/react/hooks/useClientErrors.js +167 -0
- package/transpiled/react/index.js +0 -1
- package/transpiled/react/stylesheet.css +1 -1
- package/react/Viewer/Footer/BottomSheetContent.jsx +0 -29
- package/react/Viewer/Footer/DownloadButton.jsx +0 -67
- package/react/Viewer/Footer/FooterActionButtons.jsx +0 -22
- package/react/Viewer/Footer/FooterActionButtons.spec.jsx +0 -30
- package/react/Viewer/Footer/FooterContent.jsx +0 -99
- package/react/Viewer/Footer/ForwardButton.jsx +0 -95
- package/react/Viewer/Footer/ForwardButton.spec.jsx +0 -87
- package/react/Viewer/Footer/ForwardOrDownloadButton.jsx +0 -24
- package/react/Viewer/Footer/Sharing.jsx +0 -60
- package/react/Viewer/Footer/helpers.js +0 -107
- package/react/Viewer/Footer/helpers.spec.js +0 -77
- package/react/Viewer/NoViewer/DownloadButton.jsx +0 -28
- package/react/Viewer/NoViewer/FileIcon.jsx +0 -46
- package/react/Viewer/NoViewer/NoViewer.jsx +0 -29
- package/react/Viewer/NoViewer/NoViewer.spec.jsx +0 -44
- package/react/Viewer/NoViewer/__snapshots__/NoViewer.spec.jsx.snap +0 -82
- package/react/Viewer/NoViewer/index.jsx +0 -1
- package/react/Viewer/Panel/ActionMenuDesktop.jsx +0 -66
- package/react/Viewer/Panel/ActionMenuMobile.jsx +0 -74
- package/react/Viewer/Panel/ActionMenuWrapper.jsx +0 -104
- package/react/Viewer/Panel/Certifications.jsx +0 -62
- package/react/Viewer/Panel/PanelContent.jsx +0 -49
- package/react/Viewer/Panel/Qualification.jsx +0 -114
- package/react/Viewer/Panel/QualificationListItemContact.jsx +0 -85
- package/react/Viewer/Panel/QualificationListItemDate.jsx +0 -77
- package/react/Viewer/Panel/QualificationListItemInformation.jsx +0 -68
- package/react/Viewer/Panel/QualificationListItemInformation.spec.jsx +0 -73
- package/react/Viewer/Panel/QualificationListItemOther.jsx +0 -61
- package/react/Viewer/Panel/QualificationListItemText.jsx +0 -30
- package/react/Viewer/Panel/getPanelBlocks.jsx +0 -56
- package/react/Viewer/Panel/getPanelBlocks.spec.jsx +0 -79
- package/react/Viewer/Panel/styles.styl +0 -13
- package/react/Viewer/Readme.md +0 -352
- package/react/Viewer/Viewer.jsx +0 -134
- package/react/Viewer/ViewerContainer.jsx +0 -169
- package/react/Viewer/ViewerExposer.js +0 -3
- package/react/Viewer/ViewerInformationsWrapper.jsx +0 -69
- package/react/Viewer/ViewerInformationsWrapper.spec.jsx +0 -63
- package/react/Viewer/ViewerWithCustomPanelAndFooter.jsx +0 -55
- package/react/Viewer/ViewersByFile/AudioViewer.jsx +0 -21
- package/react/Viewer/ViewersByFile/AudioViewer.spec.jsx +0 -39
- package/react/Viewer/ViewersByFile/BlankPaperViewer.jsx +0 -46
- package/react/Viewer/ViewersByFile/ImageViewer.jsx +0 -330
- package/react/Viewer/ViewersByFile/ImageViewer.spec.jsx +0 -70
- package/react/Viewer/ViewersByFile/NoNetworkViewer.jsx +0 -17
- package/react/Viewer/ViewersByFile/OnlyOfficeViewer.jsx +0 -28
- package/react/Viewer/ViewersByFile/PdfJsViewer.jsx +0 -210
- package/react/Viewer/ViewersByFile/PdfJsViewer.spec.jsx +0 -160
- package/react/Viewer/ViewersByFile/PdfMobileViewer.jsx +0 -106
- package/react/Viewer/ViewersByFile/PdfMobileViewer.spec.jsx +0 -76
- package/react/Viewer/ViewersByFile/ShortcutViewer.jsx +0 -38
- package/react/Viewer/ViewersByFile/ShortcutViewer.spec.jsx +0 -32
- package/react/Viewer/ViewersByFile/TextViewer.jsx +0 -126
- package/react/Viewer/ViewersByFile/TextViewer.spec.jsx +0 -118
- package/react/Viewer/ViewersByFile/VideoViewer.jsx +0 -13
- package/react/Viewer/ViewersByFile/VideoViewer.spec.jsx +0 -39
- package/react/Viewer/ViewersByFile/__snapshots__/AudioViewer.spec.jsx.snap +0 -43
- package/react/Viewer/ViewersByFile/__snapshots__/ShortcutViewer.spec.jsx.snap +0 -57
- package/react/Viewer/ViewersByFile/__snapshots__/TextViewer.spec.jsx.snap +0 -100
- package/react/Viewer/ViewersByFile/__snapshots__/VideoViewer.spec.jsx.snap +0 -19
- package/react/Viewer/ViewersByFile/styles.styl +0 -87
- package/react/Viewer/assets/IlluGenericNewPage.svg +0 -10
- package/react/Viewer/components/ExpirationAlert.jsx +0 -86
- package/react/Viewer/components/ExpirationAnnotation.jsx +0 -40
- package/react/Viewer/components/Footer.jsx +0 -13
- package/react/Viewer/components/InformationPanel.jsx +0 -26
- package/react/Viewer/components/Navigation.jsx +0 -39
- package/react/Viewer/components/PdfToolbarButton.jsx +0 -26
- package/react/Viewer/components/PrintButton.jsx +0 -90
- package/react/Viewer/components/Toolbar.jsx +0 -111
- package/react/Viewer/components/ToolbarButtons.jsx +0 -11
- package/react/Viewer/components/ToolbarFilePath.jsx +0 -61
- package/react/Viewer/components/ViewerByFile.jsx +0 -112
- package/react/Viewer/components/ViewerByFile.spec.jsx +0 -100
- package/react/Viewer/components/ViewerControls.jsx +0 -190
- package/react/Viewer/components/ViewerControls.spec.jsx +0 -54
- package/react/Viewer/components/ViewerSpinner.jsx +0 -17
- package/react/Viewer/components/styles.styl +0 -93
- package/react/Viewer/helpers.js +0 -131
- package/react/Viewer/helpers.spec.js +0 -136
- package/react/Viewer/hoc/withFileUrl.jsx +0 -93
- package/react/Viewer/hoc/withViewerLocales.jsx +0 -4
- package/react/Viewer/hooks/useReferencedContactName.jsx +0 -26
- package/react/Viewer/index.jsx +0 -12
- package/react/Viewer/locales/en.json +0 -66
- package/react/Viewer/locales/fr.json +0 -66
- package/react/Viewer/locales/index.js +0 -4
- package/react/Viewer/proptypes.js +0 -12
- package/react/Viewer/providers/ActionMenuProvider.jsx +0 -35
- package/react/Viewer/queries.js +0 -20
- package/react/Viewer/styles.styl +0 -22
- package/react/Viewer/vars.styl +0 -6
- package/transpiled/react/Viewer/Footer/BottomSheetContent.js +0 -28
- package/transpiled/react/Viewer/Footer/DownloadButton.js +0 -91
- package/transpiled/react/Viewer/Footer/FooterActionButtons.js +0 -21
- package/transpiled/react/Viewer/Footer/FooterContent.js +0 -98
- package/transpiled/react/Viewer/Footer/ForwardButton.js +0 -143
- package/transpiled/react/Viewer/Footer/ForwardOrDownloadButton.js +0 -25
- package/transpiled/react/Viewer/Footer/Sharing.js +0 -57
- package/transpiled/react/Viewer/Footer/helpers.js +0 -151
- package/transpiled/react/Viewer/NoViewer/DownloadButton.js +0 -34
- package/transpiled/react/Viewer/NoViewer/FileIcon.js +0 -57
- package/transpiled/react/Viewer/NoViewer/NoViewer.js +0 -49
- package/transpiled/react/Viewer/NoViewer/index.js +0 -1
- package/transpiled/react/Viewer/Panel/ActionMenuDesktop.js +0 -68
- package/transpiled/react/Viewer/Panel/ActionMenuMobile.js +0 -70
- package/transpiled/react/Viewer/Panel/ActionMenuWrapper.js +0 -129
- package/transpiled/react/Viewer/Panel/Certifications.js +0 -56
- package/transpiled/react/Viewer/Panel/PanelContent.js +0 -48
- package/transpiled/react/Viewer/Panel/Qualification.js +0 -119
- package/transpiled/react/Viewer/Panel/QualificationListItemContact.js +0 -96
- package/transpiled/react/Viewer/Panel/QualificationListItemDate.js +0 -64
- package/transpiled/react/Viewer/Panel/QualificationListItemInformation.js +0 -59
- package/transpiled/react/Viewer/Panel/QualificationListItemOther.js +0 -53
- package/transpiled/react/Viewer/Panel/QualificationListItemText.js +0 -29
- package/transpiled/react/Viewer/Panel/getPanelBlocks.js +0 -62
- package/transpiled/react/Viewer/Viewer.js +0 -172
- package/transpiled/react/Viewer/ViewerContainer.js +0 -189
- package/transpiled/react/Viewer/ViewerExposer.js +0 -2
- package/transpiled/react/Viewer/ViewerInformationsWrapper.js +0 -49
- package/transpiled/react/Viewer/ViewerWithCustomPanelAndFooter.js +0 -56
- package/transpiled/react/Viewer/ViewersByFile/AudioViewer.js +0 -41
- package/transpiled/react/Viewer/ViewersByFile/BlankPaperViewer.js +0 -74
- package/transpiled/react/Viewer/ViewersByFile/ImageViewer.js +0 -367
- package/transpiled/react/Viewer/ViewersByFile/NoNetworkViewer.js +0 -38
- package/transpiled/react/Viewer/ViewersByFile/OnlyOfficeViewer.js +0 -29
- package/transpiled/react/Viewer/ViewersByFile/PdfJsViewer.js +0 -254
- package/transpiled/react/Viewer/ViewersByFile/PdfMobileViewer.js +0 -153
- package/transpiled/react/Viewer/ViewersByFile/ShortcutViewer.js +0 -42
- package/transpiled/react/Viewer/ViewersByFile/TextViewer.js +0 -219
- package/transpiled/react/Viewer/ViewersByFile/VideoViewer.js +0 -33
- package/transpiled/react/Viewer/assets/IlluGenericNewPage.svg +0 -10
- package/transpiled/react/Viewer/components/ExpirationAlert.js +0 -100
- package/transpiled/react/Viewer/components/ExpirationAnnotation.js +0 -41
- package/transpiled/react/Viewer/components/Footer.js +0 -29
- package/transpiled/react/Viewer/components/InformationPanel.js +0 -23
- package/transpiled/react/Viewer/components/Navigation.js +0 -47
- package/transpiled/react/Viewer/components/PdfToolbarButton.js +0 -28
- package/transpiled/react/Viewer/components/PrintButton.js +0 -137
- package/transpiled/react/Viewer/components/Toolbar.js +0 -115
- package/transpiled/react/Viewer/components/ToolbarButtons.js +0 -9
- package/transpiled/react/Viewer/components/ToolbarFilePath.js +0 -71
- package/transpiled/react/Viewer/components/ViewerByFile.js +0 -105
- package/transpiled/react/Viewer/components/ViewerControls.js +0 -226
- package/transpiled/react/Viewer/components/ViewerSpinner.js +0 -17
- package/transpiled/react/Viewer/helpers.js +0 -147
- package/transpiled/react/Viewer/hoc/withFileUrl.js +0 -207
- package/transpiled/react/Viewer/hoc/withViewerLocales.js +0 -3
- package/transpiled/react/Viewer/hooks/useReferencedContactName.js +0 -32
- package/transpiled/react/Viewer/index.js +0 -11
- package/transpiled/react/Viewer/locales/index.js +0 -136
- package/transpiled/react/Viewer/proptypes.js +0 -14
- package/transpiled/react/Viewer/providers/ActionMenuProvider.js +0 -34
- package/transpiled/react/Viewer/queries.js +0 -26
- /package/react/{Viewer/providers/EncryptedProvider.jsx → providers/Encrypted/index.jsx} +0 -0
- /package/transpiled/react/{Viewer/providers/EncryptedProvider.js → providers/Encrypted/index.js} +0 -0
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`NoViewer should render the viewer 1`] = `
|
|
4
|
-
<div>
|
|
5
|
-
<div
|
|
6
|
-
class="styles__viewer-noviewer___auG-6"
|
|
7
|
-
>
|
|
8
|
-
<svg
|
|
9
|
-
class="styles__icon___23x3R"
|
|
10
|
-
height="140"
|
|
11
|
-
viewBox="0 0 32 32"
|
|
12
|
-
width="160"
|
|
13
|
-
>
|
|
14
|
-
<g
|
|
15
|
-
fill="none"
|
|
16
|
-
fill-rule="evenodd"
|
|
17
|
-
>
|
|
18
|
-
<path
|
|
19
|
-
d="M3 2.002C3 .896 3.89 0 4.997 0H22l7 7v22.996A2 2 0 0127.003 32H4.997A1.995 1.995 0 013 29.998V2.002z"
|
|
20
|
-
fill="#D1D5DB"
|
|
21
|
-
/>
|
|
22
|
-
<path
|
|
23
|
-
d="M21.5 0c-.276 0-.5.23-.5.5V8h7.5c.276 0 .5-.232.5-.5V7l-7-7h-.5z"
|
|
24
|
-
fill="#A3ACB8"
|
|
25
|
-
/>
|
|
26
|
-
</g>
|
|
27
|
-
</svg>
|
|
28
|
-
<p
|
|
29
|
-
class="styles__viewer-filename___3jZCt"
|
|
30
|
-
>
|
|
31
|
-
notSupported.xyz
|
|
32
|
-
</p>
|
|
33
|
-
<button
|
|
34
|
-
class="styles__c-btn___3kXsk styles__c-btn--center___Nny0n"
|
|
35
|
-
type="submit"
|
|
36
|
-
>
|
|
37
|
-
<span>
|
|
38
|
-
<span>
|
|
39
|
-
Download
|
|
40
|
-
</span>
|
|
41
|
-
</span>
|
|
42
|
-
</button>
|
|
43
|
-
</div>
|
|
44
|
-
</div>
|
|
45
|
-
`;
|
|
46
|
-
|
|
47
|
-
exports[`NoViewer should render the viewer with specific extra content 1`] = `
|
|
48
|
-
<div>
|
|
49
|
-
<div
|
|
50
|
-
class="styles__viewer-noviewer___auG-6"
|
|
51
|
-
>
|
|
52
|
-
<svg
|
|
53
|
-
class="styles__icon___23x3R"
|
|
54
|
-
height="140"
|
|
55
|
-
viewBox="0 0 32 32"
|
|
56
|
-
width="160"
|
|
57
|
-
>
|
|
58
|
-
<g
|
|
59
|
-
fill="none"
|
|
60
|
-
fill-rule="evenodd"
|
|
61
|
-
>
|
|
62
|
-
<path
|
|
63
|
-
d="M3 2.002C3 .896 3.89 0 4.997 0H22l7 7v22.996A2 2 0 0127.003 32H4.997A1.995 1.995 0 013 29.998V2.002z"
|
|
64
|
-
fill="#D1D5DB"
|
|
65
|
-
/>
|
|
66
|
-
<path
|
|
67
|
-
d="M21.5 0c-.276 0-.5.23-.5.5V8h7.5c.276 0 .5-.232.5-.5V7l-7-7h-.5z"
|
|
68
|
-
fill="#A3ACB8"
|
|
69
|
-
/>
|
|
70
|
-
</g>
|
|
71
|
-
</svg>
|
|
72
|
-
<p
|
|
73
|
-
class="styles__viewer-filename___3jZCt"
|
|
74
|
-
>
|
|
75
|
-
notSupported.xyz
|
|
76
|
-
</p>
|
|
77
|
-
<div>
|
|
78
|
-
with specific extra content
|
|
79
|
-
</div>
|
|
80
|
-
</div>
|
|
81
|
-
</div>
|
|
82
|
-
`;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './NoViewer'
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types'
|
|
2
|
-
import React, { forwardRef } from 'react'
|
|
3
|
-
|
|
4
|
-
import styles from './styles.styl'
|
|
5
|
-
import AppLinker from '../../AppLinker'
|
|
6
|
-
import Icon from '../../Icon'
|
|
7
|
-
import Copy from '../../Icons/Copy'
|
|
8
|
-
import Edit from '../../Icons/Rename'
|
|
9
|
-
import Typography from '../../Typography'
|
|
10
|
-
import ActionMenu, { ActionMenuItem } from '../../deprecated/ActionMenu'
|
|
11
|
-
import { useI18n } from '../../providers/I18n'
|
|
12
|
-
|
|
13
|
-
const ActionMenuDesktop = forwardRef(
|
|
14
|
-
({ onClose, isEditable, actions, appLink, appSlug }, ref) => {
|
|
15
|
-
const { handleCopy, handleEdit } = actions
|
|
16
|
-
const { t } = useI18n()
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<ActionMenu
|
|
20
|
-
className={styles['ActionMenuDesktop-ActionMenu']}
|
|
21
|
-
onClose={onClose}
|
|
22
|
-
anchorElRef={ref}
|
|
23
|
-
>
|
|
24
|
-
{isEditable && (
|
|
25
|
-
<AppLinker app={{ slug: appSlug }} href={appLink}>
|
|
26
|
-
{({ onClick, href }) => {
|
|
27
|
-
return (
|
|
28
|
-
<a href={href} onClick={() => handleEdit(onClick)}>
|
|
29
|
-
<ActionMenuItem
|
|
30
|
-
left={<Icon icon={Edit} color="var(--iconTextColor)" />}
|
|
31
|
-
>
|
|
32
|
-
<Typography>
|
|
33
|
-
{t(`Viewer.panel.qualification.actions.edit`)}
|
|
34
|
-
</Typography>
|
|
35
|
-
</ActionMenuItem>
|
|
36
|
-
</a>
|
|
37
|
-
)
|
|
38
|
-
}}
|
|
39
|
-
</AppLinker>
|
|
40
|
-
)}
|
|
41
|
-
<ActionMenuItem
|
|
42
|
-
onClick={handleCopy}
|
|
43
|
-
left={<Icon icon={Copy} color="var(--iconTextColor)" />}
|
|
44
|
-
>
|
|
45
|
-
<Typography>
|
|
46
|
-
{t(`Viewer.panel.qualification.actions.copy`)}
|
|
47
|
-
</Typography>
|
|
48
|
-
</ActionMenuItem>
|
|
49
|
-
</ActionMenu>
|
|
50
|
-
)
|
|
51
|
-
}
|
|
52
|
-
)
|
|
53
|
-
ActionMenuDesktop.displayName = 'ActionMenuDesktop'
|
|
54
|
-
|
|
55
|
-
ActionMenuDesktop.propTypes = {
|
|
56
|
-
onClose: PropTypes.func,
|
|
57
|
-
isEditable: PropTypes.bool,
|
|
58
|
-
actions: PropTypes.shape({
|
|
59
|
-
handleCopy: PropTypes.func,
|
|
60
|
-
handleEdit: PropTypes.func
|
|
61
|
-
}),
|
|
62
|
-
appLink: PropTypes.string,
|
|
63
|
-
appSlug: PropTypes.string
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export default ActionMenuDesktop
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
|
|
4
|
-
import AppLinker from '../../AppLinker'
|
|
5
|
-
import BottomSheet, { BottomSheetItem } from '../../BottomSheet'
|
|
6
|
-
import Icon from '../../Icon'
|
|
7
|
-
import Copy from '../../Icons/Copy'
|
|
8
|
-
import Edit from '../../Icons/Rename'
|
|
9
|
-
import List from '../../List'
|
|
10
|
-
import ListItem from '../../ListItem'
|
|
11
|
-
import ListItemIcon from '../../ListItemIcon'
|
|
12
|
-
import ListItemText from '../../ListItemText'
|
|
13
|
-
import { useI18n } from '../../providers/I18n'
|
|
14
|
-
|
|
15
|
-
const ActionMenuMobile = ({
|
|
16
|
-
onClose,
|
|
17
|
-
isEditable,
|
|
18
|
-
actions,
|
|
19
|
-
appLink,
|
|
20
|
-
appSlug
|
|
21
|
-
}) => {
|
|
22
|
-
const { t } = useI18n()
|
|
23
|
-
const { handleCopy, handleEdit } = actions
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<BottomSheet backdrop onClose={onClose}>
|
|
27
|
-
<BottomSheetItem disableGutters>
|
|
28
|
-
<List>
|
|
29
|
-
{isEditable && (
|
|
30
|
-
<AppLinker app={{ slug: appSlug }} href={appLink}>
|
|
31
|
-
{({ onClick, href }) => {
|
|
32
|
-
return (
|
|
33
|
-
<ListItem
|
|
34
|
-
button
|
|
35
|
-
component="a"
|
|
36
|
-
href={href}
|
|
37
|
-
onClick={() => handleEdit(onClick)}
|
|
38
|
-
>
|
|
39
|
-
<ListItemIcon>
|
|
40
|
-
<Icon icon={Edit} />
|
|
41
|
-
</ListItemIcon>
|
|
42
|
-
<ListItemText
|
|
43
|
-
primary={t(`Viewer.panel.qualification.actions.edit`)}
|
|
44
|
-
/>
|
|
45
|
-
</ListItem>
|
|
46
|
-
)
|
|
47
|
-
}}
|
|
48
|
-
</AppLinker>
|
|
49
|
-
)}
|
|
50
|
-
<ListItem button onClick={handleCopy}>
|
|
51
|
-
<ListItemIcon>
|
|
52
|
-
<Icon icon={Copy} />
|
|
53
|
-
</ListItemIcon>
|
|
54
|
-
<ListItemText
|
|
55
|
-
primary={t(`Viewer.panel.qualification.actions.copyClipboard`)}
|
|
56
|
-
/>
|
|
57
|
-
</ListItem>
|
|
58
|
-
</List>
|
|
59
|
-
</BottomSheetItem>
|
|
60
|
-
</BottomSheet>
|
|
61
|
-
)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
ActionMenuMobile.propTypes = {
|
|
65
|
-
onClose: PropTypes.func,
|
|
66
|
-
isEditable: PropTypes.bool,
|
|
67
|
-
actions: PropTypes.shape({
|
|
68
|
-
handleCopy: PropTypes.func,
|
|
69
|
-
handleEdit: PropTypes.func
|
|
70
|
-
}),
|
|
71
|
-
appLink: PropTypes.string
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export default ActionMenuMobile
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types'
|
|
2
|
-
import React, { forwardRef } from 'react'
|
|
3
|
-
|
|
4
|
-
import { useAppLinkWithStoreFallback, useClient } from 'cozy-client'
|
|
5
|
-
|
|
6
|
-
import ActionMenuDesktop from './ActionMenuDesktop'
|
|
7
|
-
import ActionMenuMobile from './ActionMenuMobile'
|
|
8
|
-
import { useAlert } from '../../providers/Alert'
|
|
9
|
-
import useBreakpoints from '../../providers/Breakpoints'
|
|
10
|
-
import { useI18n } from '../../providers/I18n'
|
|
11
|
-
import {
|
|
12
|
-
buildEditAttributePath,
|
|
13
|
-
isEditableAttribute,
|
|
14
|
-
getCurrentModel
|
|
15
|
-
} from '../helpers'
|
|
16
|
-
import useActionMenuContext from '../providers/ActionMenuProvider'
|
|
17
|
-
|
|
18
|
-
const mespapiersAppSlug = 'mespapiers'
|
|
19
|
-
|
|
20
|
-
const ActionMenuWrapper = forwardRef(({ onClose, file, optionFile }, ref) => {
|
|
21
|
-
const { name, value } = optionFile
|
|
22
|
-
const editPathByModelProps = useActionMenuContext()
|
|
23
|
-
const { isMobile } = useBreakpoints()
|
|
24
|
-
const { t } = useI18n()
|
|
25
|
-
const { showAlert } = useAlert()
|
|
26
|
-
const client = useClient()
|
|
27
|
-
|
|
28
|
-
const currentModel = getCurrentModel(name)
|
|
29
|
-
const editPath = buildEditAttributePath(
|
|
30
|
-
editPathByModelProps,
|
|
31
|
-
currentModel,
|
|
32
|
-
optionFile.name
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
const { fetchStatus, url } = useAppLinkWithStoreFallback(
|
|
36
|
-
mespapiersAppSlug,
|
|
37
|
-
client,
|
|
38
|
-
editPath
|
|
39
|
-
)
|
|
40
|
-
const isAppLinkLoaded = fetchStatus === 'loaded'
|
|
41
|
-
const isEditable = Boolean(editPath) && isEditableAttribute(name, file)
|
|
42
|
-
|
|
43
|
-
const handleCopy = async () => {
|
|
44
|
-
try {
|
|
45
|
-
await navigator.clipboard.writeText(value)
|
|
46
|
-
showAlert({
|
|
47
|
-
message: t(`Viewer.snackbar.copiedToClipboard.success`),
|
|
48
|
-
severity: 'success',
|
|
49
|
-
variant: 'filled',
|
|
50
|
-
icon: false
|
|
51
|
-
})
|
|
52
|
-
} catch (error) {
|
|
53
|
-
showAlert({
|
|
54
|
-
message: t(`Viewer.snackbar.copiedToClipboard.error`),
|
|
55
|
-
severity: 'error',
|
|
56
|
-
variant: 'filled',
|
|
57
|
-
icon: false
|
|
58
|
-
})
|
|
59
|
-
}
|
|
60
|
-
onClose()
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const handleEdit = cb => {
|
|
64
|
-
if (isAppLinkLoaded) {
|
|
65
|
-
onClose()
|
|
66
|
-
cb && cb()
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (isMobile) {
|
|
71
|
-
return (
|
|
72
|
-
<ActionMenuMobile
|
|
73
|
-
onClose={onClose}
|
|
74
|
-
isEditable={isEditable}
|
|
75
|
-
actions={{ handleCopy, handleEdit }}
|
|
76
|
-
appLink={url}
|
|
77
|
-
appSlug={mespapiersAppSlug}
|
|
78
|
-
/>
|
|
79
|
-
)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
<ActionMenuDesktop
|
|
84
|
-
ref={ref}
|
|
85
|
-
onClose={onClose}
|
|
86
|
-
isEditable={isEditable}
|
|
87
|
-
actions={{ handleCopy, handleEdit }}
|
|
88
|
-
appLink={url}
|
|
89
|
-
appSlug={mespapiersAppSlug}
|
|
90
|
-
/>
|
|
91
|
-
)
|
|
92
|
-
})
|
|
93
|
-
ActionMenuWrapper.displayName = 'ActionMenuWrapper'
|
|
94
|
-
|
|
95
|
-
ActionMenuWrapper.propTypes = {
|
|
96
|
-
onClose: PropTypes.func,
|
|
97
|
-
file: PropTypes.object,
|
|
98
|
-
optionFile: PropTypes.shape({
|
|
99
|
-
name: PropTypes.string,
|
|
100
|
-
value: PropTypes.string
|
|
101
|
-
})
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export default ActionMenuWrapper
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import has from 'lodash/has'
|
|
2
|
-
import PropTypes from 'prop-types'
|
|
3
|
-
import React from 'react'
|
|
4
|
-
|
|
5
|
-
import Icon, { iconPropType } from '../../Icon'
|
|
6
|
-
import CarbonCopyIcon from '../../Icons/CarbonCopy'
|
|
7
|
-
import SafeIcon from '../../Icons/Safe'
|
|
8
|
-
import Typography from '../../Typography'
|
|
9
|
-
import { Media, Img, Bd } from '../../deprecated/Media'
|
|
10
|
-
import { withViewerLocales } from '../hoc/withViewerLocales'
|
|
11
|
-
|
|
12
|
-
const Certification = ({ icon, title, caption }) => {
|
|
13
|
-
return (
|
|
14
|
-
<div className="u-ph-2 u-pv-1">
|
|
15
|
-
<Media className="u-mb-half" align="top">
|
|
16
|
-
<Img className="u-mr-half">
|
|
17
|
-
<Icon icon={icon} />
|
|
18
|
-
</Img>
|
|
19
|
-
<Bd>
|
|
20
|
-
<Typography variant="body1">{title}</Typography>
|
|
21
|
-
</Bd>
|
|
22
|
-
</Media>
|
|
23
|
-
<Typography variant="caption">{caption}</Typography>
|
|
24
|
-
</div>
|
|
25
|
-
)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
Certification.propTypes = {
|
|
29
|
-
icon: iconPropType.isRequired,
|
|
30
|
-
title: PropTypes.string.isRequired,
|
|
31
|
-
caption: PropTypes.string.isRequired
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const Certifications = ({ file, t }) => {
|
|
35
|
-
const hasCarbonCopy = has(file, 'metadata.carbonCopy')
|
|
36
|
-
const hasElectronicSafe = has(file, 'metadata.electronicSafe')
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<>
|
|
40
|
-
{hasCarbonCopy && (
|
|
41
|
-
<Certification
|
|
42
|
-
icon={CarbonCopyIcon}
|
|
43
|
-
title={t('Viewer.panel.certifications.carbonCopy.title')}
|
|
44
|
-
caption={t('Viewer.panel.certifications.carbonCopy.caption')}
|
|
45
|
-
/>
|
|
46
|
-
)}
|
|
47
|
-
{hasElectronicSafe && (
|
|
48
|
-
<Certification
|
|
49
|
-
icon={SafeIcon}
|
|
50
|
-
title={t('Viewer.panel.certifications.electronicSafe.title')}
|
|
51
|
-
caption={t('Viewer.panel.certifications.electronicSafe.caption')}
|
|
52
|
-
/>
|
|
53
|
-
)}
|
|
54
|
-
</>
|
|
55
|
-
)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
Certifications.propTypes = {
|
|
59
|
-
file: PropTypes.object.isRequired
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export default withViewerLocales(Certifications)
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import cx from 'classnames'
|
|
2
|
-
import PropTypes from 'prop-types'
|
|
3
|
-
import React from 'react'
|
|
4
|
-
|
|
5
|
-
import getPanelBlocks, { getPanelBlocksSpecs } from './getPanelBlocks'
|
|
6
|
-
import Paper from '../../Paper'
|
|
7
|
-
import Stack from '../../Stack'
|
|
8
|
-
import Typography from '../../Typography'
|
|
9
|
-
import { withViewerLocales } from '../hoc/withViewerLocales'
|
|
10
|
-
|
|
11
|
-
const PanelContent = ({ file, isPublic, t }) => {
|
|
12
|
-
const panelBlocks = getPanelBlocks({
|
|
13
|
-
panelBlocksSpecs: getPanelBlocksSpecs(isPublic),
|
|
14
|
-
file
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<Stack spacing="s" className={cx('u-flex u-flex-column u-h-100')}>
|
|
19
|
-
<Paper
|
|
20
|
-
className="u-flex u-flex-items-center u-h-3 u-ph-2 u-flex-shrink-0"
|
|
21
|
-
elevation={2}
|
|
22
|
-
square
|
|
23
|
-
>
|
|
24
|
-
<Typography variant="h4">{t('Viewer.panel.title')}</Typography>
|
|
25
|
-
</Paper>
|
|
26
|
-
{panelBlocks.map((PanelBlock, index) => (
|
|
27
|
-
<Paper
|
|
28
|
-
key={index}
|
|
29
|
-
className={cx({
|
|
30
|
-
'u-flex-grow-1': index === panelBlocks.length - 1
|
|
31
|
-
})}
|
|
32
|
-
elevation={2}
|
|
33
|
-
square
|
|
34
|
-
>
|
|
35
|
-
<Typography variant="h4" className="u-pv-1">
|
|
36
|
-
<PanelBlock file={file} />
|
|
37
|
-
</Typography>
|
|
38
|
-
</Paper>
|
|
39
|
-
))}
|
|
40
|
-
</Stack>
|
|
41
|
-
)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
PanelContent.propTypes = {
|
|
45
|
-
file: PropTypes.object.isRequired,
|
|
46
|
-
isPublic: PropTypes.bool
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export default withViewerLocales(PanelContent)
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types'
|
|
2
|
-
import React, { useRef, useState, createRef, useMemo, useEffect } from 'react'
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
isExpiringSoon,
|
|
6
|
-
formatMetadataQualification,
|
|
7
|
-
KNOWN_BILLS_ATTRIBUTES_NAMES,
|
|
8
|
-
getMetadataQualificationType
|
|
9
|
-
} from 'cozy-client/dist/models/paper'
|
|
10
|
-
|
|
11
|
-
import ActionMenuWrapper from './ActionMenuWrapper'
|
|
12
|
-
import QualificationListItemContact from './QualificationListItemContact'
|
|
13
|
-
import QualificationListItemDate from './QualificationListItemDate'
|
|
14
|
-
import QualificationListItemInformation from './QualificationListItemInformation'
|
|
15
|
-
import QualificationListItemOther from './QualificationListItemOther'
|
|
16
|
-
import List from '../../List'
|
|
17
|
-
import ExpirationAlert from '../components/ExpirationAlert'
|
|
18
|
-
import { withViewerLocales } from '../hoc/withViewerLocales'
|
|
19
|
-
|
|
20
|
-
const ComponentFromMetadataQualificationType = {
|
|
21
|
-
contact: QualificationListItemContact,
|
|
22
|
-
date: QualificationListItemDate,
|
|
23
|
-
information: QualificationListItemInformation,
|
|
24
|
-
other: QualificationListItemOther,
|
|
25
|
-
bills: QualificationListItemInformation
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const isExpirationAlertHidden = file => {
|
|
29
|
-
return file?.metadata?.hideExpirationAlert ?? false
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const Qualification = ({ file }) => {
|
|
33
|
-
const { metadata = {} } = file
|
|
34
|
-
const actionBtnRef = useRef([])
|
|
35
|
-
const [optionFile, setOptionFile] = useState({
|
|
36
|
-
id: '',
|
|
37
|
-
name: '',
|
|
38
|
-
value: ''
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
const hideActionsMenu = () => {
|
|
42
|
-
setOptionFile({ id: '', name: '', value: '' })
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const toggleActionsMenu = (id, name, value) => {
|
|
46
|
-
setOptionFile(prev => {
|
|
47
|
-
if (prev.value) return { id: '', name: '', value: '' }
|
|
48
|
-
return { id, name, value }
|
|
49
|
-
})
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const formattedMetadataQualification = useMemo(() => {
|
|
53
|
-
const relatedBills = file.bills?.data?.[0]
|
|
54
|
-
|
|
55
|
-
if (relatedBills) {
|
|
56
|
-
const formattedBillsMetadata = KNOWN_BILLS_ATTRIBUTES_NAMES.map(
|
|
57
|
-
attrName => ({ name: attrName, value: relatedBills[attrName] })
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
return formatMetadataQualification(metadata).concat(
|
|
61
|
-
formattedBillsMetadata
|
|
62
|
-
)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return formatMetadataQualification(metadata)
|
|
66
|
-
}, [metadata, file.bills?.data])
|
|
67
|
-
|
|
68
|
-
useEffect(() => {
|
|
69
|
-
actionBtnRef.current = formattedMetadataQualification.map(
|
|
70
|
-
(_, idx) => actionBtnRef.current[idx] ?? createRef()
|
|
71
|
-
)
|
|
72
|
-
}, [formattedMetadataQualification])
|
|
73
|
-
|
|
74
|
-
return (
|
|
75
|
-
<>
|
|
76
|
-
{isExpiringSoon(file) && !isExpirationAlertHidden(file) && (
|
|
77
|
-
<ExpirationAlert file={file} />
|
|
78
|
-
)}
|
|
79
|
-
<List className="u-pv-1">
|
|
80
|
-
{formattedMetadataQualification.map((meta, idx) => {
|
|
81
|
-
const { name } = meta
|
|
82
|
-
const metadataQualificationType = getMetadataQualificationType(name)
|
|
83
|
-
const QualificationListItemComp =
|
|
84
|
-
ComponentFromMetadataQualificationType[metadataQualificationType]
|
|
85
|
-
|
|
86
|
-
return (
|
|
87
|
-
<QualificationListItemComp
|
|
88
|
-
key={idx}
|
|
89
|
-
file={file}
|
|
90
|
-
ref={actionBtnRef.current[idx]}
|
|
91
|
-
formattedMetadataQualification={meta}
|
|
92
|
-
toggleActionsMenu={val => toggleActionsMenu(idx, name, val)}
|
|
93
|
-
/>
|
|
94
|
-
)
|
|
95
|
-
})}
|
|
96
|
-
|
|
97
|
-
{optionFile.name && (
|
|
98
|
-
<ActionMenuWrapper
|
|
99
|
-
onClose={hideActionsMenu}
|
|
100
|
-
file={file}
|
|
101
|
-
optionFile={optionFile}
|
|
102
|
-
ref={actionBtnRef.current[optionFile.id]}
|
|
103
|
-
/>
|
|
104
|
-
)}
|
|
105
|
-
</List>
|
|
106
|
-
</>
|
|
107
|
-
)
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
Qualification.propTypes = {
|
|
111
|
-
file: PropTypes.object.isRequired
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export default withViewerLocales(Qualification)
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types'
|
|
2
|
-
import React, { useRef, useState } from 'react'
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
getTranslatedNameForContact,
|
|
6
|
-
formatContactValue
|
|
7
|
-
} from 'cozy-client/dist/models/paper'
|
|
8
|
-
|
|
9
|
-
import ActionMenuWrapper from './ActionMenuWrapper'
|
|
10
|
-
import QualificationListItemText from './QualificationListItemText'
|
|
11
|
-
import Icon from '../../Icon'
|
|
12
|
-
import IconButton from '../../IconButton'
|
|
13
|
-
import Dots from '../../Icons/Dots'
|
|
14
|
-
import ListItem from '../../ListItem'
|
|
15
|
-
import ListItemSecondaryAction from '../../ListItemSecondaryAction'
|
|
16
|
-
import Spinner from '../../Spinner'
|
|
17
|
-
import { useI18n } from '../../providers/I18n'
|
|
18
|
-
import useReferencedContactName from '../hooks/useReferencedContactName'
|
|
19
|
-
|
|
20
|
-
const QualificationListItemContact = ({ file }) => {
|
|
21
|
-
const { lang } = useI18n()
|
|
22
|
-
const actionBtnRef = useRef()
|
|
23
|
-
const [optionFile, setOptionFile] = useState({
|
|
24
|
-
name: '',
|
|
25
|
-
value: ''
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
const hideActionsMenu = () => setOptionFile({ name: '', value: '' })
|
|
29
|
-
const toggleActionsMenu = (name, value) =>
|
|
30
|
-
setOptionFile(prev => {
|
|
31
|
-
if (prev.value) return { name: '', value: '' }
|
|
32
|
-
return { name, value }
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
const { contacts, isLoadingContacts } = useReferencedContactName(file)
|
|
36
|
-
|
|
37
|
-
if (isLoadingContacts) {
|
|
38
|
-
return (
|
|
39
|
-
<ListItem className="u-pl-2 u-pr-3">
|
|
40
|
-
<Spinner color="var(--secondaryTextColor)" />
|
|
41
|
-
</ListItem>
|
|
42
|
-
)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const formattedTitle = getTranslatedNameForContact({ lang })
|
|
46
|
-
const formattedValue = formatContactValue(contacts)
|
|
47
|
-
|
|
48
|
-
if (!isLoadingContacts && !formattedValue) {
|
|
49
|
-
return null
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return (
|
|
53
|
-
<>
|
|
54
|
-
<ListItem className="u-ph-2">
|
|
55
|
-
<QualificationListItemText
|
|
56
|
-
primary={formattedTitle}
|
|
57
|
-
secondary={formattedValue}
|
|
58
|
-
/>
|
|
59
|
-
<ListItemSecondaryAction>
|
|
60
|
-
<IconButton
|
|
61
|
-
ref={actionBtnRef}
|
|
62
|
-
onClick={() => toggleActionsMenu('contact', formattedValue)}
|
|
63
|
-
>
|
|
64
|
-
<Icon icon={Dots} />
|
|
65
|
-
</IconButton>
|
|
66
|
-
</ListItemSecondaryAction>
|
|
67
|
-
</ListItem>
|
|
68
|
-
|
|
69
|
-
{optionFile.value && (
|
|
70
|
-
<ActionMenuWrapper
|
|
71
|
-
onClose={hideActionsMenu}
|
|
72
|
-
file={file}
|
|
73
|
-
optionFile={optionFile}
|
|
74
|
-
ref={actionBtnRef}
|
|
75
|
-
/>
|
|
76
|
-
)}
|
|
77
|
-
</>
|
|
78
|
-
)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
QualificationListItemContact.propTypes = {
|
|
82
|
-
file: PropTypes.object.isRequired
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export default QualificationListItemContact
|