Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(IVizNode): Get All Visualization nodes #1573

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

lordrip
Copy link
Member

@lordrip lordrip commented Oct 14, 2024

Context

A frequent use case for the Canvas is to identify nodes, unfortunately, there's no easy way to find nodes using a predicate.

Changes

This PR allows finding nodes given a predicate or retrieving all nodes if no predicate has been provided.

How to use?

// First we obtain the `VisualizationController`
const controller = useVisualizationController();

// Second, we define a predicate
const predicate = (vizNode: IVisualizationNode) => {
  return vizNode.getComponentSchema()?.definition?.disabled;
};

// Lastly, we use the `getVisualizationNodesFromGraph` function to find the nodes
const vizNodes = getVisualizationNodesFromGraph(visualizationController.getGraph(), predicate);

Prerequisite of: #1574

A frequent use case for the Canvas is to identify nodes, unfortunately, there's no easy way to find nodes using a predicate.

This commit allows finding nodes given a predicate or retrieving all nodes if no predicate has been provided.

* How to use?
```typescript
// First we obtain the `VisualizationController`
const controller = useVisualizationController();

// Second, we define a predicate
const predicate = (vizNode: IVisualizationNode) => {
  return vizNode.getComponentSchema()?.definition?.disabled;
};

// Lastly, we use the `getVisualizationNodesFromGraph` function to find the nodes
const vizNodes = getVisualizationNodesFromGraph(visualizationController.getGraph(), predicate);
```
Copy link

sonarcloud bot commented Oct 14, 2024

Copy link

codecov bot commented Oct 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (main@6823d5a). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1573   +/-   ##
=======================================
  Coverage        ?   79.96%           
  Complexity      ?      272           
=======================================
  Files           ?      277           
  Lines           ?     7880           
  Branches        ?     1546           
=======================================
  Hits            ?     6301           
  Misses          ?     1470           
  Partials        ?      109           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lordrip lordrip merged commit d985f82 into KaotoIO:main Oct 15, 2024
11 of 12 checks passed
@lordrip lordrip deleted the feat/get-all-visualization-nodes branch October 15, 2024 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants