Skip to content

Commit 59cc658

Browse files
committed
improved workflow
1 parent ea40cc8 commit 59cc658

File tree

2 files changed

+36
-30
lines changed

2 files changed

+36
-30
lines changed

services/static-webserver/client/source/class/osparc/editor/AnnotationNoteCreator.js

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -151,35 +151,34 @@ qx.Class.define("osparc.editor.AnnotationNoteCreator", {
151151
},
152152

153153
__recipientSelected: function(userGid) {
154-
this.__setRecipientGid(userGid);
155154
const currentAccessRights = this.__study.getAccessRights();
156-
const proposeSharing = [];
157-
if (!(userGid in currentAccessRights)) {
158-
proposeSharing.push(userGid);
159-
}
160-
if (proposeSharing.length) {
161-
const collaboratorsManager = new osparc.share.NewCollaboratorsManager(currentStudy, false, true, proposeSharing);
162-
collaboratorsManager.addListener("addCollaborators", ev => {
163-
const {
164-
selectedGids,
165-
newAccessRights,
166-
} = ev.getData();
167-
const newCollaborators = {};
168-
selectedGids.forEach(gid => {
169-
newCollaborators[gid] = newAccessRights;
170-
});
171-
const studyData = this.__study.serialize();
172-
osparc.store.Study.addCollaborators(studyData, newCollaborators)
173-
.then(() => {
174-
const potentialCollaborators = osparc.store.Groups.getInstance().getPotentialCollaborators()
175-
selectedGids.forEach(gid => {
176-
if (gid in potentialCollaborators && "getUserId" in potentialCollaborators[gid]) {
177-
const uid = potentialCollaborators[gid].getUserId();
155+
if (userGid in currentAccessRights) {
156+
this.__setRecipientGid(userGid);
157+
} else {
158+
const msg = this.tr("This user has no access to the project. Do you want to share it?");
159+
const win = new osparc.ui.window.Confirmation(msg).set({
160+
caption: this.tr("Share"),
161+
confirmText: this.tr("Share"),
162+
confirmAction: "create"
163+
});
164+
win.center();
165+
win.open();
166+
win.addListener("close", () => {
167+
if (win.getConfirmed()) {
168+
const newCollaborators = {
169+
[userGid]: osparc.data.Roles.STUDY["write"].accessRights
170+
};
171+
osparc.store.Study.addCollaborators(this.__studyData, newCollaborators)
172+
.then(() => {
173+
this.__setRecipientGid(userGid);
174+
const potentialCollaborators = osparc.store.Groups.getInstance().getPotentialCollaborators()
175+
if (userGid in potentialCollaborators && "getUserId" in potentialCollaborators[userGid]) {
176+
const uid = potentialCollaborators[userGid].getUserId();
178177
osparc.notification.Notifications.postNewStudy(uid, studyData["uuid"]);
179178
}
180-
});
181-
})
182-
.finally(() => collaboratorsManager.close());
179+
})
180+
.finally(() => collaboratorsManager.close());
181+
}
183182
});
184183
}
185184
},

services/static-webserver/client/source/class/osparc/info/CommentAdd.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@ qx.Class.define("osparc.info.CommentAdd", {
165165
// Note!
166166
// This check only works if the project is directly shared with the user.
167167
// If it's shared through a group, it might be a bit confusing
168-
if (!(userGid in this.__studyData["accessRights"])) {
168+
if (userGid in this.__studyData["accessRights"]) {
169+
this.__addNotify(userGid);
170+
} else {
169171
const msg = this.tr("This user has no access to the project. Do you want to share it?");
170172
const win = new osparc.ui.window.Confirmation(msg).set({
171173
caption: this.tr("Share"),
@@ -180,12 +182,17 @@ qx.Class.define("osparc.info.CommentAdd", {
180182
[userGid]: osparc.data.Roles.STUDY["write"].accessRights
181183
};
182184
osparc.store.Study.addCollaborators(this.__studyData, newCollaborators)
183-
.then(() => this.__addNotify(userGid))
185+
.then(() => {
186+
this.__addNotify(userGid);
187+
const potentialCollaborators = osparc.store.Groups.getInstance().getPotentialCollaborators()
188+
if (userGid in potentialCollaborators && "getUserId" in potentialCollaborators[userGid]) {
189+
const uid = potentialCollaborators[userGid].getUserId();
190+
osparc.notification.Notifications.postNewStudy(uid, studyData["uuid"]);
191+
}
192+
})
184193
.catch(err => osparc.FlashMessenger.logError(err));
185194
}
186195
}, this);
187-
} else {
188-
this.__addNotify(userGid);
189196
}
190197
},
191198

0 commit comments

Comments
 (0)