diff --git a/app/soapbox/features/ui/index.js b/app/soapbox/features/ui/index.js index 869aae0f2..a440396a2 100644 --- a/app/soapbox/features/ui/index.js +++ b/app/soapbox/features/ui/index.js @@ -29,16 +29,15 @@ import TabsBar from './components/tabs_bar'; import LinkFooter from './components/link_footer'; import FeaturesPanel from './components/features_panel'; import ProfilePage from 'soapbox/pages/profile_page'; -import UserPanel from './components/user_panel'; import WhoToFollowPanel from './components/who_to_follow_panel'; import TrendsPanel from './components/trends_panel'; import PromoPanel from './components/promo_panel'; -import FundingPanel from './components/funding_panel'; -import CryptoDonatePanel from 'soapbox/features/crypto_donate/components/crypto_donate_panel'; // import GroupsPage from 'soapbox/pages/groups_page'; // import GroupPage from 'soapbox/pages/group_page'; // import GroupSidebarPanel from '../groups/sidebar_panel'; import HomePage from 'soapbox/pages/home_page'; +import DefaultPage from 'soapbox/pages/default_page'; +import EmptyPage from 'soapbox/pages/default_page'; import AdminPage from 'soapbox/pages/admin_page'; import SidebarMenu from '../../components/sidebar_menu'; import { connectUserStream } from '../../actions/streaming'; @@ -47,7 +46,6 @@ import Icon from 'soapbox/components/icon'; import { isStaff } from 'soapbox/utils/accounts'; import ProfileHoverCard from 'soapbox/components/profile_hover_card'; import { getAccessToken } from 'soapbox/utils/auth'; -import { getSoapboxConfig } from 'soapbox/actions/soapbox'; import { getFeatures } from 'soapbox/utils/features'; import { @@ -111,43 +109,6 @@ import '../../components/status'; const isMobile = width => width <= 1190; -const makeLayouts = state => { - const me = state.get('me'); - const soapbox = getSoapboxConfig(state); - - const hasPatron = soapbox.getIn(['extensions', 'patron', 'enabled']); - const hasCrypto = typeof soapbox.getIn(['cryptoAddresses', 0, 'ticker']) === 'string'; - const cryptoLimit = soapbox.getIn(['cryptoDonatePanel', 'limit']); - const features = getFeatures(state.get('instance')); - - const EMPTY = { - LEFT: null, - RIGHT: null, - }; - - const DEFAULT = { - LEFT: EMPTY.LEFT, - RIGHT: [ - features.trends && , - features.suggestions && , - , - , - , - ], - }; - - const HOME = { - LEFT: [ - , - hasPatron && , - hasCrypto && , - ], - RIGHT: DEFAULT.RIGHT, - }; - - return { EMPTY, DEFAULT, HOME }; -}; - const messages = defineMessages({ beforeUnload: { id: 'ui.beforeunload', defaultMessage: 'Your draft will be lost if you leave.' }, publish: { id: 'compose_form.publish', defaultMessage: 'Publish' }, @@ -163,7 +124,6 @@ const mapStateToProps = state => { streamingUrl: state.getIn(['instance', 'urls', 'streaming_api']), me, account, - layouts: makeLayouts(state), }; }; @@ -201,7 +161,6 @@ class SwitchingColumnsArea extends React.PureComponent { children: PropTypes.node, location: PropTypes.object, onLayoutChange: PropTypes.func.isRequired, - layouts: PropTypes.object.isRequired, }; state = { @@ -230,20 +189,20 @@ class SwitchingColumnsArea extends React.PureComponent { } render() { - const { children, layouts: LAYOUT } = this.props; + const { children } = this.props; return ( - - + + - - - - - + + + + + {/* @@ -262,7 +221,7 @@ class SwitchingColumnsArea extends React.PureComponent { - + @@ -272,22 +231,22 @@ class SwitchingColumnsArea extends React.PureComponent { - - - + + + - + - + - - + + - - - - - + + + + + @@ -296,29 +255,29 @@ class SwitchingColumnsArea extends React.PureComponent { - - + + - + - - - - - + + + + + - + - + - + ); } @@ -343,7 +302,6 @@ class UI extends React.PureComponent { me: SoapboxPropTypes.me, streamingUrl: PropTypes.string, account: PropTypes.object, - layouts: PropTypes.object.isRequired, }; state = { @@ -638,7 +596,7 @@ class UI extends React.PureComponent { render() { const { streamingUrl } = this.props; const { draggingOver, mobile } = this.state; - const { intl, children, location, dropdownMenuIsOpen, me, layouts } = this.props; + const { intl, children, location, dropdownMenuIsOpen, me } = this.props; if (me === null || !streamingUrl) return null; @@ -685,7 +643,7 @@ class UI extends React.PureComponent {
- + {children} diff --git a/app/soapbox/pages/default_page.js b/app/soapbox/pages/default_page.js new file mode 100644 index 000000000..1ea168b6b --- /dev/null +++ b/app/soapbox/pages/default_page.js @@ -0,0 +1,56 @@ +import React from 'react'; +import { connect } from 'react-redux'; +import ImmutablePureComponent from 'react-immutable-pure-component'; +import WhoToFollowPanel from 'soapbox/features/ui/components/who_to_follow_panel'; +import TrendsPanel from 'soapbox/features/ui/components/trends_panel'; +import PromoPanel from 'soapbox/features/ui/components/promo_panel'; +import FeaturesPanel from 'soapbox/features/ui/components/features_panel'; +import LinkFooter from 'soapbox/features/ui/components/link_footer'; +import { getFeatures } from 'soapbox/utils/features'; + +const mapStateToProps = state => { + const features = getFeatures(state.get('instance')); + + return { + showTrendsPanel: features.trends, + showWhoToFollowPanel: features.suggestions, + }; +}; + +export default @connect(mapStateToProps) +class DefaultPage extends ImmutablePureComponent { + + render() { + const { children, showTrendsPanel, showWhoToFollowPanel } = this.props; + + return ( +
+
+
+ +
+
+
+ +
+
+ {children} +
+
+ +
+
+ {showTrendsPanel && } + {showWhoToFollowPanel && } + + + +
+
+
+
+
+ ); + } + +} diff --git a/app/soapbox/pages/empty_page.js b/app/soapbox/pages/empty_page.js new file mode 100644 index 000000000..7ba4da5d5 --- /dev/null +++ b/app/soapbox/pages/empty_page.js @@ -0,0 +1,33 @@ +import React from 'react'; +import ImmutablePureComponent from 'react-immutable-pure-component'; + +export default class DefaultPage extends ImmutablePureComponent { + + render() { + const { children } = this.props; + + return ( +
+
+
+ +
+
+
+ +
+
+ {children} +
+
+ +
+
+
+
+
+
+ ); + } + +} diff --git a/app/soapbox/pages/home_page.js b/app/soapbox/pages/home_page.js index 16e66abf7..3f43062cf 100644 --- a/app/soapbox/pages/home_page.js +++ b/app/soapbox/pages/home_page.js @@ -3,13 +3,34 @@ import { connect } from 'react-redux'; import ImmutablePureComponent from 'react-immutable-pure-component'; import ComposeFormContainer from '../features/compose/containers/compose_form_container'; import Avatar from '../components/avatar'; +import UserPanel from 'soapbox/features/ui/components/user_panel'; +import WhoToFollowPanel from 'soapbox/features/ui/components/who_to_follow_panel'; +import TrendsPanel from 'soapbox/features/ui/components/trends_panel'; +import PromoPanel from 'soapbox/features/ui/components/promo_panel'; +import FundingPanel from 'soapbox/features/ui/components/funding_panel'; +import CryptoDonatePanel from 'soapbox/features/crypto_donate/components/crypto_donate_panel'; // import GroupSidebarPanel from '../features/groups/sidebar_panel'; +import FeaturesPanel from 'soapbox/features/ui/components/features_panel'; +import LinkFooter from 'soapbox/features/ui/components/link_footer'; +import { getSoapboxConfig } from 'soapbox/actions/soapbox'; +import { getFeatures } from 'soapbox/utils/features'; const mapStateToProps = state => { const me = state.get('me'); + const soapbox = getSoapboxConfig(state); + const hasPatron = soapbox.getIn(['extensions', 'patron', 'enabled']); + const hasCrypto = typeof soapbox.getIn(['cryptoAddresses', 0, 'ticker']) === 'string'; + const cryptoLimit = soapbox.getIn(['cryptoDonatePanel', 'limit']); + const features = getFeatures(state.get('instance')); + return { me, account: state.getIn(['accounts', me]), + showFundingPanel: hasPatron, + showCryptoDonatePanel: hasCrypto && cryptoLimit > 0, + cryptoLimit, + showTrendsPanel: features.trends, + showWhoToFollowPanel: features.suggestions, }; }; @@ -21,13 +42,8 @@ class HomePage extends ImmutablePureComponent { this.composeBlock = React.createRef(); } - static defaultProps = { - layout: { LEFT: null, RIGHT: null }, - } - render() { - const { me, children, account } = this.props; - const LAYOUT = this.props.layout || this.defaultProps.layout; + const { me, children, account, showFundingPanel, showCryptoDonatePanel, cryptoLimit, showTrendsPanel, showWhoToFollowPanel } = this.props; return (
@@ -36,7 +52,9 @@ class HomePage extends ImmutablePureComponent {
- {LAYOUT.LEFT} + + {showFundingPanel && } + {showCryptoDonatePanel && }
@@ -59,7 +77,11 @@ class HomePage extends ImmutablePureComponent {
- {LAYOUT.RIGHT} + {showTrendsPanel && } + {showWhoToFollowPanel && } + + +