Просмотр исходного кода

create resetWithoutProxySettings

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

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

@@ -9,35 +9,19 @@ import CustomBotWithoutProxyIntegrationCard from './CustomBotWithoutProxyIntegra
 import DeleteSlackBotSettingsModal from './DeleteSlackBotSettingsModal';
 
 const CustomBotWithoutProxySettings = (props) => {
-  const { appContainer, onResetAllSettings } = props;
+  const { appContainer, onResetWithoutProxySettings } = props;
   const { t } = useTranslation();
 
   const [siteName, setSiteName] = useState('');
   const [isDeleteConfirmModalShown, setIsDeleteConfirmModalShown] = useState(false);
 
-
-  // const deleteSlackSettingsHandler = async() => {
-  //   try {
-  //     await appContainer.apiv3.put('/slack-integration-settings/bot-type', {
-  //       slackSigningSecret: null,
-  //       slackBotToken: null,
-  //       currentBotType: null,
-  //     });
-  //     toastSuccess('success');
-  //   }
-  //   catch (err) {
-  //     toastError(err);
-  //   }
-  // };
-
-  const resetWithoutProxySettings = () => {
-    if (onResetAllSettings == null) {
+  const resetSettings = async() => {
+    if (onResetWithoutProxySettings == null) {
       return;
     }
-    onResetAllSettings();
+    onResetWithoutProxySettings();
   };
 
-
   useEffect(() => {
     const siteName = appContainer.config.crowi.title;
     setSiteName(siteName);
@@ -72,7 +56,7 @@ const CustomBotWithoutProxySettings = (props) => {
       <DeleteSlackBotSettingsModal
         isOpen={isDeleteConfirmModalShown}
         onClose={() => setIsDeleteConfirmModalShown(false)}
-        onClickDeleteButton={resetWithoutProxySettings}
+        onClickDeleteButton={resetSettings}
       />
     </>
   );
@@ -89,7 +73,7 @@ CustomBotWithoutProxySettings.propTypes = {
   slackBotTokenEnv: PropTypes.string,
   isRgisterSlackCredentials: PropTypes.bool,
   slackWSNameInWithoutProxy: PropTypes.string,
-  onResetAllSettings: PropTypes.func,
+  onResetWithoutProxySettings: PropTypes.func,
 };
 
 export default CustomBotWithoutProxySettingsWrapper;

+ 5 - 9
src/client/js/components/Admin/SlackIntegration/SlackIntegration.jsx

@@ -49,15 +49,10 @@ const SlackIntegration = (props) => {
     }
   }, [appContainer.apiv3]);
 
-  const resetAllSettings = async() => {
-    try {
-      await appContainer.apiv3.delete('/slack-integration-settings/bot-type');
-      fetchSlackIntegrationData();
-      toastSuccess('success');
-    }
-    catch (err) {
-      toastError(err);
-    }
+  const resetWithoutProxySettings = async() => {
+    await appContainer.apiv3.put('/slack-integration-settings/bot-type', { currentBotType });
+    fetchSlackIntegrationData();
+    toastSuccess('success');
   };
 
 
@@ -123,6 +118,7 @@ const SlackIntegration = (props) => {
           onSetSlackBotToken={setSlackBotToken}
           onSetIsSendTestMessage={setIsSendTestMessage}
           onSetCurrentBotType={setCurrentBotType}
+          onResetWithoutProxySettings={resetWithoutProxySettings}
         />
       );
       break;