gab-social/app/javascript/gabsocial/components/link_footer.js

149 lines
4.4 KiB
JavaScript
Raw Normal View History

2020-02-04 15:50:18 +00:00
import {
2020-02-05 22:45:48 +00:00
FormattedMessage,
2020-02-04 15:50:18 +00:00
defineMessages,
injectIntl,
} from 'react-intl'
import { openModal } from '../actions/modal'
import {
repository,
source_url,
me,
} from '../initial_state'
2020-05-01 06:50:27 +01:00
import { DEFAULT_REL } from '../constants'
2020-02-21 00:57:29 +00:00
import Text from './text'
import Button from './button'
2020-02-04 15:50:18 +00:00
const messages = defineMessages({
2020-02-21 00:57:29 +00:00
help: { id: 'getting_started.help', defaultMessage: 'Help' },
2020-02-04 15:50:18 +00:00
invite: { id: 'getting_started.invite', defaultMessage: 'Invite people' },
hotkeys: { id: 'navigation_bar.keyboard_shortcuts', defaultMessage: 'Hotkeys' },
security: { id: 'getting_started.security', defaultMessage: 'Security' },
about: { id: 'navigation_bar.info', defaultMessage: 'About' },
developers: { id: 'getting_started.developers', defaultMessage: 'Developers' },
terms: { id: 'getting_started.terms', defaultMessage: 'Terms of Service' },
dmca: { id: 'getting_started.dmca', defaultMessage: 'DMCA' },
2020-02-21 00:57:29 +00:00
salesTerms: { id: 'getting_started.terms_of_sale', defaultMessage: 'Terms of Sale' },
2020-02-04 15:50:18 +00:00
privacy: { id: 'getting_started.privacy', defaultMessage: 'Privacy Policy' },
logout: { id: 'navigation_bar.logout', defaultMessage: 'Logout' },
})
const mapDispatchToProps = (dispatch) => ({
onOpenHotkeys() {
dispatch(openModal('HOTKEYS'))
},
})
2020-02-24 21:56:07 +00:00
export default
@connect(null, mapDispatchToProps)
2020-02-04 15:50:18 +00:00
@injectIntl
class LinkFooter extends PureComponent {
static propTypes = {
intl: PropTypes.object.isRequired,
onOpenHotkeys: PropTypes.func.isRequired,
}
render() {
const { onOpenHotkeys, intl } = this.props
2020-02-21 00:57:29 +00:00
2020-04-08 02:06:59 +01:00
const currentYear = new Date().getFullYear()
2020-02-04 15:50:18 +00:00
const linkFooterItems = [
{
2020-02-21 00:57:29 +00:00
to: '/help',
text: intl.formatMessage(messages.help),
requiresUser: true,
},
2020-05-03 06:22:49 +01:00
// : todo :
// {
// onClick: onOpenHotkeys,
// text: intl.formatMessage(messages.hotkeys),
// requiresUser: true,
// },
2020-02-04 15:50:18 +00:00
{
to: '/auth/edit',
text: intl.formatMessage(messages.security),
requiresUser: true,
},
{
to: '/about',
text: intl.formatMessage(messages.about),
},
{
to: '/settings/applications',
text: intl.formatMessage(messages.developers),
},
{
to: '/about/tos',
text: intl.formatMessage(messages.terms),
},
{
to: '/about/dmca',
text: intl.formatMessage(messages.dmca),
},
{
to: '/about/sales',
2020-02-21 00:57:29 +00:00
text: intl.formatMessage(messages.salesTerms),
2020-02-04 15:50:18 +00:00
},
{
to: '/about/privacy',
text: intl.formatMessage(messages.privacy),
},
{
to: '/auth/sign_out',
text: intl.formatMessage(messages.logout),
requiresUser: true,
logout: true,
},
]
return (
2020-03-11 23:56:18 +00:00
<div className={[_s.default, _s.px10, _s.mb15].join(' ')}>
2020-02-19 23:57:07 +00:00
<nav aria-label='Footer' role='navigation' className={[_s.default, _s.flexWrap, _s.flexRow].join(' ')}>
2020-02-04 15:50:18 +00:00
{
linkFooterItems.map((linkFooterItem, i) => {
if (linkFooterItem.requiresUser && !me) return null
2020-02-05 22:45:48 +00:00
2020-02-04 15:50:18 +00:00
return (
2020-02-21 00:57:29 +00:00
<Button
2020-04-23 07:13:29 +01:00
isText
2020-02-21 00:57:29 +00:00
underlineOnHover
color='none'
backgroundColor='none'
2020-02-04 15:50:18 +00:00
key={`link-footer-item-${i}`}
href={linkFooterItem.to}
data-method={linkFooterItem.logout ? 'delete' : null}
2020-02-21 00:57:29 +00:00
onClick={linkFooterItem.onClick || null}
2020-04-25 18:00:51 +01:00
className={[_s.mt5, _s.mb5, _s.pr15].join(' ')}
2020-02-04 15:50:18 +00:00
>
2020-04-24 04:17:27 +01:00
<Text size='small' color='tertiary'>
2020-02-21 00:57:29 +00:00
{linkFooterItem.text}
</Text>
</Button>
2020-02-04 15:50:18 +00:00
)
})
}
</nav>
2020-04-24 04:17:27 +01:00
<Text size='small' color='tertiary' className={_s.mt10}>
2020-02-21 00:57:29 +00:00
© {currentYear} Gab AI, Inc.
</Text>
2020-04-24 04:17:27 +01:00
<Text size='small' color='tertiary' tagName='p' className={_s.mt10}>
2020-02-05 22:45:48 +00:00
<FormattedMessage
id='getting_started.open_source_notice'
defaultMessage='Gab Social is open source software. You can contribute or report issues on our self-hosted GitLab at {gitlab}.'
2020-02-21 00:57:29 +00:00
values={{
gitlab: (
2020-05-01 06:50:27 +01:00
<a href={source_url} className={_s.inherit} rel={DEFAULT_REL} target='_blank'>
2020-02-21 00:57:29 +00:00
{repository}
</a>
)
}}
2020-02-05 22:45:48 +00:00
/>
2020-02-21 00:57:29 +00:00
</Text>
2020-02-04 15:50:18 +00:00
</div>
)
}
}