diff --git a/client/src/components/User.js b/client/src/components/User.js index a59f620a..ea47bffb 100644 --- a/client/src/components/User.js +++ b/client/src/components/User.js @@ -2,7 +2,7 @@ import React, {useEffect, useRef, useState} from "react"; import "./User.scss"; import InputField from "./InputField"; import {dateFromEpoch} from "../utils/Date"; -import {highestAuthority} from "../utils/UserRole"; +import {AUTHORITIES, highestAuthority} from "../utils/UserRole"; import I18n from "../locale/I18n"; import Logo from "./Logo"; import {Card, CardType} from "@surfnet/sds"; @@ -11,8 +11,9 @@ import {deriveRemoteApplicationAttributes} from "../utils/Manage"; import {ReactComponent as SearchIcon} from "@surfnet/sds/icons/functional-icons/search.svg"; import {MoreLessText} from "./MoreLessText"; import {RoleCard} from "./RoleCard"; +import DOMPurify from "dompurify"; -export const User = ({user, other}) => { +export const User = ({user, other, config}) => { const searchRef = useRef(); const [query, setQuery] = useState(""); @@ -104,18 +105,22 @@ export const User = ({user, other}) => { user.highestAuthority = I18n.t(`access.${highestAuthority(user)}`); const attributes = [["name"], ["sub"], ["eduPersonPrincipalName"], ["schacHomeOrganization"], ["email"], ["highestAuthority"], ["lastActivity", true]]; - const filteredUserRoles = user.userRoles.filter(filterUserRole); + const filteredUserRoles = user.userRoles.filter(filterUserRole).filter(role => role.authority !== AUTHORITIES.GUEST); const filteredApplications = (user.applications || []).filter(filterApplication); + const hasRoles = !isEmpty(user.userRoles.filter(role => role.authority !== AUTHORITIES.GUEST)) return (
{attributes.map((attr, index) => attribute(index, attr[0], attr[1]))}

{I18n.t("users.roles")}

- {(isEmpty(user.userRoles) && user.superUser) && + {highestAuthority(user) === AUTHORITIES.GUEST && +

} + {(!hasRoles && user.superUser) &&

{I18n.t("users.noRolesInfo")}

} - {(isEmpty(user.userRoles) && user.institutionAdmin) && + {(!hasRoles && user.institutionAdmin) &&

{I18n.t("users.noRolesInstitutionAdmin")}

} - {!isEmpty(user.userRoles) && + {hasRoles && <>

diff --git a/client/src/locale/en.js b/client/src/locale/en.js index 6d218170..4348a00b 100644 --- a/client/src/locale/en.js +++ b/client/src/locale/en.js @@ -92,6 +92,7 @@ const en = { applications: "Applications", noRolesInfo: "You have no roles (which means you must be super-user)", noRolesInstitutionAdmin: "As an institution admin you have no roles (but you do have access to applications)", + guestRoleOnly: "You are a guest user. Are you looking for the inviter app for guests?", rolesInfo: "You have the following roles", applicationsInfo: "You have access to the following applications", noRolesFound: "No roles are found.", @@ -163,6 +164,8 @@ const en = { multipleUserRoles: "user roles", searchPlaceHolder: "Search for user roles...", noResults: "No user roles where found", + guestRoles: "{{count}} guest users", + managerRoles: "{{count}} manager & inviter users", notAllowed: "You're not allowed to delete this user role because of missing roles", updateConfirmation: "Are you sure you want to change the end date of role {{roleName}} for {{userName}}", updateConfirmationRemoveEndDate: "Are you sure you want to remove the end date of role {{roleName}} for {{userName}}", diff --git a/client/src/locale/nl.js b/client/src/locale/nl.js index 2ea19b0b..336baef7 100644 --- a/client/src/locale/nl.js +++ b/client/src/locale/nl.js @@ -92,6 +92,7 @@ const nl = { applications: "Applicaties", noRolesInfo: "Je hebt geen rollen (je bent een super-user)", noRolesInstitutionAdmin: "Als een instellingsmanager heb je geen rollen (maar je hebt wel toegang tot je applicaties)", + guestRoleOnly: "Je bent een gast gebruiker. Was je op zoek naar de inviter app voor gasten?", rolesInfo: "Je hebt de volgende rollen", applicationsInfo: "Je hebt toegang tot de volgende applicaties", noRolesFound: "Geen rollen gevonden.", @@ -163,6 +164,8 @@ const nl = { multipleUserRoles: "gebruikersrollen", searchPlaceHolder: "Zoek gebruikersrollen...", noResults: "Geen gebruikersrollen gevonden", + guestRoles: "{{count}} gast gebruiker", + managerRoles: "{{count}} managers & uitnodigers", notAllowed: "Je kunt deze gebruikersrol niet verwijderen vanwege ontbrekende rollen", updateConfirmation: "Weet je zeker dat je de einddatum wilt aanpassen van rol {{roleName}} voor {{userName}}", updateConfirmationRemoveEndDate: "Weet je zeker dat je de einddatum wilt verwijderen van rol {{roleName}} voor {{userName}}", diff --git a/client/src/pages/Profile.js b/client/src/pages/Profile.js index 9dc99de5..bc0a9775 100644 --- a/client/src/pages/Profile.js +++ b/client/src/pages/Profile.js @@ -13,7 +13,7 @@ import {isEmpty} from "../utils/Utils"; export const Profile = () => { const {id} = useParams(); - const {user: currentUser} = useAppStore(state => state); + const {user: currentUser, config} = useAppStore(state => state); const [user, setUser] = useState(null); const [loading, setLoading] = useState(true); @@ -56,7 +56,7 @@ export const Profile = () => { })}

- +
); }; diff --git a/client/src/tabs/Roles.js b/client/src/tabs/Roles.js index 1d00d721..b029307c 100644 --- a/client/src/tabs/Roles.js +++ b/client/src/tabs/Roles.js @@ -49,11 +49,12 @@ export const Roles = () => { }, [user]);// eslint-disable-line react-hooks/exhaustive-deps const initFilterValues = res => { + const userRoles = res.filter(role => !(role.isUserRole && role.authority === "GUEST")); const newFilterOptions = [{ - label: I18n.t("invitations.statuses.all", {nbr: res.length}), + label: I18n.t("invitations.statuses.all", {nbr: userRoles.length}), value: allValue }]; - const reducedRoles = res.reduce((acc, role) => { + const reducedRoles = userRoles.reduce((acc, role) => { const option = acc.find(opt => opt.manageId === role.manageId); if (option) { ++option.nbr; diff --git a/client/src/tabs/UserRoles.js b/client/src/tabs/UserRoles.js index ff9bd9cb..6609ffbe 100644 --- a/client/src/tabs/UserRoles.js +++ b/client/src/tabs/UserRoles.js @@ -241,7 +241,7 @@ export const UserRoles = ({role, guests, userRoles}) => { newEntityFunc={() => navigate(`/invitation/new?maintainer=${guests === false}`, {state: role.id})} customNoEntities={I18n.t(`userRoles.noResults`)} loading={false} - hideTitle={true} + title={I18n.t(guests ? "userRoles.guestRoles" : "userRoles.managerRoles", {count: userRoles.length})} actions={actionButtons()} searchCallback={searchCallback} searchAttributes={["name", "email", "schacHomeOrganization"]}