kaori 4 лет назад
Родитель
Сommit
c6bea64502

+ 21 - 3
src/client/js/components/Admin/SlackIntegration/OfficialbotSettingsAccordion.jsx

@@ -2,18 +2,37 @@ import React from 'react';
 import PropTypes from 'prop-types';
 import PropTypes from 'prop-types';
 import { useTranslation } from 'react-i18next';
 import { useTranslation } from 'react-i18next';
 import { CopyToClipboard } from 'react-copy-to-clipboard';
 import { CopyToClipboard } from 'react-copy-to-clipboard';
+import loggerFactory from '@alias/logger';
 import Accordion from '../Common/Accordion';
 import Accordion from '../Common/Accordion';
 import AdminUpdateButtonRow from '../Common/AdminUpdateButtonRow';
 import AdminUpdateButtonRow from '../Common/AdminUpdateButtonRow';
-import { toastSuccess } from '../../../util/apiNotification';
+import { toastSuccess, toastError } from '../../../util/apiNotification';
 import { withUnstatedContainers } from '../../UnstatedUtils';
 import { withUnstatedContainers } from '../../UnstatedUtils';
 import AppContainer from '../../../services/AppContainer';
 import AppContainer from '../../../services/AppContainer';
 
 
+const logger = loggerFactory('growi:SlackBotSettings'); //
 
 
 const OfficialBotSettingsAccordion = (props) => {
 const OfficialBotSettingsAccordion = (props) => {
   // TODO: apply i18n by GW-5878
   // TODO: apply i18n by GW-5878
   const { t } = useTranslation();
   const { t } = useTranslation();
   const { appContainer } = props;
   const { appContainer } = props;
   const growiUrl = appContainer.config.crowi.url;
   const growiUrl = appContainer.config.crowi.url;
+  const currentBotType = 'customBotWithoutProxy';
+
+  const updateProxyUrl = async(proxyUri) => {
+    try {
+      const res = await appContainer.apiv3.put('/slack-integration-settings', {
+        proxyUri,
+        currentBotType,
+      });
+      console.log('res', res);
+      // const { siteUrlSettingParams } = res.data;
+      toastSuccess(t('toaster.update_successed', { target: t('Proxy URL') }));
+    }
+    catch (err) {
+      toastError(err);
+      logger.error(err);
+    }
+  };
 
 
   return (
   return (
     <div className="card border-0 rounded-lg shadow overflow-hidden">
     <div className="card border-0 rounded-lg shadow overflow-hidden">
@@ -110,8 +129,7 @@ const OfficialBotSettingsAccordion = (props) => {
           <AdminUpdateButtonRow
           <AdminUpdateButtonRow
             disabled={false}
             disabled={false}
             // TODO: Add Proxy URL submit logic
             // TODO: Add Proxy URL submit logic
-            // eslint-disable-next-line no-console
-            onClick={() => console.log('Update')}
+            onClick={() => updateProxyUrl('ProxyUrl')}
           />
           />
         </div>
         </div>
       </Accordion>
       </Accordion>