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/08/30 23:02:22 UTC

[GitHub] [incubator-devlake] e2corporation opened a new pull request, #2886: feat: setup configuration-ui plugin registry

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

   ### ⚠️ Config-UI / Plugin Registry
   > WIP DO NOT MERGE
   
   - [ ] Create a Defined Plugin Registration Schema (JSON Registration Files)
   - [ ] Create Local Plugin Registry Configuration
      - [ ] JIRA
      - [ ] GitLab
      - [ ] GitHub
      - [ ] Jenkins
      - [ ] TAPD
      - [ ] AE
      - [ ] DBT
      - [ ] StarRocks
      - [ ] RefDiff
   - [ ] Implement `useIntegrations` Hook
   - [ ] Create Dynamic / Live Plugin Registry (Allow Plugins to load via API)
   - [ ] Create Basic Documentation for Plugin JSON Registration
   - [ ] Refactor Integrations Data Dependencies
   
   ### Description
   
   This PR creates a **Plugin Registry** on **Configuration-UI** as outlined on #2882.
   
   ### Local Plugin Registry
   
   ### API Plugin Registry
   
   ### Plugin Registration Schema (JSON)
   
   ### Does this close any open issues?
   #2882
   
   ### Screenshots
   `[<PENDING>]`
   


-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/components/Sidebar.jsx:
##########
@@ -29,35 +35,46 @@ import { ReactComponent as Logo } from '@/images/devlake-logo.svg'
 import { ReactComponent as LogoText } from '@/images/devlake-textmark.svg'
 
 import '@/styles/sidebar.scss'
-import UIContext from '../store/UIContext'
+import UIContext from '@/store/UIContext'
 
-const Sidebar = () => {
+const Sidebar = (props) => {
+  const { integrations = [] } = props
   const activeRoute = useRouteMatch()
   const uiContext = useContext(UIContext)
 
-  const [menu, setMenu] = useState(MenuConfiguration(activeRoute))
+  const getMenu = useCallback(
+    () => MenuConfiguration(activeRoute, integrations),
+    [activeRoute, integrations]
+  )
+
+  const ActiveMenu = useMemo(() => getMenu(), [getMenu])
+
+  const [menu, setMenu] = useState(ActiveMenu)
   const [versionTag, setVersionTag] = useState('')
 
-  useEffect(() => {
-    setMenu(MenuConfiguration(activeRoute))
-  }, [activeRoute])
+  // useEffect(() => {
+  //   setMenu(ActiveMenu)
+  // }, [ActiveMenu])
 
   useEffect(() => {
-    const fetchVersion = async () => {
-      try {
-        const versionUrl = `${DEVLAKE_ENDPOINT}/version`

Review Comment:
   this API has been deleted? @klesh 



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/components/Sidebar.jsx:
##########
@@ -29,35 +35,46 @@ import { ReactComponent as Logo } from '@/images/devlake-logo.svg'
 import { ReactComponent as LogoText } from '@/images/devlake-textmark.svg'
 
 import '@/styles/sidebar.scss'
-import UIContext from '../store/UIContext'
+import UIContext from '@/store/UIContext'
 
-const Sidebar = () => {
+const Sidebar = (props) => {
+  const { integrations = [] } = props
   const activeRoute = useRouteMatch()
   const uiContext = useContext(UIContext)
 
-  const [menu, setMenu] = useState(MenuConfiguration(activeRoute))
+  const getMenu = useCallback(
+    () => MenuConfiguration(activeRoute, integrations),
+    [activeRoute, integrations]
+  )
+
+  const ActiveMenu = useMemo(() => getMenu(), [getMenu])
+
+  const [menu, setMenu] = useState(ActiveMenu)
   const [versionTag, setVersionTag] = useState('')
 
-  useEffect(() => {
-    setMenu(MenuConfiguration(activeRoute))
-  }, [activeRoute])
+  // useEffect(() => {
+  //   setMenu(ActiveMenu)
+  // }, [ActiveMenu])
 
   useEffect(() => {
-    const fetchVersion = async () => {
-      try {
-        const versionUrl = `${DEVLAKE_ENDPOINT}/version`
-        const res = await request.get(versionUrl).catch((e) => {
-          console.log('>>> API VERSION ERROR...', e)
-          setVersionTag('')
-        })
-        setVersionTag(res?.data ? res.data?.version : '')
-      } catch (e) {
-        setVersionTag('')
-      }
-    }
-    fetchVersion()
+    // @todo: re-enable version fetch
+    // const fetchVersion = async () => {
+    //   try {
+    //     const versionUrl = `${DEVLAKE_ENDPOINT}/version`
+    //     const res = await request.get(versionUrl).catch((e) => {
+    //       console.log('>>> API VERSION ERROR...', e)
+    //       setVersionTag('')
+    //     })
+    //     setVersionTag(res?.data ? res.data?.version : '')
+    //   } catch (e) {
+    //     setVersionTag('')
+    //   }
+    // }
+    // fetchVersion()
   }, [])
 
+  // useEffect(() => {}, [integrations])

Review Comment:
   Commented code will be removed in a future cleanup.



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/pages/configure/settings/tapd.jsx:
##########
@@ -24,6 +24,8 @@ import '@/styles/connections.scss'
 
 export default function TapdSettings(props) {
   const {
+    Providers,

Review Comment:
   TAPD settings needs to be implemented, having unused imports here is not a problem for 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 #2886: feat: setup configuration-ui plugin registry

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

   @likyh @tk103331 I'll be making more commits as I continue ideating on the Plugin Registry concept. In the mean time, I'm fine with both of you contributing thoughts & ideas to this effort, that are hopefully inline with this strategy.
   
   @tk103331 Feel free to comment on more suggestions/questions or issues for the Plugin Schema as it's being developed, some option configurations can be for a future need as well. The important thing is to get an essential schema for the short-term without overcomplicating it. You will also be able to add commits if you are wanting to contribute.
   
   @likyh When I'm done with a few more commits, I'll tag you to adapt some of your valid refactor changes from your closed PR, such as the Dynamic Menu from new **$Integrations** var. There are also areas of the `useIntegrations` hook you can extend, such as the validation handler to verify a plugin's object properties meets Schema specifications, as well as working on live API registry.


-- 
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 #2886: feat: setup configuration-ui plugin registry `Draft`

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

   @klesh @likyh @mintsweet Phase 1 Of Dynamic **Plugin Registry** is ready for `main` branch **next** so more development & refactor can continue. Thanks.


-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/hooks/useIntegrations.jsx:
##########
@@ -15,17 +15,308 @@
  * limitations under the License.
  *
  */
-import { useState, useEffect } from 'react'
-import { integrationsData } from '@/data/integrations'
+import React, { useState, useEffect, useCallback, useMemo } from 'react'
 
-function useIntegrations(data = []) {
-  const [integrations, setIntegrations] = useState(integrationsData)
+import Plugin from '@/models/Plugin'
 
-  useEffect(() => {
-    // setIntegrations(integrationsData)
+// LOCAL PLUGIN REGISTRY
+// "integration" Plugins a.k.a "Providers"
+import JiraPlugin from '@/registry/plugins/jira.json'
+import GitHubPlugin from '@/registry/plugins/github.json'
+import GitLabPlugin from '@/registry/plugins/gitlab.json'
+import JenkinsPlugin from '@/registry/plugins/jenkins.json'
+import TapdPlugin from '@/registry/plugins/tapd.json'
+import AzurePlugin from '@/registry/plugins/azure.json'
+import BitbucketPlugin from '@/registry/plugins/bitbucket.json'
+import GiteePlugin from '@/registry/plugins/gitee.json'
+import AePlugin from '@/registry/plugins/ae.json'
+import RefdiffPlugin from '@/registry/plugins/refdiff.json'
+import DbtPlugin from '@/registry/plugins/dbt.json'
+import StarrocksPlugin from '@/registry/plugins/starrocks.json'
+import DoraPlugin from '@/registry/plugins/dora.json'
+
+const ProviderTypes = {
+  PLUGIN: 'plugin',
+  INTEGRATION: 'integration',
+  PIPELINE: 'pipeline',
+  WEBHOOK: 'webhook'
+}
+
+function useIntegrations(
+  pluginRegistry = [

Review Comment:
   It looks like never used as a param. Just define it as a const.



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/pages/blueprints/blueprint-settings.jsx:
##########
@@ -89,7 +89,18 @@ const BlueprintSettings = (props) => {
   const history = useHistory()
   const { bId } = useParams()
 
-  const [activeProvider, setActiveProvider] = useState(integrationsData[0])
+  const {
+    registry,
+    plugins: Plugins,
+    integrations: Integrations,
+    Providers,
+    ProviderLabels,
+    ProviderIcons,

Review Comment:
   This is can be done in a future cleanup PR.



##########
config-ui/src/pages/blueprints/blueprint-detail.jsx:
##########
@@ -59,13 +59,26 @@ import StageLane from '@/components/pipelines/StageLane'
 import { ToastNotification } from '@/components/Toast'
 import BlueprintNavigationLinks from '@/components/blueprints/BlueprintNavigationLinks'
 
+import useIntegrations from '@/hooks/useIntegrations'
 import useBlueprintManager from '@/hooks/useBlueprintManager'
 import usePipelineManager from '@/hooks/usePipelineManager'
 import usePaginator from '@/hooks/usePaginator'
 
 const BlueprintDetail = (props) => {
   // eslint-disable-next-line no-unused-vars
   const history = useHistory()
+
+  const {
+    registry,
+    plugins: Plugins,
+    integrations: Integrations,
+    Providers,
+    ProviderIcons,
+    ProviderLabels,

Review Comment:
   This is can be done in a future cleanup 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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/hooks/data-scope/useTransformationsManager.jsx:
##########
@@ -178,7 +188,27 @@ const useTransformationsManager = () => {
       )
       return transformations[key]
     },
-    [transformations]
+    [transformations, generateKey]
+  )
+
+  // get provider's specific scope options
+  // @todo: refactor "projectNameOrBoard" to "entity" in all areas
+  const getTransformationScopeOptions = useCallback(
+    (connectionProvider, projectNameOrBoard) => {
+      const key = generateKey(connectionProvider, projectNameOrBoard)
+      const plugin = Integrations.find((p) => p.id === connectionProvider)
+      console.debug(
+        '>> useTransformationsManager.getScopeOptions...',
+
+        connectionProvider,
+        projectNameOrBoard
+      )
+      return plugin &&
+        typeof plugin?.getDefaultTransformationScopeOptions === 'function'

Review Comment:
   No not a Typo, this is from the **Plugin** Model where it's defined as `getDefaultTransformationScopeOptions`, inside that function `getTransformationScopeOptions` is used on the Model correctly.



-- 
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 #2886: feat: setup configuration-ui plugin registry

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

   No matter how to do it, it looks like we must use one config to control all the logic. I think #2862 "delete ProviderIcons and ProviderFormPlaceholders and replace them with one config ProviderConfigMap. (integrationsData will refactor in future)" and "replace some switch(provider.id)/[xxx,yyy].includes(provider.id)/[jira,github] with more common code." is necessary. Why you hate it so much?


-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/pages/configure/integration/manage.jsx:
##########
@@ -461,7 +480,7 @@ export default function ManageIntegration() {
                         ))}
                       </tbody>
                     </table>
-                    {connectionLimitReached && (
+                    {connectionLimitReached ? (

Review Comment:
   They have the same effect.



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/components/blueprints/ProviderTransformationSettings.jsx:
##########
@@ -50,102 +64,32 @@ const ProviderTransformationSettings = (props) => {
     isFetchingJIRA = false
   } = props
 
-  return (
-    <div className='transformation-settings' data-provider={provider?.id}>
-      {provider?.id === Providers.GITHUB && (
-        <GithubSettings
-          provider={provider}
-          connection={connection}
-          transformation={transformation}
-          onSettingsChange={onSettingsChange}
-          entities={entities[connection?.id]}
-          isSaving={isSaving}
-          isSavingConnection={isSavingConnection}
-        />
-      )}
-
-      {provider?.id === Providers.GITLAB && (
-        <GitlabSettings
-          provider={provider}
-          connection={connection}
-          transformation={transformation}
-          onSettingsChange={onSettingsChange}
-          entities={entities[connection?.id]}
-          isSaving={isSaving}
-          isSavingConnection={isSavingConnection}
-        />
-      )}
+  // Provider Transformation Components (LOCAL)
+  const TransformationComponents = useMemo(
+    () => ({
+      [Providers.GITHUB]: GithubSettings,

Review Comment:
   The main reason for the `Memo` as well is because `Providers` is no longer imported from a Global Data Constant, Originally I had `TransformationComponents` Map defined _outside_ the class, but with the new design Providers is not accessible in a global state outside the class, therefore it has to be moved inside the the Component and wrapped with a Memo.



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/hooks/useDataScopesManager.jsx:
##########
@@ -108,68 +122,88 @@ function useDataScopesManager({
         ...defaultScope,
         entities: entities[connection.id]?.map((entity) => entity.value) || []
       }
-      switch (providerId) {
-        case Providers.JIRA:
-          newScope = boards[connection.id]?.map((b) => ({
-            ...newScope,
-            options: {
-              boardId: Number(b?.value),
-              title: b.title
-              // @todo: verify initial value of since date for jira provider
-              // since: new Date(),
-            },
-            transformation: {
-              ...getTransformation(connection?.providerId, connection?.id, b)
-            }
-          }))
-          break
-        case Providers.GITLAB:
-          newScope = projects[connection.id]?.map((p) => ({
-            ...newScope,
-            options: {
-              projectId: Number(p.value),
-              title: p.title
-            },
-            transformation: {
-              ...getTransformation(connection?.providerId, connection?.id, p)
-            }
-          }))
-          break
-        case Providers.JENKINS:
-          newScope = projects[connection.id]?.map((p) => ({
-            ...newScope,
-            options: {
-              jobName: p.value
-            },
-            transformation: {
-              ...getTransformation(connection?.providerId, connection?.id, p)
-            }
-          }))
-          break
-        case Providers.GITHUB:
-          newScope = projects[connection.id]?.map((p) => ({
-            ...newScope,
-            options: {
-              owner: p.value.split('/')[0],
-              repo: p.value.split('/')[1]
-            },
-            transformation: {
-              ...getTransformation(connection?.providerId, connection?.id, p)
-            }
-          }))
-          break
-        case Providers.TAPD:
-          newScope = {
-            ...newScope
-            // options: {
-            // },
-            // transformation: {},
-          }
-          break
-      }
+      // Generate scopes Dynamically for all Project/Board/Job/... Entities
+      // @todo: refactor again when boards & projects get merged...
+      newScope = [
+        ...(Array.isArray(boards[connection.id]) ? boards[connection.id] : []),
+        ...(Array.isArray(projects[connection.id])
+          ? projects[connection.id]
+          : [])
+      ].map((e) => ({
+        ...newScope,
+        options: {
+          ...getTransformationScopeOptions(connection?.providerId, e)
+        },
+        transformation: {
+          ...getTransformation(connection?.providerId, connection?.id, e)
+        }

Review Comment:
   No not the same return value, `getTransformation` returns _transformation_ values. `getTransformationScopeOptions` is for the other _data scope options_  for the Entity that were previously declared when provider scopes were manually built with the switch statement. Configuration-wise in the registry json I've grouped it with transformations as it's related to transformations.



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/hooks/data-scope/useTransformationsManager.jsx:
##########
@@ -178,7 +188,27 @@ const useTransformationsManager = () => {
       )
       return transformations[key]
     },
-    [transformations]
+    [transformations, generateKey]
+  )
+
+  // get provider's specific scope options
+  // @todo: refactor "projectNameOrBoard" to "entity" in all areas
+  const getTransformationScopeOptions = useCallback(
+    (connectionProvider, projectNameOrBoard) => {
+      const key = generateKey(connectionProvider, projectNameOrBoard)
+      const plugin = Integrations.find((p) => p.id === connectionProvider)
+      console.debug(
+        '>> useTransformationsManager.getScopeOptions...',
+
+        connectionProvider,
+        projectNameOrBoard
+      )
+      return plugin &&
+        typeof plugin?.getDefaultTransformationScopeOptions === 'function'

Review Comment:
   Is this typo? Actual value is `getTransformationScopeOptions` defined in models?



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/pages/configure/integration/manage.jsx:
##########
@@ -461,7 +480,7 @@ export default function ManageIntegration() {
                         ))}
                       </tbody>
                     </table>
-                    {connectionLimitReached && (
+                    {connectionLimitReached ? (

Review Comment:
   Suggestion applied.



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/hooks/data-scope/useTransformationsManager.jsx:
##########
@@ -15,103 +15,109 @@
  * limitations under the License.
  *
  */
-import { useCallback, useState } from 'react'
-import { Providers } from '@/data/Providers'
+import { useCallback, useState, useContext } from 'react'
+import IntegrationsContext from '@/store/integrations-context'
+// 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 { Providers, ProviderTransformations, Integrations } =
+    useContext(IntegrationsContext)
   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}`
-  }
+  const getDefaultTransformations = useCallback(
+    (provider) => {
+      // let transforms = {}
+      const transforms = ProviderTransformations[provider] || {}
+      // @note: Default Transformations configured in Plugin Registry! (see @src/registry/plugins)
+      // 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
+    },
+    [ProviderTransformations]
+  )
+
+  const generateKey = useCallback(
+    (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

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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/components/Sidebar.jsx:
##########
@@ -29,35 +35,46 @@ import { ReactComponent as Logo } from '@/images/devlake-logo.svg'
 import { ReactComponent as LogoText } from '@/images/devlake-textmark.svg'
 
 import '@/styles/sidebar.scss'
-import UIContext from '../store/UIContext'
+import UIContext from '@/store/UIContext'
 
-const Sidebar = () => {
+const Sidebar = (props) => {
+  const { integrations = [] } = props
   const activeRoute = useRouteMatch()
   const uiContext = useContext(UIContext)
 
-  const [menu, setMenu] = useState(MenuConfiguration(activeRoute))
+  const getMenu = useCallback(
+    () => MenuConfiguration(activeRoute, integrations),
+    [activeRoute, integrations]
+  )
+
+  const ActiveMenu = useMemo(() => getMenu(), [getMenu])
+
+  const [menu, setMenu] = useState(ActiveMenu)
   const [versionTag, setVersionTag] = useState('')
 
-  useEffect(() => {
-    setMenu(MenuConfiguration(activeRoute))
-  }, [activeRoute])
+  // useEffect(() => {
+  //   setMenu(ActiveMenu)
+  // }, [ActiveMenu])
 
   useEffect(() => {
-    const fetchVersion = async () => {
-      try {
-        const versionUrl = `${DEVLAKE_ENDPOINT}/version`

Review Comment:
   @likyh We no longer display the version tag on the sidebar, fetch is not needed at the moment.



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/components/blueprints/transformations/CICD/Deployment.jsx:
##########
@@ -24,10 +24,12 @@ import {
   Radio,
   Tag
 } from '@blueprintjs/core'
-import { Providers, ProviderLabels } from '@/data/Providers'
+// import { Providers, ProviderLabels } from '@/data/Providers'
 
 const Deployment = (props) => {
   const {
+    Providers = {},
+    ProviderLabels = {},

Review Comment:
   Context can be used by Child-components directly. These can probably get replaced with the Integrations Context.



-- 
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 #2886: feat: setup configuration-ui plugin registry

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

   @likyh @mintsweet All notable code review feedback has been resolved, any additional cleanups will be deferred to a subsequent 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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/hooks/useDataScopesManager.jsx:
##########
@@ -363,27 +397,31 @@ function useDataScopesManager({
     []
   )
 
-  const getDefaultEntities = useCallback((providerId) => {
-    let entities = []
-    switch (providerId) {
-      case Providers.GITHUB:
-      case Providers.GITLAB:
-        entities = DEFAULT_DATA_ENTITIES
-        break
-      case Providers.JIRA:
-        entities = DEFAULT_DATA_ENTITIES.filter(
-          (d) => d.name === 'issue-tracking' || d.name === 'cross-domain'
-        )
-        break
-      case Providers.JENKINS:
-        entities = DEFAULT_DATA_ENTITIES.filter((d) => d.name === 'ci-cd')
-        break
-      case Providers.TAPD:
-        entities = DEFAULT_DATA_ENTITIES.filter((d) => d.name === 'ci-cd')
-        break
-    }
-    return entities
-  }, [])
+  const getDefaultEntities = useCallback(
+    (providerId) => {
+      console.log('GET ENTITIES FOR PROVIDER =', providerId)
+      let entities = []
+      switch (providerId) {
+        case Providers.GITHUB:
+        case Providers.GITLAB:
+          entities = DEFAULT_DATA_ENTITIES
+          break
+        case Providers.JIRA:
+          entities = DEFAULT_DATA_ENTITIES.filter(
+            (d) => d.name === 'issue-tracking' || d.name === 'cross-domain'
+          )
+          break
+        case Providers.JENKINS:
+          entities = DEFAULT_DATA_ENTITIES.filter((d) => d.name === 'ci-cd')
+          break
+        case Providers.TAPD:
+          entities = DEFAULT_DATA_ENTITIES.filter((d) => d.name === 'ci-cd')

Review Comment:
   Good point, I'll update this to get entities dynamically.



-- 
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 #2886: feat: setup configuration-ui plugin registry

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

   > Wouldn't it be better to define the properties of the field like this:
   > 
   > ```
   > ...
   > {
   >     "authentication": "token",
   >     "fields": [
   >         {
   >             "name": "name",
   >             "label": "Connection Name",
   >             "placeholder": "eg.GitLab",
   >             "enable": true,
   >             "required": true,
   >             "readonly": false
   >         },
   >         {
   >             "name": "endpoint",
   >             "label": "Endpoint URL",
   >             "placeholder": "eg. https://gitlab.com/api/v4/"
   >         },
   >         {
   >             "name": "token",
   >             "label": "Access Token",
   >             "placeholder": "eg. ff9d1ad0e5c04f1f98fa"
   >         }
   >     ]
   > }
   > ...
   > ```
   > 
   > This has at least the following benefits:
   > 
   > * Focus on all properties of a field when defining fields, rather than defining them in scattered places.
   > * The form of the fileds array can solve the sorting problem of the fields, and the way of using the JSON object is likely to cause the problem of the traversal order.
   > 
   > In addition, do you need to add some other attributes to the field, such as
   > 
   > * showType, which represents front-end display components, such as input, select, checkbox, etc.
   > * validation, which represents standard validation rules, including regular validation, length validation, etc.
   > * multiple, which means that it is a multiple format, such as the PAT of the GitHub plugin, you can fill in multiple.
   > 
   > There is some information in this issue #2846
   
   I thought about this as well, and I agree to a certain extent and may re-configure the json files to be this way. The JSON schema is still being evaluated and worked on. For now it's easier on the user to edit 3 separate objects than 1 config object with 2nd level keys for everything. Additionally, it let's me construct the existing Variable Configurations without having to reduce the object configuration and transform it again into the structure I need.
   
   


-- 
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] tk103331 commented on pull request #2886: feat: setup configuration-ui plugin registry

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

   Is it better for the fields of the connection?
   
   ```
   ...
   {
       "authentication": "token",
       "fields": [
           {
               "name": "name",
               "label": "Connection Name",
               "placeholder": "eg.GitLab",
               "enable": true,
               "required": true,
               "readonly": false
           },
           {
               "name": "endpoint",
               "label": "Endpoint URL",
               "placeholder": "eg. https://gitlab.com/api/v4/"
           },
           {
               "name": "token",
               "label": "Access Token",
               "placeholder": "eg. ff9d1ad0e5c04f1f98fa"
           }
       ]
   }
   ...
   ```
   
   This has at least the following benefits:
   
   - Focus on all properties of a field when defining fields, rather than defining them in scattered places.
   - The form of the fileds array can solve the sorting problem of the fields, and the way of using the JSON object is likely to cause the problem of the traversal order.
   
   In addition, do you need to add some other attributes to the field, such as
   - showType, which represents front-end display components, such as input, select, checkbox, etc.
   - validation, which represents standard validation rules, including regular validation, length validation, etc.
   - multiple, which means that it is a multiple format, such as the PAT of the GitHub plugin, you can fill in multiple.
   
   There is some information in this issue https://github.com/apache/incubator-devlake/issues/2846


-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/components/blueprints/transformations/CICD/Deployment.jsx:
##########
@@ -24,10 +24,12 @@ import {
   Radio,
   Tag
 } from '@blueprintjs/core'
-import { Providers, ProviderLabels } from '@/data/Providers'
+// import { Providers, ProviderLabels } from '@/data/Providers'
 
 const Deployment = (props) => {
   const {
+    Providers = {},
+    ProviderLabels = {},

Review Comment:
   I will remove these added props in favor of the Integrations Context in another commit to this PR. These properties were defined before the context was added, this is why new props are being used in the first place.



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/pages/configure/integration/manage.jsx:
##########
@@ -461,7 +480,7 @@ export default function ManageIntegration() {
                         ))}
                       </tbody>
                     </table>
-                    {connectionLimitReached && (
+                    {connectionLimitReached ? (

Review Comment:
   No, the first will cause an unnecessary render of a value leading to a stray "0" character in the table row.



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/components/blueprints/ProviderTransformationSettings.jsx:
##########
@@ -50,102 +64,32 @@ const ProviderTransformationSettings = (props) => {
     isFetchingJIRA = false
   } = props
 
-  return (
-    <div className='transformation-settings' data-provider={provider?.id}>
-      {provider?.id === Providers.GITHUB && (
-        <GithubSettings
-          provider={provider}
-          connection={connection}
-          transformation={transformation}
-          onSettingsChange={onSettingsChange}
-          entities={entities[connection?.id]}
-          isSaving={isSaving}
-          isSavingConnection={isSavingConnection}
-        />
-      )}
-
-      {provider?.id === Providers.GITLAB && (
-        <GitlabSettings
-          provider={provider}
-          connection={connection}
-          transformation={transformation}
-          onSettingsChange={onSettingsChange}
-          entities={entities[connection?.id]}
-          isSaving={isSaving}
-          isSavingConnection={isSavingConnection}
-        />
-      )}
+  // Provider Transformation Components (LOCAL)
+  const TransformationComponents = useMemo(
+    () => ({
+      [Providers.GITHUB]: GithubSettings,

Review Comment:
   use ReactNode as the value of `useMemo`? It looks like not a common way, and I don't know if it can work. We can write like this:
   
   ```js
   const TransformationComponents = {
     [Providers.GITHUB]: GithubSettings,
     [Providers.GITLAB]: GitlabSettings,
     [Providers.JIRA]: JiraSettings,
     [Providers.JENKINS]: JenkinsSettings,
     [Providers.TAPD]: TapdSettings,
     [Providers.AZURE]: AzureSettings,
     [Providers.BITBUCKET]: BitbucketSettings,
     [Providers.GITEE]: GiteeSettings
   }
   let TransformationWithProviderSettings = TransformationComponents[provider?.id]
   return (
     <div className='transformation-settings' data-provider={provider?.id}>
       <TransformationWithProviderSettings
             provider={provider}
             connection={connection}
             transformation={transformation}
             onSettingsChange={onSettingsChange}
             entities={entities[connection?.id]}
             isSaving={isSaving}
             isSavingConnection={isSavingConnection}
           />
     </div>
   )
   ```
   
   https://reactjs.org/docs/jsx-in-depth.html#choosing-the-type-at-runtime



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/pages/configure/integration/manage.jsx:
##########
@@ -490,7 +509,7 @@ export default function ManageIntegration() {
                     }}
                   >
                     Fetched <strong>{connections.length}</strong> connection(s)
-                    from Lake API for <strong>{activeProvider.name}</strong>
+                    from Lake API for <strong>{activeProvider?.name}</strong>

Review Comment:
   I think "Resolve Conversation" need to be clicked by the reviewer..



-- 
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 #2886: feat: setup configuration-ui plugin registry

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

   > Wouldn't it be better to define the properties of the field like this:
   > 
   > ```
   > ...
   > {
   >     "authentication": "token",
   >     "fields": [
   >         {
   >             "name": "name",
   >             "label": "Connection Name",
   >             "placeholder": "eg.GitLab",
   >             "enable": true,
   >             "required": true,
   >             "readonly": false
   >         },
   >         {
   >             "name": "endpoint",
   >             "label": "Endpoint URL",
   >             "placeholder": "eg. https://gitlab.com/api/v4/"
   >         },
   >         {
   >             "name": "token",
   >             "label": "Access Token",
   >             "placeholder": "eg. ff9d1ad0e5c04f1f98fa"
   >         }
   >     ]
   > }
   > ...
   > ```
   > 
   > This has at least the following benefits:
   > 
   > * Focus on all properties of a field when defining fields, rather than defining them in scattered places.
   > * The form of the fileds array can solve the sorting problem of the fields, and the way of using the JSON object is likely to cause the problem of the traversal order.
   > 
   > In addition, do you need to add some other attributes to the field, such as
   > 
   > * showType, which represents front-end display components, such as input, select, checkbox, etc.
   > * validation, which represents standard validation rules, including regular validation, length validation, etc.
   > * multiple, which means that it is a multiple format, such as the PAT of the GitHub plugin, you can fill in multiple.
   > 
   > There is some information in this issue #2846
   
   I think so.


-- 
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 #2886: feat: setup configuration-ui plugin registry

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

   > It's the first PR and ProviderConfigMap can be replaced with JSON or API requests at any time.
   > 
   > In addition, my two PRS may not be merged. But please don't create PR so big. It's an open-source project.
   
   `ProviderConfigMap` is short term hack. Had you invested time in discussing with me what your intentions were you could have saved yourself a lot of time, Instead you choose to refactor on your own and make your own decisions, and create a PR with changes that go against my design strategy. 


-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/pages/blueprints/blueprint-detail.jsx:
##########
@@ -59,13 +59,26 @@ import StageLane from '@/components/pipelines/StageLane'
 import { ToastNotification } from '@/components/Toast'
 import BlueprintNavigationLinks from '@/components/blueprints/BlueprintNavigationLinks'
 
+import useIntegrations from '@/hooks/useIntegrations'
 import useBlueprintManager from '@/hooks/useBlueprintManager'
 import usePipelineManager from '@/hooks/usePipelineManager'
 import usePaginator from '@/hooks/usePaginator'
 
 const BlueprintDetail = (props) => {
   // eslint-disable-next-line no-unused-vars
   const history = useHistory()
+
+  const {
+    registry,
+    plugins: Plugins,
+    integrations: Integrations,
+    Providers,
+    ProviderIcons,
+    ProviderLabels,

Review Comment:
   just import states used.



##########
config-ui/src/pages/blueprints/blueprint-settings.jsx:
##########
@@ -89,7 +89,18 @@ const BlueprintSettings = (props) => {
   const history = useHistory()
   const { bId } = useParams()
 
-  const [activeProvider, setActiveProvider] = useState(integrationsData[0])
+  const {
+    registry,
+    plugins: Plugins,
+    integrations: Integrations,
+    Providers,
+    ProviderLabels,
+    ProviderIcons,

Review Comment:
   just import states used.



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/components/blueprints/transformations/CICD/Deployment.jsx:
##########
@@ -24,10 +24,12 @@ import {
   Radio,
   Tag
 } from '@blueprintjs/core'
-import { Providers, ProviderLabels } from '@/data/Providers'
+// import { Providers, ProviderLabels } from '@/data/Providers'
 
 const Deployment = (props) => {
   const {
+    Providers = {},
+    ProviderLabels = {},

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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/hooks/useDataScopesManager.jsx:
##########
@@ -363,27 +397,31 @@ function useDataScopesManager({
     []
   )
 
-  const getDefaultEntities = useCallback((providerId) => {
-    let entities = []
-    switch (providerId) {
-      case Providers.GITHUB:
-      case Providers.GITLAB:
-        entities = DEFAULT_DATA_ENTITIES
-        break
-      case Providers.JIRA:
-        entities = DEFAULT_DATA_ENTITIES.filter(
-          (d) => d.name === 'issue-tracking' || d.name === 'cross-domain'
-        )
-        break
-      case Providers.JENKINS:
-        entities = DEFAULT_DATA_ENTITIES.filter((d) => d.name === 'ci-cd')
-        break
-      case Providers.TAPD:
-        entities = DEFAULT_DATA_ENTITIES.filter((d) => d.name === 'ci-cd')
-        break
-    }
-    return entities
-  }, [])
+  const getDefaultEntities = useCallback(
+    (providerId) => {
+      console.log('GET ENTITIES FOR PROVIDER =', providerId)
+      let entities = []
+      switch (providerId) {
+        case Providers.GITHUB:
+        case Providers.GITLAB:
+          entities = DEFAULT_DATA_ENTITIES
+          break
+        case Providers.JIRA:
+          entities = DEFAULT_DATA_ENTITIES.filter(
+            (d) => d.name === 'issue-tracking' || d.name === 'cross-domain'
+          )
+          break
+        case Providers.JENKINS:
+          entities = DEFAULT_DATA_ENTITIES.filter((d) => d.name === 'ci-cd')
+          break
+        case Providers.TAPD:
+          entities = DEFAULT_DATA_ENTITIES.filter((d) => d.name === 'ci-cd')

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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/hooks/useJIRA.jsx:
##########
@@ -15,17 +15,19 @@
  * limitations under the License.
  *
  */
-import { useEffect, useState, useCallback } from 'react'
+import { useEffect, useState, useCallback, useContext } from 'react'
 import request from '@/utils/request'
 import { ToastNotification } from '@/components/Toast'
-import { Providers } from '@/data/Providers'
+import IntegrationsContext from '@/store/integrations-context'
+// import { Providers } from '@/data/Providers'
 import DataScopeConnection from '@/models/DataScopeConnection'
 
 const useJIRA = (
   { apiProxyPath, issuesEndpoint, fieldsEndpoint, boardsEndpoint },
   activeConnection = null,
   setConnections = () => []
 ) => {
+  const { Providers } = useContext(IntegrationsContext)

Review Comment:
   Correct, it was never used before, but it was defined, so it had to be updated as a result of these new changes. The Integrations Hook is mainly Configuration and can be used anywhere, including in the `useJIRA` Hook where it can be used if needed. I'll remove the reference for 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 a diff in pull request #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/hooks/useJIRA.jsx:
##########
@@ -15,17 +15,19 @@
  * limitations under the License.
  *
  */
-import { useEffect, useState, useCallback } from 'react'
+import { useEffect, useState, useCallback, useContext } from 'react'
 import request from '@/utils/request'
 import { ToastNotification } from '@/components/Toast'
-import { Providers } from '@/data/Providers'
+import IntegrationsContext from '@/store/integrations-context'
+// import { Providers } from '@/data/Providers'
 import DataScopeConnection from '@/models/DataScopeConnection'
 
 const useJIRA = (
   { apiProxyPath, issuesEndpoint, fieldsEndpoint, boardsEndpoint },
   activeConnection = null,
   setConnections = () => []
 ) => {
+  const { Providers } = useContext(IntegrationsContext)

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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/hooks/useDataScopesManager.jsx:
##########
@@ -35,6 +36,19 @@ function useDataScopesManager({
   /* connection, */ settings = {},
   setSettings = () => {}
 }) {
+  const {
+    registry,
+    plugins: Plugins,
+    integrations: Integrations,
+    activeProvider: IntegrationActiveProvider,
+    Providers,
+    ProviderLabels,
+    ProviderIcons,
+    ProviderFormLabels,
+    ProviderFormPlaceholders,

Review Comment:
   Just import the necessaries



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/registry/plugins/azure.json:
##########
@@ -0,0 +1,53 @@
+{
+  "id": "azure",
+  "name": "Azure CI",
+  "type": "integration",
+  "enabled": true,
+  "multiConnection": true,
+  "connectionLimit": 0,
+  "isBeta": false,
+  "isProvider": true,
+  "icon": "src/images/integrations/azure.svg",
+  "private": false,
+  "connection": {
+    "authentication": "plain",
+    "fields": {
+      "name": { "enable": true, "required": true, "readonly": false },
+      "endpoint": { },
+      "proxy": { },
+      "username": { },
+      "password": { },
+      "rateLimitPerHour": { }
+    },
+    "labels": {

Review Comment:
   OK, fix in 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 a diff in pull request #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/registry/plugins/azure.json:
##########
@@ -0,0 +1,53 @@
+{
+  "id": "azure",
+  "name": "Azure CI",
+  "type": "integration",
+  "enabled": true,
+  "multiConnection": true,
+  "connectionLimit": 0,
+  "isBeta": false,
+  "isProvider": true,
+  "icon": "src/images/integrations/azure.svg",
+  "private": false,
+  "connection": {
+    "authentication": "plain",
+    "fields": {
+      "name": { "enable": true, "required": true, "readonly": false },
+      "endpoint": { },
+      "proxy": { },
+      "username": { },
+      "password": { },
+      "rateLimitPerHour": { }
+    },
+    "labels": {

Review Comment:
   @likyh The fields group is for other meta configuration options for the connection field properties themselves, it is not fully implemented as yet and will be in another PR. These `labels` , `tooltips` and `placeholder` props maybe reorganized in the future according to suggestions by @tk103331 that would consolidate them.



-- 
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] mintsweet commented on a diff in pull request #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/components/Sidebar.jsx:
##########
@@ -29,35 +35,46 @@ import { ReactComponent as Logo } from '@/images/devlake-logo.svg'
 import { ReactComponent as LogoText } from '@/images/devlake-textmark.svg'
 
 import '@/styles/sidebar.scss'
-import UIContext from '../store/UIContext'
+import UIContext from '@/store/UIContext'
 
-const Sidebar = () => {
+const Sidebar = (props) => {
+  const { integrations = [] } = props
   const activeRoute = useRouteMatch()
   const uiContext = useContext(UIContext)
 
-  const [menu, setMenu] = useState(MenuConfiguration(activeRoute))
+  const getMenu = useCallback(
+    () => MenuConfiguration(activeRoute, integrations),
+    [activeRoute, integrations]
+  )
+
+  const ActiveMenu = useMemo(() => getMenu(), [getMenu])
+
+  const [menu, setMenu] = useState(ActiveMenu)
   const [versionTag, setVersionTag] = useState('')
 
-  useEffect(() => {
-    setMenu(MenuConfiguration(activeRoute))
-  }, [activeRoute])
+  // useEffect(() => {
+  //   setMenu(ActiveMenu)
+  // }, [ActiveMenu])
 
   useEffect(() => {
-    const fetchVersion = async () => {
-      try {
-        const versionUrl = `${DEVLAKE_ENDPOINT}/version`
-        const res = await request.get(versionUrl).catch((e) => {
-          console.log('>>> API VERSION ERROR...', e)
-          setVersionTag('')
-        })
-        setVersionTag(res?.data ? res.data?.version : '')
-      } catch (e) {
-        setVersionTag('')
-      }
-    }
-    fetchVersion()
+    // @todo: re-enable version fetch
+    // const fetchVersion = async () => {
+    //   try {
+    //     const versionUrl = `${DEVLAKE_ENDPOINT}/version`
+    //     const res = await request.get(versionUrl).catch((e) => {
+    //       console.log('>>> API VERSION ERROR...', e)
+    //       setVersionTag('')
+    //     })
+    //     setVersionTag(res?.data ? res.data?.version : '')
+    //   } catch (e) {
+    //     setVersionTag('')
+    //   }
+    // }
+    // fetchVersion()
   }, [])
 
+  // useEffect(() => {}, [integrations])

Review Comment:
   I think since it is a refactoring, these commented-out codes can be deleted.



##########
config-ui/src/hooks/useDataScopesManager.jsx:
##########
@@ -363,27 +397,31 @@ function useDataScopesManager({
     []
   )
 
-  const getDefaultEntities = useCallback((providerId) => {
-    let entities = []
-    switch (providerId) {
-      case Providers.GITHUB:
-      case Providers.GITLAB:
-        entities = DEFAULT_DATA_ENTITIES
-        break
-      case Providers.JIRA:
-        entities = DEFAULT_DATA_ENTITIES.filter(
-          (d) => d.name === 'issue-tracking' || d.name === 'cross-domain'
-        )
-        break
-      case Providers.JENKINS:
-        entities = DEFAULT_DATA_ENTITIES.filter((d) => d.name === 'ci-cd')
-        break
-      case Providers.TAPD:
-        entities = DEFAULT_DATA_ENTITIES.filter((d) => d.name === 'ci-cd')
-        break
-    }
-    return entities
-  }, [])
+  const getDefaultEntities = useCallback(
+    (providerId) => {
+      console.log('GET ENTITIES FOR PROVIDER =', providerId)
+      let entities = []
+      switch (providerId) {
+        case Providers.GITHUB:
+        case Providers.GITLAB:
+          entities = DEFAULT_DATA_ENTITIES
+          break
+        case Providers.JIRA:
+          entities = DEFAULT_DATA_ENTITIES.filter(
+            (d) => d.name === 'issue-tracking' || d.name === 'cross-domain'
+          )
+          break
+        case Providers.JENKINS:
+          entities = DEFAULT_DATA_ENTITIES.filter((d) => d.name === 'ci-cd')
+          break
+        case Providers.TAPD:
+          entities = DEFAULT_DATA_ENTITIES.filter((d) => d.name === 'ci-cd')

Review Comment:
   **entities** can also be defined in the plugin so that the conditional judgment here can be omitted.



##########
config-ui/src/components/Sidebar.jsx:
##########
@@ -29,35 +35,46 @@ import { ReactComponent as Logo } from '@/images/devlake-logo.svg'
 import { ReactComponent as LogoText } from '@/images/devlake-textmark.svg'
 
 import '@/styles/sidebar.scss'
-import UIContext from '../store/UIContext'
+import UIContext from '@/store/UIContext'
 
-const Sidebar = () => {
+const Sidebar = (props) => {
+  const { integrations = [] } = props
   const activeRoute = useRouteMatch()
   const uiContext = useContext(UIContext)
 
-  const [menu, setMenu] = useState(MenuConfiguration(activeRoute))
+  const getMenu = useCallback(
+    () => MenuConfiguration(activeRoute, integrations),
+    [activeRoute, integrations]
+  )
+
+  const ActiveMenu = useMemo(() => getMenu(), [getMenu])

Review Comment:
   `useMemo(() =>  MenuConfiguration(activeRoute, integrations), [...])`
   
   Wouldn't this save the **useCallback** above?



##########
config-ui/src/hooks/data-scope/useTransformationsManager.jsx:
##########
@@ -15,103 +15,109 @@
  * limitations under the License.
  *
  */
-import { useCallback, useState } from 'react'
-import { Providers } from '@/data/Providers'
+import { useCallback, useState, useContext } from 'react'
+import IntegrationsContext from '@/store/integrations-context'
+// 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 { Providers, ProviderTransformations, Integrations } =
+    useContext(IntegrationsContext)
   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}`
-  }
+  const getDefaultTransformations = useCallback(
+    (provider) => {
+      // let transforms = {}
+      const transforms = ProviderTransformations[provider] || {}
+      // @note: Default Transformations configured in Plugin Registry! (see @src/registry/plugins)
+      // 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
+    },
+    [ProviderTransformations]
+  )
+
+  const generateKey = useCallback(
+    (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

Review Comment:
   I found this place before, and I didn't see the difference between the two conditions.



##########
config-ui/src/hooks/usePipelineManager.jsx:
##########
@@ -47,18 +49,9 @@ function usePipelineManager(
   const [activePipeline, setActivePipeline] = useState(NullPipelineRun)
   const [lastRunId, setLastRunId] = useState(null)
   const [pipelineRun, setPipelineRun] = useState(NullPipelineRun)
-  const [allowedProviders, setAllowedProviders] = useState([
-    Providers.JIRA,
-    Providers.GITLAB,
-    Providers.JENKINS,
-    Providers.GITHUB,
-    Providers.REFDIFF,
-    Providers.GITEXTRACTOR,
-    Providers.FEISHU,
-    Providers.AE,
-    Providers.DBT,
-    Providers.TAPD
-  ])
+  const [allowedProviders, setAllowedProviders] = useState(

Review Comment:
   **Config UI** doesn't seem to support all plugins yet, is this judgment unnecessary?



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/hooks/usePipelineManager.jsx:
##########
@@ -47,18 +49,9 @@ function usePipelineManager(
   const [activePipeline, setActivePipeline] = useState(NullPipelineRun)
   const [lastRunId, setLastRunId] = useState(null)
   const [pipelineRun, setPipelineRun] = useState(NullPipelineRun)
-  const [allowedProviders, setAllowedProviders] = useState([
-    Providers.JIRA,
-    Providers.GITLAB,
-    Providers.JENKINS,
-    Providers.GITHUB,
-    Providers.REFDIFF,
-    Providers.GITEXTRACTOR,
-    Providers.FEISHU,
-    Providers.AE,
-    Providers.DBT,
-    Providers.TAPD
-  ])
+  const [allowedProviders, setAllowedProviders] = useState(

Review Comment:
   It's not being fully enforced in Advanced Mode, so this restriction won't apply.



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/hooks/useConnectionManager.jsx:
##########
@@ -38,6 +37,18 @@ function useConnectionManager(
   const history = useHistory()
   const { handleOfflineMode } = useNetworkOfflineMode()
 
+  const {
+    registry,
+    plugins: Plugins,
+    integrations: Integrations,
+    activeProvider: IntegrationActiveProvider,
+    Providers,
+    ProviderFormLabels,
+    ProviderFormPlaceholders,

Review Comment:
   Just import the state used.



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/data/Providers.js:
##########
@@ -381,13 +391,15 @@ const ProviderIcons = {
   )
 }
 
+// @note: migrated to @data/ConnectionStatus
 const ConnectionStatus = {
   OFFLINE: 0,
   ONLINE: 1,
   DISCONNECTED: 2,
   TESTING: 3
 }
 
+// @note: migrated to @data/ConnectionStatus

Review Comment:
   When will these move and delete?



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/components/blueprints/ProviderTransformationSettings.jsx:
##########
@@ -50,102 +64,32 @@ const ProviderTransformationSettings = (props) => {
     isFetchingJIRA = false
   } = props
 
-  return (
-    <div className='transformation-settings' data-provider={provider?.id}>
-      {provider?.id === Providers.GITHUB && (
-        <GithubSettings
-          provider={provider}
-          connection={connection}
-          transformation={transformation}
-          onSettingsChange={onSettingsChange}
-          entities={entities[connection?.id]}
-          isSaving={isSaving}
-          isSavingConnection={isSavingConnection}
-        />
-      )}
-
-      {provider?.id === Providers.GITLAB && (
-        <GitlabSettings
-          provider={provider}
-          connection={connection}
-          transformation={transformation}
-          onSettingsChange={onSettingsChange}
-          entities={entities[connection?.id]}
-          isSaving={isSaving}
-          isSavingConnection={isSavingConnection}
-        />
-      )}
+  // Provider Transformation Components (LOCAL)
+  const TransformationComponents = useMemo(
+    () => ({
+      [Providers.GITHUB]: GithubSettings,

Review Comment:
   This is well supported and a proper use case for applying a Higher-Order-Component (HOC), documented in the "JSX In Depth" section. Components can be created dynamically from a variable reference when needed, especially in our scenario where we need transformation settings to load dynamically without the need for having a switch statement.
   
   https://reactjs.org/docs/jsx-in-depth.html
   
   <img width="962" alt="Screen Shot 2022-10-28 at 9 37 43 AM" src="https://user-images.githubusercontent.com/1742233/198616497-a0843ed3-aba6-4d4c-b2db-0ff361f97f93.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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/data/Providers.js:
##########
@@ -381,13 +391,15 @@ const ProviderIcons = {
   )
 }
 
+// @note: migrated to @data/ConnectionStatus
 const ConnectionStatus = {
   OFFLINE: 0,
   ONLINE: 1,
   DISCONNECTED: 2,
   TESTING: 3
 }
 
+// @note: migrated to @data/ConnectionStatus

Review Comment:
   It's already done, this is just a comment to be removed when Providers.js is cleaned up and/or deprecated.



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/pages/configure/connections/AddConnection.jsx:
##########
@@ -42,9 +43,23 @@ export default function AddConnection() {
   const history = useHistory()
   const { providerId } = useParams()
 
-  const [activeProvider, setActiveProvider] = useState(
-    integrationsData.find((p) => p.id === providerId)
-  )
+  const {
+    registry,
+    plugins: Plugins,
+    integrations: Integrations,
+    activeProvider,
+    Providers,
+    ProviderFormLabels,
+    ProviderFormPlaceholders,

Review Comment:
   just import states used. And some others 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 pull request #2886: feat: setup configuration-ui plugin registry

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

   > No matter how to do it, it looks like we must use one config to control all the logic. I think #2862 「delete ProviderIcons and ProviderFormPlaceholders and replace them with one config ProviderConfigMap. (integrationsData will refactor in future)」 and 「replace some switch(provider.id)/[xxx,yyy].includes(provider.id)/[jira,github] with more common code.」 are necessary. Why you hate it so much?
   
   You go through all the trouble of introducing another foreign `ProviderConfigMap` which is a hack workaround to stuff all the needed props into one place, add a note that you have to refactor it more in the future -- and you think that's a better solution that well defined JSON config files? Your solution was more out of desperation than a proper way to evolve the configuration system. I only have 1 commit on this PR -- there are more changes to be added. I already mentioned that the switch statements in connection manager will be consolidated and removed.


-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/hooks/useJIRA.jsx:
##########
@@ -15,17 +15,19 @@
  * limitations under the License.
  *
  */
-import { useEffect, useState, useCallback } from 'react'
+import { useEffect, useState, useCallback, useContext } from 'react'
 import request from '@/utils/request'
 import { ToastNotification } from '@/components/Toast'
-import { Providers } from '@/data/Providers'
+import IntegrationsContext from '@/store/integrations-context'
+// import { Providers } from '@/data/Providers'
 import DataScopeConnection from '@/models/DataScopeConnection'
 
 const useJIRA = (
   { apiProxyPath, issuesEndpoint, fieldsEndpoint, boardsEndpoint },
   activeConnection = null,
   setConnections = () => []
 ) => {
+  const { Providers } = useContext(IntegrationsContext)

Review Comment:
   `Providers` should not use in `useJIRA` hook. This hook is a util hook, and it should keep pure and basic of other UI components. 
   
   Also it's never used.



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/pages/configure/integration/manage.jsx:
##########
@@ -490,7 +509,7 @@ export default function ManageIntegration() {
                     }}
                   >
                     Fetched <strong>{connections.length}</strong> connection(s)
-                    from Lake API for <strong>{activeProvider.name}</strong>
+                    from Lake API for <strong>{activeProvider?.name}</strong>

Review Comment:
   This is safer to use optional chaining, it may be removed in the future. If `activeProvider` was not available, other errors would be raised.



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/data/Providers.js:
##########
@@ -381,13 +391,15 @@ const ProviderIcons = {
   )
 }
 
+// @note: migrated to @data/ConnectionStatus
 const ConnectionStatus = {
   OFFLINE: 0,
   ONLINE: 1,
   DISCONNECTED: 2,
   TESTING: 3
 }
 
+// @note: migrated to @data/ConnectionStatus

Review Comment:
   ok



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/hooks/useDataScopesManager.jsx:
##########
@@ -108,68 +122,88 @@ function useDataScopesManager({
         ...defaultScope,
         entities: entities[connection.id]?.map((entity) => entity.value) || []
       }
-      switch (providerId) {
-        case Providers.JIRA:
-          newScope = boards[connection.id]?.map((b) => ({
-            ...newScope,
-            options: {
-              boardId: Number(b?.value),
-              title: b.title
-              // @todo: verify initial value of since date for jira provider
-              // since: new Date(),
-            },
-            transformation: {
-              ...getTransformation(connection?.providerId, connection?.id, b)
-            }
-          }))
-          break
-        case Providers.GITLAB:
-          newScope = projects[connection.id]?.map((p) => ({
-            ...newScope,
-            options: {
-              projectId: Number(p.value),
-              title: p.title
-            },
-            transformation: {
-              ...getTransformation(connection?.providerId, connection?.id, p)
-            }
-          }))
-          break
-        case Providers.JENKINS:
-          newScope = projects[connection.id]?.map((p) => ({
-            ...newScope,
-            options: {
-              jobName: p.value
-            },
-            transformation: {
-              ...getTransformation(connection?.providerId, connection?.id, p)
-            }
-          }))
-          break
-        case Providers.GITHUB:
-          newScope = projects[connection.id]?.map((p) => ({
-            ...newScope,
-            options: {
-              owner: p.value.split('/')[0],
-              repo: p.value.split('/')[1]
-            },
-            transformation: {
-              ...getTransformation(connection?.providerId, connection?.id, p)
-            }
-          }))
-          break
-        case Providers.TAPD:
-          newScope = {
-            ...newScope
-            // options: {
-            // },
-            // transformation: {},
-          }
-          break
-      }
+      // Generate scopes Dynamically for all Project/Board/Job/... Entities
+      // @todo: refactor again when boards & projects get merged...
+      newScope = [
+        ...(Array.isArray(boards[connection.id]) ? boards[connection.id] : []),
+        ...(Array.isArray(projects[connection.id])
+          ? projects[connection.id]
+          : [])
+      ].map((e) => ({
+        ...newScope,
+        options: {
+          ...getTransformationScopeOptions(connection?.providerId, e)
+        },
+        transformation: {
+          ...getTransformation(connection?.providerId, connection?.id, e)
+        }

Review Comment:
   ```js
           options: getTransformationScopeOptions(connection?.providerId, e),
           transformation: getTransformation(connection?.providerId, connection?.id, e),
   ```
   Or they are return the same object every time?



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/pages/configure/integration/manage.jsx:
##########
@@ -490,7 +509,7 @@ export default function ManageIntegration() {
                     }}
                   >
                     Fetched <strong>{connections.length}</strong> connection(s)
-                    from Lake API for <strong>{activeProvider.name}</strong>
+                    from Lake API for <strong>{activeProvider?.name}</strong>

Review Comment:
   If we know `activeProvider` won't be null, Let don't use `?.`. Sometimes it will uncover some bugs because it doesn't raise an error and just displays empty.



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/components/blueprints/transformations/CICD/Deployment.jsx:
##########
@@ -24,10 +24,12 @@ import {
   Radio,
   Tag
 } from '@blueprintjs/core'
-import { Providers, ProviderLabels } from '@/data/Providers'
+// import { Providers, ProviderLabels } from '@/data/Providers'
 
 const Deployment = (props) => {
   const {
+    Providers = {},
+    ProviderLabels = {},

Review Comment:
   Context can be used by Child-components directly.



##########
config-ui/src/hooks/useIntegrations.jsx:
##########
@@ -15,17 +15,308 @@
  * limitations under the License.
  *
  */
-import { useState, useEffect } from 'react'
-import { integrationsData } from '@/data/integrations'
+import React, { useState, useEffect, useCallback, useMemo } from 'react'
 
-function useIntegrations(data = []) {
-  const [integrations, setIntegrations] = useState(integrationsData)
+import Plugin from '@/models/Plugin'
 
-  useEffect(() => {
-    // setIntegrations(integrationsData)
+// LOCAL PLUGIN REGISTRY
+// "integration" Plugins a.k.a "Providers"
+import JiraPlugin from '@/registry/plugins/jira.json'
+import GitHubPlugin from '@/registry/plugins/github.json'
+import GitLabPlugin from '@/registry/plugins/gitlab.json'
+import JenkinsPlugin from '@/registry/plugins/jenkins.json'
+import TapdPlugin from '@/registry/plugins/tapd.json'
+import AzurePlugin from '@/registry/plugins/azure.json'
+import BitbucketPlugin from '@/registry/plugins/bitbucket.json'
+import GiteePlugin from '@/registry/plugins/gitee.json'
+import AePlugin from '@/registry/plugins/ae.json'
+import RefdiffPlugin from '@/registry/plugins/refdiff.json'
+import DbtPlugin from '@/registry/plugins/dbt.json'
+import StarrocksPlugin from '@/registry/plugins/starrocks.json'
+import DoraPlugin from '@/registry/plugins/dora.json'
+
+const ProviderTypes = {
+  PLUGIN: 'plugin',
+  INTEGRATION: 'integration',
+  PIPELINE: 'pipeline',
+  WEBHOOK: 'webhook'
+}
+
+function useIntegrations(
+  pluginRegistry = [

Review Comment:
   param with a default value



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/pages/configure/connections/AddConnection.jsx:
##########
@@ -42,9 +43,23 @@ export default function AddConnection() {
   const history = useHistory()
   const { providerId } = useParams()
 
-  const [activeProvider, setActiveProvider] = useState(
-    integrationsData.find((p) => p.id === providerId)
-  )
+  const {
+    registry,
+    plugins: Plugins,
+    integrations: Integrations,
+    activeProvider,
+    Providers,
+    ProviderFormLabels,
+    ProviderFormPlaceholders,

Review Comment:
   This is can be done in a future cleanup PR.



##########
config-ui/src/pages/blueprints/create-blueprint.jsx:
##########
@@ -91,6 +92,22 @@ const CreateBlueprint = (props) => {
   const history = useHistory()
   // const dispatch = useDispatch()
 
+  const {
+    registry,
+    plugins: Plugins,
+    integrations: Integrations,
+    activeProvider,
+    DataSources: DataSourcesList,
+    Providers,
+    ProviderLabels,
+    ProviderIcons,
+    ProviderFormLabels,
+    ProviderFormPlaceholders,

Review Comment:
   This is can be done in a future cleanup 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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/pages/configure/integration/manage.jsx:
##########
@@ -490,7 +509,7 @@ export default function ManageIntegration() {
                     }}
                   >
                     Fetched <strong>{connections.length}</strong> connection(s)
-                    from Lake API for <strong>{activeProvider.name}</strong>
+                    from Lake API for <strong>{activeProvider?.name}</strong>

Review Comment:
   "other errors would be raised", then we can notice it. Displaying empty sometimes uncover some bugs because .



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/hooks/useConnectionManager.jsx:
##########
@@ -38,6 +37,18 @@ function useConnectionManager(
   const history = useHistory()
   const { handleOfflineMode } = useNetworkOfflineMode()
 
+  const {
+    registry,
+    plugins: Plugins,
+    integrations: Integrations,
+    activeProvider: IntegrationActiveProvider,
+    Providers,
+    ProviderFormLabels,
+    ProviderFormPlaceholders,

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 pull request #2886: feat: setup configuration-ui plugin registry `Draft`

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

   Is this PR will continue 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] likyh commented on a diff in pull request #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/pages/blueprints/create-blueprint.jsx:
##########
@@ -91,6 +92,22 @@ const CreateBlueprint = (props) => {
   const history = useHistory()
   // const dispatch = useDispatch()
 
+  const {
+    registry,
+    plugins: Plugins,
+    integrations: Integrations,
+    activeProvider,
+    DataSources: DataSourcesList,
+    Providers,
+    ProviderLabels,
+    ProviderIcons,
+    ProviderFormLabels,
+    ProviderFormPlaceholders,

Review Comment:
   just import states used.



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/pages/configure/integration/manage.jsx:
##########
@@ -461,7 +480,7 @@ export default function ManageIntegration() {
                         ))}
                       </tbody>
                     </table>
-                    {connectionLimitReached && (
+                    {connectionLimitReached ? (

Review Comment:
   !!connectionLimitReached && 



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/pages/configure/integration/manage.jsx:
##########
@@ -490,7 +509,7 @@ export default function ManageIntegration() {
                     }}
                   >
                     Fetched <strong>{connections.length}</strong> connection(s)
-                    from Lake API for <strong>{activeProvider.name}</strong>
+                    from Lake API for <strong>{activeProvider?.name}</strong>

Review Comment:
   This is a non-issue, optional chaining was not designed to "cover" bugs but to cleanly add non-exist state checking. I can resolve a conversation If I feel the question has been answered and there is no problem identified.



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/hooks/useDataScopesManager.jsx:
##########
@@ -108,68 +122,88 @@ function useDataScopesManager({
         ...defaultScope,
         entities: entities[connection.id]?.map((entity) => entity.value) || []
       }
-      switch (providerId) {
-        case Providers.JIRA:
-          newScope = boards[connection.id]?.map((b) => ({
-            ...newScope,
-            options: {
-              boardId: Number(b?.value),
-              title: b.title
-              // @todo: verify initial value of since date for jira provider
-              // since: new Date(),
-            },
-            transformation: {
-              ...getTransformation(connection?.providerId, connection?.id, b)
-            }
-          }))
-          break
-        case Providers.GITLAB:
-          newScope = projects[connection.id]?.map((p) => ({
-            ...newScope,
-            options: {
-              projectId: Number(p.value),
-              title: p.title
-            },
-            transformation: {
-              ...getTransformation(connection?.providerId, connection?.id, p)
-            }
-          }))
-          break
-        case Providers.JENKINS:
-          newScope = projects[connection.id]?.map((p) => ({
-            ...newScope,
-            options: {
-              jobName: p.value
-            },
-            transformation: {
-              ...getTransformation(connection?.providerId, connection?.id, p)
-            }
-          }))
-          break
-        case Providers.GITHUB:
-          newScope = projects[connection.id]?.map((p) => ({
-            ...newScope,
-            options: {
-              owner: p.value.split('/')[0],
-              repo: p.value.split('/')[1]
-            },
-            transformation: {
-              ...getTransformation(connection?.providerId, connection?.id, p)
-            }
-          }))
-          break
-        case Providers.TAPD:
-          newScope = {
-            ...newScope
-            // options: {
-            // },
-            // transformation: {},
-          }
-          break
-      }
+      // Generate scopes Dynamically for all Project/Board/Job/... Entities
+      // @todo: refactor again when boards & projects get merged...

Review Comment:
   ok



-- 
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 merged pull request #2886: feat: setup configuration-ui plugin registry

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


-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/components/blueprints/transformations/CICD/Deployment.jsx:
##########
@@ -24,10 +24,12 @@ import {
   Radio,
   Tag
 } from '@blueprintjs/core'
-import { Providers, ProviderLabels } from '@/data/Providers'
+// import { Providers, ProviderLabels } from '@/data/Providers'
 
 const Deployment = (props) => {
   const {
+    Providers = {},
+    ProviderLabels = {},

Review Comment:
   What difference between props and useContext?



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/components/Sidebar.jsx:
##########
@@ -29,35 +35,46 @@ import { ReactComponent as Logo } from '@/images/devlake-logo.svg'
 import { ReactComponent as LogoText } from '@/images/devlake-textmark.svg'
 
 import '@/styles/sidebar.scss'
-import UIContext from '../store/UIContext'
+import UIContext from '@/store/UIContext'
 
-const Sidebar = () => {
+const Sidebar = (props) => {
+  const { integrations = [] } = props
   const activeRoute = useRouteMatch()
   const uiContext = useContext(UIContext)
 
-  const [menu, setMenu] = useState(MenuConfiguration(activeRoute))
+  const getMenu = useCallback(
+    () => MenuConfiguration(activeRoute, integrations),
+    [activeRoute, integrations]
+  )
+
+  const ActiveMenu = useMemo(() => getMenu(), [getMenu])

Review Comment:
   It's needed to prevent excessive re-render of the MenuConfiguration



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/pages/configure/settings/tapd.jsx:
##########
@@ -24,6 +24,8 @@ import '@/styles/connections.scss'
 
 export default function TapdSettings(props) {
   const {
+    Providers,

Review Comment:
   Let's don't add unused parameters. 



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/components/Sidebar.jsx:
##########
@@ -29,35 +35,46 @@ import { ReactComponent as Logo } from '@/images/devlake-logo.svg'
 import { ReactComponent as LogoText } from '@/images/devlake-textmark.svg'
 
 import '@/styles/sidebar.scss'
-import UIContext from '../store/UIContext'
+import UIContext from '@/store/UIContext'
 
-const Sidebar = () => {
+const Sidebar = (props) => {
+  const { integrations = [] } = props
   const activeRoute = useRouteMatch()
   const uiContext = useContext(UIContext)
 
-  const [menu, setMenu] = useState(MenuConfiguration(activeRoute))
+  const getMenu = useCallback(
+    () => MenuConfiguration(activeRoute, integrations),
+    [activeRoute, integrations]
+  )
+
+  const ActiveMenu = useMemo(() => getMenu(), [getMenu])
+
+  const [menu, setMenu] = useState(ActiveMenu)
   const [versionTag, setVersionTag] = useState('')
 
-  useEffect(() => {
-    setMenu(MenuConfiguration(activeRoute))
-  }, [activeRoute])
+  // useEffect(() => {
+  //   setMenu(ActiveMenu)
+  // }, [ActiveMenu])
 
   useEffect(() => {
-    const fetchVersion = async () => {
-      try {
-        const versionUrl = `${DEVLAKE_ENDPOINT}/version`

Review Comment:
   @likyh Version Tag is not a key focus of this PR, anything related to version tag can be tracked under #3607 



-- 
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 #2886: feat: setup configuration-ui plugin registry `Draft`

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

   > Is this PR will continue now?
   
   I will be refreshing this soon, ideally other refactor PRs need to be completed or halted while I get this initial version of dynamic config ready.


-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/hooks/useIntegrations.jsx:
##########
@@ -15,17 +15,308 @@
  * limitations under the License.
  *
  */
-import { useState, useEffect } from 'react'
-import { integrationsData } from '@/data/integrations'
+import React, { useState, useEffect, useCallback, useMemo } from 'react'
 
-function useIntegrations(data = []) {
-  const [integrations, setIntegrations] = useState(integrationsData)
+import Plugin from '@/models/Plugin'
 
-  useEffect(() => {
-    // setIntegrations(integrationsData)
+// LOCAL PLUGIN REGISTRY
+// "integration" Plugins a.k.a "Providers"
+import JiraPlugin from '@/registry/plugins/jira.json'
+import GitHubPlugin from '@/registry/plugins/github.json'
+import GitLabPlugin from '@/registry/plugins/gitlab.json'
+import JenkinsPlugin from '@/registry/plugins/jenkins.json'
+import TapdPlugin from '@/registry/plugins/tapd.json'
+import AzurePlugin from '@/registry/plugins/azure.json'
+import BitbucketPlugin from '@/registry/plugins/bitbucket.json'
+import GiteePlugin from '@/registry/plugins/gitee.json'
+import AePlugin from '@/registry/plugins/ae.json'
+import RefdiffPlugin from '@/registry/plugins/refdiff.json'
+import DbtPlugin from '@/registry/plugins/dbt.json'
+import StarrocksPlugin from '@/registry/plugins/starrocks.json'
+import DoraPlugin from '@/registry/plugins/dora.json'
+
+const ProviderTypes = {
+  PLUGIN: 'plugin',
+  INTEGRATION: 'integration',
+  PIPELINE: 'pipeline',
+  WEBHOOK: 'webhook'
+}
+
+function useIntegrations(
+  pluginRegistry = [

Review Comment:
   It looks like a const rather than a param. 



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/hooks/data-scope/useTransformationsManager.jsx:
##########
@@ -15,103 +15,109 @@
  * limitations under the License.
  *
  */
-import { useCallback, useState } from 'react'
-import { Providers } from '@/data/Providers'
+import { useCallback, useState, useContext } from 'react'
+import IntegrationsContext from '@/store/integrations-context'
+// 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 { Providers, ProviderTransformations, Integrations } =
+    useContext(IntegrationsContext)
   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}`
-  }
+  const getDefaultTransformations = useCallback(
+    (provider) => {
+      // let transforms = {}
+      const transforms = ProviderTransformations[provider] || {}
+      // @note: Default Transformations configured in Plugin Registry! (see @src/registry/plugins)
+      // 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
+    },
+    [ProviderTransformations]
+  )
+
+  const generateKey = useCallback(
+    (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

Review Comment:
   Projects and Boards will be merged in a separate PR by @likyh, this switch block will be removed after.



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/hooks/data-scope/useTransformationsManager.jsx:
##########
@@ -15,103 +15,109 @@
  * limitations under the License.
  *
  */
-import { useCallback, useState } from 'react'
-import { Providers } from '@/data/Providers'
+import { useCallback, useState, useContext } from 'react'
+import IntegrationsContext from '@/store/integrations-context'
+// 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 { Providers, ProviderTransformations, Integrations } =
+    useContext(IntegrationsContext)
   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}`
-  }
+  const getDefaultTransformations = useCallback(
+    (provider) => {
+      // let transforms = {}
+      const transforms = ProviderTransformations[provider] || {}
+      // @note: Default Transformations configured in Plugin Registry! (see @src/registry/plugins)
+      // 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
+    },
+    [ProviderTransformations]
+  )
+
+  const generateKey = useCallback(
+    (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

Review Comment:
   Then again it would be good to make the update to the generateKey function on this 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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/components/blueprints/transformations/CICD/Deployment.jsx:
##########
@@ -24,10 +24,12 @@ import {
   Radio,
   Tag
 } from '@blueprintjs/core'
-import { Providers, ProviderLabels } from '@/data/Providers'
+// import { Providers, ProviderLabels } from '@/data/Providers'
 
 const Deployment = (props) => {
   const {
+    Providers = {},
+    ProviderLabels = {},

Review Comment:
   So here we can use `useContext` too?



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/registry/plugins/azure.json:
##########
@@ -0,0 +1,53 @@
+{
+  "id": "azure",
+  "name": "Azure CI",
+  "type": "integration",
+  "enabled": true,
+  "multiConnection": true,
+  "connectionLimit": 0,
+  "isBeta": false,
+  "isProvider": true,
+  "icon": "src/images/integrations/azure.svg",
+  "private": false,
+  "connection": {
+    "authentication": "plain",
+    "fields": {
+      "name": { "enable": true, "required": true, "readonly": false },
+      "endpoint": { },
+      "proxy": { },
+      "username": { },
+      "password": { },
+      "rateLimitPerHour": { }
+    },
+    "labels": {

Review Comment:
   why do we add `labels`, `tooltips` and `placeholders` into `fields`? It looks all these are dicribe `fields`.



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/hooks/useIntegrations.jsx:
##########
@@ -15,17 +15,308 @@
  * limitations under the License.
  *
  */
-import { useState, useEffect } from 'react'
-import { integrationsData } from '@/data/integrations'
+import React, { useState, useEffect, useCallback, useMemo } from 'react'
 
-function useIntegrations(data = []) {
-  const [integrations, setIntegrations] = useState(integrationsData)
+import Plugin from '@/models/Plugin'
 
-  useEffect(() => {
-    // setIntegrations(integrationsData)
+// LOCAL PLUGIN REGISTRY
+// "integration" Plugins a.k.a "Providers"
+import JiraPlugin from '@/registry/plugins/jira.json'
+import GitHubPlugin from '@/registry/plugins/github.json'
+import GitLabPlugin from '@/registry/plugins/gitlab.json'
+import JenkinsPlugin from '@/registry/plugins/jenkins.json'
+import TapdPlugin from '@/registry/plugins/tapd.json'
+import AzurePlugin from '@/registry/plugins/azure.json'
+import BitbucketPlugin from '@/registry/plugins/bitbucket.json'
+import GiteePlugin from '@/registry/plugins/gitee.json'
+import AePlugin from '@/registry/plugins/ae.json'
+import RefdiffPlugin from '@/registry/plugins/refdiff.json'
+import DbtPlugin from '@/registry/plugins/dbt.json'
+import StarrocksPlugin from '@/registry/plugins/starrocks.json'
+import DoraPlugin from '@/registry/plugins/dora.json'
+
+const ProviderTypes = {
+  PLUGIN: 'plugin',
+  INTEGRATION: 'integration',
+  PIPELINE: 'pipeline',
+  WEBHOOK: 'webhook'
+}
+
+function useIntegrations(
+  pluginRegistry = [

Review Comment:
   No this means the `pluginRegistry` is an argument for the Integrations Hook, and thus can be overloaded if desired. It becomes the initial state value on Ln 62 `const [registry, setRegistry] = useState(pluginRegistry || [])`



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/hooks/useIntegrations.jsx:
##########
@@ -15,17 +15,308 @@
  * limitations under the License.
  *
  */
-import { useState, useEffect } from 'react'
-import { integrationsData } from '@/data/integrations'
+import React, { useState, useEffect, useCallback, useMemo } from 'react'
 
-function useIntegrations(data = []) {
-  const [integrations, setIntegrations] = useState(integrationsData)
+import Plugin from '@/models/Plugin'
 
-  useEffect(() => {
-    // setIntegrations(integrationsData)
+// LOCAL PLUGIN REGISTRY
+// "integration" Plugins a.k.a "Providers"
+import JiraPlugin from '@/registry/plugins/jira.json'
+import GitHubPlugin from '@/registry/plugins/github.json'
+import GitLabPlugin from '@/registry/plugins/gitlab.json'
+import JenkinsPlugin from '@/registry/plugins/jenkins.json'
+import TapdPlugin from '@/registry/plugins/tapd.json'
+import AzurePlugin from '@/registry/plugins/azure.json'
+import BitbucketPlugin from '@/registry/plugins/bitbucket.json'
+import GiteePlugin from '@/registry/plugins/gitee.json'
+import AePlugin from '@/registry/plugins/ae.json'
+import RefdiffPlugin from '@/registry/plugins/refdiff.json'
+import DbtPlugin from '@/registry/plugins/dbt.json'
+import StarrocksPlugin from '@/registry/plugins/starrocks.json'
+import DoraPlugin from '@/registry/plugins/dora.json'
+
+const ProviderTypes = {
+  PLUGIN: 'plugin',
+  INTEGRATION: 'integration',
+  PIPELINE: 'pipeline',
+  WEBHOOK: 'webhook'
+}
+
+function useIntegrations(
+  pluginRegistry = [

Review Comment:
   No this means the `pluginRegistry` is an argument for the Integrations Hook, and thus can be overloaded if desired. It becomes the initial state value for `const [registry, setRegistry]`



-- 
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 #2886: feat: setup configuration-ui plugin registry

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


##########
config-ui/src/components/blueprints/ProviderTransformationSettings.jsx:
##########
@@ -50,102 +64,32 @@ const ProviderTransformationSettings = (props) => {
     isFetchingJIRA = false
   } = props
 
-  return (
-    <div className='transformation-settings' data-provider={provider?.id}>
-      {provider?.id === Providers.GITHUB && (
-        <GithubSettings
-          provider={provider}
-          connection={connection}
-          transformation={transformation}
-          onSettingsChange={onSettingsChange}
-          entities={entities[connection?.id]}
-          isSaving={isSaving}
-          isSavingConnection={isSavingConnection}
-        />
-      )}
-
-      {provider?.id === Providers.GITLAB && (
-        <GitlabSettings
-          provider={provider}
-          connection={connection}
-          transformation={transformation}
-          onSettingsChange={onSettingsChange}
-          entities={entities[connection?.id]}
-          isSaving={isSaving}
-          isSavingConnection={isSavingConnection}
-        />
-      )}
+  // Provider Transformation Components (LOCAL)
+  const TransformationComponents = useMemo(
+    () => ({
+      [Providers.GITHUB]: GithubSettings,

Review Comment:
   Additionally, Entire Components can be Memoized.



-- 
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] tk103331 commented on pull request #2886: feat: setup configuration-ui plugin registry `Draft`

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

   Sorry, I didn't see what you edited in my reply two days ago.
   
   > I do see your point, I wouldn't say it's scattered, sorting of the fields is not something needed or relevant, the order of the fields in the connection form follows a natural order starting with Name, ending with Rate Limit.
   
   What I mean is to spread the multiple information (name, label, placeholder) of a field to be defined in multiple places instead of using only one object.
   Regarding field sorting, in general, we will use the code writing order. However, if fileds is data requested from the backend. Possibly, the backend may use the map data structure (because the field is not fixed and cannot use struct), which will cause problems due to the uncertainty of the map traversal order. Of course, we can provide some instructions or helpers to avoid this problem, but it really depends on how the backend people write the code.
   
   > I see the point, and we can certainly evolve the configuration to let validation rules be defined here but it's not needed right now. Instead of showType we would just use type (string|number|object) etc and add a component prop to specify a form control that's to be used for render.
   
   Yes, the name `component` would be more appropriate, the name showType is a premature suggestion.


-- 
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 #2886: feat: setup configuration-ui plugin registry

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

   It's the first PR and ProviderConfigMap can be replaced with JSON or API requests at any time.
   
   In addition, my two PRS may not be merged. But please don't create PR so big. It's an open-source project.
   


-- 
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 #2886: feat: setup configuration-ui plugin registry

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

   A Plugin does not need to be responsible for determining it's own Connection Fields at this time with regards to them being dynamically created, it should be following a standard convention so Each Plugin has to satisfy the current Connection model defined by the backend. The plugin can have dynamic control (enabled state, required state etc) over the standard connection fields that exist currently, which is what this configuration is intended for. Based on a plugin's authentication type that also is a main factor as to what main fields are required for the connection.
   
   In the future the plugin can perhaps have more control and custom rendering options for the field. This is something to be discussed in more detail.


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