Przeglądaj źródła

Merge branch 'feat/5529-delete-info-from-backend' into feat/5456-show-access-token

Steven Fukase 5 lat temu
rodzic
commit
ee091898f7

+ 1 - 0
resource/locales/en_US/admin/admin.json

@@ -253,6 +253,7 @@
     "delete": "Delete"
     "delete": "Delete"
   },
   },
   "slack_integration": {
   "slack_integration": {
+    "bot_reset_successful": "Bot settings have been reset.",
     "modal": {
     "modal": {
       "warning": "Warning",
       "warning": "Warning",
       "sure_change_bot_type": "Are you sure you want to change the bot type?",
       "sure_change_bot_type": "Are you sure you want to change the bot type?",

+ 1 - 0
resource/locales/ja_JP/admin/admin.json

@@ -251,6 +251,7 @@
     "Directory_hierarchy_tag": "ディレクトリ階層タグ"
     "Directory_hierarchy_tag": "ディレクトリ階層タグ"
   },
   },
   "slack_integration": {
   "slack_integration": {
+    "bot_reset_successful": "Botの設定を消去しました。",
     "modal": {
     "modal": {
       "warning": "注意",
       "warning": "注意",
       "sure_change_bot_type": "Botの種類を変更しますか?",
       "sure_change_bot_type": "Botの種類を変更しますか?",

+ 1 - 0
resource/locales/zh_CN/admin/admin.json

@@ -261,6 +261,7 @@
 		"delete": "删除"
 		"delete": "删除"
   },
   },
   "slack_integration": {
   "slack_integration": {
+    "bot_reset_successful": "删除了BOT设置。",
     "modal": {
     "modal": {
       "warning": "警告",
       "warning": "警告",
       "sure_change_bot_type": "您确定要更改设置吗?",
       "sure_change_bot_type": "您确定要更改设置吗?",

+ 18 - 7
src/client/js/components/Admin/SlackIntegration/SlackIntegration.jsx

@@ -1,8 +1,9 @@
 import React, { useState, useEffect, useCallback } from 'react';
 import React, { useState, useEffect, useCallback } from 'react';
 import PropTypes from 'prop-types';
 import PropTypes from 'prop-types';
+import { useTranslation } from 'react-i18next';
 import AppContainer from '../../../services/AppContainer';
 import AppContainer from '../../../services/AppContainer';
 import { withUnstatedContainers } from '../../UnstatedUtils';
 import { withUnstatedContainers } from '../../UnstatedUtils';
-import { toastError } from '../../../util/apiNotification';
+import { toastSuccess, toastError } from '../../../util/apiNotification';
 import AccessTokenSettings from './AccessTokenSettings';
 import AccessTokenSettings from './AccessTokenSettings';
 import OfficialBotSettings from './OfficialBotSettings';
 import OfficialBotSettings from './OfficialBotSettings';
 import CustomBotWithoutProxySettings from './CustomBotWithoutProxySettings';
 import CustomBotWithoutProxySettings from './CustomBotWithoutProxySettings';
@@ -11,7 +12,7 @@ import ConfirmBotChangeModal from './ConfirmBotChangeModal';
 
 
 const SlackIntegration = (props) => {
 const SlackIntegration = (props) => {
   const { appContainer } = props;
   const { appContainer } = props;
-
+  const { t } = useTranslation();
   const [currentBotType, setCurrentBotType] = useState(null);
   const [currentBotType, setCurrentBotType] = useState(null);
   const [selectedBotType, setSelectedBotType] = useState(null);
   const [selectedBotType, setSelectedBotType] = useState(null);
 
 
@@ -58,10 +59,20 @@ const SlackIntegration = (props) => {
     setSelectedBotType(null);
     setSelectedBotType(null);
   };
   };
 
 
-  const changeCurrentBotSettings = () => {
-    resetBotType();
-    setCurrentBotType(selectedBotType);
-    setSelectedBotType(null);
+  const handleChangeCurrentBotSettings = async() => {
+    try {
+      const res = await appContainer.apiv3.put('slack-integration/custom-bot-without-proxy', {
+        slackSigningSecret: '',
+        slackBotToken: '',
+        botType: selectedBotType,
+      });
+      setCurrentBotType(res.data.customBotWithoutProxySettingParams.slackBotType);
+      setSelectedBotType(null);
+      toastSuccess(t('admin:slack_integration.bot_reset_successful'));
+    }
+    catch (err) {
+      toastError(err);
+    }
   };
   };
 
 
   let settingsComponent = null;
   let settingsComponent = null;
@@ -83,7 +94,7 @@ const SlackIntegration = (props) => {
       <div className="container">
       <div className="container">
         <ConfirmBotChangeModal
         <ConfirmBotChangeModal
           isOpen={selectedBotType != null}
           isOpen={selectedBotType != null}
-          onConfirmClick={changeCurrentBotSettings}
+          onConfirmClick={handleChangeCurrentBotSettings}
           onCancelClick={handleCancelBotChange}
           onCancelClick={handleCancelBotChange}
         />
         />
       </div>
       </div>