import React from 'react'; import { connect } from 'react-redux'; import PropTypes from 'prop-types'; import Icon from 'soapbox/components/icon'; import IconWithCounter from 'soapbox/components/icon_with_counter'; import { NavLink } from 'react-router-dom'; import { injectIntl, defineMessages } from 'react-intl'; import { OrderedSet as ImmutableOrderedSet } from 'immutable'; import { getFeatures } from 'soapbox/utils/features'; import { getBaseURL } from 'soapbox/utils/accounts'; const messages = defineMessages({ edit_profile: { id: 'account.edit_profile', defaultMessage: 'Edit Profile' }, preferences: { id: 'navigation_bar.preferences', defaultMessage: 'Preferences' }, security: { id: 'navigation_bar.security', defaultMessage: 'Security' }, lists: { id: 'column.lists', defaultMessage: 'Lists' }, bookmarks: { id: 'column.bookmarks', defaultMessage: 'Bookmarks' }, follow_requests: { id: 'navigation_bar.follow_requests', defaultMessage: 'Follow requests' }, }); const mapStateToProps = state => { const me = state.get('me'); const account = state.getIn(['accounts', me]); const instance = state.get('instance'); const features = getFeatures(instance); return { isLocked: state.getIn(['accounts', me, 'locked']), followRequestsCount: state.getIn(['user_lists', 'follow_requests', 'items'], ImmutableOrderedSet()).count(), baseURL: getBaseURL(account), features, }; }; export default @connect(mapStateToProps) @injectIntl class FeaturesPanel extends React.PureComponent { static propTypes = { intl: PropTypes.object.isRequired, isLocked: PropTypes.bool, followRequestsCount: PropTypes.number, baseURL: PropTypes.string, features: PropTypes.object.isRequired, }; render() { const { intl, isLocked, followRequestsCount, baseURL, features } = this.props; return (
{intl.formatMessage(messages.edit_profile)} {(isLocked || followRequestsCount > 0) && {intl.formatMessage(messages.follow_requests)} } {features.bookmarks && ( {intl.formatMessage(messages.bookmarks)} )} {features.lists && ( {intl.formatMessage(messages.lists)} )} {features.securityAPI ? ( {intl.formatMessage(messages.security)} ) : ( {intl.formatMessage(messages.security)} )} {features.settingsStore ? ( {intl.formatMessage(messages.preferences)} ) : ( {intl.formatMessage(messages.preferences)} )}
); } }