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 3a9dc5525 feat(config-ui): support plugin pagerduty (#4817)
3a9dc5525 is described below

commit 3a9dc5525ce4a531963753439c2c578dd68db874
Author: 青湛 <[email protected]>
AuthorDate: Fri Mar 31 00:36:43 2023 +0800

    feat(config-ui): support plugin pagerduty (#4817)
    
    * refactor(config-ui): adjust the sort for plugins
    
    * feat(config-ui): support plugin pagerduty
---
 .../plugins/components/data-scope-form/index.tsx   |  9 +++-
 config-ui/src/plugins/config.ts                    |  2 +
 config-ui/src/plugins/register/base/config.ts      |  2 +-
 .../src/plugins/register/pagerduty/assets/icon.svg | 26 +++++++++++
 .../{zentao/config.ts => pagerduty/config.tsx}     | 27 ++++++-----
 .../src/plugins/register/pagerduty/data-scope.tsx  | 52 ++++++++++++++++++++++
 .../{base/config.ts => pagerduty/index.ts}         | 20 +--------
 .../{base/config.ts => pagerduty/styled.ts}        | 19 +-------
 .../{base/config.ts => pagerduty/types.ts}         | 21 ++-------
 config-ui/src/plugins/register/tapd/config.tsx     |  2 +-
 config-ui/src/plugins/register/zentao/config.ts    |  2 +-
 11 files changed, 114 insertions(+), 68 deletions(-)

diff --git a/config-ui/src/plugins/components/data-scope-form/index.tsx 
b/config-ui/src/plugins/components/data-scope-form/index.tsx
index 27ab684bc..adf630099 100644
--- a/config-ui/src/plugins/components/data-scope-form/index.tsx
+++ b/config-ui/src/plugins/components/data-scope-form/index.tsx
@@ -30,6 +30,7 @@ import { GitLabDataScope } from '@/plugins/register/gitlab';
 import { JenkinsDataScope } from '@/plugins/register/jenkins';
 import { BitbucketDataScope } from '@/plugins/register/bitbucket';
 import { SonarQubeDataScope } from '@/plugins/register/sonarqube';
+import { PagerDutyDataScope } from '@/plugins/register/pagerduty';
 import { ZentaoDataScope } from '@/plugins/register/zentao';
 
 import * as API from './api';
@@ -147,13 +148,17 @@ export const DataScopeForm = ({
             <SonarQubeDataScope connectionId={connectionId} 
selectedItems={scope} onChangeItems={setScope} />
           )}
 
-          {plugin === 'zentao' && (
-            <ZentaoDataScope connectionId={connectionId} selectedItems={scope} 
onChangeItems={setScope} />
+          {plugin === 'pagerduty' && (
+            <PagerDutyDataScope connectionId={connectionId} 
selectedItems={scope} onChangeItems={setScope} />
           )}
 
           {plugin === 'tapd' && (
             <TapdDataScope connectionId={connectionId} selectedItems={scope} 
onChangeItems={setScope} />
           )}
+
+          {plugin === 'zentao' && (
+            <ZentaoDataScope connectionId={connectionId} selectedItems={scope} 
onChangeItems={setScope} />
+          )}
         </div>
 
         <div className="block">
diff --git a/config-ui/src/plugins/config.ts b/config-ui/src/plugins/config.ts
index d8554f8af..3901bf9a8 100644
--- a/config-ui/src/plugins/config.ts
+++ b/config-ui/src/plugins/config.ts
@@ -32,6 +32,7 @@ import { GitLabConfig } from './register/gitlab';
 import { JenkinsConfig } from './register/jenkins';
 import { JiraConfig } from './register/jira';
 import { OrgConfig } from './register/org';
+import { PagerDutyConfig } from './register/pagerduty';
 import { RefDiffConfig } from './register/refdiff';
 import { SonarQubeConfig } from './register/sonarqube';
 import { StarRocksConfig } from './register/starrocks';
@@ -56,6 +57,7 @@ export const PluginConfig: PluginConfigType[] = [
   JenkinsConfig,
   JiraConfig,
   OrgConfig,
+  PagerDutyConfig,
   RefDiffConfig,
   SonarQubeConfig,
   StarRocksConfig,
diff --git a/config-ui/src/plugins/register/base/config.ts 
b/config-ui/src/plugins/register/base/config.ts
index 26403e4d3..2cec50ce9 100644
--- a/config-ui/src/plugins/register/base/config.ts
+++ b/config-ui/src/plugins/register/base/config.ts
@@ -25,7 +25,7 @@ export const BasePipelineConfig = {
   plugin: undefined,
   name: undefined,
   icon: Icon,
-  sort: 99,
+  sort: 101,
   connection: {
     docLink: '',
     initialValues: {},
diff --git a/config-ui/src/plugins/register/pagerduty/assets/icon.svg 
b/config-ui/src/plugins/register/pagerduty/assets/icon.svg
new file mode 100644
index 000000000..029a71372
--- /dev/null
+++ b/config-ui/src/plugins/register/pagerduty/assets/icon.svg
@@ -0,0 +1,26 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<svg width="54" height="54" viewBox="0 0 54 54" fill="none" 
xmlns="http://www.w3.org/2000/svg";>
+  <path
+    d="M21.2345 26.4141H26.3121C29.8682 26.4141 32.5628 24.9843 32.5628 
21.2449C32.5628 17.7621 30.3814 16.2223 26.0188 16.2773L21.2345 16.314V26.4141Z"
+    fill="#7497F7" />
+  <path fill-rule="evenodd" clip-rule="evenodd"
+    d="M2.55572 0.333984C1.32842 0.333984 0.333496 1.32891 0.333496 
2.55621V51.4451C0.333496 52.6724 1.32842 53.6673 2.55572 
53.6673H51.4446C52.6719 53.6673 53.6668 52.6724 53.6668 51.4451V2.55621C53.6668 
1.32891 52.6719 0.333984 51.4446 0.333984H2.55572ZM25.3772 12.5562C29.0983 
12.5562 30.6747 12.7578 32.9477 13.9677C35.404 15.3058 36.9254 17.9271 36.9254 
21.2082C36.9254 24.2328 35.6973 26.854 33.3143 28.4304C31.133 29.8786 28.6584 
30.0802 25.3406 30.0802H17.0002V12.5562H25.3772ZM17.000 [...]
+    fill="#7497F7" />
+</svg>
+  
\ No newline at end of file
diff --git a/config-ui/src/plugins/register/zentao/config.ts 
b/config-ui/src/plugins/register/pagerduty/config.tsx
similarity index 69%
copy from config-ui/src/plugins/register/zentao/config.ts
copy to config-ui/src/plugins/register/pagerduty/config.tsx
index 27142f9f3..b7d2aa1d1 100644
--- a/config-ui/src/plugins/register/zentao/config.ts
+++ b/config-ui/src/plugins/register/pagerduty/config.tsx
@@ -21,29 +21,34 @@ import { PluginType } from '@/plugins';
 
 import Icon from './assets/icon.svg';
 
-export const ZenTaoConfig: PluginConfigType = {
+export const PagerDutyConfig: PluginConfigType = {
   type: PluginType.Connection,
-  plugin: 'zentao',
-  name: 'ZenTao',
+  plugin: 'pagerduty',
+  name: 'PagerDuty',
   icon: Icon,
-  sort: 100,
+  sort: 8,
   connection: {
-    docLink: 'https://devlake.apache.org/docs/Configuration/Zentao',
+    docLink: 'https://devlake.apache.org/docs/Configuration/PagerDuty',
+    initialValues: {
+      endpoint: 'https://api.pagerduty.com/',
+    },
     fields: [
       'name',
       {
         key: 'endpoint',
-        subLabel: 'Provide the Zentao instance API endpoint (Opensource v16+). 
E.g. http://<host>:<port>/api.php/v1',
+        multipleVersions: {
+          cloud: 'https://api.pagerduty.com/',
+          server: '',
+        },
       },
-      'username',
-      'password',
+      'token',
       'proxy',
       {
         key: 'rateLimitPerHour',
         subLabel:
-          'By default, DevLake uses 10,000 requests/hour for data collection 
for ZenTao. But you can adjust the collection speed by setting up your 
desirable rate limit.',
-        learnMore: 
'https://devlake.apache.org/docs/Configuration/Zentao/#custom-rate-limit-optional',
-        externalInfo: 'ZenTao does not specify a maximum value of rate limit.',
+          'By default, DevLake uses 10,000 requests/hour for data collection 
for PagerDuty. But you can adjust the collection speed by setting up your 
desirable rate limit.',
+        learnMore: 
'https://devlake.apache.org/docs/Configuration/PagerDuty/#custom-rate-limit-optional',
+        externalInfo: 'PagerDuty does not specify a maximum value of rate 
limit.',
         defaultValue: 10000,
       },
     ],
diff --git a/config-ui/src/plugins/register/pagerduty/data-scope.tsx 
b/config-ui/src/plugins/register/pagerduty/data-scope.tsx
new file mode 100644
index 000000000..59c4e9d73
--- /dev/null
+++ b/config-ui/src/plugins/register/pagerduty/data-scope.tsx
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+import { useMemo } from 'react';
+
+import { DataScopeMillerColumns } from '@/plugins';
+
+import type { ScopeItemType } from './types';
+import * as S from './styled';
+
+interface Props {
+  connectionId: ID;
+  selectedItems: ScopeItemType[];
+  onChangeItems: (selectedItems: ScopeItemType[]) => void;
+}
+
+export const PagerDutyDataScope = ({ connectionId, onChangeItems, ...props }: 
Props) => {
+  const selectedItems = useMemo(
+    () => props.selectedItems.map((it) => ({ id: `${it.id}`, name: it.name, 
data: it })),
+    [props.selectedItems],
+  );
+
+  return (
+    <S.DataScope>
+      <h3>PagerDuty Services *</h3>
+      <p>You can either add services by searching or selecting from the 
following directory.</p>
+      <DataScopeMillerColumns
+        title="PagerDuty Services *"
+        columnCount={1}
+        plugin="pagerduty"
+        connectionId={connectionId}
+        selectedItems={selectedItems}
+        onChangeItems={onChangeItems}
+      />
+    </S.DataScope>
+  );
+};
diff --git a/config-ui/src/plugins/register/base/config.ts 
b/config-ui/src/plugins/register/pagerduty/index.ts
similarity index 70%
copy from config-ui/src/plugins/register/base/config.ts
copy to config-ui/src/plugins/register/pagerduty/index.ts
index 26403e4d3..46ed09889 100644
--- a/config-ui/src/plugins/register/base/config.ts
+++ b/config-ui/src/plugins/register/pagerduty/index.ts
@@ -16,21 +16,5 @@
  *
  */
 
-import { PluginType } from '../../types';
-
-import Icon from './assets/icon.svg';
-
-export const BasePipelineConfig = {
-  type: PluginType.Pipeline,
-  plugin: undefined,
-  name: undefined,
-  icon: Icon,
-  sort: 99,
-  connection: {
-    docLink: '',
-    initialValues: {},
-    fields: [],
-  },
-  entities: [],
-  transformation: {},
-};
+export * from './config';
+export * from './data-scope';
diff --git a/config-ui/src/plugins/register/base/config.ts 
b/config-ui/src/plugins/register/pagerduty/styled.ts
similarity index 70%
copy from config-ui/src/plugins/register/base/config.ts
copy to config-ui/src/plugins/register/pagerduty/styled.ts
index 26403e4d3..2a80753ef 100644
--- a/config-ui/src/plugins/register/base/config.ts
+++ b/config-ui/src/plugins/register/pagerduty/styled.ts
@@ -16,21 +16,6 @@
  *
  */
 
-import { PluginType } from '../../types';
+import styled from 'styled-components';
 
-import Icon from './assets/icon.svg';
-
-export const BasePipelineConfig = {
-  type: PluginType.Pipeline,
-  plugin: undefined,
-  name: undefined,
-  icon: Icon,
-  sort: 99,
-  connection: {
-    docLink: '',
-    initialValues: {},
-    fields: [],
-  },
-  entities: [],
-  transformation: {},
-};
+export const DataScope = styled.div``;
diff --git a/config-ui/src/plugins/register/base/config.ts 
b/config-ui/src/plugins/register/pagerduty/types.ts
similarity index 71%
copy from config-ui/src/plugins/register/base/config.ts
copy to config-ui/src/plugins/register/pagerduty/types.ts
index 26403e4d3..85a835aba 100644
--- a/config-ui/src/plugins/register/base/config.ts
+++ b/config-ui/src/plugins/register/pagerduty/types.ts
@@ -16,21 +16,8 @@
  *
  */
 
-import { PluginType } from '../../types';
-
-import Icon from './assets/icon.svg';
-
-export const BasePipelineConfig = {
-  type: PluginType.Pipeline,
-  plugin: undefined,
-  name: undefined,
-  icon: Icon,
-  sort: 99,
-  connection: {
-    docLink: '',
-    initialValues: {},
-    fields: [],
-  },
-  entities: [],
-  transformation: {},
+export type ScopeItemType = {
+  connectionId: ID;
+  id: ID;
+  name: string;
 };
diff --git a/config-ui/src/plugins/register/tapd/config.tsx 
b/config-ui/src/plugins/register/tapd/config.tsx
index 73e46fc4c..c09576633 100644
--- a/config-ui/src/plugins/register/tapd/config.tsx
+++ b/config-ui/src/plugins/register/tapd/config.tsx
@@ -29,7 +29,7 @@ export const TAPDConfig: PluginConfigType = {
   plugin: 'tapd',
   name: 'TAPD',
   icon: Icon,
-  sort: 100,
+  sort: 9,
   connection: {
     docLink: 'https://devlake.apache.org/docs/Configuration/Tapd',
     initialValues: {
diff --git a/config-ui/src/plugins/register/zentao/config.ts 
b/config-ui/src/plugins/register/zentao/config.ts
index 27142f9f3..eb900df05 100644
--- a/config-ui/src/plugins/register/zentao/config.ts
+++ b/config-ui/src/plugins/register/zentao/config.ts
@@ -26,7 +26,7 @@ export const ZenTaoConfig: PluginConfigType = {
   plugin: 'zentao',
   name: 'ZenTao',
   icon: Icon,
-  sort: 100,
+  sort: 10,
   connection: {
     docLink: 'https://devlake.apache.org/docs/Configuration/Zentao',
     fields: [

Reply via email to