refactor nav links display; move logic to index.js

This commit is contained in:
Travis Eden 2018-09-24 09:25:32 -04:00
parent 6d6bb40fe6
commit 7fd0e66d9b
2 changed files with 9 additions and 8 deletions

View file

@ -1,10 +1,12 @@
import { connect } from 'react-redux';
import { logOutChannel, checkForLoggedInChannel } from '../../actions/channel';
import isApprovedChannel from '../../../../utils/isApprovedChannel';
import View from './view';
const mapStateToProps = ({ site, channel: { loggedInChannel: { name, shortId, longId } } }) => {
return {
site,
showPublish : (!site.publishOnlyApproved || isApprovedChannel({ longId }, site.approvedChannels)),
closedRegistration: site.closedRegistration,
channelName : name,
channelShortId : shortId,
channelLongId : longId,

View file

@ -1,7 +1,6 @@
import React from 'react';
import { NavLink, withRouter } from 'react-router-dom';
import NavBarChannelOptionsDropdown from '@components/NavBarChannelOptionsDropdown';
import isApprovedChannel from '../../../../utils/isApprovedChannel';
const VIEW = 'VIEW';
const LOGOUT = 'LOGOUT';
@ -29,10 +28,10 @@ class NavigationLinks extends React.Component {
}
}
render () {
const { site, channelLongId, channelName } = this.props;
const { channelName, showPublish, closedRegistration } = this.props;
return (
<div className='navigation-links'>
{(!site.publishOnlyApproved || isApprovedChannel({ longId: channelLongId }, site.approvedChannels)) && <NavLink
{showPublish && <NavLink
className='nav-bar-link link--nav'
activeClassName='link--nav-active'
to='/'
@ -55,7 +54,7 @@ class NavigationLinks extends React.Component {
VIEW={VIEW}
LOGOUT={LOGOUT}
/>
) : !site.closedRegistration && (
) : !closedRegistration && (
<NavLink
id='nav-bar-login-link'
className='nav-bar-link link--nav'