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:
@@ -27,6 +27,20 @@ type Connector interface {
|
||||
// non-empty parentID.
|
||||
ListResources(ctx context.Context, config *types.DataSourceConfig, parentID string) ([]types.Resource, error)
|
||||
|
||||
// ResolveResourceAncestors resolves, for each of the given resource IDs, the
|
||||
// ExternalIDs of every ancestor whose direct children must be loaded so a
|
||||
// lazily-loaded picker can reveal a pre-existing (possibly deeply nested)
|
||||
// selection. The returned set is deduplicated and unordered.
|
||||
//
|
||||
// It exists so connectors that load their tree one level at a time (e.g. the
|
||||
// Feishu wiki) can expose, in O(depth) per selection, the path back to the
|
||||
// root without re-traversing the whole tree. Connectors that already return
|
||||
// the full tree (Notion) or a flat list (Yuque) have nothing to reveal and
|
||||
// return an empty slice.
|
||||
ResolveResourceAncestors(
|
||||
ctx context.Context, config *types.DataSourceConfig, resourceIDs []string,
|
||||
) ([]string, error)
|
||||
|
||||
// FetchAll performs a full sync of the specified resources.
|
||||
// Returns all items from the given resource IDs.
|
||||
FetchAll(ctx context.Context, config *types.DataSourceConfig, resourceIDs []string) ([]types.FetchedItem, error)
|
||||
|
||||
Reference in New Issue
Block a user