Skip to content

Commit fe16fe8

Browse files
authored
Merge branch 'master' into enh/update-guided-trours
2 parents 84883c0 + bba85b1 commit fe16fe8

File tree

11 files changed

+231
-64
lines changed

11 files changed

+231
-64
lines changed

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

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,29 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
141141
__classifiersPage: null,
142142
__qualityPage: null,
143143

144-
__addOpenButton: function(page) {
144+
__addToolbarButtons: function(page) {
145145
const resourceData = this.__resourceData;
146146

147147
const toolbar = this.self().createToolbar();
148148
page.addToHeader(toolbar);
149149

150-
if (["study", "template"].includes(this.__resourceData["resourceType"])) {
150+
if (["study", "template", "tutorial"].includes(resourceData["resourceType"])) {
151+
const cantReadServices = osparc.study.Utils.getCantReadServices(resourceData["services"]);
152+
if (cantReadServices.length) {
153+
const requestAccessButton = new qx.ui.form.Button(this.tr("Request Apps Access"));
154+
osparc.dashboard.resources.pages.BasePage.decorateHeaderButton(requestAccessButton);
155+
requestAccessButton.set({
156+
minWidth: 170,
157+
maxWidth: 170,
158+
});
159+
requestAccessButton.addListener("execute", () => {
160+
osparc.share.RequestServiceAccess.openRequestAccess(cantReadServices);
161+
});
162+
toolbar.add(requestAccessButton);
163+
}
164+
}
165+
166+
if (this.__resourceData["resourceType"] === "study") {
151167
const payDebtButton = new qx.ui.form.Button(this.tr("Credits required"));
152168
page.payDebtButton = payDebtButton;
153169
osparc.dashboard.resources.pages.BasePage.decorateHeaderButton(payDebtButton);
@@ -405,7 +421,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
405421
const title = this.tr("Overview");
406422
const iconSrc = "@FontAwesome5Solid/info/22";
407423
const page = this.__infoPage = new osparc.dashboard.resources.pages.BasePage(title, iconSrc, id);
408-
this.__addOpenButton(page);
424+
this.__addToolbarButtons(page);
409425

410426
const lazyLoadContent = () => {
411427
const resourceData = this.__resourceData;
@@ -446,7 +462,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
446462
const title = this.tr("Billing Settings");
447463
const iconSrc = "@FontAwesome5Solid/cogs/22";
448464
const page = this.__billingSettings = new osparc.dashboard.resources.pages.BasePage(title, iconSrc, id);
449-
this.__addOpenButton(page);
465+
this.__addToolbarButtons(page);
450466

451467
if (resourceData["resourceType"] === "study") {
452468
const canBeOpened = osparc.study.Utils.canShowBillingOptions(resourceData);
@@ -473,7 +489,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
473489
const title = this.tr("Tiers");
474490
const iconSrc = "@FontAwesome5Solid/server/22";
475491
const page = new osparc.dashboard.resources.pages.BasePage(title, iconSrc, id);
476-
this.__addOpenButton(page);
492+
this.__addToolbarButtons(page);
477493

478494
const lazyLoadContent = () => {
479495
const pricingUnitsList = new osparc.service.PricingUnitsList(resourceData);
@@ -502,7 +518,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
502518
const title = this.tr("Pipeline View");
503519
const iconSrc = "@FontAwesome5Solid/eye/22";
504520
const page = new osparc.dashboard.resources.pages.BasePage(title, iconSrc, id);
505-
this.__addOpenButton(page);
521+
this.__addToolbarButtons(page);
506522

507523
const studyData = this.__resourceData;
508524
const enabled = osparc.study.Utils.canShowPreview(studyData);
@@ -528,7 +544,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
528544
const title = this.tr("Conversations");
529545
const iconSrc = "@FontAwesome5Solid/comments/22";
530546
const page = new osparc.dashboard.resources.pages.BasePage(title, iconSrc, id);
531-
this.__addOpenButton(page);
547+
this.__addToolbarButtons(page);
532548

533549
const lazyLoadContent = () => {
534550
const conversations = new osparc.study.Conversations(resourceData);
@@ -544,7 +560,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
544560
const title = this.tr("Sharing");
545561
const iconSrc = "@FontAwesome5Solid/share-alt/22";
546562
const page = this.__permissionsPage = new osparc.dashboard.resources.pages.BasePage(title, iconSrc, id);
547-
this.__addOpenButton(page);
563+
this.__addToolbarButtons(page);
548564

549565
const lazyLoadContent = () => {
550566
const resourceData = this.__resourceData;
@@ -587,7 +603,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
587603
const title = this.tr("Classifiers");
588604
const iconSrc = "@FontAwesome5Solid/search/22";
589605
const page = this.__classifiersPage = new osparc.dashboard.resources.pages.BasePage(title, iconSrc, id);
590-
this.__addOpenButton(page);
606+
this.__addToolbarButtons(page);
591607

592608
const lazyLoadContent = () => {
593609
const resourceData = this.__resourceData;
@@ -625,7 +641,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
625641
const title = this.tr("Quality");
626642
const iconSrc = "@FontAwesome5Solid/star-half/22";
627643
const page = this.__qualityPage = new osparc.dashboard.resources.pages.BasePage(title, iconSrc, id);
628-
this.__addOpenButton(page);
644+
this.__addToolbarButtons(page);
629645

630646
const lazyLoadContent = () => {
631647
const qualityEditor = new osparc.metadata.QualityEditor(resourceData);
@@ -655,7 +671,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
655671
const title = this.tr("Tags");
656672
const iconSrc = "@FontAwesome5Solid/tags/22";
657673
const page = this.__tagsPage = new osparc.dashboard.resources.pages.BasePage(title, iconSrc, id);
658-
this.__addOpenButton(page);
674+
this.__addToolbarButtons(page);
659675

660676
const lazyLoadContent = () => {
661677
const tagManager = new osparc.form.tag.TagManager(resourceData);
@@ -681,7 +697,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
681697
const title = this.tr("Services Updates");
682698
const iconSrc = "@MaterialIcons/update/24";
683699
const page = this.__servicesUpdatePage = new osparc.dashboard.resources.pages.BasePage(title, iconSrc, id);
684-
this.__addOpenButton(page);
700+
this.__addToolbarButtons(page);
685701

686702
const studyData = this.__resourceData;
687703
const enabled = osparc.study.Utils.canShowServiceUpdates(studyData);
@@ -713,7 +729,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
713729
const title = this.tr("Boot Options");
714730
const iconSrc = "@FontAwesome5Solid/play-circle/22";
715731
const page = new osparc.dashboard.resources.pages.BasePage(title, iconSrc, id);
716-
this.__addOpenButton(page);
732+
this.__addToolbarButtons(page);
717733

718734
const studyData = this.__resourceData;
719735
const enabled = osparc.study.Utils.canShowServiceBootOptions(studyData);
@@ -829,7 +845,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
829845
},
830846

831847
__getCreateFunctionsPage: function() {
832-
if (osparc.utils.DisabledPlugins.isFunctionsDisabled()) {
848+
if (!osparc.data.Permissions.getInstance().checkFunctionPermissions("writeFunctions")) {
833849
return null;
834850
}
835851

services/static-webserver/client/source/class/osparc/data/Permissions.js

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ qx.Class.define("osparc.data.Permissions", {
192192
},
193193

194194
members: {
195+
__permissions: null,
196+
__functionPermissions: null,
197+
195198
arePermissionsReady() {
196199
return this.getRole() !== null;
197200
},
@@ -276,19 +279,44 @@ qx.Class.define("osparc.data.Permissions", {
276279
return canDo;
277280
},
278281

279-
checkCanDo: function(action) {
280-
return new Promise((resolve, reject) => {
281-
osparc.data.Resources.get("permissions")
282-
.then(permissions => {
283-
const found = permissions.find(permission => permission["name"] === action);
284-
if (found) {
285-
resolve(found["allowed"]);
286-
} else {
287-
resolve(false);
288-
}
289-
})
290-
.catch(err => reject(err));
291-
});
282+
fetchPermissions: function() {
283+
osparc.data.Resources.get("permissions")
284+
.then(permissions => {
285+
this.__permissions = permissions;
286+
})
287+
.catch(err => console.error(err));
288+
},
289+
290+
checkMyGroupCanDo: function(action) {
291+
if (this.__permissions) {
292+
const found = this.__permissions.find(permission => permission["name"] === action);
293+
if (found) {
294+
return found["allowed"];
295+
}
296+
}
297+
return false;
298+
},
299+
300+
fetchFunctionPermissions: function() {
301+
osparc.data.Resources.get("functionPermissions")
302+
.then(functionPermissions => {
303+
this.__functionPermissions = functionPermissions;
304+
})
305+
.catch(err => console.error(err));
306+
},
307+
308+
checkFunctionPermissions: function(action) {
309+
if (osparc.utils.DisabledPlugins.isFunctionsDisabled()) {
310+
return false;
311+
}
312+
313+
if (
314+
this.__functionPermissions &&
315+
action in this.__functionPermissions
316+
) {
317+
return this.__functionPermissions[action];
318+
}
319+
return false;
292320
},
293321

294322
isTester: function() {

services/static-webserver/client/source/class/osparc/data/Resources.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,18 @@ qx.Class.define("osparc.data.Resources", {
837837
}
838838
}
839839
},
840+
/*
841+
* FUNCTION PERMISSIONS
842+
*/
843+
"functionPermissions": {
844+
useCache: true,
845+
endpoints: {
846+
get: {
847+
method: "GET",
848+
url: statics.API + "/me/function-permissions"
849+
}
850+
}
851+
},
840852
/*
841853
* API-KEYS
842854
*/

services/static-webserver/client/source/class/osparc/desktop/MainPage.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ qx.Class.define("osparc.desktop.MainPage", {
7070
preloadPromises.push(osparc.store.Products.getInstance().fetchUiConfig());
7171
preloadPromises.push(osparc.store.PollTasks.getInstance().fetchTasks());
7272
preloadPromises.push(osparc.store.Jobs.getInstance().fetchJobsLatest());
73+
preloadPromises.push(osparc.data.Permissions.getInstance().fetchPermissions());
74+
preloadPromises.push(osparc.data.Permissions.getInstance().fetchFunctionPermissions());
7375
Promise.all(preloadPromises)
7476
.then(() => {
7577
const mainStack = this.__createMainStack();

services/static-webserver/client/source/class/osparc/desktop/WorkbenchView.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,8 +1090,6 @@ qx.Class.define("osparc.desktop.WorkbenchView", {
10901090
}
10911091

10921092
const nodeOptions = new osparc.widget.NodeOptions(node);
1093-
nodeOptions.buildLayout();
1094-
10951093
return nodeOptions;
10961094
},
10971095

services/static-webserver/client/source/class/osparc/share/CollaboratorsStudy.js

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -235,32 +235,7 @@ qx.Class.define("osparc.share.CollaboratorsStudy", {
235235
if (gids.length === 0) {
236236
return;
237237
}
238-
239-
const promises = [];
240-
gids.forEach(gid => {
241-
const params = {
242-
url: {
243-
"studyId": this._serializedDataCopy["uuid"],
244-
"gid": gid
245-
}
246-
};
247-
promises.push(osparc.data.Resources.fetch("studies", "checkShareePermissions", params));
248-
});
249-
Promise.all(promises)
250-
.then(values => {
251-
const noAccessible = values.filter(value => value["accessible"] === false);
252-
if (noAccessible.length) {
253-
const shareePermissions = new osparc.share.ShareePermissions(noAccessible);
254-
const win = osparc.ui.window.Window.popUpInWindow(shareePermissions, this.tr("Sharee permissions"), 500, 500, "@FontAwesome5Solid/exclamation-triangle/14").set({
255-
clickAwayClose: false,
256-
resizable: true,
257-
showClose: true
258-
});
259-
win.getChildControl("icon").set({
260-
textColor: "warning-yellow"
261-
});
262-
}
263-
});
238+
osparc.share.ShareePermissions.checkShareePermissions(this._serializedDataCopy["uuid"], gids);
264239
}
265240
}
266241
});
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* oSPARC - The SIMCORE frontend - https://osparc.io
3+
* Copyright: 2025 IT'IS Foundation - https://itis.swiss
4+
* License: MIT - https://opensource.org/licenses/MIT
5+
* Authors: Odei Maiz (odeimaiz)
6+
*/
7+
8+
qx.Class.define("osparc.share.RequestServiceAccess", {
9+
extend: qx.ui.core.Widget,
10+
11+
construct: function(cantReadServicesData) {
12+
this.base(arguments);
13+
14+
this._setLayout(new qx.ui.layout.VBox(25));
15+
16+
this.__populateLayout(cantReadServicesData);
17+
},
18+
19+
statics: {
20+
openRequestAccess: function(cantReadServicesData) {
21+
const requestServiceAccess = new osparc.share.RequestServiceAccess(cantReadServicesData);
22+
const caption = qx.locale.Manager.tr("Request Apps Access");
23+
osparc.ui.window.Window.popUpInWindow(requestServiceAccess, caption, 600, 400).set({
24+
clickAwayClose: false,
25+
resizable: true,
26+
showClose: true
27+
});
28+
}
29+
},
30+
31+
members: {
32+
__populateLayout: function(cantReadServicesData) {
33+
const text = this.tr("In order to open the project, the following users/groups need to give you access to some apps. Please contact the app owner:");
34+
this._add(new qx.ui.basic.Label().set({
35+
value: text,
36+
font: "text-14",
37+
rich: true,
38+
wrap: true
39+
}));
40+
41+
const grid = new qx.ui.layout.Grid(20, 10);
42+
const layout = new qx.ui.container.Composite(grid);
43+
this._add(layout);
44+
45+
// Header
46+
layout.add(new qx.ui.basic.Label(this.tr("Owner")), {
47+
row: 0,
48+
column: 0
49+
});
50+
layout.add(new qx.ui.basic.Label(this.tr("Email")), {
51+
row: 0,
52+
column: 1
53+
});
54+
layout.add(new qx.ui.basic.Label(this.tr("App")), {
55+
row: 0,
56+
column: 2
57+
});
58+
59+
// Populate the grid with the cantReadServicesData
60+
cantReadServicesData.forEach((cantReadServiceData, idx) => {
61+
const group = osparc.store.Groups.getInstance().getGroup(cantReadServiceData["owner"]);
62+
if (group) {
63+
const username = new qx.ui.basic.Label(group.getLabel()).set({
64+
rich: true,
65+
selectable: true,
66+
});
67+
layout.add(username, {
68+
row: idx+1,
69+
column: 0
70+
});
71+
const email = new qx.ui.basic.Label(group.getEmail()).set({
72+
rich: true,
73+
selectable: true,
74+
});
75+
layout.add(email, {
76+
row: idx+1,
77+
column: 1
78+
});
79+
const appLabel = new qx.ui.basic.Label().set({
80+
value: `${cantReadServiceData["key"]}:${osparc.service.Utils.extractVersionDisplay(cantReadServiceData["release"])}`,
81+
rich: true,
82+
selectable: true,
83+
});
84+
layout.add(appLabel, {
85+
row: idx+1,
86+
column: 2
87+
});
88+
}
89+
});
90+
}
91+
}
92+
});

0 commit comments

Comments
 (0)