Procházet zdrojové kódy

Merge branch 'feat/growi-bot' into fix/able-to-test-not-setting-Secret-and-Token

zahmis před 5 roky
rodič
revize
60212d4e63

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

@@ -5,7 +5,6 @@ import AppContainer from '../../../services/AppContainer';
 import AdminAppContainer from '../../../services/AdminAppContainer';
 import { withUnstatedContainers } from '../../UnstatedUtils';
 import { toastError } from '../../../util/apiNotification';
-import SlackGrowiBridging from './SlackGrowiBridging';
 import CustomBotWithoutProxySettingsAccordion, { botInstallationStep } from './CustomBotWithoutProxySettingsAccordion';
 import GrowiLogo from '../../Icons/GrowiLogo';
 
@@ -15,8 +14,6 @@ const CustomBotWithoutProxySettings = (props) => {
 
   const [slackWSNameInWithoutProxy, setSlackWSNameInWithoutProxy] = useState(null);
 
-  // get site name from this GROWI
-  // eslint-disable-next-line no-unused-vars
   const [siteName, setSiteName] = useState('');
 
   const fetchSlackWorkSpaceName = async() => {
@@ -29,8 +26,13 @@ const CustomBotWithoutProxySettings = (props) => {
     }
   };
 
+  const fetchSiteName = () => {
+    const siteName = appContainer.config.crowi.title;
+    setSiteName(siteName);
+  };
+
   useEffect(() => {
-    setSlackWSNameInWithoutProxy(null);
+    fetchSiteName();
     if (props.isSetupSlackBot) {
       fetchSlackWorkSpaceName();
     }
@@ -43,13 +45,7 @@ const CustomBotWithoutProxySettings = (props) => {
 
       <div className="d-flex justify-content-center my-5 bot-integration">
         <div className="card rounded shadow border-0 w-50 admin-bot-card">
-          <div className="row">
-            <h5 className="card-title font-weight-bold mt-3 ml-4 col">Slack</h5>
-            <div className="pull-right mt-3 mr-3">
-              <div className="icon-fw fa fa-repeat fa-2x" onClick={fetchSlackWorkSpaceName}></div>
-            </div>
-          </div>
-
+          <h5 className="card-title font-weight-bold mt-3 ml-4">Slack</h5>
           <div className="card-body p-2 w-50 mx-auto">
             {slackWSNameInWithoutProxy && (
               <div className="card p-20 slack-work-space-name-card">
@@ -71,17 +67,12 @@ const CustomBotWithoutProxySettings = (props) => {
         <div className="card rounded-lg shadow border-0 w-50 admin-bot-card">
           <h5 className="card-title font-weight-bold mt-3 ml-4">GROWI App</h5>
           <div className="card-body p-4 mb-5 text-center">
-            <div className="btn btn-primary">WESEEK Inner Wiki</div>
+            <div className="btn btn-primary">{ siteName }</div>
           </div>
         </div>
       </div>
 
       <h2 className="admin-setting-header">{t('admin:slack_integration.custom_bot_without_proxy_settings')}</h2>
-      {/* temporarily put bellow component */}
-      <SlackGrowiBridging
-        siteName={siteName}
-        slackWorkSpaceName={slackWSNameInWithoutProxy}
-      />
 
       <div className="my-5 mx-3">
         <CustomBotWithoutProxySettingsAccordion

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

@@ -1,17 +0,0 @@
-import React from 'react';
-import PropTypes from 'prop-types';
-
-const SlackGrowiBridging = (props) => {
-  return (
-    <>
-      {props.slackWorkSpaceName}{props.siteName}
-    </>
-  );
-};
-
-SlackGrowiBridging.propTypes = {
-  slackWorkSpaceName: PropTypes.string,
-  siteName: PropTypes.string,
-};
-
-export default SlackGrowiBridging;

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

@@ -5,7 +5,6 @@ import AppContainer from '../../../services/AppContainer';
 import { withUnstatedContainers } from '../../UnstatedUtils';
 import { toastSuccess, toastError } from '../../../util/apiNotification';
 
-import AccessTokenSettings from './AccessTokenSettings';
 import OfficialBotSettings from './OfficialBotSettings';
 import CustomBotWithoutProxySettings from './CustomBotWithoutProxySettings';
 import CustomBotWithProxySettings from './CustomBotWithProxySettings';
@@ -19,7 +18,6 @@ const SlackIntegration = (props) => {
   const { t } = useTranslation();
   const [currentBotType, setCurrentBotType] = useState(null);
   const [selectedBotType, setSelectedBotType] = useState(null);
-  const [accessToken, setAccessToken] = useState('');
   const [slackSigningSecret, setSlackSigningSecret] = useState('');
   const [slackBotToken, setSlackBotToken] = useState('');
   const [slackSigningSecretEnv, setSlackSigningSecretEnv] = useState('');
@@ -33,13 +31,12 @@ const SlackIntegration = (props) => {
   const fetchData = useCallback(async() => {
     try {
       const response = await appContainer.apiv3.get('slack-integration/');
-      const { currentBotType, customBotWithoutProxySettings, accessToken } = response.data.slackBotSettingParams;
+      const { currentBotType, customBotWithoutProxySettings } = response.data.slackBotSettingParams;
       const {
         slackSigningSecret, slackBotToken, slackSigningSecretEnvVars, slackBotTokenEnvVars, isSetupSlackBot, isConnectedToSlack,
       } = customBotWithoutProxySettings;
 
       setCurrentBotType(currentBotType);
-      setAccessToken(accessToken);
       setSlackSigningSecret(slackSigningSecret);
       setSlackBotToken(slackBotToken);
       setSlackSigningSecretEnv(slackSigningSecretEnvVars);
@@ -96,27 +93,6 @@ const SlackIntegration = (props) => {
     }
   };
 
-  const generateTokenHandler = async() => {
-    try {
-      await appContainer.apiv3.put('slack-integration/access-token');
-      fetchData();
-    }
-    catch (err) {
-      toastError(err);
-    }
-  };
-
-  const discardTokenHandler = async() => {
-    try {
-      await appContainer.apiv3.delete('slack-integration/access-token');
-      fetchData();
-      toastSuccess(t('admin:slack_integration.bot_reset_successful'));
-    }
-    catch (err) {
-      toastError(err);
-    }
-  };
-
   let settingsComponent = null;
 
   switch (currentBotType) {
@@ -126,7 +102,6 @@ const SlackIntegration = (props) => {
     case 'customBotWithoutProxy':
       settingsComponent = (
         <CustomBotWithoutProxySettings
-          accessToken={accessToken}
           isSendTestMessage={isSendTestMessage}
           isRegisterSlackCredentials={isRegisterSlackCredentials}
           isConnectedToSlack={isConnectedToSlack}
@@ -156,12 +131,6 @@ const SlackIntegration = (props) => {
         onCancelClick={cancelBotChangeHandler}
       />
 
-      <AccessTokenSettings
-        accessToken={accessToken}
-        onClickDiscardButton={discardTokenHandler}
-        onClickGenerateToken={generateTokenHandler}
-      />
-
       <div className="selecting-bot-type my-5">
         <h2 className="admin-setting-header mb-4">
           {t('admin:slack_integration.selecting_bot_types.slack_bot')}