Skip to content

Commit ae412cf

Browse files
authored
🐛 [Frontend] Fix: Make Join/Open button text dynamic (#8709)
1 parent 73f95fd commit ae412cf

File tree

4 files changed

+34
-6
lines changed

4 files changed

+34
-6
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,12 @@ qx.Class.define("osparc.dashboard.CardBase", {
896896
__showCurrentUserGroupIds: function(currentUserGroupIds) {
897897
const avatarGroup = this.getChildControl("avatar-group");
898898
avatarGroup.setUserGroupIds(currentUserGroupIds);
899+
900+
if (this.openButton) {
901+
const resourceData = this.getResourceData();
902+
const openText = osparc.dashboard.ResourceBrowserBase.getOpenText(resourceData);
903+
this.openButton.setLabel(openText);
904+
}
899905
},
900906

901907
__showBlockedCardFromStatus: function(reason, state) {

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,17 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
407407
},
408408

409409
__addPages: function() {
410+
const studyStore = osparc.store.Study.getInstance();
411+
studyStore.addListener("studyStateChanged", e => {
412+
const {
413+
studyId,
414+
state,
415+
} = e.getData();
416+
if ("uuid" in this.__resourceData && studyId === this.__resourceData["uuid"]) {
417+
this.__studyStateChanged(state);
418+
}
419+
});
420+
410421
const tabsView = this.getChildControl("tabs-view");
411422

412423
// keep selected page
@@ -554,7 +565,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
554565
const lazyLoadContent = () => {
555566
const billingSettings = new osparc.study.BillingSettings(resourceData);
556567
this.self().disableIfInUse(resourceData, billingSettings);
557-
billingSettings.addListener("debtPayed", () => {
568+
billingSettings.addListener("debtPaid", () => {
558569
page.payDebtButton.set({
559570
visibility: osparc.study.Utils.isInDebt(resourceData) ? "visible" : "excluded"
560571
});
@@ -1024,6 +1035,16 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
10241035
}
10251036
},
10261037

1038+
__studyStateChanged: function(state) {
1039+
this.__resourceData.state = osparc.utils.Utils.deepCloneObject(state);
1040+
this.getChildControl("tabs-view").getChildren().forEach(page => {
1041+
if (page.openButton) {
1042+
const openText = osparc.dashboard.ResourceBrowserBase.getOpenText(this.__resourceData);
1043+
page.openButton.setLabel(openText);
1044+
}
1045+
});
1046+
},
1047+
10271048
// overridden
10281049
destroy: function() {
10291050
this.__widgets.forEach(w => w.destroy());

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,6 +2001,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
20012001
}
20022002

20032003
const openButton = this._getOpenMenuButton(studyData);
2004+
card.openButton = openButton;
20042005
if (openButton) {
20052006
menu.add(openButton);
20062007
}

services/static-webserver/client/source/class/osparc/study/BillingSettings.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ qx.Class.define("osparc.study.BillingSettings", {
3232
},
3333

3434
events: {
35-
"debtPayed": "qx.event.type.Event",
35+
"debtPaid": "qx.event.type.Event",
3636
"closeWindow": "qx.event.type.Event",
3737
},
3838

@@ -221,7 +221,7 @@ qx.Class.define("osparc.study.BillingSettings", {
221221
} = osparc.desktop.credits.Utils.openBuyCredits(paymentMethods);
222222
buyCreditsWidget.addListener("completed", () => {
223223
// at this point we can assume that the study got unblocked
224-
this.__debtPayed();
224+
this.__debtPaid();
225225
})
226226
});
227227
}
@@ -250,17 +250,17 @@ qx.Class.define("osparc.study.BillingSettings", {
250250
osparc.store.Study.getInstance().payDebt(this.__studyData["uuid"], wallet.getWalletId(), this.__studyData["debt"])
251251
.then(() => {
252252
// at this point we can assume that the study got unblocked
253-
this.__debtPayed();
253+
this.__debtPaid();
254254
// also switch the study's wallet to this one
255255
this.__switchWallet(wallet.getWalletId());
256256
})
257257
.catch(err => osparc.FlashMessenger.logError(err));
258258
},
259259

260-
__debtPayed: function() {
260+
__debtPaid: function() {
261261
delete this.__studyData["debt"];
262262
osparc.store.Study.getInstance().setStudyDebt(this.__studyData["uuid"], 0);
263-
this.fireEvent("debtPayed");
263+
this.fireEvent("debtPaid");
264264
if (this.__debtMessage) {
265265
this._remove(this.__debtMessage);
266266
}

0 commit comments

Comments
 (0)