diff --git a/app/soapbox/components/sidebar_menu.js b/app/soapbox/components/sidebar_menu.js
index 8bbde589d..bae67ba83 100644
--- a/app/soapbox/components/sidebar_menu.js
+++ b/app/soapbox/components/sidebar_menu.js
@@ -218,14 +218,14 @@ class SidebarMenu extends ImmutablePureComponent {
{intl.formatMessage(messages.donate_crypto)}
}
-
+ {features.lists &&
{intl.formatMessage(messages.lists)}
-
-
+ }
+ {features.bookmarks &&
{intl.formatMessage(messages.bookmarks)}
-
+ }
diff --git a/app/soapbox/components/status_action_bar.js b/app/soapbox/components/status_action_bar.js
index b7ee34aae..7e15c9d9f 100644
--- a/app/soapbox/components/status_action_bar.js
+++ b/app/soapbox/components/status_action_bar.js
@@ -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;
diff --git a/app/soapbox/features/account/components/header.js b/app/soapbox/features/account/components/header.js
index f3bc72a38..f5a4efe35 100644
--- a/app/soapbox/features/account/components/header.js
+++ b/app/soapbox/features/account/components/header.js
@@ -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 });
}
diff --git a/app/soapbox/features/compose/components/action_bar.js b/app/soapbox/features/compose/components/action_bar.js
deleted file mode 100644
index 3a4098e87..000000000
--- a/app/soapbox/features/compose/components/action_bar.js
+++ /dev/null
@@ -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 (
-
- );
- }
-
-}
-
-export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(ActionBar));
diff --git a/app/soapbox/features/status/components/action_bar.js b/app/soapbox/features/status/components/action_bar.js
index 332108133..d569bcf76 100644
--- a/app/soapbox/features/status/components/action_bar.js
+++ b/app/soapbox/features/status/components/action_bar.js
@@ -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);
diff --git a/app/soapbox/features/ui/components/features_panel.js b/app/soapbox/features/ui/components/features_panel.js
index dd8314778..7c4d564a7 100644
--- a/app/soapbox/features/ui/components/features_panel.js
+++ b/app/soapbox/features/ui/components/features_panel.js
@@ -62,15 +62,19 @@ class FeaturesPanel extends React.PureComponent {
{intl.formatMessage(messages.follow_requests)}
}
-
-
- {intl.formatMessage(messages.bookmarks)}
-
+ {features.bookmarks && (
+
+
+ {intl.formatMessage(messages.bookmarks)}
+
+ )}
-
-
- {intl.formatMessage(messages.lists)}
-
+ {features.lists && (
+
+
+ {intl.formatMessage(messages.lists)}
+
+ )}
{features.securityAPI ? (
diff --git a/app/soapbox/utils/features.js b/app/soapbox/utils/features.js
index 2ae45ccbb..c1e9f17ca 100644
--- a/app/soapbox/utils/features.js
+++ b/app/soapbox/utils/features.js
@@ -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],
};