Skip to content

Commit 4fa268d

Browse files
committed
WORKSPACE
1 parent dd75ef6 commit 4fa268d

File tree

1 file changed

+19
-38
lines changed

1 file changed

+19
-38
lines changed

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

Lines changed: 19 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -34,30 +34,6 @@ qx.Class.define("osparc.share.CollaboratorsWorkspace", {
3434
canIDelete: function(myAccessRights) {
3535
return myAccessRights["delete"];
3636
},
37-
38-
getViewerAccessRight: function() {
39-
return {
40-
"read": true,
41-
"write": false,
42-
"delete": false
43-
};
44-
},
45-
46-
getCollaboratorAccessRight: function() {
47-
return {
48-
"read": true,
49-
"write": true,
50-
"delete": false
51-
};
52-
},
53-
54-
getOwnerAccessRight: function() {
55-
return {
56-
"read": true,
57-
"write": true,
58-
"delete": true
59-
};
60-
}
6137
},
6238

6339
members: {
@@ -68,8 +44,9 @@ qx.Class.define("osparc.share.CollaboratorsWorkspace", {
6844
return;
6945
}
7046

47+
const writeAccessRole = osparc.data.Roles.WORKSPACE["write"];
7148
const newCollaborators = {};
72-
gids.forEach(gid => newCollaborators[gid] = this.self().getCollaboratorAccessRight());
49+
gids.forEach(gid => newCollaborators[gid] = writeAccessRole.accessRights);
7350
osparc.store.Workspaces.getInstance().addCollaborators(this.__workspace.getWorkspaceId(), newCollaborators)
7451
.then(() => {
7552
const text = this.tr("Workspace successfully shared");
@@ -117,40 +94,43 @@ qx.Class.define("osparc.share.CollaboratorsWorkspace", {
11794
},
11895

11996
_promoteToEditor: function(collaborator, item) {
97+
const writeAccessRole = osparc.data.Roles.WORKSPACE["write"];
12098
this.__make(
12199
collaborator["gid"],
122-
this.self().getCollaboratorAccessRight(),
123-
this.tr(`Successfully promoted to ${osparc.data.Roles.WORKSPACE["write"].label}`),
124-
this.tr(`Something went wrong while promoting to ${osparc.data.Roles.WORKSPACE["write"].label}`),
100+
writeAccessRole.accessRights,
101+
this.tr(`Successfully promoted to ${writeAccessRole.label}`),
102+
this.tr(`Something went wrong while promoting to ${writeAccessRole.label}`),
125103
item
126104
);
127105
},
128106

129107
_promoteToOwner: function(collaborator, item) {
108+
const deleteAccessRole = osparc.data.Roles.WORKSPACE["delete"];
130109
this.__make(
131110
collaborator["gid"],
132-
this.self().getOwnerAccessRight(),
133-
this.tr(`Successfully promoted to ${osparc.data.Roles.WORKSPACE["delete"].label}`),
134-
this.tr(`Something went wrong while promoting to ${osparc.data.Roles.WORKSPACE["delete"].label}`),
111+
deleteAccessRole.accessRights,
112+
this.tr(`Successfully promoted to ${deleteAccessRole.label}`),
113+
this.tr(`Something went wrong while promoting to ${deleteAccessRole.label}`),
135114
item
136115
);
137116
},
138117

139118
_demoteToUser: async function(collaborator, item) {
119+
const readAccessRole = osparc.data.Roles.WORKSPACE["read"];
140120
const groupId = collaborator["gid"];
141121
const demoteToUser = (gid, itm) => {
142122
this.__make(
143123
gid,
144-
this.self().getViewerAccessRight(),
145-
this.tr(`Successfully demoted to ${osparc.data.Roles.WORKSPACE["read"].label}`),
146-
this.tr(`Something went wrong while demoting to ${osparc.data.Roles.WORKSPACE["read"].label}`),
124+
readAccessRole.accessRights,
125+
this.tr(`Successfully demoted to ${readAccessRole.label}`),
126+
this.tr(`Something went wrong while demoting to ${readAccessRole.label}`),
147127
itm
148128
);
149129
};
150130

151131
const group = osparc.store.Groups.getInstance().getOrganization(groupId);
152132
if (group) {
153-
const msg = this.tr(`Demoting to ${osparc.data.Roles.WORKSPACE["read"].label} will remove write access to all the members of the Organization. Are you sure?`);
133+
const msg = this.tr(`Demoting to ${readAccessRole.label} will remove write access to all the members of the Organization. Are you sure?`);
154134
const win = new osparc.ui.window.Confirmation(msg).set({
155135
caption: this.tr("Demote"),
156136
confirmAction: "delete",
@@ -169,11 +149,12 @@ qx.Class.define("osparc.share.CollaboratorsWorkspace", {
169149
},
170150

171151
_demoteToEditor: function(collaborator, item) {
152+
const writeAccessRole = osparc.data.Roles.WORKSPACE["write"];
172153
this.__make(
173154
collaborator["gid"],
174-
this.self().getCollaboratorAccessRight(),
175-
this.tr(`Successfully demoted to ${osparc.data.Roles.WORKSPACE["write"].label}`),
176-
this.tr(`Something went wrong while demoting to ${osparc.data.Roles.WORKSPACE["write"].label}`),
155+
writeAccessRole.accessRights,
156+
this.tr(`Successfully demoted to ${writeAccessRole.label}`),
157+
this.tr(`Something went wrong while demoting to ${writeAccessRole.label}`),
177158
item
178159
);
179160
}

0 commit comments

Comments
 (0)