Skip to content

Commit

Permalink
BSR institution admin
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Sep 28, 2023
1 parent fa34612 commit cd42c58
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion client/src/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ const en = {
history: "Invitation History"
},
institutionAdmin: {
welcome: "Welcome Institution administrator of {{name}}! You can start with creating your first role and invite managers.",
welcome: "Welcome Institution administrator of {{name}}! You can start with creating your first role and subsequently invite managers.",
create: "Create access role"
},
tooltips: {
Expand Down
17 changes: 11 additions & 6 deletions client/src/tabs/Roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {useAppStore} from "../stores/AppStore";
import React, {useEffect, useState} from "react";
import {Entities} from "../components/Entities";
import I18n from "../locale/I18n";
import {Button, Chip, Loader} from "@surfnet/sds";
import {Button, ButtonSize, Chip, Loader} from "@surfnet/sds";
import {useNavigate} from "react-router-dom";
import {AUTHORITIES, highestAuthority, isUserAllowed, markAndFilterRoles} from "../utils/UserRole";
import {rolesByApplication, searchRoles} from "../api";
Expand All @@ -26,13 +26,16 @@ export const Roles = () => {
if (isUserAllowed(AUTHORITIES.MANAGER, user)) {
if (!roleSearchRequired) {
rolesByApplication()
.then(res => setRoles(markAndFilterRoles(user, res, I18n.locale)))
setLoading(false);
.then(res => {
setRoles(markAndFilterRoles(user, res, I18n.locale));
setLoading(false);
})

}
} else {
setRoles(markAndFilterRoles(user, [], I18n.locale))
setLoading(false);
}
setLoading(false);
}, [user]);// eslint-disable-line react-hooks/exhaustive-deps

const openRole = (e, role) => {
Expand Down Expand Up @@ -84,7 +87,9 @@ export const Roles = () => {
<div className="institution-admin-welcome">
{logo ? <img src={logo} alt="logo"/> : <VoidImage/>}
<p>{I18n.t("institutionAdmin.welcome", {name: name})}</p>
<Button txt={I18n.t("institutionAdmin.create")} onClick={() => navigate("/role/new")}/>
<Button txt={I18n.t("institutionAdmin.create")}
size={ButtonSize.Full}
onClick={() => navigate("/role/new")}/>
</div>
);
}
Expand Down Expand Up @@ -137,7 +142,7 @@ export const Roles = () => {
const isSuperUser = isUserAllowed(AUTHORITIES.SUPER_USER, user);
const isManager = isUserAllowed(AUTHORITIES.MANAGER, user);
const isInstitutionAdmin = highestAuthority(user) === AUTHORITIES.INSTITUTION_ADMIN;
if (isInstitutionAdmin && !isEmpty(user.institution)) {
if (isInstitutionAdmin && !isEmpty(user.institution) && roles.length === 0) {
return (
<div className={"mod-roles"}>
{noRolesInstitutionAdmin()}
Expand Down
3 changes: 1 addition & 2 deletions client/src/tabs/Roles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ div.mod-roles {
}

p {
margin: 25px 0;
font-size: 18px;
margin: 40px 0;
}
}

Expand Down

0 comments on commit cd42c58

Please sign in to comment.