import { NavLink } from 'react-router-dom' import ImmutablePropTypes from 'react-immutable-proptypes' import ImmutablePureComponent from 'react-immutable-pure-component' import { injectIntl, defineMessages } from 'react-intl' import Button from './button' import { closeSidebar } from '../actions/sidebar' import { me } from '../initial_state' import { makeGetAccount } from '../selectors' import GabLogo from './assets/gab_logo' import SidebarSectionTitle from './sidebar_section_title' import SidebarSectionItem from './sidebar_section_item' const messages = defineMessages({ followers: { id: 'account.followers', defaultMessage: 'Followers' }, follows: { id: 'account.follows', defaultMessage: 'Follows' }, profile: { id: 'account.profile', defaultMessage: 'Profile' }, preferences: { id: 'navigation_bar.preferences', defaultMessage: 'Preferences' }, follow_requests: { id: 'navigation_bar.follow_requests', defaultMessage: 'Follow requests' }, blocks: { id: 'navigation_bar.blocks', defaultMessage: 'Blocked users' }, domain_blocks: { id: 'navigation_bar.domain_blocks', defaultMessage: 'Hidden domains' }, mutes: { id: 'navigation_bar.mutes', defaultMessage: 'Muted users' }, filters: { id: 'navigation_bar.filters', defaultMessage: 'Muted words' }, logout: { id: 'navigation_bar.logout', defaultMessage: 'Logout' }, lists: { id: 'column.lists', defaultMessage: 'Lists', }, apps: { id: 'tabs_bar.apps', defaultMessage: 'Apps' }, more: { id: 'sidebar.more', defaultMessage: 'More' }, pro: { id: 'promo.gab_pro', defaultMessage: 'Upgrade to GabPRO' }, trends: { id: 'promo.trends', defaultMessage: 'Trends' }, search: { id: 'tabs_bar.search', defaultMessage: 'Search' }, shop: { id: 'tabs_bar.shop', defaultMessage: 'Store - Buy Merch' }, donate: { id: 'tabs_bar.donate', defaultMessage: 'Make a Donation' }, }) const mapStateToProps = state => { const getAccount = makeGetAccount() return { account: getAccount(state, me), sidebarOpen: state.get('sidebar').sidebarOpen, } } const mapDispatchToProps = (dispatch) => ({ onClose() { dispatch(closeSidebar()) }, }) export default @connect(mapStateToProps, mapDispatchToProps) @injectIntl class Sidebar extends ImmutablePureComponent { static propTypes = { intl: PropTypes.object.isRequired, account: ImmutablePropTypes.map, sidebarOpen: PropTypes.bool, onClose: PropTypes.func.isRequired, } state = { moreOpen: false, } componentDidUpdate() { if (!me) return if (this.props.sidebarOpen) { document.body.classList.add('with-modals--active') } else { document.body.classList.remove('with-modals--active') } } toggleMore = () => { this.setState({ moreOpen: !this.state.moreOpen }) } handleSidebarClose = () => { this.props.onClose() this.setState({ moreOpen: false, }) } render() { const { sidebarOpen, intl, account } = this.props const { moreOpen } = this.state if (!me || !account) return null const acct = account.get('acct') const isPro = account.get('is_pro') const moreIcon = moreOpen ? 'minus' : 'plus' const moreContainerStyle = { display: moreOpen ? 'block' : 'none' } const menuItems = [ { title: 'Home', icon: 'home', to: '/', count: 124, }, { title: 'Notifications', icon: 'notifications', to: '/notifications', count: 40, }, { title: 'Groups', icon: 'group', to: '/groups', }, { title: 'Lists', icon: 'list', to: '/lists', }, { title: 'Chat', icon: 'chat', to: '/', }, { title: 'More', icon: 'more', to: '/', }, ] const shortcutItems = [ { title: 'Meme Group', icon: 'group', to: '/', count: 0, }, { title: '@andrew', image: 'http://localhost:3000/system/accounts/avatars/000/000/001/original/260e8c96c97834da.jpeg?1562898139', to: '/', count: 3, }, ] const exploreItems = [ { title: 'Apps', icon: 'apps', to: '/', }, { title: 'Shop', icon: 'shop', to: '/', }, { title: 'Trends', icon: 'trends', to: '/', }, { title: 'Dissenter', icon: 'dissenter', to: '/', }, ] return (

) } }