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

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

@@ -4,32 +4,17 @@ 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 CustomBotWithoutProxySettingsAccordion, { botInstallationStep } from './CustomBotWithoutProxySettingsAccordion';
 import CustomBotWithoutProxyIntegrationCard from './CustomBotWithoutProxyIntegrationCard';
 import DeleteSlackBotSettingsModal from './DeleteSlackBotSettingsModal';
 
 const CustomBotWithoutProxySettings = (props) => {
-  const { appContainer, fetchSlackIntegrationData } = props;
+  const { appContainer, resetAllSettings } = props;
   const { t } = useTranslation();
 
   const [siteName, setSiteName] = useState('');
   const [isDeleteConfirmModalShown, setIsDeleteConfirmModalShown] = useState(false);
 
-  const deleteSlackSettingsHandler = async() => {
-    try {
-      await appContainer.apiv3.put('/slack-integration-settings/custom-bot-without-proxy', {
-        slackSigningSecret: '',
-        slackBotToken: '',
-        currentBotType: '',
-      });
-      fetchSlackIntegrationData();
-      toastSuccess('success');
-    }
-    catch (err) {
-      toastError(err);
-    }
-  };
 
   useEffect(() => {
     const siteName = appContainer.config.crowi.title;
@@ -65,7 +50,7 @@ const CustomBotWithoutProxySettings = (props) => {
       <DeleteSlackBotSettingsModal
         isOpen={isDeleteConfirmModalShown}
         onClose={() => setIsDeleteConfirmModalShown(false)}
-        onClickDeleteButton={deleteSlackSettingsHandler}
+        onClickDeleteButton={resetAllSettings}
       />
     </>
   );
@@ -82,7 +67,7 @@ CustomBotWithoutProxySettings.propTypes = {
   slackBotTokenEnv: PropTypes.string,
   isRgisterSlackCredentials: PropTypes.bool,
   slackWSNameInWithoutProxy: PropTypes.string,
-  fetchSlackIntegrationData: PropTypes.func,
+  resetAllSettings: PropTypes.func,
 };
 
 export default CustomBotWithoutProxySettingsWrapper;

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

@@ -54,6 +54,7 @@ const SlackIntegration = (props) => {
     fetchSlackIntegrationData();
   }, [fetchSlackIntegrationData]);
 
+
   const handleBotTypeSelect = (clickedBotType) => {
     if (clickedBotType === currentBotType) {
       return;
@@ -69,6 +70,21 @@ const SlackIntegration = (props) => {
     setSelectedBotType(null);
   };
 
+  const resetAllSettings = async() => {
+    try {
+      await appContainer.apiv3.put('/slack-integration-settings/custom-bot-without-proxy', {
+        slackSigningSecret: '',
+        slackBotToken: '',
+        currentBotType: '',
+      });
+      toastSuccess('success');
+    }
+    catch (err) {
+      toastError(err);
+    }
+  };
+
+
   const changeCurrentBotSettingsHandler = async() => {
     try {
       const res = await appContainer.apiv3.put('/slack-integration-settings/custom-bot-without-proxy', {
@@ -109,7 +125,7 @@ const SlackIntegration = (props) => {
           onSetSlackSigningSecret={setSlackSigningSecret}
           onSetSlackBotToken={setSlackBotToken}
           onSetIsSendTestMessage={setIsSendTestMessage}
-          fetchSlackIntegrationData={fetchSlackIntegrationData}
+          onResetAllSettings={resetAllSettings}
         />
       );
       break;