diff --git a/webui/src/components/user.jsx b/webui/src/components/user.jsx index fb8033651..a9ee7d980 100644 --- a/webui/src/components/user.jsx +++ b/webui/src/components/user.jsx @@ -111,15 +111,15 @@ export const UserProfile = React.createClass({ ); }, - createLink(communitiesList, name){ - return (admin page) + createLink(communitiesMapping, name) { + return (admin page) }, - listRoles(roles, communitiesList){ + listRoles(roles, communitiesMapping) { return roles.map(r =>
  • {r.get('description')} - {r.get('name').includes(':admin')? this.createLink(communitiesList, r.get('name')) : ""} + {r.get('name').includes(':admin')? this.createLink(communitiesMapping, r.get('name')) : ""}
  • ) }, @@ -129,11 +129,13 @@ export const UserProfile = React.createClass({ return this.renderNoUser(); } const roles = user.get('roles'); - const communitiesListTemp = serverCache.getCommunities(); - var communitiesList = communitiesListTemp.reduce(function(map, community){ - map[community.get('id').replace(new RegExp("-",'g'),"")] = community.get('name'); - return map; - }); + const communitiesList = serverCache.getCommunities(); + if (communitiesList.size) { + var communitiesMapping = communitiesList.reduce((map, community) => { + map[community.get('id').replace(new RegExp("-",'g'),"")] = community.get('name'); + return map; + }, {}); + } return (

    User Profile

    @@ -145,7 +147,7 @@ export const UserProfile = React.createClass({

    Roles

    - {roles && roles.count() && typeof(communitiesList) !== "undefined" ? this.listRoles(roles, communitiesList) : "You have no assigned roles" } + {(roles && roles.count() && communitiesMapping !== undefined) ? this.listRoles(roles, communitiesMapping) : "You have no assigned roles" }