You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by GitBox <gi...@apache.org> on 2022/10/11 15:14:38 UTC

[GitHub] [incubator-devlake] likyh opened a new pull request, #3371: Issues/3328

likyh opened a new pull request, #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371

   # Summary
   
   <!--
   Thanks for submitting a pull request!
   
   We appreciate you spending the time to work on these changes.
   Please fill out as many sections below as possible.
   -->
   
   ### Does this close any open issues?
   Closes #3328 
   Closes #3365
   Closes #3364
   Closes #3357
   


-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] e2corporation commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
e2corporation commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r992523994


##########
config-ui/src/components/blueprints/create-workflow/DataTransformations.jsx:
##########
@@ -136,17 +109,47 @@ const DataTransformations = (props) => {
   )
   const [activeEntity, setActiveEntity] = useState()
 
-  const transformationHasChanged = useCallback(
+  const checkCurrentTransformationIsChanged = useCallback(

Review Comment:
   `Has` instead of `Is` would also read better.
   
   ```suggestion
     const checkCurrentTransformationHasChanged = useCallback(
   ```



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] likyh commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r992480920


##########
config-ui/src/hooks/useDataScopesManager.jsx:
##########
@@ -26,6 +26,7 @@ import GitlabProject from '@/models/GitlabProject'
 import { ProviderIcons, ProviderLabels, Providers } from '@/data/Providers'
 import { DataScopeModes } from '@/data/DataScopes'
 import JenkinsJob from '@/models/JenkinsJob'
+import useTransformationsManager from '@/hooks/data-scope/useTransformationsManager'

Review Comment:
   If a manager is too big, what are the alternatives here?



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] likyh commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r992516388


##########
config-ui/src/pages/blueprints/create-blueprint.jsx:
##########
@@ -904,57 +879,18 @@ const CreateBlueprint = (props) => {
     dataEntities,
     boards,
     projects,
-    transformations,
     validatePipeline,
     createProviderScopes,
     setBlueprintSettings
   ])
 
-  useEffect(() => {

Review Comment:
   https://github.com/apache/incubator-devlake/issues/3366
   It is duplicated in two places.



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] e2corporation commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
e2corporation commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r996527784


##########
config-ui/src/hooks/data-scope/useTransformationsManager.jsx:
##########
@@ -0,0 +1,236 @@
+/*
+ * 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 { useCallback, useState } from 'react'
+import { Providers } from '@/data/Providers'
+import TransformationSettings from '@/models/TransformationSettings'
+import { isEqual } from 'lodash'
+
+// TODO separate to each plugin
+const getDefaultTransformations = (provider) => {
+  let transforms = {}
+  switch (provider) {
+    case Providers.GITHUB:
+      transforms = {
+        prType: '',
+        prComponent: '',
+        prBodyClosePattern: '',
+        issueSeverity: '',
+        issueComponent: '',
+        issuePriority: '',
+        issueTypeRequirement: '',
+        issueTypeBug: '',
+        issueTypeIncident: '',
+        refdiff: null,
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.JIRA:
+      transforms = {
+        epicKeyField: '',
+        typeMappings: {},
+        storyPointField: '',
+        remotelinkCommitShaPattern: '',
+        bugTags: [],
+        incidentTags: [],
+        requirementTags: [],
+        // @todo: verify if jira utilizes deploy tag(s)?
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.JENKINS:
+      transforms = {
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.GITLAB:
+      transforms = {
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.TAPD:
+      // @todo: complete tapd transforms #2673
+      transforms = {
+        issueTypeRequirement: '',
+        issueTypeBug: '',
+        issueTypeIncident: '',
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+  }
+  return transforms
+}
+
+// manage transformations in one place
+const useTransformationsManager = () => {
+  const [transformations, setTransformations] = useState({})
+
+  const generateKey = (
+    connectionProvider,
+    connectionId,
+    projectNameOrBoard

Review Comment:
   ```suggestion
       entityId
   ```



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] e2corporation commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
e2corporation commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r992488504


##########
config-ui/src/hooks/data-scope/useTransformationsManager.jsx:
##########
@@ -0,0 +1,237 @@
+/*
+ * 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 { useCallback, useState } from 'react'
+import { Providers } from '@/data/Providers'
+import useDataScopesManager from '@/hooks/useDataScopesManager'
+import TransformationSettings from '@/models/TransformationSettings'
+import { isEqual } from 'lodash'
+
+// TODO separate to each plugin
+const getDefaultTransformations = (provider) => {
+  let transforms = {}
+  switch (provider) {
+    case Providers.GITHUB:
+      transforms = {
+        prType: '',
+        prComponent: '',
+        prBodyClosePattern: '',
+        issueSeverity: '',
+        issueComponent: '',
+        issuePriority: '',
+        issueTypeRequirement: '',
+        issueTypeBug: '',
+        issueTypeIncident: '',
+        refdiff: null,
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.JIRA:
+      transforms = {
+        epicKeyField: '',
+        typeMappings: {},
+        storyPointField: '',
+        remotelinkCommitShaPattern: '',
+        bugTags: [],
+        incidentTags: [],
+        requirementTags: [],
+        // @todo: verify if jira utilizes deploy tag(s)?
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.JENKINS:
+      transforms = {
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.GITLAB:
+      transforms = {
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.TAPD:
+      // @todo: complete tapd transforms #2673
+      transforms = {
+        issueTypeRequirement: '',
+        issueTypeBug: '',
+        issueTypeIncident: '',
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+  }
+  return transforms
+}
+
+// manage transformations in one place
+const useTransformationsManager = () => {
+  const [transformations, setTransformations] = useState({})
+
+  const generateKey = (
+    connectionProvider,
+    connectionId,
+    projectNameOrBoard
+  ) => {
+    let key = `not-distinguish`

Review Comment:
   What benefit do we have of having initial key default to `not-distinguish`? Why not default to Connection ID like I used previously? `C#[connId]` as a sane value to be used for providers like Jenkins which started with no project or entity concept?
   ```suggestion
       let key = `${connectionProvider}/${connectionId}`
   ```



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] e2corporation commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
e2corporation commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r992509058


##########
config-ui/src/pages/blueprints/create-blueprint.jsx:
##########
@@ -904,57 +879,18 @@ const CreateBlueprint = (props) => {
     dataEntities,
     boards,
     projects,
-    transformations,
     validatePipeline,
     createProviderScopes,
     setBlueprintSettings
   ])
 
-  useEffect(() => {

Review Comment:
   This logic should have already been commented out/removed at one point and replaced by the logic moved to the DSM Hook. Not sure why it's still intact.



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] e2corporation commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
e2corporation commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r996527592


##########
config-ui/src/hooks/data-scope/useTransformationsManager.jsx:
##########
@@ -0,0 +1,236 @@
+/*
+ * 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 { useCallback, useState } from 'react'
+import { Providers } from '@/data/Providers'
+import TransformationSettings from '@/models/TransformationSettings'
+import { isEqual } from 'lodash'
+
+// TODO separate to each plugin
+const getDefaultTransformations = (provider) => {
+  let transforms = {}
+  switch (provider) {
+    case Providers.GITHUB:
+      transforms = {
+        prType: '',
+        prComponent: '',
+        prBodyClosePattern: '',
+        issueSeverity: '',
+        issueComponent: '',
+        issuePriority: '',
+        issueTypeRequirement: '',
+        issueTypeBug: '',
+        issueTypeIncident: '',
+        refdiff: null,
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.JIRA:
+      transforms = {
+        epicKeyField: '',
+        typeMappings: {},
+        storyPointField: '',
+        remotelinkCommitShaPattern: '',
+        bugTags: [],
+        incidentTags: [],
+        requirementTags: [],
+        // @todo: verify if jira utilizes deploy tag(s)?
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.JENKINS:
+      transforms = {
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.GITLAB:
+      transforms = {
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.TAPD:
+      // @todo: complete tapd transforms #2673
+      transforms = {
+        issueTypeRequirement: '',
+        issueTypeBug: '',
+        issueTypeIncident: '',
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+  }
+  return transforms
+}
+
+// manage transformations in one place
+const useTransformationsManager = () => {
+  const [transformations, setTransformations] = useState({})
+
+  const generateKey = (
+    connectionProvider,
+    connectionId,
+    projectNameOrBoard
+  ) => {
+    let key = `not-distinguished`
+    switch (connectionProvider) {
+      case Providers.GITHUB:
+      case Providers.GITLAB:
+      case Providers.JENKINS:
+        key = projectNameOrBoard?.id
+        break
+      case Providers.JIRA:
+        key = projectNameOrBoard?.id
+        break
+    }
+    return `${connectionProvider}/${connectionId}/${key}`
+  }
+
+  // change some setting in specific connection's specific transformation
+  const changeTransformationSettings = useCallback(
+    (connectionProvider, connectionId, projectNameOrBoard, settings) => {
+      const key = generateKey(
+        connectionProvider,
+        connectionId,
+        projectNameOrBoard
+      )
+      console.info(
+        '>> SETTING TRANSFORMATION SETTINGS PROJECT/BOARD...',
+        key,
+        settings
+      )
+      setTransformations((existingTransformations) => ({
+        ...existingTransformations,
+        [key]: new TransformationSettings({
+          ...existingTransformations[key],
+          ...settings
+        })
+      }))
+    },
+    [setTransformations]
+  )
+
+  // set a default value for connection's specific transformation
+  const initializeDefaultTransformation = useCallback(
+    (connectionProvider, connectionId, projectNameOrBoard) => {
+      const key = generateKey(
+        connectionProvider,
+        connectionId,
+        projectNameOrBoard
+      )
+      console.info(
+        '>> INIT DEFAULT TRANSFORMATION SETTINGS PROJECT/BOARD...',
+        key
+      )
+      if (!transformations[key]) {
+        setTransformations((old) => ({
+          ...old,
+          [key]: new TransformationSettings(
+            getDefaultTransformations(connectionProvider)
+          )
+        }))
+      }
+    },
+    [setTransformations, transformations]
+  )
+
+  // get specific connection's specific transformation
+  const getTransformation = useCallback(
+    (connectionProvider, connectionId, projectNameOrBoard) => {

Review Comment:
   For accuracy with existing design and future compatibility for all entity types, I think this var `projectNameOrBoard` should be refactored to `entityId`
   
   ```suggestion
       (connectionProvider, connectionId, entityId) => {
   ```



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] likyh commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r992505499


##########
config-ui/src/hooks/useDataScopesManager.jsx:
##########
@@ -26,6 +26,7 @@ import GitlabProject from '@/models/GitlabProject'
 import { ProviderIcons, ProviderLabels, Providers } from '@/data/Providers'
 import { DataScopeModes } from '@/data/DataScopes'
 import JenkinsJob from '@/models/JenkinsJob'
+import useTransformationsManager from '@/hooks/data-scope/useTransformationsManager'

Review Comment:
   ![image](https://user-images.githubusercontent.com/3294100/195138785-b0177a96-d9f3-4685-befa-ee0b2db254c8.png)
   
   No. I think the hook is used like this.



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] e2corporation commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
e2corporation commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r992498810


##########
config-ui/src/hooks/useDataScopesManager.jsx:
##########
@@ -26,6 +26,7 @@ import GitlabProject from '@/models/GitlabProject'
 import { ProviderIcons, ProviderLabels, Providers } from '@/data/Providers'
 import { DataScopeModes } from '@/data/DataScopes'
 import JenkinsJob from '@/models/JenkinsJob'
+import useTransformationsManager from '@/hooks/data-scope/useTransformationsManager'

Review Comment:
   @likyh If you run `npm run lint` on your local dev env, does it come back with a Hook Violation Warning?



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] likyh commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r994535269


##########
config-ui/src/components/blueprints/create-workflow/DataTransformations.jsx:
##########
@@ -136,17 +109,47 @@ const DataTransformations = (props) => {
   )
   const [activeEntity, setActiveEntity] = useState()
 
-  const transformationHasChanged = useCallback(
+  const checkCurrentTransformationIsChanged = useCallback(
     (item) => {
-      const initializeTransform = initializeTransformations[item?.id]
-      const storedTransform = transformations[item?.id]
-      return (
-        initializeTransform &&
-        storedTransform &&
-        !isEqual(initializeTransform, storedTransform)
+      return checkTransformationIsChanged(
+        configuredConnection?.provider,
+        configuredConnection?.id,
+        item
       )
     },
-    [initializeTransformations, transformations]
+    [
+      configuredConnection?.provider,
+      configuredConnection?.id,
+      checkTransformationIsChanged
+    ]
+  )
+
+  const changeCurrentTransformationSettings = useCallback(
+    (settings) => {

Review Comment:
   fixed



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] likyh commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r992505499


##########
config-ui/src/hooks/useDataScopesManager.jsx:
##########
@@ -26,6 +26,7 @@ import GitlabProject from '@/models/GitlabProject'
 import { ProviderIcons, ProviderLabels, Providers } from '@/data/Providers'
 import { DataScopeModes } from '@/data/DataScopes'
 import JenkinsJob from '@/models/JenkinsJob'
+import useTransformationsManager from '@/hooks/data-scope/useTransformationsManager'

Review Comment:
   ![image](https://user-images.githubusercontent.com/3294100/195138785-b0177a96-d9f3-4685-befa-ee0b2db254c8.png)
   
   No. I think the hook is used maybe a good practice like `useRoute` or others.



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] e2corporation commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
e2corporation commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r992517746


##########
config-ui/src/components/blueprints/create-workflow/DataTransformations.jsx:
##########
@@ -136,17 +109,47 @@ const DataTransformations = (props) => {
   )
   const [activeEntity, setActiveEntity] = useState()
 
-  const transformationHasChanged = useCallback(
+  const checkCurrentTransformationIsChanged = useCallback(

Review Comment:
   Why wouldn't `checkCurrentTransformationIsChanged` and `changeCurrentTransformationSettings` be defined in the Transformation Manager?



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] e2corporation commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
e2corporation commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r996529984


##########
config-ui/src/hooks/useDataScopesManager.jsx:
##########
@@ -661,16 +525,46 @@ function useDataScopesManager({
     ]
   )
 
+  const checkConfiguredProjectTransformationHasChanged = useCallback(

Review Comment:
   ```suggestion
     const hasEntityTransformationChanged = useCallback(
   ```



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] e2corporation commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
e2corporation commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r996530094


##########
config-ui/src/hooks/useDataScopesManager.jsx:
##########
@@ -661,16 +525,46 @@ function useDataScopesManager({
     ]
   )
 
+  const checkConfiguredProjectTransformationHasChanged = useCallback(
+    (item) => {
+      return checkTransformationHasChanged(
+        configuredConnection?.provider,
+        configuredConnection?.id,
+        item
+      )
+    },
+    [
+      configuredConnection?.provider,
+      configuredConnection?.id,
+      checkTransformationHasChanged
+    ]
+  )
+
+  const changeConfiguredProjectTransformationSettings = useCallback(

Review Comment:
   ```suggestion
     const changeEntityTransformation = useCallback(
   ```



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] e2corporation commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
e2corporation commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r992480786


##########
config-ui/src/components/blueprints/transformations/CICD/Deployment.jsx:
##########
@@ -49,16 +48,13 @@ const Deployment = (props) => {
   }, [transformation?.deploymentPattern, transformation?.productionPattern])
 
   const handleChangeSelectValue = (sv) => {
-    if (entityIdKey && sv === 0) {
-      onSettingsChange(
-        { deploymentPattern: undefined, productionPattern: undefined },
-        entityIdKey
-      )
-    } else if (entityIdKey && sv === 1) {
-      onSettingsChange(
-        { deploymentPattern: '', productionPattern: '' },
-        entityIdKey
-      )
+    if (sv === 0) {
+      onSettingsChange({
+        deploymentPattern: undefined,

Review Comment:
   This practice of using `undefined` as a state value is not ideal and breaks principles of React **Controlled** Form Inputs. This area is what needs refactoring under this ticket https://github.com/apache/incubator-devlake/issues/3357



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] likyh commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r993004933


##########
config-ui/src/pages/blueprints/create-blueprint.jsx:
##########
@@ -904,57 +879,18 @@ const CreateBlueprint = (props) => {
     dataEntities,
     boards,
     projects,
-    transformations,
     validatePipeline,
     createProviderScopes,
     setBlueprintSettings
   ])
 
-  useEffect(() => {
-    console.log('>> PROJECTS LIST', projects)
-    console.log('>> BOARDS LIST', boards)
-
-    const projectTransformation = projects[configuredConnection?.id]?.map(
-      (p) => p.id
-    )
-    const boardTransformation = boards[configuredConnection?.id]?.map(
-      (b) => b.id
-    )
-    if (projectTransformation) {
-      setTransformations((cT) => ({
-        ...projectTransformation.reduce(initializeTransformations, {}),
-        // Spread Current/Existing Transformations Settings
-        ...cT
-      }))
-    }
-    if (boardTransformation) {
-      setTransformations((cT) => ({
-        ...boardTransformation.reduce(initializeTransformations, {}),
-        // Spread Current/Existing Transformations Settings
-        ...cT
-      }))
-    }
-  }, [
-    projects,
-    boards,
-    configuredConnection,
-    initializeTransformations,
-    setTransformations
-  ])
-
   useEffect(() => {
     console.log('>>> SELECTED PROJECT TO CONFIGURE...', configuredProject)
-    // setActiveTransformation((aT) =>
-    //   configuredProject !== null ? transformations[configuredProject] : {}
-    // )
     setCanAdvanceNext(!configuredProject)
   }, [configuredProject, setCanAdvanceNext])
 
   useEffect(() => {
-    console.log('>>> SELECTED BOARD TO CONFIGURE...', configuredBoard?.id)

Review Comment:
   It remains now. Just log the whole `configuredBoard` instead of `configuredBoard.id` now.



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] e2corporation commented on pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
e2corporation commented on PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#issuecomment-1280096532

   > I'll merge `project` and `board` next. (On another PR)
   
   `[projects, setProjects]` and `[boards, setBoards]` should be consolidated to `const [entities, setEntities] = useState([])`


-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] likyh commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r992505499


##########
config-ui/src/hooks/useDataScopesManager.jsx:
##########
@@ -26,6 +26,7 @@ import GitlabProject from '@/models/GitlabProject'
 import { ProviderIcons, ProviderLabels, Providers } from '@/data/Providers'
 import { DataScopeModes } from '@/data/DataScopes'
 import JenkinsJob from '@/models/JenkinsJob'
+import useTransformationsManager from '@/hooks/data-scope/useTransformationsManager'

Review Comment:
   ![image](https://user-images.githubusercontent.com/3294100/195138785-b0177a96-d9f3-4685-befa-ee0b2db254c8.png)
   
   No. 



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] likyh commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r994541454


##########
config-ui/src/components/blueprints/create-workflow/DataTransformations.jsx:
##########
@@ -136,17 +109,47 @@ const DataTransformations = (props) => {
   )
   const [activeEntity, setActiveEntity] = useState()
 
-  const transformationHasChanged = useCallback(
+  const checkCurrentTransformationIsChanged = useCallback(

Review Comment:
   moved



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] likyh commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r996562539


##########
config-ui/src/hooks/useDataScopesManager.jsx:
##########
@@ -661,16 +525,46 @@ function useDataScopesManager({
     ]
   )
 
+  const checkConfiguredProjectTransformationHasChanged = useCallback(

Review Comment:
   ok, `checkConfiguredProjectTransformationHasChanged ` => `hasConfiguredEntityTransformationChanged` will be changed on next PR.



##########
config-ui/src/hooks/useDataScopesManager.jsx:
##########
@@ -661,16 +525,46 @@ function useDataScopesManager({
     ]
   )
 
+  const checkConfiguredProjectTransformationHasChanged = useCallback(
+    (item) => {
+      return checkTransformationHasChanged(
+        configuredConnection?.provider,
+        configuredConnection?.id,
+        item
+      )
+    },
+    [
+      configuredConnection?.provider,
+      configuredConnection?.id,
+      checkTransformationHasChanged
+    ]
+  )
+
+  const changeConfiguredProjectTransformationSettings = useCallback(

Review Comment:
   ok, `changeConfiguredProjectTransformationSettings ` => `changeConfiguredEntityTransformation ` will be changed on next PR.



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] likyh commented on pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
likyh commented on PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#issuecomment-1280198593

   > @likyh In the screenshot above for the Jenkins Data Scope (init Jenkins connection), shouldn't the applicable Jenkins Jobs be displayed in the DataScope column?
   
   An issue was created and recorded it. https://github.com/apache/incubator-devlake/issues/3448


-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] e2corporation merged pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
e2corporation merged PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371


-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] e2corporation commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
e2corporation commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r992474151


##########
config-ui/src/hooks/useDataScopesManager.jsx:
##########
@@ -26,6 +26,7 @@ import GitlabProject from '@/models/GitlabProject'
 import { ProviderIcons, ProviderLabels, Providers } from '@/data/Providers'
 import { DataScopeModes } from '@/data/DataScopes'
 import JenkinsJob from '@/models/JenkinsJob'
+import useTransformationsManager from '@/hooks/data-scope/useTransformationsManager'

Review Comment:
   I have to double-check, but I think this breaks a core rule of Hook usage that Custom Hooks must not use other Custom Hooks. I may have to update our ESLint Rules to detect this.



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] likyh commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r993426797


##########
config-ui/src/pages/blueprints/create-blueprint.jsx:
##########
@@ -613,28 +607,10 @@ const CreateBlueprint = (props) => {
     setConnectionDialogIsOpen(true)
   }, [])
 
-  // @note: replaced by definition in dsm hook!
-  // const setTransformationSettings = useCallback(
-  //   (settings, configuredEntity) => {
-  //     console.log(
-  //       '>> SETTING TRANSFORMATION SETTINGS PROJECT/BOARD...',
-  //       configuredEntity,
-  //       settings
-  //     )
-  //     setTransformations((existingTransformations) => ({
-  //       ...existingTransformations,
-  //       [configuredEntity]: {
-  //         ...existingTransformations[configuredEntity],
-  //         ...settings,
-  //       },
-  //     }))
-  //   },
-  //   [setTransformations]
-  // )
-
   const handleTransformationSave = useCallback(
     (settings, entity) => {
       console.log('>> SAVING / CLOSING Transformation Settings')
+      // FIXME what's this???

Review Comment:
   ok, I'll delete these comment



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] likyh commented on pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
likyh commented on PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#issuecomment-1277490303

   I'll merge `project` and `board` next. (On another PR)


-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] e2corporation commented on pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
e2corporation commented on PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#issuecomment-1280150426

   @likyh In the screenshot above for the Jenkins Data Scope (init Jenkins connection), shouldn't the applicable Jenkins Jobs be displayed in the DataScope column?


-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] likyh commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r996386148


##########
config-ui/src/hooks/data-scope/useTransformationsManager.jsx:
##########
@@ -0,0 +1,237 @@
+/*
+ * 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 { useCallback, useState } from 'react'
+import { Providers } from '@/data/Providers'
+import useDataScopesManager from '@/hooks/useDataScopesManager'

Review Comment:
   fixed



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] e2corporation commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
e2corporation commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r992479115


##########
config-ui/src/hooks/data-scope/useTransformationsManager.jsx:
##########
@@ -0,0 +1,237 @@
+/*
+ * 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 { useCallback, useState } from 'react'
+import { Providers } from '@/data/Providers'
+import useDataScopesManager from '@/hooks/useDataScopesManager'
+import TransformationSettings from '@/models/TransformationSettings'
+import { isEqual } from 'lodash'
+
+// TODO separate to each plugin
+const getDefaultTransformations = (provider) => {
+  let transforms = {}
+  switch (provider) {
+    case Providers.GITHUB:
+      transforms = {
+        prType: '',
+        prComponent: '',
+        prBodyClosePattern: '',
+        issueSeverity: '',
+        issueComponent: '',
+        issuePriority: '',
+        issueTypeRequirement: '',
+        issueTypeBug: '',
+        issueTypeIncident: '',
+        refdiff: null,
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.JIRA:
+      transforms = {
+        epicKeyField: '',
+        typeMappings: {},
+        storyPointField: '',
+        remotelinkCommitShaPattern: '',
+        bugTags: [],
+        incidentTags: [],
+        requirementTags: [],
+        // @todo: verify if jira utilizes deploy tag(s)?
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.JENKINS:
+      transforms = {
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.GITLAB:
+      transforms = {
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.TAPD:
+      // @todo: complete tapd transforms #2673
+      transforms = {
+        issueTypeRequirement: '',
+        issueTypeBug: '',
+        issueTypeIncident: '',
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+  }
+  return transforms
+}
+
+// manage transformations in one place
+const useTransformationsManager = () => {
+  const [transformations, setTransformations] = useState({})
+
+  const generateKey = (
+    connectionProvider,
+    connectionId,
+    projectNameOrBoard
+  ) => {
+    let key = `not-distinguish`
+    switch (connectionProvider) {
+      case Providers.GITHUB:
+      case Providers.GITLAB:
+      case Providers.JENKINS:
+        key = projectNameOrBoard?.id
+        break
+      case Providers.JIRA:
+        key = projectNameOrBoard?.id
+        break
+    }
+    return `${connectionProvider}/${connectionId}/${key}`
+  }
+
+  // change some setting in specific connection's specific transformation
+  const changeTransformationSettings = useCallback(
+    (connectionProvider, connectionId, projectNameOrBoard, settings) => {
+      const key = generateKey(
+        connectionProvider,
+        connectionId,
+        projectNameOrBoard
+      )
+      console.info(
+        '>> SETTING TRANSFORMATION SETTINGS PROJECT/BOARD...',
+        key,
+        settings
+      )
+      setTransformations((existingTransformations) => ({
+        ...existingTransformations,
+        [key]: new TransformationSettings({
+          ...existingTransformations[key],
+          ...settings
+        })
+      }))
+    },
+    [setTransformations]
+  )
+
+  // set a default value for connection's specific transformation
+  const initializeDefaultTransformationSettingsIfNotExist = useCallback(

Review Comment:
   I think this method name is a bit too verbose, it should be implied that settings are initialized if they don't exist (keyword `initialize` would imply this)
   ```suggestion
     const initializeDefaultTransformations = useCallback(
   ```



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] e2corporation commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
e2corporation commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r992513032


##########
config-ui/src/hooks/data-scope/useTransformationsManager.jsx:
##########
@@ -0,0 +1,237 @@
+/*
+ * 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 { useCallback, useState } from 'react'
+import { Providers } from '@/data/Providers'
+import useDataScopesManager from '@/hooks/useDataScopesManager'
+import TransformationSettings from '@/models/TransformationSettings'
+import { isEqual } from 'lodash'
+
+// TODO separate to each plugin
+const getDefaultTransformations = (provider) => {
+  let transforms = {}
+  switch (provider) {
+    case Providers.GITHUB:
+      transforms = {
+        prType: '',
+        prComponent: '',
+        prBodyClosePattern: '',
+        issueSeverity: '',
+        issueComponent: '',
+        issuePriority: '',
+        issueTypeRequirement: '',
+        issueTypeBug: '',
+        issueTypeIncident: '',
+        refdiff: null,
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.JIRA:
+      transforms = {
+        epicKeyField: '',
+        typeMappings: {},
+        storyPointField: '',
+        remotelinkCommitShaPattern: '',
+        bugTags: [],
+        incidentTags: [],
+        requirementTags: [],
+        // @todo: verify if jira utilizes deploy tag(s)?
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.JENKINS:
+      transforms = {
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.GITLAB:
+      transforms = {
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.TAPD:
+      // @todo: complete tapd transforms #2673
+      transforms = {
+        issueTypeRequirement: '',
+        issueTypeBug: '',
+        issueTypeIncident: '',
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+  }
+  return transforms
+}
+
+// manage transformations in one place
+const useTransformationsManager = () => {
+  const [transformations, setTransformations] = useState({})
+
+  const generateKey = (
+    connectionProvider,
+    connectionId,
+    projectNameOrBoard
+  ) => {
+    let key = `not-distinguish`

Review Comment:
   Ok, as a grammatical suggestion `not-distinguished` in past tense may read a bit better.



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] e2corporation commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
e2corporation commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r992506738


##########
config-ui/src/pages/blueprints/create-blueprint.jsx:
##########
@@ -613,28 +607,10 @@ const CreateBlueprint = (props) => {
     setConnectionDialogIsOpen(true)
   }, [])
 
-  // @note: replaced by definition in dsm hook!
-  // const setTransformationSettings = useCallback(
-  //   (settings, configuredEntity) => {
-  //     console.log(
-  //       '>> SETTING TRANSFORMATION SETTINGS PROJECT/BOARD...',
-  //       configuredEntity,
-  //       settings
-  //     )
-  //     setTransformations((existingTransformations) => ({
-  //       ...existingTransformations,
-  //       [configuredEntity]: {
-  //         ...existingTransformations[configuredEntity],
-  //         ...settings,
-  //       },
-  //     }))
-  //   },
-  //   [setTransformations]
-  // )
-
   const handleTransformationSave = useCallback(
     (settings, entity) => {
       console.log('>> SAVING / CLOSING Transformation Settings')
+      // FIXME what's this???

Review Comment:
   There's nothing to `Fix` here, this is a comment/reminder to indicate that at one point UI requirements wanted a **Save** Button, which means that we only write new transformations when save is clicked, however existing form controls are reactive so transformations are written/stored when **typed**.



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] e2corporation commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
e2corporation commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r992528294


##########
config-ui/src/components/blueprints/create-workflow/DataTransformations.jsx:
##########
@@ -136,17 +109,47 @@ const DataTransformations = (props) => {
   )
   const [activeEntity, setActiveEntity] = useState()
 
-  const transformationHasChanged = useCallback(
+  const checkCurrentTransformationIsChanged = useCallback(
     (item) => {
-      const initializeTransform = initializeTransformations[item?.id]
-      const storedTransform = transformations[item?.id]
-      return (
-        initializeTransform &&
-        storedTransform &&
-        !isEqual(initializeTransform, storedTransform)
+      return checkTransformationIsChanged(
+        configuredConnection?.provider,
+        configuredConnection?.id,
+        item
       )
     },
-    [initializeTransformations, transformations]
+    [
+      configuredConnection?.provider,
+      configuredConnection?.id,
+      checkTransformationIsChanged
+    ]
+  )
+
+  const changeCurrentTransformationSettings = useCallback(
+    (settings) => {

Review Comment:
   Is looks like we assume Board, then default to Project. It possible to make this more declarative?
   
   ```suggestion
       (settings) => {
           console.log(configuredBoard || configuredProject)
           return changeTransformationSettings(
             configuredConnection?.provider,
             configuredConnection?.id,
             configuredBoard || configuredProject,
             settings
           )
        }
   ```



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] likyh commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r992525204


##########
config-ui/src/components/blueprints/create-workflow/DataTransformations.jsx:
##########
@@ -136,17 +109,47 @@ const DataTransformations = (props) => {
   )
   const [activeEntity, setActiveEntity] = useState()
 
-  const transformationHasChanged = useCallback(
+  const checkCurrentTransformationIsChanged = useCallback(

Review Comment:
   All are acceptable. I write it here because write related code in small scope instead of passing it through many levels. If you insist, I'll move it into hook.



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] likyh commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r996557583


##########
config-ui/src/hooks/data-scope/useTransformationsManager.jsx:
##########
@@ -0,0 +1,236 @@
+/*
+ * 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 { useCallback, useState } from 'react'
+import { Providers } from '@/data/Providers'
+import TransformationSettings from '@/models/TransformationSettings'
+import { isEqual } from 'lodash'
+
+// TODO separate to each plugin
+const getDefaultTransformations = (provider) => {
+  let transforms = {}
+  switch (provider) {
+    case Providers.GITHUB:
+      transforms = {
+        prType: '',
+        prComponent: '',
+        prBodyClosePattern: '',
+        issueSeverity: '',
+        issueComponent: '',
+        issuePriority: '',
+        issueTypeRequirement: '',
+        issueTypeBug: '',
+        issueTypeIncident: '',
+        refdiff: null,
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.JIRA:
+      transforms = {
+        epicKeyField: '',
+        typeMappings: {},
+        storyPointField: '',
+        remotelinkCommitShaPattern: '',
+        bugTags: [],
+        incidentTags: [],
+        requirementTags: [],
+        // @todo: verify if jira utilizes deploy tag(s)?
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.JENKINS:
+      transforms = {
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.GITLAB:
+      transforms = {
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.TAPD:
+      // @todo: complete tapd transforms #2673
+      transforms = {
+        issueTypeRequirement: '',
+        issueTypeBug: '',
+        issueTypeIncident: '',
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+  }
+  return transforms
+}
+
+// manage transformations in one place
+const useTransformationsManager = () => {
+  const [transformations, setTransformations] = useState({})
+
+  const generateKey = (
+    connectionProvider,
+    connectionId,
+    projectNameOrBoard
+  ) => {
+    let key = `not-distinguished`
+    switch (connectionProvider) {
+      case Providers.GITHUB:
+      case Providers.GITLAB:
+      case Providers.JENKINS:
+        key = projectNameOrBoard?.id
+        break
+      case Providers.JIRA:
+        key = projectNameOrBoard?.id
+        break
+    }
+    return `${connectionProvider}/${connectionId}/${key}`
+  }
+
+  // change some setting in specific connection's specific transformation
+  const changeTransformationSettings = useCallback(
+    (connectionProvider, connectionId, projectNameOrBoard, settings) => {
+      const key = generateKey(
+        connectionProvider,
+        connectionId,
+        projectNameOrBoard
+      )
+      console.info(
+        '>> SETTING TRANSFORMATION SETTINGS PROJECT/BOARD...',
+        key,
+        settings
+      )
+      setTransformations((existingTransformations) => ({
+        ...existingTransformations,
+        [key]: new TransformationSettings({
+          ...existingTransformations[key],
+          ...settings
+        })
+      }))
+    },
+    [setTransformations]
+  )
+
+  // set a default value for connection's specific transformation
+  const initializeDefaultTransformation = useCallback(
+    (connectionProvider, connectionId, projectNameOrBoard) => {
+      const key = generateKey(
+        connectionProvider,
+        connectionId,
+        projectNameOrBoard
+      )
+      console.info(
+        '>> INIT DEFAULT TRANSFORMATION SETTINGS PROJECT/BOARD...',
+        key
+      )
+      if (!transformations[key]) {
+        setTransformations((old) => ({
+          ...old,
+          [key]: new TransformationSettings(
+            getDefaultTransformations(connectionProvider)
+          )
+        }))
+      }
+    },
+    [setTransformations, transformations]
+  )
+
+  // get specific connection's specific transformation
+  const getTransformation = useCallback(
+    (connectionProvider, connectionId, projectNameOrBoard) => {

Review Comment:
   ok, `projectNameOrBoard` => `entityId` or `entity` will change on next PR.



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] e2corporation commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
e2corporation commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r996339235


##########
config-ui/src/hooks/data-scope/useTransformationsManager.jsx:
##########
@@ -0,0 +1,237 @@
+/*
+ * 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 { useCallback, useState } from 'react'
+import { Providers } from '@/data/Providers'
+import useDataScopesManager from '@/hooks/useDataScopesManager'

Review Comment:
   `useTransformationsManager` doesn't appear to be initializing the DSM Hook (`useDataScopesManager`), it should removed from import here. If there is a dependency to DSM Hook, this hook should receive it as a prop after DSM Hook is initialized.



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] likyh commented on pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
likyh commented on PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#issuecomment-1277471565

   ![image](https://user-images.githubusercontent.com/3294100/195584327-07aaf58f-85c4-40f3-a35d-f528741142e4.png)
   I test them, they are same. So I use `transformation?.xxxxTags` to replace them.
   
   
   Now #3294 and #3295 fix.
   ![image](https://user-images.githubusercontent.com/3294100/195586063-f7b96d45-72fd-4157-8806-c980ac1f9fbb.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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] e2corporation commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
e2corporation commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r992483465


##########
config-ui/src/hooks/useDataScopesManager.jsx:
##########
@@ -26,6 +26,7 @@ import GitlabProject from '@/models/GitlabProject'
 import { ProviderIcons, ProviderLabels, Providers } from '@/data/Providers'
 import { DataScopeModes } from '@/data/DataScopes'
 import JenkinsJob from '@/models/JenkinsJob'
+import useTransformationsManager from '@/hooks/data-scope/useTransformationsManager'

Review Comment:
   The reason I placed transformation logic in the DSM Hook is because DataScopes are at the highest level and encompasses transformation Logic. The other alternative is to make the Transformation Manager a non-react pure JS Utility with logic ported to accomplish the same goals (under `utils/`).
   
   Wait till I verify that this is truly a Hook violation first before refactoring again.



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] likyh commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r992481625


##########
config-ui/src/components/blueprints/transformations/CICD/Deployment.jsx:
##########
@@ -49,16 +48,13 @@ const Deployment = (props) => {
   }, [transformation?.deploymentPattern, transformation?.productionPattern])
 
   const handleChangeSelectValue = (sv) => {
-    if (entityIdKey && sv === 0) {
-      onSettingsChange(
-        { deploymentPattern: undefined, productionPattern: undefined },
-        entityIdKey
-      )
-    } else if (entityIdKey && sv === 1) {
-      onSettingsChange(
-        { deploymentPattern: '', productionPattern: '' },
-        entityIdKey
-      )
+    if (sv === 0) {
+      onSettingsChange({
+        deploymentPattern: undefined,

Review Comment:
   That is another issue I haven't fixed. It will fix on another PR.



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] likyh commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r992502273


##########
config-ui/src/hooks/data-scope/useTransformationsManager.jsx:
##########
@@ -0,0 +1,237 @@
+/*
+ * 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 { useCallback, useState } from 'react'
+import { Providers } from '@/data/Providers'
+import useDataScopesManager from '@/hooks/useDataScopesManager'
+import TransformationSettings from '@/models/TransformationSettings'
+import { isEqual } from 'lodash'
+
+// TODO separate to each plugin
+const getDefaultTransformations = (provider) => {
+  let transforms = {}
+  switch (provider) {
+    case Providers.GITHUB:
+      transforms = {
+        prType: '',
+        prComponent: '',
+        prBodyClosePattern: '',
+        issueSeverity: '',
+        issueComponent: '',
+        issuePriority: '',
+        issueTypeRequirement: '',
+        issueTypeBug: '',
+        issueTypeIncident: '',
+        refdiff: null,
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.JIRA:
+      transforms = {
+        epicKeyField: '',
+        typeMappings: {},
+        storyPointField: '',
+        remotelinkCommitShaPattern: '',
+        bugTags: [],
+        incidentTags: [],
+        requirementTags: [],
+        // @todo: verify if jira utilizes deploy tag(s)?
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.JENKINS:
+      transforms = {
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.GITLAB:
+      transforms = {
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.TAPD:
+      // @todo: complete tapd transforms #2673
+      transforms = {
+        issueTypeRequirement: '',
+        issueTypeBug: '',
+        issueTypeIncident: '',
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+  }
+  return transforms
+}
+
+// manage transformations in one place
+const useTransformationsManager = () => {
+  const [transformations, setTransformations] = useState({})
+
+  const generateKey = (
+    connectionProvider,
+    connectionId,
+    projectNameOrBoard
+  ) => {
+    let key = `not-distinguish`

Review Comment:
   Now key will be `${connectionProvider}/${connectionId}/not-distinguish`. That will be more readable when the new developer adds another plugin next time but forgets to distinguish `connectionId`. He will find here move easily.



##########
config-ui/src/hooks/data-scope/useTransformationsManager.jsx:
##########
@@ -0,0 +1,237 @@
+/*
+ * 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 { useCallback, useState } from 'react'
+import { Providers } from '@/data/Providers'
+import useDataScopesManager from '@/hooks/useDataScopesManager'
+import TransformationSettings from '@/models/TransformationSettings'
+import { isEqual } from 'lodash'
+
+// TODO separate to each plugin
+const getDefaultTransformations = (provider) => {
+  let transforms = {}
+  switch (provider) {
+    case Providers.GITHUB:
+      transforms = {
+        prType: '',
+        prComponent: '',
+        prBodyClosePattern: '',
+        issueSeverity: '',
+        issueComponent: '',
+        issuePriority: '',
+        issueTypeRequirement: '',
+        issueTypeBug: '',
+        issueTypeIncident: '',
+        refdiff: null,
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.JIRA:
+      transforms = {
+        epicKeyField: '',
+        typeMappings: {},
+        storyPointField: '',
+        remotelinkCommitShaPattern: '',
+        bugTags: [],
+        incidentTags: [],
+        requirementTags: [],
+        // @todo: verify if jira utilizes deploy tag(s)?
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.JENKINS:
+      transforms = {
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.GITLAB:
+      transforms = {
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+    case Providers.TAPD:
+      // @todo: complete tapd transforms #2673
+      transforms = {
+        issueTypeRequirement: '',
+        issueTypeBug: '',
+        issueTypeIncident: '',
+        productionPattern: '',
+        deploymentPattern: ''
+        // stagingPattern: '',
+        // testingPattern: ''
+      }
+      break
+  }
+  return transforms
+}
+
+// manage transformations in one place
+const useTransformationsManager = () => {
+  const [transformations, setTransformations] = useState({})
+
+  const generateKey = (
+    connectionProvider,
+    connectionId,
+    projectNameOrBoard
+  ) => {
+    let key = `not-distinguish`
+    switch (connectionProvider) {
+      case Providers.GITHUB:
+      case Providers.GITLAB:
+      case Providers.JENKINS:
+        key = projectNameOrBoard?.id
+        break
+      case Providers.JIRA:
+        key = projectNameOrBoard?.id
+        break
+    }
+    return `${connectionProvider}/${connectionId}/${key}`
+  }
+
+  // change some setting in specific connection's specific transformation
+  const changeTransformationSettings = useCallback(
+    (connectionProvider, connectionId, projectNameOrBoard, settings) => {
+      const key = generateKey(
+        connectionProvider,
+        connectionId,
+        projectNameOrBoard
+      )
+      console.info(
+        '>> SETTING TRANSFORMATION SETTINGS PROJECT/BOARD...',
+        key,
+        settings
+      )
+      setTransformations((existingTransformations) => ({
+        ...existingTransformations,
+        [key]: new TransformationSettings({
+          ...existingTransformations[key],
+          ...settings
+        })
+      }))
+    },
+    [setTransformations]
+  )
+
+  // set a default value for connection's specific transformation
+  const initializeDefaultTransformationSettingsIfNotExist = useCallback(

Review Comment:
   fixed



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] e2corporation commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
e2corporation commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r992531183


##########
config-ui/src/components/blueprints/create-workflow/DataTransformations.jsx:
##########
@@ -136,17 +109,47 @@ const DataTransformations = (props) => {
   )
   const [activeEntity, setActiveEntity] = useState()
 
-  const transformationHasChanged = useCallback(
+  const checkCurrentTransformationIsChanged = useCallback(

Review Comment:
   Yea I think these are key functions of the DSM / Transformation Manager. It would be better encapsulated in the Hook for consistency. We'll try to adapt some Contexts in the future to possibly help with our nested props being passed to many levels.



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] e2corporation commented on a diff in pull request #3371: add transformations hook to write all logic about it in one file.

Posted by GitBox <gi...@apache.org>.
e2corporation commented on code in PR #3371:
URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r993001758


##########
config-ui/src/pages/blueprints/create-blueprint.jsx:
##########
@@ -904,57 +879,18 @@ const CreateBlueprint = (props) => {
     dataEntities,
     boards,
     projects,
-    transformations,
     validatePipeline,
     createProviderScopes,
     setBlueprintSettings
   ])
 
-  useEffect(() => {
-    console.log('>> PROJECTS LIST', projects)
-    console.log('>> BOARDS LIST', boards)
-
-    const projectTransformation = projects[configuredConnection?.id]?.map(
-      (p) => p.id
-    )
-    const boardTransformation = boards[configuredConnection?.id]?.map(
-      (b) => b.id
-    )
-    if (projectTransformation) {
-      setTransformations((cT) => ({
-        ...projectTransformation.reduce(initializeTransformations, {}),
-        // Spread Current/Existing Transformations Settings
-        ...cT
-      }))
-    }
-    if (boardTransformation) {
-      setTransformations((cT) => ({
-        ...boardTransformation.reduce(initializeTransformations, {}),
-        // Spread Current/Existing Transformations Settings
-        ...cT
-      }))
-    }
-  }, [
-    projects,
-    boards,
-    configuredConnection,
-    initializeTransformations,
-    setTransformations
-  ])
-
   useEffect(() => {
     console.log('>>> SELECTED PROJECT TO CONFIGURE...', configuredProject)
-    // setActiveTransformation((aT) =>
-    //   configuredProject !== null ? transformations[configuredProject] : {}
-    // )
     setCanAdvanceNext(!configuredProject)
   }, [configuredProject, setCanAdvanceNext])
 
   useEffect(() => {
-    console.log('>>> SELECTED BOARD TO CONFIGURE...', configuredBoard?.id)

Review Comment:
   This log entry can remain for debugging



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org