Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Improve cozy-bar interactions #2608

Merged
merged 1 commit into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
* Update cozy-stack-client and cozy-pouch-link to sync with cozy-client version
* Update cozy-ui
- Modify Viewers to handle [68.0.0 BC](https://github.com/cozy/cozy-ui/releases/tag/v68.0.0)
* Update cozy-scripts for Amirale development

## 🐛 Bug Fixes

* Improve cozy-bar implementation to fix UI bugs in Amirale

## 🔧 Tech

# 1.42.1
Expand Down
2 changes: 1 addition & 1 deletion 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 Down
20 changes: 16 additions & 4 deletions src/drive/web/modules/drive/Toolbar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import SharingProvider, { SharedDocument } from 'cozy-sharing'
import { translate } from 'cozy-ui/transpiled/react/I18n'
import withBreakpoints from 'cozy-ui/transpiled/react/helpers/withBreakpoints'
import BarContextProvider from 'cozy-ui/transpiled/react/BarContextProvider'
import { useWebviewIntent } from 'cozy-intent'

import { isSelectionBarVisible } from 'drive/web/modules/selection/duck'
import { getCurrentFolderId } from 'drive/web/modules/selectors'
Expand Down Expand Up @@ -60,7 +61,7 @@ class Toolbar extends Component {
hasWriteAccess,
breakpoints: { isMobile },
client,
webviewIntent
webviewService
} = this.props

const isDisabled = disabled || selectionModeActive
Expand Down Expand Up @@ -99,7 +100,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 All @@ -122,6 +123,12 @@ const mapStateToProps = state => ({
selectionModeActive: isSelectionBarVisible(state)
})

const ToolbarWithWebviewContext = props => {
const webviewIntent = useWebviewIntent()

return <Toolbar webviewService={webviewIntent} {...props} />
}

/**
* Provides the Toolbar with sharing properties of the current folder.
*
Expand All @@ -130,12 +137,17 @@ const mapStateToProps = state => ({
*/
const ToolbarWithSharingContext = props => {
return !props.folderId ? (
<Toolbar {...props} />
<ToolbarWithWebviewContext {...props} />
) : (
<SharedDocument docId={props.folderId}>
{sharingProps => {
const { hasWriteAccess } = sharingProps
return <Toolbar {...props} hasWriteAccess={hasWriteAccess} />
return (
<ToolbarWithWebviewContext
{...props}
hasWriteAccess={hasWriteAccess}
/>
)
}}
</SharedDocument>
)
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
4 changes: 0 additions & 4 deletions src/drive/web/modules/views/Drive/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import FolderViewBreadcrumb from 'drive/web/modules/views/Folder/FolderViewBread
import { useTrashRedirect } from 'drive/web/modules/views/Drive/useTrashRedirect'
import FabWithMenuContext from 'drive/web/modules/drive/FabWithMenuContext'
import AddMenuProvider from 'drive/web/modules/drive/AddMenu/AddMenuProvider'
import { useWebviewIntent } from 'cozy-intent'

const desktopExtraColumnsNames = ['carbonCopy', 'electronicSafe']
const mobileExtraColumnsNames = []
Expand Down Expand Up @@ -172,8 +171,6 @@ const DriveView = ({
}
}, [setIsFabDisplayed, isMobile, canWriteToCurrentFolder])

const webviewIntent = useWebviewIntent()

return (
<FolderView>
<FolderViewHeader>
Expand All @@ -188,7 +185,6 @@ const DriveView = ({
canUpload={true}
canCreateFolder={true}
disabled={isLoading || isInError || isPending}
webviewIntent={webviewIntent}
/>
</FolderViewHeader>
{__TARGET__ === 'mobile' && (
Expand Down
8 changes: 4 additions & 4 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