Conditionally render Trends and WhoToFollow panels, fixes #87

This commit is contained in:
Alex Gleason 2020-05-17 16:24:52 -05:00
parent 269d48c900
commit 8eba7af308
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
5 changed files with 31 additions and 20 deletions

View File

@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePropTypes from 'react-immutable-proptypes';
import { FormattedMessage, injectIntl } from 'react-intl'; import { FormattedMessage, injectIntl } from 'react-intl';
import AccountContainer from '../../../containers/account_container'; import AccountContainer from '../../../containers/account_container';
@ -8,13 +9,19 @@ import ImmutablePureComponent from 'react-immutable-pure-component';
import Hashtag from '../../../components/hashtag'; import Hashtag from '../../../components/hashtag';
import Icon from 'gabsocial/components/icon'; import Icon from 'gabsocial/components/icon';
import WhoToFollowPanel from '../../ui/components/who_to_follow_panel'; import WhoToFollowPanel from '../../ui/components/who_to_follow_panel';
// import TrendsPanel from '../../ui/components/trends_panel'; import { getFeatures } from 'gabsocial/utils/features';
export default @injectIntl const mapStateToProps = state => ({
features: getFeatures(state.get('instance')),
});
export default @connect(mapStateToProps)
@injectIntl
class SearchResults extends ImmutablePureComponent { class SearchResults extends ImmutablePureComponent {
static propTypes = { static propTypes = {
results: ImmutablePropTypes.map.isRequired, results: ImmutablePropTypes.map.isRequired,
features: PropTypes.node,
intl: PropTypes.object.isRequired, intl: PropTypes.object.isRequired,
}; };
@ -23,14 +30,13 @@ class SearchResults extends ImmutablePureComponent {
} }
render() { render() {
const { results } = this.props; const { results, features } = this.props;
const { isSmallScreen } = this.state; const { isSmallScreen } = this.state;
if (results.isEmpty() && isSmallScreen) { if (results.isEmpty() && isSmallScreen) {
return ( return (
<div className='search-results'> <div className='search-results'>
<WhoToFollowPanel /> {features.suggestions && <WhoToFollowPanel />}
{/* <TrendsPanel /> */}
</div> </div>
); );
} }

View File

@ -22,7 +22,6 @@ import { openModal } from '../../actions/modal';
import { WrappedRoute } from './util/react_router_helpers'; import { WrappedRoute } from './util/react_router_helpers';
import UploadArea from './components/upload_area'; import UploadArea from './components/upload_area';
import TabsBar from './components/tabs_bar'; import TabsBar from './components/tabs_bar';
// import TrendsPanel from './components/trends_panel';
import WhoToFollowPanel from './components/who_to_follow_panel'; import WhoToFollowPanel from './components/who_to_follow_panel';
import LinkFooter from './components/link_footer'; import LinkFooter from './components/link_footer';
import ProfilePage from 'gabsocial/pages/profile_page'; import ProfilePage from 'gabsocial/pages/profile_page';
@ -136,7 +135,6 @@ const LAYOUT = {
<LinkFooter key='1' />, <LinkFooter key='1' />,
], ],
RIGHT: [ RIGHT: [
// <TrendsPanel />,
// <GroupSidebarPanel key='0' /> // <GroupSidebarPanel key='0' />
], ],
}, },
@ -146,7 +144,6 @@ const LAYOUT = {
RIGHT: [ RIGHT: [
// <GroupSidebarPanel key='0' />, // <GroupSidebarPanel key='0' />,
<WhoToFollowPanel key='1' />, <WhoToFollowPanel key='1' />,
// <TrendsPanel />,
<LinkFooter key='2' />, <LinkFooter key='2' />,
], ],
}, },

View File

@ -9,6 +9,7 @@ import UserPanel from '../features/ui/components/user_panel';
import FundingPanel from '../features/ui/components/funding_panel'; import FundingPanel from '../features/ui/components/funding_panel';
import ComposeFormContainer from '../features/compose/containers/compose_form_container'; import ComposeFormContainer from '../features/compose/containers/compose_form_container';
import Avatar from '../components/avatar'; import Avatar from '../components/avatar';
import { getFeatures } from 'gabsocial/utils/features';
// import GroupSidebarPanel from '../features/groups/sidebar_panel'; // import GroupSidebarPanel from '../features/groups/sidebar_panel';
const mapStateToProps = state => { const mapStateToProps = state => {
@ -16,6 +17,7 @@ const mapStateToProps = state => {
return { return {
account: state.getIn(['accounts', me]), account: state.getIn(['accounts', me]),
hasPatron: state.getIn(['soapbox', 'extensions', 'patron']), hasPatron: state.getIn(['soapbox', 'extensions', 'patron']),
features: getFeatures(state.get('instance')),
}; };
}; };
@ -28,7 +30,7 @@ class HomePage extends ImmutablePureComponent {
} }
render() { render() {
const { children, account, hasPatron } = this.props; const { children, account, hasPatron, features } = this.props;
return ( return (
<div className='page'> <div className='page'>
@ -64,8 +66,8 @@ class HomePage extends ImmutablePureComponent {
<div className='columns-area__panels__pane columns-area__panels__pane--right'> <div className='columns-area__panels__pane columns-area__panels__pane--right'>
<div className='columns-area__panels__pane__inner'> <div className='columns-area__panels__pane__inner'>
{/* <GroupSidebarPanel /> */} {/* <GroupSidebarPanel /> */}
<TrendsPanel limit={3} /> {features.trends && <TrendsPanel limit={3} />}
<WhoToFollowPanel limit={5} /> {features.suggestions && <WhoToFollowPanel limit={5} />}
</div> </div>
</div> </div>
</div> </div>

View File

@ -6,13 +6,13 @@ import ImmutablePureComponent from 'react-immutable-pure-component';
import Helmet from 'gabsocial/components/helmet'; import Helmet from 'gabsocial/components/helmet';
import HeaderContainer from '../features/account_timeline/containers/header_container'; import HeaderContainer from '../features/account_timeline/containers/header_container';
import WhoToFollowPanel from '../features/ui/components/who_to_follow_panel'; import WhoToFollowPanel from '../features/ui/components/who_to_follow_panel';
// import TrendsPanel from '../features/ui/components/trends_panel';
import LinkFooter from '../features/ui/components/link_footer'; import LinkFooter from '../features/ui/components/link_footer';
import SignUpPanel from '../features/ui/components/sign_up_panel'; import SignUpPanel from '../features/ui/components/sign_up_panel';
import ProfileInfoPanel from '../features/ui/components/profile_info_panel'; import ProfileInfoPanel from '../features/ui/components/profile_info_panel';
import { acctFull } from 'gabsocial/utils/accounts'; import { acctFull } from 'gabsocial/utils/accounts';
import { fetchAccount, fetchAccountByUsername } from '../actions/accounts'; import { fetchAccount, fetchAccountByUsername } from '../actions/accounts';
import { fetchAccountIdentityProofs } from '../actions/identity_proofs'; import { fetchAccountIdentityProofs } from '../actions/identity_proofs';
import { getFeatures } from 'gabsocial/utils/features';
const mapStateToProps = (state, { params: { username }, withReplies = false }) => { const mapStateToProps = (state, { params: { username }, withReplies = false }) => {
const accounts = state.getIn(['accounts']); const accounts = state.getIn(['accounts']);
@ -35,6 +35,7 @@ const mapStateToProps = (state, { params: { username }, withReplies = false }) =
account, account,
accountId, accountId,
accountUsername, accountUsername,
features: getFeatures(state.get('instance')),
}; };
}; };
@ -44,6 +45,7 @@ class ProfilePage extends ImmutablePureComponent {
static propTypes = { static propTypes = {
account: ImmutablePropTypes.map, account: ImmutablePropTypes.map,
accountUsername: PropTypes.string.isRequired, accountUsername: PropTypes.string.isRequired,
features: PropTypes.node,
}; };
componentWillMount() { componentWillMount() {
@ -58,7 +60,7 @@ class ProfilePage extends ImmutablePureComponent {
} }
render() { render() {
const { children, accountId, account, accountUsername } = this.props; const { children, accountId, account, accountUsername, features } = this.props;
if (!account) return null; if (!account) return null;
const bg = account.getIn(['customizations', 'background']); const bg = account.getIn(['customizations', 'background']);
@ -90,8 +92,7 @@ class ProfilePage extends ImmutablePureComponent {
<div className='columns-area__panels__pane columns-area__panels__pane--right'> <div className='columns-area__panels__pane columns-area__panels__pane--right'>
<div className='columns-area__panels__pane__inner'> <div className='columns-area__panels__pane__inner'>
<SignUpPanel /> <SignUpPanel />
<WhoToFollowPanel /> {features.suggestions && <WhoToFollowPanel />}
{/* <TrendsPanel /> */}
<LinkFooter /> <LinkFooter />
</div> </div>
</div> </div>

View File

@ -1,12 +1,17 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import Header from '../features/search/components/header'; import Header from '../features/search/components/header';
import WhoToFollowPanel from '../features/ui/components/who_to_follow_panel'; import WhoToFollowPanel from '../features/ui/components/who_to_follow_panel';
// import TrendsPanel from '../features/ui/components/trends_panel';
import LinkFooter from '../features/ui/components/link_footer'; import LinkFooter from '../features/ui/components/link_footer';
import SignUpPanel from '../features/ui/components/sign_up_panel'; import SignUpPanel from '../features/ui/components/sign_up_panel';
import { getFeatures } from 'gabsocial/utils/features';
const SearchPage = ({ children }) => ( const mapStateToProps = state => ({
features: getFeatures(state.get('instance')),
});
const SearchPage = ({ children, features }) => (
<div className='page'> <div className='page'>
<div className='page__top'> <div className='page__top'>
<Header /> <Header />
@ -16,7 +21,6 @@ const SearchPage = ({ children }) => (
<div className='columns-area__panels__pane columns-area__panels__pane--left'> <div className='columns-area__panels__pane columns-area__panels__pane--left'>
<div className='columns-area__panels__pane__inner'> <div className='columns-area__panels__pane__inner'>
{/* <TrendsPanel /> */}
<LinkFooter /> <LinkFooter />
</div> </div>
</div> </div>
@ -30,7 +34,7 @@ const SearchPage = ({ children }) => (
<div className='columns-area__panels__pane columns-area__panels__pane--right'> <div className='columns-area__panels__pane columns-area__panels__pane--right'>
<div className='columns-area__panels__pane__inner'> <div className='columns-area__panels__pane__inner'>
<SignUpPanel /> <SignUpPanel />
<WhoToFollowPanel /> {features.suggestions && <WhoToFollowPanel />}
</div> </div>
</div> </div>
</div> </div>
@ -40,6 +44,7 @@ const SearchPage = ({ children }) => (
SearchPage.propTypes = { SearchPage.propTypes = {
children: PropTypes.node, children: PropTypes.node,
features: PropTypes.node,
}; };
export default SearchPage; export default connect(mapStateToProps)(SearchPage);