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

163 lines
4.7 KiB
JavaScript
Raw Normal View History

import React from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
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'
import { CX, 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
class LinkFooter extends React.PureComponent {
2020-02-04 15:50:18 +00:00
render() {
const {
intl,
noPadding,
onOpenHotkeys,
} = 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 = [
{
href: 'https://help.gab.com',
2020-02-21 00:57:29 +00:00
text: intl.formatMessage(messages.help),
},
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
{
href: '/auth/edit',
2020-02-04 15:50:18 +00:00
text: intl.formatMessage(messages.security),
requiresUser: true,
},
{
to: '/about',
text: intl.formatMessage(messages.about),
},
{
to: '/about/investors',
text: intl.formatMessage(messages.investors),
},
2020-02-04 15:50:18 +00:00
{
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),
},
{
href: '/auth/sign_out',
2020-02-04 15:50:18 +00:00
text: intl.formatMessage(messages.logout),
requiresUser: true,
logout: true,
},
]
const containerClasses = CX({
d: 1,
px10: !noPadding,
mb15: 1,
})
2020-02-04 15:50:18 +00:00
return (
<div className={containerClasses}>
<nav aria-label='Footer' role='navigation' className={[_s.d, _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}`}
to={linkFooterItem.to}
href={linkFooterItem.href}
2020-02-04 15:50:18 +00:00
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: (
<a href={source_url} className={[_s.displayBlock, _s.inherit].join(' ')} 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>
)
}
}
const messages = defineMessages({
investors: { id: 'getting_started.investors', defaultMessage: 'Investors' },
help: { id: 'getting_started.help', defaultMessage: 'Help' },
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' },
salesTerms: { id: 'getting_started.terms_of_sale', defaultMessage: 'Terms of Sale' },
privacy: { id: 'getting_started.privacy', defaultMessage: 'Privacy Policy' },
logout: { id: 'navigation_bar.logout', defaultMessage: 'Logout' },
})
const mapDispatchToProps = (dispatch) => ({
onOpenHotkeys() {
dispatch(openModal('HOTKEYS'))
},
})
LinkFooter.propTypes = {
intl: PropTypes.object.isRequired,
noPadding: PropTypes.bool,
onOpenHotkeys: PropTypes.func.isRequired,
}
export default injectIntl(connect(null, mapDispatchToProps)(LinkFooter))