From 1018cc88ce1a2c9fb338dcd2df251cc58aeda2bd Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Mon, 7 Apr 2025 10:05:28 +0200 Subject: [PATCH 01/14] isShareWithEmailEnabled --- .../class/osparc/share/NewCollaboratorsManager.js | 10 ++++++++++ .../source/class/osparc/utils/DisabledPlugins.js | 6 ++++++ 2 files changed, 16 insertions(+) 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 0db26b0dbf4..4ea1c7ac6ec 100644 --- a/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js +++ b/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js @@ -33,6 +33,16 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { this.__potentialCollaborators = {}; this.__reloadPotentialCollaborators(); + this.__shareWithEmail = false; + if (this.__resourceData["resourceType"] === "study") { + osparc.utils.DisabledPlugins.isShareWithEmailEnabled() + .then(isEnabled => { + if (isEnabled) { + this.__shareWithEmail = true; + } + }); + } + this.center(); this.open(); }, diff --git a/services/static-webserver/client/source/class/osparc/utils/DisabledPlugins.js b/services/static-webserver/client/source/class/osparc/utils/DisabledPlugins.js index ccd68623f94..edfef797a19 100644 --- a/services/static-webserver/client/source/class/osparc/utils/DisabledPlugins.js +++ b/services/static-webserver/client/source/class/osparc/utils/DisabledPlugins.js @@ -29,6 +29,7 @@ qx.Class.define("osparc.utils.DisabledPlugins", { VERSION_CONTROL: "WEBSERVER_VERSION_CONTROL", META_MODELING: "WEBSERVER_META_MODELING", LICENSES: "WEBSERVER_LICENSES", + SHARE_WITH_EMAIL: "WEBSERVER_SHARE_WITH_EMAIL", isExportDisabled: function() { return this.__isPluginDisabled(this.EXPORT); @@ -52,6 +53,11 @@ qx.Class.define("osparc.utils.DisabledPlugins", { return this.__isPluginDisabled(this.LICENSES); }, + isShareWithEmailEnabled: function() { + // return !this.__isPluginDisabled(this.SHARE_WITH_EMAIL); + return true; + }, + isJobsEnabled: function() { if (osparc.utils.Utils.isDevelopmentPlatform() && osparc.product.Utils.isProduct("s4lacad")) { return true; From e459843de83fced04cf53bbb514775262f2ccec2 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Mon, 7 Apr 2025 10:19:26 +0200 Subject: [PATCH 02/14] checkEmail --- .../client/source/class/osparc/auth/core/Utils.js | 6 ++++++ .../class/osparc/share/NewCollaboratorsManager.js | 13 +++++++++---- .../source/class/osparc/utils/DisabledPlugins.js | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/auth/core/Utils.js b/services/static-webserver/client/source/class/osparc/auth/core/Utils.js index da013ab969f..e04140bdc1d 100644 --- a/services/static-webserver/client/source/class/osparc/auth/core/Utils.js +++ b/services/static-webserver/client/source/class/osparc/auth/core/Utils.js @@ -68,6 +68,12 @@ qx.Class.define("osparc.auth.core.Utils", { }; }, + checkEmail: function(emailValue) { + // Same expression used in qx.util.Validate.checkEmail + const reg = /^([A-Za-z0-9_\-.+])+@([A-Za-z0-9_\-.])+\.([A-Za-z]{2,})$/; + return reg.test(emailValue); + }, + /** Finds parameters in the fragment * * Expected fragment format as https://osparc.io#page=reset-password;code=123546 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 4ea1c7ac6ec..72970fbf689 100644 --- a/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js +++ b/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js @@ -33,12 +33,12 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { this.__potentialCollaborators = {}; this.__reloadPotentialCollaborators(); - this.__shareWithEmail = false; + this.__shareWithEmailEnabled = false; if (this.__resourceData["resourceType"] === "study") { osparc.utils.DisabledPlugins.isShareWithEmailEnabled() .then(isEnabled => { if (isEnabled) { - this.__shareWithEmail = true; + this.__shareWithEmailEnabled = true; } }); } @@ -153,11 +153,16 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { const textFilter = this.getChildControl("text-filter"); const filterTextField = textFilter.getChildControl("textfield"); filterTextField.addListener("input", e => { - const filterValue = e.getData(); + const inputValue = e.getData(); if (this.__searchDelayer) { clearTimeout(this.__searchDelayer); } - if (filterValue.length > 3) { + if (inputValue.length > 3) { + if (this.__shareWithEmailEnabled) { + let errorMessage = null + osparc.auth.core.Utils.checkEmail(inputValue, null, errorMessage); + console.log(errorMessage); + } const waitBeforeSearching = 1000; this.__searchDelayer = setTimeout(() => { this.__searchUsers(); diff --git a/services/static-webserver/client/source/class/osparc/utils/DisabledPlugins.js b/services/static-webserver/client/source/class/osparc/utils/DisabledPlugins.js index edfef797a19..c4a5a4d8bb9 100644 --- a/services/static-webserver/client/source/class/osparc/utils/DisabledPlugins.js +++ b/services/static-webserver/client/source/class/osparc/utils/DisabledPlugins.js @@ -55,7 +55,7 @@ qx.Class.define("osparc.utils.DisabledPlugins", { isShareWithEmailEnabled: function() { // return !this.__isPluginDisabled(this.SHARE_WITH_EMAIL); - return true; + return new Promise(resolve => resolve(true)); }, isJobsEnabled: function() { From 19b0457ba2f9488b9b0f647347158508dfcde8f2 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Mon, 7 Apr 2025 10:23:10 +0200 Subject: [PATCH 03/14] console.log("Valid email"); --- .../source/class/osparc/share/NewCollaboratorsManager.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 72970fbf689..2d7a6e71418 100644 --- a/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js +++ b/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js @@ -159,9 +159,9 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { } if (inputValue.length > 3) { if (this.__shareWithEmailEnabled) { - let errorMessage = null - osparc.auth.core.Utils.checkEmail(inputValue, null, errorMessage); - console.log(errorMessage); + if (osparc.auth.core.Utils.checkEmail(inputValue)) { + console.log("Valid email"); + } } const waitBeforeSearching = 1000; this.__searchDelayer = setTimeout(() => { From 876ef37c4eaa6ce01f501c4a924d0899ddfcda89 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Mon, 7 Apr 2025 11:14:17 +0200 Subject: [PATCH 04/14] [skip ci] send-email-button --- .../osparc/share/NewCollaboratorsManager.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) 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 2d7a6e71418..3f14b64008f 100644 --- a/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js +++ b/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js @@ -75,6 +75,10 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { this.add(control); break; } + case "filter-layout": + control = new qx.ui.container.Composite(new qx.ui.layout.HBox(5)); + this.add(control); + break; case "text-filter": { control = new osparc.filter.TextFilter("name", "collaboratorsManager"); control.setCompact(true); @@ -82,7 +86,15 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { filterTextField.setPlaceholder(this.tr("Search")); filterTextField.setBackgroundColor("transparent"); this.addListener("appear", () => filterTextField.focus()); - this.add(control); + this.getChildControl("filter-layout").add(control, { + flex: 1 + }); + break; + } + case "send-email-button": { + control = new qx.ui.form.Button(this.tr("Send email")); + control.exclude(); + this.getChildControl("filter-layout").add(control); break; } case "potential-collaborators-list": { @@ -157,10 +169,12 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { if (this.__searchDelayer) { clearTimeout(this.__searchDelayer); } + const sendEmailButton = this.getChildControl("send-email-button"); + sendEmailButton.exclude(); if (inputValue.length > 3) { if (this.__shareWithEmailEnabled) { if (osparc.auth.core.Utils.checkEmail(inputValue)) { - console.log("Valid email"); + sendEmailButton.show(); } } const waitBeforeSearching = 1000; From 7a6b2c234e8885add839afb325bc89577a2ff423 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Mon, 7 Apr 2025 11:33:47 +0200 Subject: [PATCH 05/14] iconSrc --- .../class/osparc/filter/CollaboratorToggleButton.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/filter/CollaboratorToggleButton.js b/services/static-webserver/client/source/class/osparc/filter/CollaboratorToggleButton.js index 0008c5d7c48..d87c450c2de 100644 --- a/services/static-webserver/client/source/class/osparc/filter/CollaboratorToggleButton.js +++ b/services/static-webserver/client/source/class/osparc/filter/CollaboratorToggleButton.js @@ -51,6 +51,15 @@ qx.Class.define("osparc.filter.CollaboratorToggleButton", { this.getChildControl("check"); }, + properties: { + iconSrc: { + check: "String", + nullable: true, + init: "@FontAwesome5Solid/check/14", + event: "changeIconSrc" + }, + }, + members: { _createChildControlImpl: function(id) { let control; @@ -69,7 +78,8 @@ qx.Class.define("osparc.filter.CollaboratorToggleButton", { } break; case "check": - control = new qx.ui.basic.Image("@FontAwesome5Solid/check/14"); + control = new qx.ui.basic.Image(); + this.bind("iconSrc", control, "source"); control.setAnonymous(true); this._add(control); this.bind("value", control, "visibility", { From ca44f4eeed6937b3723b7e2d81fbe102d6970d14 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Mon, 7 Apr 2025 11:34:15 +0200 Subject: [PATCH 06/14] [skip ci] invitedButton --- .../osparc/share/NewCollaboratorsManager.js | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) 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 3f14b64008f..dd22b318742 100644 --- a/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js +++ b/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js @@ -94,6 +94,15 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { case "send-email-button": { control = new qx.ui.form.Button(this.tr("Send email")); control.exclude(); + control.addListener("execute", () => { + const textField = this.getChildControl("text-filter").getChildControl("textfield"); + const email = textField.getValue(); + if (osparc.auth.core.Utils.checkEmail(email)) { + this.__selectedCollaborators[email] = email; + const invitedButton = this.__invitedButton(email); + this.getChildControl("potential-collaborators-list").add(invitedButton); + } + }); this.getChildControl("filter-layout").add(control); break; } @@ -249,13 +258,10 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { this.__addPotentialCollaborators(); }, - __collaboratorButton: function(collaborator, preSelected = false) { + __collaboratorButton: function(collaborator) { const collaboratorButton = new osparc.filter.CollaboratorToggleButton(collaborator); collaboratorButton.groupId = collaborator.getGroupId(); - collaboratorButton.setValue(preSelected); - if (!preSelected) { - collaboratorButton.subscribeToFilterGroup("collaboratorsManager"); - } + collaboratorButton.subscribeToFilterGroup("collaboratorsManager"); collaboratorButton.addListener("changeValue", e => { const selected = e.getData(); @@ -271,6 +277,28 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { return collaboratorButton; }, + __invitedButton: function(email) { + const collaboratorData = { + label: email, + description: null, + }; + const collaborator = qx.data.marshal.Json.createModel(collaboratorData); + const collaboratorButton = new osparc.filter.CollaboratorToggleButton(collaborator); + collaboratorButton.email = email; + collaboratorButton.setIconSrc("@FontAwesome5Solid/envelope/14"); + collaboratorButton.setValue(true); + + collaboratorButton.addListener("changeValue", e => { + const selected = e.getData(); + if (!selected && collaborator.email in this.__selectedCollaborators) { + delete this.__selectedCollaborators[collaborator.getGroupId()]; + collaboratorButton.subscribeToFilterGroup("collaboratorsManager"); + } + this.getChildControl("share-button").setEnabled(Boolean(Object.keys(this.__selectedCollaborators).length)); + }, this); + return collaboratorButton; + }, + __addPotentialCollaborators: function(foundCollaborators = []) { const potentialCollaborators = Object.values(this.__potentialCollaborators).concat(foundCollaborators); const potentialCollaboratorList = this.getChildControl("potential-collaborators-list"); From b07c9a658440ff434ccda2aa3a15c891d17c1cda Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Mon, 7 Apr 2025 13:13:21 +0200 Subject: [PATCH 07/14] shareWithEmails --- .../source/class/osparc/data/Resources.js | 4 ++ .../class/osparc/share/AddCollaborators.js | 8 ++- .../osparc/share/NewCollaboratorsManager.js | 51 ++++++++++++++++--- 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/data/Resources.js b/services/static-webserver/client/source/class/osparc/data/Resources.js index 1ef6bb8d7cb..ef9783942b2 100644 --- a/services/static-webserver/client/source/class/osparc/data/Resources.js +++ b/services/static-webserver/client/source/class/osparc/data/Resources.js @@ -276,6 +276,10 @@ qx.Class.define("osparc.data.Resources", { method: "PUT", url: statics.API + "/projects/{studyId}/groups/{gId}" }, + shareWithEmail: { + method: "POST", + url: statics.API + "/projects/{studyId}:share" + }, addTag: { useCache: false, method: "POST", diff --git a/services/static-webserver/client/source/class/osparc/share/AddCollaborators.js b/services/static-webserver/client/source/class/osparc/share/AddCollaborators.js index f59327843c8..666f7b1ace8 100644 --- a/services/static-webserver/client/source/class/osparc/share/AddCollaborators.js +++ b/services/static-webserver/client/source/class/osparc/share/AddCollaborators.js @@ -41,7 +41,8 @@ qx.Class.define("osparc.share.AddCollaborators", { }, events: { - "addCollaborators": "qx.event.type.Data" + "addCollaborators": "qx.event.type.Data", + "shareWithEmails": "qx.event.type.Data", }, members: { @@ -99,6 +100,11 @@ qx.Class.define("osparc.share.AddCollaborators", { collaboratorsManager.close(); this.fireDataEvent("addCollaborators", e.getData()); }, this); + collaboratorsManager.addListener("shareWithEmails", e => { + collaboratorsManager.close(); + console.log("Sending emails: ", e.getData()); + this.fireDataEvent("shareWithEmails", e.getData()); + }, this); }, this); const organizations = this.getChildControl("my-organizations"); 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 dd22b318742..122b2db3db7 100644 --- a/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js +++ b/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js @@ -48,7 +48,8 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { }, events: { - "addCollaborators": "qx.event.type.Data" + "addCollaborators": "qx.event.type.Data", + "shareWithEmails": "qx.event.type.Data", }, members: { @@ -291,7 +292,7 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { collaboratorButton.addListener("changeValue", e => { const selected = e.getData(); if (!selected && collaborator.email in this.__selectedCollaborators) { - delete this.__selectedCollaborators[collaborator.getGroupId()]; + delete this.__selectedCollaborators[collaborator.email]; collaboratorButton.subscribeToFilterGroup("collaboratorsManager"); } this.getChildControl("share-button").setEnabled(Boolean(Object.keys(this.__selectedCollaborators).length)); @@ -372,10 +373,48 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { } } if (Object.keys(this.__selectedCollaborators).length) { - this.fireDataEvent("addCollaborators", { - selectedGids: Object.keys(this.__selectedCollaborators), - newAccessRights, - }); + const selectedGIds = Object.keys(this.__selectedCollaborators).filter(key => qx.lang.Type.isNumber(key)); + const selectedEmails = Object.keys(this.__selectedCollaborators).filter(key => osparc.auth.core.Utils.checkEmail(key)); + + const addCollaborators = () => { + if (selectedGIds.length) { + this.fireDataEvent("addCollaborators", { + selectedGids: selectedGIds, + newAccessRights, + }); + } + }; + + const sendEmails = message => { + if (selectedEmails.length) { + this.fireDataEvent("shareWithEmails", { + selectedEmails, + newAccessRights, + message, + }); + } + }; + + if (selectedEmails.length) { + console.log("Inviting users: ", selectedEmails); + const dialog = new osparc.ui.window.Confirmation(); + dialog.setCaption(this.tr("Add Message")); + dialog.setMessage(this.tr("You can add a message that will be go in the email")); + dialog.getConfirmButton().setLabel(this.tr("Send")); + const messageEditor = new qx.ui.form.TextArea().set({ + autoSize: true, + minHeight: 70, + maxHeight: 140, + }); + dialog.addWidget(messageEditor); + dialog.open(); + dialog.addListener("close", () => { + addCollaborators(); + sendEmails(messageEditor.getValue()); + }, this); + } else { + addCollaborators(); + } } } } From d93b59b018d33c282c3ac18d735cd6ea3dc807ee Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Mon, 7 Apr 2025 13:50:34 +0200 Subject: [PATCH 08/14] sendShareEmails --- .../class/osparc/share/AddCollaborators.js | 21 ++++++++++++------- .../osparc/share/NewCollaboratorsManager.js | 2 +- .../client/source/class/osparc/store/Study.js | 19 +++++++++++++++++ 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/share/AddCollaborators.js b/services/static-webserver/client/source/class/osparc/share/AddCollaborators.js index 666f7b1ace8..3e59a7b0391 100644 --- a/services/static-webserver/client/source/class/osparc/share/AddCollaborators.js +++ b/services/static-webserver/client/source/class/osparc/share/AddCollaborators.js @@ -41,8 +41,7 @@ qx.Class.define("osparc.share.AddCollaborators", { }, events: { - "addCollaborators": "qx.event.type.Data", - "shareWithEmails": "qx.event.type.Data", + "addCollaborators": "qx.event.type.Data" }, members: { @@ -100,11 +99,19 @@ qx.Class.define("osparc.share.AddCollaborators", { collaboratorsManager.close(); this.fireDataEvent("addCollaborators", e.getData()); }, this); - collaboratorsManager.addListener("shareWithEmails", e => { - collaboratorsManager.close(); - console.log("Sending emails: ", e.getData()); - this.fireDataEvent("shareWithEmails", e.getData()); - }, this); + if (this.__serializedDataCopy["resourceType"] === "study") { + collaboratorsManager.addListener("shareWithEmails", e => { + const { + selectedEmails, + newAccessRights, + message, + } = e.getData(); + collaboratorsManager.close(); + osparc.store.Study.sendShareEmails(selectedEmails, newAccessRights, message) + .then(() => osparc.FlashMessenger.logAs("success", this.tr("Emails sent"))) + .catch(err => osparc.FlashMessenger.logError(err)); + }, this); + } }, this); const organizations = this.getChildControl("my-organizations"); 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 122b2db3db7..d2cea2d48da 100644 --- a/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js +++ b/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js @@ -102,6 +102,7 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { this.__selectedCollaborators[email] = email; const invitedButton = this.__invitedButton(email); this.getChildControl("potential-collaborators-list").add(invitedButton); + invitedButton.setValue(true); } }); this.getChildControl("filter-layout").add(control); @@ -287,7 +288,6 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { const collaboratorButton = new osparc.filter.CollaboratorToggleButton(collaborator); collaboratorButton.email = email; collaboratorButton.setIconSrc("@FontAwesome5Solid/envelope/14"); - collaboratorButton.setValue(true); collaboratorButton.addListener("changeValue", e => { const selected = e.getData(); diff --git a/services/static-webserver/client/source/class/osparc/store/Study.js b/services/static-webserver/client/source/class/osparc/store/Study.js index 9f57f5281ac..85c8ede08d2 100644 --- a/services/static-webserver/client/source/class/osparc/store/Study.js +++ b/services/static-webserver/client/source/class/osparc/store/Study.js @@ -111,5 +111,24 @@ qx.Class.define("osparc.store.Study", { }) .catch(err => osparc.FlashMessenger.logError(err)); }, + + sendShareEmails: function(selectedEmails, newAccessRights, message) { + const promises = selectedEmails.map(selectedEmail => { + const params = { + url: { + "studyId": this.__serializedDataCopy["uuid"], + }, + data: { + shareeEmail: selectedEmail, + sharerMessage: message, + read: newAccessRights["read"], + write: newAccessRights["write"], + delete: newAccessRights["delete"], + } + }; + return osparc.data.Resources.fetch("studies", "shareWithEmail", params); + }); + return Promise.all(promises); + }, } }); From 199cefb2f448e4bd7d0fc242a5517c546d3d321e Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Mon, 7 Apr 2025 14:19:14 +0200 Subject: [PATCH 09/14] workflow working --- .../client/source/class/osparc/share/AddCollaborators.js | 2 +- .../client/source/class/osparc/store/Study.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/share/AddCollaborators.js b/services/static-webserver/client/source/class/osparc/share/AddCollaborators.js index 3e59a7b0391..d5764b27d39 100644 --- a/services/static-webserver/client/source/class/osparc/share/AddCollaborators.js +++ b/services/static-webserver/client/source/class/osparc/share/AddCollaborators.js @@ -107,7 +107,7 @@ qx.Class.define("osparc.share.AddCollaborators", { message, } = e.getData(); collaboratorsManager.close(); - osparc.store.Study.sendShareEmails(selectedEmails, newAccessRights, message) + osparc.store.Study.sendShareEmails(this.__serializedDataCopy, selectedEmails, newAccessRights, message) .then(() => osparc.FlashMessenger.logAs("success", this.tr("Emails sent"))) .catch(err => osparc.FlashMessenger.logError(err)); }, this); diff --git a/services/static-webserver/client/source/class/osparc/store/Study.js b/services/static-webserver/client/source/class/osparc/store/Study.js index 85c8ede08d2..78a30233761 100644 --- a/services/static-webserver/client/source/class/osparc/store/Study.js +++ b/services/static-webserver/client/source/class/osparc/store/Study.js @@ -112,11 +112,11 @@ qx.Class.define("osparc.store.Study", { .catch(err => osparc.FlashMessenger.logError(err)); }, - sendShareEmails: function(selectedEmails, newAccessRights, message) { + sendShareEmails: function(studyData, selectedEmails, newAccessRights, message) { const promises = selectedEmails.map(selectedEmail => { const params = { url: { - "studyId": this.__serializedDataCopy["uuid"], + "studyId": studyData["uuid"], }, data: { shareeEmail: selectedEmail, From 51838e43cdc5d94968cb137852373b86e11262d2 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Mon, 7 Apr 2025 14:49:50 +0200 Subject: [PATCH 10/14] minor --- .../client/source/class/osparc/utils/DisabledPlugins.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/utils/DisabledPlugins.js b/services/static-webserver/client/source/class/osparc/utils/DisabledPlugins.js index c4a5a4d8bb9..233ba211e05 100644 --- a/services/static-webserver/client/source/class/osparc/utils/DisabledPlugins.js +++ b/services/static-webserver/client/source/class/osparc/utils/DisabledPlugins.js @@ -55,7 +55,7 @@ qx.Class.define("osparc.utils.DisabledPlugins", { isShareWithEmailEnabled: function() { // return !this.__isPluginDisabled(this.SHARE_WITH_EMAIL); - return new Promise(resolve => resolve(true)); + return new Promise(resolve => resolve(osparc.utils.Utils.isDevelopmentPlatform())); }, isJobsEnabled: function() { From efd6fb4e7909cd87bec9c48cf03bc221966ba7e6 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Mon, 7 Apr 2025 15:14:34 +0200 Subject: [PATCH 11/14] cleanup --- .../client/source/class/osparc/share/AddCollaborators.js | 2 +- .../client/source/class/osparc/share/NewCollaboratorsManager.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/share/AddCollaborators.js b/services/static-webserver/client/source/class/osparc/share/AddCollaborators.js index d5764b27d39..8f21a4e1958 100644 --- a/services/static-webserver/client/source/class/osparc/share/AddCollaborators.js +++ b/services/static-webserver/client/source/class/osparc/share/AddCollaborators.js @@ -108,7 +108,7 @@ qx.Class.define("osparc.share.AddCollaborators", { } = e.getData(); collaboratorsManager.close(); osparc.store.Study.sendShareEmails(this.__serializedDataCopy, selectedEmails, newAccessRights, message) - .then(() => osparc.FlashMessenger.logAs("success", this.tr("Emails sent"))) + .then(() => osparc.FlashMessenger.logAs(this.tr("Emails sent"), "INFO")) .catch(err => osparc.FlashMessenger.logError(err)); }, this); } 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 d2cea2d48da..bf37906c0f2 100644 --- a/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js +++ b/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js @@ -396,7 +396,6 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { }; if (selectedEmails.length) { - console.log("Inviting users: ", selectedEmails); const dialog = new osparc.ui.window.Confirmation(); dialog.setCaption(this.tr("Add Message")); dialog.setMessage(this.tr("You can add a message that will be go in the email")); From 2d45d9fd8cab76d74cd57ff87dc471816154aacc Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Mon, 7 Apr 2025 15:31:12 +0200 Subject: [PATCH 12/14] UX --- .../class/osparc/share/NewCollaboratorsManager.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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 bf37906c0f2..f81e73715d4 100644 --- a/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js +++ b/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js @@ -101,7 +101,7 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { if (osparc.auth.core.Utils.checkEmail(email)) { this.__selectedCollaborators[email] = email; const invitedButton = this.__invitedButton(email); - this.getChildControl("potential-collaborators-list").add(invitedButton); + this.getChildControl("potential-collaborators-list").addAt(invitedButton, 0); invitedButton.setValue(true); } }); @@ -280,6 +280,10 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { }, __invitedButton: function(email) { + if (email in this.__selectedCollaborators) { + return this.__selectedCollaborators[email]; + } + const collaboratorData = { label: email, description: null, @@ -291,7 +295,10 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { collaboratorButton.addListener("changeValue", e => { const selected = e.getData(); - if (!selected && collaborator.email in this.__selectedCollaborators) { + if (selected) { + this.__selectedCollaborators[collaborator.email] = collaborator; + collaboratorButton.unsubscribeToFilterGroup("collaboratorsManager"); + } else if (collaborator.email in this.__selectedCollaborators) { delete this.__selectedCollaborators[collaborator.email]; collaboratorButton.subscribeToFilterGroup("collaboratorsManager"); } From a119f150dd750d6044877a931214cbc67def453f Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Mon, 7 Apr 2025 15:45:09 +0200 Subject: [PATCH 13/14] more UX --- .../source/class/osparc/share/NewCollaboratorsManager.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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 f81e73715d4..e9eb0ad7b64 100644 --- a/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js +++ b/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js @@ -99,7 +99,6 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { const textField = this.getChildControl("text-filter").getChildControl("textfield"); const email = textField.getValue(); if (osparc.auth.core.Utils.checkEmail(email)) { - this.__selectedCollaborators[email] = email; const invitedButton = this.__invitedButton(email); this.getChildControl("potential-collaborators-list").addAt(invitedButton, 0); invitedButton.setValue(true); @@ -286,20 +285,20 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { const collaboratorData = { label: email, + email: email, description: null, }; const collaborator = qx.data.marshal.Json.createModel(collaboratorData); const collaboratorButton = new osparc.filter.CollaboratorToggleButton(collaborator); - collaboratorButton.email = email; collaboratorButton.setIconSrc("@FontAwesome5Solid/envelope/14"); collaboratorButton.addListener("changeValue", e => { const selected = e.getData(); if (selected) { - this.__selectedCollaborators[collaborator.email] = collaborator; + this.__selectedCollaborators[collaborator.getEmail()] = collaborator; collaboratorButton.unsubscribeToFilterGroup("collaboratorsManager"); - } else if (collaborator.email in this.__selectedCollaborators) { - delete this.__selectedCollaborators[collaborator.email]; + } else if (collaborator.getEmail() in this.__selectedCollaborators) { + delete this.__selectedCollaborators[collaborator.getEmail()]; collaboratorButton.subscribeToFilterGroup("collaboratorsManager"); } this.getChildControl("share-button").setEnabled(Boolean(Object.keys(this.__selectedCollaborators).length)); From b61d03843b9ada3d0e557176e09c5d6a4449a196 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Mon, 7 Apr 2025 16:34:27 +0200 Subject: [PATCH 14/14] reword --- .../client/source/class/osparc/share/NewCollaboratorsManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e9eb0ad7b64..3ca3ea2918d 100644 --- a/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js +++ b/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js @@ -404,7 +404,7 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { if (selectedEmails.length) { const dialog = new osparc.ui.window.Confirmation(); dialog.setCaption(this.tr("Add Message")); - dialog.setMessage(this.tr("You can add a message that will be go in the email")); + dialog.setMessage(this.tr("Add a message to include in the email (optional)")); dialog.getConfirmButton().setLabel(this.tr("Send")); const messageEditor = new qx.ui.form.TextArea().set({ autoSize: true,