cozy-ui 111.21.0 → 112.0.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 +14 -0
- package/package.json +3 -2
- 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,86 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types'
|
|
2
|
-
import React, { useState } from 'react'
|
|
3
|
-
|
|
4
|
-
import { useClient } from 'cozy-client'
|
|
5
|
-
import {
|
|
6
|
-
isForeignPaper,
|
|
7
|
-
computeExpirationDate,
|
|
8
|
-
computeExpirationNoticeLink,
|
|
9
|
-
makeExpirationDescription
|
|
10
|
-
} from 'cozy-client/dist/models/paper'
|
|
11
|
-
|
|
12
|
-
import Alert from '../../Alert'
|
|
13
|
-
import Button from '../../Buttons'
|
|
14
|
-
import Link from '../../Link'
|
|
15
|
-
import Typography from '../../Typography'
|
|
16
|
-
import { useI18n } from '../../providers/I18n'
|
|
17
|
-
import { withViewerLocales } from '../hoc/withViewerLocales'
|
|
18
|
-
|
|
19
|
-
const FILES_DOCTYPE = 'io.cozy.files'
|
|
20
|
-
|
|
21
|
-
const ExpirationAlert = ({ file }) => {
|
|
22
|
-
const { t, lang } = useI18n()
|
|
23
|
-
const client = useClient()
|
|
24
|
-
const [isBusy, setIsBusy] = useState(false)
|
|
25
|
-
|
|
26
|
-
const handleClose = async () => {
|
|
27
|
-
setIsBusy(true)
|
|
28
|
-
await client.collection(FILES_DOCTYPE).updateMetadataAttribute(file.id, {
|
|
29
|
-
...file.metadata,
|
|
30
|
-
hideExpirationAlert: true
|
|
31
|
-
})
|
|
32
|
-
setIsBusy(false)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const expirationDate = computeExpirationDate(file)
|
|
36
|
-
const expirationNoticeLink = !isForeignPaper(file)
|
|
37
|
-
? computeExpirationNoticeLink(file)
|
|
38
|
-
: null
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<Alert
|
|
42
|
-
severity="warning"
|
|
43
|
-
block
|
|
44
|
-
action={
|
|
45
|
-
<Button
|
|
46
|
-
color="warning"
|
|
47
|
-
variant="text"
|
|
48
|
-
size="small"
|
|
49
|
-
busy={isBusy}
|
|
50
|
-
label={t('Viewer.panel.expiration.dismiss')}
|
|
51
|
-
onClick={handleClose}
|
|
52
|
-
/>
|
|
53
|
-
}
|
|
54
|
-
className="u-mt-1 u-mh-1"
|
|
55
|
-
>
|
|
56
|
-
<Typography component="span" variant="inherit">
|
|
57
|
-
<Typography component="span" variant="inherit">
|
|
58
|
-
{makeExpirationDescription(expirationDate, {
|
|
59
|
-
lang
|
|
60
|
-
})}
|
|
61
|
-
</Typography>
|
|
62
|
-
{expirationNoticeLink && (
|
|
63
|
-
<>
|
|
64
|
-
<Typography component="span" variant="inherit">
|
|
65
|
-
{' : '}
|
|
66
|
-
</Typography>
|
|
67
|
-
<Link
|
|
68
|
-
href={expirationNoticeLink}
|
|
69
|
-
rel="noreferrer"
|
|
70
|
-
target="_blank"
|
|
71
|
-
className="u-warning"
|
|
72
|
-
>
|
|
73
|
-
{new URL(expirationNoticeLink).hostname}
|
|
74
|
-
</Link>
|
|
75
|
-
</>
|
|
76
|
-
)}
|
|
77
|
-
</Typography>
|
|
78
|
-
</Alert>
|
|
79
|
-
)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
ExpirationAlert.propTypes = {
|
|
83
|
-
file: PropTypes.object.isRequired
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export default withViewerLocales(ExpirationAlert)
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
|
|
4
|
-
import { models } from 'cozy-client'
|
|
5
|
-
|
|
6
|
-
import Typography from '../../Typography'
|
|
7
|
-
import { useI18n } from '../../providers/I18n'
|
|
8
|
-
|
|
9
|
-
const {
|
|
10
|
-
computeExpirationDate,
|
|
11
|
-
isExpired,
|
|
12
|
-
makeExpiredMessage,
|
|
13
|
-
makeExpiresInMessage
|
|
14
|
-
} = models.paper
|
|
15
|
-
|
|
16
|
-
const ExpirationAnnotation = ({ file }) => {
|
|
17
|
-
const { lang } = useI18n()
|
|
18
|
-
|
|
19
|
-
if (isExpired(file)) {
|
|
20
|
-
return (
|
|
21
|
-
<Typography component="span" variant="inherit" color="error">
|
|
22
|
-
{makeExpiredMessage({ lang })}
|
|
23
|
-
</Typography>
|
|
24
|
-
)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const expirationDate = computeExpirationDate(file)
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<Typography component="span" variant="inherit" className="u-warning">
|
|
31
|
-
{makeExpiresInMessage(expirationDate, { lang })}
|
|
32
|
-
</Typography>
|
|
33
|
-
)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
ExpirationAnnotation.propTypes = {
|
|
37
|
-
file: PropTypes.object.isRequired
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export default ExpirationAnnotation
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
|
|
3
|
-
import styles from './styles.styl'
|
|
4
|
-
import useBreakpoints from '../../providers/Breakpoints'
|
|
5
|
-
|
|
6
|
-
const Footer = ({ children }) => {
|
|
7
|
-
const { isDesktop } = useBreakpoints()
|
|
8
|
-
|
|
9
|
-
if (isDesktop) return null
|
|
10
|
-
return <div className={styles['viewer-footer']}>{children}</div>
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export default Footer
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
|
|
4
|
-
export const infoWidth = '22rem'
|
|
5
|
-
|
|
6
|
-
const styles = {
|
|
7
|
-
panel: {
|
|
8
|
-
width: infoWidth,
|
|
9
|
-
backgroundColor: 'var(--defaultBackgroundColor)'
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const InformationPanel = ({ children }) => {
|
|
14
|
-
return (
|
|
15
|
-
<div style={styles.panel} className="u-h-100 u-ov-auto">
|
|
16
|
-
{children}
|
|
17
|
-
</div>
|
|
18
|
-
)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
InformationPanel.propTypes = {
|
|
22
|
-
classes: PropTypes.object,
|
|
23
|
-
children: PropTypes.element
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export default InformationPanel
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import cx from 'classnames'
|
|
2
|
-
import PropTypes from 'prop-types'
|
|
3
|
-
import React from 'react'
|
|
4
|
-
|
|
5
|
-
import styles from './styles.styl'
|
|
6
|
-
import Icon from '../../Icon'
|
|
7
|
-
import { default as ArrowIcon } from '../../Icons/DropdownClose'
|
|
8
|
-
|
|
9
|
-
const Navigation = ({
|
|
10
|
-
className,
|
|
11
|
-
hidden,
|
|
12
|
-
onMouseEnter,
|
|
13
|
-
onMouseLeave,
|
|
14
|
-
onClick
|
|
15
|
-
}) => {
|
|
16
|
-
return (
|
|
17
|
-
<div
|
|
18
|
-
role="button"
|
|
19
|
-
className={cx(className, styles['viewer-nav'], {
|
|
20
|
-
[styles['viewer-nav--visible']]: !hidden
|
|
21
|
-
})}
|
|
22
|
-
onClick={onClick}
|
|
23
|
-
onMouseEnter={onMouseEnter}
|
|
24
|
-
onMouseLeave={onMouseLeave}
|
|
25
|
-
>
|
|
26
|
-
<Icon icon={ArrowIcon} size="32" className={styles['viewer-nav-arrow']} />
|
|
27
|
-
</div>
|
|
28
|
-
)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
Navigation.propTypes = {
|
|
32
|
-
className: PropTypes.string.isRequired,
|
|
33
|
-
hidden: PropTypes.bool.isRequired,
|
|
34
|
-
onMouseEnter: PropTypes.func.isRequired,
|
|
35
|
-
onMouseLeave: PropTypes.func.isRequired,
|
|
36
|
-
onClick: PropTypes.func.isRequired
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export default Navigation
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
|
|
4
|
-
import Button from '../../deprecated/Button'
|
|
5
|
-
|
|
6
|
-
const PdfToolbarButton = ({ icon, onClick, disabled, label }) => (
|
|
7
|
-
<Button
|
|
8
|
-
iconOnly
|
|
9
|
-
subtle
|
|
10
|
-
theme="secondary"
|
|
11
|
-
className="u-p-half u-m-half"
|
|
12
|
-
icon={icon}
|
|
13
|
-
onClick={onClick}
|
|
14
|
-
disabled={disabled}
|
|
15
|
-
label={label}
|
|
16
|
-
/>
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
PdfToolbarButton.propTypes = {
|
|
20
|
-
icon: PropTypes.string.isRequired,
|
|
21
|
-
onClick: PropTypes.func.isRequired,
|
|
22
|
-
disabled: PropTypes.bool,
|
|
23
|
-
label: PropTypes.string.isRequired
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export default PdfToolbarButton
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types'
|
|
2
|
-
import React, { useState, useEffect, forwardRef } from 'react'
|
|
3
|
-
|
|
4
|
-
import { useWebviewIntent } from 'cozy-intent'
|
|
5
|
-
|
|
6
|
-
import { makeActions } from '../../ActionsMenu/Actions/helpers'
|
|
7
|
-
import { print } from '../../ActionsMenu/Actions/print'
|
|
8
|
-
import ActionsItems, {
|
|
9
|
-
actionsItemsComponentPropTypes
|
|
10
|
-
} from '../../ActionsMenu/ActionsItems'
|
|
11
|
-
import Button from '../../Buttons'
|
|
12
|
-
import Icon from '../../Icon'
|
|
13
|
-
import IconButton from '../../IconButton'
|
|
14
|
-
|
|
15
|
-
const ActionComponent = forwardRef(({ action, variant, onClick }, ref) => {
|
|
16
|
-
const { label, icon } = action
|
|
17
|
-
|
|
18
|
-
if (variant === 'button') {
|
|
19
|
-
return (
|
|
20
|
-
<Button
|
|
21
|
-
ref={ref}
|
|
22
|
-
variant="secondary"
|
|
23
|
-
aria-label={label}
|
|
24
|
-
label={<Icon icon={icon} />}
|
|
25
|
-
onClick={onClick}
|
|
26
|
-
/>
|
|
27
|
-
)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<IconButton
|
|
32
|
-
ref={ref}
|
|
33
|
-
className="u-white"
|
|
34
|
-
aria-label={label}
|
|
35
|
-
onClick={onClick}
|
|
36
|
-
>
|
|
37
|
-
<Icon icon={icon} />
|
|
38
|
-
</IconButton>
|
|
39
|
-
)
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
ActionComponent.displayName = 'ActionComponent'
|
|
43
|
-
|
|
44
|
-
ActionComponent.propTypes = {
|
|
45
|
-
...actionsItemsComponentPropTypes,
|
|
46
|
-
variant: PropTypes.oneOf(['default', 'button'])
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const PrintButton = ({ file, variant }) => {
|
|
50
|
-
const [isPrintAvailable, setIsPrintAvailable] = useState(false)
|
|
51
|
-
const webviewIntent = useWebviewIntent()
|
|
52
|
-
|
|
53
|
-
const isPDFDoc = file.mime === 'application/pdf'
|
|
54
|
-
const showPrintButton = isPDFDoc && isPrintAvailable
|
|
55
|
-
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
const init = async () => {
|
|
58
|
-
const isAvailable =
|
|
59
|
-
(await webviewIntent?.call('isAvailable', 'print')) ?? true
|
|
60
|
-
|
|
61
|
-
setIsPrintAvailable(isAvailable)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
init()
|
|
65
|
-
}, [webviewIntent])
|
|
66
|
-
|
|
67
|
-
if (!showPrintButton) return null
|
|
68
|
-
|
|
69
|
-
const actions = makeActions([print])
|
|
70
|
-
|
|
71
|
-
return (
|
|
72
|
-
<ActionsItems
|
|
73
|
-
docs={[file]}
|
|
74
|
-
actions={actions}
|
|
75
|
-
component={ActionComponent}
|
|
76
|
-
variant={variant}
|
|
77
|
-
/>
|
|
78
|
-
)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
PrintButton.propTypes = {
|
|
82
|
-
file: PropTypes.object.isRequired,
|
|
83
|
-
variant: PropTypes.oneOf(['default', 'button'])
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
PrintButton.defaultProps = {
|
|
87
|
-
variant: 'default'
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export default PrintButton
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import cx from 'classnames'
|
|
2
|
-
import PropTypes from 'prop-types'
|
|
3
|
-
import React from 'react'
|
|
4
|
-
|
|
5
|
-
import { useClient } from 'cozy-client'
|
|
6
|
-
|
|
7
|
-
import PrintButton from './PrintButton'
|
|
8
|
-
import { ToolbarFilePath } from './ToolbarFilePath'
|
|
9
|
-
import styles from './styles.styl'
|
|
10
|
-
import Icon from '../../Icon'
|
|
11
|
-
import IconButton from '../../IconButton'
|
|
12
|
-
import DownloadIcon from '../../Icons/Download'
|
|
13
|
-
import PreviousIcon from '../../Icons/Previous'
|
|
14
|
-
import MidEllipsis from '../../MidEllipsis'
|
|
15
|
-
import Typography from '../../Typography'
|
|
16
|
-
import withBreakpoints from '../../helpers/withBreakpoints'
|
|
17
|
-
import { useI18n } from '../../providers/I18n'
|
|
18
|
-
import { makeStyles } from '../../styles'
|
|
19
|
-
import { extractChildrenCompByName } from '../Footer/helpers'
|
|
20
|
-
import { downloadFile } from '../helpers'
|
|
21
|
-
import { useEncrypted } from '../providers/EncryptedProvider'
|
|
22
|
-
|
|
23
|
-
const useClasses = makeStyles(theme => ({
|
|
24
|
-
iconButton: {
|
|
25
|
-
[theme.breakpoints.down('md')]: {
|
|
26
|
-
marginLeft: '0.25rem'
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}))
|
|
30
|
-
|
|
31
|
-
const Toolbar = ({
|
|
32
|
-
hidden,
|
|
33
|
-
onMouseEnter,
|
|
34
|
-
onMouseLeave,
|
|
35
|
-
file,
|
|
36
|
-
onClose,
|
|
37
|
-
toolbarRef,
|
|
38
|
-
breakpoints: { isDesktop },
|
|
39
|
-
children,
|
|
40
|
-
showFilePath
|
|
41
|
-
}) => {
|
|
42
|
-
const client = useClient()
|
|
43
|
-
const classes = useClasses()
|
|
44
|
-
const { t } = useI18n()
|
|
45
|
-
|
|
46
|
-
const { url } = useEncrypted()
|
|
47
|
-
|
|
48
|
-
const ToolbarButtons = extractChildrenCompByName({
|
|
49
|
-
children,
|
|
50
|
-
file,
|
|
51
|
-
name: 'ToolbarButtons'
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
<div
|
|
56
|
-
ref={toolbarRef}
|
|
57
|
-
data-testid="viewer-toolbar"
|
|
58
|
-
className={cx(styles['viewer-toolbar'], {
|
|
59
|
-
[styles['viewer-toolbar--hidden']]: hidden
|
|
60
|
-
})}
|
|
61
|
-
onMouseEnter={onMouseEnter}
|
|
62
|
-
onMouseLeave={onMouseLeave}
|
|
63
|
-
>
|
|
64
|
-
{onClose && (
|
|
65
|
-
<IconButton
|
|
66
|
-
className={cx(classes.iconButton, { 'u-white': isDesktop })}
|
|
67
|
-
onClick={onClose}
|
|
68
|
-
>
|
|
69
|
-
<Icon icon={PreviousIcon} />
|
|
70
|
-
</IconButton>
|
|
71
|
-
)}
|
|
72
|
-
<div className="u-pl-half u-ov-auto u-w-100">
|
|
73
|
-
<Typography
|
|
74
|
-
variant="h3"
|
|
75
|
-
color={isDesktop ? 'inherit' : 'textPrimary'}
|
|
76
|
-
noWrap
|
|
77
|
-
>
|
|
78
|
-
<MidEllipsis text={file.name} />
|
|
79
|
-
</Typography>
|
|
80
|
-
{showFilePath ? <ToolbarFilePath file={file} /> : null}
|
|
81
|
-
</div>
|
|
82
|
-
|
|
83
|
-
<div className="u-flex">
|
|
84
|
-
{isDesktop && (
|
|
85
|
-
<>
|
|
86
|
-
{ToolbarButtons}
|
|
87
|
-
<PrintButton file={file} />
|
|
88
|
-
<IconButton
|
|
89
|
-
className="u-white"
|
|
90
|
-
aria-label={t('Viewer.download')}
|
|
91
|
-
onClick={() => downloadFile({ client, file, url })}
|
|
92
|
-
>
|
|
93
|
-
<Icon icon={DownloadIcon} />
|
|
94
|
-
</IconButton>
|
|
95
|
-
</>
|
|
96
|
-
)}
|
|
97
|
-
</div>
|
|
98
|
-
</div>
|
|
99
|
-
)
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
Toolbar.propTypes = {
|
|
103
|
-
hidden: PropTypes.bool,
|
|
104
|
-
onMouseEnter: PropTypes.func.isRequired,
|
|
105
|
-
onMouseLeave: PropTypes.func.isRequired,
|
|
106
|
-
file: PropTypes.object.isRequired,
|
|
107
|
-
onClose: PropTypes.func,
|
|
108
|
-
showFilePath: PropTypes.bool
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export default withBreakpoints()(Toolbar)
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
|
|
3
|
-
import FooterActionButtons from '../Footer/FooterActionButtons'
|
|
4
|
-
|
|
5
|
-
const ToolbarButtons = props => {
|
|
6
|
-
return <FooterActionButtons {...props} />
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
ToolbarButtons.displayName = 'ToolbarButtons'
|
|
10
|
-
|
|
11
|
-
export default ToolbarButtons
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import React, { useMemo } from 'react'
|
|
2
|
-
|
|
3
|
-
import { useClient, useQuery, models } from 'cozy-client'
|
|
4
|
-
|
|
5
|
-
import AppLinker from '../../AppLinker'
|
|
6
|
-
import FilePath from '../../FilePath'
|
|
7
|
-
import Link from '../../Link'
|
|
8
|
-
import useBreakpoints from '../../providers/Breakpoints'
|
|
9
|
-
import {
|
|
10
|
-
makeWebLink,
|
|
11
|
-
normalizeAndSpreadAttributes,
|
|
12
|
-
removeFilenameFromPath
|
|
13
|
-
} from '../helpers'
|
|
14
|
-
import { buildFileByIdQuery } from '../queries'
|
|
15
|
-
|
|
16
|
-
const { ensureFilePath } = models.file
|
|
17
|
-
|
|
18
|
-
const ToolbarFilePath = ({ file }) => {
|
|
19
|
-
const client = useClient()
|
|
20
|
-
const { isDesktop } = useBreakpoints()
|
|
21
|
-
|
|
22
|
-
const normalizeFile = normalizeAndSpreadAttributes(file)
|
|
23
|
-
|
|
24
|
-
const parentQuery = buildFileByIdQuery(normalizeFile.dir_id)
|
|
25
|
-
const parentResult = useQuery(parentQuery.definition, {
|
|
26
|
-
...parentQuery.options,
|
|
27
|
-
enabled: !!normalizeFile.dir_id
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
const fileWithPath = useMemo(
|
|
31
|
-
() =>
|
|
32
|
-
parentResult.data
|
|
33
|
-
? ensureFilePath(normalizeFile, parentResult.data)
|
|
34
|
-
: undefined,
|
|
35
|
-
[normalizeFile, parentResult.data]
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
if (fileWithPath) {
|
|
39
|
-
const appSlug = 'drive'
|
|
40
|
-
const nativePath = `/folder/${fileWithPath.dir_id}`
|
|
41
|
-
const path = removeFilenameFromPath(fileWithPath.path)
|
|
42
|
-
const link = makeWebLink({ client, path: nativePath, slug: appSlug })
|
|
43
|
-
|
|
44
|
-
if (isDesktop && link) {
|
|
45
|
-
return (
|
|
46
|
-
<AppLinker app={{ slug: appSlug }} nativePath={nativePath} href={link}>
|
|
47
|
-
{({ href, onClick }) => (
|
|
48
|
-
<Link href={href} onClick={onClick} color="inherit">
|
|
49
|
-
<FilePath className="u-white">{path}</FilePath>
|
|
50
|
-
</Link>
|
|
51
|
-
)}
|
|
52
|
-
</AppLinker>
|
|
53
|
-
)
|
|
54
|
-
}
|
|
55
|
-
return <FilePath className={isDesktop ? 'u-white' : null}>{path}</FilePath>
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return null
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export { ToolbarFilePath }
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types'
|
|
2
|
-
import React, { useMemo } from 'react'
|
|
3
|
-
|
|
4
|
-
import { isPlainText } from 'cozy-client/dist/models/file'
|
|
5
|
-
import { isMobile as isMobileDevice } from 'cozy-device-helper'
|
|
6
|
-
|
|
7
|
-
import withBreakpoints from '../../helpers/withBreakpoints'
|
|
8
|
-
import { FileDoctype } from '../../proptypes'
|
|
9
|
-
import NoViewer from '../NoViewer'
|
|
10
|
-
import AudioViewer from '../ViewersByFile/AudioViewer'
|
|
11
|
-
import BlankPaperViewer from '../ViewersByFile/BlankPaperViewer'
|
|
12
|
-
import ImageViewer from '../ViewersByFile/ImageViewer'
|
|
13
|
-
import OnlyOfficeViewer from '../ViewersByFile/OnlyOfficeViewer'
|
|
14
|
-
import PdfJsViewer from '../ViewersByFile/PdfJsViewer'
|
|
15
|
-
import PdfMobileViewer from '../ViewersByFile/PdfMobileViewer'
|
|
16
|
-
import ShortcutViewer from '../ViewersByFile/ShortcutViewer'
|
|
17
|
-
import TextViewer from '../ViewersByFile/TextViewer'
|
|
18
|
-
import VideoViewer from '../ViewersByFile/VideoViewer'
|
|
19
|
-
import { useEncrypted } from '../providers/EncryptedProvider'
|
|
20
|
-
|
|
21
|
-
const isBlankPaper = doc => doc.metadata?.paperProps?.isBlank
|
|
22
|
-
|
|
23
|
-
export const getViewerComponentName = ({
|
|
24
|
-
file,
|
|
25
|
-
isDesktop,
|
|
26
|
-
isOnlyOfficeEnabled
|
|
27
|
-
}) => {
|
|
28
|
-
switch (file.class) {
|
|
29
|
-
case 'shortcut':
|
|
30
|
-
return ShortcutViewer
|
|
31
|
-
case 'image':
|
|
32
|
-
return ImageViewer
|
|
33
|
-
case 'audio':
|
|
34
|
-
return AudioViewer
|
|
35
|
-
case 'video':
|
|
36
|
-
return isMobileDevice() ? NoViewer : VideoViewer
|
|
37
|
-
case 'pdf':
|
|
38
|
-
return isBlankPaper(file)
|
|
39
|
-
? BlankPaperViewer
|
|
40
|
-
: isDesktop
|
|
41
|
-
? PdfJsViewer
|
|
42
|
-
: PdfMobileViewer
|
|
43
|
-
case 'text':
|
|
44
|
-
return isPlainText(file.mime, file.name)
|
|
45
|
-
? TextViewer
|
|
46
|
-
: isOnlyOfficeEnabled
|
|
47
|
-
? OnlyOfficeViewer
|
|
48
|
-
: NoViewer
|
|
49
|
-
case 'slide':
|
|
50
|
-
return isOnlyOfficeEnabled ? OnlyOfficeViewer : NoViewer
|
|
51
|
-
case 'spreadsheet':
|
|
52
|
-
return isOnlyOfficeEnabled ? OnlyOfficeViewer : NoViewer
|
|
53
|
-
default:
|
|
54
|
-
return NoViewer
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const ViewerByFile = withBreakpoints()(
|
|
59
|
-
({
|
|
60
|
-
file,
|
|
61
|
-
onClose,
|
|
62
|
-
renderFallbackExtraContent,
|
|
63
|
-
gestures,
|
|
64
|
-
gesturesRef,
|
|
65
|
-
onSwipe,
|
|
66
|
-
breakpoints: { isDesktop },
|
|
67
|
-
componentsProps
|
|
68
|
-
}) => {
|
|
69
|
-
const isOnlyOfficeEnabled = componentsProps?.OnlyOfficeViewer?.isEnabled
|
|
70
|
-
const onlyOfficeOpener = componentsProps?.OnlyOfficeViewer?.opener
|
|
71
|
-
|
|
72
|
-
const { url } = useEncrypted()
|
|
73
|
-
|
|
74
|
-
const ComponentName = useMemo(
|
|
75
|
-
() =>
|
|
76
|
-
getViewerComponentName({
|
|
77
|
-
file,
|
|
78
|
-
isDesktop,
|
|
79
|
-
isOnlyOfficeEnabled
|
|
80
|
-
}),
|
|
81
|
-
[file, isDesktop, isOnlyOfficeEnabled]
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
return (
|
|
85
|
-
<ComponentName
|
|
86
|
-
file={file}
|
|
87
|
-
url={url}
|
|
88
|
-
onClose={onClose}
|
|
89
|
-
renderFallbackExtraContent={renderFallbackExtraContent}
|
|
90
|
-
gestures={gestures}
|
|
91
|
-
gesturesRef={gesturesRef}
|
|
92
|
-
onSwipe={onSwipe}
|
|
93
|
-
onlyOfficeOpener={onlyOfficeOpener}
|
|
94
|
-
/>
|
|
95
|
-
)
|
|
96
|
-
}
|
|
97
|
-
)
|
|
98
|
-
|
|
99
|
-
ViewerByFile.propTypes = {
|
|
100
|
-
file: FileDoctype.isRequired,
|
|
101
|
-
onClose: PropTypes.func.isRequired,
|
|
102
|
-
renderFallbackExtraContent: PropTypes.func,
|
|
103
|
-
// gestures, gesturesRef and onSwipe are got from ViewerControls
|
|
104
|
-
gestures: PropTypes.object,
|
|
105
|
-
gesturesRef: PropTypes.object,
|
|
106
|
-
onSwipe: PropTypes.func,
|
|
107
|
-
componentsProps: PropTypes.object
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
ViewerByFile.displayName = 'ViewerByFile'
|
|
111
|
-
|
|
112
|
-
export default ViewerByFile
|