bigbuffet-rw/app/soapbox/features/ui/components/features_panel.js

75 lines
2.7 KiB
JavaScript
Raw Normal View History

import { OrderedSet as ImmutableOrderedSet } from 'immutable';
import PropTypes from 'prop-types';
2020-08-08 22:29:28 -07:00
import React from 'react';
import { injectIntl, defineMessages } from 'react-intl';
import { connect } from 'react-redux';
2020-08-09 12:37:02 -07:00
import { NavLink } from 'react-router-dom';
2022-01-10 14:01:24 -08:00
import Icon from 'soapbox/components/icon';
import IconWithCounter from 'soapbox/components/icon_with_counter';
import { getFeatures } from 'soapbox/utils/features';
2020-08-08 22:29:28 -07:00
2020-08-10 20:03:28 -07:00
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' },
2020-08-10 20:03:28 -07:00
});
const mapStateToProps = state => {
const me = state.get('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(),
features,
};
};
export default @connect(mapStateToProps)
2020-08-10 20:03:28 -07:00
@injectIntl
class FeaturesPanel extends React.PureComponent {
static propTypes = {
intl: PropTypes.object.isRequired,
isLocked: PropTypes.bool,
followRequestsCount: PropTypes.number,
features: PropTypes.object.isRequired,
2020-08-10 20:03:28 -07:00
};
2020-08-08 22:29:28 -07:00
render() {
2022-03-21 11:09:01 -07:00
const { intl, isLocked, followRequestsCount, features } = this.props;
2020-08-10 20:03:28 -07:00
2020-08-08 22:29:28 -07:00
return (
2022-03-21 11:09:01 -07:00
<div className='wtf-panel promo-panel panel'>
2020-08-08 22:29:28 -07:00
<div className='promo-panel__container'>
{(isLocked || followRequestsCount > 0) && <NavLink className='promo-panel-item' to='/follow_requests'>
<IconWithCounter src={require('@tabler/icons/icons/user-plus.svg')} count={followRequestsCount} className='promo-panel-item__icon' />
{intl.formatMessage(messages.follow_requests)}
</NavLink>}
2020-11-10 16:22:02 -08:00
{features.bookmarks && (
<NavLink className='promo-panel-item' to='/bookmarks'>
<Icon src={require('@tabler/icons/icons/bookmark.svg')} className='promo-panel-item__icon' />
{intl.formatMessage(messages.bookmarks)}
</NavLink>
)}
2020-11-10 16:22:02 -08:00
{features.lists && (
<NavLink className='promo-panel-item' to='/lists'>
<Icon src={require('@tabler/icons/icons/list.svg')} className='promo-panel-item__icon' />
{intl.formatMessage(messages.lists)}
</NavLink>
)}
2020-08-08 22:29:28 -07:00
</div>
</div>
);
}
}