hide unusable components based on site settings
This commit is contained in:
parent
845a0a3b01
commit
3c21ce36b7
7 changed files with 63 additions and 34 deletions
|
@ -1,21 +0,0 @@
|
|||
import React from 'react';
|
||||
import ChannelLoginForm from '@containers/ChannelLoginForm';
|
||||
import ChannelCreateForm from '@containers/ChannelCreateForm';
|
||||
import Row from '@components/Row';
|
||||
|
||||
const ChannelTools = () => {
|
||||
return (
|
||||
<div>
|
||||
<Row>
|
||||
<h3>Log in to an existing channel:</h3>
|
||||
<ChannelLoginForm />
|
||||
</Row>
|
||||
<Row>
|
||||
<h3>Create a brand new channel:</h3>
|
||||
<ChannelCreateForm />
|
||||
</Row>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ChannelTools;
|
10
client/src/containers/ChannelTools/index.js
Normal file
10
client/src/containers/ChannelTools/index.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
import { connect } from 'react-redux';
|
||||
import View from './view';
|
||||
|
||||
const mapStateToProps = ({ site: { closedRegistration } }) => {
|
||||
return {
|
||||
closedRegistration,
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, null)(View);
|
23
client/src/containers/ChannelTools/view.jsx
Normal file
23
client/src/containers/ChannelTools/view.jsx
Normal file
|
@ -0,0 +1,23 @@
|
|||
import React from 'react';
|
||||
import ChannelLoginForm from '@containers/ChannelLoginForm';
|
||||
import ChannelCreateForm from '@containers/ChannelCreateForm';
|
||||
import Row from '@components/Row';
|
||||
|
||||
class ChannelTools extends React.Component {
|
||||
render () {
|
||||
return (
|
||||
<div>
|
||||
<Row>
|
||||
<h3>Log in to an existing channel:</h3>
|
||||
<ChannelLoginForm />
|
||||
</Row>
|
||||
{!this.props.closedRegistration && (<Row>
|
||||
<h3>Create a brand new channel:</h3>
|
||||
<ChannelCreateForm />
|
||||
</Row>)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default ChannelTools;
|
|
@ -2,8 +2,9 @@ import { connect } from 'react-redux';
|
|||
import { logOutChannel, checkForLoggedInChannel } from '../../actions/channel';
|
||||
import View from './view';
|
||||
|
||||
const mapStateToProps = ({ channel: { loggedInChannel: { name, shortId, longId } } }) => {
|
||||
const mapStateToProps = ({ site, channel: { loggedInChannel: { name, shortId, longId } } }) => {
|
||||
return {
|
||||
site,
|
||||
channelName : name,
|
||||
channelShortId: shortId,
|
||||
channelLongId : longId,
|
||||
|
|
|
@ -28,16 +28,17 @@ class NavigationLinks extends React.Component {
|
|||
}
|
||||
}
|
||||
render () {
|
||||
const { site, channelLongId, channelName } = this.props;
|
||||
return (
|
||||
<div className='navigation-links'>
|
||||
<NavLink
|
||||
{(!site.publishOnlyApproved || site.approvedChannels.includes(channelLongId)) && <NavLink
|
||||
className='nav-bar-link link--nav'
|
||||
activeClassName='link--nav-active'
|
||||
to='/'
|
||||
exact
|
||||
>
|
||||
Publish
|
||||
</NavLink>
|
||||
</NavLink>}
|
||||
<NavLink
|
||||
className='nav-bar-link link--nav'
|
||||
activeClassName='link--nav-active'
|
||||
|
@ -45,7 +46,7 @@ class NavigationLinks extends React.Component {
|
|||
>
|
||||
About
|
||||
</NavLink>
|
||||
{ this.props.channelName ? (
|
||||
{ channelName ? (
|
||||
<NavBarChannelOptionsDropdown
|
||||
channelName={this.props.channelName}
|
||||
handleSelection={this.handleSelection}
|
||||
|
@ -53,7 +54,7 @@ class NavigationLinks extends React.Component {
|
|||
VIEW={VIEW}
|
||||
LOGOUT={LOGOUT}
|
||||
/>
|
||||
) : (
|
||||
) : !site.closedRegistration && (
|
||||
<NavLink
|
||||
id='nav-bar-login-link'
|
||||
className='nav-bar-link link--nav'
|
||||
|
|
|
@ -4,7 +4,7 @@ import PageLayout from '@components/PageLayout';
|
|||
import HorizontalSplit from '@components/HorizontalSplit';
|
||||
|
||||
import ChannelAbout from '@components/ChannelAbout';
|
||||
import ChannelTools from '@components/ChannelTools';
|
||||
import ChannelTools from '@containers/ChannelTools';
|
||||
|
||||
class LoginPage extends React.Component {
|
||||
componentWillReceiveProps (newProps) {
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
import siteConfig from '@config/siteConfig.json';
|
||||
|
||||
let initialState = {
|
||||
description : 'default description',
|
||||
googleAnalyticsId : 'default google id',
|
||||
host : 'default host',
|
||||
title : 'default title',
|
||||
twitter : 'default twitter',
|
||||
defaultDescription: 'default description',
|
||||
defaultThumbnail : 'default thumbnail',
|
||||
description : 'default description',
|
||||
googleAnalyticsId : 'default google id',
|
||||
host : 'default host',
|
||||
title : 'default title',
|
||||
twitter : 'default twitter',
|
||||
defaultDescription : 'default description',
|
||||
defaultThumbnail : 'default thumbnail',
|
||||
closedRegistration : false,
|
||||
serveOnlyApproved : false,
|
||||
publishOnlyApproved: false,
|
||||
approvedChannels : [],
|
||||
|
||||
};
|
||||
|
||||
if (siteConfig) {
|
||||
|
@ -25,6 +30,12 @@ if (siteConfig) {
|
|||
title,
|
||||
twitter,
|
||||
},
|
||||
publishing: {
|
||||
closedRegistration,
|
||||
serveOnlyApproved,
|
||||
publishOnlyApproved,
|
||||
approvedChannels,
|
||||
},
|
||||
} = siteConfig;
|
||||
|
||||
initialState = {
|
||||
|
@ -35,6 +46,10 @@ if (siteConfig) {
|
|||
twitter,
|
||||
defaultDescription,
|
||||
defaultThumbnail,
|
||||
closedRegistration,
|
||||
serveOnlyApproved,
|
||||
publishOnlyApproved,
|
||||
approvedChannels,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue