2018-05-23 04:06:37 +02:00
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = void 0 ;
var _react = _interopRequireDefault ( require ( "react" ) ) ;
var _ChannelLoginForm = _interopRequireDefault ( require ( "@containers/ChannelLoginForm" ) ) ;
var _ChannelCreateForm = _interopRequireDefault ( require ( "@containers/ChannelCreateForm" ) ) ;
2018-06-04 09:09:33 +02:00
var _publish _channel _select _states = require ( "../../constants/publish_channel_select_states" ) ;
2018-05-23 04:06:37 +02:00
2018-06-04 09:09:33 +02:00
var _PublishDetailsRow = _interopRequireDefault ( require ( "@components/PublishDetailsRow" ) ) ;
var _ChooseAnonymousPublishRadio = _interopRequireDefault ( require ( "@components/ChooseAnonymousPublishRadio" ) ) ;
var _ChooseChannelPublishRadio = _interopRequireDefault ( require ( "@components/ChooseChannelPublishRadio" ) ) ;
var _ErrorDisplay = _interopRequireDefault ( require ( "@components/ErrorDisplay" ) ) ;
var _Label = _interopRequireDefault ( require ( "@components/Label" ) ) ;
var _ChannelSelectDropdown = _interopRequireDefault ( require ( "@components/ChannelSelectDropdown" ) ) ;
2018-05-23 04:06:37 +02:00
function _interopRequireDefault ( obj ) { return obj && obj . _ _esModule ? obj : { default : obj } ; }
function _typeof ( obj ) { if ( typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ) { _typeof = function _typeof ( obj ) { return typeof obj ; } ; } else { _typeof = function _typeof ( obj ) { return obj && typeof Symbol === "function" && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ; } ; } return _typeof ( obj ) ; }
function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( "Cannot call a class as a function" ) ; } }
function _inherits ( subClass , superClass ) { if ( typeof superClass !== "function" && superClass !== null ) { throw new TypeError ( "Super expression must either be null or a function" ) ; } _setPrototypeOf ( subClass . prototype , superClass && superClass . prototype ) ; if ( superClass ) _setPrototypeOf ( subClass , superClass ) ; }
function _setPrototypeOf ( o , p ) { _setPrototypeOf = Object . setPrototypeOf || function _setPrototypeOf ( o , p ) { o . _ _proto _ _ = p ; return o ; } ; return _setPrototypeOf ( o , p ) ; }
function _defineProperties ( target , props ) { for ( var i = 0 ; i < props . length ; i ++ ) { var descriptor = props [ i ] ; descriptor . enumerable = descriptor . enumerable || false ; descriptor . configurable = true ; if ( "value" in descriptor ) descriptor . writable = true ; Object . defineProperty ( target , descriptor . key , descriptor ) ; } }
function _createClass ( Constructor , protoProps , staticProps ) { if ( protoProps ) _defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) _defineProperties ( Constructor , staticProps ) ; return Constructor ; }
function _possibleConstructorReturn ( self , call ) { if ( call && ( _typeof ( call ) === "object" || typeof call === "function" ) ) { return call ; } return _assertThisInitialized ( self ) ; }
function _getPrototypeOf ( o ) { _getPrototypeOf = Object . getPrototypeOf || function _getPrototypeOf ( o ) { return o . _ _proto _ _ ; } ; return _getPrototypeOf ( o ) ; }
function _assertThisInitialized ( self ) { if ( self === void 0 ) { throw new ReferenceError ( "this hasn't been initialised - super() hasn't been called" ) ; } return self ; }
var ChannelSelect =
/*#__PURE__*/
function ( _React$Component ) {
function ChannelSelect ( props ) {
var _this ;
_classCallCheck ( this , ChannelSelect ) ;
_this = _possibleConstructorReturn ( this , _getPrototypeOf ( ChannelSelect ) . call ( this , props ) ) ;
_this . toggleAnonymousPublish = _this . toggleAnonymousPublish . bind ( _assertThisInitialized ( _assertThisInitialized ( _this ) ) ) ;
_this . handleSelection = _this . handleSelection . bind ( _assertThisInitialized ( _assertThisInitialized ( _this ) ) ) ;
return _this ;
}
_createClass ( ChannelSelect , [ {
key : "toggleAnonymousPublish" ,
value : function toggleAnonymousPublish ( event ) {
var value = event . target . value ;
if ( value === 'anonymous' ) {
this . props . onPublishInChannelChange ( false ) ;
} else {
this . props . onPublishInChannelChange ( true ) ;
}
}
} , {
key : "handleSelection" ,
value : function handleSelection ( event ) {
var selectedOption = event . target . selectedOptions [ 0 ] . value ;
this . props . onChannelSelect ( selectedOption ) ;
}
} , {
key : "render" ,
value : function render ( ) {
2018-06-04 09:09:33 +02:00
return _react . default . createElement ( "div" , null , _react . default . createElement ( _PublishDetailsRow . default , {
label : _react . default . createElement ( _ChooseAnonymousPublishRadio . default , {
publishInChannel : this . props . publishInChannel ,
toggleAnonymousPublish : this . toggleAnonymousPublish
} ) ,
content : _react . default . createElement ( _ChooseChannelPublishRadio . default , {
publishInChannel : this . props . publishInChannel ,
toggleAnonymousPublish : this . toggleAnonymousPublish
} )
} ) , _react . default . createElement ( _ErrorDisplay . default , {
errorMessage : this . props . channelError ,
defaultMessage : 'Publish anonymously or in a channel'
} ) , this . props . publishInChannel && _react . default . createElement ( "div" , null , _react . default . createElement ( _PublishDetailsRow . default , {
label : _react . default . createElement ( _Label . default , {
value : 'Channel:'
} ) ,
content : _react . default . createElement ( _ChannelSelectDropdown . default , {
selectedChannel : this . props . selectedChannel ,
handleSelection : this . handleSelection
} , "loggedInChannelName=" , this . props . loggedInChannelName )
} ) , this . props . selectedChannel === _publish _channel _select _states . LOGIN && _react . default . createElement ( _ChannelLoginForm . default , null ) , this . props . selectedChannel === _publish _channel _select _states . CREATE && _react . default . createElement ( _ChannelCreateForm . default , null ) ) ) ;
2018-05-23 04:06:37 +02:00
}
} ] ) ;
_inherits ( ChannelSelect , _React$Component ) ;
return ChannelSelect ;
} ( _react . default . Component ) ;
var _default = ChannelSelect ;
exports . default = _default ;