Skip to content

Commit ff4a746

Browse files
committed
feat: Remove Viewer
BREAKING CHANGE: if you want to use the Viewer, you must import components from `cozy-viewer`. So replace `import Something from 'cozy-ui/transpiled/react/Viewer/...'` by `import Something from 'cozy-viewer/...'`
1 parent 9471b03 commit ff4a746

File tree

99 files changed

+71
-6395
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+71
-6395
lines changed

docs/styleguide.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ module.exports = {
9595
'../react/SquareAppIcon',
9696
'../react/QualificationGrid',
9797
'../react/QualificationItem',
98-
'../react/UploadQueue',
99-
'../react/Viewer'
98+
'../react/UploadQueue'
10099
]
101100
},
102101
{

react/FileImageLoader/Readme.md

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,77 @@
33
A component to get the image in `links` prop of a file, according to its class (could be `image` or `pdf`).
44

55
```jsx
6-
import DemoProvider from 'cozy-ui/transpiled/react/Viewer/docs/DemoProvider'
7-
6+
import DemoProvider from 'cozy-ui/transpiled/react/providers/DemoProvider'
87
import FileImageLoader from 'cozy-ui/transpiled/react/FileImageLoader'
98
import Icon from 'cozy-ui/transpiled/react/Icon'
109
import FileDuotoneIcon from "cozy-ui/transpiled/react/Icons/FileDuotone"
1110
import BankIcon from "cozy-ui/transpiled/react/Icons/Bank"
1211
import CloudWallpaper from 'cozy-ui/docs/cloud-wallpaper.jpg'
1312

13+
const demoTextFileResponse = {
14+
text: () => new Promise(resolve => resolve('Hello World !'))
15+
}
16+
17+
const demoFilesByClass = {
18+
pdf: 'https://raw.githubusercontent.com/rospdf/pdf-php/2ccf7591fc2f18e63342ebfedad7997b08c34ed2/readme.pdf',
19+
audio: 'https://viewerdemo.cozycloud.cc/Z.mp3',
20+
video: 'https://viewerdemo.cozycloud.cc/Nextcloud.mp4',
21+
text: 'https://viewerdemo.cozycloud.cc/notes.md'
22+
}
23+
24+
const mockClient = {
25+
plugins: {
26+
realtime: {
27+
subscribe: () => {},
28+
unsubscribe: () => {},
29+
unsubscribeAll: () => {}
30+
}
31+
},
32+
on: () => {},
33+
collection: () => ({
34+
getDownloadLinkById: id =>
35+
new Promise(resolve => resolve(demoFilesByClass[id])),
36+
download: () =>
37+
alert(
38+
"This is a demo, there's no actual Cozy to download the file from ¯\\_(ツ)_/¯"
39+
),
40+
get: () =>
41+
new Promise(resolve =>
42+
resolve({
43+
data: {
44+
links: {
45+
large: CloudWallpaper
46+
}
47+
}
48+
})
49+
)
50+
}),
51+
getStackClient: () => ({
52+
uri: '',
53+
fetch: () => new Promise(resolve => resolve(demoTextFileResponse))
54+
}),
55+
getClient: () => mockClient,
56+
store: {
57+
getState: () => {},
58+
subscribe: () => {},
59+
unsubscribe: () => {}
60+
},
61+
getQueryFromState: queryName => {
62+
if (queryName === 'io.cozy.files/parent_folder') {
63+
return {
64+
data: {
65+
_id: 'parent_id',
66+
path: '/Parent'
67+
}
68+
}
69+
}
70+
},
71+
query: () => ({
72+
data: [{ attributes: { slug: 'mespapiers' }, links: { related: '' } }]
73+
}),
74+
getInstanceOptions: () => ({ app: { slug: 'mespapiers' }, subdomain: 'flat' })
75+
}
76+
1477
const file = {
1578
_id: 'image',
1679
class: 'image',
@@ -31,7 +94,7 @@ const FallbackComp = () => {
3194

3295
;
3396

34-
<DemoProvider>
97+
<DemoProvider client={mockClient}>
3598
<FileImageLoader
3699
file={file}
37100
linkType="large"

react/FileImageLoader/index.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import PropTypes from 'prop-types'
22
import { Component } from 'react'
33

44
import { withClient } from 'cozy-client'
5+
import { isEncrypted } from 'cozy-client/dist/models/file'
56
import logger from 'cozy-logger'
67

78
const PENDING = 'PENDING'
@@ -12,8 +13,7 @@ const FAILED = 'FAILED'
1213
const GET_LINK = 'GET_LINK'
1314

1415
import { checkImageSource } from './checkImageSource'
15-
import { isFileEncrypted } from '../Viewer/helpers'
16-
import { EncryptedContext } from '../Viewer/providers/EncryptedProvider'
16+
import { EncryptedContext } from '../providers/Encrypted'
1717

1818
export class FileImageLoader extends Component {
1919
state = {
@@ -60,7 +60,7 @@ export class FileImageLoader extends Component {
6060

6161
loadNextSrc(lastError = null) {
6262
const { file } = this.props
63-
if (isFileEncrypted(file)) {
63+
if (isEncrypted(file)) {
6464
// No link available for encrypted files
6565
return
6666
}

react/FileImageLoader/index.spec.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import logger from 'cozy-logger'
66

77
import { FileImageLoader } from '.'
88
import { checkImageSource } from './checkImageSource'
9-
import EncryptedProvider from '../Viewer/providers/EncryptedProvider'
9+
import EncryptedProvider from '../providers/Encrypted'
1010

1111
jest.mock('./checkImageSource', () => ({
1212
...jest.requireActual('./checkImageSource'),

react/Viewer/Footer/BottomSheetContent.jsx

Lines changed: 0 additions & 29 deletions
This file was deleted.

react/Viewer/Footer/DownloadButton.jsx

Lines changed: 0 additions & 67 deletions
This file was deleted.

react/Viewer/Footer/FooterActionButtons.jsx

Lines changed: 0 additions & 22 deletions
This file was deleted.

react/Viewer/Footer/FooterActionButtons.spec.jsx

Lines changed: 0 additions & 30 deletions
This file was deleted.

react/Viewer/Footer/FooterContent.jsx

Lines changed: 0 additions & 99 deletions
This file was deleted.

0 commit comments

Comments
 (0)