cozy-ui 111.20.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 +21 -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/Skeletons/ListItemSkeleton.jsx +4 -3
- package/react/Skeletons/Readme.md +12 -3
- 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/Skeletons/ListItemSkeleton.js +7 -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,136 +0,0 @@
|
|
|
1
|
-
import { createMockClient } from 'cozy-client'
|
|
2
|
-
import {
|
|
3
|
-
KNOWN_DATE_METADATA_NAMES,
|
|
4
|
-
KNOWN_INFORMATION_METADATA_NAMES
|
|
5
|
-
} from 'cozy-client/dist/models/paper'
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
downloadFile,
|
|
9
|
-
getCurrentModel,
|
|
10
|
-
buildEditAttributePath,
|
|
11
|
-
isEditableAttribute,
|
|
12
|
-
removeFilenameFromPath
|
|
13
|
-
} from './helpers'
|
|
14
|
-
|
|
15
|
-
describe('helpers', () => {
|
|
16
|
-
describe('download', () => {
|
|
17
|
-
const client = new createMockClient({})
|
|
18
|
-
const mockDownload = jest.fn()
|
|
19
|
-
const mockForceFileDownload = jest.fn()
|
|
20
|
-
client.collection = jest.fn(() => ({
|
|
21
|
-
download: mockDownload,
|
|
22
|
-
forceFileDownload: mockForceFileDownload
|
|
23
|
-
}))
|
|
24
|
-
|
|
25
|
-
it('should call download when file is not encrypted', async () => {
|
|
26
|
-
const file = { name: 'toto.txt' }
|
|
27
|
-
|
|
28
|
-
await downloadFile({ client, file })
|
|
29
|
-
expect(mockDownload).toHaveBeenCalledWith(file)
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
it('should call forceFileDownload when file is encrypted', async () => {
|
|
33
|
-
const file = { name: 'encrypted-toto.txt', encrypted: true }
|
|
34
|
-
const url = 'blob:http://thedecryptedtoto'
|
|
35
|
-
await downloadFile({ client, file, url })
|
|
36
|
-
expect(mockForceFileDownload).toHaveBeenCalledWith(url, file.name)
|
|
37
|
-
})
|
|
38
|
-
})
|
|
39
|
-
describe('getCurrentModel', () => {
|
|
40
|
-
const expected = 'information'
|
|
41
|
-
it.each([
|
|
42
|
-
...KNOWN_DATE_METADATA_NAMES,
|
|
43
|
-
...KNOWN_INFORMATION_METADATA_NAMES
|
|
44
|
-
])(`getCurrentModel(%s) should return ${expected}`, input => {
|
|
45
|
-
expect(getCurrentModel(input)).toBe(expected)
|
|
46
|
-
})
|
|
47
|
-
})
|
|
48
|
-
describe('buildEditAttributePath', () => {
|
|
49
|
-
it('should build correct path', () => {
|
|
50
|
-
const editPathByModelProps = {
|
|
51
|
-
information: `#/paper/edit/information/01?metadata=__NAME__&backgroundPath=$/path`,
|
|
52
|
-
page: `#/paper/edit/page/01?backgroundPath=/path`
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const buildInformationPath = buildEditAttributePath(
|
|
56
|
-
editPathByModelProps,
|
|
57
|
-
'information',
|
|
58
|
-
'number'
|
|
59
|
-
)
|
|
60
|
-
const buildPagePath = buildEditAttributePath(
|
|
61
|
-
editPathByModelProps,
|
|
62
|
-
'page',
|
|
63
|
-
'number'
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
expect(buildInformationPath).toBe(
|
|
67
|
-
'#/paper/edit/information/01?metadata=number&backgroundPath=$/path'
|
|
68
|
-
)
|
|
69
|
-
expect(buildPagePath).toBe('#/paper/edit/page/01?backgroundPath=/path')
|
|
70
|
-
})
|
|
71
|
-
})
|
|
72
|
-
describe('isEditableAttribute', () => {
|
|
73
|
-
const makeFile = ({ fromConnector } = {}) => ({
|
|
74
|
-
_id: '00',
|
|
75
|
-
name: 'file',
|
|
76
|
-
cozyMetadata: fromConnector ? { sourceAccount: '123' } : {}
|
|
77
|
-
})
|
|
78
|
-
describe('file provided by a Connector', () => {
|
|
79
|
-
it('"issueDate" should not be a editable attribute', () => {
|
|
80
|
-
const issueDate = isEditableAttribute(
|
|
81
|
-
'issueDate',
|
|
82
|
-
makeFile({ fromConnector: true })
|
|
83
|
-
)
|
|
84
|
-
expect(issueDate).toBe(false)
|
|
85
|
-
})
|
|
86
|
-
it('"number" should be an editable attribute', () => {
|
|
87
|
-
const number = isEditableAttribute(
|
|
88
|
-
'number',
|
|
89
|
-
makeFile({ fromConnector: true })
|
|
90
|
-
)
|
|
91
|
-
expect(number).toBe(true)
|
|
92
|
-
})
|
|
93
|
-
it('"datetime" should not be an editable attribute', () => {
|
|
94
|
-
const datetime = isEditableAttribute('datetime', makeFile())
|
|
95
|
-
expect(datetime).toBe(false)
|
|
96
|
-
})
|
|
97
|
-
it('"qualification" should not be an editable attribute', () => {
|
|
98
|
-
const qualification = isEditableAttribute('qualification', makeFile())
|
|
99
|
-
expect(qualification).toBe(false)
|
|
100
|
-
})
|
|
101
|
-
})
|
|
102
|
-
describe('file NOT provided by a Connector', () => {
|
|
103
|
-
it('"issueDate" should not be a editable attribute', () => {
|
|
104
|
-
const issueDate = isEditableAttribute('issueDate', makeFile())
|
|
105
|
-
expect(issueDate).toBe(true)
|
|
106
|
-
})
|
|
107
|
-
it('"number" should be a editable attribute', () => {
|
|
108
|
-
const number = isEditableAttribute('number', makeFile())
|
|
109
|
-
expect(number).toBe(true)
|
|
110
|
-
})
|
|
111
|
-
it('"datetime" should not be an editable attribute', () => {
|
|
112
|
-
const datetime = isEditableAttribute('datetime', makeFile())
|
|
113
|
-
expect(datetime).toBe(false)
|
|
114
|
-
})
|
|
115
|
-
it('"qualification" should not be an editable attribute', () => {
|
|
116
|
-
const qualification = isEditableAttribute('qualification', makeFile())
|
|
117
|
-
expect(qualification).toBe(false)
|
|
118
|
-
})
|
|
119
|
-
})
|
|
120
|
-
})
|
|
121
|
-
describe('removeFilenameFromPath', () => {
|
|
122
|
-
it('should handle all types of path', () => {
|
|
123
|
-
expect(removeFilenameFromPath('/folder/7IsD.gif', '7IsD.gif')).toBe(
|
|
124
|
-
'/folder'
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
expect(removeFilenameFromPath('/7IsD.gif', '7IsD.gif')).toBe('/')
|
|
128
|
-
|
|
129
|
-
expect(removeFilenameFromPath('//7IsD.gif', '7IsD.gif')).toBe('/')
|
|
130
|
-
|
|
131
|
-
expect(removeFilenameFromPath('/7IsD.gif/7IsD.gif', '7IsD.gif')).toBe(
|
|
132
|
-
'/7IsD.gif'
|
|
133
|
-
)
|
|
134
|
-
})
|
|
135
|
-
})
|
|
136
|
-
})
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types'
|
|
2
|
-
import React, { Component } from 'react'
|
|
3
|
-
|
|
4
|
-
import NoNetworkViewer from '../ViewersByFile/NoNetworkViewer'
|
|
5
|
-
import ViewerSpinner from '../components/ViewerSpinner'
|
|
6
|
-
import { isFileEncrypted } from '../helpers'
|
|
7
|
-
|
|
8
|
-
const TTL = 6000
|
|
9
|
-
|
|
10
|
-
const LOADING = 'LOADING'
|
|
11
|
-
const LOADED = 'LOADED'
|
|
12
|
-
const FAILED = 'FAILED'
|
|
13
|
-
|
|
14
|
-
const withFileUrl = BaseComponent =>
|
|
15
|
-
class withFileUrlClass extends Component {
|
|
16
|
-
state = {
|
|
17
|
-
status: LOADING,
|
|
18
|
-
downloadUrl: null
|
|
19
|
-
}
|
|
20
|
-
static contextTypes = {
|
|
21
|
-
client: PropTypes.object.isRequired
|
|
22
|
-
}
|
|
23
|
-
UNSAFE_componentWillMount() {
|
|
24
|
-
this.loadDownloadUrl()
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
28
|
-
if (
|
|
29
|
-
nextProps.file.id !== this.props.file.id ||
|
|
30
|
-
nextProps.url !== this.props.url
|
|
31
|
-
) {
|
|
32
|
-
this.reset()
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
componentDidUpdate() {
|
|
37
|
-
if (this.state.status === LOADING && !this.timeout) {
|
|
38
|
-
this.loadDownloadUrl()
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
async loadDownloadUrl() {
|
|
43
|
-
const { file, url } = this.props
|
|
44
|
-
this.timeout = setTimeout(
|
|
45
|
-
() => this.setState(state => ({ ...state, status: FAILED })),
|
|
46
|
-
TTL
|
|
47
|
-
)
|
|
48
|
-
try {
|
|
49
|
-
if (isFileEncrypted(file)) {
|
|
50
|
-
// The download link cannot be provided by the stack if the file is encrypted
|
|
51
|
-
if (url) {
|
|
52
|
-
this.clearTimeout()
|
|
53
|
-
this.setState({ downloadUrl: url, status: LOADED })
|
|
54
|
-
}
|
|
55
|
-
return
|
|
56
|
-
}
|
|
57
|
-
const downloadUrl = await this.getDownloadLink(file)
|
|
58
|
-
this.clearTimeout()
|
|
59
|
-
this.setState({ downloadUrl, status: LOADED })
|
|
60
|
-
} catch (err) {
|
|
61
|
-
this.clearTimeout()
|
|
62
|
-
this.setState(state => ({ ...state, status: FAILED }))
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
getDownloadLink(file) {
|
|
67
|
-
return this.context.client
|
|
68
|
-
.collection('io.cozy.files')
|
|
69
|
-
.getDownloadLinkById(file._id, file.name)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
clearTimeout() {
|
|
73
|
-
clearTimeout(this.timeout)
|
|
74
|
-
this.timeout = null
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
reset = () => {
|
|
78
|
-
this.clearTimeout()
|
|
79
|
-
this.setState({ status: LOADING, downloadUrl: null })
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
render() {
|
|
83
|
-
if (this.state.status === LOADING) {
|
|
84
|
-
return <ViewerSpinner />
|
|
85
|
-
}
|
|
86
|
-
if (this.state.status === FAILED) {
|
|
87
|
-
return <NoNetworkViewer onReload={this.reset} />
|
|
88
|
-
}
|
|
89
|
-
return <BaseComponent {...this.props} url={this.state.downloadUrl} />
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export default withFileUrl
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { getReferencedBy, useQuery, isQueryLoading } from 'cozy-client'
|
|
2
|
-
|
|
3
|
-
import { buildContactByIdsQuery } from '../queries'
|
|
4
|
-
|
|
5
|
-
const useReferencedContactName = file => {
|
|
6
|
-
const contactIds = getReferencedBy(file, 'io.cozy.contacts').map(
|
|
7
|
-
ref => ref.id
|
|
8
|
-
)
|
|
9
|
-
const isContactByIdsQueryEnabled = contactIds.length > 0
|
|
10
|
-
|
|
11
|
-
const contactByIdsQuery = buildContactByIdsQuery(contactIds)
|
|
12
|
-
const { data: contacts, ...contactsQueryResult } = useQuery(
|
|
13
|
-
contactByIdsQuery.definition,
|
|
14
|
-
{
|
|
15
|
-
...contactByIdsQuery.options,
|
|
16
|
-
enabled: isContactByIdsQueryEnabled
|
|
17
|
-
}
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
const isLoadingContacts =
|
|
21
|
-
isContactByIdsQueryEnabled &&
|
|
22
|
-
(isQueryLoading(contactsQueryResult) || contactsQueryResult.hasMore)
|
|
23
|
-
|
|
24
|
-
return { contacts, isLoadingContacts }
|
|
25
|
-
}
|
|
26
|
-
export default useReferencedContactName
|
package/react/Viewer/index.jsx
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import ViewerContainer from './ViewerContainer'
|
|
2
|
-
|
|
3
|
-
export { default as Viewer } from './Viewer'
|
|
4
|
-
export { default as ViewerContainer } from './ViewerContainer'
|
|
5
|
-
export * as toolbarPropsPropType from './proptypes'
|
|
6
|
-
export { default as ViewerWithCustomPanelAndFooter } from './ViewerWithCustomPanelAndFooter'
|
|
7
|
-
export { default as ToolbarButtons } from './components/ToolbarButtons'
|
|
8
|
-
export { default as FooterActionButtons } from './Footer/FooterActionButtons'
|
|
9
|
-
export { default as ForwardButton } from './Footer/ForwardButton'
|
|
10
|
-
export { default as ForwardOrDownloadButton } from './Footer/ForwardOrDownloadButton'
|
|
11
|
-
|
|
12
|
-
export default ViewerContainer
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"Viewer": {
|
|
3
|
-
"actions": {
|
|
4
|
-
"download": "Download",
|
|
5
|
-
"forward": "Send"
|
|
6
|
-
},
|
|
7
|
-
"alert": {
|
|
8
|
-
"preparing": "Preparing your files…"
|
|
9
|
-
},
|
|
10
|
-
"close": "close",
|
|
11
|
-
"download": "Download",
|
|
12
|
-
"complete": "Complete the document",
|
|
13
|
-
"noImage": "No image",
|
|
14
|
-
"error": {
|
|
15
|
-
"downloadFile": {
|
|
16
|
-
"offline": "You should be connected to download this file"
|
|
17
|
-
},
|
|
18
|
-
"generic": "An error occurred when opening this file, please try again.",
|
|
19
|
-
"missing": "This file is missing",
|
|
20
|
-
"network": "This file could not be loaded. Do you have a working internet connection right now?"
|
|
21
|
-
},
|
|
22
|
-
"goto": "Go to %{url}",
|
|
23
|
-
"next": "Next",
|
|
24
|
-
"openWith": "Open with...",
|
|
25
|
-
"openInOnlyOffice": "Open with Only Office",
|
|
26
|
-
"panel": {
|
|
27
|
-
"certifications": {
|
|
28
|
-
"carbonCopy": {
|
|
29
|
-
"title": "Carbon Copy",
|
|
30
|
-
"caption": "Indicates whether the document is defined as \"authentic and original\" by Cozy Cloud, the host of your Cozy, as it can claim that it comes directly from a third-party service, without having undergone any modification."
|
|
31
|
-
},
|
|
32
|
-
"electronicSafe": {
|
|
33
|
-
"title": "Electronic Safe",
|
|
34
|
-
"caption": "Indicates whether the original document is secured by your personal digital safe with the certifications that give it probative value and a 50-year retention guarantee beyond its deposit."
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
"qualification": {
|
|
38
|
-
"actions": {
|
|
39
|
-
"copy": "Copy",
|
|
40
|
-
"copyClipboard": "Copy to clipboard",
|
|
41
|
-
"edit": "Edit"
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
"expiration": {
|
|
45
|
-
"dismiss": "I understood"
|
|
46
|
-
},
|
|
47
|
-
"title": "Useful information"
|
|
48
|
-
},
|
|
49
|
-
"previous": "Previous",
|
|
50
|
-
"retry": "Retry",
|
|
51
|
-
"scaledown": "Zoom out",
|
|
52
|
-
"scaleup": "Zoom in",
|
|
53
|
-
"share": {
|
|
54
|
-
"title": "Link to my document %{name}",
|
|
55
|
-
"text": "Here is a link to my document %{name}: ",
|
|
56
|
-
"error": "Problem with link recovery: %{error}",
|
|
57
|
-
"success": "Your file has been shared with success"
|
|
58
|
-
},
|
|
59
|
-
"snackbar": {
|
|
60
|
-
"copiedToClipboard": {
|
|
61
|
-
"success": "Copied to clipboard",
|
|
62
|
-
"error": "Cannot copy to clipboard"
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"Viewer": {
|
|
3
|
-
"actions": {
|
|
4
|
-
"download": "Télécharger",
|
|
5
|
-
"forward": "Envoyer"
|
|
6
|
-
},
|
|
7
|
-
"alert": {
|
|
8
|
-
"preparing": "Preparation de vos fichiers…"
|
|
9
|
-
},
|
|
10
|
-
"close": "Fermer",
|
|
11
|
-
"download": "Télécharger",
|
|
12
|
-
"complete": "Compléter le document",
|
|
13
|
-
"noImage": "Aucune image",
|
|
14
|
-
"error": {
|
|
15
|
-
"downloadFile": {
|
|
16
|
-
"offline": "Vous devez être connecté pour télécharger ce fichier"
|
|
17
|
-
},
|
|
18
|
-
"generic": "Une erreur s'est produite lors de l'ouverture de ce fichier, veuillez réessayer.",
|
|
19
|
-
"missing": "Le fichier est manquant",
|
|
20
|
-
"network": "Ce fichier n'a pas pu être chargé. Avez-vous une connexion internet qui fonctionne actuellement ?"
|
|
21
|
-
},
|
|
22
|
-
"goto": "Ouvrir %{url}",
|
|
23
|
-
"next": "Suivante",
|
|
24
|
-
"openWith": "Ouvrir avec...",
|
|
25
|
-
"openInOnlyOffice": "Ouvrir avec Only Office",
|
|
26
|
-
"panel": {
|
|
27
|
-
"certifications": {
|
|
28
|
-
"carbonCopy": {
|
|
29
|
-
"title": "Copie conforme",
|
|
30
|
-
"caption": "Le document est défini \"authentique et original\" par Cozy Cloud, l'hébergeur de votre Cozy, car il peut affirmer qu'il provient directement des services de son émetteur sans avoir subi aucune modification."
|
|
31
|
-
},
|
|
32
|
-
"electronicSafe": {
|
|
33
|
-
"title": "Coffre-fort électronique",
|
|
34
|
-
"caption": "Indique si le document original est sécurisé par votre coffre-fort numérique personnel avec les certifications qui lui confèrent une valeur probante et une garantie de conservation de 50 ans au-delà de son dépôt."
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
"qualification": {
|
|
38
|
-
"actions": {
|
|
39
|
-
"copy": "Copier",
|
|
40
|
-
"copyClipboard": "Copier dans le presse-papier",
|
|
41
|
-
"edit": "Modifier"
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
"expiration": {
|
|
45
|
-
"dismiss": "J'ai compris"
|
|
46
|
-
},
|
|
47
|
-
"title": "Informations utiles"
|
|
48
|
-
},
|
|
49
|
-
"previous": "Précédente",
|
|
50
|
-
"retry": "Réessayer",
|
|
51
|
-
"scaledown": "Zoom arrière",
|
|
52
|
-
"scaleup": "Zoom avant",
|
|
53
|
-
"share": {
|
|
54
|
-
"title": "Lien vers mon document %{name}",
|
|
55
|
-
"text": "Voici un lien vers mon document %{name} : ",
|
|
56
|
-
"error": "Problème avec la récupération du lien : %{error}",
|
|
57
|
-
"success": "Votre fichier a été partagé avec succès"
|
|
58
|
-
},
|
|
59
|
-
"snackbar": {
|
|
60
|
-
"copiedToClipboard": {
|
|
61
|
-
"success": "Copié dans le presse-papier",
|
|
62
|
-
"error": "Impossible de copier dans le presse-papier"
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types'
|
|
2
|
-
|
|
3
|
-
export const toolbarPropsPropType = {
|
|
4
|
-
/** Whether to show the toolbar or not. Note that the built-in close button is in the toolbar */
|
|
5
|
-
showToolbar: PropTypes.bool,
|
|
6
|
-
/** Whether to show close button in toolbar */
|
|
7
|
-
showClose: PropTypes.bool,
|
|
8
|
-
/** React reference of the toolbar node */
|
|
9
|
-
toolbarRef: PropTypes.object,
|
|
10
|
-
/** Whether to show file path below his name */
|
|
11
|
-
showFilePath: PropTypes.bool
|
|
12
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import React, { createContext, useContext } from 'react'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @typedef {object} useActionMenuContextReturn
|
|
5
|
-
* @property {string} information
|
|
6
|
-
* @property {string} page
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const ActionMenuContext = createContext()
|
|
10
|
-
|
|
11
|
-
const ActionMenuProvider = ({ children, editPathByModelProps = {} }) => {
|
|
12
|
-
return (
|
|
13
|
-
<ActionMenuContext.Provider value={editPathByModelProps}>
|
|
14
|
-
{children}
|
|
15
|
-
</ActionMenuContext.Provider>
|
|
16
|
-
)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @returns {useActionMenuContextReturn}
|
|
21
|
-
*/
|
|
22
|
-
const useActionMenuContext = () => {
|
|
23
|
-
const actionMenuContext = useContext(ActionMenuContext)
|
|
24
|
-
if (!actionMenuContext) {
|
|
25
|
-
throw new Error(
|
|
26
|
-
'ActionMenuContext must be used within a ActionMenuProvider'
|
|
27
|
-
)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return actionMenuContext
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export default useActionMenuContext
|
|
34
|
-
|
|
35
|
-
export { ActionMenuProvider }
|
package/react/Viewer/queries.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Q, fetchPolicies } from 'cozy-client'
|
|
2
|
-
|
|
3
|
-
const defaultFetchPolicy = fetchPolicies.olderThan(30 * 1000)
|
|
4
|
-
|
|
5
|
-
export const buildContactByIdsQuery = (ids = []) => ({
|
|
6
|
-
definition: () => Q('io.cozy.contacts').getByIds(ids),
|
|
7
|
-
options: {
|
|
8
|
-
as: `io.cozy.contacts/${ids.join('')}`,
|
|
9
|
-
fetchPolicy: defaultFetchPolicy
|
|
10
|
-
}
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
export const buildFileByIdQuery = fileId => ({
|
|
14
|
-
definition: () => Q('io.cozy.files').getById(fileId),
|
|
15
|
-
options: {
|
|
16
|
-
as: `io.cozy.files/${fileId}`,
|
|
17
|
-
fetchPolicy: defaultFetchPolicy,
|
|
18
|
-
singleDocData: true
|
|
19
|
-
}
|
|
20
|
-
})
|
package/react/Viewer/styles.styl
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
@require 'settings/breakpoints.styl'
|
|
2
|
-
@require './vars.styl'
|
|
3
|
-
|
|
4
|
-
.viewer-wrapper
|
|
5
|
-
position absolute
|
|
6
|
-
left 0
|
|
7
|
-
right 0
|
|
8
|
-
top 0
|
|
9
|
-
bottom 0
|
|
10
|
-
z-index var(--zIndex-overlay)
|
|
11
|
-
overflow hidden
|
|
12
|
-
background var(--charcoalGrey)
|
|
13
|
-
color var(--white)
|
|
14
|
-
display flex
|
|
15
|
-
|
|
16
|
-
.flagship-app &
|
|
17
|
-
padding-top var(--flagship-top-height)
|
|
18
|
-
padding-bottom var(--flagship-bottom-height)
|
|
19
|
-
|
|
20
|
-
+medium-screen()
|
|
21
|
-
color var(--primaryTextColor)
|
|
22
|
-
background var(--paperBackgroundColor)
|
package/react/Viewer/vars.styl
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { BottomSheetItem } from "cozy-ui/transpiled/react/BottomSheet";
|
|
4
|
-
import getPanelBlocks, { getPanelBlocksSpecs } from "cozy-ui/transpiled/react/Viewer/Panel/getPanelBlocks";
|
|
5
|
-
|
|
6
|
-
var BottomSheetContent = function BottomSheetContent(_ref) {
|
|
7
|
-
var file = _ref.file,
|
|
8
|
-
isPublic = _ref.isPublic;
|
|
9
|
-
var panelBlocks = getPanelBlocks({
|
|
10
|
-
panelBlocksSpecs: getPanelBlocksSpecs(isPublic),
|
|
11
|
-
file: file
|
|
12
|
-
});
|
|
13
|
-
return panelBlocks.map(function (PanelBlock, index) {
|
|
14
|
-
return /*#__PURE__*/React.createElement(BottomSheetItem, {
|
|
15
|
-
key: index,
|
|
16
|
-
disableGutters: true,
|
|
17
|
-
disableElevation: index === panelBlocks.length - 1
|
|
18
|
-
}, /*#__PURE__*/React.createElement(PanelBlock, {
|
|
19
|
-
file: file
|
|
20
|
-
}));
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
BottomSheetContent.propTypes = {
|
|
25
|
-
file: PropTypes.object.isRequired,
|
|
26
|
-
isPublic: PropTypes.bool
|
|
27
|
-
};
|
|
28
|
-
export default BottomSheetContent;
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import { useClient } from 'cozy-client';
|
|
6
|
-
import Button from "cozy-ui/transpiled/react/Buttons";
|
|
7
|
-
import Icon from "cozy-ui/transpiled/react/Icon";
|
|
8
|
-
import IconButton from "cozy-ui/transpiled/react/IconButton";
|
|
9
|
-
import DownloadIcon from "cozy-ui/transpiled/react/Icons/Download";
|
|
10
|
-
import Alerter from "cozy-ui/transpiled/react/deprecated/Alerter";
|
|
11
|
-
import { useI18n } from "cozy-ui/transpiled/react/providers/I18n";
|
|
12
|
-
|
|
13
|
-
var DownloadButton = function DownloadButton(_ref) {
|
|
14
|
-
var file = _ref.file,
|
|
15
|
-
variant = _ref.variant;
|
|
16
|
-
var client = useClient();
|
|
17
|
-
|
|
18
|
-
var _useI18n = useI18n(),
|
|
19
|
-
t = _useI18n.t;
|
|
20
|
-
|
|
21
|
-
var icon = /*#__PURE__*/React.createElement(Icon, {
|
|
22
|
-
icon: DownloadIcon
|
|
23
|
-
});
|
|
24
|
-
var label = t('Viewer.download');
|
|
25
|
-
|
|
26
|
-
var handleClick = /*#__PURE__*/function () {
|
|
27
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
28
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
29
|
-
while (1) {
|
|
30
|
-
switch (_context.prev = _context.next) {
|
|
31
|
-
case 0:
|
|
32
|
-
_context.prev = 0;
|
|
33
|
-
_context.next = 3;
|
|
34
|
-
return client.collection('io.cozy.files').download(file);
|
|
35
|
-
|
|
36
|
-
case 3:
|
|
37
|
-
_context.next = 8;
|
|
38
|
-
break;
|
|
39
|
-
|
|
40
|
-
case 5:
|
|
41
|
-
_context.prev = 5;
|
|
42
|
-
_context.t0 = _context["catch"](0);
|
|
43
|
-
Alerter.info('Viewer.error.generic');
|
|
44
|
-
|
|
45
|
-
case 8:
|
|
46
|
-
case "end":
|
|
47
|
-
return _context.stop();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}, _callee, null, [[0, 5]]);
|
|
51
|
-
}));
|
|
52
|
-
|
|
53
|
-
return function handleClick() {
|
|
54
|
-
return _ref2.apply(this, arguments);
|
|
55
|
-
};
|
|
56
|
-
}();
|
|
57
|
-
|
|
58
|
-
if (variant === 'iconButton') {
|
|
59
|
-
return /*#__PURE__*/React.createElement(IconButton, {
|
|
60
|
-
className: "u-white",
|
|
61
|
-
"aria-label": label,
|
|
62
|
-
onClick: handleClick
|
|
63
|
-
}, icon);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (variant === 'buttonIcon') {
|
|
67
|
-
return /*#__PURE__*/React.createElement(Button, {
|
|
68
|
-
variant: "secondary",
|
|
69
|
-
label: icon,
|
|
70
|
-
"aria-label": label,
|
|
71
|
-
onClick: handleClick
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return /*#__PURE__*/React.createElement(Button, {
|
|
76
|
-
fullWidth: true,
|
|
77
|
-
variant: "secondary",
|
|
78
|
-
startIcon: icon,
|
|
79
|
-
label: label,
|
|
80
|
-
onClick: handleClick
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
DownloadButton.propTypes = {
|
|
85
|
-
file: PropTypes.object,
|
|
86
|
-
variant: PropTypes.oneOf(['default', 'iconButton', 'buttonIcon'])
|
|
87
|
-
};
|
|
88
|
-
DownloadButton.defaultProptypes = {
|
|
89
|
-
variant: 'default'
|
|
90
|
-
};
|
|
91
|
-
export default DownloadButton;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
import { cloneElement } from 'react';
|
|
3
|
-
import { mapToAllChildren } from "cozy-ui/transpiled/react/Viewer/Footer/helpers";
|
|
4
|
-
|
|
5
|
-
var FooterActionButtons = function FooterActionButtons(_ref) {
|
|
6
|
-
var children = _ref.children,
|
|
7
|
-
file = _ref.file;
|
|
8
|
-
if (!children) return null;
|
|
9
|
-
return mapToAllChildren(children, function (child) {
|
|
10
|
-
return /*#__PURE__*/cloneElement(child, {
|
|
11
|
-
file: file
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
FooterActionButtons.displayName = 'FooterActionButtons';
|
|
17
|
-
FooterActionButtons.propTypes = {
|
|
18
|
-
children: PropTypes.oneOfType([PropTypes.node, PropTypes.arrayOf(PropTypes.node)]),
|
|
19
|
-
file: PropTypes.object
|
|
20
|
-
};
|
|
21
|
-
export default FooterActionButtons;
|