Explorar o código

Merge pull request #3719 from weseek/feat/create-modal-of-reset-button-in-with-proxy

Feat/create modal of reset button in with proxy
Yuki Takei %!s(int64=4) %!d(string=hai) anos
pai
achega
611f306680

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

@@ -4,12 +4,16 @@ 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';
 import CustomBotWithProxySettingsAccordion from './CustomBotWithProxySettingsAccordion';
+import DeleteSlackBotSettingsModal from './DeleteSlackBotSettingsModal';
 
 const CustomBotWithProxySettings = (props) => {
   // eslint-disable-next-line no-unused-vars
   const { appContainer, adminAppContainer } = props;
+  const [isDeleteConfirmModalShown, setIsDeleteConfirmModalShown] = useState(false);
+
   const { t } = useTranslation();
 
   // TODO: Multiple accordion logic
@@ -26,6 +30,19 @@ const CustomBotWithProxySettings = (props) => {
     );
   };
 
+  const deleteSlackSettingsHandler = async() => {
+    try {
+      // TODO imple delete PtoG and GtoP Token at GW 5861
+      await appContainer.apiv3.put('/slack-integration-settings/custom-bot-with-proxy', {
+      });
+      deleteAccordionHandler();
+      toastSuccess('success');
+    }
+    catch (err) {
+      toastError(err);
+    }
+  };
+
   return (
     <>
       <h2 className="admin-setting-header mb-2">{t('admin:slack_integration.custom_bot_with_proxy_integration')}</h2>
@@ -57,7 +74,7 @@ const CustomBotWithProxySettings = (props) => {
               <button
                 className="my-3 btn btn-outline-danger"
                 type="button"
-                onClick={deleteAccordionHandler}
+                onClick={() => setIsDeleteConfirmModalShown(true)}
               >
                 <i className="icon-trash mr-1" />
                 {t('admin:slack_integration.delete')}
@@ -79,6 +96,11 @@ const CustomBotWithProxySettings = (props) => {
           </button>
         </div>
       </div>
+      <DeleteSlackBotSettingsModal
+        isOpen={isDeleteConfirmModalShown}
+        onClose={() => setIsDeleteConfirmModalShown(false)}
+        onClickDeleteButton={deleteSlackSettingsHandler}
+      />
     </>
   );
 };

+ 1 - 1
src/server/routes/apiv3/slack-integration-settings.js

@@ -69,7 +69,7 @@ module.exports = (crowi) => {
     return configManager.updateConfigsInTheSameNamespace('crowi', params, true);
   }
 
-
+  // eslint-disable-next-line no-unused-vars
   function generateAccessToken(user) {
     const hasher = crypto.createHash('sha512');
     hasher.update(new Date().getTime() + user._id);