import React from 'react'; import PropTypes from 'prop-types'; import { withTranslation } from 'react-i18next'; import loggerFactory from '@alias/logger'; import { withUnstatedContainers } from '../../UnstatedUtils'; import { toastSuccess, toastError } from '../../../util/apiNotification'; import AppContainer from '../../../services/AppContainer'; import AdminNotificationContainer from '../../../services/AdminNotificationContainer'; import GlobalNotificationList from './GlobalNotificationList'; const logger = loggerFactory('growi:GlobalNotification'); class GlobalNotification extends React.Component { constructor() { super(); this.onClickSubmit = this.onClickSubmit.bind(this); } async onClickSubmit() { const { t, adminNotificationContainer } = this.props; try { await adminNotificationContainer.updateGlobalNotificationForPages(); toastSuccess(t('toaster.update_successed', { target: t('External_Notification') })); } catch (err) { toastError(err); logger.error(err); } } render() { const { t, adminNotificationContainer } = this.props; const { globalNotifications } = adminNotificationContainer.state; return (

{t('notification_setting.valid_page')}

{/* eslint-disable-next-line react/no-danger */}

{ adminNotificationContainer.switchIsNotificationForOwnerPageEnabled() }} />
{ adminNotificationContainer.switchIsNotificationForGroupPageEnabled() }} />

{t('notification_setting.notification_list')}

{t('notification_setting.add_notification')}

{/* eslint-disable-next-line react/no-danger */} {globalNotifications.length !== 0 && ( )}
ON/OFF{t('notification_setting.trigger_path')} {t('notification_setting.trigger_events')} {t('notification_setting.notify_to')}
); } } const GlobalNotificationWrapper = withUnstatedContainers(GlobalNotification, [AppContainer, AdminNotificationContainer]); GlobalNotification.propTypes = { t: PropTypes.func.isRequired, // i18next appContainer: PropTypes.instanceOf(AppContainer).isRequired, adminNotificationContainer: PropTypes.instanceOf(AdminNotificationContainer).isRequired, }; export default withTranslation()(GlobalNotificationWrapper);