Skip to content

Commit 53f3065

Browse files
committed
refactor and pass access rights
1 parent 9459040 commit 53f3065

File tree

7 files changed

+44
-16
lines changed

7 files changed

+44
-16
lines changed

services/static-webserver/client/source/class/osparc/desktop/organizations/MembersList.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,13 @@ qx.Class.define("osparc.desktop.organizations.MembersList", {
9999
collaboratorsManager.setCaption("Add Members");
100100
collaboratorsManager.getActionButton().setLabel(this.tr("Add"));
101101
collaboratorsManager.addListener("addCollaborators", e => {
102-
const selectedMembers = e.getData();
103-
if (selectedMembers.length) {
102+
const {
103+
selectedGids,
104+
} = e.getData();
105+
if (selectedGids.length) {
104106
const promises = [];
105107
const usersStore = osparc.store.Users.getInstance();
106-
selectedMembers.forEach(selectedMemberGId => promises.push(usersStore.getUser(selectedMemberGId)));
108+
selectedGids.forEach(selectedMemberGId => promises.push(usersStore.getUser(selectedMemberGId)));
107109
Promise.all(promises)
108110
.then(values => {
109111
values.forEach(user => {

services/static-webserver/client/source/class/osparc/desktop/wallets/MembersList.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,11 @@ qx.Class.define("osparc.desktop.wallets.MembersList", {
9898
const showOrganizations = false;
9999
const collaboratorsManager = new osparc.share.NewCollaboratorsManager(serializedData, showOrganizations);
100100
collaboratorsManager.addListener("addCollaborators", e => {
101+
const {
102+
selectedGids,
103+
} = e.getData();
101104
const cb = () => collaboratorsManager.close();
102-
this.__addMembers(e.getData(), cb);
105+
this.__addMembers(selectedGids, cb);
103106
}, this);
104107
}, this);
105108
vBox.add(addMemberBtn);

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,12 @@ qx.Class.define("osparc.editor.AnnotationNoteCreator", {
8888
collaboratorsManager.setCaption("Recipient");
8989
collaboratorsManager.getActionButton().setLabel(this.tr("Add"));
9090
collaboratorsManager.addListener("addCollaborators", e => {
91-
const collabs = e.getData();
92-
if (collabs) {
91+
const {
92+
selectedGids,
93+
} = e.getData();
94+
if (selectedGids) {
9395
collaboratorsManager.close();
94-
this.__setRecipientGid(collabs[0]);
96+
this.__setRecipientGid(selectedGids[0]);
9597
}
9698
}, this);
9799
}, this);

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,13 @@ qx.Class.define("osparc.share.Collaborators", {
267267
// pass resourceType, so that, if it's a template testers can share it with product everyone
268268
serializedDataCopy["resourceType"] = this._resourceType;
269269
const addCollaborators = new osparc.share.AddCollaborators(serializedDataCopy);
270-
addCollaborators.addListener("addCollaborators", e => this._addEditors(e.getData()), this);
270+
addCollaborators.addListener("addCollaborators", e => {
271+
const {
272+
selectedGids,
273+
newAccessRights,
274+
} = e.getData();
275+
this._addEditors(selectedGids, newAccessRights);
276+
}, this);
271277
return addCollaborators;
272278
},
273279

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,22 @@ qx.Class.define("osparc.share.CollaboratorsStudy", {
7878
},
7979

8080
members: {
81-
_addEditors: function(gids) {
81+
_addEditors: function(gids, newAccessRights) {
8282
if (gids.length === 0) {
8383
return;
8484
}
8585

8686
const readAccessRole = osparc.data.Roles.STUDY["read"];
87-
const writeAccessRole = osparc.data.Roles.STUDY["read"];
87+
const writeAccessRole = osparc.data.Roles.STUDY["write"];
88+
if (!newAccessRights) {
89+
newAccessRights = this._resourceType === "study" ? writeAccessRole.accessRights : readAccessRole.accessRights;
90+
}
8891
const resourceAlias = this._resourceType === "template" ?
8992
osparc.product.Utils.getTemplateAlias({firstUpperCase: true}) :
9093
osparc.product.Utils.getStudyAlias({firstUpperCase: true});
9194
const newCollaborators = {};
9295
gids.forEach(gid => {
93-
newCollaborators[gid] = this._resourceType === "study" ? writeAccessRole.accessRights : readAccessRole.accessRights
96+
newCollaborators[gid] = newAccessRights;
9497
});
9598
osparc.store.Study.addCollaborators(this._serializedDataCopy, newCollaborators)
9699
.then(() => {

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", {
7777
}
7878
case "potential-collaborators-list": {
7979
control = new qx.ui.container.Composite(new qx.ui.layout.VBox()).set({
80-
minHeight: 100,
80+
minHeight: 160,
8181
});
8282
const scrollContainer = new qx.ui.container.Scroll();
8383
scrollContainer.add(control);
@@ -311,8 +311,18 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", {
311311
this.getChildControl("potential-collaborators-list").setEnabled(false);
312312
this.getChildControl("share-button").setFetching(true);
313313

314+
let newAccessRights = null;
315+
if (this.__resourceData["resourceType"] === "study") {
316+
const selected = this.getChildControl("access-rights-selector").getSelection()[0];
317+
if (selected) {
318+
newAccessRights = osparc.data.Roles.STUDY[selected.getModel()];
319+
}
320+
}
314321
if (Object.keys(this.__selectedCollaborators).length) {
315-
this.fireDataEvent("addCollaborators", Object.keys(this.__selectedCollaborators));
322+
this.fireDataEvent("addCollaborators", {
323+
selectedGids: Object.keys(this.__selectedCollaborators),
324+
newAccessRights,
325+
});
316326
}
317327
}
318328
}

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@ qx.Class.define("osparc.share.PublishTemplate", {
5959
this._add(this.__selectedCollabs);
6060

6161
addCollaborators.addListener("addCollaborators", e => {
62-
const gids = e.getData();
63-
if (gids.length) {
62+
const {
63+
selectedGids,
64+
} = e.getData();
65+
if (selectedGids.length) {
6466
const potentialCollaborators = osparc.store.Groups.getInstance().getPotentialCollaborators(false, true)
6567
const currentGids = this.getSelectedGroups();
66-
gids.forEach(gid => {
68+
selectedGids.forEach(gid => {
6769
if (gid in potentialCollaborators && !currentGids.includes(gid)) {
6870
const collabButton = new qx.ui.toolbar.Button(potentialCollaborators[gid].getLabel(), "@MaterialIcons/close/12");
6971
collabButton.gid = gid;

0 commit comments

Comments
 (0)