You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by li...@apache.org on 2023/01/05 11:18:25 UTC

[incubator-devlake] branch main updated: feat(config-ui): support connection bitbucket (#4117)

This is an automated email from the ASF dual-hosted git repository.

likyh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new b5cb5556a feat(config-ui): support connection bitbucket (#4117)
b5cb5556a is described below

commit b5cb5556abf9cb9929ac75da5056d4ae1bb7c301
Author: 青湛 <0x...@gmail.com>
AuthorDate: Thu Jan 5 19:18:21 2023 +0800

    feat(config-ui): support connection bitbucket (#4117)
    
    * feat(config-ui): add tag beta for connection
    
    * refactor(config-ui): rename github-token to githubToken
    
    * feat(config-ui): update plugin the bitbucket config
    
    * refactor(config-ui): adjust the config for tapd and zentao
    
    * refactor(config-ui): adjust the position for plugin
---
 config-ui/src/pages/connection/form/index.tsx |  2 +-
 config-ui/src/pages/connection/home/index.tsx |  9 ++++-
 config-ui/src/pages/connection/home/styled.ts | 13 +++++--
 config-ui/src/plugins/bitbucket/config.ts     | 52 ++++++++++++++++++++++++++-
 config-ui/src/plugins/config.ts               |  4 +--
 config-ui/src/plugins/github/config.ts        |  2 +-
 config-ui/src/plugins/tapd/config.ts          |  8 +++--
 config-ui/src/plugins/types.ts                |  3 +-
 config-ui/src/plugins/zentao/config.ts        |  8 +++--
 9 files changed, 87 insertions(+), 14 deletions(-)

diff --git a/config-ui/src/pages/connection/form/index.tsx b/config-ui/src/pages/connection/form/index.tsx
index bda33a0dc..4ed3f5e70 100644
--- a/config-ui/src/pages/connection/form/index.tsx
+++ b/config-ui/src/pages/connection/form/index.tsx
@@ -124,7 +124,7 @@ export const ConnectionFormPage = () => {
             }
           />
         )}
-        {type === 'github-token' && (
+        {type === 'githubToken' && (
           <GitHubToken
             form={form}
             value={form.token}
diff --git a/config-ui/src/pages/connection/home/index.tsx b/config-ui/src/pages/connection/home/index.tsx
index 668fa9e01..c543c8f50 100644
--- a/config-ui/src/pages/connection/home/index.tsx
+++ b/config-ui/src/pages/connection/home/index.tsx
@@ -18,7 +18,9 @@
 
 import React, { useMemo } from 'react';
 import { useHistory } from 'react-router-dom';
+import { Tag, Intent } from '@blueprintjs/core';
 
+import type { PluginConfigConnectionType } from '@/plugins';
 import { PluginConfig, PluginType, Plugins } from '@/plugins';
 
 import * as S from './styled';
@@ -28,7 +30,7 @@ export const ConnectionHomePage = () => {
 
   const [connections, webhook] = useMemo(
     () => [
-      PluginConfig.filter((p) => p.type === PluginType.Connection),
+      PluginConfig.filter((p) => p.type === PluginType.Connection) as PluginConfigConnectionType[],
       PluginConfig.filter((p) => p.plugin === Plugins.Webhook),
     ],
     [],
@@ -44,6 +46,11 @@ export const ConnectionHomePage = () => {
             <li key={cs.plugin} onClick={() => history.push(`/connections/${cs.plugin}`)}>
               <img src={cs.icon} alt="" />
               <span>{cs.name}</span>
+              {cs.isBeta && (
+                <Tag intent={Intent.WARNING} round>
+                  beta
+                </Tag>
+              )}
             </li>
           ))}
         </ul>
diff --git a/config-ui/src/pages/connection/home/styled.ts b/config-ui/src/pages/connection/home/styled.ts
index 7a12f4989..534e8387e 100644
--- a/config-ui/src/pages/connection/home/styled.ts
+++ b/config-ui/src/pages/connection/home/styled.ts
@@ -40,6 +40,7 @@ export const Wrapper = styled.div`
   }
 
   li {
+    position: relative;
     display: flex;
     flex-direction: column;
     align-items: center;
@@ -54,13 +55,19 @@ export const Wrapper = styled.div`
       box-shadow: 0 2px 2px 0 rgb(0 0 0 / 16%), 0 0 2px 0 rgb(0 0 0 / 12%);
     }
 
-    img {
-      width: 50px;
+    & > img {
+      width: 45px;
     }
 
-    span {
+    & > span {
       margin-top: 4px;
     }
+
+    & > .bp4-tag {
+      position: absolute;
+      top: -4px;
+      right: 4px;
+    }
   }
 
   li + li {
diff --git a/config-ui/src/plugins/bitbucket/config.ts b/config-ui/src/plugins/bitbucket/config.ts
index 45f9531b3..3b0b15415 100644
--- a/config-ui/src/plugins/bitbucket/config.ts
+++ b/config-ui/src/plugins/bitbucket/config.ts
@@ -24,6 +24,56 @@ import Icon from './assets/icon.svg';
 export const BitBucketConfig: PluginConfigType = {
   plugin: Plugins.BitBucket,
   name: 'BitBucket',
-  type: PluginType.Pipeline,
+  type: PluginType.Connection,
+  isBeta: true,
   icon: Icon,
+  connection: {
+    initialValues: {
+      rateLimitPerHour: 10000,
+    },
+    fields: [
+      {
+        key: 'name',
+        label: 'Connection Name',
+        type: 'text',
+        required: true,
+        placeholder: 'eg. BitBucket',
+      },
+      {
+        key: 'endpoint',
+        label: 'Endpoint URL',
+        type: 'text',
+        required: true,
+        placeholder: 'eg. https://api.bitbucket.org/2.0/',
+      },
+      {
+        key: 'username',
+        label: 'Username',
+        type: 'text',
+        required: true,
+        placeholder: 'eg. admin',
+      },
+      {
+        key: 'password',
+        label: 'App Password',
+        type: 'password',
+        required: true,
+        placeholder: 'eg. ************',
+      },
+      {
+        key: 'proxy',
+        label: 'Proxy URL',
+        type: 'text',
+        placeholder: 'eg. http://proxy.localhost:8080',
+      },
+      {
+        key: 'rateLimitPerHour',
+        label: 'Fixed Rate Limit (per hour)',
+        type: 'rateLimit',
+        tooltip: 'Rate Limit requests per hour,\nEnter a numeric value > 0 to enable.',
+      },
+    ],
+  },
+  entities: [],
+  transformation: {},
 };
diff --git a/config-ui/src/plugins/config.ts b/config-ui/src/plugins/config.ts
index 17a51db76..226bfba25 100644
--- a/config-ui/src/plugins/config.ts
+++ b/config-ui/src/plugins/config.ts
@@ -39,7 +39,6 @@ import { ZenTaoConfig } from './zentao';
 export const PluginConfig: PluginConfigType[] = [
   AEConfig,
   AzureConfig,
-  BitBucketConfig,
   DBTConfig,
   DORAConfig,
   FeiShuConfig,
@@ -52,7 +51,8 @@ export const PluginConfig: PluginConfigType[] = [
   JIRAConfig,
   RefDiffConfig,
   StarRocksConfig,
+  BitBucketConfig,
   TAPDConfig,
-  WebhookConfig,
   ZenTaoConfig,
+  WebhookConfig,
 ];
diff --git a/config-ui/src/plugins/github/config.ts b/config-ui/src/plugins/github/config.ts
index 3c9b96813..406ff7cb8 100644
--- a/config-ui/src/plugins/github/config.ts
+++ b/config-ui/src/plugins/github/config.ts
@@ -49,7 +49,7 @@ export const GitHubConfig: PluginConfigType = {
       {
         key: 'token',
         label: 'Basic Auth Token',
-        type: 'github-token',
+        type: 'githubToken',
         required: true,
         tooltip: "Due to Github's rate limit, input more tokens, \ncomma separated, to accelerate data collection.",
       },
diff --git a/config-ui/src/plugins/tapd/config.ts b/config-ui/src/plugins/tapd/config.ts
index 7b90cdb8e..204c9c2ac 100644
--- a/config-ui/src/plugins/tapd/config.ts
+++ b/config-ui/src/plugins/tapd/config.ts
@@ -25,8 +25,12 @@ export const TAPDConfig: PluginConfigType = {
   plugin: Plugins.TAPD,
   name: 'TAPD',
   type: PluginType.Connection,
+  isBeta: true,
   icon: Icon,
   connection: {
+    initialValues: {
+      rateLimitPerHour: 3000,
+    },
     fields: [
       {
         key: 'name',
@@ -64,8 +68,8 @@ export const TAPDConfig: PluginConfigType = {
       },
       {
         key: 'rateLimitPerHour',
-        label: 'Rate Limit (per hour)',
-        type: 'numeric',
+        label: 'Fixed Rate Limit (per hour)',
+        type: 'rateLimit',
         tooltip: 'Rate Limit requests per hour,\nEnter a numeric value > 0 to enable.',
       },
     ],
diff --git a/config-ui/src/plugins/types.ts b/config-ui/src/plugins/types.ts
index 6a6d9f5db..08eaa8fe2 100644
--- a/config-ui/src/plugins/types.ts
+++ b/config-ui/src/plugins/types.ts
@@ -48,11 +48,12 @@ export type PluginConfigConnectionType = {
   name: string;
   type: PluginType.Connection;
   icon: string;
+  isBeta?: boolean;
   connection: {
     initialValues?: Record<string, any>;
     fields: Array<{
       key: string;
-      type: 'text' | 'password' | 'switch' | 'rateLimit' | 'github-token';
+      type: 'text' | 'password' | 'switch' | 'rateLimit' | 'githubToken';
       label: string;
       required?: boolean;
       placeholder?: string;
diff --git a/config-ui/src/plugins/zentao/config.ts b/config-ui/src/plugins/zentao/config.ts
index 2ac9b27ba..b2f744dad 100644
--- a/config-ui/src/plugins/zentao/config.ts
+++ b/config-ui/src/plugins/zentao/config.ts
@@ -25,8 +25,12 @@ export const ZenTaoConfig: PluginConfigType = {
   plugin: Plugins.ZenTao,
   name: 'ZenTao',
   type: PluginType.Connection,
+  isBeta: true,
   icon: Icon,
   connection: {
+    initialValues: {
+      rateLimitPerHour: 10000,
+    },
     fields: [
       {
         key: 'name',
@@ -64,8 +68,8 @@ export const ZenTaoConfig: PluginConfigType = {
       },
       {
         key: 'rateLimitPerHour',
-        label: 'Rate Limit (per hour)',
-        type: 'numeric',
+        label: 'Fixed Rate Limit (per hour)',
+        type: 'rateLimit',
         tooltip: 'Rate Limit requests per hour,\nEnter a numeric value > 0 to enable.',
       },
     ],