Merge branch 'more-feature-flags' into 'develop'
Feature flags: Lists and Bookmarks See merge request soapbox-pub/soapbox-fe!769
This commit is contained in:
commit
b857729713
7 changed files with 66 additions and 142 deletions
|
@ -218,14 +218,14 @@ class SidebarMenu extends ImmutablePureComponent {
|
|||
<Icon id='bitcoin' />
|
||||
<span className='sidebar-menu-item__title'>{intl.formatMessage(messages.donate_crypto)}</span>
|
||||
</NavLink>}
|
||||
<NavLink className='sidebar-menu-item' to='/lists' onClick={this.handleClose}>
|
||||
{features.lists && <NavLink className='sidebar-menu-item' to='/lists' onClick={this.handleClose}>
|
||||
<Icon id='list' />
|
||||
<span className='sidebar-menu-item__title'>{intl.formatMessage(messages.lists)}</span>
|
||||
</NavLink>
|
||||
<NavLink className='sidebar-menu-item' to='/bookmarks' onClick={this.handleClose}>
|
||||
</NavLink>}
|
||||
{features.bookmarks && <NavLink className='sidebar-menu-item' to='/bookmarks' onClick={this.handleClose}>
|
||||
<Icon id='bookmark' />
|
||||
<span className='sidebar-menu-item__title'>{intl.formatMessage(messages.bookmarks)}</span>
|
||||
</NavLink>
|
||||
</NavLink>}
|
||||
</div>
|
||||
|
||||
<div className='sidebar-menu__section'>
|
||||
|
|
|
@ -290,7 +290,7 @@ class StatusActionBar extends ImmutablePureComponent {
|
|||
}
|
||||
|
||||
_makeMenu = (publicStatus) => {
|
||||
const { status, intl, withDismiss, withGroupAdmin, me, isStaff, isAdmin } = this.props;
|
||||
const { status, intl, withDismiss, withGroupAdmin, me, features, isStaff, isAdmin } = this.props;
|
||||
const mutingConversation = status.get('muted');
|
||||
const ownAccount = status.getIn(['account', 'id']) === me;
|
||||
|
||||
|
@ -303,7 +303,9 @@ class StatusActionBar extends ImmutablePureComponent {
|
|||
// menu.push({ text: intl.formatMessage(messages.embed), action: this.handleEmbed });
|
||||
}
|
||||
|
||||
menu.push({ text: intl.formatMessage(status.get('bookmarked') ? messages.unbookmark : messages.bookmark), action: this.handleBookmarkClick });
|
||||
if (features.bookmarks) {
|
||||
menu.push({ text: intl.formatMessage(status.get('bookmarked') ? messages.unbookmark : messages.bookmark), action: this.handleBookmarkClick });
|
||||
}
|
||||
|
||||
if (!me) {
|
||||
return menu;
|
||||
|
|
|
@ -189,16 +189,21 @@ class Header extends ImmutablePureComponent {
|
|||
menu.push({ text: intl.formatMessage(messages.showReblogs, { name: account.get('username') }), action: this.props.onReblogToggle });
|
||||
}
|
||||
|
||||
if (account.getIn(['relationship', 'subscribing'])) {
|
||||
menu.push({ text: intl.formatMessage(messages.unsubscribe, { name: account.get('username') }), action: this.props.onSubscriptionToggle });
|
||||
} else {
|
||||
menu.push({ text: intl.formatMessage(messages.subscribe, { name: account.get('username') }), action: this.props.onSubscriptionToggle });
|
||||
if (features.accountSubscriptions) {
|
||||
if (account.getIn(['relationship', 'subscribing'])) {
|
||||
menu.push({ text: intl.formatMessage(messages.unsubscribe, { name: account.get('username') }), action: this.props.onSubscriptionToggle });
|
||||
} else {
|
||||
menu.push({ text: intl.formatMessage(messages.subscribe, { name: account.get('username') }), action: this.props.onSubscriptionToggle });
|
||||
}
|
||||
}
|
||||
|
||||
if (features.lists) {
|
||||
menu.push({ text: intl.formatMessage(messages.add_or_remove_from_list), action: this.props.onAddToList });
|
||||
}
|
||||
|
||||
menu.push({ text: intl.formatMessage(messages.add_or_remove_from_list), action: this.props.onAddToList });
|
||||
// menu.push({ text: intl.formatMessage(account.getIn(['relationship', 'endorsed']) ? messages.unendorse : messages.endorse), action: this.props.onEndorseToggle });
|
||||
menu.push(null);
|
||||
} else if (features.unrestrictedLists) {
|
||||
} else if (features.lists && features.unrestrictedLists) {
|
||||
menu.push({ text: intl.formatMessage(messages.add_or_remove_from_list), action: this.props.onAddToList });
|
||||
}
|
||||
|
||||
|
|
|
@ -1,103 +0,0 @@
|
|||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { openModal } from '../../../actions/modal';
|
||||
import PropTypes from 'prop-types';
|
||||
import DropdownMenuContainer from '../../../containers/dropdown_menu_container';
|
||||
import { isStaff } from 'soapbox/utils/accounts';
|
||||
import { defineMessages, injectIntl } from 'react-intl';
|
||||
import { logOut } from 'soapbox/actions/auth';
|
||||
|
||||
const messages = defineMessages({
|
||||
profile: { id: 'account.profile', defaultMessage: 'Profile' },
|
||||
messages: { id: 'navigation_bar.messages', defaultMessage: 'Messages' },
|
||||
lists: { id: 'navigation_bar.lists', defaultMessage: 'Lists' },
|
||||
bookmarks: { id: 'navigation_bar.bookmarks', defaultMessage: 'Bookmarks' },
|
||||
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' },
|
||||
admin_settings: { id: 'navigation_bar.admin_settings', defaultMessage: 'Admin settings' },
|
||||
soapbox_config: { id: 'navigation_bar.soapbox_config', defaultMessage: 'Soapbox config' },
|
||||
import_data: { id: 'navigation_bar.import_data', defaultMessage: 'Import data' },
|
||||
security: { id: 'navigation_bar.security', defaultMessage: 'Security' },
|
||||
logout: { id: 'navigation_bar.logout', defaultMessage: 'Logout' },
|
||||
keyboard_shortcuts: { id: 'navigation_bar.keyboard_shortcuts', defaultMessage: 'Hotkeys' },
|
||||
});
|
||||
|
||||
const mapStateToProps = state => {
|
||||
const me = state.get('me');
|
||||
return {
|
||||
meUsername: state.getIn(['accounts', me, 'username']),
|
||||
isStaff: isStaff(state.getIn(['accounts', me])),
|
||||
};
|
||||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch, { intl }) => ({
|
||||
onOpenHotkeys() {
|
||||
dispatch(openModal('HOTKEYS'));
|
||||
},
|
||||
onClickLogOut(e) {
|
||||
dispatch(logOut(intl));
|
||||
e.preventDefault();
|
||||
},
|
||||
});
|
||||
|
||||
class ActionBar extends React.PureComponent {
|
||||
|
||||
static propTypes = {
|
||||
intl: PropTypes.object.isRequired,
|
||||
size: PropTypes.number,
|
||||
onOpenHotkeys: PropTypes.func.isRequired,
|
||||
onClickLogOut: PropTypes.func.isRequired,
|
||||
meUsername: PropTypes.string,
|
||||
isStaff: PropTypes.bool.isRequired,
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
isStaff: false,
|
||||
}
|
||||
|
||||
handleHotkeyClick = () => {
|
||||
this.props.onOpenHotkeys();
|
||||
}
|
||||
|
||||
render() {
|
||||
const { intl, onClickLogOut, meUsername, isStaff } = this.props;
|
||||
const size = this.props.size || 16;
|
||||
|
||||
const menu = [];
|
||||
|
||||
menu.push({ text: intl.formatMessage(messages.profile), to: `/@${meUsername}` });
|
||||
menu.push({ text: intl.formatMessage(messages.lists), to: '/lists' });
|
||||
menu.push({ text: intl.formatMessage(messages.bookmarks), to: '/bookmarks' });
|
||||
menu.push(null);
|
||||
menu.push({ text: intl.formatMessage(messages.follow_requests), to: '/follow_requests' });
|
||||
menu.push({ text: intl.formatMessage(messages.mutes), to: '/mutes' });
|
||||
menu.push({ text: intl.formatMessage(messages.blocks), to: '/blocks' });
|
||||
menu.push({ text: intl.formatMessage(messages.domain_blocks), to: '/domain_blocks' });
|
||||
menu.push({ text: intl.formatMessage(messages.filters), to: '/filters' });
|
||||
menu.push(null);
|
||||
menu.push({ text: intl.formatMessage(messages.keyboard_shortcuts), action: this.handleHotkeyClick });
|
||||
if (isStaff) {
|
||||
menu.push({ text: intl.formatMessage(messages.admin_settings), href: '/pleroma/admin', newTab: true });
|
||||
menu.push({ text: intl.formatMessage(messages.soapbox_config), to: '/soapbox/config' });
|
||||
}
|
||||
menu.push({ text: intl.formatMessage(messages.preferences), to: '/settings/preferences' });
|
||||
menu.push({ text: intl.formatMessage(messages.import_data), to: '/settings/import' });
|
||||
menu.push({ text: intl.formatMessage(messages.security), to: '/auth/edit' });
|
||||
menu.push({ text: intl.formatMessage(messages.logout), to: '/auth/sign_out', action: onClickLogOut });
|
||||
|
||||
return (
|
||||
<div className='compose__action-bar' style={{ 'marginTop':'-6px' }}>
|
||||
<div className='compose__action-bar-dropdown'>
|
||||
<DropdownMenuContainer items={menu} icon='chevron-down' size={size} direction='right' />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(ActionBar));
|
|
@ -315,7 +315,9 @@ class ActionBar extends React.PureComponent {
|
|||
// menu.push({ text: intl.formatMessage(messages.embed), action: this.handleEmbed });
|
||||
}
|
||||
|
||||
menu.push({ text: intl.formatMessage(status.get('bookmarked') ? messages.unbookmark : messages.bookmark), action: this.handleBookmarkClick });
|
||||
if (features.bookmarks) {
|
||||
menu.push({ text: intl.formatMessage(status.get('bookmarked') ? messages.unbookmark : messages.bookmark), action: this.handleBookmarkClick });
|
||||
}
|
||||
|
||||
menu.push(null);
|
||||
|
||||
|
|
|
@ -62,15 +62,19 @@ class FeaturesPanel extends React.PureComponent {
|
|||
{intl.formatMessage(messages.follow_requests)}
|
||||
</NavLink>}
|
||||
|
||||
<NavLink className='promo-panel-item' to='/bookmarks'>
|
||||
<Icon id='bookmark' className='promo-panel-item__icon' fixedWidth />
|
||||
{intl.formatMessage(messages.bookmarks)}
|
||||
</NavLink>
|
||||
{features.bookmarks && (
|
||||
<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>
|
||||
{features.lists && (
|
||||
<NavLink className='promo-panel-item' to='/lists'>
|
||||
<Icon id='list' className='promo-panel-item__icon' fixedWidth />
|
||||
{intl.formatMessage(messages.lists)}
|
||||
</NavLink>
|
||||
)}
|
||||
|
||||
{features.securityAPI ? (
|
||||
<NavLink className='promo-panel-item' to='/auth/edit'>
|
||||
|
|
|
@ -3,32 +3,46 @@ import gte from 'semver/functions/gte';
|
|||
import { List as ImmutableList, Map as ImmutableMap } from 'immutable';
|
||||
import { createSelector } from 'reselect';
|
||||
|
||||
const any = arr => arr.some(Boolean);
|
||||
|
||||
// For uglification
|
||||
const MASTODON = 'Mastodon';
|
||||
const PLEROMA = 'Pleroma';
|
||||
|
||||
export const getFeatures = createSelector([
|
||||
instance => parseVersion(instance.get('version')),
|
||||
instance => instance.getIn(['pleroma', 'metadata', 'features'], ImmutableList()),
|
||||
instance => instance.getIn(['pleroma', 'metadata', 'federation'], ImmutableMap()),
|
||||
], (v, features, federation) => {
|
||||
return {
|
||||
suggestions: v.software === 'Mastodon' && gte(v.compatVersion, '2.4.3'),
|
||||
suggestionsV2: v.software === 'Mastodon' && gte(v.compatVersion, '3.4.0'),
|
||||
trends: v.software === 'Mastodon' && gte(v.compatVersion, '3.0.0'),
|
||||
emojiReacts: v.software === 'Pleroma' && gte(v.version, '2.0.0'),
|
||||
emojiReactsRGI: v.software === 'Pleroma' && gte(v.version, '2.2.49'),
|
||||
attachmentLimit: v.software === 'Pleroma' ? Infinity : 4,
|
||||
focalPoint: v.software === 'Mastodon' && gte(v.compatVersion, '2.3.0'),
|
||||
importMutes: v.software === 'Pleroma' && gte(v.version, '2.2.0'),
|
||||
bookmarks: any([
|
||||
v.software === MASTODON && gte(v.compatVersion, '3.1.0'),
|
||||
v.software === PLEROMA && gte(v.version, '0.9.9'),
|
||||
]),
|
||||
lists: any([
|
||||
v.software === MASTODON && gte(v.compatVersion, '2.1.0'),
|
||||
v.software === PLEROMA && gte(v.version, '0.9.9'),
|
||||
]),
|
||||
suggestions: v.software === MASTODON && gte(v.compatVersion, '2.4.3'),
|
||||
suggestionsV2: v.software === MASTODON && gte(v.compatVersion, '3.4.0'),
|
||||
trends: v.software === MASTODON && gte(v.compatVersion, '3.0.0'),
|
||||
emojiReacts: v.software === PLEROMA && gte(v.version, '2.0.0'),
|
||||
emojiReactsRGI: v.software === PLEROMA && gte(v.version, '2.2.49'),
|
||||
attachmentLimit: v.software === PLEROMA ? Infinity : 4,
|
||||
focalPoint: v.software === MASTODON && gte(v.compatVersion, '2.3.0'),
|
||||
importMutes: v.software === PLEROMA && gte(v.version, '2.2.0'),
|
||||
emailList: features.includes('email_list'),
|
||||
chats: v.software === 'Pleroma' && gte(v.version, '2.1.0'),
|
||||
scopes: v.software === 'Pleroma' ? 'read write follow push admin' : 'read write follow push',
|
||||
chats: v.software === PLEROMA && gte(v.version, '2.1.0'),
|
||||
scopes: v.software === PLEROMA ? 'read write follow push admin' : 'read write follow push',
|
||||
federating: federation.get('enabled', true), // Assume true unless explicitly false
|
||||
richText: v.software === 'Pleroma',
|
||||
securityAPI: v.software === 'Pleroma',
|
||||
settingsStore: v.software === 'Pleroma',
|
||||
accountAliasesAPI: v.software === 'Pleroma',
|
||||
resetPasswordAPI: v.software === 'Pleroma',
|
||||
richText: v.software === PLEROMA,
|
||||
securityAPI: v.software === PLEROMA,
|
||||
settingsStore: v.software === PLEROMA,
|
||||
accountAliasesAPI: v.software === PLEROMA,
|
||||
resetPasswordAPI: v.software === PLEROMA,
|
||||
exposableReactions: features.includes('exposable_reactions'),
|
||||
accountSubscriptions: v.software === 'Pleroma' && gte(v.version, '1.0.0'),
|
||||
unrestrictedLists: v.software === 'Pleroma',
|
||||
accountSubscriptions: v.software === PLEROMA && gte(v.version, '1.0.0'),
|
||||
unrestrictedLists: v.software === PLEROMA,
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -36,7 +50,7 @@ export const parseVersion = version => {
|
|||
const regex = /^([\w\.]*)(?: \(compatible; ([\w]*) (.*)\))?$/;
|
||||
const match = regex.exec(version);
|
||||
return {
|
||||
software: match[2] || 'Mastodon',
|
||||
software: match[2] || MASTODON,
|
||||
version: match[3] || match[1],
|
||||
compatVersion: match[1],
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue