From 1b065498d9e379f960f4460d424e0a041b9ae394 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Wed, 20 Nov 2024 17:45:38 +0100 Subject: [PATCH] not a promise --- .../osparc/desktop/wallets/MembersList.js | 21 ++++++------- .../class/osparc/share/Collaborators.js | 8 ++--- .../class/osparc/share/CollaboratorsStudy.js | 31 +++++++++---------- .../osparc/share/NewCollaboratorsManager.js | 26 +++++++--------- .../class/osparc/share/PublishTemplate.js | 28 ++++++++--------- 5 files changed, 51 insertions(+), 63 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/desktop/wallets/MembersList.js b/services/static-webserver/client/source/class/osparc/desktop/wallets/MembersList.js index e7c155a3682..232bd3d21d2 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/wallets/MembersList.js +++ b/services/static-webserver/client/source/class/osparc/desktop/wallets/MembersList.js @@ -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"]; @@ -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()); + } + }); }); }, diff --git a/services/static-webserver/client/source/class/osparc/share/Collaborators.js b/services/static-webserver/client/source/class/osparc/share/Collaborators.js index 989e8e0fd23..f580ef11304 100644 --- a/services/static-webserver/client/source/class/osparc/share/Collaborators.js +++ b/services/static-webserver/client/source/class/osparc/share/Collaborators.js @@ -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() { diff --git a/services/static-webserver/client/source/class/osparc/share/CollaboratorsStudy.js b/services/static-webserver/client/source/class/osparc/share/CollaboratorsStudy.js index 849db65071f..d02199889bd 100644 --- a/services/static-webserver/client/source/class/osparc/share/CollaboratorsStudy.js +++ b/services/static-webserver/client/source/class/osparc/share/CollaboratorsStudy.js @@ -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) { diff --git a/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js b/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js index b3f8509dc43..dad8f976529 100644 --- a/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js +++ b/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js @@ -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) { diff --git a/services/static-webserver/client/source/class/osparc/share/PublishTemplate.js b/services/static-webserver/client/source/class/osparc/share/PublishTemplate.js index 015f6ca3fba..d638e0285b9 100644 --- a/services/static-webserver/client/source/class/osparc/share/PublishTemplate.js +++ b/services/static-webserver/client/source/class/osparc/share/PublishTemplate.js @@ -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); },