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 669121b66 fix(config-ui): improve data scope remote select component
(#6599)
669121b66 is described below
commit 669121b660cae3f3b9666f5a4b9f9990ecdb6c2f
Author: 青湛 <[email protected]>
AuthorDate: Mon Dec 11 11:50:38 2023 +0800
fix(config-ui): improve data scope remote select component (#6599)
---
.../components/data-scope-remote/search-local.tsx | 31 ++++++++++++----------
.../components/data-scope-remote/search-remote.tsx | 31 ++++++++++++----------
2 files changed, 34 insertions(+), 28 deletions(-)
diff --git
a/config-ui/src/plugins/components/data-scope-remote/search-local.tsx
b/config-ui/src/plugins/components/data-scope-remote/search-local.tsx
index de090b3ca..9dd819b58 100644
--- a/config-ui/src/plugins/components/data-scope-remote/search-local.tsx
+++ b/config-ui/src/plugins/components/data-scope-remote/search-local.tsx
@@ -18,7 +18,7 @@
import { useState, useEffect, useMemo } from 'react';
import { CheckCircleFilled } from '@ant-design/icons';
-import { Form, Select, Button, Input, Modal, message } from 'antd';
+import { Form, Space, Tag, Button, Input, Modal, message } from 'antd';
import type { McsID, McsItem, McsColumn } from 'miller-columns-select';
import { MillerColumnsSelect } from 'miller-columns-select';
import { useDebounce } from 'ahooks';
@@ -61,11 +61,6 @@ export const SearchLocal = ({ plugin, connectionId, config,
disabledScope, selec
const [query, setQuery] = useState('');
const search = useDebounce(query, { wait: 500 });
- const [selectedIds, selectedOptions] = useMemo(
- () => [selectedScope.map((sc) => sc.id), selectedScope.map((sc) => ({
label: sc.fullName, value: sc.id }))],
- [selectedScope],
- );
-
const scopes = useMemo(
() =>
search
@@ -192,14 +187,22 @@ export const SearchLocal = ({ plugin, connectionId,
config, disabledScope, selec
return (
<Form layout="vertical">
<Form.Item label={config.title} required>
- <Select
- style={{ width: '100%' }}
- disabled
- suffixIcon={null}
- mode="tags"
- value={selectedIds}
- options={selectedOptions}
- />
+ <Space wrap>
+ {selectedScope.length ? (
+ selectedScope.map((sc) => (
+ <Tag
+ key={sc.id}
+ color="blue"
+ closable
+ onClose={() => onChange(selectedScope.filter((it) => it.id !==
sc.id))}
+ >
+ {sc.fullName}
+ </Tag>
+ ))
+ ) : (
+ <span>Please select scope...</span>
+ )}
+ </Space>
</Form.Item>
<Form.Item>
{(status === 'loading' || status === 'cancel') && (
diff --git
a/config-ui/src/plugins/components/data-scope-remote/search-remote.tsx
b/config-ui/src/plugins/components/data-scope-remote/search-remote.tsx
index 12b3eeb34..0d8d92f74 100644
--- a/config-ui/src/plugins/components/data-scope-remote/search-remote.tsx
+++ b/config-ui/src/plugins/components/data-scope-remote/search-remote.tsx
@@ -18,7 +18,7 @@
import { useState, useEffect, useMemo } from 'react';
import { SearchOutlined } from '@ant-design/icons';
-import { Form, Select, Input, message } from 'antd';
+import { Form, Space, Tag, Input, message } from 'antd';
import type { McsID, McsItem, McsColumn } from 'miller-columns-select';
import MillerColumnsSelect from 'miller-columns-select';
import { useDebounce } from 'ahooks';
@@ -68,11 +68,6 @@ export const SearchRemote = ({ plugin, connectionId, config,
disabledScope, sele
const searchDebounce = useDebounce(search.query, { wait: 500 });
- const [selectedIds, selectedOptions] = useMemo(
- () => [selectedScope.map((sc) => sc.id), selectedScope.map((sc) => ({
label: sc.fullName, value: sc.id }))],
- [selectedScope],
- );
-
const allItems = useMemo(
() =>
uniqBy(
@@ -156,14 +151,22 @@ export const SearchRemote = ({ plugin, connectionId,
config, disabledScope, sele
return (
<Form layout="vertical">
<Form.Item label={config.title} required>
- <Select
- style={{ width: '100%' }}
- disabled
- suffixIcon={null}
- mode="tags"
- value={selectedIds}
- options={selectedOptions}
- />
+ <Space wrap>
+ {selectedScope.length ? (
+ selectedScope.map((sc) => (
+ <Tag
+ key={sc.id}
+ color="blue"
+ closable
+ onClose={() => onChange(selectedScope.filter((it) => it.id !==
sc.id))}
+ >
+ {sc.fullName}
+ </Tag>
+ ))
+ ) : (
+ <span>Please select scope...</span>
+ )}
+ </Space>
</Form.Item>
<Form.Item>
<Input