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

abeizn 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 e794a198 fix(config-ui): adjust the parameters so the devlake can not 
execute DORA tasks
e794a198 is described below

commit e794a19809b3808025338335dc3a0b4f389b0425
Author: mintsweet <[email protected]>
AuthorDate: Mon Sep 26 14:47:16 2022 +0800

    fix(config-ui): adjust the parameters so the devlake can not execute DORA 
tasks
---
 .../create-workflow/DataTransformations.jsx        |  23 ++++-
 .../blueprints/transformations/CICD/Deployment.jsx | 101 ++++++++++-----------
 2 files changed, 67 insertions(+), 57 deletions(-)

diff --git 
a/config-ui/src/components/blueprints/create-workflow/DataTransformations.jsx 
b/config-ui/src/components/blueprints/create-workflow/DataTransformations.jsx
index 1c5e110d..14581368 100644
--- 
a/config-ui/src/components/blueprints/create-workflow/DataTransformations.jsx
+++ 
b/config-ui/src/components/blueprints/create-workflow/DataTransformations.jsx
@@ -22,6 +22,7 @@ import React, {
   useCallback,
   useMemo
 } from 'react'
+import { isEqual } from 'lodash'
 import {
   Button,
   Icon,
@@ -96,6 +97,13 @@ const DataTransformations = (props) => {
     cardStyle = {}
   } = props
 
+  // Used to determine whether to display edit transformation or add 
transformation
+  const [initializeTransformations, setInitializeTransformations] = 
useState({})
+
+  useEffect(() => {
+    setInitializeTransformations(transformations)
+  }, [])
+
   const isTransformationSupported = useMemo(
     () =>
       configuredProject ||
@@ -138,15 +146,20 @@ const DataTransformations = (props) => {
   )
   const [activeEntity, setActiveEntity] = useState()
 
-  const transformationHasProperties = useCallback(
+  const transformationHasChanged = useCallback(
     (item) => {
+      const initializeTransform = initializeTransformations[item?.id]
       const storedTransform = transformations[item?.id]
+
+      console.log(initializeTransform)
+      console.log(storedTransform)
       return (
+        initializeTransform &&
         storedTransform &&
-        Object.values(storedTransform).some((v) => v && v.length > 0)
+        !isEqual(initializeTransform, storedTransform)
       )
     },
-    [transformations]
+    [initializeTransformations, transformations]
   )
 
   useEffect(() => {
@@ -340,7 +353,7 @@ const DataTransformations = (props) => {
                           activeItem={configuredProject}
                           onAdd={addProjectTransformation}
                           onChange={addProjectTransformation}
-                          isEditing={transformationHasProperties}
+                          isEditing={transformationHasChanged}
                         />
                         {projects[configuredConnection.id].length === 0 && (
                           <NoData
@@ -365,7 +378,7 @@ const DataTransformations = (props) => {
                           activeItem={configuredBoard}
                           onAdd={addBoardTransformation}
                           onChange={addBoardTransformation}
-                          isEditing={transformationHasProperties}
+                          isEditing={transformationHasChanged}
                         />
                         {boards[configuredConnection.id].length === 0 && (
                           <NoData
diff --git 
a/config-ui/src/components/blueprints/transformations/CICD/Deployment.jsx 
b/config-ui/src/components/blueprints/transformations/CICD/Deployment.jsx
index 9ed180b6..5cd63743 100644
--- a/config-ui/src/components/blueprints/transformations/CICD/Deployment.jsx
+++ b/config-ui/src/components/blueprints/transformations/CICD/Deployment.jsx
@@ -40,17 +40,25 @@ const Deployment = (props) => {
   useEffect(() => {
     setSelectValue(
       transformation?.deploymentPattern ||
-        transformation?.deploymentPattern === ''
+        transformation?.deploymentPattern === '' ||
+        transformation?.productionPattern ||
+        transformation?.productionPattern === ''
         ? 1
         : 0
     )
-  }, [transformation?.deploymentPattern])
+  }, [transformation?.deploymentPattern, transformation?.productionPattern])
 
   const handleChangeSelectValue = (sv) => {
     if (entityIdKey && sv === 0) {
-      onSettingsChange({ deploymentPattern: undefined }, entityIdKey)
+      onSettingsChange(
+        { deploymentPattern: undefined, productionPattern: undefined },
+        entityIdKey
+      )
     } else if (entityIdKey && sv === 1) {
-      onSettingsChange({ deploymentPattern: '' }, entityIdKey)
+      onSettingsChange(
+        { deploymentPattern: '', productionPattern: '' },
+        entityIdKey
+      )
     }
     setSelectValue(sv)
   }
@@ -95,44 +103,6 @@ const Deployment = (props) => {
   return (
     <>
       <h5>CI/CD</h5>
-      <p style={{ color: '#292B3F' }}>
-        <strong>Environment Mapping</strong>{' '}
-        <Tag intent={Intent.PRIMARY} style={{ fontSize: '10px' }} minimal>
-          DORA
-        </Tag>
-      </p>
-      <p>
-        The environment that matches the given regEx is considered as the
-        Production environment. If you leave this field empty, all data will be
-        tagged as in the Production environment.
-      </p>
-      <FormGroup
-        disabled={isSaving}
-        inline={true}
-        label={
-          <label
-            className='bp3-label'
-            style={{ minWidth: '150px', marginRight: '10px' }}
-          >
-            Production
-          </label>
-        }
-        labelFor='production'
-        className='formGroup'
-        contentClassName='formGroupContent'
-      >
-        <InputGroup
-          id='deploy-tag-production'
-          placeholder='(?i)production'
-          value={transformation?.productionPattern}
-          onChange={(e) =>
-            onSettingsChange({ productionPattern: e.target.value }, 
entityIdKey)
-          }
-          disabled={isSaving}
-          className='input'
-          maxLength={255}
-        />
-      </FormGroup>
       <p style={{ color: '#292B3F' }}>
         <strong>What is a deployment?</strong>{' '}
         <Tag intent={Intent.PRIMARY} style={{ fontSize: '10px' }} minimal>
@@ -157,20 +127,12 @@ const Deployment = (props) => {
         />
         {selectValue === 1 && (
           <>
-            <div
-              className='bp3-form-helper-text'
-              style={{
-                display: 'block',
-                textAlign: 'left',
-                color: '#94959F',
-                marginBottom: '5px'
-              }}
-            >
+            <p>
               {getDeployTagHint(
                 provider?.id,
                 ProviderLabels[provider?.id?.toUpperCase()]
               )}
-            </div>
+            </p>
             <div className='formContainer'>
               <FormGroup
                 disabled={isSaving}
@@ -203,6 +165,41 @@ const Deployment = (props) => {
                 />
               </FormGroup>
             </div>
+            <p>
+              The environment that matches the given regEx is considered as the
+              Production environment. If you leave this field empty, all data
+              will be tagged as in the Production environment.
+            </p>
+            <FormGroup
+              disabled={isSaving}
+              inline={true}
+              label={
+                <label
+                  className='bp3-label'
+                  style={{ minWidth: '150px', marginRight: '10px' }}
+                >
+                  Production
+                </label>
+              }
+              labelFor='production'
+              className='formGroup'
+              contentClassName='formGroupContent'
+            >
+              <InputGroup
+                id='deploy-tag-production'
+                placeholder='(?i)production'
+                value={transformation?.productionPattern}
+                onChange={(e) =>
+                  onSettingsChange(
+                    { productionPattern: e.target.value },
+                    entityIdKey
+                  )
+                }
+                disabled={isSaving}
+                className='input'
+                maxLength={255}
+              />
+            </FormGroup>
           </>
         )}
         <Radio

Reply via email to