force publishes to loggedInChannel when publishOnlyApproved

This commit is contained in:
Travis Eden 2018-10-04 15:25:53 -04:00
parent 50cbe12649
commit fda83dca5b
2 changed files with 23 additions and 5 deletions

View file

@ -1,13 +1,18 @@
import {connect} from 'react-redux';
import {setPublishInChannel, updateSelectedChannel, updateError} from '../../actions/publish';
// import isApprovedChannel from '../../../../utils/isApprovedChannel';
import View from './view';
const mapStateToProps = ({ channel, publish }) => {
const mapStateToProps = ({ publish, site, channel: { loggedInChannel: { name, shortId, longId } } }) => {
return {
loggedInChannelName: channel.loggedInChannel.name,
// isApprovedChannel : isApprovedChannel({ longId }, site.approvedChannels),
publishOnlyApproved: site.publishOnlyApproved,
// closedRegistration : site.closedRegistration,
loggedInChannelName: name,
publishInChannel : publish.publishInChannel,
selectedChannel : publish.selectedChannel,
channelError : publish.error.channel,
longId,
};
};

View file

@ -16,9 +16,12 @@ class ChannelSelect extends React.Component {
this.handleSelection = this.handleSelection.bind(this);
}
componentWillMount () {
const { loggedInChannelName } = this.props;
const { loggedInChannelName, onChannelSelect, publishOnlyApproved, onPublishInChannelChange } = this.props;
if (loggedInChannelName) {
this.props.onChannelSelect(loggedInChannelName);
onChannelSelect(loggedInChannelName);
}
if (publishOnlyApproved) {
onPublishInChannelChange(true);
}
}
toggleAnonymousPublish (event) {
@ -34,7 +37,17 @@ class ChannelSelect extends React.Component {
this.props.onChannelSelect(selectedOption);
}
render () {
const { publishInChannel, channelError, selectedChannel, loggedInChannelName } = this.props;
const { publishInChannel, channelError, selectedChannel, loggedInChannelName, publishOnlyApproved } = this.props;
if (publishOnlyApproved) {
return (
<div>
<RowLabeled
label={<Label value={'Channel:'} />}
content={<span>{loggedInChannelName}</span>}
/>
</div>
);
}
return (
<div>
<RowLabeled