KaotoIO / kaoto

The UI of the Kaoto project
https://kaoto.io
Apache License 2.0
38 stars 29 forks source link

feat(IVizNode): Get All Visualization nodes #1573

Closed lordrip closed 1 month ago

lordrip commented 1 month ago

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: https://github.com/KaotoIO/kaoto/pull/1574

sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.