import React from 'react'; import { useTranslation } from 'next-i18next'; import PropTypes from 'prop-types'; import AdminNotificationContainer from '~/client/services/AdminNotificationContainer'; import { toastSuccess, toastError } from '~/client/util/apiNotification'; import loggerFactory from '~/utils/logger'; import { withUnstatedContainers } from '../../UnstatedUtils'; 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')}
); } } GlobalNotification.propTypes = { t: PropTypes.func.isRequired, // i18next adminNotificationContainer: PropTypes.instanceOf(AdminNotificationContainer).isRequired, }; const GlobalNotificationWrapperFC = (props) => { const { t } = useTranslation(); return ; }; const GlobalNotificationWrapper = withUnstatedContainers(GlobalNotificationWrapperFC, [AdminNotificationContainer]); export default GlobalNotificationWrapper;