Skip to content

Commit a3372a8

Browse files
committed
canItBeOpened
1 parent a9eb158 commit a3372a8

File tree

2 files changed

+34
-23
lines changed

2 files changed

+34
-23
lines changed

services/static-webserver/client/source/class/osparc/workbench/ServiceCatalog.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,22 @@ qx.Class.define("osparc.workbench.ServiceCatalog", {
8282
statics: {
8383
LATEST: "latest",
8484
Width: 580,
85-
Height: 500
85+
Height: 500,
86+
87+
canItBeOpened: function(study) {
88+
if (study) {
89+
if (study.isReadOnly()) {
90+
osparc.FlashMessenger.logError("Nodes can't be added to a read-only project");
91+
return false;
92+
}
93+
if (study.isPipelineRunning()) {
94+
osparc.FlashMessenger.logError(osparc.data.model.Workbench.CANT_ADD_NODE);
95+
return false;
96+
}
97+
return true;
98+
}
99+
return false;
100+
},
86101
},
87102

88103
members: {

services/static-webserver/client/source/class/osparc/workbench/WorkbenchUI.js

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -293,29 +293,25 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
293293
},
294294

295295
openServiceCatalog: function(nodePos) {
296-
if (this.getStudy().isReadOnly()) {
297-
return null;
298-
}
299-
if (this.getStudy().isPipelineRunning()) {
300-
osparc.FlashMessenger.logError(osparc.data.model.Workbench.CANT_ADD_NODE);
301-
return null;
296+
if (osparc.workbench.ServiceCatalog.canItBeOpened(this.getStudy())) {
297+
const srvCat = new osparc.workbench.ServiceCatalog();
298+
srvCat.addListener("addService", async e => {
299+
const {
300+
service,
301+
nodeLeftId,
302+
nodeRightId
303+
} = e.getData();
304+
const nodeUI = await this.__addNode(service, nodePos);
305+
if (nodeUI && nodeLeftId !== null || nodeRightId !== null) {
306+
const newNodeId = nodeUI.getNodeId();
307+
this._createEdgeBetweenNodes(nodeLeftId ? nodeLeftId : newNodeId, nodeRightId ? nodeRightId : newNodeId, true);
308+
}
309+
}, this);
310+
srvCat.center();
311+
srvCat.open();
312+
return srvCat;
302313
}
303-
const srvCat = new osparc.workbench.ServiceCatalog();
304-
srvCat.addListener("addService", async e => {
305-
const {
306-
service,
307-
nodeLeftId,
308-
nodeRightId
309-
} = e.getData();
310-
const nodeUI = await this.__addNode(service, nodePos);
311-
if (nodeUI && nodeLeftId !== null || nodeRightId !== null) {
312-
const newNodeId = nodeUI.getNodeId();
313-
this._createEdgeBetweenNodes(nodeLeftId ? nodeLeftId : newNodeId, nodeRightId ? nodeRightId : newNodeId, true);
314-
}
315-
}, this);
316-
srvCat.center();
317-
srvCat.open();
318-
return srvCat;
314+
return null;
319315
},
320316

321317
__createTemporaryNodeUI: function(pos) {

0 commit comments

Comments
 (0)