load home channel content on homepage when publishing is locked down and user is not logged in

This commit is contained in:
Travis Eden 2018-09-21 11:38:06 -04:00
parent 208c56366f
commit 31891a553e
3 changed files with 11 additions and 5 deletions

View file

@ -3,12 +3,14 @@ import ErrorPage from '@pages/ErrorPage';
import ShowAssetLite from '@pages/ShowAssetLite'; import ShowAssetLite from '@pages/ShowAssetLite';
import ShowAssetDetails from '@pages/ShowAssetDetails'; import ShowAssetDetails from '@pages/ShowAssetDetails';
import ShowChannel from '@pages/ShowChannel'; import ShowChannel from '@pages/ShowChannel';
import { withRouter } from 'react-router-dom';
import { CHANNEL, ASSET_LITE, ASSET_DETAILS } from '../../constants/show_request_types'; import { CHANNEL, ASSET_LITE, ASSET_DETAILS } from '../../constants/show_request_types';
class ContentPageWrapper extends React.Component { class ContentPageWrapper extends React.Component {
componentDidMount () { componentDidMount () {
this.props.onHandleShowPageUri(this.props.match.params); const { onHandleShowPageUri, match, homeChannel } = this.props;
onHandleShowPageUri(homeChannel ? { claim: homeChannel } : match.params);
} }
componentWillReceiveProps (nextProps) { componentWillReceiveProps (nextProps) {
if (nextProps.match.params !== this.props.match.params) { if (nextProps.match.params !== this.props.match.params) {
@ -35,4 +37,4 @@ class ContentPageWrapper extends React.Component {
} }
}; };
export default ContentPageWrapper; export default withRouter(ContentPageWrapper);

View file

@ -2,10 +2,11 @@ import { connect } from 'react-redux';
import { onHandleShowPageUri } from '../../actions/show'; import { onHandleShowPageUri } from '../../actions/show';
import View from './view'; import View from './view';
const mapStateToProps = ({ show }) => { const mapStateToProps = ({ show, site, channel }) => {
return { return {
error : show.request.error, error : show.request.error,
requestType: show.request.type, requestType: show.request.type,
homeChannel: site.publishOnlyApproved && !channel.loggedInChannel.name ? `${site.approvedChannels[0].name}:${site.approvedChannels[0].longId}` : null,
}; };
}; };

View file

@ -1,11 +1,14 @@
import React from 'react'; import React from 'react';
import PageLayout from '@components/PageLayout'; import PageLayout from '@components/PageLayout';
import PublishTool from '@containers/PublishTool'; import PublishTool from '@containers/PublishTool';
import ContentPageWrapper from '@pages/ContentPageWrapper';
class HomePage extends React.Component { class HomePage extends React.Component {
render () { render () {
return ( const { homeChannel } = this.props;
return homeChannel ? (
<ContentPageWrapper homeChannel={homeChannel} />
) : (
<PageLayout <PageLayout
pageTitle={'Speech'} pageTitle={'Speech'}
pageUri={''} pageUri={''}