Sfoglia il codice sorgente

rename func, removed unneccessary null check

Steven Fukase 4 anni fa
parent
commit
5e59781a23

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

@@ -46,7 +46,7 @@ const CustomBotWithProxySettings = (props) => {
     }
   };
 
-  const generateTokenHandler = async() => {
+  const onClickGenerateTokenBtn = async() => {
     try {
       // GW-6068 set new value after this
       await appContainer.apiv3.put('/slack-integration-settings/access-tokens');
@@ -126,7 +126,7 @@ const CustomBotWithProxySettings = (props) => {
               </div>
               <WithProxyAccordions
                 botType="customBotWithProxy"
-                generateTokenHandler={generateTokenHandler}
+                onClickGenerateTokenBtn={onClickGenerateTokenBtn}
                 tokenGtoP={tokenGtoP}
                 tokenPtoG={tokenPtoG}
               />

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

@@ -73,9 +73,9 @@ const RegisteringProxyUrlProcess = () => {
 const GeneratingTokensAndRegisteringProxyServiceProcess = withUnstatedContainers((props) => {
   const { t } = useTranslation();
 
-  const generateTokenHandler = () => {
-    if (props.generateTokenHandler != null) {
-      props.generateTokenHandler();
+  const onClickGenerateTokenBtn = () => {
+    if (props.onClickGenerateTokenBtn != null) {
+      props.onClickGenerateTokenBtn();
     }
   };
 
@@ -113,7 +113,7 @@ const GeneratingTokensAndRegisteringProxyServiceProcess = withUnstatedContainers
         <button
           type="button"
           className="btn btn-primary mx-auto"
-          onClick={generateTokenHandler}
+          onClick={onClickGenerateTokenBtn}
         >
           { t('admin:slack_integration.access_token_settings.regenerate') }
         </button>
@@ -254,7 +254,7 @@ const WithProxyAccordions = (props) => {
       title: 'register_for_growi_official_bot_proxy_service',
       content: <GeneratingTokensAndRegisteringProxyServiceProcess
         growiUrl={props.appContainer.config.crowi.url}
-        generateTokenHandler={props.generateTokenHandler}
+        onClickGenerateTokenBtn={props.onClickGenerateTokenBtn}
         tokenPtoG={props.tokenPtoG}
         tokenGtoP={props.tokenGtoP}
       />,
@@ -282,7 +282,7 @@ const WithProxyAccordions = (props) => {
       title: 'register_for_growi_official_bot_proxy_service',
       content: <GeneratingTokensAndRegisteringProxyServiceProcess
         growiUrl={props.appContainer.config.crowi.url}
-        generateTokenHandler={props.generateTokenHandler}
+        onClickGenerateTokenBtn={props.onClickGenerateTokenBtn}
         tokenPtoG={props.tokenPtoG}
         tokenGtoP={props.tokenGtoP}
       />,
@@ -326,7 +326,7 @@ const OfficialBotSettingsAccordionsWrapper = withUnstatedContainers(WithProxyAcc
 WithProxyAccordions.propTypes = {
   appContainer: PropTypes.instanceOf(AppContainer).isRequired,
   botType: PropTypes.string.isRequired,
-  generateTokenHandler: PropTypes.func,
+  onClickGenerateTokenBtn: PropTypes.func,
   tokenPtoG: PropTypes.string,
   tokenGtoP: PropTypes.string,
 };

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

@@ -59,19 +59,11 @@ module.exports = (crowi) => {
       body('proxyUri').if(value => value !== '').trim().matches(/^(https?:\/\/)/)
         .isURL({ require_tld: false }),
     ],
-    AccessTokens: [
-      query('tokenGtoP').trim().not().isEmpty()
-        .isString()
-        .isLength({ min: 1 }),
-      query('tokenPtoG').trim().not().isEmpty()
-        .isString()
-        .isLength({ min: 1 }),
-    ],
     RelationTest: [
       body('slackappintegrationsId').isMongoId(),
     ],
     deleteIntegration: [
-      query('integrationIdToDelete').isMongoId().not().isEmpty(),
+      query('integrationIdToDelete').isMongoId(),
     ],
     SlackChannel: [
       body('channel').trim().not().isEmpty()