Skip to content

Commit d12b498

Browse files
committed
function role
1 parent 7049063 commit d12b498

File tree

2 files changed

+36
-49
lines changed

2 files changed

+36
-49
lines changed

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

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ qx.Class.define("osparc.data.Roles", {
7777
},
7878
}
7979
},
80-
// study & templates & functions
80+
// study & templates
8181
STUDY: {
8282
"read": {
8383
id: "read",
@@ -120,6 +120,35 @@ qx.Class.define("osparc.data.Roles", {
120120
},
121121
}
122122
},
123+
FUNCTION: {
124+
"read": {
125+
id: "read",
126+
label: qx.locale.Manager.tr("User"),
127+
longLabel: qx.locale.Manager.tr("User: Read access"),
128+
canDo: [
129+
qx.locale.Manager.tr("- Can open it without making changes")
130+
],
131+
accessRights: {
132+
"execute": true,
133+
"read": true,
134+
"write": false
135+
},
136+
},
137+
"write": {
138+
id: "write",
139+
label: qx.locale.Manager.tr("Owner"),
140+
longLabel: qx.locale.Manager.tr("Owner: Read/Write access"),
141+
canDo: [
142+
qx.locale.Manager.tr("- Can make changes"),
143+
qx.locale.Manager.tr("- Can share it")
144+
],
145+
accessRights: {
146+
"execute": true,
147+
"read": true,
148+
"write": true
149+
},
150+
},
151+
},
123152
SERVICES: {
124153
"read": {
125154
id: "read",

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

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -38,34 +38,6 @@ qx.Class.define("osparc.share.CollaboratorsFunction", {
3838
}
3939
return canWrite;
4040
},
41-
42-
canGroupsDelete: function(accessRights, gIds) {
43-
let canWrite = false;
44-
for (let i=0; i<gIds.length && !canWrite; i++) {
45-
const gid = gIds[i];
46-
canWrite = (gid in accessRights) ? accessRights[gid]["delete"] : false;
47-
}
48-
return canWrite;
49-
},
50-
51-
__getDeleters: function(functionData) {
52-
const deleters = [];
53-
Object.entries(functionData["accessRights"]).forEach(([key, value]) => {
54-
if (value["delete"]) {
55-
deleters.push(key);
56-
}
57-
});
58-
return deleters;
59-
},
60-
61-
// checks that if the user to remove is an owner, there will still be another owner
62-
canCollaboratorBeRemoved: function(functionData, gid) {
63-
const ownerGids = this.__getDeleters(functionData);
64-
if (ownerGids.includes(gid.toString())) {
65-
return ownerGids.length > 1;
66-
}
67-
return true;
68-
},
6941
},
7042

7143
members: {
@@ -74,8 +46,8 @@ qx.Class.define("osparc.share.CollaboratorsFunction", {
7446
return;
7547
}
7648

77-
const readAccessRole = osparc.data.Roles.STUDY["read"];
78-
const writeAccessRole = osparc.data.Roles.STUDY["write"];
49+
const readAccessRole = osparc.data.Roles.FUNCTION["read"];
50+
const writeAccessRole = osparc.data.Roles.FUNCTION["write"];
7951
if (!newAccessRights) {
8052
newAccessRights = this._resourceType === "function" ? writeAccessRole.accessRights : readAccessRole.accessRights;
8153
}
@@ -131,7 +103,7 @@ qx.Class.define("osparc.share.CollaboratorsFunction", {
131103
},
132104

133105
_promoteToEditor: function(collaborator, item) {
134-
const writeAccessRole = osparc.data.Roles.STUDY["write"];
106+
const writeAccessRole = osparc.data.Roles.FUNCTION["write"];
135107
this.__make(
136108
collaborator["gid"],
137109
writeAccessRole.accessRights,
@@ -142,18 +114,11 @@ qx.Class.define("osparc.share.CollaboratorsFunction", {
142114
},
143115

144116
_promoteToOwner: function(collaborator, item) {
145-
const deleteAccessRole = osparc.data.Roles.STUDY["delete"];
146-
this.__make(
147-
collaborator["gid"],
148-
deleteAccessRole.accessRights,
149-
this.tr(`Successfully promoted to ${deleteAccessRole.label}`),
150-
this.tr(`Something went wrong while promoting to ${deleteAccessRole.label}`),
151-
item
152-
);
117+
osparc.FlashMessenger.logAs(this.tr("Operation not available"), "WARNING");
153118
},
154119

155120
_demoteToUser: async function(collaborator, item) {
156-
const readAccessRole = osparc.data.Roles.STUDY["read"];
121+
const readAccessRole = osparc.data.Roles.FUNCTION["read"];
157122
const groupId = collaborator["gid"];
158123
const demoteToUser = (gid, itm) => {
159124
this.__make(
@@ -186,14 +151,7 @@ qx.Class.define("osparc.share.CollaboratorsFunction", {
186151
},
187152

188153
_demoteToEditor: function(collaborator, item) {
189-
const writeAccessRole = osparc.data.Roles.STUDY["write"];
190-
this.__make(
191-
collaborator["gid"],
192-
writeAccessRole.accessRights,
193-
this.tr(`Successfully demoted to ${writeAccessRole.label}`),
194-
this.tr(`Something went wrong while demoting to ${writeAccessRole.label}`),
195-
item
196-
);
154+
osparc.FlashMessenger.logAs(this.tr("Operation not available"), "WARNING");
197155
},
198156
}
199157
});

0 commit comments

Comments
 (0)