Skip to content

Commit

Permalink
Add admin check to no entries label in group acl (#976)
Browse files Browse the repository at this point in the history
Just noticed this special case:
<img width="1461" alt="Bildschirmfoto 2023-10-24 um 14 43 35"
src="https://github.com/elan-ev/tobira/assets/94838646/eba06161-4b3c-46df-a862-7665e0d16f9c">

Maybe this is ok, since a) only admins will see this and b) my guess is
that the list will usually have at least one real (i.e. not the
`Administrators`) entry. On the other hand, adding a check for this is
rather trivial.
  • Loading branch information
LukasKalbertodt authored Oct 24, 2023
2 parents 2877f3c + 88bcd2b commit b4e0a4d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions frontend/src/ui/Access.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ const AclSelect: React.FC<AclSelectProps> = ({ acl, kind }) => {
const { t, i18n } = useTranslation();
const { change, knownGroups, groupDag } = useAclContext();
const [menuIsOpen, setMenuIsOpen] = useState<boolean>(false);
const userIsAdmin = isRealUser(user) && user.roles.includes(COMMON_ROLES.ADMIN);

// Turn known roles into selectable options that react-select understands.
const knownRoles = kind === "Group" ? knownGroups : KNOWN_USERS;
Expand Down Expand Up @@ -287,7 +288,7 @@ const AclSelect: React.FC<AclSelectProps> = ({ acl, kind }) => {
</thead>
<tbody>
{/* Placeholder if there are no entries */}
{selection.length === 0 && <tr>
{selection.length === 0 && !userIsAdmin && <tr>
<td colSpan={3} css={{ textAlign: "center", fontStyle: "italic" }}>
{t("acl.no-entries")}
</td>
Expand All @@ -304,8 +305,7 @@ const AclSelect: React.FC<AclSelectProps> = ({ acl, kind }) => {
{(
kind === "Group"
&& !selection.some(s => s.value === COMMON_ROLES.ADMIN)
&& isRealUser(user)
&& user.roles.includes(COMMON_ROLES.ADMIN)
&& userIsAdmin
) && (
<ListEntry
item={{ label: t("acl.groups.admins"), value: COMMON_ROLES.ADMIN }}
Expand Down

0 comments on commit b4e0a4d

Please sign in to comment.