Skip to content

Commit

Permalink
feat: Display MoreMenu all the time
Browse files Browse the repository at this point in the history
This change is necessary with the upcoming functionality.
As there will no longer be a banner to add/sync the share.
  • Loading branch information
Merkur39 committed Nov 21, 2024
1 parent a702913 commit 51a8b96
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 40 deletions.
35 changes: 15 additions & 20 deletions src/modules/public/PublicToolbarByLink.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,19 @@ import AddMenuProvider from 'modules/drive/AddMenu/AddMenuProvider'
import AddButton from 'modules/drive/Toolbar/components/AddButton'
import { DownloadFilesButton } from 'modules/public/DownloadButton'
import PublicToolbarMoreMenu from 'modules/public/PublicToolbarMoreMenu'
import { isFilesIsFile, openExternalLink } from 'modules/public/helpers'
import { openExternalLink } from 'modules/public/helpers'
import { useSelectionContext } from 'modules/selection/SelectionProvider'

const PublicToolbarByLink = ({
files,
hasWriteAccess,
refreshFolderContent
}) => {
const isFile = isFilesIsFile(files)
const { isMobile } = useBreakpoints()
const { t } = useI18n()
const { displayedFolder } = useDisplayedFolder()
const { showSelectionBar, isSelectionBarVisible } = useSelectionContext()

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

return (
<>
<BarRightOnMobile>
Expand All @@ -47,22 +44,20 @@ const PublicToolbarByLink = ({
)}
</>
)}
{shouldDisplayMoreMenu && (
<PublicToolbarMoreMenu
files={files}
hasWriteAccess={hasWriteAccess}
showSelectionBar={showSelectionBar}
>
{isMobile && (
<ActionMenuItem
onClick={() => openExternalLink(HOME_LINK_HREF)}
left={<Icon icon="to-the-cloud" />}
>
{t('Share.create-cozy')}
</ActionMenuItem>
)}
</PublicToolbarMoreMenu>
)}
<PublicToolbarMoreMenu
files={files}
hasWriteAccess={hasWriteAccess}
showSelectionBar={showSelectionBar}
>
{isMobile && (
<ActionMenuItem
onClick={() => openExternalLink(HOME_LINK_HREF)}
left={<Icon icon="to-the-cloud" />}
>
{t('Share.create-cozy')}
</ActionMenuItem>
)}
</PublicToolbarMoreMenu>
</AddMenuProvider>
</BarRightOnMobile>
</>
Expand Down
32 changes: 12 additions & 20 deletions src/modules/public/PublicToolbarCozyToCozy.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,33 @@ import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
import { BarRightOnMobile } from 'components/Bar'
import { DownloadFilesButton } from 'modules/public/DownloadButton'
import PublicToolbarMoreMenu from 'modules/public/PublicToolbarMoreMenu'
import { isFilesIsFile, openExternalLink } from 'modules/public/helpers'
import { openExternalLink } from 'modules/public/helpers'
import { useSelectionContext } from 'modules/selection/SelectionProvider'

const PublicToolbarCozyToCozy = ({
isSharingShortcutCreated,
discoveryLink,
files
}) => {
const isFile = isFilesIsFile(files)
const { isMobile } = useBreakpoints()
const { t } = useI18n()
const { showSelectionBar } = useSelectionContext()

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

return (
<BarRightOnMobile>
{!isMobile && files.length > 0 && <DownloadFilesButton files={files} />}
{shouldDisplayMoreMenu && (
<PublicToolbarMoreMenu
files={files}
showSelectionBar={showSelectionBar}
<PublicToolbarMoreMenu files={files} showSelectionBar={showSelectionBar}>
<ActionMenuItem
onClick={() => openExternalLink(discoveryLink)}
left={
<Icon icon={isSharingShortcutCreated ? 'sync' : 'to-the-cloud'} />
}
>
<ActionMenuItem
onClick={() => openExternalLink(discoveryLink)}
left={
<Icon icon={isSharingShortcutCreated ? 'sync' : 'to-the-cloud'} />
}
>
{isSharingShortcutCreated
? t('toolbar.menu_sync_cozy')
: t('toolbar.add_to_mine')}
</ActionMenuItem>
</PublicToolbarMoreMenu>
)}
{isSharingShortcutCreated
? t('toolbar.menu_sync_cozy')
: t('toolbar.add_to_mine')}
</ActionMenuItem>
</PublicToolbarMoreMenu>
</BarRightOnMobile>
)
}
Expand Down

0 comments on commit 51a8b96

Please sign in to comment.