diff --git a/src/modules/breadcrumb/components/DesktopBreadcrumb.jsx b/src/modules/breadcrumb/components/DesktopBreadcrumb.jsx
index e61b01a035..5eb37d305b 100644
--- a/src/modules/breadcrumb/components/DesktopBreadcrumb.jsx
+++ b/src/modules/breadcrumb/components/DesktopBreadcrumb.jsx
@@ -1,12 +1,12 @@
import React, { useEffect, useMemo, useState } from 'react'
+import ActionsMenu from 'cozy-ui/transpiled/react/ActionsMenu'
+import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem'
import BreadcrumbMui from 'cozy-ui/transpiled/react/Breadcrumbs'
import Icon from 'cozy-ui/transpiled/react/Icon'
import FolderIcon from 'cozy-ui/transpiled/react/Icons/Folder'
import RightIcon from 'cozy-ui/transpiled/react/Icons/Right'
-import ActionMenu, {
- ActionMenuItem
-} from 'cozy-ui/transpiled/react/deprecated/ActionMenu'
+import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
import IconServer from 'assets/icons/icon-server.svg'
@@ -28,13 +28,15 @@ const DesktopBreadcrumb = ({ onBreadcrumbClick, path }) => {
)
const [menuDisplayed, setMenuDisplayed] = useState(false)
+ const closeMenu = () => setMenuDisplayed(false)
+
const handleDropdownTriggerClick = e => {
e.stopPropagation()
setMenuDisplayed(true)
}
useEffect(() => {
- setMenuDisplayed(false)
+ closeMenu()
setDropdownTrigger(document.querySelector(`[aria-label="${expandText}"]`))
}, [path]) // eslint-disable-line react-hooks/exhaustive-deps
@@ -43,7 +45,7 @@ const DesktopBreadcrumb = ({ onBreadcrumbClick, path }) => {
if (trigger) {
trigger.addEventListener('click', handleDropdownTriggerClick)
return () => {
- setMenuDisplayed(false)
+ closeMenu()
trigger.removeEventListener('click', handleDropdownTriggerClick)
}
}
@@ -115,36 +117,29 @@ const DesktopBreadcrumb = ({ onBreadcrumbClick, path }) => {
{menuDisplayed && (
- {
- setMenuDisplayed(false)
- }}
- popperOptions={{
- placement: 'bottom-end',
- modifiers: [
- {
- name: 'offset',
- options: {
- offset: [0, 10]
- }
- }
- ]
+
{path.slice(1, -2).map(breadcrumbPath => (
- {
e.stopPropagation()
onBreadcrumbClick(breadcrumbPath)
}}
>
- {breadcrumbPath.name}
-
+
+
))}
-
+
)}
>
)
diff --git a/src/modules/drive/AddMenu/AddMenu.jsx b/src/modules/drive/AddMenu/AddMenu.jsx
index 3196259719..8bedf602c8 100644
--- a/src/modules/drive/AddMenu/AddMenu.jsx
+++ b/src/modules/drive/AddMenu/AddMenu.jsx
@@ -1,8 +1,10 @@
import React from 'react'
import flag from 'cozy-flags'
-import Typography from 'cozy-ui/transpiled/react/Typography'
-import ActionMenu from 'cozy-ui/transpiled/react/deprecated/ActionMenu'
+import ActionsMenu from 'cozy-ui/transpiled/react/ActionsMenu'
+import ActionsMenuMobileHeader from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuMobileHeader'
+import Divider from 'cozy-ui/transpiled/react/Divider'
+import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints'
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
@@ -23,25 +25,27 @@ export const ActionMenuContent = ({
refreshFolderContent,
isPublic,
isEncryptedFolder,
- displayedFolder
+ displayedFolder,
+ onClick
}) => {
const { t } = useI18n()
- const { isMobile, isDesktop } = useBreakpoints()
+ const { isDesktop } = useBreakpoints()
const { hasScanner } = useScannerContext()
return (
<>
- {isMobile && (
- <>
-
- {t('toolbar.menu_add')}
-
-
- >
+
+
+
+
+ {canCreateFolder && !isEncryptedFolder && (
+
)}
- {canCreateFolder && !isEncryptedFolder && }
{canCreateFolder && !isPublic && flag('drive.enable-encryption') && (
-
+
)}
{!isPublic && !isEncryptedFolder && (
@@ -54,17 +58,18 @@ export const ActionMenuContent = ({
>
)}
{!isEncryptedFolder && (
-
+
)}
- {canUpload &&
}
+ {canUpload && }
{canUpload && (
)}
- {hasScanner && }
+ {hasScanner && }
>
)
}
@@ -82,13 +87,12 @@ const AddMenu = ({
...actionMenuProps
}) => {
return (
-
-
+
)
}
diff --git a/src/modules/drive/Toolbar/components/AddEncryptedFolderItem.jsx b/src/modules/drive/Toolbar/components/AddEncryptedFolderItem.jsx
index 546a935e52..094f4820a8 100644
--- a/src/modules/drive/Toolbar/components/AddEncryptedFolderItem.jsx
+++ b/src/modules/drive/Toolbar/components/AddEncryptedFolderItem.jsx
@@ -2,24 +2,30 @@ import React from 'react'
import { connect } from 'react-redux'
import { useVaultUnlockContext } from 'cozy-keys-lib'
-import { ActionMenuItem } from 'cozy-ui/transpiled/react/deprecated/ActionMenu'
+import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem'
+import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
import { showNewFolderInput, encryptedFolder } from 'modules/filelist/duck'
import EncryptedFolderIcon from 'modules/views/Folder/EncryptedFolderIcon'
-const AddEncryptedFolderItem = ({ addEncryptedFolder }) => {
+const AddEncryptedFolderItem = ({ addEncryptedFolder, onClick }) => {
const { t } = useI18n()
const { showUnlockForm } = useVaultUnlockContext()
+ const handleClick = () => {
+ showUnlockForm({ onUnlock: addEncryptedFolder })
+ onClick()
+ }
+
return (
- showUnlockForm({ onUnlock: addEncryptedFolder })}
- left={}
+ onClick={handleClick}
>
- {t('toolbar.menu_new_encrypted_folder')}
-
+
+
+
)
}
diff --git a/src/modules/drive/Toolbar/components/AddFolderItem.jsx b/src/modules/drive/Toolbar/components/AddFolderItem.jsx
index 27e1f1ea1c..08ca823bcc 100644
--- a/src/modules/drive/Toolbar/components/AddFolderItem.jsx
+++ b/src/modules/drive/Toolbar/components/AddFolderItem.jsx
@@ -1,22 +1,28 @@
import React from 'react'
import { connect } from 'react-redux'
+import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem'
import Icon from 'cozy-ui/transpiled/react/Icon'
import IconFolder from 'cozy-ui/transpiled/react/Icons/FileTypeFolder'
-import { ActionMenuItem } from 'cozy-ui/transpiled/react/deprecated/ActionMenu'
+import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
+import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
import { translate } from 'cozy-ui/transpiled/react/providers/I18n'
import { showNewFolderInput } from 'modules/filelist/duck'
-const AddFolderItem = translate()(({ t, addFolder }) => {
+const AddFolderItem = translate()(({ t, addFolder, onClick }) => {
+ const handleClick = () => {
+ addFolder()
+ onClick()
+ }
+
return (
- }
- >
- {t('toolbar.menu_new_folder')}
-
+
+
+
+
+
+
)
})
const mapDispatchToProps = dispatch => ({
diff --git a/src/modules/drive/Toolbar/components/AddMenuItem.jsx b/src/modules/drive/Toolbar/components/AddMenuItem.jsx
index 5aeb82f241..fa3e0916ae 100644
--- a/src/modules/drive/Toolbar/components/AddMenuItem.jsx
+++ b/src/modules/drive/Toolbar/components/AddMenuItem.jsx
@@ -1,13 +1,15 @@
import React, { useContext } from 'react'
+import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem'
import Icon from 'cozy-ui/transpiled/react/Icon'
import PlusIcon from 'cozy-ui/transpiled/react/Icons/Plus'
-import { ActionMenuItem } from 'cozy-ui/transpiled/react/deprecated/ActionMenu'
+import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
+import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
import { AddMenuContext } from 'modules/drive/AddMenu/AddMenuProvider'
-const AddMenuItem = () => {
+const AddMenuItem = ({ onClick }) => {
const { t } = useI18n()
const {
@@ -19,18 +21,24 @@ const AddMenuItem = () => {
a11y
} = useContext(AddMenuContext)
+ const handleClick = () => {
+ isOffline ? handleOfflineClick() : handleToggle()
+ onClick()
+ }
+
return (
-
-
}
- disabled={isDisabled || isOffline}
- icon={PlusIcon}
- onClick={handleToggle}
- {...a11y}
- >
- {t('toolbar.menu_add_item')}
-
-
+
+
+ } />
+
+
+
)
}
diff --git a/src/modules/drive/Toolbar/components/CreateNoteItem.jsx b/src/modules/drive/Toolbar/components/CreateNoteItem.jsx
index aea07179c5..0529b6d756 100644
--- a/src/modules/drive/Toolbar/components/CreateNoteItem.jsx
+++ b/src/modules/drive/Toolbar/components/CreateNoteItem.jsx
@@ -10,10 +10,12 @@ import {
} from 'cozy-client'
import { isFlagshipApp } from 'cozy-device-helper'
import { useWebviewIntent } from 'cozy-intent'
+import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem'
import { generateUniversalLink } from 'cozy-ui/transpiled/react/AppLinker/native'
import Icon from 'cozy-ui/transpiled/react/Icon'
import IconNote from 'cozy-ui/transpiled/react/Icons/FileTypeNote'
-import { ActionMenuItem } from 'cozy-ui/transpiled/react/deprecated/ActionMenu'
+import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
+import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
import { translate } from 'cozy-ui/transpiled/react/providers/I18n'
const CreateNoteItem = ({ client, t, displayedFolder }) => {
@@ -53,38 +55,39 @@ const CreateNoteItem = ({ client, t, displayedFolder }) => {
}
}
- return (
- }
- onClick={async () => {
- if (notesAppUrl === undefined) return
- if (notesAppIsInstalled) {
- const { data: file } = await client.create('io.cozy.notes', {
- dir_id: displayedFolder.id
- })
+ const handleClick = async () => {
+ if (notesAppUrl === undefined) return
+ if (notesAppIsInstalled) {
+ const { data: file } = await client.create('io.cozy.notes', {
+ dir_id: displayedFolder.id
+ })
- const privateUrl = await models.note.generatePrivateUrl(
- notesAppUrl,
- file,
- { returnUrl }
- )
+ const privateUrl = await models.note.generatePrivateUrl(
+ notesAppUrl,
+ file,
+ { returnUrl }
+ )
- /**
- * Not using AppLinker here because it would require too much refactoring and would be risky
- * Instead we use the webviewIntent programmatically to open the cozy-note app on the note href
- */
- if (isFlagshipApp() && webviewIntent)
- return webviewIntent.call('openApp', privateUrl, { slug: 'notes' })
+ /**
+ * Not using AppLinker here because it would require too much refactoring and would be risky
+ * Instead we use the webviewIntent programmatically to open the cozy-note app on the note href
+ */
+ if (isFlagshipApp() && webviewIntent)
+ return webviewIntent.call('openApp', privateUrl, { slug: 'notes' })
- window.location.href = privateUrl
- } else {
- window.location.href = notesAppUrl
- }
- }}
- >
- {t('toolbar.menu_create_note')}
-
+ window.location.href = privateUrl
+ } else {
+ window.location.href = notesAppUrl
+ }
+ }
+
+ return (
+
+
+
+
+
+
)
}
diff --git a/src/modules/drive/Toolbar/components/CreateOnlyOfficeItem.jsx b/src/modules/drive/Toolbar/components/CreateOnlyOfficeItem.jsx
index 1b96fc6ca1..bf59e68f02 100644
--- a/src/modules/drive/Toolbar/components/CreateOnlyOfficeItem.jsx
+++ b/src/modules/drive/Toolbar/components/CreateOnlyOfficeItem.jsx
@@ -1,8 +1,10 @@
import React, { useCallback, useMemo } from 'react'
import { useParams, useNavigate } from 'react-router-dom'
+import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem'
import Icon from 'cozy-ui/transpiled/react/Icon'
-import { ActionMenuItem } from 'cozy-ui/transpiled/react/deprecated/ActionMenu'
+import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
+import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
import { ROOT_DIR_ID } from 'constants/config'
@@ -30,9 +32,12 @@ const CreateOnlyOfficeItem = ({ fileClass }) => {
)
return (
- }>
- {t(`toolbar.menu_onlyOffice.${fileClass}`)}
-
+
+
+
+
+
+
)
}
diff --git a/src/modules/drive/Toolbar/components/CreateShortcut.jsx b/src/modules/drive/Toolbar/components/CreateShortcut.jsx
index 4406511251..77e9834c0a 100644
--- a/src/modules/drive/Toolbar/components/CreateShortcut.jsx
+++ b/src/modules/drive/Toolbar/components/CreateShortcut.jsx
@@ -2,24 +2,30 @@ import React from 'react'
import { showModal } from 'react-cozy-helpers'
import { connect } from 'react-redux'
+import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem'
import Icon from 'cozy-ui/transpiled/react/Icon'
import DeviceBrowserIcon from 'cozy-ui/transpiled/react/Icons/DeviceBrowser'
-import { ActionMenuItem } from 'cozy-ui/transpiled/react/deprecated/ActionMenu'
+import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
+import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
import ShortcutCreationModal from './ShortcutCreationModal'
-const CreateShortcutWrapper = ({ openModal }) => {
+const CreateShortcutWrapper = ({ openModal, onClick }) => {
const { t } = useI18n()
+ const handleClick = () => {
+ openModal()
+ onClick()
+ }
+
return (
- }
- onClick={openModal}
- >
- {t('toolbar.menu_create_shortcut')}
-
+
+
+
+
+
+
)
}
diff --git a/src/modules/drive/Toolbar/components/DownloadButtonItem.jsx b/src/modules/drive/Toolbar/components/DownloadButtonItem.jsx
index d70eba678e..c15b0d6cbe 100644
--- a/src/modules/drive/Toolbar/components/DownloadButtonItem.jsx
+++ b/src/modules/drive/Toolbar/components/DownloadButtonItem.jsx
@@ -3,9 +3,11 @@ import React from 'react'
import { connect } from 'react-redux'
import { withClient } from 'cozy-client'
+import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem'
import Icon from 'cozy-ui/transpiled/react/Icon'
import DownloadIcon from 'cozy-ui/transpiled/react/Icons/Download'
-import { ActionMenuItem } from 'cozy-ui/transpiled/react/deprecated/ActionMenu'
+import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
+import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert'
import { translate } from 'cozy-ui/transpiled/react/providers/I18n'
@@ -15,12 +17,15 @@ const DownloadButtonItem = ({ t, downloadAll, displayedFolder }) => {
const { showAlert } = useAlert()
return (
- }
+ downloadAll([displayedFolder], showAlert, t)}
>
- {t('toolbar.menu_download_folder')}
-
+
+
+
+
+
)
}
diff --git a/src/modules/drive/Toolbar/components/MoreMenu.jsx b/src/modules/drive/Toolbar/components/MoreMenu.jsx
index f3bc29eda9..e21a18e328 100644
--- a/src/modules/drive/Toolbar/components/MoreMenu.jsx
+++ b/src/modules/drive/Toolbar/components/MoreMenu.jsx
@@ -1,8 +1,9 @@
-import React, { useState, useCallback } from 'react'
+import React, { useState, useCallback, useRef } from 'react'
import { isIOSApp } from 'cozy-device-helper'
import { useSharingContext } from 'cozy-sharing'
-import ActionMenu from 'cozy-ui/transpiled/react/deprecated/ActionMenu'
+import ActionsMenu from 'cozy-ui/transpiled/react/ActionsMenu'
+import Divider from 'cozy-ui/transpiled/react/Divider'
import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints'
import { MoreButton } from 'components/Button'
@@ -45,7 +46,7 @@ const MoreMenu = ({
isSharedWithMe
}) => {
const [menuIsVisible, setMenuVisible] = useState(false)
- const anchorRef = React.createRef()
+ const anchorRef = useRef()
const { isMobile } = useBreakpoints()
const { allLoaded } = useSharingContext() // We need to wait for the sharing context to be completely loaded to avoid race conditions
@@ -71,12 +72,15 @@ const MoreMenu = ({
isSelectionBarVisible={isSelectionBarVisible}
>
{menuIsVisible && (
-
{isMobile && allLoaded && (
@@ -100,14 +104,14 @@ const MoreMenu = ({
displayedFolder={displayedFolder}
folderId={folderId}
>
-
+
)}
-
+
)}
diff --git a/src/modules/drive/Toolbar/components/Scanner/ScannerMenuItem.tsx b/src/modules/drive/Toolbar/components/Scanner/ScannerMenuItem.tsx
index cc990d1679..60dbb7b5f0 100644
--- a/src/modules/drive/Toolbar/components/Scanner/ScannerMenuItem.tsx
+++ b/src/modules/drive/Toolbar/components/Scanner/ScannerMenuItem.tsx
@@ -1,29 +1,48 @@
import React from 'react'
+import logger from 'cozy-logger'
+import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem'
import Icon from 'cozy-ui/transpiled/react/Icon'
import CameraIcon from 'cozy-ui/transpiled/react/Icons/Camera'
-import { ActionMenuItem } from 'cozy-ui/transpiled/react/deprecated/ActionMenu'
+import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
+import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
import { useScannerContext } from 'modules/drive/Toolbar/components/Scanner/ScannerProvider'
+const log = logger.namespace('Toolbar/components/Scanner/ScannerMenuItem')
+
/**
* Renders a scanner menu item.
* @returns The JSX element representing the scanner menu item.
*/
-export const ScannerMenuItem = (): JSX.Element | null => {
+interface ScannerMenuItemProps {
+ onClick: () => void
+}
+
+export const ScannerMenuItem = ({
+ onClick
+}: ScannerMenuItemProps): JSX.Element | null => {
const { t } = useI18n()
const { hasScanner, startScanner } = useScannerContext()
+ const handleClick = (): void => {
+ if (startScanner) {
+ startScanner().catch((error: Error) => {
+ log('error', `Failed to start scanner: ${error.message}`)
+ })
+ }
+ onClick()
+ }
+
return hasScanner ? (
-
}
- data-testid="scan-doc"
- >
- {t('Scan.scan_a_doc')}
-
+
+
+
+
+
+
) : null
}
diff --git a/src/modules/drive/Toolbar/components/UploadItem.jsx b/src/modules/drive/Toolbar/components/UploadItem.jsx
index 9117669337..9d9c0e8482 100644
--- a/src/modules/drive/Toolbar/components/UploadItem.jsx
+++ b/src/modules/drive/Toolbar/components/UploadItem.jsx
@@ -5,39 +5,47 @@ import { compose } from 'redux'
import { useClient } from 'cozy-client'
import { useVaultClient } from 'cozy-keys-lib'
import withSharingState from 'cozy-sharing/dist/hoc/withSharingState'
+import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem'
import FileInput from 'cozy-ui/transpiled/react/FileInput'
import Icon from 'cozy-ui/transpiled/react/Icon'
import UploadIcon from 'cozy-ui/transpiled/react/Icons/Upload'
-import { ActionMenuItem } from 'cozy-ui/transpiled/react/deprecated/ActionMenu'
+import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
+import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert'
import { translate } from 'cozy-ui/transpiled/react/providers/I18n'
import { uploadFiles } from 'modules/navigation/duck'
-const UploadItem = ({ t, isDisabled, onUpload, displayedFolder }) => {
+const UploadItem = ({ t, isDisabled, onUpload, displayedFolder, onClick }) => {
const client = useClient()
const vaultClient = useVaultClient()
const { showAlert } = useAlert()
+ const handleClick = evt => {
+ evt.stopPropagation()
+ }
+ const handleChange = files => {
+ onUpload(client, vaultClient, files, displayedFolder, showAlert)
+ onClick()
+ }
+
return (
- onUpload(client, vaultClient, files, displayedFolder, showAlert)
- }
+ onChange={handleChange}
data-testid="upload-btn"
value={[]}
// FileInput needs to stay rendered until the onChange event, so we prevent the event from bubbling
- onClick={e => e.stopPropagation()}
+ onClick={handleClick}
>
- }
- onClick={e => e.stopPropagation()}
- >
- {t('toolbar.menu_upload')}
-
+
+
+
+
+
+
)
}
diff --git a/src/modules/drive/Toolbar/delete/DeleteItem.jsx b/src/modules/drive/Toolbar/delete/DeleteItem.jsx
index 07fae82030..0dc4ca50d3 100644
--- a/src/modules/drive/Toolbar/delete/DeleteItem.jsx
+++ b/src/modules/drive/Toolbar/delete/DeleteItem.jsx
@@ -2,9 +2,11 @@ import compose from 'lodash/flowRight'
import PropTypes from 'prop-types'
import React from 'react'
+import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem'
import Icon from 'cozy-ui/transpiled/react/Icon'
import TrashIcon from 'cozy-ui/transpiled/react/Icons/Trash'
-import { ActionMenuItem } from 'cozy-ui/transpiled/react/deprecated/ActionMenu'
+import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
+import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
import { translate } from 'cozy-ui/transpiled/react/providers/I18n'
import deleteContainer from './delete'
@@ -17,13 +19,16 @@ const DeleteItem = ({ t, isSharedWithMe, trashFolder, displayedFolder }) => {
const label = isSharedWithMe ? t('toolbar.leave') : t('toolbar.trash')
return (
- }
+ isListItem
onClick={handleClick}
>
- {label}
-
+
+
+
+
+
)
}
diff --git a/src/modules/drive/Toolbar/selectable/SelectableItem.jsx b/src/modules/drive/Toolbar/selectable/SelectableItem.jsx
index e214cd1153..4f12684e1b 100644
--- a/src/modules/drive/Toolbar/selectable/SelectableItem.jsx
+++ b/src/modules/drive/Toolbar/selectable/SelectableItem.jsx
@@ -1,9 +1,11 @@
import PropTypes from 'prop-types'
import React from 'react'
+import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem'
import Icon from 'cozy-ui/transpiled/react/Icon'
import CheckSquareIcon from 'cozy-ui/transpiled/react/Icons/CheckSquare'
-import { ActionMenuItem } from 'cozy-ui/transpiled/react/deprecated/ActionMenu'
+import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
+import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
/**
@@ -13,12 +15,12 @@ const SelectableItem = ({ onClick }) => {
const { t } = useI18n()
return (
- } onClick={onClick}>
- left={}
- onClick={showSelectionBar}
- >
- {t('toolbar.menu_select')}
-
+
+
+
+
+
+
)
}
diff --git a/src/modules/drive/Toolbar/share/ShareItem.jsx b/src/modules/drive/Toolbar/share/ShareItem.jsx
index e73c55e1b1..cb240b536d 100644
--- a/src/modules/drive/Toolbar/share/ShareItem.jsx
+++ b/src/modules/drive/Toolbar/share/ShareItem.jsx
@@ -3,15 +3,15 @@ import { useNavigate, useLocation } from 'react-router-dom'
import { SharedDocument } from 'cozy-sharing'
import { AvatarList } from 'cozy-sharing/dist/components/Avatar/AvatarList'
+import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem'
import Icon from 'cozy-ui/transpiled/react/Icon'
import ShareIcon from 'cozy-ui/transpiled/react/Icons/Share'
-import { ActionMenuItem } from 'cozy-ui/transpiled/react/deprecated/ActionMenu'
+import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
+import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
import { getPathToShareDisplayedFolder } from 'modules/drive/Toolbar/share/helpers'
-import styles from 'styles/toolbar.styl'
-
const ShareItem = ({ displayedFolder }) => {
const { t } = useI18n()
const navigate = useNavigate()
@@ -24,26 +24,19 @@ const ShareItem = ({ displayedFolder }) => {
return (
{({ isSharedWithMe, recipients, link }) => (
- }
- right={
-
- }
- >
- {t(
- isSharedWithMe
- ? 'Files.share.sharedWithMe'
- : 'toolbar.menu_share_folder'
- )}
-
+
+
+
+
+
+
+
)}
)
diff --git a/src/modules/public/PublicToolbarByLink.jsx b/src/modules/public/PublicToolbarByLink.jsx
index 6b0371ea12..6063d8d2a2 100644
--- a/src/modules/public/PublicToolbarByLink.jsx
+++ b/src/modules/public/PublicToolbarByLink.jsx
@@ -1,18 +1,21 @@
import { useDisplayedFolder } from 'hooks'
import React from 'react'
-import Icon from 'cozy-ui/transpiled/react/Icon'
-import { ActionMenuItem } from 'cozy-ui/transpiled/react/deprecated/ActionMenu'
+import { useClient } from 'cozy-client'
+import { makeActions } from 'cozy-ui/transpiled/react/ActionsMenu/Actions'
+import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert'
import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints'
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
import { BarRightOnMobile } from 'components/Bar'
import { HOME_LINK_HREF } from 'constants/config'
+import { download, openExternalLink } from 'modules/actions'
import AddMenuProvider from 'modules/drive/AddMenu/AddMenuProvider'
import AddButton from 'modules/drive/Toolbar/components/AddButton'
+import AddMenuItem from 'modules/drive/Toolbar/components/AddMenuItem'
+import SelectableItem from 'modules/drive/Toolbar/selectable/SelectableItem'
import { DownloadFilesButton } from 'modules/public/DownloadButton'
import PublicToolbarMoreMenu from 'modules/public/PublicToolbarMoreMenu'
-import { openExternalLink } from 'modules/public/helpers'
import { useSelectionContext } from 'modules/selection/SelectionProvider'
const PublicToolbarByLink = ({
@@ -21,46 +24,53 @@ const PublicToolbarByLink = ({
refreshFolderContent
}) => {
const { isMobile } = useBreakpoints()
+ const client = useClient()
+ const { showAlert } = useAlert()
const { t } = useI18n()
const { displayedFolder } = useDisplayedFolder()
const { showSelectionBar, isSelectionBarVisible } = useSelectionContext()
+ const actionOptions = {
+ client,
+ t,
+ showAlert,
+ isPublic: true,
+ link: HOME_LINK_HREF
+ }
+ const actions = makeActions(
+ [isMobile && files.length > 0 && download, isMobile && openExternalLink],
+ actionOptions
+ )
+
return (
- <>
-
-
- {!isMobile && (
- <>
- {hasWriteAccess && }
- {files.length > 0 && (
-
- )}
- >
- )}
-
- {isMobile && (
- openExternalLink(HOME_LINK_HREF)}
- left={}
- >
- {t('Share.create-cozy')}
-
+
+
+ {!isMobile && (
+ <>
+ {hasWriteAccess && }
+ {files.length > 0 && (
+
)}
-
-
-
- >
+ >
+ )}
+
+ {isMobile && hasWriteAccess && }
+ {files.length > 1 && }
+
+
+
)
}
diff --git a/src/modules/public/PublicToolbarCozyToCozy.jsx b/src/modules/public/PublicToolbarCozyToCozy.jsx
index dd5beba141..e94c73ebad 100644
--- a/src/modules/public/PublicToolbarCozyToCozy.jsx
+++ b/src/modules/public/PublicToolbarCozyToCozy.jsx
@@ -1,14 +1,16 @@
import React from 'react'
-import Icon from 'cozy-ui/transpiled/react/Icon'
-import { ActionMenuItem } from 'cozy-ui/transpiled/react/deprecated/ActionMenu'
+import { useClient } from 'cozy-client'
+import { makeActions } from 'cozy-ui/transpiled/react/ActionsMenu/Actions'
+import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert'
import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints'
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
import { BarRightOnMobile } from 'components/Bar'
+import { download, openExternalLink } from 'modules/actions'
+import SelectableItem from 'modules/drive/Toolbar/selectable/SelectableItem'
import { DownloadFilesButton } from 'modules/public/DownloadButton'
import PublicToolbarMoreMenu from 'modules/public/PublicToolbarMoreMenu'
-import { openExternalLink } from 'modules/public/helpers'
import { useSelectionContext } from 'modules/selection/SelectionProvider'
const PublicToolbarCozyToCozy = ({
@@ -19,21 +21,31 @@ const PublicToolbarCozyToCozy = ({
const { isMobile } = useBreakpoints()
const { t } = useI18n()
const { showSelectionBar } = useSelectionContext()
+ const client = useClient()
+ const { showAlert } = useAlert()
+
+ const actionOptions = {
+ client,
+ t,
+ showAlert,
+ isPublic: true,
+ isSharingShortcutCreated,
+ link: discoveryLink
+ }
+ const actions = makeActions(
+ [isMobile && files.length > 0 && download, openExternalLink],
+ actionOptions
+ )
return (
{!isMobile && files.length > 0 && }
-
- openExternalLink(discoveryLink)}
- left={
-
- }
- >
- {isSharingShortcutCreated
- ? t('toolbar.menu_sync_cozy')
- : t('toolbar.add_to_mine')}
-
+
+ {files.length > 1 && }
)
diff --git a/src/modules/public/PublicToolbarMoreMenu.jsx b/src/modules/public/PublicToolbarMoreMenu.jsx
index d12d23bb85..ce94483c84 100644
--- a/src/modules/public/PublicToolbarMoreMenu.jsx
+++ b/src/modules/public/PublicToolbarMoreMenu.jsx
@@ -1,30 +1,14 @@
+import cx from 'classnames'
import React, { useState, useCallback, useRef } from 'react'
-import { useClient } from 'cozy-client'
-import Icon from 'cozy-ui/transpiled/react/Icon'
-import ActionMenu, {
- ActionMenuItem
-} from 'cozy-ui/transpiled/react/deprecated/ActionMenu'
-import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert'
+import ActionsMenu from 'cozy-ui/transpiled/react/ActionsMenu'
import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints'
-import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
import { MoreButton } from 'components/Button'
-import { downloadFiles } from 'modules/actions/utils'
-import AddMenuItem from 'modules/drive/Toolbar/components/AddMenuItem'
-import SelectableItem from 'modules/drive/Toolbar/selectable/SelectableItem'
-const PublicToolbarMoreMenu = ({
- files,
- hasWriteAccess,
- children,
- showSelectionBar
-}) => {
- const anchorRef = useRef()
- const { t } = useI18n()
- const client = useClient()
+const PublicToolbarMoreMenu = ({ files, actions, children }) => {
+ const moreButtonRef = useRef()
const { isMobile } = useBreakpoints()
- const { showAlert } = useAlert()
const [menuIsVisible, setMenuVisible] = useState(false)
@@ -37,23 +21,33 @@ const PublicToolbarMoreMenu = ({
return (
<>
-
+
{menuIsVisible && (
-
- {children}
- {isMobile && files.length > 0 && (
- downloadFiles(client, files, { showAlert, t })}
- left={}
- >
- {t('toolbar.menu_download')}
-
- )}
- {isMobile && hasWriteAccess && }
- {files.length > 1 && }
-
+
+ {React.Children.map(children, child => {
+ if (React.isValidElement(child)) {
+ return React.cloneElement(child, {
+ onClick: () => {
+ child.props.onClick?.()
+ closeMenu()
+ }
+ })
+ }
+ })}
+
)}
>
)
diff --git a/src/styles/toolbar.styl b/src/styles/toolbar.styl
index 789ee98603..b745f8518d 100644
--- a/src/styles/toolbar.styl
+++ b/src/styles/toolbar.styl
@@ -23,12 +23,3 @@
.fil-toolbar-trash
margin-left auto
display flex
-
-.menu-recipients-wrapper
- position relative
-
-.menu-recipients
- position absolute
- right 0
- top -.5rem
-