Skip to content

Commit 4be5278

Browse files
committed
getEveryoneGroupIds
1 parent 73e055a commit 4be5278

File tree

4 files changed

+38
-32
lines changed

4 files changed

+38
-32
lines changed

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

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,7 @@ qx.Class.define("osparc.dashboard.CardBase", {
148148
return false;
149149
}
150150
case "shared-with-everyone": {
151-
const everyoneGroupIds = [
152-
groupsStore.getEveryoneProductGroup().getGroupId(),
153-
groupsStore.getEveryoneGroup().getGroupId(),
154-
];
151+
const everyoneGroupIds = groupsStore.getEveryoneGroupIds();
155152
const found = Object.keys(checks).some(gId => everyoneGroupIds.includes(parseInt(gId)));
156153
// show those that are shared with "1" or product everyone's groupId
157154
return !found;
@@ -190,13 +187,12 @@ qx.Class.define("osparc.dashboard.CardBase", {
190187

191188
// Icon
192189
const groupsStore = osparc.store.Groups.getInstance();
193-
const groupEveryone = groupsStore.getEveryoneGroup();
194-
const groupProductEveryone = groupsStore.getEveryoneProductGroup();
190+
const everyoneGroupIds = groupsStore.getEveryoneGroupIds();
195191
const organizations = groupsStore.getOrganizations();
196192
const myGroupId = groupsStore.getMyGroupId();
197193

198194
const organizationIds = Object.keys(organizations).map(key => parseInt(key));
199-
if (gids.includes(groupEveryone.getGroupId()) || gids.includes(groupProductEveryone.getGroupId())) {
195+
if (gids.some(gid => everyoneGroupIds.includes(gid))) {
200196
shareIcon.setSource(osparc.dashboard.CardBase.SHARED_ALL);
201197
} else if (organizationIds.filter(value => gids.includes(value)).length) { // find intersection
202198
shareIcon.setSource(osparc.dashboard.CardBase.SHARED_ORGS);
@@ -230,14 +226,11 @@ qx.Class.define("osparc.dashboard.CardBase", {
230226

231227
addHintFromGids: function(icon, gids) {
232228
const groupsStore = osparc.store.Groups.getInstance();
233-
const groupEveryone = groupsStore.getEveryoneGroup();
234-
const groupProductEveryone = groupsStore.getEveryoneProductGroup();
229+
const everyoneGroupIds = groupsStore.getEveryoneGroupIds();
235230
const organizations = groupsStore.getOrganizations();
236231
const myGroupId = groupsStore.getMyGroupId();
237232

238-
const groups = [];
239-
groups.push(groupEveryone);
240-
groups.push(groupProductEveryone);
233+
const groups = everyoneGroupIds;
241234
groups.push(...Object.values(organizations));
242235
const sharedGrps = [];
243236
groups.forEach(group => {

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -434,16 +434,13 @@ qx.Class.define("osparc.share.Collaborators", {
434434
// reload list
435435
this.__collaboratorsModel.removeAll();
436436

437+
const usersStore = osparc.store.Users.getInstance();
437438
const groupsStore = osparc.store.Groups.getInstance();
438-
const everyoneGIds = [
439-
groupsStore.getEveryoneProductGroup().getGroupId(),
440-
groupsStore.getEveryoneGroup().getGroupId()
441-
];
439+
const everyoneGroupIds = groupsStore.getEveryoneGroupIds();
440+
const allGroups = groupsStore.getAllGroups();
441+
const showOptions = this.__canIChangePermissions();
442442
const accessRights = this._serializedDataCopy["accessRights"];
443443
const collaboratorsList = [];
444-
const showOptions = this.__canIChangePermissions();
445-
const allGroups = groupsStore.getAllGroups();
446-
const usersStore = osparc.store.Users.getInstance();
447444
for (let i=0; i<Object.keys(accessRights).length; i++) {
448445
const gid = parseInt(Object.keys(accessRights)[i]);
449446
let collab = null;
@@ -462,7 +459,7 @@ qx.Class.define("osparc.share.Collaborators", {
462459
};
463460
if (!("getUserId" in collab)) {
464461
// organization
465-
if (everyoneGIds.includes(parseInt(gid))) {
462+
if (everyoneGroupIds.includes(parseInt(gid))) {
466463
collaborator["thumbnail"] = "@FontAwesome5Solid/globe/32";
467464
} else if (!collaborator["thumbnail"]) {
468465
collaborator["thumbnail"] = "@FontAwesome5Solid/users/26";

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

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ qx.Class.define("osparc.store.Groups", {
2828
properties: {
2929
everyoneGroup: {
3030
check: "osparc.data.model.Group",
31-
init: {}
31+
init: null // this will stay null for guest users
3232
},
3333

3434
everyoneProductGroup: {
3535
check: "osparc.data.model.Group",
36-
init: {}
36+
init: null // this will stay null for guest users
3737
},
3838

3939
organizations: {
@@ -120,10 +120,14 @@ qx.Class.define("osparc.store.Groups", {
120120
const allGroupsAndUsers = {};
121121

122122
const groupEveryone = this.getEveryoneGroup();
123-
allGroupsAndUsers[groupEveryone.getGroupId()] = groupEveryone;
123+
if (groupEveryone) {
124+
allGroupsAndUsers[groupEveryone.getGroupId()] = groupEveryone;
125+
}
124126

125127
const groupProductEveryone = this.getEveryoneProductGroup();
126-
allGroupsAndUsers[groupProductEveryone.getGroupId()] = groupProductEveryone;
128+
if (groupProductEveryone) {
129+
allGroupsAndUsers[groupProductEveryone.getGroupId()] = groupProductEveryone;
130+
}
127131

128132
const groupMe = this.getGroupMe();
129133
allGroupsAndUsers[groupMe.getGroupId()] = groupMe;
@@ -157,6 +161,17 @@ qx.Class.define("osparc.store.Groups", {
157161
return allMyGroupIds;
158162
},
159163

164+
getEveryoneGroupIds: function() {
165+
const everyoneGroupIds = [];
166+
if (this.getEveryoneProductGroup()) {
167+
everyoneGroupIds.push(this.getEveryoneProductGroup().getGroupId());
168+
}
169+
if (this.getEveryoneGroup()) {
170+
everyoneGroupIds.push(this.getEveryoneGroup().getGroupId());
171+
}
172+
return everyoneGroupIds;
173+
},
174+
160175
getGroup: function(groupId) {
161176
const groups = [];
162177

@@ -177,12 +192,16 @@ qx.Class.define("osparc.store.Groups", {
177192
});
178193

179194
const groupProductEveryone = this.getEveryoneProductGroup();
180-
groupProductEveryone["collabType"] = 0;
181-
groups.push(groupProductEveryone);
195+
if (groupProductEveryone) {
196+
groupProductEveryone["collabType"] = 0;
197+
groups.push(groupProductEveryone);
198+
}
182199

183200
const groupEveryone = this.getEveryoneGroup();
184-
groupEveryone["collabType"] = 0;
185-
groups.push(groupEveryone);
201+
if (groupEveryone) {
202+
groupEveryone["collabType"] = 0;
203+
groups.push(groupEveryone);
204+
}
186205
const idx = groups.findIndex(group => group.getGroupId() === parseInt(groupId));
187206
if (idx > -1) {
188207
return groups[idx];

services/static-webserver/client/source/class/osparc/ui/list/CollaboratorListItem.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,7 @@ qx.Class.define("osparc.ui.list.CollaboratorListItem", {
129129
return;
130130
}
131131
const groupsStore = osparc.store.Groups.getInstance();
132-
const everyoneGroupIds = [
133-
groupsStore.getEveryoneProductGroup().getGroupId(),
134-
groupsStore.getEveryoneGroup().getGroupId(),
135-
];
132+
const everyoneGroupIds = groupsStore.getEveryoneGroupIds();
136133
const label = this.getChildControl("title");
137134
if (everyoneGroupIds.includes(this.getModel())) {
138135
label.setValue(this.tr("Public"));

0 commit comments

Comments
 (0)