Skip to content

Commit

Permalink
fix: Improve cozy-bar interactions
Browse files Browse the repository at this point in the history
WebviewIntent was not passed correctly in most cases
  • Loading branch information
acezard committed May 31, 2022
1 parent ecdbdef commit 7225303
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 19 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
"classnames": "2.3.1",
"copy-text-to-clipboard": "1.0.4",
"cozy-authentication": "2.8.3",
"cozy-bar": "7.17.7",
"cozy-bar": "7.17.9",
"cozy-ci": "0.4.1",
"cozy-client": "^29.1.1",
"cozy-client-js": "0.19.0",
Expand All @@ -131,7 +131,7 @@
"cozy-scripts": "6.3.1",
"cozy-sharing": "4.1.5",
"cozy-stack-client": "^29.0.0",
"cozy-ui": "^67.0.2",
"cozy-ui": "^68.2.0",
"date-fns": "1.30.1",
"diacritics": "1.3.0",
"fastclick": "1.0.6",
Expand Down
4 changes: 2 additions & 2 deletions src/drive/web/modules/drive/Toolbar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Toolbar extends Component {
hasWriteAccess,
breakpoints: { isMobile },
client,
webviewIntent
webviewService
} = this.props

const isDisabled = disabled || selectionModeActive
Expand Down Expand Up @@ -99,7 +99,7 @@ class Toolbar extends Component {
store={this.context.store}
t={t}
lang={lang}
webviewService={webviewIntent}
webviewService={webviewService}
>
<SharingProvider doctype="io.cozy.files" documentType="Files">
<MoreMenu
Expand Down
9 changes: 8 additions & 1 deletion src/drive/web/modules/public/PublicToolbarByLink.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import AddButton from 'drive/web/modules/drive/Toolbar/components/AddButton'
import AddMenuProvider from 'drive/web/modules/drive/AddMenu/AddMenuProvider'

import { DownloadFilesButton } from './DownloadButton'
import { useWebviewIntent } from 'cozy-intent'

export const isFilesIsFile = files =>
files.length === 1 && files[0].type === 'file'
Expand Down Expand Up @@ -87,12 +88,18 @@ const PublicToolbarByLink = ({
const isFile = isFilesIsFile(files)
const client = useClient()
const { isMobile } = useBreakpoints()
const webviewIntent = useWebviewIntent()

const shouldDisplayMoreMenu = isMobile || (!isFile && files.length > 0)

return (
<CozyBarRightMobile>
<BarContextProvider client={client} t={t} store={client.store}>
<BarContextProvider
client={client}
t={t}
store={client.store}
webviewService={webviewIntent}
>
{!isMobile && (
<>
{hasWriteAccess && (
Expand Down
9 changes: 8 additions & 1 deletion src/drive/web/modules/public/PublicToolbarCozyToCozy.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { downloadFiles } from 'drive/web/modules/actions/utils'
import CozyBarRightMobile from 'drive/web/modules/public/CozyBarRightMobile'
import { DownloadFilesButton } from './DownloadButton'
import { isFilesIsFile } from './PublicToolbarByLink'
import { useWebviewIntent } from 'cozy-intent'

const openExternalLink = url => (window.location = url)

Expand Down Expand Up @@ -77,12 +78,18 @@ const PublicToolbarCozyToCozy = ({
const isFile = isFilesIsFile(files)
const client = useClient()
const { isMobile } = useBreakpoints()
const { webviewIntent } = useWebviewIntent()

const shouldDisplayMoreMenu = isMobile || (!isFile && files.length > 0)

return (
<CozyBarRightMobile>
<BarContextProvider client={client} t={t} store={client.store}>
<BarContextProvider
client={client}
t={t}
store={client.store}
webviewService={webviewIntent}
>
{!isMobile && files.length > 0 && <DownloadFilesButton files={files} />}
{shouldDisplayMoreMenu && (
<MoreMenu
Expand Down
9 changes: 8 additions & 1 deletion src/drive/web/modules/trash/Toolbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { MoreButton } from 'components/Button'
import EmptyTrashConfirm from './components/EmptyTrashConfirm'

import styles from 'drive/styles/toolbar.styl'
import { useWebviewIntent } from 'cozy-intent'

export const Toolbar = ({
t,
Expand All @@ -33,6 +34,7 @@ export const Toolbar = ({
const anchorRef = React.createRef()
const openMenu = useCallback(() => setMenuVisible(true), [setMenuVisible])
const closeMenu = useCallback(() => setMenuVisible(false), [setMenuVisible])
const webviewIntent = useWebviewIntent()

const { pushModal, popModal } = useContext(ModalContext)

Expand Down Expand Up @@ -94,7 +96,12 @@ export const Toolbar = ({

{isMobile ? (
<BarRight>
<BarContextProvider client={client} t={t} store={client.store}>
<BarContextProvider
client={client}
t={t}
store={client.store}
webviewService={webviewIntent}
>
{MoreMenu}
</BarContextProvider>
</BarRight>
Expand Down
2 changes: 1 addition & 1 deletion src/drive/web/modules/views/Drive/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ const DriveView = ({
canUpload={true}
canCreateFolder={true}
disabled={isLoading || isInError || isPending}
webviewIntent={webviewIntent}
webviewService={webviewIntent}
/>
</FolderViewHeader>
{__TARGET__ === 'mobile' && (
Expand Down
8 changes: 7 additions & 1 deletion src/drive/web/modules/views/Recent/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ import {
import { useFilesQueryWithPath } from 'drive/web/modules/views/hooks'
import { useExtraColumns } from 'drive/web/modules/certifications/useExtraColumns'
import { makeExtraColumnsNamesFromMedia } from 'drive/web/modules/certifications'
import { useWebviewIntent } from 'cozy-intent'

const desktopExtraColumnsNames = ['carbonCopy', 'electronicSafe']
const mobileExtraColumnsNames = []

export const RecentView = ({ router, location, children }) => {
const { t } = useI18n()
const { isMobile } = useBreakpoints()
const webviewIntent = useWebviewIntent()

const extraColumnsNames = makeExtraColumnsNamesFromMedia({
isMobile,
Expand Down Expand Up @@ -105,7 +107,11 @@ export const RecentView = ({ router, location, children }) => {
<FolderView>
<FolderViewHeader>
<Breadcrumb path={[{ name: t('breadcrumb.title_recent') }]} />
<Toolbar canUpload={false} canCreateFolder={false} />
<Toolbar
canUpload={false}
canCreateFolder={false}
webviewService={webviewIntent}
/>
</FolderViewHeader>
<FolderViewBody
navigateToFolder={navigateToFolder}
Expand Down
8 changes: 7 additions & 1 deletion src/drive/web/modules/views/Sharings/SharingsFolderView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import FolderViewBody from '../Folder/FolderViewBody'
import FolderViewBreadcrumb from '../Folder/FolderViewBreadcrumb'
import { useExtraColumns } from 'drive/web/modules/certifications/useExtraColumns'
import { makeExtraColumnsNamesFromMedia } from 'drive/web/modules/certifications'
import { useWebviewIntent } from 'cozy-intent'

const desktopExtraColumnsNames = ['carbonCopy', 'electronicSafe']
const mobileExtraColumnsNames = []
Expand All @@ -45,6 +46,7 @@ const SharingsFolderView = ({
children
}) => {
const { isMobile } = useBreakpoints()
const webviewIntent = useWebviewIntent()

const extraColumnsNames = makeExtraColumnsNamesFromMedia({
isMobile,
Expand Down Expand Up @@ -127,7 +129,11 @@ const SharingsFolderView = ({
navigateToFolder={navigateToFolder}
/>
)}
<Toolbar canUpload={hasWriteAccess} canCreateFolder={hasWriteAccess} />
<Toolbar
canUpload={hasWriteAccess}
canCreateFolder={hasWriteAccess}
webviewService={webviewIntent}
/>
</FolderViewHeader>
<FolderViewBody
navigateToFolder={navigateToFolder}
Expand Down
8 changes: 7 additions & 1 deletion src/drive/web/modules/views/Sharings/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { useFilesQueryWithPath } from 'drive/web/modules/views/hooks'
import { useExtraColumns } from 'drive/web/modules/certifications/useExtraColumns'
import { makeExtraColumnsNamesFromMedia } from 'drive/web/modules/certifications'
import FileListRowsPlaceholder from 'drive/web/modules/filelist/FileListRowsPlaceholder'
import { useWebviewIntent } from 'cozy-intent'

const desktopExtraColumnsNames = ['carbonCopy', 'electronicSafe']
const mobileExtraColumnsNames = []
Expand All @@ -46,6 +47,7 @@ export const SharingsView = ({
}) => {
const { t } = useI18n()
const { isMobile } = useBreakpoints()
const webviewIntent = useWebviewIntent()

const extraColumnsNames = makeExtraColumnsNamesFromMedia({
isMobile,
Expand Down Expand Up @@ -104,7 +106,11 @@ export const SharingsView = ({
<FolderView>
<FolderViewHeader>
<Breadcrumb path={[{ name: t('breadcrumb.title_sharings') }]} />
<Toolbar canUpload={false} canCreateFolder={false} />
<Toolbar
canUpload={false}
canCreateFolder={false}
webviewService={webviewIntent}
/>
</FolderViewHeader>
{!allLoaded || !hasQueryBeenLoaded(result) ? (
<FileListRowsPlaceholder />
Expand Down
27 changes: 19 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5890,10 +5890,10 @@ cozy-authentication@2.8.3:
snarkdown "1.2.2"
url-polyfill "1.1.7"

cozy-bar@7.17.7:
version "7.17.7"
resolved "https://registry.yarnpkg.com/cozy-bar/-/cozy-bar-7.17.7.tgz#d1dd7985fdbb29819bbebfeced03ce757b0cac9a"
integrity sha512-ZwUrOphiH2dJohZsQoePiVAPXsLm4Fg/kvyPqwpkoxMpGtCMsGHGs+gZ2oX/bOiyb3z7I7KNun7HZ+/VZ8D3uQ==
cozy-bar@7.17.9:
version "7.17.9"
resolved "https://registry.yarnpkg.com/cozy-bar/-/cozy-bar-7.17.9.tgz#00727dfbcbacaafcd598b991bd31b50587e15aaf"
integrity sha512-dYJ7E2yGQg0Jmx7OLOpXLsCX/KgpIi5wt5QQn/CTj9+pRvGzN4+jUUzwL2i9EnqU5MxORIQoqrt9Q2b9ok7oPw==
dependencies:
"@cozy/minilog" "^1.0.0"
cozy-client "^27.14.4"
Expand Down Expand Up @@ -6299,10 +6299,10 @@ cozy-ui@22.3.1:
react-pdf "^4.0.5"
react-select "2.2.0"

cozy-ui@^67.0.2:
version "67.0.2"
resolved "https://registry.yarnpkg.com/cozy-ui/-/cozy-ui-67.0.2.tgz#f7c99a016e6b447b088e46d9768acb5b8323e8ea"
integrity sha512-aLO1ztvD0d1J7qfQ8sS9LSHr3mOBgvmsjmx2Zxt/VjGQX8W+Oeef4E8KNf19ee5lwEG39h1t19fHNbeYCYziuw==
cozy-ui@^68.2.0:
version "68.2.0"
resolved "https://registry.yarnpkg.com/cozy-ui/-/cozy-ui-68.2.0.tgz#c360b3c260094ad0670fe44af8f4a36125844fd2"
integrity sha512-pd3Tztq1sWcMCXEaUyWJNrak+1Sakrc6EQmkicV5+jkJzftc+zq6GFYdWV8vpu+fAsrH3i/i9xsD4yiDFN8Zgw==
dependencies:
"@babel/runtime" "^7.3.4"
"@popperjs/core" "^2.4.4"
Expand Down Expand Up @@ -13027,6 +13027,17 @@ msgpack5@^4.0.2:
readable-stream "^2.3.6"
safe-buffer "^5.1.2"

"mui-bottom-sheet@git+https://github.com/cozy/mui-bottom-sheet.git#v1.0.6":
version "1.0.6"
uid "494c40416ecde95732c864f9b921e7e545075aa5"
resolved "git+https://github.com/cozy/mui-bottom-sheet.git#494c40416ecde95732c864f9b921e7e545075aa5"
dependencies:
"@juggle/resize-observer" "^3.1.3"
jest-environment-jsdom-sixteen "^1.0.3"
react-spring "9.0.0-rc.3"
react-use-gesture "^7.0.8"
react-use-measure "^2.0.0"

"mui-bottom-sheet@https://github.com/cozy/mui-bottom-sheet.git#v1.0.6":
version "1.0.6"
resolved "https://github.com/cozy/mui-bottom-sheet.git#494c40416ecde95732c864f9b921e7e545075aa5"
Expand Down

0 comments on commit 7225303

Please sign in to comment.