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

View file

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

View file

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