itizawa před 6 roky
rodič
revize
7011b275ab

+ 10 - 2
src/client/js/components/Admin/Notification/ManageGlobalNotification.jsx

@@ -8,6 +8,8 @@ import { toastError } from '../../../util/apiNotification';
 
 
 import TriggerEventCheckBox from './TriggerEventCheckBox';
 import TriggerEventCheckBox from './TriggerEventCheckBox';
 import AdminUpdateButtonRow from '../Common/AdminUpdateButtonRow';
 import AdminUpdateButtonRow from '../Common/AdminUpdateButtonRow';
+import AppContainer from '../../../services/AppContainer';
+import { createSubscribedElement } from '../../UnstatedUtils';
 
 
 const logger = loggerFactory('growi:manageGlobalNotification');
 const logger = loggerFactory('growi:manageGlobalNotification');
 
 
@@ -75,7 +77,7 @@ class ManageGlobalNotification extends React.Component {
   async submitHandler() {
   async submitHandler() {
 
 
     try {
     try {
-      // TODO GW-778 create apiV3 update notification
+      await this.props.appContainer.apiv3.post('/notification-setting/global-notification');
     }
     }
     catch (err) {
     catch (err) {
       toastError(err);
       toastError(err);
@@ -255,8 +257,14 @@ class ManageGlobalNotification extends React.Component {
 
 
 }
 }
 
 
+const ManageGlobalNotificationWrapper = (props) => {
+  return createSubscribedElement(ManageGlobalNotification, props, [AppContainer]);
+};
+
 ManageGlobalNotification.propTypes = {
 ManageGlobalNotification.propTypes = {
   t: PropTypes.func.isRequired, // i18next
   t: PropTypes.func.isRequired, // i18next
+  appContainer: PropTypes.instanceOf(AppContainer).isRequired,
+
 };
 };
 
 
-export default withTranslation()(ManageGlobalNotification);
+export default withTranslation()(ManageGlobalNotificationWrapper);

+ 30 - 0
src/server/routes/apiv3/notification-setting.js

@@ -190,6 +190,36 @@ module.exports = (crowi) => {
 
 
   });
   });
 
 
+  // TODO swagger
+  router.post('/global-notification', loginRequiredStrictly, adminRequired, csrf, async(req, res) => {
+
+    const form = req.body;
+
+    console.log(form);
+    let setting;
+
+    // switch (form.notifyToType) {
+    //   case GlobalNotificationSetting.TYPE.MAIL:
+    //     setting = new GlobalNotificationMailSetting(crowi);
+    //     setting.toEmail = form.toEmail;
+    //     break;
+    //   case GlobalNotificationSetting.TYPE.SLACK:
+    //     setting = new GlobalNotificationSlackSetting(crowi);
+    //     setting.slackChannels = form.slackChannels;
+    //     break;
+    //   default:
+    //     logger.error('GlobalNotificationSetting Type Error: undefined type');
+    //     req.flash('errorMessage', 'Error occurred in creating a new global notification setting: undefined notification type');
+    //     return res.redirect('/admin/notification#global-notification');
+    // }
+
+    // setting.triggerPath = form.triggerPath;
+    // setting.triggerEvents = getNotificationEvents(form);
+    // setting.save();
+    return res.apiv3();
+
+  });
+
   /**
   /**
    * @swagger
    * @swagger
    *
    *