Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
osparc.desktop.MainPageHandler.getInstance().startStudy(studyId);
};

const walletsEnabled = osparc.desktop.credits.Utils.areWalletsEnabled();
const walletsEnabled = osparc.store.StaticInfo.isBillableProduct();
if (walletsEnabled) {
Promise.all([
osparc.store.Study.getInstance().getWallet(studyId),
Expand Down Expand Up @@ -767,7 +767,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
const studyAlias = osparc.product.Utils.getStudyAlias({firstUpperCase: true});
this._showLoadingPage(this.tr("Creating ") + (templateData.name || studyAlias));

if (osparc.desktop.credits.Utils.areWalletsEnabled()) {
if (osparc.store.StaticInfo.isBillableProduct()) {
const studyOptions = new osparc.study.StudyOptions();
// they will be patched once the study is created
studyOptions.setPatchStudy(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
},

__addBillingPage: function() {
if (!osparc.desktop.credits.Utils.areWalletsEnabled()) {
if (!osparc.store.StaticInfo.isBillableProduct()) {
return;
}
if (osparc.utils.Resources.isStudyLike(this.__resourceData) && !osparc.data.model.Study.canIWrite(this.__resourceData["accessRights"])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2074,7 +2074,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
const studyDataButton = this.__getStudyDataMenuButton(card);
menu.add(studyDataButton);

if (osparc.desktop.credits.Utils.areWalletsEnabled()) {
if (osparc.store.StaticInfo.isBillableProduct()) {
const billingsSettingsButton = this.__getBillingMenuButton(card);
menu.add(billingsSettingsButton);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ qx.Class.define("osparc.desktop.MainPage", {

const store = osparc.store.Store.getInstance();
const preloadPromises = [];
const walletsEnabled = osparc.desktop.credits.Utils.areWalletsEnabled();
const walletsEnabled = osparc.store.StaticInfo.isBillableProduct();
if (walletsEnabled) {
preloadPromises.push(store.reloadCreditPrice());
preloadPromises.push(store.reloadWallets());
preloadPromises.push(store.fetchCreditPrice());
preloadPromises.push(store.fetchWallets());
}
preloadPromises.push(store.getAllClassifiers(true));
preloadPromises.push(osparc.store.Tags.getInstance().fetchTags());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ qx.Class.define("osparc.desktop.account.MyAccount", {
this.__profilePage = this.__addProfilePage();

// show Usage in My Account if wallets are not enabled. If they are enabled it will be in the BIlling Center
if (!osparc.desktop.credits.Utils.areWalletsEnabled()) {
if (!osparc.store.StaticInfo.isBillableProduct()) {
if (osparc.data.Permissions.getInstance().canDo("usage.all.read")) {
this.__usagePage = this.__addUsagePage();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ qx.Class.define("osparc.desktop.credits.CurrentUsage", {

members: {
__currentStudyChanged: function(currentStudy) {
if (osparc.desktop.credits.Utils.areWalletsEnabled()) {
if (osparc.store.StaticInfo.isBillableProduct()) {
if (currentStudy) {
const store = osparc.store.Store.getInstance();
const contextWallet = store.getContextWallet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ qx.Class.define("osparc.desktop.credits.ResourceInTableViewer", {
}
});

if (osparc.desktop.credits.Utils.areWalletsEnabled()) {
if (osparc.store.StaticInfo.isBillableProduct()) {
const store = osparc.store.Store.getInstance();
store.getWallets().forEach(wallet => {
walletSelectBox.add(new qx.ui.form.ListItem(wallet.getName(), null, wallet));
Expand All @@ -136,7 +136,7 @@ qx.Class.define("osparc.desktop.credits.ResourceInTableViewer", {
},

_getSelectWalletId: function() {
if (osparc.desktop.credits.Utils.areWalletsEnabled()) {
if (osparc.store.StaticInfo.isBillableProduct()) {
const walletSelectBox = this.getChildControl("wallet-selector");
const selectedWallet = walletSelectBox.getSelection()[0].getModel();
return selectedWallet.getWalletId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ qx.Class.define("osparc.desktop.credits.UsageTable", {

columnModel.setDataCellRenderer(this.self().COLS.COST.column, new qx.ui.table.cellrenderer.Number());

if (!osparc.desktop.credits.Utils.areWalletsEnabled()) {
if (!osparc.store.StaticInfo.isBillableProduct()) {
columnModel.setColumnVisible(this.self().COLS.COST.column, false);
columnModel.setColumnVisible(this.self().COLS.USER.column, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ qx.Class.define("osparc.desktop.credits.Utils", {
};
},

areWalletsEnabled: function() {
return Boolean(osparc.store.StaticInfo.getValue("isPaymentEnabled"));
},

getNoWriteAccessInformationLabel: function() {
return new qx.ui.basic.Label().set({
value: qx.locale.Manager.tr("You can't access this information"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ qx.Class.define("osparc.desktop.preferences.pages.GeneralPage", {

this._setLayout(new qx.ui.layout.VBox(15));

if (osparc.desktop.credits.Utils.areWalletsEnabled()) {
if (osparc.store.StaticInfo.isBillableProduct()) {
this.__addCreditsIndicatorSettings();
}

Expand All @@ -33,7 +33,7 @@ qx.Class.define("osparc.desktop.preferences.pages.GeneralPage", {
this.__addLowDiskSpaceSetting();
}

if (osparc.desktop.credits.Utils.areWalletsEnabled()) {
if (osparc.store.StaticInfo.isBillableProduct()) {
this.__addInactivitySetting();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ qx.Class.define("osparc.info.ServiceLarge", {
vBox.add(infoLayout);

// Resources info if not billable
if (!osparc.desktop.credits.Utils.areWalletsEnabled()) {
if (!osparc.store.StaticInfo.isBillableProduct()) {
const resources = this.__createResources();
if (resources) {
vBox.add(resources);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ qx.Class.define("osparc.navigation.NavigationBar", {
}
this.getChildControl("notifications-button");
this.getChildControl("help-button");
if (osparc.desktop.credits.Utils.areWalletsEnabled()) {
if (osparc.store.StaticInfo.isBillableProduct()) {
this.getChildControl("credits-button");
}
this.getChildControl("log-in-button");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ qx.Class.define("osparc.navigation.UserMenu", {
control = new qx.ui.menu.Button(this.tr("Billing Center"));
osparc.utils.Utils.setIdToWidget(control, "userMenuBillingCenterBtn");
control.addListener("execute", () => {
const walletsEnabled = osparc.desktop.credits.Utils.areWalletsEnabled();
const walletsEnabled = osparc.store.StaticInfo.isBillableProduct();
if (walletsEnabled) {
osparc.desktop.credits.BillingCenterWindow.openWindow();
}
Expand Down Expand Up @@ -166,7 +166,7 @@ qx.Class.define("osparc.navigation.UserMenu", {
if (osparc.data.Permissions.getInstance().isAdmin()) {
this.getChildControl("admin-center");
}
if (osparc.desktop.credits.Utils.areWalletsEnabled()) {
if (osparc.store.StaticInfo.isBillableProduct()) {
this.getChildControl("billing-center");
}
this.getChildControl("organizations");
Expand Down Expand Up @@ -222,7 +222,7 @@ qx.Class.define("osparc.navigation.UserMenu", {
if (osparc.data.Permissions.getInstance().isAdmin()) {
this.getChildControl("admin-center");
}
if (osparc.desktop.credits.Utils.areWalletsEnabled()) {
if (osparc.store.StaticInfo.isBillableProduct()) {
this.getChildControl("billing-center");
}
this.getChildControl("organizations");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ qx.Class.define("osparc.notification.NotificationUI", {
this.__openStudyDetails(resourceId, notification);
break;
case "WALLET_SHARED": {
const walletsEnabled = osparc.desktop.credits.Utils.areWalletsEnabled();
const walletsEnabled = osparc.store.StaticInfo.isBillableProduct();
if (walletsEnabled) {
this.__openWalletDetails(parseInt(resourceId));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,9 @@ qx.Class.define("osparc.store.StaticInfo", {
isDevFeaturesEnabled: function() {
return this.getValue("webserverDevFeaturesEnabled");
},

isBillableProduct: function() {
return Boolean(this.getValue("isPaymentEnabled"));
},
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ qx.Class.define("osparc.store.Store", {
return null;
},

reloadCreditPrice: function() {
fetchCreditPrice: function() {
const store = osparc.store.Store.getInstance();
store.setCreditPrice(null);

Expand Down Expand Up @@ -489,15 +489,22 @@ qx.Class.define("osparc.store.Store", {
return 0;
},

reloadWallets: function() {
fetchWallets: function() {
return new Promise((resolve, reject) => {
osparc.data.Resources.fetch("wallets", "get")
.then(walletsData => {
let personalWalletFound = false;
const wallets = [];
const myGroupId = osparc.auth.Data.getInstance().getGroupId();
walletsData.forEach(walletReducedData => {
personalWalletFound = personalWalletFound || myGroupId === walletReducedData["owner"];
const wallet = new osparc.data.model.Wallet(walletReducedData);
wallets.push(wallet);
});
if (!personalWalletFound) {
const msg = this.tr("No personal wallet found, some functionalities might not work properly. Please contact support.");
osparc.FlashMessenger.logAs(msg, "WARNING");
}
this.setWallets(wallets);

// 1) fetch the access rights
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ qx.Class.define("osparc.widget.NodeOptions", {
let showStartStopButton = false;

// Tier Selection
if (osparc.desktop.credits.Utils.areWalletsEnabled()) {
if (osparc.store.StaticInfo.isBillableProduct()) {
const tierSelectionView = new osparc.node.TierSelectionView(node);
sections.push(tierSelectionView);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ qx.Class.define("osparc.widget.PersistentIframe", {
break;
}
case "openWallets": {
if (osparc.desktop.credits.Utils.areWalletsEnabled()) {
if (osparc.store.StaticInfo.isBillableProduct()) {
setTimeout(() => osparc.desktop.credits.BillingCenterWindow.openWindow(), 100);
}
break;
Expand Down
Loading