Skip to content

Commit 57c704a

Browse files
authored
Permission policies (#731)
* LinkButton and LinkLabel moved * Project -> Study * default hardcoded permissions added * Added some restrictions * Link -> Edge * Moved permission checks to data level * Set Default Role * more permission checks * token permission checks * datcore read permission check * study.node.data.* permission check * study.node.rename permission check * services.filtered.read permission check * fixed plotly minor bug * Test permissions * Moved some removeNode code to Workbench * Moved removeEdge code to Workbench * test edge create/delete * test node rename * deserializeNodes and deserializeEdges added * deserializeEdges fixed for 'outputNode's * got rid of canStart * Typo: presgined -> presigned * do not allow anonymous users to add/delete tokens * do not allow anonymous users to update user profile
1 parent 4037c5e commit 57c704a

27 files changed

+668
-335
lines changed

services/web/client/source/class/qxapp/component/widget/NodeInOut.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ qx.Class.define("qxapp.component.widget.NodeInOut", {
7171
},
7272

7373
events: {
74-
"linkDragStart": "qx.event.type.Data",
75-
"linkDragOver": "qx.event.type.Data",
76-
"linkDrop": "qx.event.type.Data",
77-
"linkDragEnd": "qx.event.type.Data"
74+
"edgeDragStart": "qx.event.type.Data",
75+
"edgeDragOver": "qx.event.type.Data",
76+
"edgeDrop": "qx.event.type.Data",
77+
"edgeDragEnd": "qx.event.type.Data"
7878
},
7979

8080
members: {
@@ -137,10 +137,10 @@ qx.Class.define("qxapp.component.widget.NodeInOut", {
137137

138138
__createUIPortConnections: function(uiPort, isInput) {
139139
[
140-
["dragstart", "linkDragStart"],
141-
["dragover", "linkDragOver"],
142-
["drop", "linkDrop"],
143-
["dragend", "linkDragEnd"]
140+
["dragstart", "edgeDragStart"],
141+
["dragover", "edgeDragOver"],
142+
["drop", "edgeDrop"],
143+
["dragend", "edgeDragEnd"]
144144
].forEach(eventPair => {
145145
uiPort.addListener(eventPair[0], e => {
146146
const eData = {

services/web/client/source/class/qxapp/component/widget/NodesTree.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ qx.Class.define("qxapp.component.widget.NodesTree", {
115115
}, this);
116116
let renameButton = new qx.ui.toolbar.Button("Rename", "@FontAwesome5Solid/i-cursor/"+iconSize);
117117
renameButton.addListener("execute", e => {
118-
this.__renameNode();
118+
this.__openItemRenamer();
119119
}, this);
120120
part2.add(deleteButton);
121121
part2.add(renameButton);
@@ -236,19 +236,21 @@ qx.Class.define("qxapp.component.widget.NodesTree", {
236236
this.fireDataEvent("removeNode", selectedItem.getNodeId());
237237
},
238238

239-
__renameNode: function() {
240-
let selectedItem = this.__getSelection();
239+
__openItemRenamer: function() {
240+
const selectedItem = this.__getSelection();
241241
if (selectedItem === null) {
242242
return;
243243
}
244244

245-
let treeItemRenamer = new qxapp.component.widget.TreeItemRenamer(selectedItem);
245+
const treeItemRenamer = new qxapp.component.widget.TreeItemRenamer(selectedItem);
246246
treeItemRenamer.addListener("labelChanged", e => {
247247
const data = e.getData();
248248
const newLabel = data.newLabel;
249249
const nodeId = selectedItem.getNodeId();
250-
let node = this.getWorkbench().getNode(nodeId);
251-
node.setLabel(newLabel);
250+
const node = this.getWorkbench().getNode(nodeId);
251+
if (node) {
252+
node.renameNode(newLabel);
253+
}
252254
}, this);
253255
const bounds = this.getLayoutParent().getContentLocation();
254256
treeItemRenamer.moveTo(bounds.left + 100, bounds.top + 150);
@@ -274,7 +276,7 @@ qx.Class.define("qxapp.component.widget.NodesTree", {
274276
}, this);
275277
this.addListener("keypress", function(keyEvent) {
276278
if (keyEvent.getKeyIdentifier() === "F2") {
277-
this.__renameNode();
279+
this.__openItemRenamer();
278280
}
279281
}, this);
280282
}

services/web/client/source/class/qxapp/component/workbench/EdgeUI.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
* Here is a little example of how to use the widget.
2424
*
2525
* <pre class='javascript'>
26-
* let link = new qxapp.data.model.Edge(linkId, node1Id, node2Id);
27-
* let linkRepresentation = svgWidget.drawCurve(x1, y1, x2, y2);
28-
* let linkUI = new qxapp.component.workbench.EdgeUI(link, linkRepresentation);
26+
* let edge = new qxapp.data.model.Edge(edgeId, node1Id, node2Id);
27+
* let edgeRepresentation = svgWidget.drawCurve(x1, y1, x2, y2);
28+
* let edgeUI = new qxapp.component.workbench.EdgeUI(edge, edgeRepresentation);
2929
* </pre>
3030
*/
3131

@@ -35,8 +35,8 @@ qx.Class.define("qxapp.component.workbench.EdgeUI", {
3535
implement: qxapp.component.filter.IFilterable,
3636

3737
/**
38-
* @param link {qxapp.data.model.Edge} Edge owning the object
39-
* @param representation {SVG Object} UI representation of the link
38+
* @param edge {qxapp.data.model.Edge} Edge owning the object
39+
* @param representation {SVG Object} UI representation of the edge
4040
*/
4141
construct: function(edge, representation) {
4242
this.base();
@@ -48,7 +48,7 @@ qx.Class.define("qxapp.component.workbench.EdgeUI", {
4848
},
4949

5050
events: {
51-
"linkSelected": "qx.event.type.Data"
51+
"edgeSelected": "qx.event.type.Data"
5252
},
5353

5454
properties: {

services/web/client/source/class/qxapp/component/workbench/NodeUI.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ qx.Class.define("qxapp.component.workbench.NodeUI", {
7979
},
8080

8181
events: {
82-
"linkDragStart": "qx.event.type.Data",
83-
"linkDragOver": "qx.event.type.Data",
84-
"linkDrop": "qx.event.type.Data",
85-
"linkDragEnd": "qx.event.type.Data",
82+
"edgeDragStart": "qx.event.type.Data",
83+
"edgeDragOver": "qx.event.type.Data",
84+
"edgeDrop": "qx.event.type.Data",
85+
"edgeDragEnd": "qx.event.type.Data",
8686
"nodeMoving": "qx.event.type.Event"
8787
},
8888

@@ -197,10 +197,10 @@ qx.Class.define("qxapp.component.workbench.NodeUI", {
197197

198198
__createUIPortConnections: function(uiPort, isInput) {
199199
[
200-
["dragstart", "linkDragStart"],
201-
["dragover", "linkDragOver"],
202-
["drop", "linkDrop"],
203-
["dragend", "linkDragEnd"]
200+
["dragstart", "edgeDragStart"],
201+
["dragover", "edgeDragOver"],
202+
["drop", "edgeDrop"],
203+
["dragend", "edgeDragEnd"]
204204
].forEach(eventPair => {
205205
uiPort.addListener(eventPair[0], e => {
206206
const eData = {

services/web/client/source/class/qxapp/component/workbench/SvgWidget.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ qx.Class.define("qxapp.component.workbench.SvgWidget", {
4545
qx.bom.element.Attribute.set(el, "id", svgLayerId);
4646
this.__svgWrapper = new qxapp.wrapper.Svg();
4747
this.__svgWrapper.addListener(("svgLibReady"), () => {
48-
this.__linksCanvas = this.__svgWrapper.createEmptyCanvas(svgLayerId);
48+
this.__edgesCanvas = this.__svgWrapper.createEmptyCanvas(svgLayerId);
4949
this.fireDataEvent("SvgWidgetReady", true);
5050
});
5151
this.__svgWrapper.init();
@@ -58,7 +58,7 @@ qx.Class.define("qxapp.component.workbench.SvgWidget", {
5858

5959
members: {
6060
__svgWrapper: null,
61-
__linksCanvas: null,
61+
__edgesCanvas: null,
6262

6363
__getControls: function(x1, y1, x2, y2, offset = 60) {
6464
return [{
@@ -78,7 +78,7 @@ qx.Class.define("qxapp.component.workbench.SvgWidget", {
7878

7979
drawCurve: function(x1, y1, x2, y2) {
8080
const controls = this.__getControls(x1, y1, x2, y2);
81-
return this.__svgWrapper.drawCurve(this.__linksCanvas, controls);
81+
return this.__svgWrapper.drawCurve(this.__edgesCanvas, controls);
8282
},
8383

8484
updateCurve: function(curve, x1, y1, x2, y2) {

services/web/client/source/class/qxapp/component/workbench/WorkbenchUI.js

+42-50
Original file line numberDiff line numberDiff line change
@@ -229,17 +229,12 @@ qx.Class.define("qxapp.component.workbench.WorkbenchUI", {
229229
if (this.__currentModel.isContainer()) {
230230
parent = this.__currentModel;
231231
}
232-
let node = this.getWorkbench().createNode(service.getKey(), service.getVersion(), null, parent, true);
233-
234-
const metaData = node.getMetaData();
235-
if (metaData && Object.prototype.hasOwnProperty.call(metaData, "innerNodes")) {
236-
const innerNodeMetaDatas = Object.values(metaData["innerNodes"]);
237-
for (const innerNodeMetaData of innerNodeMetaDatas) {
238-
this.getWorkbench().createNode(innerNodeMetaData.key, innerNodeMetaData.version, null, node, true);
239-
}
232+
const node = this.getWorkbench().createNode(service.getKey(), service.getVersion(), null, parent, true);
233+
if (!node) {
234+
return;
240235
}
241236

242-
let nodeUI = this.__createNodeUI(node.getNodeId());
237+
const nodeUI = this.__createNodeUI(node.getNodeId());
243238
this.__addNodeToWorkbench(nodeUI, pos);
244239

245240
if (nodeAId !== null && portA !== null) {
@@ -308,9 +303,12 @@ qx.Class.define("qxapp.component.workbench.WorkbenchUI", {
308303
return nodeUI;
309304
},
310305

311-
__createEdgeUI: function(node1Id, node2Id, linkId) {
312-
let link = this.getWorkbench().createEdge(linkId, node1Id, node2Id);
313-
if (this.__linkRepresetationExists(link)) {
306+
__createEdgeUI: function(node1Id, node2Id, edgeId) {
307+
const edge = this.getWorkbench().createEdge(edgeId, node1Id, node2Id);
308+
if (!edge) {
309+
return null;
310+
}
311+
if (this.__edgeRepresetationExists(edge)) {
314312
return null;
315313
}
316314

@@ -330,27 +328,27 @@ qx.Class.define("qxapp.component.workbench.WorkbenchUI", {
330328
const y1 = pointList[0] ? pointList[0][1] : 0;
331329
const x2 = pointList[1] ? pointList[1][0] : 0;
332330
const y2 = pointList[1] ? pointList[1][1] : 0;
333-
let linkRepresentation = this.__svgWidget.drawCurve(x1, y1, x2, y2);
331+
const edgeRepresentation = this.__svgWidget.drawCurve(x1, y1, x2, y2);
334332

335-
let linkUI = new qxapp.component.workbench.EdgeUI(link, linkRepresentation);
336-
this.__edgesUI.push(linkUI);
333+
const edgeUI = new qxapp.component.workbench.EdgeUI(edge, edgeRepresentation);
334+
this.__edgesUI.push(edgeUI);
337335

338-
linkUI.getRepresentation().node.addEventListener("click", e => {
336+
edgeUI.getRepresentation().node.addEventListener("click", e => {
339337
// this is needed to get out of the context of svg
340-
linkUI.fireDataEvent("linkSelected", linkUI.getEdgeId());
338+
edgeUI.fireDataEvent("edgeSelected", edgeUI.getEdgeId());
341339
e.stopPropagation();
342340
}, this);
343341

344-
linkUI.addListener("linkSelected", e => {
345-
this.__selectedItemChanged(linkUI.getEdgeId());
342+
edgeUI.addListener("edgeSelected", e => {
343+
this.__selectedItemChanged(edgeUI.getEdgeId());
346344
}, this);
347345

348-
return linkUI;
346+
return edgeUI;
349347
}
350348
return null;
351349
},
352350

353-
__linkRepresetationExists: function(edge) {
351+
__edgeRepresetationExists: function(edge) {
354352
for (let i=0; i<this.__edgesUI.length; i++) {
355353
const edgeUI = this.__edgesUI[i];
356354
if (edgeUI.getEdge().getEdgeId() === edge.getEdgeId()) {
@@ -362,7 +360,7 @@ qx.Class.define("qxapp.component.workbench.WorkbenchUI", {
362360

363361
__createDragDropMechanism: function(nodeUI) {
364362
const evType = "pointermove";
365-
nodeUI.addListener("linkDragStart", e => {
363+
nodeUI.addListener("edgeDragStart", e => {
366364
let data = e.getData();
367365
let event = data.event;
368366
let dragNodeId = data.nodeId;
@@ -389,7 +387,7 @@ qx.Class.define("qxapp.component.workbench.WorkbenchUI", {
389387
);
390388
}, this);
391389

392-
nodeUI.addListener("linkDragOver", e => {
390+
nodeUI.addListener("edgeDragOver", e => {
393391
let data = e.getData();
394392
let event = data.event;
395393
let dropNodeId = data.nodeId;
@@ -411,7 +409,7 @@ qx.Class.define("qxapp.component.workbench.WorkbenchUI", {
411409
}
412410
}, this);
413411

414-
nodeUI.addListener("linkDrop", e => {
412+
nodeUI.addListener("edgeDrop", e => {
415413
let data = e.getData();
416414
let event = data.event;
417415
let dropNodeId = data.nodeId;
@@ -439,7 +437,7 @@ qx.Class.define("qxapp.component.workbench.WorkbenchUI", {
439437
}
440438
}, this);
441439

442-
nodeUI.addListener("linkDragEnd", e => {
440+
nodeUI.addListener("edgeDragEnd", e => {
443441
let data = e.getData();
444442
let dragNodeId = data.nodeId;
445443

@@ -542,34 +540,28 @@ qx.Class.define("qxapp.component.workbench.WorkbenchUI", {
542540
return null;
543541
},
544542

545-
__createEdgeBetweenNodes: function(from, to, linkId) {
546-
let node1Id = from.nodeUuid;
547-
let node2Id = to.nodeUuid;
548-
this.__createEdgeUI(node1Id, node2Id, linkId);
543+
__createEdgeBetweenNodes: function(from, to, edgeId) {
544+
const node1Id = from.nodeUuid;
545+
const node2Id = to.nodeUuid;
546+
this.__createEdgeUI(node1Id, node2Id, edgeId);
549547
},
550548

551-
__createEdgeBetweenNodesAndInputNodes: function(from, to, linkId) {
549+
__createEdgeBetweenNodesAndInputNodes: function(from, to, edgeId) {
552550
const inputNodes = this.__inputNodesLayout.getChildren();
553551
// Children[0] is the title
554552
for (let i = 1; i < inputNodes.length; i++) {
555553
const inputNodeId = inputNodes[i].getNodeId();
556554
if (inputNodeId === from.nodeUuid) {
557555
let node1Id = from.nodeUuid;
558556
let node2Id = to.nodeUuid;
559-
this.__createEdgeUI(node1Id, node2Id, linkId);
557+
this.__createEdgeUI(node1Id, node2Id, edgeId);
560558
}
561559
}
562560
},
563561

564-
__createEdgeToExposedOutputs: function(from, to, linkId) {
565-
let node1Id = from.nodeUuid;
566-
let node2Id = to.nodeUuid;
567-
this.__createEdgeUI(node1Id, node2Id, linkId);
568-
},
569-
570562
__updatePosition: function(nodeUI) {
571563
const cBounds = nodeUI.getCurrentBounds();
572-
let node = this.getWorkbench().getNode(nodeUI.getNodeId());
564+
const node = this.getWorkbench().getNode(nodeUI.getNodeId());
573565
node.setPosition(cBounds.left, cBounds.top);
574566
},
575567

@@ -676,9 +668,9 @@ qx.Class.define("qxapp.component.workbench.WorkbenchUI", {
676668
return null;
677669
},
678670

679-
__getEdgeUI: function(linkId) {
671+
__getEdgeUI: function(edgeId) {
680672
for (let i = 0; i < this.__edgesUI.length; i++) {
681-
if (this.__edgesUI[i].getEdgeId() === linkId) {
673+
if (this.__edgesUI[i].getEdgeId() === edgeId) {
682674
return this.__edgesUI[i];
683675
}
684676
}
@@ -699,12 +691,12 @@ qx.Class.define("qxapp.component.workbench.WorkbenchUI", {
699691
}
700692
},
701693

702-
clearEdge: function(linkId) {
703-
this.__clearEdge(this.__getEdgeUI(linkId));
694+
clearEdge: function(edgeId) {
695+
this.__clearEdge(this.__getEdgeUI(edgeId));
704696
},
705697

706-
__removeEdge: function(link) {
707-
this.fireDataEvent("removeEdge", link.getEdgeId());
698+
__removeEdge: function(edge) {
699+
this.fireDataEvent("removeEdge", edge.getEdgeId());
708700
},
709701

710702
__removeAllEdges: function() {
@@ -735,9 +727,9 @@ qx.Class.define("qxapp.component.workbench.WorkbenchUI", {
735727
}
736728
},
737729

738-
__clearEdge: function(link) {
739-
this.__svgWidget.removeCurve(link.getRepresentation());
740-
let index = this.__edgesUI.indexOf(link);
730+
__clearEdge: function(edge) {
731+
this.__svgWidget.removeCurve(edge.getRepresentation());
732+
let index = this.__edgesUI.indexOf(edge);
741733
if (index > -1) {
742734
this.__edgesUI.splice(index, 1);
743735
}
@@ -805,7 +797,7 @@ qx.Class.define("qxapp.component.workbench.WorkbenchUI", {
805797
for (const innerNodeId in innerNodes) {
806798
const innerNode = innerNodes[innerNodeId];
807799
if (innerNode.getIsOutputNode()) {
808-
this.__createEdgeToExposedOutputs({
800+
this.__createEdgeBetweenNodes({
809801
nodeUuid: innerNode.getNodeId()
810802
}, {
811803
nodeUuid: model.getNodeId()
@@ -829,15 +821,15 @@ qx.Class.define("qxapp.component.workbench.WorkbenchUI", {
829821
if (oldId) {
830822
if (this.__isSelectedItemAnEdge(oldId)) {
831823
const unselectedEdge = this.__getEdgeUI(oldId);
832-
const unselectedColor = qxapp.theme.Color.colors["workbench-link-comp-active"];
824+
const unselectedColor = qxapp.theme.Color.colors["workbench-edge-comp-active"];
833825
this.__svgWidget.updateColor(unselectedEdge.getRepresentation(), unselectedColor);
834826
}
835827
}
836828

837829
this.__selectedItemId = newID;
838830
if (this.__isSelectedItemAnEdge(newID)) {
839831
const selectedEdge = this.__getEdgeUI(newID);
840-
const selectedColor = qxapp.theme.Color.colors["workbench-link-selected"];
832+
const selectedColor = qxapp.theme.Color.colors["workbench-edge-selected"];
841833
this.__svgWidget.updateColor(selectedEdge.getRepresentation(), selectedColor);
842834
} else if (newID) {
843835
this.fireDataEvent("changeSelectedNode", newID);

0 commit comments

Comments
 (0)