Skip to content

Commit

Permalink
feat: Replace qualify action with infos action
Browse files Browse the repository at this point in the history
  • Loading branch information
JF-Cozy committed Dec 18, 2024
1 parent 54a38a4 commit 6194ba0
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@
"error": "An error occurred, please try again."
},
"actions": {
"infos": "Details and qualification",
"duplicateTo": {
"label": "Duplicate to…"
}
Expand Down
1 change: 1 addition & 0 deletions src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,7 @@
"error": "Une erreur est survenue, merci de réessayer."
},
"actions": {
"infos": "Détails et qualification",
"duplicateTo": {
"label": "Dupliquer vers…"
}
Expand Down
1 change: 1 addition & 0 deletions src/modules/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export { qualify } from './qualify'
export { versions } from './versions'
export { restore } from './restore'
export { select } from './select'
export { infos } from './infos'
export { addItems } from './addItems'
41 changes: 41 additions & 0 deletions src/modules/actions/infos.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React, { forwardRef } from 'react'

import { isFile } from 'cozy-client/dist/models/file'
import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem'
import Icon from 'cozy-ui/transpiled/react/Icon'
import InfoIcon from 'cozy-ui/transpiled/react/Icons/Info'
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
import ListItemText from 'cozy-ui/transpiled/react/ListItemText'

const makeComponent = (label, icon) => {
const Component = forwardRef((props, ref) => {
return (
<ActionsMenuItem {...props} ref={ref}>
<ListItemIcon>
<Icon icon={icon} />
</ListItemIcon>
<ListItemText primary={label} />
</ActionsMenuItem>
)
})

Component.displayName = 'infos'

return Component
}

export const infos = ({ t, navigate }) => {
const icon = InfoIcon
const label = t('actions.infos')

return {
name: 'infos',
icon,
label,
displayCondition: docs => isFile(docs[0]),
Component: makeComponent(label, icon),
action: docs => {
navigate(`file/${docs[0]._id}`)
}
}
}
4 changes: 2 additions & 2 deletions src/modules/views/Drive/DriveFolderView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
download,
trash,
rename,
qualify,
infos,
versions,
hr
} from 'modules/actions'
Expand Down Expand Up @@ -166,12 +166,12 @@ const DriveFolderView = () => {
share,
download,
hr,
qualify,
rename,
moveTo,
duplicateTo,
addToFavorites,
removeFromFavorites,
infos,
hr,
versions,
hr,
Expand Down
5 changes: 3 additions & 2 deletions src/modules/views/Favorites/FavoritesView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { useModalContext } from 'lib/ModalContext'
import {
download,
rename,
qualify,
infos,
versions,
share,
hr,
Expand Down Expand Up @@ -99,15 +99,16 @@ const FavoritesView: FC = () => {
}

const actions = makeActions(
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
[
share,
download,
hr,
qualify,
rename,
moveTo,
addToFavorites,
removeFromFavorites,
infos,
hr,
versions,
hr,
Expand Down
4 changes: 2 additions & 2 deletions src/modules/views/Recent/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
download,
trash,
rename,
qualify,
infos,
versions,
hr,
share
Expand Down Expand Up @@ -89,11 +89,11 @@ export const RecentView = () => {
share,
download,
hr,
qualify,
rename,
moveTo,
addToFavorites,
removeFromFavorites,
infos,
hr,
versions,
hr,
Expand Down
4 changes: 2 additions & 2 deletions src/modules/views/Sharings/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import FolderViewBody from '../Folder/FolderViewBody'
import FolderViewHeader from '../Folder/FolderViewHeader'
import useHead from 'components/useHead'
import { useModalContext } from 'lib/ModalContext'
import { download, rename, qualify, versions, share, hr } from 'modules/actions'
import { download, rename, infos, versions, share, hr } from 'modules/actions'
import { addToFavorites } from 'modules/actions/components/addToFavorites'
import { moveTo } from 'modules/actions/components/moveTo'
import { removeFromFavorites } from 'modules/actions/components/removeFromFavorites'
Expand Down Expand Up @@ -85,11 +85,11 @@ export const SharingsView = ({ sharedDocumentIds = [] }) => {
share,
download,
hr,
qualify,
rename,
moveTo,
addToFavorites,
removeFromFavorites,
infos,
hr,
versions
],
Expand Down

0 comments on commit 6194ba0

Please sign in to comment.