2015-10-08 12:27:09 -04:00
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
2015-06-14 23:53:32 -08:00
// See License.txt for license information.
2016-11-04 11:21:14 -04:00
import SettingItemMin from 'components/setting_item_min.jsx' ;
import SettingItemMax from 'components/setting_item_max.jsx' ;
2015-06-14 23:53:32 -08:00
2016-11-04 11:21:14 -04:00
import $ from 'jquery' ;
2016-03-14 08:50:46 -04:00
import React from 'react' ;
2016-11-04 11:21:14 -04:00
import { Modal } from 'react-bootstrap' ;
import { FormattedMessage } from 'react-intl' ;
2016-02-02 19:39:56 -03:00
2016-12-21 15:27:42 +01:00
import { updateChannelNotifyProps } from 'actions/channel_actions.jsx' ;
2015-11-10 15:45:19 -05:00
export default class ChannelNotificationsModal extends React . Component {
2015-08-19 13:39:02 -07:00
constructor ( props ) {
super ( props ) ;
2015-08-31 11:20:31 -04:00
2015-08-19 13:39:02 -07:00
this . updateSection = this . updateSection . bind ( this ) ;
2016-11-04 11:21:14 -04:00
this . onHide = this . onHide . bind ( this ) ;
2015-08-31 11:20:31 -04:00
2017-02-27 17:55:12 -03:00
this . handleSubmitDesktopNotifyLevel = this . handleSubmitDesktopNotifyLevel . bind ( this ) ;
this . handleUpdateDesktopNotifyLevel = this . handleUpdateDesktopNotifyLevel . bind ( this ) ;
this . createDesktopNotifyLevelSection = this . createDesktopNotifyLevelSection . bind ( this ) ;
2015-09-23 11:38:08 -04:00
this . handleSubmitMarkUnreadLevel = this . handleSubmitMarkUnreadLevel . bind ( this ) ;
this . handleUpdateMarkUnreadLevel = this . handleUpdateMarkUnreadLevel . bind ( this ) ;
this . createMarkUnreadLevelSection = this . createMarkUnreadLevelSection . bind ( this ) ;
2017-02-27 17:55:12 -03:00
this . handleSubmitPushNotificationLevel = this . handleSubmitPushNotificationLevel . bind ( this ) ;
this . handleUpdatePushNotificationLevel = this . handleUpdatePushNotificationLevel . bind ( this ) ;
this . createPushNotificationLevelSection = this . createPushNotificationLevelSection . bind ( this ) ;
2015-09-23 11:38:08 -04:00
this . state = {
2016-02-08 07:26:10 -05:00
activeSection : '' ,
2016-11-04 11:21:14 -04:00
show : true ,
notifyLevel : props . channelMember . notify _props . desktop ,
2017-02-27 17:55:12 -03:00
unreadLevel : props . channelMember . notify _props . mark _unread ,
pushLevel : props . channelMember . notify _props . push || 'default'
2015-09-23 11:38:08 -04:00
} ;
2015-08-19 13:39:02 -07:00
}
2016-11-04 11:21:14 -04:00
2016-02-08 07:26:10 -05:00
updateSection ( section ) {
2016-08-18 19:09:33 +05:00
if ( $ ( '.section-max' ) . length ) {
$ ( '.settings-modal .modal-body' ) . scrollTop ( 0 ) . perfectScrollbar ( 'update' ) ;
}
2016-02-08 07:26:10 -05:00
this . setState ( { activeSection : section } ) ;
}
2016-11-04 11:21:14 -04:00
onHide ( ) {
this . setState ( { show : false } ) ;
2015-08-19 13:39:02 -07:00
}
2016-11-04 11:21:14 -04:00
2017-02-27 17:55:12 -03:00
handleSubmitDesktopNotifyLevel ( ) {
2016-12-21 15:27:42 +01:00
const channelId = this . props . channel . id ;
const notifyLevel = this . state . notifyLevel ;
const currentUserId = this . props . currentUser . id ;
2015-06-14 23:53:32 -08:00
2016-02-08 07:26:10 -05:00
if ( this . props . channelMember . notify _props . desktop === notifyLevel ) {
2015-09-23 16:58:50 -04:00
this . updateSection ( '' ) ;
return ;
}
2017-02-27 17:55:12 -03:00
const options = { desktop : notifyLevel } ;
2016-12-21 15:27:42 +01:00
const data = {
channel _id : channelId ,
2017-02-27 17:55:12 -03:00
user _id : currentUserId
2016-12-21 15:27:42 +01:00
} ;
2015-06-14 23:53:32 -08:00
2017-02-27 17:55:12 -03:00
updateChannelNotifyProps ( data , options ,
2015-09-23 11:38:08 -04:00
( ) => {
2015-08-19 13:39:02 -07:00
this . updateSection ( '' ) ;
2015-09-23 11:38:08 -04:00
} ,
( err ) => {
2015-08-19 13:39:02 -07:00
this . setState ( { serverError : err . message } ) ;
2015-09-23 11:38:08 -04:00
}
2015-06-14 23:53:32 -08:00
) ;
2015-08-19 13:39:02 -07:00
}
2016-11-04 11:21:14 -04:00
2017-02-27 17:55:12 -03:00
handleUpdateDesktopNotifyLevel ( notifyLevel ) {
2015-09-23 11:38:08 -04:00
this . setState ( { notifyLevel } ) ;
2015-08-19 13:39:02 -07:00
}
2016-11-04 11:21:14 -04:00
2017-02-27 17:55:12 -03:00
createDesktopNotifyLevelSection ( serverError ) {
2016-02-08 07:26:10 -05:00
// Get glabal user setting for notifications
2016-11-01 08:34:52 -04:00
const globalNotifyLevel = this . props . currentUser . notify _props ? this . props . currentUser . notify _props . desktop : 'all' ;
2015-09-22 12:00:34 -04:00
let globalNotifyLevelName ;
if ( globalNotifyLevel === 'all' ) {
2016-02-02 19:39:56 -03:00
globalNotifyLevelName = (
< FormattedMessage
id = 'channel_notifications.allActivity'
defaultMessage = 'For all activity'
/ >
) ;
2015-09-22 12:00:34 -04:00
} else if ( globalNotifyLevel === 'mention' ) {
2016-02-02 19:39:56 -03:00
globalNotifyLevelName = (
< FormattedMessage
id = 'channel_notifications.onlyMentions'
defaultMessage = 'Only for mentions'
/ >
) ;
2015-09-22 12:00:34 -04:00
} else {
2016-02-02 19:39:56 -03:00
globalNotifyLevelName = (
< FormattedMessage
id = 'channel_notifications.never'
defaultMessage = 'Never'
/ >
) ;
2015-09-22 12:00:34 -04:00
}
2016-02-02 19:39:56 -03:00
const sendDesktop = (
< FormattedMessage
id = 'channel_notifications.sendDesktop'
defaultMessage = 'Send desktop notifications'
/ >
) ;
2016-02-08 07:26:10 -05:00
const notificationLevel = this . state . notifyLevel ;
2015-06-22 14:23:59 -04:00
if ( this . state . activeSection === 'desktop' ) {
2016-02-08 07:26:10 -05:00
const notifyActive = [ false , false , false , false ] ;
if ( notificationLevel === 'default' ) {
2015-06-22 14:23:59 -04:00
notifyActive [ 0 ] = true ;
2016-02-08 07:26:10 -05:00
} else if ( notificationLevel === 'all' ) {
2015-09-22 12:00:34 -04:00
notifyActive [ 1 ] = true ;
2016-02-08 07:26:10 -05:00
} else if ( notificationLevel === 'mention' ) {
2015-06-22 14:23:59 -04:00
notifyActive [ 2 ] = true ;
2015-09-22 12:00:34 -04:00
} else {
notifyActive [ 3 ] = true ;
2015-06-22 14:23:59 -04:00
}
2015-08-31 11:20:31 -04:00
var inputs = [ ] ;
2015-06-22 14:23:59 -04:00
inputs . push (
2015-10-23 17:30:58 -07:00
< div key = 'channel-notification-level-radio' >
2015-08-19 13:39:02 -07:00
< div className = 'radio' >
2015-06-22 14:23:59 -04:00
< label >
2015-08-19 13:39:02 -07:00
< input
2017-03-21 17:16:48 -06:00
id = 'channelNotificationGlobalDefault'
2015-08-19 13:39:02 -07:00
type = 'radio'
2016-06-27 08:21:24 -04:00
name = 'desktopNotificationLevel'
2015-08-19 13:39:02 -07:00
checked = { notifyActive [ 0 ] }
2017-02-27 17:55:12 -03:00
onChange = { this . handleUpdateDesktopNotifyLevel . bind ( this , 'default' ) }
2015-10-23 17:30:58 -07:00
/ >
2016-02-02 19:39:56 -03:00
< FormattedMessage
id = 'channel_notifications.globalDefault'
2016-02-23 09:57:39 -03:00
defaultMessage = 'Global default ({notifyLevel})'
2016-02-02 19:39:56 -03:00
values = { {
notifyLevel : ( globalNotifyLevelName )
} }
/ >
2015-06-22 14:23:59 -04:00
< / label >
< br / >
< / div >
2015-08-19 13:39:02 -07:00
< div className = 'radio' >
2015-06-22 14:23:59 -04:00
< label >
2015-08-19 13:39:02 -07:00
< input
2017-03-21 17:16:48 -06:00
id = 'channelNotificationAllActivity'
2015-08-19 13:39:02 -07:00
type = 'radio'
2016-06-27 08:21:24 -04:00
name = 'desktopNotificationLevel'
2015-08-19 13:39:02 -07:00
checked = { notifyActive [ 1 ] }
2017-02-27 17:55:12 -03:00
onChange = { this . handleUpdateDesktopNotifyLevel . bind ( this , 'all' ) }
2015-10-23 17:30:58 -07:00
/ >
2016-02-22 08:31:10 -05:00
< FormattedMessage id = 'channel_notifications.allActivity' / >
2015-06-22 14:23:59 -04:00
< / label >
< br / >
< / div >
2015-08-19 13:39:02 -07:00
< div className = 'radio' >
2015-06-22 14:23:59 -04:00
< label >
2015-08-19 13:39:02 -07:00
< input
2017-03-21 17:16:48 -06:00
id = 'channelNotificationMentions'
2015-08-19 13:39:02 -07:00
type = 'radio'
2016-06-27 08:21:24 -04:00
name = 'desktopNotificationLevel'
2015-08-19 13:39:02 -07:00
checked = { notifyActive [ 2 ] }
2017-02-27 17:55:12 -03:00
onChange = { this . handleUpdateDesktopNotifyLevel . bind ( this , 'mention' ) }
2015-10-23 17:30:58 -07:00
/ >
2016-02-22 08:31:10 -05:00
< FormattedMessage id = 'channel_notifications.onlyMentions' / >
2015-09-22 12:00:34 -04:00
< / label >
< br / >
< / div >
< div className = 'radio' >
< label >
< input
2017-03-21 17:16:48 -06:00
id = 'channelNotificationNever'
2015-09-22 12:00:34 -04:00
type = 'radio'
2016-06-27 08:21:24 -04:00
name = 'desktopNotificationLevel'
2015-09-22 12:00:34 -04:00
checked = { notifyActive [ 3 ] }
2017-02-27 17:55:12 -03:00
onChange = { this . handleUpdateDesktopNotifyLevel . bind ( this , 'none' ) }
2015-10-23 17:30:58 -07:00
/ >
2016-02-22 08:31:10 -05:00
< FormattedMessage id = 'channel_notifications.never' / >
2015-06-22 14:23:59 -04:00
< / label >
< / div >
< / div >
) ;
2016-02-08 07:26:10 -05:00
const handleUpdateSection = function updateSection ( e ) {
2015-08-31 11:20:31 -04:00
this . updateSection ( '' ) ;
2015-08-19 13:39:02 -07:00
e . preventDefault ( ) ;
2015-08-31 11:20:31 -04:00
} . bind ( this ) ;
2015-08-19 13:39:02 -07:00
2015-09-22 12:00:34 -04:00
const extraInfo = (
2015-09-24 10:58:06 -04:00
< span >
2016-02-02 19:39:56 -03:00
< FormattedMessage
id = 'channel_notifications.override'
defaultMessage = 'Selecting an option other than "Default" will override the global notification settings. Desktop notifications are available on Firefox, Safari, and Chrome.'
/ >
2015-09-24 10:58:06 -04:00
< / span >
) ;
2015-09-03 08:20:40 -07:00
2015-08-31 11:20:31 -04:00
return (
2015-06-22 14:23:59 -04:00
< SettingItemMax
2016-02-02 19:39:56 -03:00
title = { sendDesktop }
2015-06-22 14:23:59 -04:00
inputs = { inputs }
2017-02-27 17:55:12 -03:00
submit = { this . handleSubmitDesktopNotifyLevel }
2015-08-19 13:39:02 -07:00
server _error = { serverError }
updateSection = { handleUpdateSection }
2015-09-03 08:20:40 -07:00
extraInfo = { extraInfo }
2015-06-22 14:23:59 -04:00
/ >
) ;
2015-08-31 11:20:31 -04:00
}
2015-08-19 13:39:02 -07:00
2015-08-31 11:20:31 -04:00
var describe ;
2016-02-08 07:26:10 -05:00
if ( notificationLevel === 'default' ) {
2016-02-02 19:39:56 -03:00
describe = (
< FormattedMessage
id = 'channel_notifications.globalDefault'
values = { {
notifyLevel : ( globalNotifyLevelName )
} }
/ >
) ;
2016-02-08 07:26:10 -05:00
} else if ( notificationLevel === 'mention' ) {
2016-02-22 08:31:10 -05:00
describe = ( < FormattedMessage id = 'channel_notifications.onlyMentions' / > ) ;
2016-02-08 07:26:10 -05:00
} else if ( notificationLevel === 'all' ) {
2016-02-22 08:31:10 -05:00
describe = ( < FormattedMessage id = 'channel_notifications.allActivity' / > ) ;
2015-08-31 11:20:31 -04:00
} else {
2016-02-22 08:31:10 -05:00
describe = ( < FormattedMessage id = 'channel_notifications.never' / > ) ;
2015-06-22 14:23:59 -04:00
}
2015-08-31 11:20:31 -04:00
return (
< SettingItemMin
2016-02-02 19:39:56 -03:00
title = { sendDesktop }
2015-08-31 11:20:31 -04:00
describe = { describe }
2016-02-08 07:26:10 -05:00
updateSection = { ( ) => {
this . updateSection ( 'desktop' ) ;
} }
2015-08-31 11:20:31 -04:00
/ >
) ;
}
2015-09-23 11:38:08 -04:00
handleSubmitMarkUnreadLevel ( ) {
2016-02-08 07:26:10 -05:00
const channelId = this . props . channel . id ;
const markUnreadLevel = this . state . unreadLevel ;
2015-09-23 11:38:08 -04:00
2016-02-08 07:26:10 -05:00
if ( this . props . channelMember . notify _props . mark _unread === markUnreadLevel ) {
2015-09-23 16:58:50 -04:00
this . updateSection ( '' ) ;
return ;
}
2017-02-27 17:55:12 -03:00
const options = { mark _unread : markUnreadLevel } ;
2015-09-23 11:38:08 -04:00
const data = {
channel _id : channelId ,
2017-02-27 17:55:12 -03:00
user _id : this . props . currentUser . id
2015-09-23 11:38:08 -04:00
} ;
2017-02-27 17:55:12 -03:00
updateChannelNotifyProps ( data , options ,
2015-09-23 11:38:08 -04:00
( ) => {
this . updateSection ( '' ) ;
} ,
( err ) => {
this . setState ( { serverError : err . message } ) ;
2015-06-22 14:23:59 -04:00
}
2015-09-23 11:38:08 -04:00
) ;
}
2015-06-22 14:23:59 -04:00
2016-02-08 07:26:10 -05:00
handleUpdateMarkUnreadLevel ( unreadLevel ) {
this . setState ( { unreadLevel } ) ;
2015-09-23 11:38:08 -04:00
}
2015-08-31 11:20:31 -04:00
2015-09-23 11:38:08 -04:00
createMarkUnreadLevelSection ( serverError ) {
let content ;
2016-02-02 19:39:56 -03:00
const markUnread = (
< FormattedMessage
id = 'channel_notifications.markUnread'
defaultMessage = 'Mark Channel Unread'
/ >
) ;
2015-09-23 11:38:08 -04:00
if ( this . state . activeSection === 'markUnreadLevel' ) {
const inputs = [ (
2015-10-23 17:30:58 -07:00
< div key = 'channel-notification-unread-radio' >
2015-08-19 13:39:02 -07:00
< div className = 'radio' >
< label >
< input
2017-03-21 17:16:48 -06:00
id = 'channelUnreadAll'
2015-08-19 13:39:02 -07:00
type = 'radio'
2016-06-27 08:21:24 -04:00
name = 'markUnreadLevel'
2016-02-08 07:26:10 -05:00
checked = { this . state . unreadLevel === 'all' }
2015-09-23 11:38:08 -04:00
onChange = { this . handleUpdateMarkUnreadLevel . bind ( this , 'all' ) }
2015-10-23 17:30:58 -07:00
/ >
2016-05-12 07:50:53 -04:00
< FormattedMessage
id = 'channel_notifications.allUnread'
defaultMessage = 'For all unread messages'
/ >
2015-08-19 13:39:02 -07:00
< / label >
2016-02-22 08:31:10 -05:00
< br / >
2015-08-19 13:39:02 -07:00
< / div >
< div className = 'radio' >
< label >
< input
2017-03-21 17:16:48 -06:00
id = 'channelUnreadMentions'
2015-08-19 13:39:02 -07:00
type = 'radio'
2016-06-27 08:21:24 -04:00
name = 'markUnreadLevel'
2016-02-08 07:26:10 -05:00
checked = { this . state . unreadLevel === 'mention' }
2015-09-23 11:38:08 -04:00
onChange = { this . handleUpdateMarkUnreadLevel . bind ( this , 'mention' ) }
2015-10-23 17:30:58 -07:00
/ >
2016-02-22 08:31:10 -05:00
< FormattedMessage id = 'channel_notifications.onlyMentions' / >
2015-08-19 13:39:02 -07:00
< / label >
2016-02-22 08:31:10 -05:00
< br / >
2015-06-22 14:23:59 -04:00
< / div >
< / div >
2015-09-23 11:38:08 -04:00
) ] ;
2015-06-22 14:23:59 -04:00
2015-09-23 11:38:08 -04:00
const handleUpdateSection = function handleUpdateSection ( e ) {
2015-08-31 11:20:31 -04:00
this . updateSection ( '' ) ;
2015-08-19 13:39:02 -07:00
e . preventDefault ( ) ;
2015-08-31 11:20:31 -04:00
} . bind ( this ) ;
2015-08-19 13:39:02 -07:00
2016-02-02 19:39:56 -03:00
const extraInfo = (
< span >
< FormattedMessage
id = 'channel_notifications.unreadInfo'
defaultMessage = 'The channel name is bolded in the sidebar when there are unread messages. Selecting "Only for mentions" will bold the channel only when you are mentioned.'
/ >
< / span >
) ;
2015-09-23 11:38:08 -04:00
content = (
2015-06-22 14:23:59 -04:00
< SettingItemMax
2016-02-02 19:39:56 -03:00
title = { markUnread }
2015-06-22 14:23:59 -04:00
inputs = { inputs }
2015-09-23 11:38:08 -04:00
submit = { this . handleSubmitMarkUnreadLevel }
2015-08-19 13:39:02 -07:00
server _error = { serverError }
updateSection = { handleUpdateSection }
2015-09-23 11:38:08 -04:00
extraInfo = { extraInfo }
2015-06-22 14:23:59 -04:00
/ >
) ;
2015-06-14 23:53:32 -08:00
} else {
2015-09-23 11:38:08 -04:00
let describe ;
2015-06-22 14:23:59 -04:00
2016-02-08 07:26:10 -05:00
if ( ! this . state . unreadLevel || this . state . unreadLevel === 'all' ) {
2016-02-02 19:39:56 -03:00
describe = (
< FormattedMessage
id = 'channel_notifications.allUnread'
defaultMessage = 'For all unread messages'
/ >
) ;
2015-09-23 11:38:08 -04:00
} else {
2016-02-22 08:31:10 -05:00
describe = ( < FormattedMessage id = 'channel_notifications.onlyMentions' / > ) ;
2015-09-23 11:38:08 -04:00
}
2015-08-19 13:39:02 -07:00
2015-09-23 11:38:08 -04:00
const handleUpdateSection = function handleUpdateSection ( e ) {
this . updateSection ( 'markUnreadLevel' ) ;
e . preventDefault ( ) ;
} . bind ( this ) ;
content = (
< SettingItemMin
2016-02-02 19:39:56 -03:00
title = { markUnread }
2015-09-23 11:38:08 -04:00
describe = { describe }
updateSection = { handleUpdateSection }
/ >
) ;
}
return content ;
2015-08-31 11:20:31 -04:00
}
2015-09-23 11:38:08 -04:00
2017-02-27 17:55:12 -03:00
handleSubmitPushNotificationLevel ( ) {
const channelId = this . props . channel . id ;
const notifyLevel = this . state . pushLevel ;
const currentUserId = this . props . currentUser . id ;
if ( this . props . channelMember . notify _props . push === notifyLevel ) {
this . updateSection ( '' ) ;
return ;
}
const options = { push : notifyLevel } ;
const data = {
channel _id : channelId ,
user _id : currentUserId
} ;
updateChannelNotifyProps ( data , options ,
( ) => {
this . updateSection ( '' ) ;
} ,
( err ) => {
this . setState ( { serverError : err . message } ) ;
}
) ;
}
handleUpdatePushNotificationLevel ( pushLevel ) {
this . setState ( { pushLevel } ) ;
}
createPushNotificationLevelSection ( serverError ) {
if ( global . mm _config . SendPushNotifications === 'false' ) {
return null ;
}
// Get glabal user setting for notifications
const globalNotifyLevel = this . props . currentUser . notify _props ? this . props . currentUser . notify _props . push : 'all' ;
let globalNotifyLevelName ;
if ( globalNotifyLevel === 'all' ) {
globalNotifyLevelName = (
< FormattedMessage
id = 'channel_notifications.allActivity'
defaultMessage = 'For all activity'
/ >
) ;
} else if ( globalNotifyLevel === 'mention' ) {
globalNotifyLevelName = (
< FormattedMessage
id = 'channel_notifications.onlyMentions'
defaultMessage = 'Only for mentions'
/ >
) ;
} else {
globalNotifyLevelName = (
< FormattedMessage
id = 'channel_notifications.never'
defaultMessage = 'Never'
/ >
) ;
}
const sendPushNotifications = (
< FormattedMessage
id = 'channel_notifications.push'
defaultMessage = 'Send mobile push notifications'
/ >
) ;
const notificationLevel = this . state . pushLevel ;
let content ;
if ( this . state . activeSection === 'push' ) {
const notifyActive = [ false , false , false , false ] ;
if ( notificationLevel === 'default' ) {
notifyActive [ 0 ] = true ;
} else if ( notificationLevel === 'all' ) {
notifyActive [ 1 ] = true ;
} else if ( notificationLevel === 'mention' ) {
notifyActive [ 2 ] = true ;
} else {
notifyActive [ 3 ] = true ;
}
const inputs = [ ] ;
inputs . push (
< div key = 'channel-notification-level-radio' >
< div className = 'radio' >
< label >
< input
2017-03-21 17:16:48 -06:00
id = 'channelPushNotificationGlobalDefault'
2017-02-27 17:55:12 -03:00
type = 'radio'
name = 'pushNotificationLevel'
checked = { notifyActive [ 0 ] }
onChange = { this . handleUpdatePushNotificationLevel . bind ( this , 'default' ) }
/ >
< FormattedMessage
id = 'channel_notifications.globalDefault'
defaultMessage = 'Global default ({notifyLevel})'
values = { {
notifyLevel : ( globalNotifyLevelName )
} }
/ >
< / label >
< br / >
< / div >
< div className = 'radio' >
< label >
< input
2017-03-21 17:16:48 -06:00
id = 'channelPushNotificationAllActivity'
2017-02-27 17:55:12 -03:00
type = 'radio'
name = 'pushNotificationLevel'
checked = { notifyActive [ 1 ] }
onChange = { this . handleUpdatePushNotificationLevel . bind ( this , 'all' ) }
/ >
< FormattedMessage id = 'channel_notifications.allActivity' / >
< / label >
< br / >
< / div >
< div className = 'radio' >
< label >
< input
2017-03-21 17:16:48 -06:00
id = 'channelPushNotificationMentions'
2017-02-27 17:55:12 -03:00
type = 'radio'
name = 'pushNotificationLevel'
checked = { notifyActive [ 2 ] }
onChange = { this . handleUpdatePushNotificationLevel . bind ( this , 'mention' ) }
/ >
< FormattedMessage id = 'channel_notifications.onlyMentions' / >
< / label >
< br / >
< / div >
< div className = 'radio' >
< label >
< input
2017-03-21 17:16:48 -06:00
id = 'channelPushNotificationNever'
2017-02-27 17:55:12 -03:00
type = 'radio'
name = 'pushNotificationLevel'
checked = { notifyActive [ 3 ] }
onChange = { this . handleUpdatePushNotificationLevel . bind ( this , 'none' ) }
/ >
< FormattedMessage id = 'channel_notifications.never' / >
< / label >
< / div >
< / div >
) ;
const handleUpdateSection = function updateSection ( e ) {
this . updateSection ( '' ) ;
e . preventDefault ( ) ;
} . bind ( this ) ;
const extraInfo = (
< span >
< FormattedMessage
id = 'channel_notifications.overridePush'
defaultMessage = 'Selecting an option other than "Global default" will override the global notification settings for mobile push notifications in account settings. Push notifications must be enabled by the System Admin.'
/ >
< / span >
) ;
content = (
< SettingItemMax
title = { sendPushNotifications }
inputs = { inputs }
submit = { this . handleSubmitPushNotificationLevel }
server _error = { serverError }
updateSection = { handleUpdateSection }
extraInfo = { extraInfo }
/ >
) ;
} else {
let describe ;
if ( notificationLevel === 'default' ) {
describe = (
< FormattedMessage
id = 'channel_notifications.globalDefault'
values = { {
notifyLevel : ( globalNotifyLevelName )
} }
/ >
) ;
} else if ( notificationLevel === 'mention' ) {
describe = ( < FormattedMessage id = 'channel_notifications.onlyMentions' / > ) ;
} else if ( notificationLevel === 'all' ) {
describe = ( < FormattedMessage id = 'channel_notifications.allActivity' / > ) ;
} else {
describe = ( < FormattedMessage id = 'channel_notifications.never' / > ) ;
}
content = (
< SettingItemMin
title = { sendPushNotifications }
describe = { describe }
updateSection = { ( ) => {
this . updateSection ( 'push' ) ;
} }
/ >
) ;
}
return (
< div >
< div className = 'divider-light' / >
{ content }
< / div >
) ;
}
2015-08-31 11:20:31 -04:00
render ( ) {
2017-02-27 17:55:12 -03:00
let serverError = null ;
2015-08-31 11:20:31 -04:00
if ( this . state . serverError ) {
serverError = < div className = 'form-group has-error' > < label className = 'control-label' > { this . state . serverError } < / label > < / div > ;
2015-06-14 23:53:32 -08:00
}
return (
2015-11-10 15:45:19 -05:00
< Modal
2016-11-04 11:21:14 -04:00
show = { this . state . show }
2016-11-04 12:56:54 -07:00
dialogClassName = 'settings-modal settings-modal--tabless'
2016-11-04 11:21:14 -04:00
onHide = { this . onHide }
onExited = { this . props . onHide }
2015-08-19 13:39:02 -07:00
>
2015-11-10 15:45:19 -05:00
< Modal.Header closeButton = { true } >
2016-02-02 19:39:56 -03:00
< Modal.Title >
< FormattedMessage
id = 'channel_notifications.preferences'
defaultMessage = 'Notification Preferences for '
/ >
< span className = 'name' > { this . props . channel . display _name } < / span >
< / Modal.Title >
2015-11-10 15:45:19 -05:00
< / Modal.Header >
< Modal.Body >
< div className = 'settings-table' >
< div className = 'settings-content' >
< div
ref = 'wrapper'
className = 'user-settings'
2015-08-19 13:39:02 -07:00
>
2015-11-10 15:45:19 -05:00
< br / >
< div className = 'divider-dark first' / >
2017-02-27 17:55:12 -03:00
{ this . createDesktopNotifyLevelSection ( serverError ) }
{ this . createPushNotificationLevelSection ( serverError ) }
2015-11-10 15:45:19 -05:00
< div className = 'divider-light' / >
{ this . createMarkUnreadLevelSection ( serverError ) }
< div className = 'divider-dark' / >
2015-06-14 23:53:32 -08:00
< / div >
< / div >
< / div >
2015-11-10 15:45:19 -05:00
{ serverError }
< / Modal.Body >
< / Modal >
2015-06-14 23:53:32 -08:00
) ;
}
2015-08-19 13:39:02 -07:00
}
2015-11-10 15:45:19 -05:00
ChannelNotificationsModal . propTypes = {
onHide : React . PropTypes . func . isRequired ,
2016-02-08 07:26:10 -05:00
channel : React . PropTypes . object . isRequired ,
channelMember : React . PropTypes . object . isRequired ,
currentUser : React . PropTypes . object . isRequired
2015-11-10 15:45:19 -05:00
} ;