e2corporation commented on code in PR #3165:
URL: https://github.com/apache/incubator-devlake/pull/3165#discussion_r977673239


##########
config-ui/src/components/blueprints/transformations/CICD/Deployment.jsx:
##########
@@ -15,76 +15,45 @@
  * limitations under the License.
  *
  */
-import React, { useState, useEffect, useMemo, useCallback } from 'react'
+import React, { useState, useEffect } from 'react'
 import {
   Intent,
   FormGroup,
   RadioGroup,
   InputGroup,
   Radio,
-  Tag,
-  Icon,
-  Colors,
-  Tooltip
+  Tag
 } from '@blueprintjs/core'
 import { Providers, ProviderLabels } from '@/data/Providers'
+
 const Deployment = (props) => {
   const {
-    connection,
     provider,
     transformation,
-    configuredProject,
-    configuredBoard,
     entityIdKey,
-    entities = [],
     isSaving = false,
     onSettingsChange = () => {}
   } = props
 
-  const [deployTag, setDeployTag] = useState(
-    transformation?.productionPattern || ''
-  )
-  const [enableDeployTag, setEnableDeployTag] = useState(
-    [
-      transformation?.productionPattern
-      // transformation?.stagingPattern,
-      // transformation?.testingPattern
-    ].some((t) => t && t !== '')
-      ? 1
-      : 0
-  )
-  const isDeployTagEmpty = useMemo(
-    () =>
-      enableDeployTag &&
-      (transformation?.productionPattern === '' ||
-        !transformation?.productionPattern),
-    [enableDeployTag, transformation?.productionPattern]
-  )
+  const [selectValue, setSelectValue] = useState(1)
 
-  const clearDeploymentTags = useCallback(
-    (deploymentOption) => {
-      if (entityIdKey && deploymentOption === 0) {
-        onSettingsChange({ productionPattern: '' }, entityIdKey)
-        // onSettingsChange({ stagingPattern: '' }, entityIdKey)
-        // onSettingsChange({ testingPattern: '' }, entityIdKey)
-      }
-    },
-    [entityIdKey, onSettingsChange]
-  )
+  useEffect(() => {
+    setSelectValue(
+      transformation?.deploymentPattern ||
+        transformation?.deploymentPattern === ''
+        ? 1
+        : 0
+    )
+  }, [transformation?.deploymentPattern])
 
-  const handleDeploymentPreference = useCallback(
-    (deployOptionState) => {
-      setEnableDeployTag(deployOptionState)
-      switch (deployOptionState) {
-        case 0:
-          clearDeploymentTags(deployOptionState)
-          break
-        case 1:
-          break
-      }
-    },
-    [clearDeploymentTags]
-  )
+  const handleChangeSelectValue = (sv) => {
+    if (entityIdKey && sv === 0) {
+      onSettingsChange({ deploymentPattern: undefined }, entityIdKey)

Review Comment:
   `deploymentPattern` is a string field that is bound to the input, it should 
never be set or initialized to undefined.
   
   <img width="1186" alt="Screen Shot 2022-09-22 at 9 38 57 AM" 
src="https://user-images.githubusercontent.com/1742233/191763108-6e286139-bb0e-4858-8896-725e9855e556.png";>
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to