Skip to content

Commit

Permalink
not a promise
Browse files Browse the repository at this point in the history
  • Loading branch information
odeimaiz committed Nov 20, 2024
1 parent 658cbb6 commit 1b06549
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ qx.Class.define("osparc.desktop.wallets.MembersList", {

const myGroupId = osparc.auth.Data.getInstance().getGroupId();
const membersList = [];
const potentialCollaborators = await osparc.store.Groups.getInstance().getPotentialCollaborators(true);
const potentialCollaborators = osparc.store.Groups.getInstance().getPotentialCollaborators(true);
const canIWrite = wallet.getMyAccessRights()["write"];
wallet.getAccessRights().forEach(accessRights => {
const gid = accessRights["gid"];
Expand Down Expand Up @@ -289,17 +289,14 @@ qx.Class.define("osparc.desktop.wallets.MembersList", {
});

// push 'WALLET_SHARED' notification
osparc.store.Groups.getInstance().getPotentialCollaborators()
.then(potentialCollaborators => {
gids.forEach(gid => {
if (gid in potentialCollaborators && "id" in potentialCollaborators[gid]) {
// it's a user, not an organization
const collab = potentialCollaborators[gid];
const uid = collab["id"];
osparc.notification.Notifications.postNewWallet(uid, wallet.getWalletId());
}
});
});
const potentialCollaborators = osparc.store.Groups.getInstance().getPotentialCollaborators()
gids.forEach(gid => {
if (gid in potentialCollaborators && "getUserId" in potentialCollaborators[gid]) {
// it's a user, not an organization
const uid = potentialCollaborators[gid].getUserId();
osparc.notification.Notifications.postNewWallet(uid, wallet.getWalletId());
}
});
});
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,9 @@ qx.Class.define("osparc.share.Collaborators", {
},

__getCollaborators: function() {
osparc.store.Groups.getInstance().getPotentialCollaborators()
.then(potentialCollaborators => {
this.__collaborators = Object.assign(this.__collaborators, potentialCollaborators);
this._reloadCollaboratorsList();
});
const potentialCollaborators = osparc.store.Groups.getInstance().getPotentialCollaborators()
this.__collaborators = Object.assign(this.__collaborators, potentialCollaborators);
this._reloadCollaboratorsList();
},

__getLeaveStudyButton: function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,24 +259,21 @@ qx.Class.define("osparc.share.CollaboratorsStudy", {

__pushNotifications: function(gids) {
// push 'STUDY_SHARED'/'TEMPLATE_SHARED' notification
osparc.store.Groups.getInstance().getPotentialCollaborators()
.then(potentialCollaborators => {
gids.forEach(gid => {
if (gid in potentialCollaborators && "id" in potentialCollaborators[gid]) {
// it's a user, not an organization
const collab = potentialCollaborators[gid];
const uid = collab["id"];
if (this._resourceType === "study") {
osparc.notification.Notifications.postNewStudy(uid, this._serializedDataCopy["uuid"]);
} else if (this._resourceType === "template") {
// do not push TEMPLATE_SHARED notification if users are not supposed to see the templates
if (osparc.data.Permissions.getInstance().canRoleDo("user", "dashboard.templates.read")) {
osparc.notification.Notifications.postNewTemplate(uid, this._serializedDataCopy["uuid"]);
}
}
const potentialCollaborators = osparc.store.Groups.getInstance().getPotentialCollaborators()
gids.forEach(gid => {
if (gid in potentialCollaborators && "getUserId" in potentialCollaborators[gid]) {
// it's a user, not an organization
const uid = potentialCollaborators[gid].getUserId();
if (this._resourceType === "study") {
osparc.notification.Notifications.postNewStudy(uid, this._serializedDataCopy["uuid"]);
} else if (this._resourceType === "template") {
// do not push TEMPLATE_SHARED notification if users are not supposed to see the templates
if (osparc.data.Permissions.getInstance().canRoleDo("user", "dashboard.templates.read")) {
osparc.notification.Notifications.postNewTemplate(uid, this._serializedDataCopy["uuid"]);
}
});
});
}
}
});
},

__checkShareePermissions: function(gids) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,18 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", {
// all users can share services with ProductEveryone
includeProductEveryone = true;
}
osparc.store.Groups.getInstance().getPotentialCollaborators(false, includeProductEveryone)
.then(potentialCollaborators => {
this.__visibleCollaborators = potentialCollaborators;
const anyCollaborator = Object.keys(potentialCollaborators).length;
// tell the user that belonging to an organization is required to start sharing
this.__introLabel.setVisibility(anyCollaborator ? "excluded" : "visible");
this.__orgsButton.setVisibility(anyCollaborator ? "excluded" : "visible");

// or start sharing
this.__textFilter.setVisibility(anyCollaborator ? "visible" : "excluded");
this.__collabButtonsContainer.setVisibility(anyCollaborator ? "visible" : "excluded");
this.__shareButton.setVisibility(anyCollaborator ? "visible" : "excluded");
this.__addEditors();
});
const potentialCollaborators = osparc.store.Groups.getInstance().getPotentialCollaborators(false, includeProductEveryone)
this.__visibleCollaborators = potentialCollaborators;
const anyCollaborator = Object.keys(potentialCollaborators).length;
// tell the user that belonging to an organization is required to start sharing
this.__introLabel.setVisibility(anyCollaborator ? "excluded" : "visible");
this.__orgsButton.setVisibility(anyCollaborator ? "excluded" : "visible");

// or start sharing
this.__textFilter.setVisibility(anyCollaborator ? "visible" : "excluded");
this.__collabButtonsContainer.setVisibility(anyCollaborator ? "visible" : "excluded");
this.__shareButton.setVisibility(anyCollaborator ? "visible" : "excluded");
this.__addEditors();
},

__collaboratorButton: function(collaborator) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,20 @@ qx.Class.define("osparc.share.PublishTemplate", {
addCollaborators.addListener("addCollaborators", e => {
const gids = e.getData();
if (gids.length) {
osparc.store.Groups.getInstance().getPotentialCollaborators(false, true)
.then(potentialCollaborators => {
const currentGids = this.getSelectedGroups();
gids.forEach(gid => {
if (gid in potentialCollaborators && !currentGids.includes(gid)) {
const collabButton = new qx.ui.toolbar.Button(potentialCollaborators[gid].getLabel(), "@MaterialIcons/close/12");
collabButton.gid = gid;
this.__selectedCollabs.add(collabButton);
collabButton.addListener("execute", () => {
this.__selectedCollabs.remove(collabButton);
this.__updateAccessRights();
});
}
const potentialCollaborators = osparc.store.Groups.getInstance().getPotentialCollaborators(false, true)
const currentGids = this.getSelectedGroups();
gids.forEach(gid => {
if (gid in potentialCollaborators && !currentGids.includes(gid)) {
const collabButton = new qx.ui.toolbar.Button(potentialCollaborators[gid].getLabel(), "@MaterialIcons/close/12");
collabButton.gid = gid;
this.__selectedCollabs.add(collabButton);
collabButton.addListener("execute", () => {
this.__selectedCollabs.remove(collabButton);
this.__updateAccessRights();
});
this.__updateAccessRights();
});
}
});
this.__updateAccessRights();
}
}, this);
},
Expand Down

0 comments on commit 1b06549

Please sign in to comment.