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


##########
config-ui/src/components/blueprints/create-workflow/DataTransformations.jsx:
##########
@@ -93,65 +78,35 @@ const DataTransformations = (props) => {
     () =>
       [Providers.TAPD].includes(configuredConnection?.provider) ||
       ([Providers.GITLAB].includes(configuredConnection?.provider) &&
-        dataEntities[configuredConnection?.id].every(
-          (e) => e.value !== DataEntityTypes.DEVOPS
+        dataDomainsGroup[configuredConnection?.id].every(
+          (e) => e.value !== DataDomainTypes.DEVOPS
         )),
     [
       configuredConnection?.provider,
       configuredConnection?.id,
-      dataEntities,
+      dataDomainsGroup,
       Providers.TAPD,
       Providers.GITLAB
     ]
   )
 
-  const boardsAndProjects = useMemo(
+  const scopeEntities = useMemo(
     () => [
-      ...(Array.isArray(boards[configuredConnection?.id])
-        ? boards[configuredConnection?.id]
-        : []),
-      ...(Array.isArray(projects[configuredConnection?.id])
-        ? projects[configuredConnection?.id]
+      ...(Array.isArray(scopeEntitiesGroup[configuredConnection?.id])
+        ? scopeEntitiesGroup[configuredConnection?.id]
         : [])
     ],
-    [projects, boards, configuredConnection?.id]
+    [scopeEntitiesGroup, configuredConnection?.id]
   )
 
-  const [entityList, setEntityList] = useState(
-    boardsAndProjects?.map((e, eIdx) => ({
-      id: eIdx,
-      value: e?.value,
-      title: e?.title,
-      entity: e,
-      type: e.variant
-    }))
-  )
-  const [activeEntity, setActiveEntity] = useState()
-
-  useEffect(() => {
-    console.log('>>> PROJECT/BOARD SELECT LIST DATA...', entityList)
-    setActiveEntity(Array.isArray(entityList) ? entityList[0] : null)
-  }, [entityList])
-
   useEffect(() => {
+    console.log('>>> SCOPE ENTITIES SELECT LIST DATA...', scopeEntities)
     if (useDropdownSelector) {
-      console.log('>>>>> PROJECT / BOARD ENTITY SELECTED!', activeEntity)
-      switch (activeEntity?.type) {
-        case Variants.BOARD:
-          addBoardTransformation(activeEntity?.entity)
-          break
-        case Variants.PROJECT:
-        default:
-          addProjectTransformation(activeEntity?.entity)
-          break
-      }
+      setConfiguredScopeEntity(
+        Array.isArray(scopeEntities) ? scopeEntities[0] : null

Review Comment:
   The original intent here was the dropdown selector should select the Active 
Scope entity being configured, if `scopeEntities[0]` is chosen here wouldn't 
this just select the first one in the list instead of the 
`activeEntity?.entity` ?



##########
config-ui/src/models/Entity.js:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ *
+ */
+
+/**
+ * @typedef {object} GitHubProject

Review Comment:
   ```suggestion
    * @typedef {object} Entity
   ```



##########
config-ui/src/components/blueprints/DataScopesGrid.jsx:
##########
@@ -144,39 +144,29 @@ const DataScopesGrid = (props) => {
                 whiteSpace: 'nowrap'
               }}
             >
-              {[Providers.GITLAB, Providers.GITHUB].includes(
-                c.provider?.id
-              ) && (
+              {[

Review Comment:
   Going forward we'll need to cleanup some of the Grouped Provider arrays to 
be more dynamic behavior in accordance with Plugin Registry. Can we perform a 
check like `entity?.getConfiguredEntityId() !== null` as a better means of 
determining whether we should list scope entities?
   
   Either that or another bool prop added to the base `Entity` Model, 
`hasScopeEntities (true|false)` that way we can  check this prop to determine 
UI features related to entities?



##########
config-ui/src/components/blueprints/create-workflow/DataScopes.jsx:
##########
@@ -67,22 +65,20 @@ const DataScopes = (props) => {
     cardStyle = {}
   } = props
 
-  const selectedBoards = useMemo(
-    () => boards[configuredConnection.id],
-    [boards, configuredConnection?.id]
+  const selectedScopeEntities = useMemo(
+    () => scopeEntitiesGroup[configuredConnection.id],
+    [scopeEntitiesGroup, configuredConnection?.id]
   )
-  const selectedProjects = useMemo(
-    () => projects[configuredConnection.id],
-    [projects, configuredConnection?.id]
-  )
-
-  useEffect(() => {
-    console.log('>> OVER HERE!!!', selectedBoards)
-  }, [selectedBoards])
 
-  useEffect(() => {
-    console.log('>> OVER HERE FOR Projects!!!', selectedProjects)
-  }, [selectedProjects])
+  const setScopeEntities = useCallback(
+    (scopeEntities) => {
+      setScopeEntitiesGroup((g) => ({
+        ...g,
+        [configuredConnection.id]: scopeEntities

Review Comment:
   @likyh Have you had a chance to review this scenario with regards to storing 
entities by Connection ID?



##########
config-ui/src/components/blueprints/create-workflow/DataScopes.jsx:
##########
@@ -67,22 +65,20 @@ const DataScopes = (props) => {
     cardStyle = {}
   } = props
 
-  const selectedBoards = useMemo(
-    () => boards[configuredConnection.id],
-    [boards, configuredConnection?.id]
+  const selectedScopeEntities = useMemo(
+    () => scopeEntitiesGroup[configuredConnection.id],
+    [scopeEntitiesGroup, configuredConnection?.id]
   )
-  const selectedProjects = useMemo(
-    () => projects[configuredConnection.id],
-    [projects, configuredConnection?.id]
-  )
-
-  useEffect(() => {
-    console.log('>> OVER HERE!!!', selectedBoards)
-  }, [selectedBoards])
 
-  useEffect(() => {
-    console.log('>> OVER HERE FOR Projects!!!', selectedProjects)
-  }, [selectedProjects])
+  const setScopeEntities = useCallback(
+    (scopeEntities) => {
+      setScopeEntitiesGroup((g) => ({
+        ...g,
+        [configuredConnection.id]: scopeEntities

Review Comment:
   @likyh Now that `projects` and `boards` and `jobs` all share the same map 
for **Scope Entities**, we can no longer key this by just `connection.id` 
alone. Consider the scenario where we have a new DevLake installation and user 
creates a multi-connection Blueprint. If the user Adds a New Data Connection 
for each Provider, they will all have a **Connection ID** of **1**. This will 
create an undesired scenario where Establishing entities for Connection A will 
be overwritten when entities for Connection B are configured, creating a bug.
   
   I think we need to re-key this with a similar generated key 
(`providerId`+`connectionId`) like the one used to store Transformations, and 
refactor all related references to use the generated key.



##########
config-ui/src/components/blueprints/ProviderTransformationSettings.jsx:
##########
@@ -45,24 +44,7 @@ const withTransformationSettings = (
   )
 
 const ProviderTransformationSettings = (props) => {
-  const {

Review Comment:
   @likyh These props are **not**  unused, do not remove them. These props are 
spread within the HOC on `Ln 69` (`...props`). Though not accessed directly at 
the moment, it's easier to see what props are being injected to each 
transformation settings component without having to look at where 
`<ProviderTransformationSettings>` is being implemented.



-- 
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