Skip to content

Commit

Permalink
feat: Add menu item for legal notice
Browse files Browse the repository at this point in the history
  • Loading branch information
cballevre committed Nov 20, 2024
1 parent c7da598 commit e691eab
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/Settings/SettingsContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
logout
} from 'components/Settings/actions'
import { termsOfService } from 'components/Settings/actions/termsOfService'
import { legalNotice } from 'components/Settings/actions/legalNotice'
import useI18n from 'components/useI18n'

const SettingsContent = ({
Expand All @@ -46,6 +47,7 @@ const SettingsContent = ({
divider,
help,
contact,
legalNotice,
termsOfService,
logout
],
Expand Down
44 changes: 44 additions & 0 deletions src/components/Settings/actions/legalNotice.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React, { forwardRef } from 'react'

import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem'
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
import Icon from 'cozy-ui/transpiled/react/Icon'
import JusticeIcon from 'cozy-ui/transpiled/react/Icons/Justice'
import OpenwithIcon from 'cozy-ui/transpiled/react/Icons/Openwith'

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

Component.displayName = 'LegalNoticeAction'

export const legalNotice = ({ t, instanceInfo }) => {
const icon = JusticeIcon
const label = t('legalNotice')

return {
name: 'legalNotice',
icon,
label,
displayCondition: () => !!instanceInfo.instance.data.legal_notice_url,
action: () => {
window.open(
instanceInfo.instance.data.legal_notice_url,
'_blank',
'noopener, noreferrer'
)
},
Component
}
}
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"logout": "Log out",
"soon": "soon",
"termsOfService": "Terms of Service",
"legalNotice": "Legal notice",
"error_UnavailableStack": "The stack is unreachable (connection timed-out).",
"error_UnauthorizedStack": "Some permissions are missing, the application can't access the requested resource on the stack.",
"no_apps": "No applications found on the Cozy.",
Expand Down
1 change: 1 addition & 0 deletions src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"logout": "Déconnexion",
"soon": "à venir",
"termsOfService": "Conditions générales d’utilisation",
"legalNotice": "Mentions légales",
"error_UnavailableStack": "Connexion à la stack impossible (connection timed-out)",
"error_UnauthorizedStack": "Des permissions sont manquante, l'application ne peut accéder aux ressources demandées.",
"no_apps": "Pas d'applications Cozy trouvées.",
Expand Down

0 comments on commit e691eab

Please sign in to comment.