You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by mi...@apache.org on 2023/08/07 07:36:22 UTC
[incubator-devlake] 01/01: fix(config-ui): missed full name when data doesn't include full name (#5808)
This is an automated email from the ASF dual-hosted git repository.
mintsweet pushed a commit to branch release-v0.18-cp-5808
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit 9aeabb50c3ad00aca4a8ce86e3db8154bc269257
Author: 青湛 <0x...@gmail.com>
AuthorDate: Mon Aug 7 17:29:11 2023 +1200
fix(config-ui): missed full name when data doesn't include full name (#5808)
---
.../components/data-scope-miller-columns/index.tsx | 4 +--
.../plugins/components/data-scope-search/index.tsx | 2 +-
.../components/data-scope-select-remote/index.tsx | 41 +++++++++-------------
3 files changed, 19 insertions(+), 28 deletions(-)
diff --git a/config-ui/src/plugins/components/data-scope-miller-columns/index.tsx b/config-ui/src/plugins/components/data-scope-miller-columns/index.tsx
index 3f9585bf9..97396786f 100644
--- a/config-ui/src/plugins/components/data-scope-miller-columns/index.tsx
+++ b/config-ui/src/plugins/components/data-scope-miller-columns/index.tsx
@@ -96,11 +96,11 @@ export const DataScopeMillerColumns = ({
const result = selectedIds.map((id) => {
const selectedItem = (selectedItems ?? []).find((it) => it.id === id);
if (selectedItem) {
- return selectedItem.data;
+ return selectedItem;
}
const item = items.find((it) => it.id === id) as McsItem<ExtraType>;
- return item.data;
+ return item;
});
onChangeItems ? onChangeItems(result) : setSelectedIds(selectedIds);
diff --git a/config-ui/src/plugins/components/data-scope-search/index.tsx b/config-ui/src/plugins/components/data-scope-search/index.tsx
index 96620ea0e..8464930be 100644
--- a/config-ui/src/plugins/components/data-scope-search/index.tsx
+++ b/config-ui/src/plugins/components/data-scope-search/index.tsx
@@ -51,7 +51,7 @@ export const DataScopeSearch = ({ plugin, connectionId, disabledItems, selectedI
const getName = (it: ItemType) => it.fullName;
- const handleChangeItems = (selectedItems: ItemType[]) => onChangeItems?.(selectedItems.map((it) => it.data));
+ const handleChangeItems = (selectedItems: ItemType[]) => onChangeItems?.(selectedItems);
return (
<MultiSelector
diff --git a/config-ui/src/plugins/components/data-scope-select-remote/index.tsx b/config-ui/src/plugins/components/data-scope-select-remote/index.tsx
index 3fa6cc0c2..3b5565224 100644
--- a/config-ui/src/plugins/components/data-scope-select-remote/index.tsx
+++ b/config-ui/src/plugins/components/data-scope-select-remote/index.tsx
@@ -39,34 +39,25 @@ interface Props {
export const DataScopeSelectRemote = ({ plugin, connectionId, disabledScope, onCancel, onSubmit }: Props) => {
const [operating, setOperating] = useState(false);
- const [scope, setScope] = useState<any>([]);
-
- const pluginConfig = useMemo(() => getPluginConfig(plugin), [plugin]);
-
- const error = useMemo(() => (!scope.length ? 'No Data Scope is Selected' : ''), [scope]);
-
- const selectedItems = useMemo(
- () =>
- scope.map((it: any) => ({ id: getPluginScopeId(plugin, it), name: it.name, fullName: it.fullName, data: it })),
- [scope],
- );
+ const [selectedItems, setSelectedItems] = useState<Array<{ data: any }>>([]);
const disabledItems = useMemo(
- () =>
- (disabledScope ?? []).map((it) => ({
- id: getPluginScopeId(plugin, it),
- name: it.name,
- fullName: it.fullName,
- data: it,
- })),
+ () => (disabledScope ?? []).map((it) => ({ id: getPluginScopeId(plugin, it) })),
[disabledScope],
);
+ const pluginConfig = useMemo(() => getPluginConfig(plugin), [plugin]);
+
+ const error = useMemo(() => (!selectedItems.length ? 'No Data Scope is Selected' : ''), [selectedItems]);
+
const handleSubmit = async () => {
- const [success, res] = await operator(() => API.updateDataScope(plugin, connectionId, { data: scope }), {
- setOperating,
- formatMessage: () => 'Add data scope successful.',
- });
+ const [success, res] = await operator(
+ () => API.updateDataScope(plugin, connectionId, { data: selectedItems.map((it) => it.data) }),
+ {
+ setOperating,
+ formatMessage: () => 'Add data scope successful.',
+ },
+ );
if (success) {
onSubmit(res);
@@ -81,7 +72,7 @@ export const DataScopeSelectRemote = ({ plugin, connectionId, disabledScope, onC
connectionId,
disabledItems,
selectedItems,
- onChangeItems: setScope,
+ onChangeItems: setSelectedItems,
})
) : (
<>
@@ -94,7 +85,7 @@ export const DataScopeSelectRemote = ({ plugin, connectionId, disabledScope, onC
connectionId={connectionId}
disabledItems={disabledItems}
selectedItems={selectedItems}
- onChangeItems={setScope}
+ onChangeItems={setSelectedItems}
/>
{pluginConfig.dataScope.search && (
<>
@@ -105,7 +96,7 @@ export const DataScopeSelectRemote = ({ plugin, connectionId, disabledScope, onC
connectionId={connectionId}
disabledItems={disabledItems}
selectedItems={selectedItems}
- onChangeItems={setScope}
+ onChangeItems={setSelectedItems}
/>
</>
)}