Skip to content

Commit 9047535

Browse files
committed
refactor page contexts
1 parent 0742742 commit 9047535

File tree

4 files changed

+23
-54
lines changed

4 files changed

+23
-54
lines changed

services/static-webserver/client/source/class/osparc/desktop/SlideshowView.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ qx.Class.define("osparc.desktop.SlideshowView", {
7272
const nodeId = e.getData();
7373
this.__hideNode(nodeId);
7474
}, this);
75-
slideshowToolbar.addListener("slidesStop", () => this.fireEvent("slidesStop"), this);
75+
slideshowToolbar.addListener("slidesStop", () => this.getStudy().getUi().setMode("workbench"), this);
7676
this._add(slideshowToolbar);
7777

7878
const mainView = this.__mainView = new qx.ui.container.Composite(new qx.ui.layout.HBox().set({
@@ -109,7 +109,6 @@ qx.Class.define("osparc.desktop.SlideshowView", {
109109
},
110110

111111
events: {
112-
"slidesStop": "qx.event.type.Event",
113112
"startPartialPipeline": "qx.event.type.Data",
114113
"stopPipeline": "qx.event.type.Event",
115114
"backToDashboardPressed": "qx.event.type.Event",

services/static-webserver/client/source/class/osparc/desktop/StudyEditor.js

Lines changed: 19 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ qx.Class.define("osparc.desktop.StudyEditor", {
3737
});
3838

3939
workbenchView.addListener("slidesEdit", () => this.__editSlides(), this);
40-
workbenchView.addListener("slidesAppStart", () => this.setPageContext(this.self().PAGE_CONTEXT[2]), this); // "app"
41-
slideshowView.addListener("slidesStop", () => this.setPageContext(this.self().PAGE_CONTEXT[1]), this); // "workbench"
4240

4341
workbenchView.addListener("takeSnapshot", () => this.__takeSnapshot(), this);
4442
workbenchView.addListener("takeSnapshot", () => this.__takeSnapshot(), this);
@@ -72,7 +70,7 @@ qx.Class.define("osparc.desktop.StudyEditor", {
7270
const startStopButtons = workbenchView.getStartStopButtons();
7371
startStopButtons.addListener("startPipeline", () => this.__startPipeline([]), this);
7472
startStopButtons.addListener("startPartialPipeline", () => {
75-
const partialPipeline = this.getPageContext() === "workbench" ? this.__workbenchView.getSelectedNodeIDs() : this.__slideshowView.getSelectedNodeIDs();
73+
const partialPipeline = this.getStudy().getUi().getMode() === "app" ? this.__slideshowView.getSelectedNodeIDs() : this.__workbenchView.getSelectedNodeIDs();
7674
this.__startPipeline(partialPipeline);
7775
}, this);
7876
startStopButtons.addListener("stopPipeline", () => this.__stopPipeline(), this);
@@ -103,26 +101,11 @@ qx.Class.define("osparc.desktop.StudyEditor", {
103101
apply: "__applyStudy",
104102
event: "changeStudy"
105103
},
106-
107-
pageContext: {
108-
check: ["workbench", "guided", "app", "standalone"], // "guided" is no longer used
109-
init: null,
110-
nullable: false,
111-
event: "changePageContext",
112-
apply: "__applyPageContext" // OM
113-
}
114104
},
115105

116106
statics: {
117107
AUTO_SAVE_INTERVAL: 3000,
118108
READ_ONLY_TEXT: qx.locale.Manager.tr("You do not have writing permissions.<br>Your changes will not be saved."),
119-
120-
PAGE_CONTEXT: {
121-
0: "dashboard",
122-
1: "workbench",
123-
2: "app",
124-
3: "standalone",
125-
},
126109
},
127110

128111
members: {
@@ -186,6 +169,8 @@ qx.Class.define("osparc.desktop.StudyEditor", {
186169
}
187170
}, this);
188171
}
172+
173+
study.getUi().addListener("changeMode", e => this.__uiModeChanged(e.getData()));
189174
})
190175
.catch(err => {
191176
console.error(err);
@@ -258,23 +243,9 @@ qx.Class.define("osparc.desktop.StudyEditor", {
258243
osparc.FlashMessenger.getInstance().logAs(msg, "WARNING");
259244
}
260245

261-
const pageContext = study.getUi().getMode();
262-
switch (pageContext) {
263-
case "guided":
264-
case "app":
265-
this.__slideshowView.startSlides();
266-
break;
267-
case "workbench":
268-
case "standalone":
269-
default:
270-
this.__workbenchView.openFirstNode();
271-
break;
272-
}
273-
this.addListener("changePageContext", e => {
274-
const pageCxt = e.getData();
275-
study.getUi().setMode(pageCxt);
276-
});
277-
this.setPageContext(pageContext);
246+
247+
const uiMode = study.getUi().getMode();
248+
this.__uiModeChanged(uiMode);
278249

279250
const workbench = study.getWorkbench();
280251
workbench.addListener("retrieveInputs", e => {
@@ -565,8 +536,8 @@ qx.Class.define("osparc.desktop.StudyEditor", {
565536
},
566537

567538
__editSlides: function() {
568-
if (this.getPageContext() !== osparc.navigation.NavigationBar.PAGE_CONTEXT[1]) { // "workbench"
569-
// if the user it not in "workbench" mode, return
539+
if (this.getStudy().getUi().getMode() !== "workbench") {
540+
// if the user is not in "workbench" mode, return
570541
return;
571542
}
572543

@@ -729,23 +700,25 @@ qx.Class.define("osparc.desktop.StudyEditor", {
729700
return this.__workbenchView.getLogger();
730701
},
731702

732-
__applyPageContext: function(newCtxt) {
733-
switch (newCtxt) {
703+
__uiModeChanged: function(newUIMode) {
704+
switch (newUIMode) {
734705
case "guided":
735706
case "app":
736707
this.__viewsStack.setSelection([this.__slideshowView]);
737-
if (this.getStudy() && this.getStudy().getUi()) {
738-
this.__slideshowView.startSlides();
739-
}
708+
this.__slideshowView.startSlides();
740709
break;
741-
case "workbench":
742710
case "standalone":
743-
default:
711+
case "workbench":
712+
default: {
744713
this.__viewsStack.setSelection([this.__workbenchView]);
745-
if (this.getStudy() && this.getStudy().getUi()) {
746-
this.__workbenchView.nodeSelected(this.getStudy().getUi().getCurrentNodeId());
714+
const currentNodeId = this.getStudy().getUi().getCurrentNodeId();
715+
if (currentNodeId) {
716+
this.__workbenchView.nodeSelected();
717+
} else {
718+
this.__workbenchView.openFirstNode();
747719
}
748720
break;
721+
}
749722
}
750723
},
751724

services/static-webserver/client/source/class/osparc/desktop/WorkbenchView.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ qx.Class.define("osparc.desktop.WorkbenchView", {
7070
"expandNavBar": "qx.event.type.Event",
7171
"backToDashboardPressed": "qx.event.type.Event",
7272
"slidesEdit": "qx.event.type.Event",
73-
"slidesAppStart": "qx.event.type.Event",
7473
"annotationRectStart": "qx.event.type.Event",
7574
"takeSnapshot": "qx.event.type.Event",
7675
"showSnapshots": "qx.event.type.Event",
@@ -448,7 +447,7 @@ qx.Class.define("osparc.desktop.WorkbenchView", {
448447
marginTop: 7,
449448
...osparc.navigation.NavigationBar.BUTTON_OPTIONS
450449
});
451-
startAppButtonTB.addListener("execute", () => this.fireEvent("slidesAppStart"));
450+
startAppButtonTB.addListener("execute", () => study.getUi().setMode("app"));
452451
topBar.add(startAppButtonTB);
453452

454453
const collapseWithUserMenu = this.__collapseWithUserMenu = new osparc.desktop.CollapseWithUserMenu();
@@ -843,7 +842,7 @@ qx.Class.define("osparc.desktop.WorkbenchView", {
843842
toolTipText: this.tr("Start App Mode"),
844843
height: buttonsHeight
845844
});
846-
startAppBtn.addListener("execute", () => this.fireEvent("slidesAppStart"), this);
845+
startAppBtn.addListener("execute", () => this.getStudy().getUi().setMode("app"), this);
847846
slideshowButtons.add(startAppBtn);
848847

849848
this.__evalSlidesButtons();

services/static-webserver/client/source/class/osparc/navigation/StudyTitleWOptions.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ qx.Class.define("osparc.navigation.StudyTitleWOptions", {
8080
label: this.tr("Convert to Pipeline"),
8181
icon: null,
8282
});
83-
control.addListener("execute", () => {
84-
console.log("Convert to Pipeline");
85-
});
83+
control.addListener("execute", () => this.getStudy().getUi().setMode("workbench"));
8684
break;
8785
case "study-menu-download-logs":
8886
control = new qx.ui.menu.Button().set({

0 commit comments

Comments
 (0)