Initial commit

Co-Authored-By: Eric Tuvesson <eric.tuvesson@gmail.com>
Co-Authored-By: mikaeltellhed <2311083+mikaeltellhed@users.noreply.github.com>
Co-Authored-By: kotte <14197736+mrtamagotchi@users.noreply.github.com>
Co-Authored-By: Anders Larsson <64838990+anders-topp@users.noreply.github.com>
Co-Authored-By: Johan  <4934465+joolsus@users.noreply.github.com>
Co-Authored-By: Tore Knudsen <18231882+torekndsn@users.noreply.github.com>
Co-Authored-By: victoratndl <99176179+victoratndl@users.noreply.github.com>
This commit is contained in:
Michael Cartner
2024-01-26 11:52:55 +01:00
commit b9c60b07dc
2789 changed files with 868795 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
export default class GraphWarnings {
constructor(graphModel, editorConnection) {
this.graphModel = graphModel;
this.editorConnection = editorConnection;
this.graphModel.getAllComponents().forEach((c) => this._bindComponentModel(c));
this.graphModel.on('componentAdded', (c) => this._bindComponentModel(c), this);
this.graphModel.on('componentRemoved', (c) => c.removeListenersWithRef(this), this);
}
_bindComponentModel(c) {
c.on('rootAdded', () => this._evaluateWarnings(c), this);
c.on(
'rootRemoved',
(root) => {
this.editorConnection.clearWarning(c.name, root, 'multiple-visual-roots-warning');
this._evaluateWarnings(c);
},
this
);
this._evaluateWarnings(c);
}
_evaluateWarnings(c) {
const roots = c.getRoots();
if (roots.lenth === 0) return;
this.editorConnection.clearWarning(c.name, roots[0], 'multiple-visual-roots-warning');
for (let i = 1; i < roots.length; i++) {
this.editorConnection.sendWarning(c.name, roots[i], 'multiple-visual-roots-warning', {
message: "This node is detached from the main node tree<br>and won't be rendered",
level: 'info'
});
}
}
dispose() {
this.graphModel.getAllComponents().forEach((c) => {
c.removeListenersWithRef(this);
});
this.graphModel.removeListenersWithRef(this);
}
}