import React from 'react'; import PropTypes from 'prop-types'; import { withTranslation } from 'react-i18next'; import loggerFactory from '@alias/logger'; import { createSubscribedElement } 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('Notification Settings') })); } catch (err) { toastError(err); logger.error(err); } } render() { const { t, adminNotificationContainer } = this.props; const { globalNotifications } = adminNotificationContainer.state; return ( {/* TODO GW-1279 i18n */}

{t('notification_setting.valid_page')}

{/* TODO GW-1279 add checkbox for display isNotificationForOwnerPageEnabled */}
{t('Just me')}
{/* TODO GW-1279 add checkbox for display isNotificationForGroupPageEnabled */}
{t('Only inside the group')}

{t('notification_setting.add_notification')}

{t('notification_setting.notification_list')}

{/* 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 = (props) => { return createSubscribedElement(GlobalNotification, props, [AppContainer, AdminNotificationContainer]); }; GlobalNotification.propTypes = { t: PropTypes.func.isRequired, // i18next appContainer: PropTypes.instanceOf(AppContainer).isRequired, adminNotificationContainer: PropTypes.instanceOf(AdminNotificationContainer).isRequired, }; export default withTranslation()(GlobalNotificationWrapper);