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 { logOutChannel, checkForLoggedInChannel } from '../../actions/channel';
|
||||||
import View from './view';
|
import View from './view';
|
||||||
|
|
||||||
const mapStateToProps = ({ channel: { loggedInChannel: { name, shortId, longId } } }) => {
|
const mapStateToProps = ({ site, channel: { loggedInChannel: { name, shortId, longId } } }) => {
|
||||||
return {
|
return {
|
||||||
|
site,
|
||||||
channelName : name,
|
channelName : name,
|
||||||
channelShortId: shortId,
|
channelShortId: shortId,
|
||||||
channelLongId : longId,
|
channelLongId : longId,
|
||||||
|
|
|
@ -28,16 +28,17 @@ class NavigationLinks extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
render () {
|
render () {
|
||||||
|
const { site, channelLongId, channelName } = this.props;
|
||||||
return (
|
return (
|
||||||
<div className='navigation-links'>
|
<div className='navigation-links'>
|
||||||
<NavLink
|
{(!site.publishOnlyApproved || site.approvedChannels.includes(channelLongId)) && <NavLink
|
||||||
className='nav-bar-link link--nav'
|
className='nav-bar-link link--nav'
|
||||||
activeClassName='link--nav-active'
|
activeClassName='link--nav-active'
|
||||||
to='/'
|
to='/'
|
||||||
exact
|
exact
|
||||||
>
|
>
|
||||||
Publish
|
Publish
|
||||||
</NavLink>
|
</NavLink>}
|
||||||
<NavLink
|
<NavLink
|
||||||
className='nav-bar-link link--nav'
|
className='nav-bar-link link--nav'
|
||||||
activeClassName='link--nav-active'
|
activeClassName='link--nav-active'
|
||||||
|
@ -45,7 +46,7 @@ class NavigationLinks extends React.Component {
|
||||||
>
|
>
|
||||||
About
|
About
|
||||||
</NavLink>
|
</NavLink>
|
||||||
{ this.props.channelName ? (
|
{ channelName ? (
|
||||||
<NavBarChannelOptionsDropdown
|
<NavBarChannelOptionsDropdown
|
||||||
channelName={this.props.channelName}
|
channelName={this.props.channelName}
|
||||||
handleSelection={this.handleSelection}
|
handleSelection={this.handleSelection}
|
||||||
|
@ -53,7 +54,7 @@ class NavigationLinks extends React.Component {
|
||||||
VIEW={VIEW}
|
VIEW={VIEW}
|
||||||
LOGOUT={LOGOUT}
|
LOGOUT={LOGOUT}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : !site.closedRegistration && (
|
||||||
<NavLink
|
<NavLink
|
||||||
id='nav-bar-login-link'
|
id='nav-bar-login-link'
|
||||||
className='nav-bar-link link--nav'
|
className='nav-bar-link link--nav'
|
||||||
|
|
|
@ -4,7 +4,7 @@ import PageLayout from '@components/PageLayout';
|
||||||
import HorizontalSplit from '@components/HorizontalSplit';
|
import HorizontalSplit from '@components/HorizontalSplit';
|
||||||
|
|
||||||
import ChannelAbout from '@components/ChannelAbout';
|
import ChannelAbout from '@components/ChannelAbout';
|
||||||
import ChannelTools from '@components/ChannelTools';
|
import ChannelTools from '@containers/ChannelTools';
|
||||||
|
|
||||||
class LoginPage extends React.Component {
|
class LoginPage extends React.Component {
|
||||||
componentWillReceiveProps (newProps) {
|
componentWillReceiveProps (newProps) {
|
||||||
|
|
|
@ -8,6 +8,11 @@ let initialState = {
|
||||||
twitter : 'default twitter',
|
twitter : 'default twitter',
|
||||||
defaultDescription : 'default description',
|
defaultDescription : 'default description',
|
||||||
defaultThumbnail : 'default thumbnail',
|
defaultThumbnail : 'default thumbnail',
|
||||||
|
closedRegistration : false,
|
||||||
|
serveOnlyApproved : false,
|
||||||
|
publishOnlyApproved: false,
|
||||||
|
approvedChannels : [],
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (siteConfig) {
|
if (siteConfig) {
|
||||||
|
@ -25,6 +30,12 @@ if (siteConfig) {
|
||||||
title,
|
title,
|
||||||
twitter,
|
twitter,
|
||||||
},
|
},
|
||||||
|
publishing: {
|
||||||
|
closedRegistration,
|
||||||
|
serveOnlyApproved,
|
||||||
|
publishOnlyApproved,
|
||||||
|
approvedChannels,
|
||||||
|
},
|
||||||
} = siteConfig;
|
} = siteConfig;
|
||||||
|
|
||||||
initialState = {
|
initialState = {
|
||||||
|
@ -35,6 +46,10 @@ if (siteConfig) {
|
||||||
twitter,
|
twitter,
|
||||||
defaultDescription,
|
defaultDescription,
|
||||||
defaultThumbnail,
|
defaultThumbnail,
|
||||||
|
closedRegistration,
|
||||||
|
serveOnlyApproved,
|
||||||
|
publishOnlyApproved,
|
||||||
|
approvedChannels,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue