From b4a2613a045a7290a732275d8741a74773c34ec5 Mon Sep 17 00:00:00 2001 From: Okke Harsta Date: Wed, 10 Jan 2024 10:28:04 +0100 Subject: [PATCH] Show error flash for roles with removed application(s) --- client/src/locale/en.js | 3 ++- client/src/locale/nl.js | 3 ++- client/src/pages/Role.js | 7 +++++-- client/src/tabs/Invitations.js | 2 +- client/src/tabs/UserRoles.js | 2 +- welcome/src/components/User.js | 4 +++- 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/client/src/locale/en.js b/client/src/locale/en.js index 623d8ce3..205dc6ce 100644 --- a/client/src/locale/en.js +++ b/client/src/locale/en.js @@ -158,7 +158,8 @@ const en = { createFlash: "Role {{name}} has been created", updateFlash: "Role {{name}} has been updated", unknownInManage: "Unknown in Manage", - unknownInManageToolTip: "The application for this role has been removed from the SURF backend. Please contact support@surfconext.nl to resolve this." + unknownInManageToolTip: "The application for this role has been removed from the SURF backend. Please contact support@surfconext.nl to resolve this.", + unknownInManageDisabled: "The application for this role has been removed from the SURF backend. Therefore you can't invite new users." }, applications: { searchPlaceHolder: "Search for roles" diff --git a/client/src/locale/nl.js b/client/src/locale/nl.js index 228204a9..d217f414 100644 --- a/client/src/locale/nl.js +++ b/client/src/locale/nl.js @@ -158,7 +158,8 @@ const nl = { createFlash: "Rol {{name}} is aangemaakt", updateFlash: "Rol {{name}} is bijgewerkt", unknownInManage: "Onbekend in Manage", - unknownInManageToolTip: "De applicatie voor deze rol is verwijderd in de SURF backend. Neem contact op met support@surfconext.nl om dit op te lossen." + unknownInManageToolTip: "De applicatie voor deze rol is verwijderd in de SURF backend. Neem contact op met support@surfconext.nl om dit op te lossen.", + unknownInManageDisabled: "De applicatie voor deze rol is verwijderd in de SURF backend. Daarom kan je geen nieuwe gebruikers uitnodigen." }, applications: { searchPlaceHolder: "Zoek rollen" diff --git a/client/src/pages/Role.js b/client/src/pages/Role.js index 281175b6..64a58b56 100644 --- a/client/src/pages/Role.js +++ b/client/src/pages/Role.js @@ -25,7 +25,7 @@ import {UnitHeaderInviter} from "../components/UnitHeaderInviter"; export const Role = () => { const {id, tab = "users"} = useParams(); const navigate = useNavigate(); - const {user, config, clearFlash} = useAppStore(state => state); + const {user, config, clearFlash, setFlash} = useAppStore(state => state); const [role, setRole] = useState({}); const [userRole, setUserRole] = useState({}); const [loading, setLoading] = useState(true); @@ -94,7 +94,10 @@ export const Role = () => { managers = res[1].filter(userRole => userRole.authority === AUTHORITIES.INSTITUTION_ADMIN) .map(userRole => userRole.userInfo.email); } - setManagerEmails(managers) + setManagerEmails(managers); + if (res[0].unknownInManage) { + setFlash(I18n.t("roles.unknownInManageDisabled"), "error"); + } setLoading(false); }) diff --git a/client/src/tabs/Invitations.js b/client/src/tabs/Invitations.js index cd26021b..8fa2db4c 100644 --- a/client/src/tabs/Invitations.js +++ b/client/src/tabs/Invitations.js @@ -310,7 +310,7 @@ export const Invitations = ({role, preloadedInvitations, standAlone = false, his columns={columns} title={title} newLabel={I18n.t("invitations.newInvite")} - showNew={!!role && (isUserAllowed(AUTHORITIES.MANAGER, user) || standAlone)} + showNew={!!role && (isUserAllowed(AUTHORITIES.MANAGER, user) || standAlone) && !role.unknownInManage} newEntityFunc={role ? () => navigate("/invitation/new", {state: role.id}) : null} customNoEntities={I18n.t(`invitations.noResults`)} loading={false} diff --git a/client/src/tabs/UserRoles.js b/client/src/tabs/UserRoles.js index 67bd731c..cec30afa 100644 --- a/client/src/tabs/UserRoles.js +++ b/client/src/tabs/UserRoles.js @@ -237,7 +237,7 @@ export const UserRoles = ({role, guests, userRoles}) => { defaultSort="name" columns={columns} newLabel={I18n.t(guests ? "invitations.newGuest" : "invitations.new")} - showNew={isUserAllowed(AUTHORITIES.MANAGER, user)} + showNew={isUserAllowed(AUTHORITIES.MANAGER, user) && !role.unknownInManage} newEntityFunc={() => navigate(`/invitation/new?maintainer=${guests === false}`, {state: role.id})} customNoEntities={I18n.t(`userRoles.noResults`)} loading={false} diff --git a/welcome/src/components/User.js b/welcome/src/components/User.js index b3ef29dc..d247ac96 100644 --- a/welcome/src/components/User.js +++ b/welcome/src/components/User.js @@ -10,7 +10,9 @@ export const User = ({user, invitationRoles = []}) => { const role = userRole.role; return ( - {role.applicationMaps.map((applicationMap, i) => + {role.applicationMaps + .filter(applicationMap => !applicationMap.unknown) + .map((applicationMap, i) =>