Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[#5042] fix(ui): show the expend arrow when reload tree node (#5043)

Qian Xia2e5bdbf3bb82
diff --git a/web/web/src/app/metalakes/metalake/MetalakeTree.js b/web/web/src/app/metalakes/metalake/MetalakeTree.js
index cf1cca7ee9..58b7c138bf 100644
--- a/web/web/src/app/metalakes/metalake/MetalakeTree.js
+++ b/web/web/src/app/metalakes/metalake/MetalakeTree.js
@@ -111,7 +111,7 @@ const MetalakeTree = props => {
break
}
default:
- dispatch(setIntoTreeNodeWithFetch({ key: nodeProps.data.key }))
+ dispatch(setIntoTreeNodeWithFetch({ key: nodeProps.data.key, reload: true }))
}
}
diff --git a/web/web/src/lib/store/metalakes/index.js b/web/web/src/lib/store/metalakes/index.js
index b0cc84c499..5dd5550100 100644
--- a/web/web/src/lib/store/metalakes/index.js
+++ b/web/web/src/lib/store/metalakes/index.js
@@ -96,7 +96,7 @@ export const updateMetalake = createAsyncThunk('appMetalakes/updateMetalake', as
export const setIntoTreeNodeWithFetch = createAsyncThunk(
'appMetalakes/setIntoTreeNodeWithFetch',
- async ({ key }, { getState, dispatch }) => {
+ async ({ key, reload }, { getState, dispatch }) => {
let result = {
key,
data: [],
@@ -137,20 +137,42 @@ export const setIntoTreeNodeWithFetch = createAsyncThunk(
}
const { identifiers = [] } = res
+ const expandedKeys = getState().metalakes.expandedNodes
+ const loadedNodes = getState().metalakes.loadedNodes
+ let reloadedEpxpandedKeys = []
+ let reloadedKeys = []
result.data = identifiers.map(schemaItem => {
+ if (reload) {
+ if (expandedKeys.includes(`{{${metalake}}}{{${catalog}}}{{${type}}}{{${schemaItem.name}}}`)) {
+ reloadedEpxpandedKeys.push(`{{${metalake}}}{{${catalog}}}{{${type}}}{{${schemaItem.name}}}`)
+ }
+ if (loadedNodes.includes(`{{${metalake}}}{{${catalog}}}{{${type}}}{{${schemaItem.name}}}`)) {
+ reloadedKeys.push(`{{${metalake}}}{{${catalog}}}{{${type}}}{{${schemaItem.name}}}`)
+ }
+ }
+
return {
...schemaItem,
node: 'schema',
id: `{{${metalake}}}{{${catalog}}}{{${type}}}{{${schemaItem.name}}}`,
key: `{{${metalake}}}{{${catalog}}}{{${type}}}{{${schemaItem.name}}}`,
path: `?${new URLSearchParams({ metalake, catalog, type, schema: schemaItem.name }).toString()}`,
+ isLeaf: reload ? false : undefined,
name: schemaItem.name,
title: schemaItem.name,
tables: [],
children: []
}
})
+ if (reloadedEpxpandedKeys.length > 0) {
+ const epxpanded = expandedKeys.filter(key => !reloadedEpxpandedKeys.includes(key))
+ dispatch(resetExpandNode(epxpanded))
+ }
+ if (reloadedKeys.length > 0) {
+ const loaded = loadedNodes.filter(key => !reloadedKeys.includes(key))
+ dispatch(setLoadedNodes(loaded))
+ }
} else if (pathArr.length === 4 && type === 'relational') {
const [err, res] = await to(getTablesApi({ metalake, catalog, schema }))
@@ -933,7 +955,7 @@ export const appMetalakesSlice = createSlice({
state.expandedNodes = expandedNodes
},
resetExpandNode(state, action) {
- state.expandedNodes = []
+ state.expandedNodes = action.payload || []
},
resetTableData(state, action) {
state.tableData = []
diff --git a/web/web/src/lib/utils/index.js b/web/web/src/lib/utils/index.js
index bcb04c6623..1524f1a23a 100644
--- a/web/web/src/lib/utils/index.js
+++ b/web/web/src/lib/utils/index.js
@@ -144,12 +144,14 @@ export const updateTreeData = (list = [], key, children = []) => {
if (node.key === key) {
return {
...node,
+ isLeaf: children?.length === 0,
children
}
}
- if (node.children) {
+ if (node.children && node.children.length > 0) {
return {
...node,
+ isLeaf: node.children.length === 0,
children: updateTreeData(node.children, key, children)
}
}