zahmis 4 лет назад
Родитель
Сommit
9c8c13ef71

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

@@ -35,7 +35,7 @@ const BotTypeCard = (props) => {
   return (
     <div
       className={`card admin-bot-card rounded border-radius-sm shadow ${props.isActive ? 'border-primary' : ''}`}
-      onClick={() => props.handleBotTypeSelect(botDetails[props.botType].botType)}
+      onClick={() => props.botTypeSelectHandler(botDetails[props.botType].botType)}
       role="button"
       key={props.botType}
     >
@@ -87,7 +87,7 @@ const BotTypeCard = (props) => {
 BotTypeCard.propTypes = {
   isActive: PropTypes.bool.isRequired,
   botType: PropTypes.string.isRequired,
-  handleBotTypeSelect: PropTypes.func.isRequired,
+  botTypeSelectHandler: PropTypes.func.isRequired,
 };
 
 export default BotTypeCard;

+ 25 - 22
src/client/js/components/Admin/SlackIntegration/SlackIntegration.jsx

@@ -78,7 +78,26 @@ const SlackIntegration = (props) => {
     fetchSlackIntegrationData();
   }, [fetchSlackIntegrationData]);
 
-  const handleBotTypeSelect = async(clickedBotType) => {
+  const changeCurrentBotSettings = async() => {
+    try {
+      const res = await appContainer.apiv3.put('/slack-integration-settings/bot-type', {
+        currentBotType: selectedBotType,
+      });
+      setCurrentBotType(res.data.slackBotTypeParam.slackBotType);
+      setSelectedBotType(null);
+      setIsRegisterSlackCredentials(false);
+      setSlackSigningSecret(null);
+      setSlackBotToken(null);
+      setIsSendTestMessage(false);
+      setSlackWSNameInWithoutProxy(null);
+      toastSuccess(t('admin:slack_integration.bot_reset_successful'));
+    }
+    catch (err) {
+      toastError(err);
+    }
+  };
+
+  const botTypeSelectHandler = async(clickedBotType) => {
     if (clickedBotType === currentBotType) {
       return;
     }
@@ -93,31 +112,15 @@ const SlackIntegration = (props) => {
       }
       return setCurrentBotType(clickedBotType);
     }
-
     setSelectedBotType(clickedBotType);
   };
 
-  const cancelBotChangeHandler = () => {
-    setSelectedBotType(null);
+  const changeCurrentBotSettingsHandler = async(clickedBotType) => {
+    changeCurrentBotSettings(clickedBotType);
   };
 
-  const changeCurrentBotSettingsHandler = async() => {
-    try {
-      const res = await appContainer.apiv3.put('/slack-integration-settings/bot-type', {
-        currentBotType: selectedBotType,
-      });
-      setCurrentBotType(res.data.slackBotTypeParam.slackBotType);
-      setSelectedBotType(null);
-      setIsRegisterSlackCredentials(false);
-      setSlackSigningSecret(null);
-      setSlackBotToken(null);
-      setIsSendTestMessage(false);
-      setSlackWSNameInWithoutProxy(null);
-      toastSuccess(t('admin:slack_integration.bot_reset_successful'));
-    }
-    catch (err) {
-      toastError(err);
-    }
+  const cancelBotChangeHandler = () => {
+    setSelectedBotType(null);
   };
 
   let settingsComponent = null;
@@ -196,7 +199,7 @@ const SlackIntegration = (props) => {
                 <BotTypeCard
                   botType={botType}
                   isActive={currentBotType === botType}
-                  handleBotTypeSelect={handleBotTypeSelect}
+                  botTypeSelectHandler={botTypeSelectHandler}
                 />
               </div>
             );