Skip to content

Commit 8b151c1

Browse files
author
Andrei Neagu
committed
Merge remote-tracking branch 'upstream/master' into pr-osparc-fix-orphan-task-removal
2 parents 2986429 + 35e7048 commit 8b151c1

File tree

12 files changed

+96
-44
lines changed

12 files changed

+96
-44
lines changed

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

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,7 @@ qx.Class.define("osparc.dashboard.CardBase", {
148148
return false;
149149
}
150150
case "shared-with-everyone": {
151-
const everyoneGroupIds = [
152-
groupsStore.getEveryoneProductGroup().getGroupId(),
153-
groupsStore.getEveryoneGroup().getGroupId(),
154-
];
151+
const everyoneGroupIds = groupsStore.getEveryoneGroupIds();
155152
const found = Object.keys(checks).some(gId => everyoneGroupIds.includes(parseInt(gId)));
156153
// show those that are shared with "1" or product everyone's groupId
157154
return !found;
@@ -190,13 +187,12 @@ qx.Class.define("osparc.dashboard.CardBase", {
190187

191188
// Icon
192189
const groupsStore = osparc.store.Groups.getInstance();
193-
const groupEveryone = groupsStore.getEveryoneGroup();
194-
const groupProductEveryone = groupsStore.getEveryoneProductGroup();
190+
const everyoneGroupIds = groupsStore.getEveryoneGroupIds();
195191
const organizations = groupsStore.getOrganizations();
196192
const myGroupId = groupsStore.getMyGroupId();
197193

198194
const organizationIds = Object.keys(organizations).map(key => parseInt(key));
199-
if (gids.includes(groupEveryone.getGroupId()) || gids.includes(groupProductEveryone.getGroupId())) {
195+
if (gids.some(gid => everyoneGroupIds.includes(gid))) {
200196
shareIcon.setSource(osparc.dashboard.CardBase.SHARED_ALL);
201197
} else if (organizationIds.filter(value => gids.includes(value)).length) { // find intersection
202198
shareIcon.setSource(osparc.dashboard.CardBase.SHARED_ORGS);
@@ -230,14 +226,11 @@ qx.Class.define("osparc.dashboard.CardBase", {
230226

231227
addHintFromGids: function(icon, gids) {
232228
const groupsStore = osparc.store.Groups.getInstance();
233-
const groupEveryone = groupsStore.getEveryoneGroup();
234-
const groupProductEveryone = groupsStore.getEveryoneProductGroup();
229+
const everyoneGroups = groupsStore.getEveryoneGroups();
235230
const organizations = groupsStore.getOrganizations();
236231
const myGroupId = groupsStore.getMyGroupId();
237232

238-
const groups = [];
239-
groups.push(groupEveryone);
240-
groups.push(groupProductEveryone);
233+
const groups = everyoneGroups.slice();
241234
groups.push(...Object.values(organizations));
242235
const sharedGrps = [];
243236
groups.forEach(group => {
@@ -275,7 +268,7 @@ qx.Class.define("osparc.dashboard.CardBase", {
275268
break;
276269
}
277270
let sharedGrpLabel = sharedGrps[i].getLabel();
278-
if ([groupEveryone, groupProductEveryone].includes(sharedGrps[i])) {
271+
if (everyoneGroups.includes(sharedGrps[i])) {
279272
sharedGrpLabel = "Public";
280273
}
281274
if (!sharedGrpLabels.includes(sharedGrpLabel)) {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,10 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
323323
templates.forEach(template => template["resourceType"] = "template");
324324
// For now, filtered in the frontend
325325
const groupsStore = osparc.store.Groups.getInstance();
326-
const everyoneGid = groupsStore.getEveryoneGroup().getGroupId();
327-
const productEveryoneGid = groupsStore.getEveryoneProductGroup().getGroupId();
326+
const everyoneGroupIds = groupsStore.getEveryoneGroupIds();
328327
const filteredTemplates = templates.filter(template => {
329-
const publicAccess = everyoneGid in template["accessRights"] || productEveryoneGid in template["accessRights"];
328+
const templateGroupIds = Object.keys(template["accessRights"]);
329+
const publicAccess = templateGroupIds.some(gid => everyoneGroupIds.includes(parseInt(gid)));
330330
if ([
331331
osparc.dashboard.StudyBrowser.CONTEXT.PUBLIC_TEMPLATES,
332332
osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PUBLIC_TEMPLATES,

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ qx.Class.define("osparc.data.model.User", {
5959
firstName,
6060
lastName,
6161
email,
62+
phoneNumber: userData["phone"] || null,
6263
thumbnail,
6364
label: userData["userName"] || description,
6465
description,
@@ -122,6 +123,13 @@ qx.Class.define("osparc.data.model.User", {
122123
event: "changeEmail",
123124
},
124125

126+
phoneNumber: {
127+
check: "String",
128+
nullable: true,
129+
init: null,
130+
event: "changePhoneNumber"
131+
},
132+
125133
thumbnail: {
126134
check: "String",
127135
nullable: true,

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
5454
__userPrivacyModel: null,
5555
__updatePrivacyBtn: null,
5656
__userProfileForm: null,
57+
__sms2FAItem: null,
5758

5859
__fetchProfile: function() {
5960
osparc.data.Resources.getOne("profile", {}, null, false)
@@ -72,10 +73,15 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
7273
"firstName": data["first_name"] || "",
7374
"lastName": data["last_name"] || "",
7475
"email": data["login"],
76+
"phone": data["phone"] || "-",
7577
"expirationDate": data["expirationDate"] || null,
7678
});
7779
}
7880
this.__updateProfileBtn.setEnabled(false);
81+
82+
if (this.__sms2FAItem) {
83+
this.__sms2FAItem.setEnabled(Boolean(data["phone"]));
84+
}
7985
},
8086

8187
__setDataToPrivacy: function(privacyData) {
@@ -124,11 +130,19 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
124130
readOnly: true
125131
});
126132

133+
const phoneNumber = new qx.ui.form.TextField().set({
134+
placeholder: this.tr("Phone Number"),
135+
readOnly: true
136+
});
137+
127138
const profileForm = this.__userProfileForm = new qx.ui.form.Form();
128139
profileForm.add(username, "Username", null, "username");
129140
profileForm.add(firstName, "First Name", null, "firstName");
130141
profileForm.add(lastName, "Last Name", null, "lastName");
131142
profileForm.add(email, "Email", null, "email");
143+
if (osparc.store.StaticInfo.getInstance().is2FARequired()) {
144+
profileForm.add(phoneNumber, "Phone Number", null, "phoneNumber");
145+
}
132146
const singleWithIcon = this.__userProfileRenderer = new osparc.ui.form.renderer.SingleWithIcon(profileForm);
133147
box.add(singleWithIcon);
134148

@@ -155,6 +169,7 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
155169
"firstName": "",
156170
"lastName": "",
157171
"email": "",
172+
"phone": "",
158173
"expirationDate": null,
159174
};
160175

@@ -169,6 +184,7 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
169184
}
170185
});
171186
controller.addTarget(lastName, "value", "lastName", true);
187+
controller.addTarget(phoneNumber, "value", "phone", true);
172188
controller.addTarget(expirationDate, "value", "expirationDate", false, {
173189
converter: expirationDay => {
174190
if (expirationDay) {
@@ -404,6 +420,9 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
404420
label: "Disabled"
405421
}].forEach(options => {
406422
const lItem = new qx.ui.form.ListItem(options.label, null, options.id);
423+
if (options.id === "SMS") {
424+
this.__sms2FAItem = lItem;
425+
}
407426
twoFAPreferenceSB.add(lItem);
408427
});
409428
const value = preferencesSettings.getTwoFAPreference();

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -434,16 +434,13 @@ qx.Class.define("osparc.share.Collaborators", {
434434
// reload list
435435
this.__collaboratorsModel.removeAll();
436436

437+
const usersStore = osparc.store.Users.getInstance();
437438
const groupsStore = osparc.store.Groups.getInstance();
438-
const everyoneGIds = [
439-
groupsStore.getEveryoneProductGroup().getGroupId(),
440-
groupsStore.getEveryoneGroup().getGroupId()
441-
];
439+
const everyoneGroupIds = groupsStore.getEveryoneGroupIds();
440+
const allGroups = groupsStore.getAllGroups();
441+
const showOptions = this.__canIChangePermissions();
442442
const accessRights = this._serializedDataCopy["accessRights"];
443443
const collaboratorsList = [];
444-
const showOptions = this.__canIChangePermissions();
445-
const allGroups = groupsStore.getAllGroups();
446-
const usersStore = osparc.store.Users.getInstance();
447444
for (let i=0; i<Object.keys(accessRights).length; i++) {
448445
const gid = parseInt(Object.keys(accessRights)[i]);
449446
let collab = null;
@@ -462,7 +459,7 @@ qx.Class.define("osparc.share.Collaborators", {
462459
};
463460
if (!("getUserId" in collab)) {
464461
// organization
465-
if (everyoneGIds.includes(parseInt(gid))) {
462+
if (everyoneGroupIds.includes(parseInt(gid))) {
466463
collaborator["thumbnail"] = "@FontAwesome5Solid/globe/32";
467464
} else if (!collaborator["thumbnail"]) {
468465
collaborator["thumbnail"] = "@FontAwesome5Solid/users/26";

services/static-webserver/client/source/class/osparc/store/Groups.js

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ qx.Class.define("osparc.store.Groups", {
2828
properties: {
2929
everyoneGroup: {
3030
check: "osparc.data.model.Group",
31-
init: {}
31+
init: null // this will stay null for guest users
3232
},
3333

3434
everyoneProductGroup: {
3535
check: "osparc.data.model.Group",
36-
init: {}
36+
init: null // this will stay null for guest users
3737
},
3838

3939
organizations: {
@@ -120,10 +120,14 @@ qx.Class.define("osparc.store.Groups", {
120120
const allGroupsAndUsers = {};
121121

122122
const groupEveryone = this.getEveryoneGroup();
123-
allGroupsAndUsers[groupEveryone.getGroupId()] = groupEveryone;
123+
if (groupEveryone) {
124+
allGroupsAndUsers[groupEveryone.getGroupId()] = groupEveryone;
125+
}
124126

125127
const groupProductEveryone = this.getEveryoneProductGroup();
126-
allGroupsAndUsers[groupProductEveryone.getGroupId()] = groupProductEveryone;
128+
if (groupProductEveryone) {
129+
allGroupsAndUsers[groupProductEveryone.getGroupId()] = groupProductEveryone;
130+
}
127131

128132
const groupMe = this.getGroupMe();
129133
allGroupsAndUsers[groupMe.getGroupId()] = groupMe;
@@ -157,6 +161,22 @@ qx.Class.define("osparc.store.Groups", {
157161
return allMyGroupIds;
158162
},
159163

164+
getEveryoneGroupIds: function() {
165+
const everyoneGroupIds = this.getEveryoneGroups().map(g => g.getGroupId());
166+
return everyoneGroupIds;
167+
},
168+
169+
getEveryoneGroups: function() {
170+
const everyoneGroups = [];
171+
if (this.getEveryoneProductGroup()) {
172+
everyoneGroups.push(this.getEveryoneProductGroup());
173+
}
174+
if (this.getEveryoneGroup()) {
175+
everyoneGroups.push(this.getEveryoneGroup());
176+
}
177+
return everyoneGroups;
178+
},
179+
160180
getGroup: function(groupId) {
161181
const groups = [];
162182

@@ -177,12 +197,16 @@ qx.Class.define("osparc.store.Groups", {
177197
});
178198

179199
const groupProductEveryone = this.getEveryoneProductGroup();
180-
groupProductEveryone["collabType"] = 0;
181-
groups.push(groupProductEveryone);
200+
if (groupProductEveryone) {
201+
groupProductEveryone["collabType"] = 0;
202+
groups.push(groupProductEveryone);
203+
}
182204

183205
const groupEveryone = this.getEveryoneGroup();
184-
groupEveryone["collabType"] = 0;
185-
groups.push(groupEveryone);
206+
if (groupEveryone) {
207+
groupEveryone["collabType"] = 0;
208+
groups.push(groupEveryone);
209+
}
186210
const idx = groups.findIndex(group => group.getGroupId() === parseInt(groupId));
187211
if (idx > -1) {
188212
return groups[idx];

services/static-webserver/client/source/class/osparc/ui/list/CollaboratorListItem.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,7 @@ qx.Class.define("osparc.ui.list.CollaboratorListItem", {
129129
return;
130130
}
131131
const groupsStore = osparc.store.Groups.getInstance();
132-
const everyoneGroupIds = [
133-
groupsStore.getEveryoneProductGroup().getGroupId(),
134-
groupsStore.getEveryoneGroup().getGroupId(),
135-
];
132+
const everyoneGroupIds = groupsStore.getEveryoneGroupIds();
136133
const label = this.getChildControl("title");
137134
if (everyoneGroupIds.includes(this.getModel())) {
138135
label.setValue(this.tr("Public"));

services/web/server/src/simcore_service_webserver/invitations/_rest.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from pydantic import Field
1212
from servicelib.aiohttp.requests_validation import parse_request_body_as
1313
from servicelib.request_keys import RQT_USERID_KEY
14-
from yarl import URL
1514

1615
from .._meta import API_VTAG as VTAG
1716
from ..constants import RQ_PRODUCT_KEY
@@ -53,21 +52,19 @@ async def generate_invitation(request: web.Request):
5352
extra_credits_in_usd=body.extra_credits_in_usd,
5453
product=req_ctx.product_name,
5554
),
55+
request.url,
5656
)
5757
assert request.url.host # nosec
5858
assert generated.product == req_ctx.product_name # nosec
5959
assert generated.guest == body.guest # nosec
6060

61-
url = URL(f"{generated.invitation_url}")
62-
invitation_link = request.url.with_path(url.path).with_fragment(url.raw_fragment)
63-
6461
invitation = InvitationGenerated(
6562
product_name=generated.product,
6663
issuer=generated.issuer,
6764
guest=generated.guest,
6865
trial_account_days=generated.trial_account_days,
6966
extra_credits_in_usd=generated.extra_credits_in_usd,
7067
created=generated.created,
71-
invitation_link=f"{invitation_link}", # type: ignore[arg-type]
68+
invitation_link=generated.invitation_url,
7269
)
7370
return envelope_json_response(invitation.model_dump(exclude_none=True))

services/web/server/src/simcore_service_webserver/invitations/_service.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
ApiInvitationInputs,
99
)
1010
from models_library.emails import LowerCaseEmailStr
11-
from pydantic import AnyHttpUrl, TypeAdapter, ValidationError
11+
from pydantic import AnyHttpUrl, HttpUrl, TypeAdapter, ValidationError
12+
from yarl import URL
1213

1314
from ..groups.api import is_user_by_email_in_group
1415
from ..products.models import Product
@@ -134,7 +135,9 @@ async def extract_invitation(
134135

135136

136137
async def generate_invitation(
137-
app: web.Application, params: ApiInvitationInputs
138+
app: web.Application,
139+
params: ApiInvitationInputs,
140+
product_origin_url: URL,
138141
) -> ApiInvitationContentAndLink:
139142
"""
140143
Raises:
@@ -145,4 +148,10 @@ async def generate_invitation(
145148
invitation: ApiInvitationContentAndLink = await get_invitations_service_api(
146149
app=app
147150
).generate_invitation(params)
151+
152+
_normalized_url = URL(f"{invitation.invitation_url}")
153+
invitation.invitation_url = HttpUrl(
154+
f"{product_origin_url.with_path(_normalized_url.path).with_fragment(_normalized_url.raw_fragment)}"
155+
)
156+
148157
return invitation

services/web/server/src/simcore_service_webserver/users/_controller/rest/accounts_rest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,13 @@ async def approve_user_account(request: web.Request) -> web.Response:
164164
guest=approval_data.email,
165165
trial_account_days=approval_data.invitation.trial_account_days,
166166
extra_credits_in_usd=approval_data.invitation.extra_credits_in_usd,
167+
product=req_ctx.product_name,
167168
)
168169

169170
invitation_result = await invitations_service.generate_invitation(
170-
request.app, params=invitation_params
171+
request.app,
172+
params=invitation_params,
173+
product_origin_url=request.url.origin(),
171174
)
172175

173176
assert ( # nosec

0 commit comments

Comments
 (0)