2020-08-08 22:29:28 -07:00
|
|
|
import React from 'react';
|
2021-03-27 08:50:21 -07:00
|
|
|
import { connect } from 'react-redux';
|
2020-08-10 20:03:28 -07:00
|
|
|
import PropTypes from 'prop-types';
|
2020-08-08 22:29:28 -07:00
|
|
|
import Icon from 'soapbox/components/icon';
|
2021-03-27 08:50:21 -07:00
|
|
|
import IconWithCounter from 'soapbox/components/icon_with_counter';
|
2020-08-09 12:37:02 -07:00
|
|
|
import { NavLink } from 'react-router-dom';
|
2020-08-10 20:03:28 -07:00
|
|
|
import { injectIntl, defineMessages } from 'react-intl';
|
2021-03-27 08:50:21 -07:00
|
|
|
import { OrderedSet as ImmutableOrderedSet } from 'immutable';
|
2021-08-23 13:31:42 -07:00
|
|
|
import { getFeatures } from 'soapbox/utils/features';
|
|
|
|
import { getBaseURL } from 'soapbox/utils/accounts';
|
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' },
|
2021-03-27 08:50:21 -07:00
|
|
|
follow_requests: { id: 'navigation_bar.follow_requests', defaultMessage: 'Follow requests' },
|
2020-08-10 20:03:28 -07:00
|
|
|
});
|
|
|
|
|
2021-03-27 08:50:21 -07:00
|
|
|
const mapStateToProps = state => {
|
|
|
|
const me = state.get('me');
|
2021-08-23 13:31:42 -07:00
|
|
|
const account = state.getIn(['accounts', me]);
|
|
|
|
|
|
|
|
const instance = state.get('instance');
|
|
|
|
const features = getFeatures(instance);
|
|
|
|
|
2021-03-27 08:50:21 -07:00
|
|
|
return {
|
|
|
|
isLocked: state.getIn(['accounts', me, 'locked']),
|
|
|
|
followRequestsCount: state.getIn(['user_lists', 'follow_requests', 'items'], ImmutableOrderedSet()).count(),
|
2021-08-23 13:31:42 -07:00
|
|
|
baseURL: getBaseURL(account),
|
|
|
|
features,
|
2021-03-27 08:50:21 -07:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default @connect(mapStateToProps)
|
2020-08-10 20:03:28 -07:00
|
|
|
@injectIntl
|
|
|
|
class FeaturesPanel extends React.PureComponent {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
intl: PropTypes.object.isRequired,
|
2021-03-27 08:50:21 -07:00
|
|
|
isLocked: PropTypes.bool,
|
|
|
|
followRequestsCount: PropTypes.number,
|
2021-08-23 13:31:42 -07:00
|
|
|
baseURL: PropTypes.string,
|
|
|
|
features: PropTypes.object.isRequired,
|
2020-08-10 20:03:28 -07:00
|
|
|
};
|
2020-08-08 22:29:28 -07:00
|
|
|
|
|
|
|
render() {
|
2021-08-23 13:31:42 -07:00
|
|
|
const { intl, isLocked, followRequestsCount, baseURL, features } = this.props;
|
2020-08-10 20:03:28 -07:00
|
|
|
|
2020-08-08 22:29:28 -07:00
|
|
|
return (
|
|
|
|
<div className='wtf-panel promo-panel'>
|
|
|
|
<div className='promo-panel__container'>
|
|
|
|
|
2020-11-10 16:22:02 -08:00
|
|
|
<NavLink className='promo-panel-item' to='/settings/profile'>
|
|
|
|
<Icon id='user' className='promo-panel-item__icon' fixedWidth />
|
|
|
|
{intl.formatMessage(messages.edit_profile)}
|
|
|
|
</NavLink>
|
|
|
|
|
2021-03-27 08:50:21 -07:00
|
|
|
{(isLocked || followRequestsCount > 0) && <NavLink className='promo-panel-item' to='/follow_requests'>
|
|
|
|
<IconWithCounter icon='user-plus' count={followRequestsCount} fixedWidth />
|
|
|
|
{intl.formatMessage(messages.follow_requests)}
|
|
|
|
</NavLink>}
|
2020-11-10 16:22:02 -08:00
|
|
|
|
|
|
|
<NavLink className='promo-panel-item' to='/bookmarks'>
|
|
|
|
<Icon id='bookmark' className='promo-panel-item__icon' fixedWidth />
|
|
|
|
{intl.formatMessage(messages.bookmarks)}
|
|
|
|
</NavLink>
|
|
|
|
|
|
|
|
<NavLink className='promo-panel-item' to='/lists'>
|
|
|
|
<Icon id='list' className='promo-panel-item__icon' fixedWidth />
|
|
|
|
{intl.formatMessage(messages.lists)}
|
|
|
|
</NavLink>
|
|
|
|
|
2021-08-23 13:31:42 -07:00
|
|
|
{features.securityAPI ? (
|
|
|
|
<NavLink className='promo-panel-item' to='/auth/edit'>
|
|
|
|
<Icon id='lock' className='promo-panel-item__icon' fixedWidth />
|
|
|
|
{intl.formatMessage(messages.security)}
|
|
|
|
</NavLink>
|
|
|
|
) : (
|
|
|
|
<a className='promo-panel-item' href={`${baseURL}/auth/edit`}>
|
|
|
|
<Icon id='lock' className='promo-panel-item__icon' fixedWidth />
|
|
|
|
{intl.formatMessage(messages.security)}
|
|
|
|
</a>
|
|
|
|
)}
|
2020-11-10 16:22:02 -08:00
|
|
|
|
2021-08-23 13:31:42 -07:00
|
|
|
{features.settingsStore ? (
|
|
|
|
<NavLink className='promo-panel-item' to='/settings/preferences'>
|
|
|
|
<Icon id='cog' className='promo-panel-item__icon' fixedWidth />
|
|
|
|
{intl.formatMessage(messages.preferences)}
|
|
|
|
</NavLink>
|
|
|
|
) : (
|
|
|
|
<a className='promo-panel-item' href={`${baseURL}/settings/preferences`}>
|
|
|
|
<Icon id='cog' className='promo-panel-item__icon' fixedWidth />
|
|
|
|
{intl.formatMessage(messages.preferences)}
|
|
|
|
</a>
|
|
|
|
)}
|
2020-08-08 22:29:28 -07:00
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|