Skip to content

Commit

Permalink
refactor(DownloadFilesButton): Remove useless code
Browse files Browse the repository at this point in the history
  • Loading branch information
Merkur39 committed Nov 27, 2024
1 parent ebca3c1 commit 668bf97
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,32 @@ import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'

import { downloadFiles } from 'modules/actions/utils'

const DownloadButton = ({ onDownload, ...props }) => (
<Button
onClick={() => onDownload()}
startIcon={<Icon icon={DownloadIcon} />}
{...props}
/>
)

export default DownloadButton

export const DownloadFilesButton = ({ files, className }) => {
export const DownloadFilesButton = ({
files,
variant = 'secondary',
...props
}) => {
const { t } = useI18n()
const client = useClient()
const { showAlert } = useAlert()

const handleClick = () => {
downloadFiles(client, files, { showAlert, t })
}

return (
<DownloadButton
<Button
label={t('toolbar.menu_download')}
data-testid="fil-public-download"
onDownload={() => {
downloadFiles(client, files, { showAlert, t })
}}
variant="secondary"
className={className}
startIcon={<Icon icon={DownloadIcon} />}
onClick={handleClick}
variant={variant}
{...props}
/>
)
}

DownloadFilesButton.propTypes = {
files: PropTypes.array.isRequired
files: PropTypes.array.isRequired,
variant: PropTypes.string
}
2 changes: 1 addition & 1 deletion src/modules/public/PublicToolbarByLink.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ 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 { DownloadFilesButton } from 'modules/public/DownloadFilesButton'
import PublicToolbarMoreMenu from 'modules/public/PublicToolbarMoreMenu'
import { useSelectionContext } from 'modules/selection/SelectionProvider'

Expand Down
2 changes: 1 addition & 1 deletion src/modules/public/PublicToolbarCozyToCozy.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ 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 { DownloadFilesButton } from 'modules/public/DownloadFilesButton'
import PublicToolbarMoreMenu from 'modules/public/PublicToolbarMoreMenu'
import { useSelectionContext } from 'modules/selection/SelectionProvider'

Expand Down

0 comments on commit 668bf97

Please sign in to comment.