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-08 17:50:25 +02:00
var _RowLabeled = _interopRequireDefault ( require ( "@components/RowLabeled" ) ) ;
2018-06-04 09:09:33 +02:00
var _ChooseAnonymousPublishRadio = _interopRequireDefault ( require ( "@components/ChooseAnonymousPublishRadio" ) ) ;
var _ChooseChannelPublishRadio = _interopRequireDefault ( require ( "@components/ChooseChannelPublishRadio" ) ) ;
2018-06-05 23:24:54 +02:00
var _FormFeedbackDisplay = _interopRequireDefault ( require ( "@components/FormFeedbackDisplay" ) ) ;
2018-06-04 09:09:33 +02:00
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 , [ {
2018-06-05 01:33:38 +02:00
key : "componentWillMount" ,
value : function componentWillMount ( ) {
var loggedInChannelName = this . props . loggedInChannelName ;
if ( loggedInChannelName ) {
this . props . onChannelSelect ( loggedInChannelName ) ;
}
}
} , {
2018-05-23 04:06:37 +02:00
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-05 01:33:38 +02:00
var _this$props = this . props ,
publishInChannel = _this$props . publishInChannel ,
channelError = _this$props . channelError ,
selectedChannel = _this$props . selectedChannel ,
loggedInChannelName = _this$props . loggedInChannelName ;
2018-06-08 17:50:25 +02:00
return _react . default . createElement ( "div" , null , _react . default . createElement ( _RowLabeled . default , {
2018-06-04 09:09:33 +02:00
label : _react . default . createElement ( _ChooseAnonymousPublishRadio . default , {
2018-06-05 01:33:38 +02:00
publishInChannel : publishInChannel ,
2018-06-04 09:09:33 +02:00
toggleAnonymousPublish : this . toggleAnonymousPublish
} ) ,
content : _react . default . createElement ( _ChooseChannelPublishRadio . default , {
2018-06-05 01:33:38 +02:00
publishInChannel : publishInChannel ,
2018-06-04 09:09:33 +02:00
toggleAnonymousPublish : this . toggleAnonymousPublish
} )
2018-06-05 23:24:54 +02:00
} ) , _react . default . createElement ( _FormFeedbackDisplay . default , {
2018-06-05 01:33:38 +02:00
errorMessage : channelError ,
2018-06-04 09:09:33 +02:00
defaultMessage : 'Publish anonymously or in a channel'
2018-06-08 17:50:25 +02:00
} ) , this . props . publishInChannel && _react . default . createElement ( "div" , null , _react . default . createElement ( _RowLabeled . default , {
2018-06-04 09:09:33 +02:00
label : _react . default . createElement ( _Label . default , {
value : 'Channel:'
} ) ,
content : _react . default . createElement ( _ChannelSelectDropdown . default , {
2018-06-05 01:33:38 +02:00
selectedChannel : selectedChannel ,
handleSelection : this . handleSelection ,
loggedInChannelName : loggedInChannelName
} )
} ) , selectedChannel === _publish _channel _select _states . LOGIN && _react . default . createElement ( _ChannelLoginForm . default , null ) , 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 ;