import React from 'react' import PropTypes from 'prop-types' import { connect } from 'react-redux' import ImmutablePropTypes from 'react-immutable-proptypes' import ImmutablePureComponent from 'react-immutable-pure-component' import { openPopover } from '../../actions/popover' import { changeSetting, saveSettings } from '../../actions/settings' import { openModal } from '../../actions/modal' import { me } from '../../initial_state' import { makeGetAccount } from '../../selectors' import { THEMES, DEFAULT_THEME, MODAL_COMPOSE, POPOVER_NAV_SETTINGS, MODAL_DECK_COLUMN_ADD, } from '../../constants' import Avatar from '../avatar' import BackButton from '../back_button' import Button from '../button' import Icon from '../icon' import NavigationBarButton from '../navigation_bar_button' import Divider from '../divider' class DeckSidebar extends ImmutablePureComponent { handleOnClickLightBulb = () => { let index = THEMES.findIndex((t) => t === this.props.theme) const nextIndex = (index === THEMES.length -1) ? 0 : index += 1 const newTheme = THEMES[nextIndex] this.props.onChange('theme', newTheme) } handleOnOpenNavSettingsPopover = () => { this.props.onOpenNavSettingsPopover(this.avatarNode) } handleOnOpenNewColumnModel = () => { this.props.onOpenNewColumnModal() } handleOnOpenComposeModal = () => { this.props.onOpenComposeModal() } setAvatarNode = (c) => { this.avatarNode = c } render() { const { account, logoDisabled } = this.props const isPro = !!account ? account.get('is_pro') : false return (

{ isPro && }
) } } const mapStateToProps = (state) => ({ account: makeGetAccount()(state, me), theme: state.getIn(['settings', 'displayOptions', 'theme'], DEFAULT_THEME), logoDisabled: state.getIn(['settings', 'displayOptions', 'logoDisabled'], false), }) const mapDispatchToProps = (dispatch) => ({ onOpenNavSettingsPopover(targetRef) { dispatch(openPopover(POPOVER_NAV_SETTINGS, { targetRef, position: 'top-start', })) }, onOpenNewColumnModal() { dispatch(openModal(MODAL_DECK_COLUMN_ADD)) }, onOpenComposeModal() { dispatch(openModal(MODAL_COMPOSE)) }, onChange(key, value) { dispatch(changeSetting(['displayOptions', key], value)) dispatch(saveSettings()) }, }) DeckSidebar.propTypes = { account: ImmutablePropTypes.map, onOpenNavSettingsPopover: PropTypes.func.isRequired, onOpenNewColumnModal: PropTypes.func.isRequired, onOpenComposeModal: PropTypes.func.isRequired, theme: PropTypes.string, logoDisabled: PropTypes.bool, } export default connect(mapStateToProps, mapDispatchToProps)(DeckSidebar)