refactor nav links display; move logic to index.js
This commit is contained in:
parent
6d6bb40fe6
commit
7fd0e66d9b
2 changed files with 9 additions and 8 deletions
|
@ -1,10 +1,12 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { logOutChannel, checkForLoggedInChannel } from '../../actions/channel';
|
import { logOutChannel, checkForLoggedInChannel } from '../../actions/channel';
|
||||||
|
import isApprovedChannel from '../../../../utils/isApprovedChannel';
|
||||||
import View from './view';
|
import View from './view';
|
||||||
|
|
||||||
const mapStateToProps = ({ site, channel: { loggedInChannel: { name, shortId, longId } } }) => {
|
const mapStateToProps = ({ site, channel: { loggedInChannel: { name, shortId, longId } } }) => {
|
||||||
return {
|
return {
|
||||||
site,
|
showPublish : (!site.publishOnlyApproved || isApprovedChannel({ longId }, site.approvedChannels)),
|
||||||
|
closedRegistration: site.closedRegistration,
|
||||||
channelName : name,
|
channelName : name,
|
||||||
channelShortId : shortId,
|
channelShortId : shortId,
|
||||||
channelLongId : longId,
|
channelLongId : longId,
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { NavLink, withRouter } from 'react-router-dom';
|
import { NavLink, withRouter } from 'react-router-dom';
|
||||||
import NavBarChannelOptionsDropdown from '@components/NavBarChannelOptionsDropdown';
|
import NavBarChannelOptionsDropdown from '@components/NavBarChannelOptionsDropdown';
|
||||||
import isApprovedChannel from '../../../../utils/isApprovedChannel';
|
|
||||||
|
|
||||||
const VIEW = 'VIEW';
|
const VIEW = 'VIEW';
|
||||||
const LOGOUT = 'LOGOUT';
|
const LOGOUT = 'LOGOUT';
|
||||||
|
@ -29,10 +28,10 @@ class NavigationLinks extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
render () {
|
render () {
|
||||||
const { site, channelLongId, channelName } = this.props;
|
const { channelName, showPublish, closedRegistration } = this.props;
|
||||||
return (
|
return (
|
||||||
<div className='navigation-links'>
|
<div className='navigation-links'>
|
||||||
{(!site.publishOnlyApproved || isApprovedChannel({ longId: channelLongId }, site.approvedChannels)) && <NavLink
|
{showPublish && <NavLink
|
||||||
className='nav-bar-link link--nav'
|
className='nav-bar-link link--nav'
|
||||||
activeClassName='link--nav-active'
|
activeClassName='link--nav-active'
|
||||||
to='/'
|
to='/'
|
||||||
|
@ -55,7 +54,7 @@ class NavigationLinks extends React.Component {
|
||||||
VIEW={VIEW}
|
VIEW={VIEW}
|
||||||
LOGOUT={LOGOUT}
|
LOGOUT={LOGOUT}
|
||||||
/>
|
/>
|
||||||
) : !site.closedRegistration && (
|
) : !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'
|
||||||
|
|
Loading…
Reference in a new issue