Skip to content

Commit 01eeeaf

Browse files
authored
πŸ› [Frontend] Fix: Pricing plan creation and Edit (#7702)
1 parent 6d446c9 commit 01eeeaf

File tree

11 files changed

+51
-32
lines changed

11 files changed

+51
-32
lines changed

β€Žservices/static-webserver/client/source/class/osparc/dashboard/Dashboard.jsβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ qx.Class.define("osparc.dashboard.Dashboard", {
110110
}];
111111
if (permissions.canDo("dashboard.templates.read")) {
112112
tabs.push({
113-
id: "templatesTab",
114-
buttonId: "templatesTabBtn",
113+
id: "tutorialsTab",
114+
buttonId: "tutorialsTabBtn",
115115
label: this.tr("TUTORIALS"),
116116
icon: "@FontAwesome5Solid/copy/"+tabIconSize,
117117
buildLayout: this.__createTutorialBrowser

β€Žservices/static-webserver/client/source/class/osparc/dashboard/SearchBarFilter.jsβ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ qx.Class.define("osparc.dashboard.SearchBarFilter", {
4545
HEIGHT: 36,
4646

4747
getSharedWithOptions: function(resourceType) {
48+
if (resourceType === "template") {
49+
resourceType = "tutorial";
50+
}
51+
4852
const resourceAlias = osparc.product.Utils.resourceTypeToAlias(resourceType, {
4953
firstUpperCase: true,
5054
plural: true

β€Žservices/static-webserver/client/source/class/osparc/pricing/PlanEditor.jsβ€Ž

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ qx.Class.define("osparc.pricing.PlanEditor", {
3636
manager.add(name);
3737

3838
if (pricingPlan) {
39-
this.__pricingPlan = osparc.utils.Utils.deepCloneObject(pricingPlan);
39+
this.__pricingPlan = pricingPlan;
4040
this.set({
4141
ppKey: pricingPlan.getPricingPlanKey(),
4242
name: pricingPlan.getName(),
@@ -76,7 +76,7 @@ qx.Class.define("osparc.pricing.PlanEditor", {
7676

7777
classification: {
7878
check: ["TIER", "LICENSE"],
79-
init: "",
79+
init: "TIER",
8080
nullable: false,
8181
event: "changeClassification"
8282
},
@@ -235,7 +235,7 @@ qx.Class.define("osparc.pricing.PlanEditor", {
235235
"classification": this.getClassification(),
236236
"isActive": this.getIsActive(),
237237
};
238-
osparc.store.Pricing.getInstance().putPricingPlan(this.__pricingPlan["pricingPlanId"], updateData)
238+
osparc.store.Pricing.getInstance().putPricingPlan(this.__pricingPlan.getPricingPlanId(), updateData)
239239
.then(() => {
240240
osparc.FlashMessenger.logAs(this.tr("Successfully updated"));
241241
this.fireEvent("done");

β€Žservices/static-webserver/client/source/class/osparc/pricing/Plans.jsβ€Ž

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,17 @@ qx.Class.define("osparc.pricing.Plans", {
125125
},
126126

127127
__openUpdatePricingPlan: function(pricingPlanId) {
128-
osparc.store.Pricing.getInstance().fetchPricingUnits(pricingPlanId)
129-
.then(pricingPlan => {
130-
const ppEditor = new osparc.pricing.PlanEditor(pricingPlan);
131-
const title = this.tr("Pricing Plan Editor");
132-
const win = osparc.ui.window.Window.popUpInWindow(ppEditor, title, 400, 250);
133-
ppEditor.addListener("done", () => {
134-
win.close();
135-
this.fetchPlans();
136-
});
137-
ppEditor.addListener("cancel", () => win.close());
128+
const pricingPlan = osparc.store.Pricing.getInstance().getPricingPlan(pricingPlanId);
129+
if (pricingPlan) {
130+
const ppEditor = new osparc.pricing.PlanEditor(pricingPlan);
131+
const title = this.tr("Pricing Plan Editor");
132+
const win = osparc.ui.window.Window.popUpInWindow(ppEditor, title, 400, 250);
133+
ppEditor.addListener("done", () => {
134+
win.close();
135+
this.fetchPlans();
138136
});
137+
ppEditor.addListener("cancel", () => win.close());
138+
}
139139
}
140140
}
141141
});

β€Žservices/static-webserver/client/source/class/osparc/store/Templates.jsβ€Ž

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,5 +126,20 @@ qx.Class.define("osparc.store.Templates", {
126126

127127
return this.__fetchAllHypertools();
128128
},
129+
130+
getTemplate: function(templateId) {
131+
if (this.__tutorials) {
132+
const template = this.__tutorials.find(t => t["templateId"] === templateId);
133+
if (template) {
134+
return new osparc.data.model.Template(template);
135+
}
136+
} else if (this.__hypertools) {
137+
const template = this.__hypertools.find(t => t["templateId"] === templateId);
138+
if (template) {
139+
return new osparc.data.model.Template(template);
140+
}
141+
}
142+
return null;
143+
},
129144
}
130145
});

β€Žservices/static-webserver/client/source/resource/osparc/tours/osparc_tours.jsonβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@
5353
"placement": "bottom"
5454
}, {
5555
"beforeClick": {
56-
"selector": "osparc-test-id=templatesTabBtn"
56+
"selector": "osparc-test-id=tutorialsTabBtn"
5757
},
58-
"anchorEl": "osparc-test-id=templatesTabBtn",
58+
"anchorEl": "osparc-test-id=tutorialsTabBtn",
5959
"text": "Clicking on a Template will create a copy of that Study, which will appear in your own Studies tab with the same name as the Template. Any changes you make to this copy will not affect the original Template.",
6060
"placement": "bottom"
6161
}, {

β€Žservices/static-webserver/client/source/resource/osparc/tours/s4l_tours.jsonβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@
5353
"placement": "bottom"
5454
}, {
5555
"beforeClick": {
56-
"selector": "osparc-test-id=templatesTabBtn"
56+
"selector": "osparc-test-id=tutorialsTabBtn"
5757
},
58-
"anchorEl": "osparc-test-id=templatesTabBtn",
58+
"anchorEl": "osparc-test-id=tutorialsTabBtn",
5959
"text": "Clicking on a Tutorial will create a copy of that Project, which will appear in your own Projects tab with the same name as the Tutorial. Any changes you make to this copy will not affect the original Tutorial.",
6060
"placement": "bottom"
6161
}, {

β€Žservices/static-webserver/client/source/resource/osparc/tours/s4llite_tours.jsonβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@
4949
"placement": "bottom"
5050
}, {
5151
"beforeClick": {
52-
"selector": "osparc-test-id=templatesTabBtn"
52+
"selector": "osparc-test-id=tutorialsTabBtn"
5353
},
54-
"anchorEl": "osparc-test-id=templatesTabBtn",
54+
"anchorEl": "osparc-test-id=tutorialsTabBtn",
5555
"title": "Tutorials",
5656
"text": "Clicking on a Tutorial will create a copy of that Project, which will appear in your own Projects tab with the same name as the Tutorial. Any changes you make to this copy will not affect the original Tutorial.",
5757
"placement": "bottom"

β€Žtests/e2e-frontend/tests/navigationBar/navigationBar.spec.jsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ for (const product in products) {
174174
}
175175
};
176176

177-
await checkButton("templatesTabBtn", isTemplatesVisible, templatesLabel);
177+
await checkButton("tutorialsTabBtn", isTemplatesVisible, templatesLabel);
178178
await checkButton("appsTabBtn", isServicesVisible, servicesLabel);
179179
await checkButton("dataTabBtn", isDataVisible, dataLabel);
180180
});

β€Žtests/e2e-playwright/tests/conftest.pyβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,11 +643,11 @@ def find_and_click_template_in_dashboard(
643643
) -> Callable[[str], None]:
644644
def _(template_id: str) -> None:
645645
with log_context(logging.INFO, f"Finding {template_id=} in dashboard"):
646-
page.get_by_test_id("templatesTabBtn").click()
646+
page.get_by_test_id("tutorialsTabBtn").click()
647647
_textbox = page.get_by_test_id("searchBarFilter-textField-template")
648648
_textbox.fill(template_id)
649649
_textbox.press("Enter")
650-
test_id = "templateBrowserListItem_" + template_id
650+
test_id = "tutorialBrowserListItem_" + template_id
651651
page.get_by_test_id(test_id).click()
652652

653653
return _

0 commit comments

Comments
Β (0)