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

147 lines
4.4 KiB
JavaScript
Raw Normal View History

2020-02-04 15:50:18 +00:00
import moment from 'moment'
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-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'))
},
})
export default @connect(null, mapDispatchToProps)
@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
const currentYear = moment().format('YYYY')
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-02-04 15:50:18 +00:00
onClick: onOpenHotkeys,
text: intl.formatMessage(messages.hotkeys),
requiresUser: true,
},
{
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-02-21 00:57:29 +00:00
<div className={[_s.default, _s.paddingHorizontal10PX, _s.marginBottom15PX].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
text
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}
className={[_s.marginVertical5PX, _s.paddingRight15PX].join(' ')}
2020-02-04 15:50:18 +00:00
>
2020-02-21 00:57:29 +00:00
<Text size='small' color='secondary'>
{linkFooterItem.text}
</Text>
</Button>
2020-02-04 15:50:18 +00:00
)
})
}
</nav>
2020-02-21 00:57:29 +00:00
<Text size='small' color='secondary' className={_s.marginTop10PX}>
© {currentYear} Gab AI, Inc.
</Text>
<Text size='small' color='secondary' tagName='p' className={_s.marginTop10PX}>
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.inherit} rel='noopener' target='_blank'>
{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>
)
}
}