Skip to content

Commit f38a0f0

Browse files
committed
STUDY
1 parent 5599d99 commit f38a0f0

File tree

3 files changed

+42
-43
lines changed

3 files changed

+42
-43
lines changed

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,22 +80,37 @@ qx.Class.define("osparc.data.Roles", {
8080
longLabel: qx.locale.Manager.tr("User: Read access"),
8181
canDo: [
8282
qx.locale.Manager.tr("- can open it")
83-
]
83+
],
84+
accessRights: {
85+
"read": true,
86+
"write": false,
87+
"delete": false
88+
},
8489
},
8590
"write": {
8691
label: qx.locale.Manager.tr("Editor"),
8792
longLabel: qx.locale.Manager.tr("Editor: Read/Write access"),
8893
canDo: [
8994
qx.locale.Manager.tr("- can make changes"),
9095
qx.locale.Manager.tr("- can share it")
91-
]
96+
],
97+
accessRights: {
98+
"read": true,
99+
"write": true,
100+
"delete": false
101+
},
92102
},
93103
"delete": {
94104
label: qx.locale.Manager.tr("Owner"),
95105
longLabel: qx.locale.Manager.tr("Owner: Read/Write/Delete access"),
96106
canDo: [
97107
qx.locale.Manager.tr("- can delete it")
98-
]
108+
],
109+
accessRights: {
110+
"read": true,
111+
"write": true,
112+
"delete": true
113+
},
99114
}
100115
},
101116
SERVICES: {

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

Lines changed: 20 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -57,30 +57,6 @@ qx.Class.define("osparc.share.CollaboratorsStudy", {
5757
return canWrite;
5858
},
5959

60-
getViewerAccessRight: function() {
61-
return {
62-
"read": true,
63-
"write": false,
64-
"delete": false
65-
};
66-
},
67-
68-
getCollaboratorAccessRight: function() {
69-
return {
70-
"read": true,
71-
"write": true,
72-
"delete": false
73-
};
74-
},
75-
76-
getOwnerAccessRight: function() {
77-
return {
78-
"read": true,
79-
"write": true,
80-
"delete": true
81-
};
82-
},
83-
8460
__getDeleters: function(studyData) {
8561
const deleters = [];
8662
Object.entries(studyData["accessRights"]).forEach(([key, value]) => {
@@ -107,12 +83,14 @@ qx.Class.define("osparc.share.CollaboratorsStudy", {
10783
return;
10884
}
10985

86+
const readAccessRole = osparc.data.Roles.STUDY["read"];
87+
const writeAccessRole = osparc.data.Roles.STUDY["read"];
11088
const resourceAlias = this._resourceType === "template" ?
11189
osparc.product.Utils.getTemplateAlias({firstUpperCase: true}) :
11290
osparc.product.Utils.getStudyAlias({firstUpperCase: true});
11391
const newCollaborators = {};
11492
gids.forEach(gid => {
115-
newCollaborators[gid] = this._resourceType === "study" ? this.self().getCollaboratorAccessRight() : this.self().getViewerAccessRight();
93+
newCollaborators[gid] = this._resourceType === "study" ? writeAccessRole.accessRights : readAccessRole.accessRights
11694
});
11795
osparc.store.Study.addCollaborators(this._serializedDataCopy, newCollaborators)
11896
.then(() => {
@@ -164,40 +142,43 @@ qx.Class.define("osparc.share.CollaboratorsStudy", {
164142
},
165143

166144
_promoteToEditor: function(collaborator, item) {
145+
const writeAccessRole = osparc.data.Roles.STUDY["write"];
167146
this.__make(
168147
collaborator["gid"],
169-
this.self().getCollaboratorAccessRight(),
170-
this.tr(`Successfully promoted to ${osparc.data.Roles.STUDY["write"].label}`),
171-
this.tr(`Something went wrong while promoting to ${osparc.data.Roles.STUDY["write"].label}`),
148+
writeAccessRole.accessRights,
149+
this.tr(`Successfully promoted to ${writeAccessRole.label}`),
150+
this.tr(`Something went wrong while promoting to ${writeAccessRole.label}`),
172151
item
173152
);
174153
},
175154

176155
_promoteToOwner: function(collaborator, item) {
156+
const deleteAccessRole = osparc.data.Roles.STUDY["delete"];
177157
this.__make(
178158
collaborator["gid"],
179-
this.self().getOwnerAccessRight(),
180-
this.tr(`Successfully promoted to ${osparc.data.Roles.STUDY["delete"].label}`),
181-
this.tr(`Something went wrong while promoting to ${osparc.data.Roles.STUDY["delete"].label}`),
159+
deleteAccessRole.accessRights,
160+
this.tr(`Successfully promoted to ${deleteAccessRole.label}`),
161+
this.tr(`Something went wrong while promoting to ${deleteAccessRole.label}`),
182162
item
183163
);
184164
},
185165

186166
_demoteToUser: async function(collaborator, item) {
167+
const readAccessRole = osparc.data.Roles.STUDY["read"];
187168
const groupId = collaborator["gid"];
188169
const demoteToUser = (gid, itm) => {
189170
this.__make(
190171
gid,
191-
this.self().getViewerAccessRight(),
192-
this.tr(`Successfully demoted to ${osparc.data.Roles.STUDY["read"].label}`),
193-
this.tr(`Something went wrong while demoting to ${osparc.data.Roles.STUDY["read"].label}`),
172+
readAccessRole.accessRights,
173+
this.tr(`Successfully demoted to ${readAccessRole.label}`),
174+
this.tr(`Something went wrong while demoting to ${readAccessRole.label}`),
194175
itm
195176
);
196177
};
197178

198179
const organization = osparc.store.Groups.getInstance().getOrganization(groupId);
199180
if (organization) {
200-
const msg = this.tr(`Demoting to ${osparc.data.Roles.STUDY["read"].label} will remove write access to all the members of the Organization. Are you sure?`);
181+
const msg = this.tr(`Demoting to ${readAccessRole.label} will remove write access to all the members of the Organization. Are you sure?`);
201182
const win = new osparc.ui.window.Confirmation(msg).set({
202183
caption: this.tr("Demote"),
203184
confirmAction: "delete",
@@ -216,11 +197,12 @@ qx.Class.define("osparc.share.CollaboratorsStudy", {
216197
},
217198

218199
_demoteToEditor: function(collaborator, item) {
200+
const writeAccessRole = osparc.data.Roles.STUDY["write"];
219201
this.__make(
220202
collaborator["gid"],
221-
this.self().getCollaboratorAccessRight(),
222-
this.tr(`Successfully demoted to ${osparc.data.Roles.STUDY["write"].label}`),
223-
this.tr(`Something went wrong while demoting to ${osparc.data.Roles.STUDY["write"].label}`),
203+
writeAccessRole.accessRights,
204+
this.tr(`Successfully demoted to ${writeAccessRole.label}`),
205+
this.tr(`Something went wrong while demoting to ${writeAccessRole.label}`),
224206
item
225207
);
226208
},

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,13 @@ qx.Class.define("osparc.share.PublishTemplate", {
8080
},
8181

8282
__updateAccessRights: function() {
83+
const readAccessRole = osparc.data.Roles.STUDY["read"];
84+
const deleteAccessRole = osparc.data.Roles.STUDY["delete"];
8385
// these "accessRights" are only used for repopulating potential collaborators in the AddCollaborators -> NewCollaboratorsManager
8486
const myGroupId = osparc.auth.Data.getInstance().getGroupId();
8587
this.__potentialTemplateData["accessRights"] = {};
86-
this.__potentialTemplateData["accessRights"][myGroupId] = osparc.share.CollaboratorsStudy.getOwnerAccessRight();
87-
this.getSelectedGroups().forEach(gid => this.__potentialTemplateData["accessRights"][gid] = osparc.share.CollaboratorsStudy.getViewerAccessRight());
88+
this.__potentialTemplateData["accessRights"][myGroupId] = deleteAccessRole.accessRights;
89+
this.getSelectedGroups().forEach(gid => this.__potentialTemplateData["accessRights"][gid] = readAccessRole.accessRights);
8890
},
8991

9092
getSelectedGroups: function() {

0 commit comments

Comments
 (0)