Skip to content

Commit dfdd1c4

Browse files
pcrespovodeimaiz
andauthored
♻️ Is3669/access rights renaming (ITISFoundation#3674)
Co-authored-by: Odei Maiz <[email protected]>
1 parent 9457419 commit dfdd1c4

File tree

9 files changed

+40
-49
lines changed

9 files changed

+40
-49
lines changed

packages/models-library/src/models_library/services_access.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Service access rights models
22
33
"""
4-
from typing import Dict, Optional
4+
from typing import Optional
55

66
from pydantic import BaseModel, Field
77
from pydantic.types import PositiveInt
@@ -20,6 +20,8 @@ class ServiceGroupAccessRights(BaseModel):
2020

2121

2222
class ServiceAccessRights(BaseModel):
23-
access_rights: Optional[Dict[GroupId, ServiceGroupAccessRights]] = Field(
24-
None, description="service access rights per group id"
23+
access_rights: Optional[dict[GroupId, ServiceGroupAccessRights]] = Field(
24+
None,
25+
alias="accessRights",
26+
description="service access rights per group id",
2527
)

services/catalog/src/simcore_service_catalog/models/schemas/services.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Config:
1313
schema_extra = {
1414
"example": {
1515
# ServiceAccessRights
16-
"access_rights": {
16+
"accessRights": {
1717
1: {
1818
"execute_access": False,
1919
"write_access": False,
@@ -66,6 +66,7 @@ class ServiceGet(
6666
owner: Optional[EmailStr]
6767

6868
class Config:
69+
allow_population_by_field_name = True
6970
extra = Extra.ignore
7071
schema_extra = {
7172
"example": {
@@ -74,7 +75,7 @@ class Config:
7475
"description": "File Picker",
7576
"classifiers": [],
7677
"quality": {},
77-
"access_rights": {
78+
"accessRights": {
7879
"1": {"execute_access": True, "write_access": False},
7980
"4": {"execute_access": True, "write_access": True},
8081
},

services/static-webserver/client/source/class/osparc/component/metadata/QualityEditor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ qx.Class.define("osparc.component.metadata.QualityEditor", {
689689
const orgIDs = osparc.auth.Data.getInstance().getOrgIds();
690690
orgIDs.push(myGid);
691691
if (osparc.utils.Resources.isService(this.__resourceData)) {
692-
return osparc.component.permissions.Service.canAnyGroupWrite(this.__resourceData["access_rights"], orgIDs);
692+
return osparc.component.permissions.Service.canAnyGroupWrite(this.__resourceData["accessRights"], orgIDs);
693693
}
694694
return osparc.component.permissions.Study.canGroupsWrite(this.__resourceData["accessRights"], orgIDs);
695695
}

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ qx.Class.define("osparc.component.permissions.Permissions", {
232232
__reloadOrganizationsAndMembers: function() {
233233
this.__organizationsAndMembers.reset();
234234

235-
const aceessRights = this.__getAccessRights();
235+
const aceessRights = this._serializedData["accessRights"];
236236
const myFriends = Object.values(this.__collaborators);
237237

238238
// sort them first
@@ -273,7 +273,7 @@ qx.Class.define("osparc.component.permissions.Permissions", {
273273
__reloadCollaboratorsList: function() {
274274
this.__collaboratorsModel.removeAll();
275275

276-
const aceessRights = this.__getAccessRights();
276+
const aceessRights = this._serializedData["accessRights"];
277277
Object.keys(aceessRights).forEach(gid => {
278278
if (Object.prototype.hasOwnProperty.call(this.__collaborators, gid)) {
279279
const collaborator = this.__collaborators[gid];
@@ -289,10 +289,6 @@ qx.Class.define("osparc.component.permissions.Permissions", {
289289
});
290290
},
291291

292-
__getAccessRights: function() {
293-
return this._serializedData["accessRights"] || this._serializedData["access_rights"];
294-
},
295-
296292
_isUserOwner: function() {
297293
throw new Error("Abstract method called!");
298294
},

services/static-webserver/client/source/class/osparc/component/permissions/Service.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ qx.Class.define("osparc.component.permissions.Service", {
7272
},
7373

7474
removeCollaborator: function(serializedData, gid) {
75-
return delete serializedData["access_rights"][gid];
75+
return delete serializedData["accessRights"][gid];
7676
},
7777

7878
getEveryoneObj: function() {
@@ -90,7 +90,7 @@ qx.Class.define("osparc.component.permissions.Service", {
9090
members: {
9191
_isUserOwner: function() {
9292
const myGid = osparc.auth.Data.getInstance().getGroupId();
93-
const aceessRights = this._serializedData["access_rights"];
93+
const aceessRights = this._serializedData["accessRights"];
9494
if (myGid in aceessRights) {
9595
return aceessRights[myGid]["write_access"];
9696
}
@@ -103,7 +103,7 @@ qx.Class.define("osparc.component.permissions.Service", {
103103
return;
104104
}
105105
gids.forEach(gid => {
106-
this._serializedData["access_rights"][gid] = this.self().getCollaboratorAccessRight();
106+
this._serializedData["accessRights"][gid] = this.self().getCollaboratorAccessRight();
107107
});
108108
const params = {
109109
url: osparc.data.Resources.getServiceUrl(
@@ -152,7 +152,7 @@ qx.Class.define("osparc.component.permissions.Service", {
152152
},
153153

154154
_makeOwner: function(collaborator) {
155-
this._serializedData["access_rights"][collaborator["gid"]] = this.self().getOwnerAccessRight();
155+
this._serializedData["accessRights"][collaborator["gid"]] = this.self().getOwnerAccessRight();
156156
const params = {
157157
url: osparc.data.Resources.getServiceUrl(
158158
this._serializedData["key"],

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

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -236,57 +236,53 @@ qx.Class.define("osparc.dashboard.CardBase", {
236236
return this.getResourceType() === resourceType;
237237
},
238238

239-
__applyResourceData: function(studyData) {
239+
__applyResourceData: function(resourceData) {
240240
let defaultThumbnail = "";
241241
let uuid = null;
242242
let owner = "";
243-
let accessRights = {};
244243
let defaultHits = null;
245244
let workbench = null;
246-
switch (studyData["resourceType"]) {
245+
switch (resourceData["resourceType"]) {
247246
case "study":
248-
uuid = studyData.uuid ? studyData.uuid : uuid;
249-
owner = studyData.prjOwner ? studyData.prjOwner : owner;
250-
accessRights = studyData.accessRights ? studyData.accessRights : accessRights;
247+
uuid = resourceData.uuid ? resourceData.uuid : uuid;
248+
owner = resourceData.prjOwner ? resourceData.prjOwner : owner;
251249
defaultThumbnail = this.self().STUDY_ICON;
252-
workbench = studyData.workbench ? studyData.workbench : workbench;
250+
workbench = resourceData.workbench ? resourceData.workbench : workbench;
253251
break;
254252
case "template":
255-
uuid = studyData.uuid ? studyData.uuid : uuid;
256-
owner = studyData.prjOwner ? studyData.prjOwner : owner;
257-
accessRights = studyData.accessRights ? studyData.accessRights : accessRights;
253+
uuid = resourceData.uuid ? resourceData.uuid : uuid;
254+
owner = resourceData.prjOwner ? resourceData.prjOwner : owner;
258255
defaultThumbnail = this.self().TEMPLATE_ICON;
259-
workbench = studyData.workbench ? studyData.workbench : workbench;
256+
workbench = resourceData.workbench ? resourceData.workbench : workbench;
260257
break;
261258
case "service":
262-
uuid = studyData.key ? studyData.key : uuid;
263-
owner = studyData.owner ? studyData.owner : owner;
264-
accessRights = studyData.access_rights ? studyData.access_rights : accessRights;
259+
uuid = resourceData.key ? resourceData.key : uuid;
260+
owner = resourceData.owner ? resourceData.owner : owner;
265261
defaultThumbnail = this.self().SERVICE_ICON;
266-
if (osparc.data.model.Node.isComputational(studyData)) {
262+
if (osparc.data.model.Node.isComputational(resourceData)) {
267263
defaultThumbnail = this.self().COMP_SERVICE_ICON;
268264
}
269-
if (osparc.data.model.Node.isDynamic(studyData)) {
265+
if (osparc.data.model.Node.isDynamic(resourceData)) {
270266
defaultThumbnail = this.self().DYNAMIC_SERVICE_ICON;
271267
}
272268
defaultHits = 0;
273269
break;
274270
}
275271

276272
this.set({
277-
resourceType: studyData.resourceType,
273+
resourceType: resourceData.resourceType,
278274
uuid,
279-
title: studyData.name,
280-
description: studyData.description,
275+
title: resourceData.name,
276+
description: resourceData.description,
281277
owner,
282-
accessRights,
283-
lastChangeDate: studyData.lastChangeDate ? new Date(studyData.lastChangeDate) : null,
284-
icon: studyData.thumbnail || defaultThumbnail,
285-
state: studyData.state ? studyData.state : {},
286-
classifiers: studyData.classifiers && studyData.classifiers ? studyData.classifiers : [],
287-
quality: studyData.quality ? studyData.quality : null,
288-
uiMode: studyData.ui && studyData.ui.mode ? studyData.ui.mode : null,
289-
hits: studyData.hits ? studyData.hits : defaultHits,
278+
accessRights: resourceData.accessRights ? resourceData.accessRights : {},
279+
lastChangeDate: resourceData.lastChangeDate ? new Date(resourceData.lastChangeDate) : null,
280+
icon: resourceData.thumbnail || defaultThumbnail,
281+
state: resourceData.state ? resourceData.state : {},
282+
classifiers: resourceData.classifiers && resourceData.classifiers ? resourceData.classifiers : [],
283+
quality: resourceData.quality ? resourceData.quality : null,
284+
uiMode: resourceData.ui && resourceData.ui.mode ? resourceData.ui.mode : null,
285+
hits: resourceData.hits ? resourceData.hits : defaultHits,
290286
workbench
291287
});
292288
},

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,11 +282,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", {
282282
} else if (this.getGroupBy() === "shared") {
283283
let orgIds = [];
284284
if ("accessRights" in resourceData) {
285-
// study or templates
286285
orgIds = Object.keys(resourceData["accessRights"]);
287-
} else if ("access_rights" in resourceData) {
288-
// services
289-
orgIds = Object.keys(resourceData["access_rights"]);
290286
}
291287
if (orgIds.length === 0) {
292288
let noGroupContainer = this.__getGroupContainer("no-group");

services/static-webserver/client/source/class/osparc/info/ServiceUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ qx.Class.define("osparc.info.ServiceUtils", {
106106
createAccessRights: function(serviceData) {
107107
let permissions = "";
108108
const myGID = osparc.auth.Data.getInstance().getGroupId();
109-
const ar = serviceData["access_rights"];
109+
const ar = serviceData["accessRights"];
110110
if (myGID in ar) {
111111
if (ar[myGID]["write_access"]) {
112112
permissions = qx.locale.Manager.tr("Write");

services/static-webserver/client/source/class/osparc/utils/Services.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ qx.Class.define("osparc.utils.Services", {
194194
isOwner: function(serviceData) {
195195
const orgIDs = osparc.auth.Data.getInstance().getOrgIds();
196196
orgIDs.push(osparc.auth.Data.getInstance().getGroupId());
197-
return osparc.component.permissions.Service.canAnyGroupWrite(serviceData["access_rights"], orgIDs);
197+
return osparc.component.permissions.Service.canAnyGroupWrite(serviceData["accessRights"], orgIDs);
198198
},
199199

200200
/**

0 commit comments

Comments
 (0)