Skip to content

Commit

Permalink
feat: Add openExternalLink action
Browse files Browse the repository at this point in the history
  • Loading branch information
Merkur39 committed Nov 21, 2024
1 parent 8fee389 commit fe07a2e
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/modules/actions/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
import ListItemText from 'cozy-ui/transpiled/react/ListItemText'

import { downloadFiles, restoreFiles } from './utils'
import { HOME_LINK_HREF } from 'constants/config'
import { isEncryptedFolder, isEncryptedFile } from 'lib/encryption'
import { navigateToModal } from 'modules/actions/helpers'
import DeleteConfirm from 'modules/drive/DeleteConfirm'
Expand Down Expand Up @@ -221,3 +222,35 @@ export const restore = ({ t, refresh, client }) => {
})
}
}

export const openExternalLink = ({ t, isSharingShortcutCreated, link }) => {
const label =
link === HOME_LINK_HREF
? t('Share.create-cozy')
: isSharingShortcutCreated
? t('toolbar.menu_sync_cozy')
: t('toolbar.add_to_mine')
const icon =
!isSharingShortcutCreated || link === HOME_LINK_HREF
? 'to-the-cloud'
: 'sync'

return {
name: 'openExternalLink',
label,
icon,
action: () => {
openExternalLink(link)
},
Component: forwardRef(function OpenExternalLink(props, ref) {
return (
<ActionsMenuItem isListItem {...props} ref={ref}>
<ListItemIcon>
<Icon icon={icon} />
</ListItemIcon>
<ListItemText primary={label} />
</ActionsMenuItem>
)
})
}
}

0 comments on commit fe07a2e

Please sign in to comment.