Skip to content

Commit

Permalink
feat(Viewer): Replace Encrypted provider by cozy-ui one
Browse files Browse the repository at this point in the history
and deal with DemoProvider too
  • Loading branch information
JF-Cozy committed Oct 24, 2024
1 parent e1278d2 commit aa81d02
Show file tree
Hide file tree
Showing 13 changed files with 12 additions and 37 deletions.
2 changes: 1 addition & 1 deletion packages/cozy-viewer/src/Footer/ForwardButton.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { isMobileApp } from 'cozy-device-helper'

import ForwardButton from './ForwardButton'
import { exportFilesNative } from './helpers'
import DemoProvider from '../docs/DemoProvider'
import DemoProvider from '../providers/DemoProvider'

jest.mock('cozy-device-helper')
jest.mock('cozy-client/dist/models/sharing', () => ({
Expand Down
2 changes: 1 addition & 1 deletion packages/cozy-viewer/src/NoViewer/NoViewer.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { render } from '@testing-library/react'
import React from 'react'

import NoViewer from './NoViewer'
import DemoProvider from '../docs/DemoProvider'
import DemoProvider from '../providers/DemoProvider'

const file = {
_id: 'notSupported',
Expand Down
2 changes: 1 addition & 1 deletion packages/cozy-viewer/src/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import { Media, Img, Bd } from 'cozy-ui/transpiled/react/deprecated/Media'
import Icon from 'cozy-ui/transpiled/react/Icon'
import CarbonCopyIcon from 'cozy-ui/transpiled/react/Icons/CarbonCopy'
// The DemoProvider inserts a fake cozy-client in the React context.
import DemoProvider from './docs/DemoProvider'
import DemoProvider from './providers/DemoProvider'
import Button from 'cozy-ui/transpiled/react/Buttons'
import DownloadIcon from 'cozy-ui/transpiled/react/Icons/Download'
import ShareIcon from 'cozy-ui/transpiled/react/Icons/Share'
Expand Down
2 changes: 1 addition & 1 deletion packages/cozy-viewer/src/ViewerContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { FileDoctype } from 'cozy-ui/transpiled/react/proptypes'
import AlertProvider from 'cozy-ui/transpiled/react/providers/Alert'
import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints'
import { useCozyTheme } from 'cozy-ui/transpiled/react/providers/CozyTheme'
import EncryptedProvider from 'cozy-ui/transpiled/react/providers/Encrypted'
import { useExtendI18n } from 'cozy-ui/transpiled/react/providers/I18n'

import Viewer from './Viewer'
Expand All @@ -15,7 +16,6 @@ import { isValidForPanel } from './helpers'
import { locales } from './locales'
import { toolbarPropsPropType } from './proptypes'
import { ActionMenuProvider } from './providers/ActionMenuProvider'
import EncryptedProvider from './providers/EncryptedProvider'
import styles from './styles.styl'

const ViewerContainer = props => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react'
import { BreakpointsProvider } from 'cozy-ui/transpiled/react/providers/Breakpoints'

import AudioViewer from './AudioViewer'
import DemoProvider from '../docs/DemoProvider'
import DemoProvider from '../providers/DemoProvider'

const file = {
_id: 'audio',
Expand Down
4 changes: 2 additions & 2 deletions packages/cozy-viewer/src/ViewersByFile/ImageViewer.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import React from 'react'

import { checkImageSource } from 'cozy-ui/transpiled/react/FileImageLoader/checkImageSource'
import { BreakpointsProvider } from 'cozy-ui/transpiled/react/providers/Breakpoints'
import EncryptedProvider from 'cozy-ui/transpiled/react/providers/Encrypted'

import ImageViewer from './ImageViewer'
import DemoProvider from '../docs/DemoProvider'
import EncryptedProvider from '../providers/EncryptedProvider'
import DemoProvider from '../providers/DemoProvider'

jest.mock('cozy-ui/transpiled/react/FileImageLoader/checkImageSource', () => ({
...jest.requireActual(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import React from 'react'

import { CozyProvider, createMockClient } from 'cozy-client'
import logger from 'cozy-logger'
import EncryptedProvider from 'cozy-ui/transpiled/react/providers/Encrypted'
import { I18n } from 'cozy-ui/transpiled/react/providers/I18n'

import { PdfMobileViewer } from './PdfMobileViewer'
import EncryptedProvider from '../providers/EncryptedProvider'

logger.error = logger.warn = jest.fn()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react'
import { BreakpointsProvider } from 'cozy-ui/transpiled/react/providers/Breakpoints'

import VideoViewer from './VideoViewer'
import DemoProvider from '../docs/DemoProvider'
import DemoProvider from '../providers/DemoProvider'

const file = {
_id: 'video',
Expand Down
2 changes: 1 addition & 1 deletion packages/cozy-viewer/src/components/Toolbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import PreviousIcon from 'cozy-ui/transpiled/react/Icons/Previous'
import MidEllipsis from 'cozy-ui/transpiled/react/MidEllipsis'
import Typography from 'cozy-ui/transpiled/react/Typography'
import withBreakpoints from 'cozy-ui/transpiled/react/helpers/withBreakpoints'
import { useEncrypted } from 'cozy-ui/transpiled/react/providers/Encrypted'
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
import { makeStyles } from 'cozy-ui/transpiled/react/styles'

import PrintButton from './PrintButton'
import { ToolbarFilePath } from './ToolbarFilePath'
import styles from './styles.styl'
import { extractChildrenCompByName } from '../Footer/helpers'
import { useEncrypted } from '../providers/EncryptedProvider'

const useClasses = makeStyles(theme => ({
iconButton: {
Expand Down
2 changes: 1 addition & 1 deletion packages/cozy-viewer/src/components/ViewerByFile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { isPlainText } from 'cozy-client/dist/models/file'
import { isMobile as isMobileDevice } from 'cozy-device-helper'
import withBreakpoints from 'cozy-ui/transpiled/react/helpers/withBreakpoints'
import { FileDoctype } from 'cozy-ui/transpiled/react/proptypes'
import { useEncrypted } from 'cozy-ui/transpiled/react/providers/Encrypted'

import NoViewer from '../NoViewer'
import AudioViewer from '../ViewersByFile/AudioViewer'
Expand All @@ -16,7 +17,6 @@ import PdfMobileViewer from '../ViewersByFile/PdfMobileViewer'
import ShortcutViewer from '../ViewersByFile/ShortcutViewer'
import TextViewer from '../ViewersByFile/TextViewer'
import VideoViewer from '../ViewersByFile/VideoViewer'
import { useEncrypted } from '../providers/EncryptedProvider'

const isBlankPaper = doc => doc.metadata?.paperProps?.isBlank

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ViewerByFile from './ViewerByFile'
import ViewerControls from './ViewerControls'

jest.mock('../ViewersByFile/AudioViewer', () => () => <div>AudioViewer</div>)
jest.mock('../providers/EncryptedProvider', () => ({
jest.mock('cozy-ui/transpiled/react/providers/Encrypted', () => ({
useEncrypted: () => ({ url: 'random' })
}))

Expand Down
25 changes: 0 additions & 25 deletions packages/cozy-viewer/src/providers/EncryptedProvider.jsx

This file was deleted.

0 comments on commit aa81d02

Please sign in to comment.