bigbuffet-rw/app/gabsocial/features/ui/components/link_footer.js

68 lines
2.6 KiB
JavaScript
Raw Normal View History

2020-03-27 13:59:38 -07:00
import React from 'react';
import PropTypes from 'prop-types';
2020-04-14 14:37:17 -07:00
import ImmutablePropTypes from 'react-immutable-proptypes';
2020-03-27 13:59:38 -07:00
import { FormattedMessage, injectIntl } from 'react-intl';
import { Link } from 'react-router-dom';
2020-04-11 13:36:54 -07:00
import { invitesEnabled } from 'gabsocial/initial_state';
2020-03-27 13:59:38 -07:00
import { connect } from 'react-redux';
import { openModal } from '../../../actions/modal';
2020-04-11 12:41:13 -07:00
import { logOut } from 'gabsocial/actions/auth';
2020-03-27 13:59:38 -07:00
2020-04-11 13:36:54 -07:00
// FIXME: Let this be configured
const sourceCode = {
name: 'soapbox-fe',
url: 'https://gitlab.com/soapbox-pub/soapbox-fe',
2020-05-18 13:38:53 -07:00
repository: 'soapbox-pub/soapbox-fe',
version: '0.9-beta',
2020-04-14 11:44:40 -07:00
};
2020-04-11 13:36:54 -07:00
const mapStateToProps = state => {
const me = state.get('me');
return {
account: state.getIn(['accounts', me]),
2020-04-14 11:44:40 -07:00
};
};
2020-03-27 13:59:38 -07:00
const mapDispatchToProps = (dispatch) => ({
onOpenHotkeys() {
dispatch(openModal('HOTKEYS'));
},
2020-04-11 12:41:13 -07:00
onClickLogOut(e) {
dispatch(logOut());
e.preventDefault();
},
2020-03-27 13:59:38 -07:00
});
2020-04-11 13:36:54 -07:00
const LinkFooter = ({ onOpenHotkeys, account, onClickLogOut }) => (
2020-03-27 13:59:38 -07:00
<div className='getting-started__footer'>
<ul>
{(invitesEnabled && account) && <li><a href='/invites'><FormattedMessage id='getting_started.invite' defaultMessage='Invite people' /></a> · </li>}
{account && <li><a href='#' onClick={onOpenHotkeys}><FormattedMessage id='navigation_bar.keyboard_shortcuts' defaultMessage='Hotkeys' /></a> · </li>}
{/* {account && <li><a href='/auth/edit'><FormattedMessage id='getting_started.security' defaultMessage='Security' /></a> · </li>} */}
2020-03-27 13:59:38 -07:00
<li><a href='/about'><FormattedMessage id='navigation_bar.info' defaultMessage='About this server' /></a> · </li>
{/* <li><a href='/settings/applications'><FormattedMessage id='getting_started.developers' defaultMessage='Developers' /></a> · </li> */}
{account && <li><Link to='/auth/sign_out' onClick={onClickLogOut}><FormattedMessage id='navigation_bar.logout' defaultMessage='Logout' /></Link></li>}
2020-03-27 13:59:38 -07:00
</ul>
<p>
<FormattedMessage
id='getting_started.open_source_notice'
2020-04-11 13:36:54 -07:00
defaultMessage='{code_name} is open source software. You can contribute or report issues at {code_link} (v{code_version}).'
values={{
code_name: sourceCode.name,
code_link: <a href={sourceCode.url} rel='noopener' target='_blank'>{sourceCode.repository}</a>,
code_version: sourceCode.version,
}}
2020-03-27 13:59:38 -07:00
/>
</p>
</div>
);
LinkFooter.propTypes = {
2020-04-14 14:37:17 -07:00
account: ImmutablePropTypes.map,
onOpenHotkeys: PropTypes.func.isRequired,
onClickLogOut: PropTypes.func.isRequired,
2020-03-27 13:59:38 -07:00
};
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(LinkFooter));