Przeglądaj źródła

add submitUpdate

itizawa 6 lat temu
rodzic
commit
4d20758eee

+ 33 - 2
src/client/js/components/Admin/Notification/SlackAppConfiguration.jsx

@@ -2,14 +2,42 @@ 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 { createSubscribedElement } from '../../UnstatedUtils';
 import { createSubscribedElement } from '../../UnstatedUtils';
+import { toastSuccess, toastError } from '../../../util/apiNotification';
 
 
 import AppContainer from '../../../services/AppContainer';
 import AppContainer from '../../../services/AppContainer';
 import AdminNotificationContainer from '../../../services/AdminNotificationContainer';
 import AdminNotificationContainer from '../../../services/AdminNotificationContainer';
 import AdminUpdateButtonRow from '../Common/AdminUpdateButtonRow';
 import AdminUpdateButtonRow from '../Common/AdminUpdateButtonRow';
 
 
+const logger = loggerFactory('growi:slackAppConfiguration');
+
 class SlackAppConfiguration extends React.Component {
 class SlackAppConfiguration extends React.Component {
 
 
+  constructor(props) {
+    super(props);
+
+    this.state = {
+      retrieveError: null,
+    };
+
+    this.onClickSubmit = this.onClickSubmit.bind(this);
+  }
+
+  async onClickSubmit() {
+    const { t, adminNotificationContainer } = this.props;
+
+    try {
+      await adminNotificationContainer.updateSlackAppConfiguration();
+      toastSuccess(t('notification_setting.updated_slackApp'));
+    }
+    catch (err) {
+      toastError(err);
+      logger.error(err);
+    }
+  }
+
   // TODO GW-788 i18n
   // TODO GW-788 i18n
   render() {
   render() {
     const { adminNotificationContainer } = this.props;
     const { adminNotificationContainer } = this.props;
@@ -21,7 +49,7 @@ class SlackAppConfiguration extends React.Component {
             <div className="my-0 btn-group">
             <div className="my-0 btn-group">
               <div className="dropdown">
               <div className="dropdown">
                 <button className="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                 <button className="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
-                  <span className="pull-left">Slack {adminNotificationContainer.state.selectSlackOption}</span>
+                  <span className="pull-left">Slack {adminNotificationContainer.state.selectSlackOption} </span>
                   <span className="bs-caret pull-right">
                   <span className="bs-caret pull-right">
                     <span className="caret" />
                     <span className="caret" />
                   </span>
                   </span>
@@ -112,7 +140,10 @@ class SlackAppConfiguration extends React.Component {
           )
           )
         }
         }
 
 
-        <AdminUpdateButtonRow />
+        <AdminUpdateButtonRow
+          onClick={this.onClickSubmit}
+          disabled={this.state.retrieveError != null}
+        />
 
 
         <hr />
         <hr />
 
 

+ 9 - 0
src/client/js/services/AdminNotificationContainer.js

@@ -55,4 +55,13 @@ export default class AdminNotificationContainer extends Container {
     this.setState({ slackToken });
     this.setState({ slackToken });
   }
   }
 
 
+  /**
+   * Update slackAppConfiguration
+   * @memberOf SlackAppConfiguration
+   */
+  async updateSlackAppConfiguration() {
+    // TODO GW-794 create apiV3 updateSlackAppConfiguration
+
+  }
+
 }
 }