Skip to content

Commit

Permalink
feat: Remove Viewer
Browse files Browse the repository at this point in the history
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/...'`
  • Loading branch information
JF-Cozy committed Oct 24, 2024
1 parent 612cff6 commit 7d2b7ef
Show file tree
Hide file tree
Showing 99 changed files with 71 additions and 6,395 deletions.
3 changes: 1 addition & 2 deletions docs/styleguide.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ module.exports = {
'../react/SquareAppIcon',
'../react/QualificationGrid',
'../react/QualificationItem',
'../react/UploadQueue',
'../react/Viewer'
'../react/UploadQueue'
]
},
{
Expand Down
69 changes: 66 additions & 3 deletions react/FileImageLoader/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,77 @@
A component to get the image in `links` prop of a file, according to its class (could be `image` or `pdf`).

```jsx
import DemoProvider from 'cozy-ui/transpiled/react/Viewer/docs/DemoProvider'

import DemoProvider from 'cozy-ui/transpiled/react/providers/DemoProvider'
import FileImageLoader from 'cozy-ui/transpiled/react/FileImageLoader'
import Icon from 'cozy-ui/transpiled/react/Icon'
import FileDuotoneIcon from "cozy-ui/transpiled/react/Icons/FileDuotone"
import BankIcon from "cozy-ui/transpiled/react/Icons/Bank"
import CloudWallpaper from 'cozy-ui/docs/cloud-wallpaper.jpg'

const demoTextFileResponse = {
text: () => new Promise(resolve => resolve('Hello World !'))
}

const demoFilesByClass = {
pdf: 'https://raw.githubusercontent.com/rospdf/pdf-php/2ccf7591fc2f18e63342ebfedad7997b08c34ed2/readme.pdf',
audio: 'https://viewerdemo.cozycloud.cc/Z.mp3',
video: 'https://viewerdemo.cozycloud.cc/Nextcloud.mp4',
text: 'https://viewerdemo.cozycloud.cc/notes.md'
}

const mockClient = {
plugins: {
realtime: {
subscribe: () => {},
unsubscribe: () => {},
unsubscribeAll: () => {}
}
},
on: () => {},
collection: () => ({
getDownloadLinkById: id =>
new Promise(resolve => resolve(demoFilesByClass[id])),
download: () =>
alert(
"This is a demo, there's no actual Cozy to download the file from ¯\\_(ツ)_/¯"
),
get: () =>
new Promise(resolve =>
resolve({
data: {
links: {
large: CloudWallpaper
}
}
})
)
}),
getStackClient: () => ({
uri: '',
fetch: () => new Promise(resolve => resolve(demoTextFileResponse))
}),
getClient: () => mockClient,
store: {
getState: () => {},
subscribe: () => {},
unsubscribe: () => {}
},
getQueryFromState: queryName => {
if (queryName === 'io.cozy.files/parent_folder') {
return {
data: {
_id: 'parent_id',
path: '/Parent'
}
}
}
},
query: () => ({
data: [{ attributes: { slug: 'mespapiers' }, links: { related: '' } }]
}),
getInstanceOptions: () => ({ app: { slug: 'mespapiers' }, subdomain: 'flat' })
}

const file = {
_id: 'image',
class: 'image',
Expand All @@ -31,7 +94,7 @@ const FallbackComp = () => {

;

<DemoProvider>
<DemoProvider client={mockClient}>
<FileImageLoader
file={file}
linkType="large"
Expand Down
6 changes: 3 additions & 3 deletions react/FileImageLoader/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import PropTypes from 'prop-types'
import { Component } from 'react'

import { withClient } from 'cozy-client'
import { isEncrypted } from 'cozy-client/dist/models/file'
import logger from 'cozy-logger'

const PENDING = 'PENDING'
Expand All @@ -12,8 +13,7 @@ const FAILED = 'FAILED'
const GET_LINK = 'GET_LINK'

import { checkImageSource } from './checkImageSource'
import { isFileEncrypted } from '../Viewer/helpers'
import { EncryptedContext } from '../Viewer/providers/EncryptedProvider'
import { EncryptedContext } from '../providers/Encrypted'

export class FileImageLoader extends Component {
state = {
Expand Down Expand Up @@ -60,7 +60,7 @@ export class FileImageLoader extends Component {

loadNextSrc(lastError = null) {
const { file } = this.props
if (isFileEncrypted(file)) {
if (isEncrypted(file)) {
// No link available for encrypted files
return
}
Expand Down
2 changes: 1 addition & 1 deletion react/FileImageLoader/index.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import logger from 'cozy-logger'

import { FileImageLoader } from '.'
import { checkImageSource } from './checkImageSource'
import EncryptedProvider from '../Viewer/providers/EncryptedProvider'
import EncryptedProvider from '../providers/Encrypted'

jest.mock('./checkImageSource', () => ({
...jest.requireActual('./checkImageSource'),
Expand Down
29 changes: 0 additions & 29 deletions react/Viewer/Footer/BottomSheetContent.jsx

This file was deleted.

67 changes: 0 additions & 67 deletions react/Viewer/Footer/DownloadButton.jsx

This file was deleted.

22 changes: 0 additions & 22 deletions react/Viewer/Footer/FooterActionButtons.jsx

This file was deleted.

30 changes: 0 additions & 30 deletions react/Viewer/Footer/FooterActionButtons.spec.jsx

This file was deleted.

99 changes: 0 additions & 99 deletions react/Viewer/Footer/FooterContent.jsx

This file was deleted.

Loading

0 comments on commit 7d2b7ef

Please sign in to comment.