Skip to content

Commit 4448bff

Browse files
committed
Share with everyone
1 parent cc4d566 commit 4448bff

File tree

4 files changed

+35
-41
lines changed

4 files changed

+35
-41
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ qx.Class.define("osparc.share.Collaborators", {
3737

3838
this.__collaborators = {};
3939
initCollabs.forEach(initCollab => {
40-
this.__collaborators[initCollab["gid"]] = initCollab;
40+
this.__collaborators[initCollab.getGroupId()] = initCollab;
4141
});
4242
this.__getCollaborators();
4343
},
@@ -402,15 +402,16 @@ qx.Class.define("osparc.share.Collaborators", {
402402

403403
const groupsStore = osparc.store.Groups.getInstance();
404404
const everyoneGIds = [
405-
groupsStore.getEveryoneProductGroup()["gid"],
406-
groupsStore.getEveryoneGroup()["gid"]
405+
groupsStore.getEveryoneProductGroup().getGroupId(),
406+
groupsStore.getEveryoneGroup().getGroupId()
407407
];
408408
const accessRights = this._serializedDataCopy["accessRights"];
409409
const collaboratorsList = [];
410410
const showOptions = this.__canIChangePermissions();
411+
const allGroupsAndUsers = groupsStore.getAllGroupsAndUsers();
411412
Object.keys(accessRights).forEach(gid => {
412-
if (Object.prototype.hasOwnProperty.call(this.__collaborators, gid)) {
413-
const collab = this.__collaborators[gid];
413+
if (gid in allGroupsAndUsers) {
414+
const collab = allGroupsAndUsers[gid];
414415
// Do not override collaborator object
415416
const collaborator = {
416417
"gid": collab.getGroupId(),

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

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ qx.Class.define("osparc.share.CollaboratorsService", {
3535
const serviceDataCopy = osparc.utils.Utils.deepCloneObject(serviceData);
3636

3737
const initCollabs = [];
38-
initCollabs.push(this.self().getEveryoneProductObj());
39-
initCollabs.push(this.self().getEveryoneObj());
38+
const groupsStore = osparc.store.Groups.getInstance();
39+
const everyoneProductGroup = groupsStore.getEveryoneProductGroup();
40+
initCollabs.push(everyoneProductGroup);
4041

4142
this.base(arguments, serviceDataCopy, initCollabs);
4243
},
@@ -64,22 +65,6 @@ qx.Class.define("osparc.share.CollaboratorsService", {
6465
"write": true
6566
};
6667
},
67-
68-
getEveryoneProductObj: function() {
69-
const groupsStore = osparc.store.Groups.getInstance();
70-
const everyoneProductGroup = groupsStore.getEveryoneProductGroup();
71-
const everyone = osparc.utils.Utils.deepCloneObject(everyoneProductGroup);
72-
everyone["accessRights"] = this.getCollaboratorAccessRight();
73-
return everyone;
74-
},
75-
76-
getEveryoneObj: function() {
77-
const groupsStore = osparc.store.Groups.getInstance();
78-
const everyoneGroup = groupsStore.getEveryoneGroup();
79-
const everyone = osparc.utils.Utils.deepCloneObject(everyoneGroup);
80-
everyone["accessRights"] = this.getCollaboratorAccessRight();
81-
return everyone;
82-
}
8368
},
8469

8570
members: {

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

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ qx.Class.define("osparc.share.CollaboratorsStudy", {
3737

3838
const initCollabs = [];
3939
if (osparc.data.Permissions.getInstance().canDo("study.everyone.share")) {
40-
initCollabs.push(this.self().getEveryoneProductObj(this._resourceType === "study"));
41-
initCollabs.push(this.self().getEveryoneObj(this._resourceType === "study"));
40+
const groupsStore = osparc.store.Groups.getInstance();
41+
const everyoneProductGroup = groupsStore.getEveryoneProductGroup();
42+
initCollabs.push(everyoneProductGroup);
4243
}
4344

4445
this.base(arguments, studyDataCopy, initCollabs);
@@ -105,22 +106,6 @@ qx.Class.define("osparc.share.CollaboratorsStudy", {
105106
}
106107
return true;
107108
},
108-
109-
getEveryoneProductObj: function(isStudy) {
110-
const groupsStore = osparc.store.Groups.getInstance();
111-
const everyoneProductGroup = groupsStore.getEveryoneProductGroup();
112-
const everyone = osparc.utils.Utils.deepCloneObject(everyoneProductGroup);
113-
everyone["accessRights"] = isStudy ? this.getCollaboratorAccessRight() : this.getViewerAccessRight();
114-
return everyone;
115-
},
116-
117-
getEveryoneObj: function(isStudy) {
118-
const groupsStore = osparc.store.Groups.getInstance();
119-
const everyoneGroup = groupsStore.getEveryoneGroup();
120-
const everyone = osparc.utils.Utils.deepCloneObject(everyoneGroup);
121-
everyone["accessRights"] = isStudy ? this.getCollaboratorAccessRight() : this.getViewerAccessRight();
122-
return everyone;
123-
}
124109
},
125110

126111
members: {

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,29 @@ qx.Class.define("osparc.store.Groups", {
136136
})
137137
},
138138

139+
getAllGroupsAndUsers: function() {
140+
const allGroupsAndUsers = {};
141+
142+
const groupEveryone = this.getEveryoneGroup();
143+
allGroupsAndUsers[groupEveryone.getGroupId()] = groupEveryone;
144+
145+
const groupProductEveryone = this.getEveryoneProductGroup();
146+
allGroupsAndUsers[groupProductEveryone.getGroupId()] = groupProductEveryone;
147+
148+
const groupMe = this.getGroupMe();
149+
allGroupsAndUsers[groupMe.getGroupId()] = groupMe;
150+
151+
Object.values(this.getOrganizations()).forEach(organization => {
152+
allGroupsAndUsers[organization.getGroupId()] = organization;
153+
});
154+
155+
Object.values(this.getReachableUsers()).forEach(reachableUser => {
156+
allGroupsAndUsers[reachableUser.getGroupId()] = reachableUser;
157+
});
158+
159+
return allGroupsAndUsers;
160+
},
161+
139162
getMyGroupId: function() {
140163
return this.getGroupMe().getGroupId();
141164
},

0 commit comments

Comments
 (0)