itizawa 4 лет назад
Родитель
Сommit
1d5eeb271b

+ 8 - 0
packages/slack/src/index.ts

@@ -8,6 +8,14 @@ export const supportedGrowiCommands: string[] = [
   'help',
 ];
 
+export const supportedCommandsNameForBroadcastUse: string[] = [
+  'search',
+];
+
+export const supportedCommandsNameForSingleUse: string[] = [
+  'create',
+];
+
 export * from './interfaces/growi-command';
 export * from './interfaces/request-between-growi-and-proxy';
 export * from './interfaces/request-from-slack';

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

@@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
 import { useTranslation } from 'react-i18next';
 import { CopyToClipboard } from 'react-copy-to-clipboard';
 import loggerFactory from '@alias/logger';
+import { supportedCommandsNameForBroadcastUse, supportedCommandsNameForSingleUse } from '@growi/slack';
 
 import { withUnstatedContainers } from '../../UnstatedUtils';
 import { toastSuccess, toastError } from '../../../util/apiNotification';
@@ -202,9 +203,6 @@ const GeneratingTokensAndRegisteringProxyServiceProcess = withUnstatedContainers
   );
 }, [AppContainer]);
 
-const commandsNameForBroadcastUse = ['search'];
-const commandsNameForSingleUse = ['create'];
-
 const ManageCommandsProcess = ({
   apiv3Put, slackAppIntegrationId, supportedCommandsForBroadcastUse, supportedCommandsForSingleUse,
 }) => {
@@ -267,7 +265,7 @@ const ManageCommandsProcess = ({
       <span className="mb-2">Broadcast Use</span>
       <div className="custom-control custom-checkbox">
         <div className="row mb-5">
-          {commandsNameForBroadcastUse.map((commandName) => {
+          {supportedCommandsNameForBroadcastUse.map((commandName) => {
             return (
               <div className="col-sm-6 my-1" key={commandName}>
                 <input
@@ -290,7 +288,7 @@ const ManageCommandsProcess = ({
       <span className="mb-2">Single Use</span>
       <div className="custom-control custom-checkbox">
         <div className="row mb-5">
-          {commandsNameForSingleUse.map((commandName) => {
+          {supportedCommandsNameForSingleUse.map((commandName) => {
             return (
               <div className="col-sm-6 my-1" key={commandName}>
                 <input

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

@@ -5,7 +5,9 @@ const axios = require('axios');
 const urljoin = require('url-join');
 const loggerFactory = require('@alias/logger');
 
-const { getConnectionStatus, getConnectionStatuses, sendSuccessMessage } = require('@growi/slack');
+const {
+  getConnectionStatus, getConnectionStatuses, sendSuccessMessage, supportedCommandsNameForBroadcastUse, supportedCommandsNameForSingleUse,
+} = require('@growi/slack');
 
 const ErrorV3 = require('../../models/vo/error-apiv3');
 
@@ -405,12 +407,12 @@ module.exports = (crowi) => {
     }
 
     const { tokenGtoP, tokenPtoG } = await SlackAppIntegration.generateUniqueAccessTokens();
-    const supportedCommandsForBroadcastUse = ['search'];
-    const supportedCommandsForSingleUse = ['create'];
-
     try {
       const slackAppTokens = await SlackAppIntegration.create({
-        tokenGtoP, tokenPtoG, supportedCommandsForBroadcastUse, supportedCommandsForSingleUse,
+        tokenGtoP,
+        tokenPtoG,
+        supportedCommandsForBroadcastUse: supportedCommandsNameForBroadcastUse,
+        supportedCommandsForSingleUse: supportedCommandsNameForSingleUse,
       });
       return res.apiv3(slackAppTokens, 200);
     }