Skip to content

Commit

Permalink
✨ Ask for wallet upon study creation and Hide Tiers by default (#4956)
Browse files Browse the repository at this point in the history
  • Loading branch information
odeimaiz authored and matusdrobuliak66 committed Nov 2, 2023
1 parent 03f57d8 commit 0852b69
Show file tree
Hide file tree
Showing 20 changed files with 404 additions and 378 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -330,15 +330,6 @@ qx.Class.define("osparc.Application", {

__loadMainPage: async function(studyId = null) {
// logged in

const walletsEnabled = osparc.desktop.credits.Utils.areWalletsEnabled();
if (osparc.product.Utils.shouldHaveWalletsEnabled() && !walletsEnabled) {
const infoLabel = this.tr("Credits information is not ready.<br>Please contact us by email:<br>");
const supportEmail = osparc.store.VendorInfo.getInstance().getSupportEmail();
osparc.FlashMessenger.getInstance().logAs(infoLabel + supportEmail, "ERROR");
this.logout();
}

const profile = await osparc.data.Resources.getOne("profile");
if (profile) {
this.__connectWebSocket();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
throw new Error("Abstract method called!");
},

_startStudyById: function(studyId, openCB, cancelCB) {
_startStudyById: function(studyId, openCB, cancelCB, isStudyCreation = false) {
if (!this._checkLoggedIn()) {
return;
}
Expand All @@ -326,8 +326,8 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
};
osparc.data.Resources.fetch("studies", "getWallet", params)
.then(wallet => {
if (wallet === null || osparc.desktop.credits.Utils.getWallet(wallet["walletId"]) === null) {
// pop up study options only if it has no wallet assigned or user has no access to it
if (isStudyCreation || wallet === null || osparc.desktop.credits.Utils.getWallet(wallet["walletId"]) === null) {
// pop up study options if the study was just created or if it has no wallet assigned or user has no access to it
const resourceSelector = new osparc.study.StudyOptions(studyId);
const win = osparc.study.StudyOptions.popUpInWindow(resourceSelector);
resourceSelector.addListener("startStudy", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ qx.Class.define("osparc.dashboard.ServiceBrowser", {
};
osparc.data.Resources.fetch("studies", "delete", params, studyId);
};
this._startStudyById(studyId, openCB, cancelCB);
const isStudyCreation = true;
this._startStudyById(studyId, openCB, cancelCB, isStudyCreation);
})
.catch(err => {
this._hideLoadingPage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,8 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
};
osparc.data.Resources.fetch("studies", "delete", params2, studyData["uuid"]);
};
this._startStudyById(studyData["uuid"], openCB, cancelCB);
const isStudyCreation = true;
this._startStudyById(studyData["uuid"], openCB, cancelCB, isStudyCreation);
})
.catch(err => {
this._hideLoadingPage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", {
};
osparc.data.Resources.fetch("studies", "delete", params, studyId);
};
this._startStudyById(studyId, openCB, cancelCB);
const isStudyCreation = true;
this._startStudyById(studyId, openCB, cancelCB, isStudyCreation);
})
.catch(err => {
this._hideLoadingPage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,10 @@ qx.Class.define("osparc.desktop.WorkbenchView", {

__getSidePanelsNewWidth: function(collapsing, sidePanels, collapsibleView) {
let sidePanelsNewWidth = null;
const sidePanelsWidth = sidePanels.getBounds().width;
const sidePanelsWidth = (sidePanels.getBounds() && ("width" in sidePanels.getBounds())) ? sidePanels.getBounds().width : 250;
if (collapsing) {
const content = collapsibleView.getChildControl("scroll-content");
sidePanelsNewWidth = sidePanelsWidth - content.getBounds().width;
sidePanelsNewWidth = (content.getBounds() && ("width" in content.getBounds())) ? sidePanelsWidth - content.getBounds().width : 150;
} else if ("precollapseWidth" in collapsibleView) {
sidePanelsNewWidth = sidePanelsWidth + (collapsibleView.precollapseWidth - osparc.widget.CollapsibleViewLight.CARET_WIDTH);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ qx.Class.define("osparc.desktop.credits.Utils", {
return parseInt(credits);
},

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

const walletSelector = new qx.ui.form.SelectBox();
Expand All @@ -78,11 +78,6 @@ qx.Class.define("osparc.desktop.credits.Utils", {
selectBox.removeAll();

const wallets = store.getWallets();
if (emptySelection) {
const sbItem = new qx.ui.form.ListItem(qx.locale.Manager.tr("Select Credit Account"));
sbItem.walletId = null;
selectBox.add(sbItem);
}
wallets.forEach(wallet => {
const found = wallet.getMyAccessRights();
if (found && found[accessRight]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,80 +16,25 @@
************************************************************************ */

qx.Class.define("osparc.editor.HtmlEditor", {
extend: qx.ui.core.Widget,
extend: osparc.editor.TextEditor,

/**
* @param initText {String} Initialization text
*/
construct: function(initText = "") {
this.base(arguments);
this.base(arguments, initText);

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

this.getChildControl("text-area");
this.getChildControl("preview");
if (initText) {
this.setText(initText);
}

this.__addButtons();
},

events: {
"textChanged": "qx.event.type.Data",
"cancel": "qx.event.type.Event"
},

properties: {
text: {
check: "String",
event: "changeText",
init: "",
nullable: true
}
this.getChildControl("preview-html");
this.getChildControl("subtitle").set({
value: this.tr("Supports HTML")
});
},

members: {
_createChildControlImpl: function(id) {
let control;
switch (id) {
case "tabs":
control = new qx.ui.tabview.TabView().set({
contentPadding: 0,
barPosition: "top"
});
this._add(control, {
flex: 1
});
break;
case "text-area": {
control = new qx.ui.form.TextArea().set({
allowGrowX: true
});
control.addListener("appear", () => {
if (control.getValue()) {
control.setTextSelection(0, control.getValue().length);
}
}, this);
this.bind("text", control, "value");
const tabs = this.getChildControl("tabs");
const writePage = new qx.ui.tabview.Page(this.tr("Write")).set({
layout: new qx.ui.layout.VBox(5)
});
writePage.getChildControl("button").getChildControl("label").set({
font: "text-13"
});
writePage.add(control, {
flex: 1
});
const subtitle = this.getChildControl("subtitle").set({
value: this.tr("Supports HTML")
});
writePage.add(subtitle);
tabs.add(writePage);
break;
}
case "preview": {
case "preview-html": {
control = new qx.ui.embed.Html();
const textArea = this.getChildControl("text-area");
textArea.bind("value", control, "html");
Expand All @@ -108,44 +53,8 @@ qx.Class.define("osparc.editor.HtmlEditor", {
tabs.add(previewPage);
break;
}
case "subtitle":
control = new qx.ui.basic.Label().set({
font: "text-12"
});
this._add(control);
break;
case "buttons":
control = new qx.ui.container.Composite(new qx.ui.layout.HBox(5).set({
alignX: "right"
}));
this._add(control);
break;
case "cancel-button": {
const buttons = this.getChildControl("buttons");
control = new qx.ui.form.Button(this.tr("Cancel"));
control.addListener("execute", () => {
this.fireDataEvent("cancel");
}, this);
buttons.add(control);
break;
}
case "accept-button": {
const buttons = this.getChildControl("buttons");
control = new qx.ui.form.Button(this.tr("Save"));
control.addListener("execute", () => {
const newText = this.getChildControl("text-area").getValue();
this.fireDataEvent("textChanged", newText);
}, this);
buttons.add(control);
break;
}
}
return control || this.base(arguments, id);
},

__addButtons: function() {
this.getChildControl("cancel-button");
this.getChildControl("accept-button");
}
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -21,80 +21,25 @@
*/

qx.Class.define("osparc.editor.MarkdownEditor", {
extend: qx.ui.core.Widget,
extend: osparc.editor.TextEditor,

/**
* @param initText {String} Initialization text
*/
construct: function(initText = "") {
this.base(arguments);
this.base(arguments, initText);

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

this.getChildControl("text-area");
this.getChildControl("preview");
if (initText) {
this.setText(initText);
}

this.__addButtons();
},

events: {
"textChanged": "qx.event.type.Data",
"cancel": "qx.event.type.Event"
},

properties: {
text: {
check: "String",
event: "changeText",
init: "",
nullable: true
}
this.getChildControl("preview-markdown");
this.getChildControl("subtitle").set({
value: this.tr("Supports Markdown")
});
},

members: {
_createChildControlImpl: function(id) {
let control;
switch (id) {
case "tabs":
control = new qx.ui.tabview.TabView().set({
contentPadding: 0,
barPosition: "top"
});
this._add(control, {
flex: 1
});
break;
case "text-area": {
control = new qx.ui.form.TextArea().set({
allowGrowX: true
});
control.addListener("appear", () => {
if (control.getValue()) {
control.setTextSelection(0, control.getValue().length);
}
}, this);
this.bind("text", control, "value");
const tabs = this.getChildControl("tabs");
const writePage = new qx.ui.tabview.Page(this.tr("Write")).set({
layout: new qx.ui.layout.VBox(5)
});
writePage.getChildControl("button").getChildControl("label").set({
font: "text-13"
});
writePage.add(control, {
flex: 1
});
const subtitle = this.getChildControl("subtitle").set({
value: this.tr("Supports Markdown")
});
writePage.add(subtitle);
tabs.add(writePage);
break;
}
case "preview": {
case "preview-markdown": {
control = new osparc.ui.markdown.Markdown().set({
padding: 3,
noMargin: true
Expand All @@ -116,44 +61,8 @@ qx.Class.define("osparc.editor.MarkdownEditor", {
tabs.add(previewPage);
break;
}
case "subtitle":
control = new qx.ui.basic.Label().set({
font: "text-12"
});
this._add(control);
break;
case "buttons":
control = new qx.ui.container.Composite(new qx.ui.layout.HBox(5).set({
alignX: "right"
}));
this._add(control);
break;
case "cancel-button": {
const buttons = this.getChildControl("buttons");
control = new qx.ui.form.Button(this.tr("Cancel"));
control.addListener("execute", () => {
this.fireDataEvent("cancel");
}, this);
buttons.add(control);
break;
}
case "accept-button": {
const buttons = this.getChildControl("buttons");
control = new qx.ui.form.Button(this.tr("Save"));
control.addListener("execute", () => {
const newText = this.getChildControl("text-area").getValue();
this.fireDataEvent("textChanged", newText);
}, this);
buttons.add(control);
break;
}
}
return control || this.base(arguments, id);
},

__addButtons: function() {
this.getChildControl("cancel-button");
this.getChildControl("accept-button");
}
}
});
Loading

0 comments on commit 0852b69

Please sign in to comment.