Skip to content

Commit 675eeef

Browse files
authored
Merge branch 'master' into fix/update-link-after-nodeui-resize
2 parents 83775b3 + 1b1b2a6 commit 675eeef

File tree

3 files changed

+71
-74
lines changed

3 files changed

+71
-74
lines changed

services/static-webserver/client/source/class/osparc/dashboard/ResourceDetails.js

Lines changed: 28 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,15 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
147147
const toolbar = this.self().createToolbar();
148148
page.addToHeader(toolbar);
149149

150-
if (this.__resourceData["resourceType"] === "study") {
150+
if (["study", "template"].includes(this.__resourceData["resourceType"])) {
151151
const payDebtButton = new qx.ui.form.Button(this.tr("Credits required"));
152152
page.payDebtButton = payDebtButton;
153153
osparc.dashboard.resources.pages.BasePage.decorateHeaderButton(payDebtButton);
154154
payDebtButton.addListener("execute", () => this.openBillingSettings());
155-
if (this.__resourceData["resourceType"] === "study") {
156-
const studyData = this.__resourceData;
157-
payDebtButton.set({
158-
visibility: osparc.study.Utils.isInDebt(studyData) ? "visible" : "excluded"
159-
});
160-
}
155+
const studyData = this.__resourceData;
156+
payDebtButton.set({
157+
visibility: osparc.study.Utils.isInDebt(studyData) ? "visible" : "excluded"
158+
});
161159
toolbar.add(payDebtButton);
162160
}
163161

@@ -183,10 +181,10 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
183181
});
184182
openButton.addListener("execute", () => this.__openTapped(openButton));
185183

186-
if (this.__resourceData["resourceType"] === "study") {
184+
if (["study", "template"].includes(this.__resourceData["resourceType"])) {
187185
const studyData = this.__resourceData;
188-
const canBeOpened = osparc.study.Utils.canBeOpened(studyData);
189-
openButton.setEnabled(canBeOpened);
186+
const enabled = osparc.study.Utils.canBeOpened(studyData);
187+
openButton.setEnabled(enabled);
190188
}
191189

192190
toolbar.add(openButton);
@@ -458,13 +456,11 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
458456
const lazyLoadContent = () => {
459457
const billingSettings = new osparc.study.BillingSettings(resourceData);
460458
billingSettings.addListener("debtPayed", () => {
461-
if (resourceData["resourceType"] === "study") {
462-
page.payDebtButton.set({
463-
visibility: osparc.study.Utils.isInDebt(resourceData) ? "visible" : "excluded"
464-
});
465-
const canBeOpened = osparc.study.Utils.canBeOpened(resourceData);
466-
page.openButton.setEnabled(canBeOpened);
467-
}
459+
page.payDebtButton.set({
460+
visibility: osparc.study.Utils.isInDebt(resourceData) ? "visible" : "excluded"
461+
});
462+
const enabled = osparc.study.Utils.canBeOpened(resourceData);
463+
page.openButton.setEnabled(enabled);
468464
})
469465
const billingScroll = new qx.ui.container.Scroll(billingSettings);
470466
page.addToContent(billingScroll);
@@ -508,11 +504,9 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
508504
const page = new osparc.dashboard.resources.pages.BasePage(title, iconSrc, id);
509505
this.__addOpenButton(page);
510506

511-
if (this.__resourceData["resourceType"] === "study") {
512-
const studyData = this.__resourceData;
513-
const canBeOpened = osparc.study.Utils.canShowPreview(studyData);
514-
page.setEnabled(canBeOpened);
515-
}
507+
const studyData = this.__resourceData;
508+
const enabled = osparc.study.Utils.canShowPreview(studyData);
509+
page.setEnabled(enabled);
516510

517511
const lazyLoadContent = () => {
518512
const resourceModel = this.__resourceModel;
@@ -689,11 +683,9 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
689683
const page = this.__servicesUpdatePage = new osparc.dashboard.resources.pages.BasePage(title, iconSrc, id);
690684
this.__addOpenButton(page);
691685

692-
if (this.__resourceData["resourceType"] === "study") {
693-
const studyData = this.__resourceData;
694-
const canBeOpened = osparc.study.Utils.canShowServiceUpdates(studyData);
695-
page.setEnabled(canBeOpened);
696-
}
686+
const studyData = this.__resourceData;
687+
const enabled = osparc.study.Utils.canShowServiceUpdates(studyData);
688+
page.setEnabled(enabled);
697689

698690
const lazyLoadContent = () => {
699691
const servicesUpdate = new osparc.metadata.ServicesInStudyUpdate(resourceData);
@@ -723,11 +715,9 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
723715
const page = new osparc.dashboard.resources.pages.BasePage(title, iconSrc, id);
724716
this.__addOpenButton(page);
725717

726-
if (this.__resourceData["resourceType"] === "study") {
727-
const studyData = this.__resourceData;
728-
const canBeOpened = osparc.study.Utils.canShowServiceBootOptions(studyData);
729-
page.setEnabled(canBeOpened);
730-
}
718+
const studyData = this.__resourceData;
719+
const enabled = osparc.study.Utils.canShowServiceBootOptions(studyData);
720+
page.setEnabled(enabled);
731721

732722
const lazyLoadContent = () => {
733723
const servicesBootOpts = new osparc.metadata.ServicesInStudyBootOpts(resourceData);
@@ -776,11 +766,9 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
776766
const title = this.tr("Publish");
777767
const page = new osparc.dashboard.resources.pages.BasePage(title, iconSrc, id);
778768

779-
if (this.__resourceData["resourceType"] === "study") {
780-
const studyData = this.__resourceData;
781-
const canBeOpened = osparc.study.Utils.canBeDuplicated(studyData);
782-
page.setEnabled(canBeOpened);
783-
}
769+
const studyData = this.__resourceData;
770+
const enabled = osparc.study.Utils.canBeDuplicated(studyData);
771+
page.setEnabled(enabled);
784772

785773
const lazyLoadContent = () => {
786774
const makeItPublic = true;
@@ -817,11 +805,9 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
817805
const title = this.tr("Template");
818806
const page = new osparc.dashboard.resources.pages.BasePage(title, iconSrc, id);
819807

820-
if (this.__resourceData["resourceType"] === "study") {
821-
const studyData = this.__resourceData;
822-
const canBeOpened = osparc.study.Utils.canBeDuplicated(studyData);
823-
page.setEnabled(canBeOpened);
824-
}
808+
const studyData = this.__resourceData;
809+
const enabled = osparc.study.Utils.canBeDuplicated(studyData);
810+
page.setEnabled(enabled);
825811

826812
const lazyLoadContent = () => {
827813
const makeItPublic = false;

services/static-webserver/client/source/class/osparc/form/renderer/PropForm.js

Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -135,58 +135,69 @@ qx.Class.define("osparc.form.renderer.PropForm", {
135135
/*
136136
* <-- Dynamic inputs -->
137137
*/
138-
__getEmptyDataLastPorts: function() {
139-
let emptyDataPorts = [];
138+
//
139+
__getHideablePorts: function() {
140+
const hideablePorts = [];
140141
const minVisibleInputs = this.getNode().getMinVisibleInputs();
141142
if (minVisibleInputs === null) {
142-
return emptyDataPorts;
143+
return hideablePorts;
143144
}
145+
// start from the last port and check the port types
146+
// if all last ports are the same type, then mark them as hideable
147+
let hideablePortType = null;
144148
const portIds = this.getPortIds();
145-
// it will always show 1 more, so: -1
146-
for (let i=minVisibleInputs-1; i<portIds.length; i++) {
149+
for (let i=portIds.length-1; i>=minVisibleInputs; i--) {
147150
const portId = portIds[i];
148151
const ctrl = this._form.getControl(portId);
149-
if (ctrl && ctrl.type.includes("data:") && !("link" in ctrl)) {
150-
emptyDataPorts.push(portId);
152+
if (ctrl && hideablePortType === null) {
153+
hideablePortType = ctrl.type;
154+
}
155+
if (ctrl &&
156+
ctrl.type === hideablePortType &&
157+
// make sure it's not linked
158+
!("link" in ctrl)
159+
) {
160+
hideablePorts.unshift(portId);
151161
} else {
152-
emptyDataPorts = [];
162+
break;
153163
}
154164
}
155-
return emptyDataPorts;
165+
return hideablePorts;
156166
},
157167

158-
__getVisibleEmptyDataLastPort: function() {
159-
let emptyDataPorts = null;
160-
this.getPortIds().forEach(portId => {
161-
const ctrl = this._form.getControl(portId);
168+
__getVisibleEmptyLastPort: function() {
169+
let emptyPorts = null;
170+
const hideablePorts = this.__getHideablePorts();
171+
for (let i=hideablePorts.length-1; i>=0; i--) {
172+
const portId = hideablePorts[i]
162173
const label = this._getLabelFieldChild(portId).child;
163174
if (
164-
ctrl && ctrl.type.includes("data:") && !("link" in ctrl) &&
165-
label && label.isVisible()
175+
label && label.isVisible() &&
176+
emptyPorts === null
166177
) {
167-
emptyDataPorts = portId;
178+
emptyPorts = portId;
168179
}
169-
});
170-
return emptyDataPorts;
180+
}
181+
return emptyPorts;
171182
},
172183

173184
__addInputPortButtonClicked: function() {
174-
const emptyDataPorts = this.__getEmptyDataLastPorts();
175-
const lastEmptyDataPort = this.__getVisibleEmptyDataLastPort();
176-
if (emptyDataPorts.length>1 && lastEmptyDataPort) {
177-
const idx = emptyDataPorts.indexOf(lastEmptyDataPort);
178-
if (idx+1 < emptyDataPorts.length) {
179-
this.__showPort(emptyDataPorts[idx+1]);
185+
const emptyPorts = this.__getHideablePorts();
186+
const lastEmptyPort = this.__getVisibleEmptyLastPort();
187+
if (emptyPorts.length>1 && lastEmptyPort) {
188+
const idx = emptyPorts.indexOf(lastEmptyPort);
189+
if (idx+1 < emptyPorts.length) {
190+
this.__showPort(emptyPorts[idx+1]);
180191
}
181192
this.__addInputPortButton.setVisibility(this.__checkAddInputPortButtonVisibility());
182193
}
183194
},
184195

185196
__checkAddInputPortButtonVisibility: function() {
186-
const emptyDataPorts = this.__getEmptyDataLastPorts();
187-
const lastEmptyDataPort = this.__getVisibleEmptyDataLastPort();
188-
const idx = emptyDataPorts.indexOf(lastEmptyDataPort);
189-
if (idx < emptyDataPorts.length-1) {
197+
const emptyPorts = this.__getHideablePorts();
198+
const lastEmptyPort = this.__getVisibleEmptyLastPort();
199+
const idx = emptyPorts.indexOf(lastEmptyPort);
200+
if (idx < emptyPorts.length-1) {
190201
return "visible";
191202
}
192203
return "excluded";
@@ -225,9 +236,9 @@ qx.Class.define("osparc.form.renderer.PropForm", {
225236
makeInputsDynamic: function() {
226237
this.getPortIds().forEach(portId => this.__showPort(portId));
227238

228-
const emptyDataPorts = this.__getEmptyDataLastPorts();
229-
for (let i=1; i<emptyDataPorts.length; i++) {
230-
const hidePortId = emptyDataPorts[i];
239+
const emptyPorts = this.__getHideablePorts();
240+
for (let i=1; i<emptyPorts.length; i++) {
241+
const hidePortId = emptyPorts[i];
231242
this.__excludePort(hidePortId);
232243
}
233244

tests/e2e/tests/startupCalls.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ module.exports = {
4747
await auto.register(page, user, pass);
4848
console.log("Registered");
4949

50-
await page.waitFor(10000);
50+
await page.waitFor(60000);
5151
}, ourTimeout);
5252

5353
afterAll(async () => {

0 commit comments

Comments
 (0)