diff --git a/packages/cozy-viewer/package.json b/packages/cozy-viewer/package.json index c367b35f64..302a68f8a1 100644 --- a/packages/cozy-viewer/package.json +++ b/packages/cozy-viewer/package.json @@ -13,13 +13,17 @@ "url": "https://github.com/cozy/cozy-libs/issues" }, "scripts": { - "build": "rm -rf ./dist && tsc -p tsconfig-build.json && env BABEL_ENV=transpilation babel --extensions .ts,.tsx,.js,.jsx,.md,.styl,.json,.snap ./src -d ./dist --copy-files --no-copy-ignored --verbose", + "build": "yarn build:clean && yarn build:types && env BABEL_ENV=transpilation babel --extensions .ts,.tsx,.js,.jsx,.md,.styl,.json,.snap ./src -d ./dist --copy-files --no-copy-ignored --verbose", + "build:clean": "rm -rf ./dist", + "build:types": "tsc -p tsconfig-build.json", "start": "yarn build --watch", "prepublishOnly": "yarn build", "test": "env NODE_ENV=test jest", "lint": "cd .. && yarn eslint --ext js,jsx packages/cozy-viewer" }, "devDependencies": { + "@babel/cli": "7.16.8", + "@babel/core": "7.16.12", "@testing-library/jest-dom": "^5.14.1", "@testing-library/react": "11.2.7", "@testing-library/react-hooks": "^3.2.1", diff --git a/packages/cozy-viewer/src/ViewerContainer.jsx b/packages/cozy-viewer/src/ViewerContainer.jsx index 388b72fa4f..fa3a168497 100644 --- a/packages/cozy-viewer/src/ViewerContainer.jsx +++ b/packages/cozy-viewer/src/ViewerContainer.jsx @@ -29,9 +29,11 @@ const ViewerContainer = props => { children, componentsProps, isPublic, + currentIndex, + files, + currentURL, ...rest } = props - const { currentIndex, files, currentURL } = props const toolbarRef = createRef() const { isDesktop } = useBreakpoints() const [isReadOnly, setIsReadOnly] = useState(true) diff --git a/packages/cozy-viewer/src/components/Toolbar.jsx b/packages/cozy-viewer/src/components/Toolbar.jsx index e91d0fa991..696b734570 100644 --- a/packages/cozy-viewer/src/components/Toolbar.jsx +++ b/packages/cozy-viewer/src/components/Toolbar.jsx @@ -19,6 +19,7 @@ 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 { ToolbarFilePath } from './ToolbarFilePath' @@ -45,6 +46,7 @@ const Toolbar = ({ useSharingInfos() const { isOwner } = useSharingContext() const { setShowShareModal } = useShareModal() + const { url } = useEncrypted() const isCozySharing = window.location.pathname === '/preview' const isShareNotAdded = !loading && !isSharingShortcutCreated @@ -107,7 +109,12 @@ const Toolbar = ({ aria-label={t('Viewer.download')} label={t('Viewer.download')} startIcon={} - onClick={() => download.action([file], { client, webviewIntent })} + onClick={() => + download({ encryptedUrl: url }).action([file], { + client, + webviewIntent + }) + } /> )} diff --git a/yarn.lock b/yarn.lock index acdd20a14c..4660dccd4e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17658,6 +17658,8 @@ __metadata: version: 0.0.0-use.local resolution: "cozy-viewer@workspace:packages/cozy-viewer" dependencies: + "@babel/cli": "npm:7.16.8" + "@babel/core": "npm:7.16.12" "@testing-library/jest-dom": "npm:^5.14.1" "@testing-library/react": "npm:11.2.7" "@testing-library/react-hooks": "npm:^3.2.1"