import React from 'react'; import PureRenderMixin from 'react-addons-pure-render-mixin'; import Flux from '../lib/flux'; import lodash from 'lodash'; import NoticeStore from '../stores/NoticeStore'; import ChannelStore from '../stores/ChannelStore'; import UserStore from '../stores/UserStore'; import SelectedChannelStore from '../stores/SelectedChannelStore'; import { UserSettingsSections, DetectedPlatformAccountsDisplayTypes, NoticeTypes, CreateGuildModalScreens, } from '../Constants'; import ModalActionCreators from '../actions/ModalActionCreators'; import NoticeActionCreators from '../actions/NoticeActionCreators'; import StatusPageActionCreators from '../actions/StatusPageActionCreators'; import UserSettingsModalActionCreators from '../actions/UserSettingsModalActionCreators'; import SelectedChannelActionCreators from '../actions/SelectedChannelActionCreators'; import CreateGuildModalActionCreators from '../actions/CreateGuildModalActionCreators'; import StreamerModeActionCreators from '../actions/StreamerModeActionCreators'; import PlatformAccountsActionCreators from '../actions/PlatformAccountsActionCreators'; import HelpdeskUtils from '../utils/HelpdeskUtils'; import DownloadApps from './DownloadApps'; import DownloadMobileAppsModal from './DownloadMobileAppsModal'; import Platforms from '../lib/Platforms'; import i18n from '../i18n'; import '../styles/notice.styl'; import DisableSilence from './warnings/DisableSilence'; const Notice = React.createClass({ mixins: [Flux.StoreListenerMixin(NoticeStore, UserStore), PureRenderMixin], getStateFromStores() { const notice = NoticeStore.getNotice(); return { currentUser: UserStore.getCurrentUser(), ...notice, }; }, getInitialState() { return { requestingNotifications: false, }; }, handleDownload() { ModalActionCreators.push(DownloadApps, {source: 'Top Bar Nag'}); }, handleClaimAccount() { UserSettingsModalActionCreators.open(UserSettingsSections.ACCOUNT); }, handleDismiss() { NoticeActionCreators.dismiss(); }, handleIgnorePlatformAccounts() { this.handleDismiss(); PlatformAccountsActionCreators.ignore(); }, handleDismissSilenceWarning() { this.handleDismiss(); ModalActionCreators.push(DisableSilence); }, handleDismissVoiceDisconnected() { const channelId = SelectedChannelStore.getVoiceChannelId(); if (channelId != null) { SelectedChannelActionCreators.clearVoiceChannel(); } this.handleDismiss(); }, handleVoiceReconnect() { const channelId = SelectedChannelStore.getVoiceChannelId(); if (channelId != null) { const channel = ChannelStore.getChannel(channelId); if (channel != null) { SelectedChannelActionCreators.selectVoiceChannel(channel['guild_id'], channelId); } } }, handleDismissScheduledMaintenance() { StatusPageActionCreators.ackScheduledMaintenance(); }, handleDisableStreamerMode() { StreamerModeActionCreators.setEnabled(false); }, handleOpenAuthorizedApps() { UserSettingsModalActionCreators.open(UserSettingsSections.AUTHORIZED_APPS); }, handleShowDetectedAccounts() { PlatformAccountsActionCreators.changeDisplayType(DetectedPlatformAccountsDisplayTypes.MODAL); }, handleCreateServer() { CreateGuildModalActionCreators.open(CreateGuildModalScreens.CreateGuild, 'Notice'); }, handleLaunchSurvey() { window.open('https://www.surveymonkey.com/r/6CCXTPS', '_blank'); this.handleDismiss(); }, handleOpenDownloadMobileApps() { this.handleDismiss(); ModalActionCreators.push(DownloadMobileAppsModal); }, render() { switch (this.state.type) { case NoticeTypes.GENERIC: return (