You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by kl...@apache.org on 2023/10/09 08:45:03 UTC
[incubator-devlake] branch main updated: fix(config-ui): missed conditions for connection scope (#6202)
This is an automated email from the ASF dual-hosted git repository.
klesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/main by this push:
new 4b1cff714 fix(config-ui): missed conditions for connection scope (#6202)
4b1cff714 is described below
commit 4b1cff714e54cf31753de12cfa2454e436f17f90
Author: 青湛 <0x...@gmail.com>
AuthorDate: Mon Oct 9 21:44:54 2023 +1300
fix(config-ui): missed conditions for connection scope (#6202)
---
config-ui/src/pages/connection/detail/index.tsx | 26 ++++++++++++++++------
.../plugins/components/data-scope-select/api.ts | 2 +-
.../plugins/components/data-scope-select/index.tsx | 24 ++++++++++++++------
3 files changed, 37 insertions(+), 15 deletions(-)
diff --git a/config-ui/src/pages/connection/detail/index.tsx b/config-ui/src/pages/connection/detail/index.tsx
index d6d771582..21375994f 100644
--- a/config-ui/src/pages/connection/detail/index.tsx
+++ b/config-ui/src/pages/connection/detail/index.tsx
@@ -82,13 +82,25 @@ const ConnectionDetail = ({ plugin, connectionId }: Props) => {
const [dataSource, total] = useMemo(
() => [
- data?.scopes.map((it: any) => ({
- id: getPluginScopeId(plugin, it.scope),
- name: it.scope.name,
- projects: it.blueprints.map((bp: any) => bp.projectName) ?? [],
- configId: it.scopeConfig.id,
- configName: it.scopeConfig.name,
- })) ?? [],
+ data?.scopes.map((it: any) => {
+ if (['github', 'gitlab'].includes(plugin)) {
+ return {
+ id: getPluginScopeId(plugin, it.scope),
+ name: it.scope.name,
+ projects: it.blueprints?.map((bp: any) => bp.projectName) ?? [],
+ configId: it.scopeConfig?.id,
+ configName: it.scopeConfig?.name,
+ };
+ }
+
+ return {
+ id: getPluginScopeId(plugin, it),
+ name: it.name,
+ projects: it.blueprints?.map((bp: any) => bp.projectName) ?? [],
+ configId: it.scopeConfigId,
+ configName: it.scopeConfigName,
+ };
+ }) ?? [],
data?.count ?? 0,
],
[data],
diff --git a/config-ui/src/plugins/components/data-scope-select/api.ts b/config-ui/src/plugins/components/data-scope-select/api.ts
index e15408316..5266f769b 100644
--- a/config-ui/src/plugins/components/data-scope-select/api.ts
+++ b/config-ui/src/plugins/components/data-scope-select/api.ts
@@ -23,7 +23,7 @@ type ParamsType = {
} & Pagination;
type ResponseType = {
- scopes: Array<{ scope: { name: string } }>;
+ scopes: Array<{ name: string; scope: { name: string } }>;
count: number;
};
diff --git a/config-ui/src/plugins/components/data-scope-select/index.tsx b/config-ui/src/plugins/components/data-scope-select/index.tsx
index b94e637c5..709e8e026 100644
--- a/config-ui/src/plugins/components/data-scope-select/index.tsx
+++ b/config-ui/src/plugins/components/data-scope-select/index.tsx
@@ -67,12 +67,22 @@ export const DataScopeSelect = ({
const res = await API.getDataScope(plugin, connectionId, { page, pageSize });
setItems([
...items,
- ...res.scopes.map((sc) => ({
- parentId: null,
- id: getPluginScopeId(plugin, sc.scope),
- title: sc.scope.name,
- data: sc.scope,
- })),
+ ...res.scopes.map((sc) => {
+ if (['github', 'gitlab'].includes(plugin)) {
+ return {
+ parentId: null,
+ id: getPluginScopeId(plugin, sc.scope),
+ title: sc.scope.name,
+ data: sc,
+ };
+ }
+ return {
+ parentId: null,
+ id: getPluginScopeId(plugin, sc),
+ title: sc.name,
+ data: sc,
+ };
+ }),
]);
if (page === 1) {
setTotal(res.count);
@@ -138,7 +148,7 @@ export const DataScopeSelect = ({
<div className="search">
<MultiSelector
loading={!ready}
- items={data?.scopes.map((sc) => sc.scope) ?? []}
+ items={data?.scopes.map((sc) => (['github', 'gitlab'].includes(plugin) ? sc.scope : sc)) ?? []}
getName={(it) => it.name}
getKey={(it) => getPluginScopeId(plugin, it)}
noResult="No Data Scopes Available."