Explorar el Código

Merge branch 'feat/growi-bot' into 5899-access-token-to-db

深瀬スティーヴン hace 4 años
padre
commit
7bd49b4eba

+ 3 - 12
packages/slackbot-proxy/src/services/RegisterService.ts

@@ -66,18 +66,9 @@ export class RegisterService implements GrowiCommandProcessor {
     const inputGrowiAccessToken = inputValues.growiAccessToken.contents_input.value;
     const inputProxyAccessToken = inputValues.proxyToken.contents_input.value;
 
-    const order = await orderRepository.findOne({ installation, growiUrl: inputGrowiUrl });
-    if (order != null) {
-      orderRepository.update(
-        { installation, growiUrl: inputGrowiUrl },
-        { growiAccessToken: inputGrowiAccessToken, proxyAccessToken: inputProxyAccessToken },
-      );
-    }
-    else {
-      orderRepository.save({
-        installation, growiUrl: inputGrowiUrl, growiAccessToken: inputGrowiAccessToken, proxyAccessToken: inputProxyAccessToken,
-      });
-    }
+    orderRepository.save({
+      installation, growiUrl: inputGrowiUrl, growiAccessToken: inputGrowiAccessToken, proxyAccessToken: inputProxyAccessToken,
+    });
   }
 
   async notifyServerUriToSlack(

+ 2 - 1
resource/locales/en_US/admin/admin.json

@@ -314,7 +314,8 @@
       "paste_growi_url": "Since a modal is displayed, enter the following URL in <b>GROWI URL</b>.",
       "enter_access_token_for_growi_and_proxy": "Enter <b>Access Token for GROWI</b> and <b>Access Token for Proxy</b>",
       "set_proxy_url_on_growi": "Set Proxy URL on GROWI",
-      "enter_proxy_url_and_update": "1. Enter and update the Proxy URL that you copied in step ③ in the <b>Proxy URL</b>  of the <b>Custom bot with proxy integration</b> on this page.",
+      "copy_proxy_url": "When the above step ② are completed successfully, the Proxy URL will be displayed in the Slack Channel you selected in the modal, so copy it.",
+      "enter_proxy_url_and_update": "Enter and update the Proxy URL that you copied in step ③ in the <b>Proxy URL</b>  of the <b>Custom bot with proxy integration</b> on this page.",
       "dont_need_update": "※If the value is already in there, there is no need to update it.",
       "select_install_your_app": "Select \"Install your app\".",
       "select_install_to_workspace": "Select \"Install to Workspace\".",

+ 2 - 1
resource/locales/ja_JP/admin/admin.json

@@ -311,7 +311,8 @@
       "paste_growi_url": "モーダルが表示されるので、<b>GROWI URL</b> には下記のURLを入力します。",
       "enter_access_token_for_growi_and_proxy": "上記で発行した<b>Access Token for GROWI</b> と <b>Access Token for Proxy</b>を入れる",
       "set_proxy_url_on_growi": "ProxyのURLをGROWIに登録する",
-      "enter_proxy_url_and_update": "1. 連携手順③でコピーしたProxy URLを、このページの<b>Custom bot with proxy 連携</b>の<b>Proxy URL</b>に入力、更新します。",
+      "copy_proxy_url": "②が正常に完了すると、モーダル内で選択したSlack ChannelにProxy URLが表示されるので、コピーします。",
+      "enter_proxy_url_and_update": "連携手順③でコピーしたProxy URLを、このページの<b>Custom bot with proxy 連携</b>の<b>Proxy URL</b>に入力、更新します。",
       "dont_need_update": "※既に値が入っている場合は更新する必要はありません",
       "select_install_your_app": "Install your app をクリックします。",
       "select_install_to_workspace": "Install to Workspace をクリックします。",

+ 2 - 1
resource/locales/zh_CN/admin/admin.json

@@ -321,7 +321,8 @@
       "paste_growi_url": "由于显示了模式,请在 <b>GROWI URL</b> 中输入以下URL",
       "enter_access_token_for_growi_and_proxy": "插入上面发出的 <b>Access Token for GROWI</b> 和 <b>Access Token for Proxy</b>。",
       "set_proxy_url_on_growi": "向GROWI注册Proxy的URL",
-      "enter_proxy_url_and_update": "1. 输入并更新你在步骤③中复制的ProxyURL到本页的<b>Custom bot with proxy 一体化</b>的<b>ProxyURL</b>。",
+      "copy_proxy_url": "当上述步骤②成功完成后,Proxy URL将显示在你在模版中选择的Slack频道中,所以请复制它。",
+      "enter_proxy_url_and_update": "输入并更新你在步骤③中复制的ProxyURL到本页的<b>Custom bot with proxy 一体化</b>的<b>ProxyURL</b>。",
       "dont_need_update": "※如果值已经在里面了,就不需要再更新。",
       "select_install_your_app": "选择 \"Install your app\"。",
       "select_install_to_workspace": "选择 \"Install to Workspace\"。",

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

@@ -55,16 +55,28 @@ const RegisteringProxyUrlProcess = () => {
   const { t } = useTranslation();
   return (
     <div className="p-4 d-flex flex-column align-items-center">
-      <div>
-        <span
-          // eslint-disable-next-line react/no-danger
-          dangerouslySetInnerHTML={{ __html: t('admin:slack_integration.accordion.enter_proxy_url_and_update') }}
-        />
-        <p className="text-danger">{t('admin:slack_integration.accordion.dont_need_update')}</p>
-      </div>
-      <div className="rounded border w-50 d-flex justify-content-center align-items-center" style={{ height: '15rem' }}>
-        <h1 className="text-muted">参考画像</h1>
-      </div>
+      <ol>
+        <li>
+          <p
+            // eslint-disable-next-line react/no-danger
+            dangerouslySetInnerHTML={{ __html: t('admin:slack_integration.accordion.copy_proxy_url') }}
+          />
+          <div className="rounded border d-flex mb-5 justify-content-center align-items-center" style={{ height: '10rem' }}>
+            <h1 className="text-muted">参考画像</h1>
+          </div>
+        </li>
+
+        <li>
+          <span
+            // eslint-disable-next-line react/no-danger
+            dangerouslySetInnerHTML={{ __html: t('admin:slack_integration.accordion.enter_proxy_url_and_update') }}
+          />
+          <p className="text-danger">{t('admin:slack_integration.accordion.dont_need_update')}</p>
+          <div className="rounded border d-flex justify-content-center align-items-center" style={{ height: '15rem' }}>
+            <h1 className="text-muted">参考画像</h1>
+          </div>
+        </li>
+      </ol>
     </div>
   );
 };
@@ -99,23 +111,29 @@ const GeneratingTokensAndRegisteringProxyServiceProcess = withUnstatedContainers
       <div className="form-group row">
         <label className="text-left text-md-right col-md-3 col-form-label">Access Token for GROWI</label>
         <div className="col-md-6">
-          <input
-            className="form-control"
-            type="text"
-            value={tokenGtoP}
-            readOnly
-          />
+          <div className="input-group-prepend mx-1">
+            {/* TODO: show tokenPtoG GW-5899 */}
+            <input className="form-control" type="text" value={tokenPtoG} readOnly />
+            <CopyToClipboard text="tokenPtoG" onCopy={() => toastSuccess(t('admin:slack_integration.copied_to_clipboard'))}>
+              <div className="btn input-group-text">
+                <i className="fa fa-clipboard mx-1" aria-hidden="true"></i>
+              </div>
+            </CopyToClipboard>
+          </div>
         </div>
       </div>
       <div className="form-group row">
         <label className="text-left text-md-right col-md-3 col-form-label">Access Token for Proxy</label>
         <div className="col-md-6">
-          <input
-            className="form-control"
-            type="text"
-            value={tokenPtoG}
-            readOnly
-          />
+          <div className="input-group-prepend mx-1">
+            {/* TODO: show tokenGtoP GW-5899 */}
+            <input className="form-control" type="text" value={tokenGtoP} readOnly />
+            <CopyToClipboard text="tokenGtoP" onCopy={() => toastSuccess(t('admin:slack_integration.copied_to_clipboard'))}>
+              <div className="btn input-group-text">
+                <i className="fa fa-clipboard mx-1" aria-hidden="true"></i>
+              </div>
+            </CopyToClipboard>
+          </div>
         </div>
       </div>
 

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

@@ -77,6 +77,7 @@ module.exports = (crowi) => {
       'slackbot:currentBotType': null,
       'slackbot:signingSecret': null,
       'slackbot:token': null,
+      'slackbot:serverUri': null,
     };
     const { configManager } = crowi;
     // update config without publishing S2sMessage