async loading group can be undefined (#2068)

This commit is contained in:
Erik Jan de Wit 2022-02-21 15:58:28 +01:00 committed by GitHub
parent 627571dbf4
commit f3de9464f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View file

@ -26,9 +26,9 @@ import { GroupsModal } from "./GroupsModal";
import { toGroups } from "./routes/Groups";
import { toGroupsSearch } from "./routes/GroupsSearch";
import { GroupRoleMapping } from "./GroupRoleMapping";
import helpUrls from "../help-urls";
import "./GroupsSection.css";
import helpUrls from "../help-urls";
export default function GroupsSection() {
const { t } = useTranslation("groups");
@ -106,7 +106,7 @@ export default function GroupsSection() {
/>
)}
<ViewHeader
titleKey={!id ? "groups:groups" : currentGroup().name!}
titleKey={!id ? "groups:groups" : currentGroup()?.name!}
subKey={!id ? "groups:groupsDescription" : ""}
helpUrl={!id ? helpUrls.groupsUrl : ""}
divider={!id}
@ -117,7 +117,7 @@ export default function GroupsSection() {
<DropdownItem
data-testid="renameGroupAction"
key="renameGroup"
onClick={() => setRename(currentGroup().name)}
onClick={() => setRename(currentGroup()?.name)}
>
{t("renameGroup")}
</DropdownItem>,
@ -174,7 +174,7 @@ export default function GroupsSection() {
data-testid="role-mapping-tab"
title={<TabTitleText>{t("roleMapping")}</TabTitleText>}
>
<GroupRoleMapping id={id!} name={currentGroup().name!} />
<GroupRoleMapping id={id!} name={currentGroup()?.name!} />
</Tab>
</Tabs>
)}

View file

@ -68,7 +68,7 @@ export const Members = () => {
});
if (includeSubGroup) {
const subGroups = getSubGroups(currentGroup().subGroups!);
const subGroups = getSubGroups(currentGroup()?.subGroups!);
for (const group of subGroups) {
members = members.concat(
await adminClient.groups.listMembers({ id: group.id! })

View file

@ -7,7 +7,7 @@ type SubGroupsProps = {
setSubGroups: (group: GroupRepresentation[]) => void;
clear: () => void;
remove: (group: GroupRepresentation) => void;
currentGroup: () => GroupRepresentation;
currentGroup: () => GroupRepresentation | undefined;
};
const SubGroupContext = createContext<SubGroupsProps | undefined>(undefined);