Skip to content

Commit

Permalink
Merge pull request #14 from Xide/fix/attribute-dependencies
Browse files Browse the repository at this point in the history
fix(graph): allow rendering of attributes dependencies
  • Loading branch information
im2nguyen authored Aug 26, 2021
2 parents 65f27d5 + 692dc57 commit 1fa5b94
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion ui/src/components/Graph/Graph.vue
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,9 @@ export default {
let vm = this;
let cy = this.$refs.cy.instance;
let el = cy.elements();
const nodesNames = this.graph.nodes.map(
x => x.data.id
)
// Reset graph
cy.remove(el);
Expand All @@ -333,6 +336,23 @@ export default {
if (n.data.id.includes("-variable") || n.data.id.includes("-output")) {
return;
}
// Browse node ancestors if target is not found in nodes
// e.g: resource.test.attribute will not be in nodes, as attributes are not exported
// this ensures that the dependency will be made on resource.test instead
let name = n.data.target
while (!nodesNames.includes(name)) {
name = name.split('.')
if (name.length < 2) {
console.warn("edge target", n.data.target, "not found in nodes")
return
}
name.pop()
name = name.join('.')
}
n.data.target = name
// Add edge to the final graph
cy.add(n);
});
Expand Down Expand Up @@ -623,4 +643,4 @@ fieldset {
margin: 0;
opacity: 0;
}
</style>
</style>

0 comments on commit 1fa5b94

Please sign in to comment.