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

Users With Multiple Roles #2225

Open
adivated opened this issue Mar 23, 2021 · 4 comments
Open

Users With Multiple Roles #2225

adivated opened this issue Mar 23, 2021 · 4 comments
Labels
bug Something isn't working UI

Comments

@adivated
Copy link

If you have a user with rights of multiple roles (e.g. 17), the organizations -> members UI page crashes. thx.

Screen Shot 2021-03-23 at 9 06 37 AM

@josipbagaric josipbagaric added the bug Something isn't working label Mar 23, 2021
@adivated
Copy link
Author

affending line(s) (the .map below) in OrganizationUsersTable.tsx:

const rows = paginatedData.map(({ user }) => {
return {
firstName: user.firstName,
lastName: user.lastName,
email: user.email,
role: getRolesFromRights(user.rights)
.map((role) => t(roleNames.filter((roleName) => roleName.value === role)[0].label))
.join(', ')
};
});

@adivated
Copy link
Author

adivated commented Mar 23, 2021

more info. The precise condition was that a user had some global roles and organization roles at the same time (e.g. a platform admin as well as an org admin). The roleNames table in organizationRoles.ts only has the org roles in its mappings, hence the bug above. Not sure how common it will be to have a user with this role setup, but it is possible I suppose. It wouldn't be hard to just add the missing roles to the roleNames var.

@adivated
Copy link
Author

adivated commented Mar 23, 2021

or a small fix (which omits the main roles but lets the page complete):

.map((role) => t(roleNames.filter((roleName) => roleName.value === role)[0]?.label))

(not elegant and not recommended...)

or to hide (not display) non org roles:

role: getRolesFromRights(user.rights)
.filter((r) => roleNames.find((elem) => elem.value === r))
.map((role) => t(roleNames.filter((roleName) => roleName.value === role)[0].label))
.join(', ')

thx.

@adivated
Copy link
Author

This is actually properly part of a larger discussion with Piotr probably, as there are 2 distinct sets/types of roles in Origin, and they are being mixed but also used for different purposes. Best to hold this until that discussion (maybe tomorrow). thx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working UI
Projects
None yet
Development

No branches or pull requests

2 participants