Skip to content

✨ Frontend: open Wallets view after log in #4649

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -34,6 +34,7 @@ qx.Class.define("osparc.Application", {
__current: null,
__themeSwitcher: null,
__mainPage: null,
__openViewAfterLogin: null,

/**
* This method contains the initial application code and gets called
Expand Down Expand Up @@ -125,6 +126,7 @@ qx.Class.define("osparc.Application", {
},

__rerouteNav: function(urlFragment) {
this.__openViewAfterLogin = null;
const page = urlFragment.nav[0];
switch (page) {
case "study": {
Expand Down Expand Up @@ -181,6 +183,22 @@ qx.Class.define("osparc.Application", {
}
break;
}
case "wallets": {
// Route: /#/wallets
this.__openViewAfterLogin = "wallets";
osparc.utils.Utils.cookie.deleteCookie("user");
osparc.auth.Manager.getInstance().validateToken()
.then(() => this.__loadMainPage())
.catch(() => {
osparc.store.VendorInfo.getInstance().getVendor()
.then(vendor => {
const landingPage = "has_landing_page" in vendor ? vendor["has_landing_page"] : false;
this.__loadLoginPage(landingPage);
})
.catch(() => this.__loadLoginPage(false));
});
break;
}
case "error": {
// Route: /#/error/?message={errorMessage}&status_code={statusCode}
if (urlFragment.params && urlFragment.params.message) {
Expand Down Expand Up @@ -380,7 +398,7 @@ qx.Class.define("osparc.Application", {
osparc.store.Store.getInstance().setCurrentStudyId(studyId);
}

const mainPage = this.__mainPage = new osparc.desktop.MainPage();
const mainPage = this.__mainPage = new osparc.desktop.MainPage(this.__openViewAfterLogin);
this.__loadView(mainPage);
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ qx.Class.define("osparc.Error", {
control = new qx.ui.form.Button().set({
icon: "@FontAwesome5Solid/sign-in-alt/14",
label: this.tr("Log in"),
appearance: "strong-button"
appearance: "strong-button",
center: true
});
control.addListener("execute", () => this.__logIn(), this);
const actionsLayout = this.getChildControl("actions-layout");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
qx.Class.define("osparc.desktop.MainPage", {
extend: qx.ui.core.Widget,

construct: function() {
this.base();
construct: function(openView) {
this.base(arguments);

this._setLayout(new qx.ui.layout.VBox(null, null, "separator-vertical"));

Expand All @@ -55,7 +55,18 @@ qx.Class.define("osparc.desktop.MainPage", {
osparc.MaintenanceTracker.getInstance().startTracker();

const store = osparc.store.Store.getInstance();
store.reloadWallets();
store.reloadWallets()
.then(() => {
if (openView && openView === "wallets") {
osparc.desktop.credits.Utils.areWalletsEnabled()
.then(walletsEnabled => {
if (walletsEnabled) {
const creditsWindow = osparc.desktop.credits.CreditsWindow.openWindow();
creditsWindow.openWallets();
}
});
}
});

Promise.all([
store.getAllClassifiers(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@ qx.Class.define("osparc.desktop.credits.Utils", {
type: "static",

statics: {
areWalletsEnabled: function() {
return new Promise(resolve => {
Promise.all([
osparc.utils.Utils.isDevelopmentPlatform(),
osparc.utils.Utils.isStagingPlatform()
])
.then(values => {
const isDevel = values[0];
const isStaging = values[1];
if ((isDevel || isStaging) && osparc.product.Utils.isProduct("s4l")) {
resolve(true);
} else {
resolve(false);
}
});
});
},

createWalletSelector: function(accessRight = "read", onlyActive = false, emptySelection = false) {
const store = osparc.store.Store.getInstance();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,9 @@ qx.Class.define("osparc.navigation.NavigationBar", {
// right-items
const walletsViewer = this.getChildControl("wallets-viewer");
walletsViewer.exclude();
osparc.utils.Utils.isDevelopmentPlatform()
.then(isDevel => {
if (isDevel && osparc.product.Utils.isProduct("s4l")) {
walletsViewer.show();
}
});
osparc.utils.Utils.isStagingPlatform()
.then(isStaging => {
if (isStaging && osparc.product.Utils.isProduct("s4l")) {
osparc.desktop.credits.Utils.areWalletsEnabled()
.then(walletsEnabled => {
if (walletsEnabled) {
walletsViewer.show();
}
});
Expand Down