feat(datasource): reveal pre-existing selections in lazily-loaded picker
When editing a data source whose tree loads one level at a time (Feishu
wiki), a saved deep-node selection was invisible: only top-level spaces
were listed, so the selected node could not be seen and its ancestor
space rendered as unchecked.
- Add Connector.ResolveResourceAncestors: given selected resource IDs,
return the ancestor IDs that must be expanded to reveal them. Feishu
walks up via GetWikiNode (O(depth) per selection, no full-tree walk);
Notion/Yuque return empty.
- Fix wikiNode.ParentNodeID JSON tag: the Feishu API field is
parent_node_token, not parent_node_id, so GetWikiNode can return the
parent and the ancestor walk works in production.
- Expose POST /datasource/{id}/resource-ancestors (service + handler +
route) and a matching frontend API client.
- Edit-mode picker reveals hidden selections by expanding and lazily
loading each ancestor level, so selections are visible and checked.
- Gate child fetching on treeFullyLoaded instead of a partial-children
heuristic, avoiding a redundant request for full-tree connectors.
This commit is contained in:
@@ -103,6 +103,13 @@ export function listResources(id: string, parentId?: string) {
|
||||
return get(`/api/v1/datasource/${id}/resources${query}`, { timeout: 120000 })
|
||||
}
|
||||
|
||||
// resolveResourceAncestors returns the ExternalIDs of every parent that must be
|
||||
// expanded to reveal the given (possibly deeply nested) selections in a lazily
|
||||
// loaded picker. Used when editing a data source to restore an existing selection.
|
||||
export function resolveResourceAncestors(id: string, resourceIds: string[]) {
|
||||
return post(`/api/v1/datasource/${id}/resource-ancestors`, { resource_ids: resourceIds }, { timeout: 120000 })
|
||||
}
|
||||
|
||||
export function triggerSync(id: string) {
|
||||
return post(`/api/v1/datasource/${id}/sync`, {})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user