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

klesh 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 2d2f1de41 feat(config-ui): support new plugin bamboo (#5773)
2d2f1de41 is described below

commit 2d2f1de4133b7af752e78a5d513701adb0ab191d
Author: 青湛 <[email protected]>
AuthorDate: Wed Aug 2 14:52:29 2023 +1200

    feat(config-ui): support new plugin bamboo (#5773)
---
 .../src/pages/pipeline/components/task/index.tsx   |   3 +
 .../plugins/components/scope-config-form/index.tsx |  13 ++-
 config-ui/src/plugins/config.ts                    |   2 +
 .../src/plugins/register/bamboo/assets/icon.svg    |  39 +++++++
 config-ui/src/plugins/register/bamboo/config.ts    |  62 +++++++++++
 config-ui/src/plugins/register/bamboo/index.ts     |  20 ++++
 config-ui/src/plugins/register/bamboo/styled.ts    |  38 +++++++
 .../src/plugins/register/bamboo/transformation.tsx | 121 +++++++++++++++++++++
 config-ui/src/plugins/utils.ts                     |   2 +
 9 files changed, 298 insertions(+), 2 deletions(-)

diff --git a/config-ui/src/pages/pipeline/components/task/index.tsx 
b/config-ui/src/pages/pipeline/components/task/index.tsx
index 4288b81c3..f59e6506d 100644
--- a/config-ui/src/pages/pipeline/components/task/index.tsx
+++ b/config-ui/src/pages/pipeline/components/task/index.tsx
@@ -78,6 +78,9 @@ export const PipelineTask = ({ task }: Props) => {
       case ['refdiff'].includes(config.plugin):
         name = `${name}:${options.repoId ?? options.projectName}`;
         break;
+      case ['bamboo'].includes(config.plugin):
+        name = `${name}:${options.planKey}`;
+        break;
     }
 
     return [config.icon, name];
diff --git a/config-ui/src/plugins/components/scope-config-form/index.tsx 
b/config-ui/src/plugins/components/scope-config-form/index.tsx
index 963310b58..019744e16 100644
--- a/config-ui/src/plugins/components/scope-config-form/index.tsx
+++ b/config-ui/src/plugins/components/scope-config-form/index.tsx
@@ -30,6 +30,7 @@ import { JenkinsTransformation } from 
'@/plugins/register/jenkins';
 import { BitbucketTransformation } from '@/plugins/register/bitbucket';
 import { AzureTransformation } from '@/plugins/register/azure';
 import { TapdTransformation } from '@/plugins/register/tapd';
+import { BambooTransformation } from '@/plugins/register/bamboo';
 import { operator } from '@/utils';
 
 import { AdditionalSettings } from './fields';
@@ -171,9 +172,9 @@ export const ScopeConfigForm = ({
       )}
       {step === 2 && (
         <>
-          <Card>
+          <Card style={{ margin: 0 }}>
             <h1 style={{ marginBottom: 16 }}>Transformations</h1>
-
+            <Divider />
             {showWarning && (
               <>
                 <Message content="Please note: if you only edit the following 
Scope Configs without editing Data Entities in the previous step, you will only 
need to re-transform data on the Project page to see the Dashboard updated." />
@@ -240,6 +241,14 @@ export const ScopeConfigForm = ({
               />
             )}
 
+            {plugin === 'bamboo' && (
+              <BambooTransformation
+                entities={entities}
+                transformation={transformation}
+                setTransformation={setTransformation}
+              />
+            )}
+
             {hasRefDiff && <AdditionalSettings transformation={transformation} 
setTransformation={setTransformation} />}
           </Card>
           <Buttons position="bottom" align="right">
diff --git a/config-ui/src/plugins/config.ts b/config-ui/src/plugins/config.ts
index a4a150beb..23860b275 100644
--- a/config-ui/src/plugins/config.ts
+++ b/config-ui/src/plugins/config.ts
@@ -18,6 +18,7 @@
 
 import type { PluginConfigType } from './types';
 import { AzureConfig } from './register/azure';
+import { BambooConfig } from './register/bamboo';
 import { BitBucketConfig } from './register/bitbucket';
 import { GitHubConfig } from './register/github';
 import { GitLabConfig } from './register/gitlab';
@@ -32,6 +33,7 @@ import { ZenTaoConfig } from './register/zentao';
 
 export const PluginConfig: PluginConfigType[] = [
   AzureConfig,
+  BambooConfig,
   BitBucketConfig,
   GitHubConfig,
   GitLabConfig,
diff --git a/config-ui/src/plugins/register/bamboo/assets/icon.svg 
b/config-ui/src/plugins/register/bamboo/assets/icon.svg
new file mode 100644
index 000000000..012dc1bc2
--- /dev/null
+++ b/config-ui/src/plugins/register/bamboo/assets/icon.svg
@@ -0,0 +1,39 @@
+<!--
+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="60" height="60" viewBox="0 0 60 60" fill="none" 
xmlns="http://www.w3.org/2000/svg";>
+  <path
+    d="M49.5895 15.9673C50.3704 16.6327 50.3704 17.839 49.5894 18.5045L33.2772 
32.4034C32.1951 33.3254 30.5296 32.5565 30.5296 31.1348L30.5296 3.33687C30.5296 
1.91525 32.1951 1.14626 33.2772 2.06826L49.5895 15.9673Z"
+    fill="#7497F7" />
+  <path
+    d="M27.3929 9.15651C22.2218 9.84207 17.3852 12.2096 13.6558 
15.9389C9.18064 20.4141 6.6665 26.4837 6.6665 32.8126L21.0005 32.8126C21.0005 
30.2853 22.0044 27.8616 23.7915 26.0746C25.5657 24.3003 27.9676 23.298 30.4752 
23.2837L27.3929 9.15651Z"
+    fill="#7497F7" />
+  <path
+    d="M30.5295 23.2836V8.94956C30.5295 8.94956 30.5295 8.94956 30.5295 
8.94956V23.2836C30.5295 23.2836 30.5295 23.2836 30.5295 23.2836Z"
+    fill="#7497F7" />
+  <path
+    d="M33.6295 56.4743C38.8017 55.7967 43.6419 53.4367 47.377 49.7131C51.4643 
45.6384 53.9228 40.2353 54.3317 34.5156C54.3973 33.5974 53.6462 32.8491 52.7257 
32.8476L41.7251 32.8306C40.8046 32.8292 40.0721 33.5799 39.9105 34.4861C39.5697 
36.397 38.6504 38.1727 37.257 39.5618C35.48 41.3333 33.0767 42.3319 30.5691 
42.3423L33.6295 56.4743Z"
+    fill="#7497F7" />
+  <path
+    d="M30.5147 42.3424L30.4926 56.6764C30.4926 56.6764 30.4926 56.6764 
30.4926 56.6764L30.5147 42.3424C30.5148 42.3424 30.5147 42.3424 30.5147 
42.3424Z"
+    fill="#7497F7" />
+  <path
+    d="M6.86094 35.853C7.5254 41.0266 9.873 45.8727 13.5869 49.6171C18.0437 
54.1106 24.103 56.6496 30.4318 56.6756L30.4906 42.3417C27.9633 42.3313 25.5437 
41.3174 23.764 39.5231C21.9972 37.7417 21.0047 35.3361 21.0006 32.8286L6.86094 
35.853Z"
+    fill="#7497F7" />
+  <path
+    d="M21.0006 32.7743L6.66676 32.7156C6.66676 32.7158 6.66677 32.7153 
6.66676 32.7156L21.0006 32.7743C21.0006 32.7741 21.0006 32.7746 21.0006 
32.7743Z"
+    fill="#7497F7" />
+</svg>
\ No newline at end of file
diff --git a/config-ui/src/plugins/register/bamboo/config.ts 
b/config-ui/src/plugins/register/bamboo/config.ts
new file mode 100644
index 000000000..f29a9a4a5
--- /dev/null
+++ b/config-ui/src/plugins/register/bamboo/config.ts
@@ -0,0 +1,62 @@
+/*
+ * 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 type { PluginConfigType } from '../../types';
+import { PluginType } from '../../types';
+
+import Icon from './assets/icon.svg';
+
+export const BambooConfig: PluginConfigType = {
+  type: PluginType.Connection,
+  plugin: 'bamboo',
+  name: 'Bamboo',
+  icon: Icon,
+  sort: 11,
+  connection: {
+    docLink: 'https://devlake.apache.org/docs/Configuration/Bamboo/',
+    fields: [
+      'name',
+      'endpoint',
+      'username',
+      'password',
+      'proxy',
+      {
+        key: 'rateLimitPerHour',
+        subLabel:
+          'By default, DevLake uses dynamic rate limit for optimized data 
collection for Bamboo. But you can adjust the collection speed by entering a 
fixed value. Please note: the rate limit setting applies to all tokens you have 
entered above.',
+        learnMore: 
'https://devlake.apache.org/docs/Configuration/Bamboo/#custom-rate-limit-optional',
+        externalInfo: 'Bamboo does not specify a maximum value of rate limit.',
+        defaultValue: 10000,
+      },
+    ],
+  },
+  dataScope: {
+    millerColumns: {
+      title: 'Add Repositories by Selecting from the Directory',
+      subTitle: 'The following directory lists out all repositories in your 
organizations.',
+      columnCount: 1,
+    },
+  },
+  scopeConfig: {
+    entities: ['CICD', 'CROSS'],
+    transformation: {
+      deploymentPattern: '',
+      productionPattern: '',
+    },
+  },
+};
diff --git a/config-ui/src/plugins/register/bamboo/index.ts 
b/config-ui/src/plugins/register/bamboo/index.ts
new file mode 100644
index 000000000..5f16858cb
--- /dev/null
+++ b/config-ui/src/plugins/register/bamboo/index.ts
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ *
+ */
+
+export * from './config';
+export * from './transformation';
diff --git a/config-ui/src/plugins/register/bamboo/styled.ts 
b/config-ui/src/plugins/register/bamboo/styled.ts
new file mode 100644
index 000000000..88bf19ae1
--- /dev/null
+++ b/config-ui/src/plugins/register/bamboo/styled.ts
@@ -0,0 +1,38 @@
+/*
+ * 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 styled from 'styled-components';
+
+export const Transformation = styled.div``;
+
+export const CICD = styled.div`
+  h3 {
+    margin-top: 16px;
+  }
+
+  .text,
+  .sub-text {
+    display: flex;
+    align-items: baseline;
+    margin-bottom: 8px;
+  }
+
+  .sub-text {
+    padding-left: 28px;
+  }
+`;
diff --git a/config-ui/src/plugins/register/bamboo/transformation.tsx 
b/config-ui/src/plugins/register/bamboo/transformation.tsx
new file mode 100644
index 000000000..e0de1cca1
--- /dev/null
+++ b/config-ui/src/plugins/register/bamboo/transformation.tsx
@@ -0,0 +1,121 @@
+/*
+ * 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 { useState, useEffect } from 'react';
+import { InputGroup, Tag, Intent, Checkbox } from '@blueprintjs/core';
+
+import { ExternalLink, HelpTooltip } from '@/components';
+
+import * as S from './styled';
+
+interface Props {
+  entities: string[];
+  transformation: any;
+  setTransformation: React.Dispatch<React.SetStateAction<any>>;
+}
+
+export const BambooTransformation = ({ entities, transformation, 
setTransformation }: Props) => {
+  const [useCustom, setUseCustom] = useState(false);
+
+  useEffect(() => {
+    if (transformation.deploymentPattern || transformation.productionPattern) {
+      setUseCustom(true);
+    } else {
+      setUseCustom(false);
+    }
+  }, [transformation]);
+
+  const handleChangeUseCustom = (e: React.FormEvent<HTMLInputElement>) => {
+    const checked = (e.target as HTMLInputElement).checked;
+
+    if (!checked) {
+      setTransformation({
+        ...transformation,
+        deploymentPattern: '',
+        productionPattern: '',
+      });
+    }
+
+    setUseCustom(checked);
+  };
+
+  return (
+    <S.Transformation>
+      {entities.includes('CICD') && (
+        <S.CICD>
+          <h2>CI/CD</h2>
+          <h3>
+            <span>Deployment</span>
+            <Tag minimal intent={Intent.PRIMARY} style={{ marginLeft: 8 }}>
+              DORA
+            </Tag>
+          </h3>
+          <p style={{ marginBottom: 16 }}>
+            Use Regular Expression to define Deployments in DevLake in order 
to measure DORA metrics.{' '}
+            <ExternalLink 
link="https://devlake.apache.org/docs/Configuration/Bamboo#step-3---adding-transformation-rules-optional";>
+              Learn more
+            </ExternalLink>
+          </p>
+          <div className="text">
+            <Checkbox disabled checked />
+            <span>Convert a Bamboo Deployment to a DevLake Deployment </span>
+          </div>
+          <div className="text">
+            <Checkbox checked={useCustom} onChange={handleChangeUseCustom} />
+            <span>
+              Convert a Bamboo Plan Build to a DevLake Deployment when its 
name or one of its job builds’ names
+            </span>
+          </div>
+          <div className="sub-text">
+            <span>matches</span>
+            <InputGroup
+              style={{ width: 180, margin: '0 8px' }}
+              placeholder="(deploy|push-image)"
+              value={transformation.deploymentPattern ?? ''}
+              onChange={(e) =>
+                setTransformation({
+                  ...transformation,
+                  deploymentPattern: e.target.value,
+                  productionPattern: !e.target.value ? '' : 
transformation.productionPattern,
+                })
+              }
+            />
+            <span>.</span>
+            <HelpTooltip content="View your BitBucket Pipelines: 
https://support.atlassian.com/bitbucket-cloud/docs/view-your-pipeline/"; />
+          </div>
+          <div className="sub-text">
+            <span>If the name also matches</span>
+            <InputGroup
+              style={{ width: 180, margin: '0 8px' }}
+              placeholder="prod(.*)"
+              value={transformation.productionPattern ?? ''}
+              onChange={(e) =>
+                setTransformation({
+                  ...transformation,
+                  productionPattern: e.target.value,
+                })
+              }
+            />
+            <span>, this Deployment is a ‘Production Deployment’</span>
+            <HelpTooltip content="If you leave this field empty, all 
Deployments will be tagged as in the Production environment. " />
+          </div>
+        </S.CICD>
+      )}
+    </S.Transformation>
+  );
+};
diff --git a/config-ui/src/plugins/utils.ts b/config-ui/src/plugins/utils.ts
index 69ca37ae8..37abe4575 100644
--- a/config-ui/src/plugins/utils.ts
+++ b/config-ui/src/plugins/utils.ts
@@ -35,6 +35,8 @@ export const getPluginScopeId = (plugin: string, scope: any) 
=> {
       return `${scope.bitbucketId}`;
     case 'sonarqube':
       return `${scope.projectKey}`;
+    case 'bamboo':
+      return `${scope.planKey}`;
     default:
       return `${scope.id}`;
   }

Reply via email to