Jelajahi Sumber

add function for update button

itizawa 6 tahun lalu
induk
melakukan
028c462d5e

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

@@ -2,15 +2,22 @@ import React from 'react';
 import PropTypes from 'prop-types';
 import PropTypes from 'prop-types';
 import { withTranslation } from 'react-i18next';
 import { withTranslation } from 'react-i18next';
 
 
+import loggerFactory from '@alias/logger';
+
+import { toastError } from '../../../util/apiNotification';
+
 import TriggerEventCheckBox from './TriggerEventCheckBox';
 import TriggerEventCheckBox from './TriggerEventCheckBox';
 import AdminUpdateButtonRow from '../Common/AdminUpdateButtonRow';
 import AdminUpdateButtonRow from '../Common/AdminUpdateButtonRow';
 
 
+const logger = loggerFactory('growi:manageGlobalNotification');
+
 class ManageGlobalNotification extends React.Component {
 class ManageGlobalNotification extends React.Component {
 
 
   constructor() {
   constructor() {
     super();
     super();
 
 
     this.state = {
     this.state = {
+      retrieveError: null,
       triggerPath: '',
       triggerPath: '',
       notifyToType: 'mail',
       notifyToType: 'mail',
       emailToSend: '',
       emailToSend: '',
@@ -18,6 +25,22 @@ class ManageGlobalNotification extends React.Component {
       triggerEvents: new Set([]),
       triggerEvents: new Set([]),
     };
     };
 
 
+    this.submitHandler = this.submitHandler.bind(this);
+  }
+
+  componentDidMount() {
+    this.retrieveTriggerEvent();
+  }
+
+  async retrieveTriggerEvent() {
+    try {
+      // TODO GW-913 create apiV3
+    }
+    catch (err) {
+      toastError(err);
+      logger.error(err);
+      this.setState({ retrieveError: err });
+    }
   }
   }
 
 
   onChangeTriggerPath(inputValue) {
   onChangeTriggerPath(inputValue) {
@@ -49,6 +72,18 @@ class ManageGlobalNotification extends React.Component {
     }
     }
   }
   }
 
 
+  async submitHandler() {
+
+    try {
+      // TODO GW-778 create apiV3 update notification
+    }
+    catch (err) {
+      toastError(err);
+      logger.error(err);
+    }
+  }
+
+
   render() {
   render() {
     const { t } = this.props;
     const { t } = this.props;
     return (
     return (
@@ -206,8 +241,10 @@ class ManageGlobalNotification extends React.Component {
             </div>
             </div>
           </div>
           </div>
 
 
-          <AdminUpdateButtonRow />
-
+          <AdminUpdateButtonRow
+            onClick={this.submitHandler}
+            disabled={this.state.retrieveError != null}
+          />
 
 
         </div>
         </div>
 
 

+ 1 - 1
src/client/js/components/Admin/Notification/TriggerEventCheckBox.jsx

@@ -29,7 +29,7 @@ TriggerEventCheckBox.propTypes = {
   checked: PropTypes.bool.isRequired,
   checked: PropTypes.bool.isRequired,
   onChange: PropTypes.func.isRequired,
   onChange: PropTypes.func.isRequired,
   event: PropTypes.string.isRequired,
   event: PropTypes.string.isRequired,
-  children: PropTypes.array.isRequired,
+  children: PropTypes.object.isRequired,
 };
 };