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/03/01 13:47:09 UTC

[incubator-devlake] branch main updated: fix(config-ui): some bugs (#4554)

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 0249c58a6 fix(config-ui): some bugs (#4554)
0249c58a6 is described below

commit 0249c58a6d450c492db37b03be45a40531ffb3ca
Author: 青湛 <0x...@gmail.com>
AuthorDate: Wed Mar 1 21:47:04 2023 +0800

    fix(config-ui): some bugs (#4554)
    
    * fix(config-ui): adjust the placeholder for github transformation
    
    * fix(config-ui): payload error from create bp
    
    * fix(config-ui): delete webhook in project does not update bp
    
    * fix(config-ui): endpoint version error in connection form
    
    * fix(config-ui): adjust icon for data scope
    
    * fix(config-ui): show support plugin version
---
 config-ui/src/pages/blueprint/create/bp-context.tsx |  2 +-
 .../pages/blueprint/create/step-two/use-columns.tsx |  2 +-
 .../pages/blueprint/detail/panel/configuration.tsx  |  2 +-
 config-ui/src/pages/project/detail/index.tsx        |  3 ++-
 .../project/detail/panel/incoming-webhooks.tsx      | 11 +++++++++--
 config-ui/src/pages/project/detail/use-project.ts   | 21 +++++++++++++++++++++
 .../components/connection-form/fields/endpoint.tsx  |  5 +++--
 config-ui/src/plugins/register/bitbucket/config.tsx |  1 +
 config-ui/src/plugins/register/github/config.tsx    |  2 +-
 .../src/plugins/register/github/transformation.tsx  | 12 ++++++------
 config-ui/src/plugins/register/gitlab/config.tsx    |  2 +-
 config-ui/src/plugins/register/jira/config.tsx      |  2 +-
 .../plugins/register/webook/connection/index.tsx    | 21 +++++++++++++++------
 13 files changed, 63 insertions(+), 23 deletions(-)

diff --git a/config-ui/src/pages/blueprint/create/bp-context.tsx b/config-ui/src/pages/blueprint/create/bp-context.tsx
index 004f597d6..ea5d22b14 100644
--- a/config-ui/src/pages/blueprint/create/bp-context.tsx
+++ b/config-ui/src/pages/blueprint/create/bp-context.tsx
@@ -119,7 +119,7 @@ export const BPContextProvider = ({ from, projectName, children }: Props) => {
   const payload = useMemo(() => {
     const params: any = {
       name,
-      projectName: window.decodeURIComponent(projectName),
+      projectName: projectName ? window.decodeURIComponent(projectName) : '',
       mode,
       enable: true,
       cronConfig,
diff --git a/config-ui/src/pages/blueprint/create/step-two/use-columns.tsx b/config-ui/src/pages/blueprint/create/step-two/use-columns.tsx
index b10fc2867..087fa3b0a 100644
--- a/config-ui/src/pages/blueprint/create/step-two/use-columns.tsx
+++ b/config-ui/src/pages/blueprint/create/step-two/use-columns.tsx
@@ -62,7 +62,7 @@ export const useColumns = ({ onDetail }: Props) => {
               small
               minimal
               intent={Intent.PRIMARY}
-              icon="add"
+              icon="cog"
               text="Set Data Scope"
               onClick={() => onDetail(connection)}
             />
diff --git a/config-ui/src/pages/blueprint/detail/panel/configuration.tsx b/config-ui/src/pages/blueprint/detail/panel/configuration.tsx
index fc396c06d..fc99df4f7 100644
--- a/config-ui/src/pages/blueprint/detail/panel/configuration.tsx
+++ b/config-ui/src/pages/blueprint/detail/panel/configuration.tsx
@@ -159,7 +159,7 @@ export const Configuration = ({ blueprint, operating, onUpdate, onRefresh }: Pro
                   setCurConnection(row);
                 }}
               >
-                <Icon icon="add" color={Colors.BLUE2} />
+                <Icon icon="annotation" color={Colors.BLUE2} />
                 <span>Change Data Scope</span>
               </div>
               {row.plugin !== 'sonarqube' && (
diff --git a/config-ui/src/pages/project/detail/index.tsx b/config-ui/src/pages/project/detail/index.tsx
index a7d8bef5b..929e94114 100644
--- a/config-ui/src/pages/project/detail/index.tsx
+++ b/config-ui/src/pages/project/detail/index.tsx
@@ -29,7 +29,7 @@ import * as S from './styled';
 export const ProjectDetailPage = () => {
   const { pname } = useParams<{ pname: string }>();
 
-  const { loading, project, saving, onUpdate, onSelectWebhook, onCreateWebhook } = useProject(pname);
+  const { loading, project, saving, onUpdate, onSelectWebhook, onCreateWebhook, onDeleteWebhook } = useProject(pname);
 
   if (loading || !project) {
     return <PageLoading />;
@@ -55,6 +55,7 @@ export const ProjectDetailPage = () => {
                 saving={saving}
                 onSelectWebhook={onSelectWebhook}
                 onCreateWebhook={onCreateWebhook}
+                onDeleteWebhook={onDeleteWebhook}
               />
             }
           />
diff --git a/config-ui/src/pages/project/detail/panel/incoming-webhooks.tsx b/config-ui/src/pages/project/detail/panel/incoming-webhooks.tsx
index 0552989e1..45ad0432d 100644
--- a/config-ui/src/pages/project/detail/panel/incoming-webhooks.tsx
+++ b/config-ui/src/pages/project/detail/panel/incoming-webhooks.tsx
@@ -30,9 +30,16 @@ interface Props {
   saving: boolean;
   onSelectWebhook: (items: WebhookItemType[]) => void;
   onCreateWebhook: (id: ID) => any;
+  onDeleteWebhook: (id: ID) => any;
 }
 
-export const IncomingWebhooksPanel = ({ project, saving, onSelectWebhook, onCreateWebhook }: Props) => {
+export const IncomingWebhooksPanel = ({
+  project,
+  saving,
+  onSelectWebhook,
+  onCreateWebhook,
+  onDeleteWebhook,
+}: Props) => {
   const [type, setType] = useState<'selectExist' | 'create'>();
 
   const webhookIds = useMemo(
@@ -75,5 +82,5 @@ export const IncomingWebhooksPanel = ({ project, saving, onSelectWebhook, onCrea
     );
   }
 
-  return <WebHookConnection filterIds={webhookIds} onCreateAfter={onCreateWebhook} />;
+  return <WebHookConnection filterIds={webhookIds} onCreateAfter={onCreateWebhook} onDeleteAfter={onDeleteWebhook} />;
 };
diff --git a/config-ui/src/pages/project/detail/use-project.ts b/config-ui/src/pages/project/detail/use-project.ts
index c8e7014fa..01c1a3523 100644
--- a/config-ui/src/pages/project/detail/use-project.ts
+++ b/config-ui/src/pages/project/detail/use-project.ts
@@ -127,6 +127,26 @@ export const useProject = (name: string) => {
     }
   };
 
+  const handleDeleteWebhook = async (id: ID) => {
+    const payload = {
+      ...project?.blueprint,
+      settings: {
+        version: '2.0.0',
+        connections: project?.blueprint.settings.connections.filter(
+          (cs: any) => !(cs.plugin === 'webhook' && cs.connectionId === id),
+        ),
+      },
+    };
+
+    const [success] = await operator(() => API.updateBlueprint(project?.blueprint.id, payload), {
+      setOperating: setSaving,
+    });
+
+    if (success) {
+      getProject();
+    }
+  };
+
   return useMemo(
     () => ({
       loading,
@@ -135,6 +155,7 @@ export const useProject = (name: string) => {
       onUpdate: handleUpdate,
       onSelectWebhook: handleSelectWebhook,
       onCreateWebhook: handleCreateWebhook,
+      onDeleteWebhook: handleDeleteWebhook,
     }),
     [loading, project, saving, name],
   );
diff --git a/config-ui/src/plugins/components/connection-form/fields/endpoint.tsx b/config-ui/src/plugins/components/connection-form/fields/endpoint.tsx
index 59bd64354..9f17011b6 100644
--- a/config-ui/src/plugins/components/connection-form/fields/endpoint.tsx
+++ b/config-ui/src/plugins/components/connection-form/fields/endpoint.tsx
@@ -66,6 +66,7 @@ export const ConnectionEndpoint = ({
 
   useEffect(() => {
     setValue(initialValue);
+    setVersion(initialValue === multipleVersions?.cloud ? 'cloud' : 'server');
   }, [initialValue]);
 
   useEffect(() => {
@@ -94,8 +95,8 @@ export const ConnectionEndpoint = ({
       <FormGroup label={<S.Label>{name} Version</S.Label>} labelInfo={<S.LabelInfo>*</S.LabelInfo>}>
         <RadioGroup inline selectedValue={version} onChange={handleChange}>
           <Radio value="cloud">{name} Cloud</Radio>
-          <Radio value="server" disabled={multipleVersions.server === undefined}>
-            {name} Server
+          <Radio value="server" disabled={!multipleVersions.server}>
+            {name} Server {multipleVersions.server ? multipleVersions.server : '(to be supported)'}
           </Radio>
         </RadioGroup>
         {version === 'cloud' && (
diff --git a/config-ui/src/plugins/register/bitbucket/config.tsx b/config-ui/src/plugins/register/bitbucket/config.tsx
index b15349ea2..c3db9da8d 100644
--- a/config-ui/src/plugins/register/bitbucket/config.tsx
+++ b/config-ui/src/plugins/register/bitbucket/config.tsx
@@ -38,6 +38,7 @@ export const BitBucketConfig: PluginConfigType = {
         key: 'endpoint',
         multipleVersions: {
           cloud: 'https://api.bitbucket.org/2.0/',
+          server: '',
         },
       },
       'username',
diff --git a/config-ui/src/plugins/register/github/config.tsx b/config-ui/src/plugins/register/github/config.tsx
index 512941114..bd7f180ec 100644
--- a/config-ui/src/plugins/register/github/config.tsx
+++ b/config-ui/src/plugins/register/github/config.tsx
@@ -42,7 +42,7 @@ export const GitHubConfig: PluginConfigType = {
         key: 'endpoint',
         multipleVersions: {
           cloud: 'https://api.github.com/',
-          server: '',
+          server: ' ',
         },
       },
       ({ initialValues, values, errors, setValues, setErrors }: any) => (
diff --git a/config-ui/src/plugins/register/github/transformation.tsx b/config-ui/src/plugins/register/github/transformation.tsx
index e3522fd42..01d33df07 100644
--- a/config-ui/src/plugins/register/github/transformation.tsx
+++ b/config-ui/src/plugins/register/github/transformation.tsx
@@ -167,7 +167,7 @@ export const GitHubTransformation = ({ transformation, setTransformation }: Prop
           }
         >
           <InputGroup
-            placeholder="component/(.*)$"
+            placeholder="component(.*)$"
             value={transformation.issueComponent}
             onChange={(e) =>
               setTransformation({
@@ -187,7 +187,7 @@ export const GitHubTransformation = ({ transformation, setTransformation }: Prop
           }
         >
           <InputGroup
-            placeholder="severity/(.*)$"
+            placeholder="severity(.*)$"
             value={transformation.issueSeverity}
             onChange={(e) =>
               setTransformation({
@@ -233,7 +233,7 @@ export const GitHubTransformation = ({ transformation, setTransformation }: Prop
                   }
                 >
                   <InputGroup
-                    placeholder="(?i)deploy"
+                    placeholder="^.*(deploy|push-image).*$"
                     value={transformation.deploymentPattern}
                     onChange={(e) =>
                       setTransformation({
@@ -253,7 +253,7 @@ export const GitHubTransformation = ({ transformation, setTransformation }: Prop
                   }
                 >
                   <InputGroup
-                    placeholder="(?i)production"
+                    placeholder="^.*product.*$"
                     value={transformation.productionPattern}
                     onChange={(e) =>
                       setTransformation({
@@ -290,7 +290,7 @@ export const GitHubTransformation = ({ transformation, setTransformation }: Prop
           }
         >
           <InputGroup
-            placeholder="type/(.*)$"
+            placeholder="type(.*)$"
             value={transformation.prType}
             onChange={(e) => setTransformation({ ...transformation, prType: e.target.value })}
           />
@@ -305,7 +305,7 @@ export const GitHubTransformation = ({ transformation, setTransformation }: Prop
           }
         >
           <InputGroup
-            placeholder="component/(.*)$"
+            placeholder="component(.*)$"
             value={transformation.prComponent}
             onChange={(e) =>
               setTransformation({
diff --git a/config-ui/src/plugins/register/gitlab/config.tsx b/config-ui/src/plugins/register/gitlab/config.tsx
index 5a3d06d1f..0518b2263 100644
--- a/config-ui/src/plugins/register/gitlab/config.tsx
+++ b/config-ui/src/plugins/register/gitlab/config.tsx
@@ -42,7 +42,7 @@ export const GitLabConfig: PluginConfigType = {
         key: 'endpoint',
         multipleVersions: {
           cloud: 'https://gitlab.com/api/v4/',
-          server: '',
+          server: '(v11+)',
         },
         subLabel:
           'If you are using GitLab Cloud, you do not need to enter the endpoint URL, which is https://gitlab.com/api/v4/.',
diff --git a/config-ui/src/plugins/register/jira/config.tsx b/config-ui/src/plugins/register/jira/config.tsx
index 86c24bb4d..abf1a39c5 100644
--- a/config-ui/src/plugins/register/jira/config.tsx
+++ b/config-ui/src/plugins/register/jira/config.tsx
@@ -37,7 +37,7 @@ export const JiraConfig: PluginConfigType = {
       {
         key: 'endpoint',
         subLabel:
-          'Provide the Jira instance API endpoint. For Jira Cloud, e.g. https://your-company.atlassian.net/rest/. For Jira Server v8+, e.g. https://your-company.atlassian.net/rest/. Please note: The endpoint URL should end with /.',
+          'Provide the Jira instance API endpoint. For Jira Cloud, e.g. https://your-company.atlassian.net/rest/. For Jira Server/Data Center v7+, e.g. https://your-company.atlassian.net/rest/. Please note: The endpoint URL should end with /.',
       },
       ({ initialValues, values, errors, setValues, setErrors }: any) => {
         const initialValue = useMemo(
diff --git a/config-ui/src/plugins/register/webook/connection/index.tsx b/config-ui/src/plugins/register/webook/connection/index.tsx
index c2bc368c9..d637895a0 100644
--- a/config-ui/src/plugins/register/webook/connection/index.tsx
+++ b/config-ui/src/plugins/register/webook/connection/index.tsx
@@ -17,9 +17,9 @@
  */
 
 import React, { useState } from 'react';
-import { ButtonGroup, Button, Icon, Intent } from '@blueprintjs/core';
+import { ButtonGroup, Button, Intent } from '@blueprintjs/core';
 
-import { Table, ColumnType, ExternalLink } from '@/components';
+import { Table, ColumnType, ExternalLink, IconButton } from '@/components';
 
 import type { WebhookItemType } from '../types';
 import { WebhookCreateDialog } from '../create-dialog';
@@ -34,9 +34,10 @@ type Type = 'add' | 'edit' | 'show' | 'delete';
 
 interface Props extends UseConnectionProps {
   onCreateAfter?: (id: ID) => void;
+  onDeleteAfter?: (id: ID) => void;
 }
 
-export const WebHookConnection = ({ onCreateAfter, ...props }: Props) => {
+export const WebHookConnection = ({ onCreateAfter, onDeleteAfter, ...props }: Props) => {
   const [type, setType] = useState<Type>();
   const [record, setRecord] = useState<WebhookItemType>();
 
@@ -71,8 +72,8 @@ export const WebHookConnection = ({ onCreateAfter, ...props }: Props) => {
       align: 'center',
       render: (_, row) => (
         <S.Action>
-          <Icon icon="edit" onClick={() => handleShowDialog('edit', row)} />
-          <Icon icon="trash" onClick={() => handleShowDialog('delete', row)} />
+          <IconButton icon="edit" tooltip="Edit" onClick={() => handleShowDialog('edit', row)} />
+          <IconButton icon="trash" tooltip="Delete" onClick={() => handleShowDialog('delete', row)} />
         </S.Action>
       ),
     },
@@ -109,7 +110,15 @@ export const WebHookConnection = ({ onCreateAfter, ...props }: Props) => {
         />
       )}
       {type === 'delete' && (
-        <WebhookDeleteDialog isOpen initialValues={record} onCancel={handleHideDialog} onSubmitAfter={onRefresh} />
+        <WebhookDeleteDialog
+          isOpen
+          initialValues={record}
+          onCancel={handleHideDialog}
+          onSubmitAfter={(id) => {
+            onRefresh();
+            onDeleteAfter?.(id);
+          }}
+        />
       )}
       {(type === 'edit' || type === 'show') && (
         <WebhookViewOrEditDialog