Skip to content

Commit

Permalink
Show error flash for roles with removed application(s)
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Jan 10, 2024
1 parent 5d8389b commit b4a2613
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion client/src/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href=\"mailto:[email protected]\">[email protected]</a> to resolve this."
unknownInManageToolTip: "The application for this role has been removed from the SURF backend. Please contact <a href=\"mailto:[email protected]\">[email protected]</a> 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"
Expand Down
3 changes: 2 additions & 1 deletion client/src/locale/nl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href=\"mailto:[email protected]\">[email protected]</a> om dit op te lossen."
unknownInManageToolTip: "De applicatie voor deze rol is verwijderd in de SURF backend. Neem contact op met <a href=\"mailto:[email protected]\">[email protected]</a> 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"
Expand Down
7 changes: 5 additions & 2 deletions client/src/pages/Role.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

})
Expand Down
2 changes: 1 addition & 1 deletion client/src/tabs/Invitations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion client/src/tabs/UserRoles.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
4 changes: 3 additions & 1 deletion welcome/src/components/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ export const User = ({user, invitationRoles = []}) => {
const role = userRole.role;
return (
<React.Fragment key={index}>
{role.applicationMaps.map((applicationMap, i) =>
{role.applicationMaps
.filter(applicationMap => !applicationMap.unknown)
.map((applicationMap, i) =>
<RoleCard role={role}
key={i}
index={i}
Expand Down

0 comments on commit b4a2613

Please sign in to comment.