Skip to content

Commit

Permalink
Format unknown groups
Browse files Browse the repository at this point in the history
  • Loading branch information
owi92 committed Sep 5, 2023
1 parent a28b7d3 commit 44a0f63
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions frontend/src/routes/manage/Video/Access.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ const supersetList = (selection: Option, selectedGroups: MultiValue<Option>) =>
};


const getDisplayName = (
const getLabel = (
record: ACLRecord,
role: string,
) => {
Expand All @@ -780,10 +780,11 @@ const getDisplayName = (
};

const formatUnknownRole = (role: string) => {
// TODO: handle unknown groups.
if (role.startsWith("ROLE_USER_")) {
const name = role.replace("ROLE_USER_", "").toLowerCase();
return name.charAt(0).toUpperCase() + name.slice(1);
for (const prefix in (["ROLE_USER_", "ROLE_GROUP_"])) {
if (role.startsWith(prefix)) {
const name = role.replace(prefix, "").toLowerCase();
return name.charAt(0).toUpperCase() + name.slice(1);
}
}

return role;
Expand All @@ -810,7 +811,7 @@ const makeSelection = (record: ACLRecord, acl: ACL): Option[] => {
roles: roles,
action: getAction(acl, role),
},
label: getDisplayName(record, role),
label: getLabel(record, role),
};
});
};
Expand Down Expand Up @@ -846,6 +847,7 @@ type Selections = {
usersRef: RefObject<ACLSelectHandle>;
}

// Collects group and user selections and prepares them for submittal.
const getSelections = ({ groupsRef, usersRef }: Selections): ACL => {
const selectedGroups = groupsRef.current?.getSelection();
const selectedUsers = usersRef.current?.getSelection();
Expand Down

0 comments on commit 44a0f63

Please sign in to comment.