2020-02-19 23:57:07 +00:00
|
|
|
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'
|
2020-02-24 21:56:07 +00:00
|
|
|
import { openModal } from '../actions/modal'
|
2020-02-19 23:57:07 +00:00
|
|
|
import { me } from '../initial_state'
|
|
|
|
import { makeGetAccount } from '../selectors'
|
|
|
|
import SidebarSectionTitle from './sidebar_section_title'
|
|
|
|
import SidebarSectionItem from './sidebar_section_item'
|
2020-02-22 23:26:23 +00:00
|
|
|
import SidebarHeader from './sidebar_header'
|
2020-02-19 23:57:07 +00:00
|
|
|
|
|
|
|
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())
|
|
|
|
},
|
2020-02-24 21:56:07 +00:00
|
|
|
onOpenComposeModal() {
|
2020-03-11 23:56:18 +00:00
|
|
|
dispatch(openModal('PRO_UPGRADE'))
|
2020-02-24 21:56:07 +00:00
|
|
|
},
|
2020-02-19 23:57:07 +00:00
|
|
|
})
|
|
|
|
|
2020-02-24 21:56:07 +00:00
|
|
|
export default
|
|
|
|
@connect(mapStateToProps, mapDispatchToProps)
|
2020-02-19 23:57:07 +00:00
|
|
|
@injectIntl
|
|
|
|
class Sidebar extends ImmutablePureComponent {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
account: ImmutablePropTypes.map,
|
|
|
|
sidebarOpen: PropTypes.bool,
|
|
|
|
onClose: PropTypes.func.isRequired,
|
2020-02-24 21:56:07 +00:00
|
|
|
onOpenComposeModal: PropTypes.func.isRequired,
|
2020-02-19 23:57:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-02-24 21:56:07 +00:00
|
|
|
handleOpenComposeModal = () => {
|
|
|
|
console.log("handleOpenComposeModal")
|
|
|
|
this.props.onOpenComposeModal()
|
|
|
|
}
|
|
|
|
|
2020-02-19 23:57:07 +00:00
|
|
|
render() {
|
|
|
|
const { sidebarOpen, intl, account } = this.props
|
|
|
|
const { moreOpen } = this.state
|
|
|
|
|
2020-02-28 15:20:47 +00:00
|
|
|
// : todo :
|
2020-02-19 23:57:07 +00:00
|
|
|
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,
|
|
|
|
},
|
2020-03-02 22:26:25 +00:00
|
|
|
{
|
|
|
|
title: 'Search',
|
|
|
|
icon: 'search-alt',
|
|
|
|
to: '/search',
|
|
|
|
},
|
2020-02-19 23:57:07 +00:00
|
|
|
{
|
|
|
|
title: 'Groups',
|
|
|
|
icon: 'group',
|
|
|
|
to: '/groups',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Lists',
|
|
|
|
icon: 'list',
|
|
|
|
to: '/lists',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Chat',
|
|
|
|
icon: 'chat',
|
2020-02-28 15:20:47 +00:00
|
|
|
to: '',
|
|
|
|
// href: 'https://chat.gab.com',
|
2020-02-19 23:57:07 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'More',
|
|
|
|
icon: 'more',
|
|
|
|
to: '/',
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
2020-02-22 23:26:23 +00:00
|
|
|
// more:
|
|
|
|
// settings/preferences
|
|
|
|
// help
|
|
|
|
// logout
|
|
|
|
|
2020-02-19 23:57:07 +00:00
|
|
|
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',
|
2020-02-28 15:20:47 +00:00
|
|
|
to: '',
|
|
|
|
// href: 'https://apps.gab.com',
|
2020-02-19 23:57:07 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Shop',
|
|
|
|
icon: 'shop',
|
2020-02-28 15:20:47 +00:00
|
|
|
to: '',
|
|
|
|
// href: 'https://shop.dissenter.com',
|
2020-02-19 23:57:07 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Trends',
|
|
|
|
icon: 'trends',
|
2020-02-28 15:20:47 +00:00
|
|
|
to: '',
|
|
|
|
// href: 'https://trends.gab.com',
|
2020-02-19 23:57:07 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Dissenter',
|
|
|
|
icon: 'dissenter',
|
2020-02-28 15:20:47 +00:00
|
|
|
to: '',
|
|
|
|
// href: 'https://dissenter.com',
|
2020-02-19 23:57:07 +00:00
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
return (
|
|
|
|
<header role='banner' className={[_s.default, _s.flexGrow1, _s.z3, _s.alignItemsEnd].join(' ')}>
|
|
|
|
<div className={[_s.default, _s.width240PX].join(' ')}>
|
|
|
|
<div className={[_s.default, _s.positionFixed, _s.top0, _s.height100PC].join(' ')}>
|
2020-03-11 23:56:18 +00:00
|
|
|
<div className={[_s.default, _s.height100PC, _s.width240PX, _s.pr15, _s.my10].join(' ')}>
|
2020-02-19 23:57:07 +00:00
|
|
|
|
2020-02-22 23:26:23 +00:00
|
|
|
<SidebarHeader />
|
2020-02-19 23:57:07 +00:00
|
|
|
|
2020-03-11 23:56:18 +00:00
|
|
|
<nav aria-label='Primary' role='navigation' className={[_s.default, _s.width100PC, _s.mb15].join(' ')}>
|
2020-02-19 23:57:07 +00:00
|
|
|
<SidebarSectionTitle>Menu</SidebarSectionTitle>
|
|
|
|
{
|
|
|
|
menuItems.map((menuItem, i) => (
|
|
|
|
<SidebarSectionItem {...menuItem} key={`sidebar-item-menu-${i}`} />
|
|
|
|
))
|
|
|
|
}
|
|
|
|
<SidebarSectionTitle>Shortcuts</SidebarSectionTitle>
|
|
|
|
{
|
|
|
|
shortcutItems.map((shortcutItem, i) => (
|
|
|
|
<SidebarSectionItem {...shortcutItem} key={`sidebar-item-shortcut-${i}`} />
|
|
|
|
))
|
|
|
|
}
|
|
|
|
<SidebarSectionTitle>Explore</SidebarSectionTitle>
|
|
|
|
{
|
|
|
|
exploreItems.map((exploreItem, i) => (
|
|
|
|
<SidebarSectionItem {...exploreItem} key={`sidebar-item-explore-${i}`} />
|
|
|
|
))
|
|
|
|
}
|
|
|
|
</nav>
|
|
|
|
|
|
|
|
<Button
|
|
|
|
block
|
2020-02-24 21:56:07 +00:00
|
|
|
onClick={this.handleOpenComposeModal}
|
2020-03-11 23:56:18 +00:00
|
|
|
className={[_s.py15, _s.fontSize15PX, _s.fontWeightBold].join(' ')}
|
2020-02-19 23:57:07 +00:00
|
|
|
>
|
|
|
|
Gab
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</header>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|