GlobalNotification.jsx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { withTranslation } from 'react-i18next';
  4. import { createSubscribedElement } from '../../UnstatedUtils';
  5. import AppContainer from '../../../services/AppContainer';
  6. import AdminNotificationContainer from '../../../services/AdminNotificationContainer';
  7. import GlobalNotificationList from './GlobalNotificationList';
  8. class GlobalNotification extends React.Component {
  9. render() {
  10. const { t, adminNotificationContainer } = this.props;
  11. const { globalNotifications } = adminNotificationContainer.state;
  12. return (
  13. <React.Fragment>
  14. <a href="/admin/global-notification/new">
  15. <p className="btn btn-default">{t('notification_setting.add_notification')}</p>
  16. </a>
  17. <h2 className="border-bottom mb-5">{t('notification_setting.notification_list')}</h2>
  18. <table className="table table-bordered">
  19. <thead>
  20. <tr>
  21. <th>ON/OFF</th>
  22. {/* eslint-disable-next-line react/no-danger */}
  23. <th>{t('notification_setting.trigger_path')} <span dangerouslySetInnerHTML={{ __html: t('notification_setting.trigger_path_help') }} /></th>
  24. <th>{t('notification_setting.trigger_events')}</th>
  25. <th>{t('notification_setting.notify_to')}</th>
  26. <th></th>
  27. </tr>
  28. </thead>
  29. {globalNotifications.length !== 0 && (
  30. <tbody className="admin-notif-list">
  31. <GlobalNotificationList />
  32. </tbody>
  33. )}
  34. </table>
  35. </React.Fragment>
  36. );
  37. }
  38. }
  39. const GlobalNotificationWrapper = (props) => {
  40. return createSubscribedElement(GlobalNotification, props, [AppContainer, AdminNotificationContainer]);
  41. };
  42. GlobalNotification.propTypes = {
  43. t: PropTypes.func.isRequired, // i18next
  44. appContainer: PropTypes.instanceOf(AppContainer).isRequired,
  45. adminNotificationContainer: PropTypes.instanceOf(AdminNotificationContainer).isRequired,
  46. };
  47. export default withTranslation()(GlobalNotificationWrapper);