zahmis 4 лет назад
Родитель
Сommit
b69c77a39c
1 измененных файлов с 26 добавлено и 10 удалено
  1. 26 10
      src/client/js/components/Admin/SlackIntegration/WithProxyAccordions.jsx

+ 26 - 10
src/client/js/components/Admin/SlackIntegration/WithProxyAccordions.jsx

@@ -180,7 +180,7 @@ const GeneratingTokensAndRegisteringProxyServiceProcess = withUnstatedContainers
 
 
 const TestProcess = (props) => {
 const TestProcess = (props) => {
   const {
   const {
-    apiv3Post, slackAppIntegrationId, onTestConnectionInvoked, isLatestConnectionSuccess, setIsLatestConnectionSuccess,
+    apiv3Post, slackAppIntegrationId, onSubmitForm, onSubmitFormFailed, isLatestConnectionSuccess,
   } = props;
   } = props;
   const { t } = useTranslation();
   const { t } = useTranslation();
   const [testChannel, setTestChannel] = useState('');
   const [testChannel, setTestChannel] = useState('');
@@ -194,16 +194,18 @@ const TestProcess = (props) => {
       await apiv3Post('/slack-integration-settings/with-proxy/relation-test', { slackAppIntegrationId, channel: testChannel });
       await apiv3Post('/slack-integration-settings/with-proxy/relation-test', { slackAppIntegrationId, channel: testChannel });
       const newLogs = addLogs(logsValue, successMessage, null);
       const newLogs = addLogs(logsValue, successMessage, null);
       setLogsValue(newLogs);
       setLogsValue(newLogs);
-      if (onTestConnectionInvoked != null) {
-        onTestConnectionInvoked();
+
+      if (onSubmitForm != null) {
+        onSubmitForm();
       }
       }
-      setIsLatestConnectionSuccess(true);
     }
     }
     catch (error) {
     catch (error) {
-      setIsLatestConnectionSuccess(false);
       const newLogs = addLogs(logsValue, error[0].message, error[0].code);
       const newLogs = addLogs(logsValue, error[0].message, error[0].code);
       setLogsValue(newLogs);
       setLogsValue(newLogs);
       logger.error(error);
       logger.error(error);
+      if (onSubmitFormFailed != null) {
+        onSubmitFormFailed();
+      }
     }
     }
   };
   };
 
 
@@ -254,9 +256,18 @@ const TestProcess = (props) => {
 
 
 const WithProxyAccordions = (props) => {
 const WithProxyAccordions = (props) => {
   const { t } = useTranslation();
   const { t } = useTranslation();
-  const { connectionStatuses } = props;
+  // const { connectionStatuses } = props;
   const [isLatestConnectionSuccess, setIsLatestConnectionSuccess] = useState(false);
   const [isLatestConnectionSuccess, setIsLatestConnectionSuccess] = useState(false);
 
 
+  const submitForm = () => {
+    props.onSubmitForm();
+    setIsLatestConnectionSuccess(true);
+  };
+
+  const submitFormFailed = () => {
+    setIsLatestConnectionSuccess(false);
+  };
+
 
 
   const officialBotIntegrationProcedure = {
   const officialBotIntegrationProcedure = {
     '①': {
     '①': {
@@ -310,11 +321,10 @@ const WithProxyAccordions = (props) => {
       title: 'test_connection',
       title: 'test_connection',
       content: <TestProcess
       content: <TestProcess
         apiv3Post={props.appContainer.apiv3.post}
         apiv3Post={props.appContainer.apiv3.post}
-        connectionStatuses={connectionStatuses}
         slackAppIntegrationId={props.slackAppIntegrationId}
         slackAppIntegrationId={props.slackAppIntegrationId}
-        onTestConnectionInvoked={props.onTestConnectionInvoked}
+        onSubmitForm={submitForm}
+        onSubmitFormFailed={submitFormFailed}
         isLatestConnectionSuccess={isLatestConnectionSuccess}
         isLatestConnectionSuccess={isLatestConnectionSuccess}
-        setIsLatestConnectionSuccess={setIsLatestConnectionSuccess}
       />,
       />,
     },
     },
   };
   };
@@ -328,7 +338,13 @@ const WithProxyAccordions = (props) => {
       {Object.entries(integrationProcedureMapping).map(([key, value]) => {
       {Object.entries(integrationProcedureMapping).map(([key, value]) => {
         return (
         return (
           <Accordion
           <Accordion
-            title={<><span className="mr-2">{key}</span>{t(`admin:slack_integration.accordion.${value.title}`)} {value.title === 'test_connection' && isLatestConnectionSuccess && <i className="ml-3 text-success fa fa-check"></i>}</>}
+            title={(
+              <>
+                <span className="mr-2">{key}</span>
+                {t(`admin:slack_integration.accordion.${value.title}`)}
+                {value.title === 'test_connection' && isLatestConnectionSuccess && <i className="ml-3 text-success fa fa-check"></i>}
+              </>
+)}
             key={key}
             key={key}
           >
           >
             {value.content}
             {value.content}