Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ [Frontend] Search users for sharing #6974

Merged
merged 147 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
147 commits
Select commit Hold shift + click to select a range
dd4f14f
prefix admin
pcrespov Dec 13, 2024
d2908b5
oas
pcrespov Dec 13, 2024
f3dc452
adds get user
pcrespov Dec 13, 2024
8350239
admin and users
pcrespov Dec 13, 2024
bd30ed0
drafter interface
pcrespov Dec 13, 2024
fb4adc6
acceptance tests
pcrespov Dec 13, 2024
089a93d
tests
pcrespov Dec 13, 2024
27e5627
drafts
pcrespov Dec 13, 2024
f7246a5
acceptance test passes
pcrespov Dec 13, 2024
6875b17
updates OAS
pcrespov Dec 16, 2024
031d39d
cleanup
pcrespov Dec 16, 2024
d2537dc
minor
pcrespov Dec 17, 2024
f0d4a54
cleanup
pcrespov Dec 17, 2024
06011ed
drafted groups
pcrespov Dec 17, 2024
73b136d
drafted tests
pcrespov Dec 17, 2024
4822f82
acceptance test passes
pcrespov Dec 17, 2024
c555613
update OAS
pcrespov Dec 17, 2024
f60ca0a
updates search on names
pcrespov Dec 17, 2024
804525f
updates OAS
pcrespov Dec 17, 2024
e4c9f31
fixes OAS
pcrespov Dec 17, 2024
cfe5d8d
fixes
pcrespov Dec 17, 2024
818588c
adds restricted access
pcrespov Dec 17, 2024
5592677
updates doc
pcrespov Dec 17, 2024
92d467f
reverts defaults
pcrespov Dec 17, 2024
fb9cb07
fixes tess
pcrespov Dec 17, 2024
3d8e18e
fixes get users in group
pcrespov Dec 17, 2024
cb0e4e3
mypy and oas
pcrespov Dec 17, 2024
f8e25ee
cleanup
pcrespov Dec 17, 2024
0ff2820
fixes tests
pcrespov Dec 17, 2024
b1ede65
Merge branch 'is1779/search-users' of github.com:pcrespov/osparc-simc…
odeimaiz Dec 17, 2024
bb01332
users -> poUsers
odeimaiz Dec 17, 2024
215f8c7
[skip ci] search users
odeimaiz Dec 17, 2024
0c7e4b2
@odeimaiz review: deprecated admin users
pcrespov Dec 17, 2024
a75fb90
search endpoint wired
odeimaiz Dec 17, 2024
f779d49
Merge branch 'master' into is1779/search-users
pcrespov Dec 17, 2024
0cd66ad
Merge branch 'is1779/search-users' of github.com:pcrespov/osparc-simc…
odeimaiz Dec 17, 2024
32b0ea4
Merge branch 'master' into is1779/search-users
pcrespov Dec 17, 2024
8ce0722
Merge branch 'is1779/search-users' of github.com:pcrespov/osparc-simc…
odeimaiz Dec 17, 2024
89dab4c
reachableUsers -> users
odeimaiz Dec 17, 2024
5e75847
Users Store
odeimaiz Dec 17, 2024
5ad5018
[skip ci] refactor
odeimaiz Dec 17, 2024
ffb54c0
prefix admin
pcrespov Dec 13, 2024
9010fb1
oas
pcrespov Dec 13, 2024
96dd806
adds get user
pcrespov Dec 13, 2024
b2a141c
admin and users
pcrespov Dec 13, 2024
c04ab93
drafter interface
pcrespov Dec 13, 2024
d39d6ff
acceptance tests
pcrespov Dec 13, 2024
de2970c
tests
pcrespov Dec 13, 2024
3f4e64b
drafts
pcrespov Dec 13, 2024
91fb710
acceptance test passes
pcrespov Dec 13, 2024
698649b
updates OAS
pcrespov Dec 16, 2024
a61399c
cleanup
pcrespov Dec 16, 2024
0643d1c
minor
pcrespov Dec 17, 2024
863df57
cleanup
pcrespov Dec 17, 2024
31d0235
drafted groups
pcrespov Dec 17, 2024
1988ed8
drafted tests
pcrespov Dec 17, 2024
39ca338
acceptance test passes
pcrespov Dec 17, 2024
5bbc612
update OAS
pcrespov Dec 17, 2024
e801470
updates search on names
pcrespov Dec 17, 2024
84ab49d
updates OAS
pcrespov Dec 17, 2024
89e646e
fixes OAS
pcrespov Dec 17, 2024
3b4e548
fixes
pcrespov Dec 17, 2024
41bb2bf
adds restricted access
pcrespov Dec 17, 2024
c7e1a82
updates doc
pcrespov Dec 17, 2024
7f03880
reverts defaults
pcrespov Dec 17, 2024
fd51bf4
fixes tess
pcrespov Dec 17, 2024
8d35cf7
fixes get users in group
pcrespov Dec 17, 2024
20d5486
mypy and oas
pcrespov Dec 17, 2024
f6cdcb9
cleanup
pcrespov Dec 17, 2024
355642a
fixes tests
pcrespov Dec 17, 2024
95b3627
@odeimaiz review: deprecated admin users
pcrespov Dec 17, 2024
8df00b3
new tests
pcrespov Dec 17, 2024
3e95ef7
common
pcrespov Dec 17, 2024
ea31c64
pylint
pcrespov Dec 17, 2024
00958ce
cleanup
pcrespov Dec 17, 2024
e4aad80
reactivated test
pcrespov Dec 18, 2024
50f64b7
fixes migration
pcrespov Dec 18, 2024
b6b1460
minor
pcrespov Dec 18, 2024
ae95280
disables meta test
pcrespov Dec 18, 2024
d8f7b4d
Merge branch 'is1779/search-users' of github.com:pcrespov/osparc-simc…
odeimaiz Dec 18, 2024
1e99456
[skip ci] support btoth types os users
odeimaiz Dec 18, 2024
5021976
renaming
odeimaiz Dec 18, 2024
c1f1b5c
[skip ci] share with strangers
odeimaiz Dec 18, 2024
29223c6
[skip ci] refactor
odeimaiz Dec 18, 2024
88c2dbc
prefix admin
pcrespov Dec 13, 2024
bbae2be
oas
pcrespov Dec 13, 2024
d43dfd3
adds get user
pcrespov Dec 13, 2024
21ccbe0
admin and users
pcrespov Dec 13, 2024
e99c334
drafter interface
pcrespov Dec 13, 2024
e33efeb
acceptance tests
pcrespov Dec 13, 2024
72751d0
tests
pcrespov Dec 13, 2024
fd9d320
drafts
pcrespov Dec 13, 2024
d5f2dd8
acceptance test passes
pcrespov Dec 13, 2024
f066895
updates OAS
pcrespov Dec 16, 2024
2a13f56
cleanup
pcrespov Dec 16, 2024
ed53e2a
minor
pcrespov Dec 17, 2024
91acb79
cleanup
pcrespov Dec 17, 2024
96d7f4e
drafted groups
pcrespov Dec 17, 2024
2cd0193
drafted tests
pcrespov Dec 17, 2024
fa125d7
acceptance test passes
pcrespov Dec 17, 2024
a76d9a1
update OAS
pcrespov Dec 17, 2024
4c6748d
updates search on names
pcrespov Dec 17, 2024
db860a7
updates OAS
pcrespov Dec 17, 2024
062e508
fixes OAS
pcrespov Dec 17, 2024
f22bd07
fixes
pcrespov Dec 17, 2024
649e6cf
adds restricted access
pcrespov Dec 17, 2024
4e8b6a5
updates doc
pcrespov Dec 17, 2024
07506bb
reverts defaults
pcrespov Dec 17, 2024
620c954
fixes tess
pcrespov Dec 17, 2024
195040a
fixes get users in group
pcrespov Dec 17, 2024
7af1bfa
mypy and oas
pcrespov Dec 17, 2024
ef92fe9
cleanup
pcrespov Dec 17, 2024
1394397
fixes tests
pcrespov Dec 17, 2024
8d088c1
@odeimaiz review: deprecated admin users
pcrespov Dec 17, 2024
1834e83
new tests
pcrespov Dec 17, 2024
72954f4
common
pcrespov Dec 17, 2024
694a0d7
pylint
pcrespov Dec 17, 2024
4aaa20d
cleanup
pcrespov Dec 17, 2024
d0bfb17
reactivated test
pcrespov Dec 18, 2024
1d39673
fixes migration
pcrespov Dec 18, 2024
e937280
minor
pcrespov Dec 18, 2024
490a5c3
disables meta test
pcrespov Dec 18, 2024
82a5348
user_id
pcrespov Dec 18, 2024
c94a135
reduced duplication
pcrespov Dec 18, 2024
68cbbd5
fetch users and refactoring
odeimaiz Dec 18, 2024
cd88ca7
minor
odeimaiz Dec 18, 2024
e80dc36
texts
odeimaiz Dec 18, 2024
916d915
minor
odeimaiz Dec 18, 2024
ce381ee
Merge branch 'is1779/search-users' of github.com:pcrespov/osparc-simc…
odeimaiz Dec 18, 2024
ba17c30
Merge branch 'master' into feature/search-users
odeimaiz Jan 3, 2025
f40de97
merge master
odeimaiz Jan 3, 2025
3a98a7a
aesthetics
odeimaiz Jan 3, 2025
c07e651
aesthetics
odeimaiz Jan 3, 2025
9ac790f
more aesthetics
odeimaiz Jan 3, 2025
d48c6d8
minor fix
odeimaiz Jan 6, 2025
89e8279
refactor and less text
odeimaiz Jan 6, 2025
447390b
refactor
odeimaiz Jan 6, 2025
aace607
[skip ci] support also orgs
odeimaiz Jan 6, 2025
bb29013
add members
odeimaiz Jan 6, 2025
917a423
Enter command
odeimaiz Jan 6, 2025
1f6e51f
texts and aesthetics
odeimaiz Jan 6, 2025
e9f15f9
rename
odeimaiz Jan 6, 2025
a228de6
compact
odeimaiz Jan 6, 2025
8873b2a
aesthetics
odeimaiz Jan 6, 2025
eec836a
do not list those that were already listed
odeimaiz Jan 6, 2025
3d328c8
Merge branch 'master' into feature/search-users
odeimaiz Jan 6, 2025
fddb55a
Merge branch 'master' into feature/search-users
odeimaiz Jan 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -148,54 +148,59 @@ qx.Class.define("osparc.dashboard.CardBase", {
return false;
},

// groups -> [orgMembs, orgs, [productEveryone], [everyone]];
setIconAndTooltip: function(shareIcon, accessRights, groups) {
shareIcon.setSource(osparc.dashboard.CardBase.SHARE_ICON);
if (osparc.data.model.Study.canIWrite(accessRights)) {
shareIcon.set({
toolTipText: qx.locale.Manager.tr("Share")
});
populateShareIcon: async function(shareIcon, accessRights) {
const gids = Object.keys(accessRights).map(key => parseInt(key));

const groupsStore = osparc.store.Groups.getInstance();

// Icon
const groupEveryone = groupsStore.getEveryoneGroup();
const groupProductEveryone = groupsStore.getEveryoneProductGroup();
const organizations = groupsStore.getOrganizations();
const organizationIds = Object.keys(organizations).map(key => parseInt(key));
if (gids.includes(groupEveryone.getGroupId()) || gids.includes(groupProductEveryone.getGroupId())) {
shareIcon.setSource(osparc.dashboard.CardBase.SHARED_ALL);
} else if (organizationIds.filter(value => gids.includes(value)).length) { // find intersection
shareIcon.setSource(osparc.dashboard.CardBase.SHARED_ORGS);
} else if (gids.length === 1) {
shareIcon.setSource(osparc.dashboard.CardBase.SHARE_ICON);
} else {
shareIcon.setSource(osparc.dashboard.CardBase.SHARED_USER);
}
let sharedGrps = [];
const myGroupId = osparc.auth.Data.getInstance().getGroupId();
for (let i=0; i<groups.length; i++) {
if (groups[i].length === 0) {
// user has no read access to the productEveryone
continue;

// Tooltip
const sharedGrps = [];
const groups = [];
groups.push(groupEveryone);
groups.push(groupProductEveryone);
groups.push(...Object.values(organizations));
groups.forEach(group => {
const idx = gids.indexOf(group.getGroupId());
if (idx > -1) {
sharedGrps.push(group);
gids.splice(idx, 1);
}
const sharedGrp = [];
const gids = Object.keys(accessRights);
for (let j=0; j<gids.length; j++) {
const gid = parseInt(gids[j]);
if (gid === myGroupId) {
continue;
}
const grp = groups[i].find(group => group.getGroupId() === gid);
if (grp) {
sharedGrp.push(grp);
});
// once the groups were removed, the remaining group ids are users' primary groups ids
const usersStore = osparc.store.Users.getInstance();
const myGroupId = groupsStore.getMyGroupId();
for (let i=0; i<gids.length; i++) {
const gid = gids[i];
if (myGroupId !== gid) {
const user = await usersStore.getUser(gid);
if (user) {
sharedGrps.push(user);
}
}
if (sharedGrp.length === 0) {
continue;
} else {
sharedGrps = sharedGrps.concat(sharedGrp);
}
switch (i) {
case 0:
shareIcon.setSource(osparc.dashboard.CardBase.SHARED_USER);
break;
case 1:
shareIcon.setSource(osparc.dashboard.CardBase.SHARED_ORGS);
break;
case 2:
case 3:
shareIcon.setSource(osparc.dashboard.CardBase.SHARED_ALL);
break;
}
}

// tooltip
const canIWrite = osparc.data.model.Study.canIWrite(accessRights);
if (sharedGrps.length === 0) {
if (canIWrite) {
shareIcon.set({
toolTipText: qx.locale.Manager.tr("Share")
});
}
return;
}
const sharedGrpLabels = [];
Expand All @@ -215,17 +220,6 @@ qx.Class.define("osparc.dashboard.CardBase", {
shareIcon.addListener("mouseover", () => hint.show(), this);
shareIcon.addListener("mouseout", () => hint.exclude(), this);
},

// groups -> [orgMembs, orgs, [productEveryone], [everyone]];
populateShareIcon: function(shareIcon, accessRights) {
const groupsStore = osparc.store.Groups.getInstance();
const orgMembs = Object.values(groupsStore.getReachableUsers());
const orgs = Object.values(groupsStore.getOrganizations());
const productEveryone = [groupsStore.getEveryoneProductGroup()];
const everyone = [groupsStore.getEveryoneGroup()];
const groups = [orgMembs, orgs, productEveryone, everyone];
osparc.dashboard.CardBase.setIconAndTooltip(shareIcon, accessRights, groups);
},
},

properties: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,22 @@ qx.Class.define("osparc.data.Resources", {
}
}
},
/*
* USERS
*/
"users": {
useCache: false, // osparc.store.Groups handles the cache
endpoints: {
get: {
method: "GET",
url: statics.API + "/groups/{gid}/users"
},
search: {
method: "POST",
url: statics.API + "/users:search"
}
}
},
/*
* WALLETS
*/
Expand Down Expand Up @@ -958,7 +974,7 @@ qx.Class.define("osparc.data.Resources", {
}
}
},
"users": {
"poUsers": {
endpoints: {
search: {
method: "GET",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ qx.Class.define("osparc.data.Roles", {
}
},

__createIntoFromRoles: function(roles, showWording = true) {
__createRolesLayout: function(roles, showWording = true) {
const rolesLayout = new qx.ui.container.Composite(new qx.ui.layout.HBox(5)).set({
alignY: "middle",
paddingRight: 10
Expand Down Expand Up @@ -202,23 +202,34 @@ qx.Class.define("osparc.data.Roles", {
},

createRolesOrgInfo: function() {
return this.__createIntoFromRoles(osparc.data.Roles.ORG);
return this.__createRolesLayout(osparc.data.Roles.ORG);
},

createRolesWalletInfo: function() {
return this.__createIntoFromRoles(osparc.data.Roles.WALLET);
return this.__createRolesLayout(osparc.data.Roles.WALLET);
},

createRolesStudyInfo: function() {
return this.__createIntoFromRoles(osparc.data.Roles.STUDY);
return this.__createRolesLayout(osparc.data.Roles.STUDY);
},

createRolesServicesInfo: function() {
return this.__createIntoFromRoles(osparc.data.Roles.SERVICES);
return this.__createRolesLayout(osparc.data.Roles.SERVICES);
},

createRolesWorkspaceInfo: function(showWording = true) {
return this.__createIntoFromRoles(osparc.data.Roles.WORKSPACE, showWording);
}
return this.__createRolesLayout(osparc.data.Roles.WORKSPACE, showWording);
},

replaceSpacerWithWidget: function(rolesLayout, widget) {
if (rolesLayout && rolesLayout.getChildren()) {
// remove spacer
rolesLayout.remove(rolesLayout.getChildren()[0]);
// add widget
rolesLayout.addAt(widget, 0, {
flex: 1
});
}
},
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -274,21 +274,19 @@ qx.Class.define("osparc.data.model.Study", {
},

canIWrite: function(studyAccessRights) {
const myGroupId = osparc.auth.Data.getInstance().getGroupId();
const groupsStore = osparc.store.Groups.getInstance();
const orgIDs = groupsStore.getOrganizationIds();
orgIDs.push(myGroupId);
orgIDs.push(groupsStore.getMyGroupId());
if (orgIDs.length) {
return osparc.share.CollaboratorsStudy.canGroupsWrite(studyAccessRights, (orgIDs));
}
return false;
},

canIDelete: function(studyAccessRights) {
const myGroupId = osparc.auth.Data.getInstance().getGroupId();
const groupsStore = osparc.store.Groups.getInstance();
const orgIDs = groupsStore.getOrganizationIds();
orgIDs.push(myGroupId);
orgIDs.push(groupsStore.getMyGroupId());
if (orgIDs.length) {
return osparc.share.CollaboratorsStudy.canGroupsDelete(studyAccessRights, (orgIDs));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,30 @@ qx.Class.define("osparc.data.model.User", {
construct: function(userData) {
this.base(arguments);

let description = "";
if (userData["first_name"]) {
description = userData["first_name"];
if (userData["last_name"]) {
description += " " + userData["last_name"];
const userId = ("id" in userData) ? parseInt(userData["id"]) : parseInt(userData["userId"]);
const groupId = ("gid" in userData) ? parseInt(userData["gid"]) : parseInt(userData["groupId"]);
const username = userData["userName"];
const email = ("login" in userData) ? userData["login"] : userData["email"];
const firstName = ("first_name" in userData) ? userData["first_name"] : userData["firstName"];
const lastName = ("last_name" in userData) ? userData["last_name"] : userData["lastName"];
let description = [firstName, lastName].join(" ").trim(); // the null values will be replaced by empty strings
if (email) {
if (description) {
description += " - "
}
description += " - ";
description += email;
}
if (userData["login"]) {
description += userData["login"];
}
const thumbnail = osparc.utils.Avatar.emailToThumbnail(userData["login"], userData["userName"]);
const thumbnail = osparc.utils.Avatar.emailToThumbnail(email, username);
this.set({
userId: parseInt(userData["id"]),
groupId: parseInt(userData["gid"]),
username: userData["userName"],
firstName: userData["first_name"],
lastName: userData["last_name"],
email: userData["login"],
label: userData["userName"],
description,
userId,
groupId,
username,
firstName,
lastName,
email,
thumbnail,
label: username,
description,
});
},

Expand Down
Loading
Loading