Procházet zdrojové kódy

Merge pull request #3739 from weseek/feat/reset-if-clicked-All-reset

Feat/reset if clicked all reset
Yuki Takei před 4 roky
rodič
revize
2bd012dcd1

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

@@ -274,6 +274,7 @@
       "impossible": "Impossible"
     },
     "bot_reset_successful": "Bot settings have been reset.",
+    "bot_all_reset_successful": "All Bot settings have been reset.",
     "copied_to_clipboard": "Copied to clipboard",
     "set_scope": "Please set up Bot Token Scopes from Slack settings",
     "modal": {

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

@@ -272,6 +272,7 @@
       "impossible": "不可"
     },
     "bot_reset_successful": "Botの設定を消去しました。",
+    "bot_all_reset_successful": "全ての Bot の設定を消去しました。",
     "copied_to_clipboard": "クリップボードにコピーされました。",
     "set_scope": "Slackの設定画面からBot Token Scopeを設定してください",
     "modal": {

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

@@ -282,6 +282,7 @@
       "impossible": "不可能"
     },
     "bot_reset_successful": "删除了BOT设置。",
+    "bot_all_reset_successful": "所有的 Bot 设置都被清除了。",
     "copied_to_clipboard": "它已复制到剪贴板。",
     "set_scope": "在Slack设置页面中配置Bot Token Scope。",
     "modal": {

+ 2 - 4
src/client/js/components/Admin/SlackIntegration/CustomBotWithProxySettings.jsx

@@ -2,7 +2,6 @@ import React, { useState } from 'react';
 import { useTranslation } from 'react-i18next';
 import PropTypes from 'prop-types';
 import AppContainer from '../../../services/AppContainer';
-import AdminAppContainer from '../../../services/AdminAppContainer';
 import { withUnstatedContainers } from '../../UnstatedUtils';
 import { toastSuccess, toastError } from '../../../util/apiNotification';
 import CustomBotWithProxyIntegrationCard from './CustomBotWithProxyIntegrationCard';
@@ -12,7 +11,7 @@ import AdminUpdateButtonRow from '../Common/AdminUpdateButtonRow';
 
 const CustomBotWithProxySettings = (props) => {
   // eslint-disable-next-line no-unused-vars
-  const { appContainer, adminAppContainer } = props;
+  const { appContainer } = props;
   const [isDeleteConfirmModalShown, setIsDeleteConfirmModalShown] = useState(false);
 
   const { t } = useTranslation();
@@ -124,11 +123,10 @@ const CustomBotWithProxySettings = (props) => {
   );
 };
 
-const CustomBotWithProxySettingsWrapper = withUnstatedContainers(CustomBotWithProxySettings, [AppContainer, AdminAppContainer]);
+const CustomBotWithProxySettingsWrapper = withUnstatedContainers(CustomBotWithProxySettings, [AppContainer]);
 
 CustomBotWithProxySettings.propTypes = {
   appContainer: PropTypes.instanceOf(AppContainer).isRequired,
-  adminAppContainer: PropTypes.instanceOf(AdminAppContainer).isRequired,
 };
 
 export default CustomBotWithProxySettingsWrapper;

+ 13 - 1
src/client/js/components/Admin/SlackIntegration/SlackIntegration.jsx

@@ -28,6 +28,7 @@ const SlackIntegration = (props) => {
   const [slackWSNameInWithoutProxy, setSlackWSNameInWithoutProxy] = useState(null);
   const [isDeleteConfirmModalShown, setIsDeleteConfirmModalShown] = useState(false);
 
+
   const fetchSlackIntegrationData = useCallback(async() => {
     try {
       const { data } = await appContainer.apiv3.get('/slack-integration-settings');
@@ -51,6 +52,17 @@ const SlackIntegration = (props) => {
     }
   }, [appContainer.apiv3]);
 
+  const resetAllSettings = async() => {
+    try {
+      await appContainer.apiv3.delete('/slack-integration-settings/bot-type');
+      fetchSlackIntegrationData();
+      toastSuccess(t('admin:slack_integration.bot_all_reset_successful'));
+    }
+    catch (error) {
+      toastError(error);
+    }
+  };
+
   const resetWithOutSettings = async() => {
     try {
       await appContainer.apiv3.put('/slack-integration-settings/bot-type', { currentBotType: 'customBotWithoutProxy' });
@@ -137,11 +149,11 @@ const SlackIntegration = (props) => {
         onCancelClick={cancelBotChangeHandler}
       />
 
-      {/* TODO add onClickDeleteButton */}
       <DeleteSlackBotSettingsModal
         isResetAll
         isOpen={isDeleteConfirmModalShown}
         onClose={() => setIsDeleteConfirmModalShown(false)}
+        onClickDeleteButton={resetAllSettings}
       />
 
       <div className="selecting-bot-type mb-5">