diff --git a/src/user/UserGroups.tsx b/src/user/UserGroups.tsx
index e22cf9ed03..fd917349be 100644
--- a/src/user/UserGroups.tsx
+++ b/src/user/UserGroups.tsx
@@ -32,6 +32,9 @@ export const UserGroups = () => {
const [username, setUsername] = useState("");
const [isDirectMembership, setDirectMembership] = useState(true);
+ const [directMembershipList, setDirectMembershipList] = useState<
+ GroupRepresentation[]
+ >([]);
const [open, setOpen] = useState(false);
const adminClient = useAdminClient();
@@ -137,6 +140,7 @@ export const UserGroups = () => {
(value) => !topLevelGroups.includes(value)
);
+ setDirectMembershipList(directMembership);
const filterDupesfromGroups = allPaths.filter(
(thing, index, self) =>
index === self.findIndex((t) => t.name === thing.name)
@@ -169,16 +173,6 @@ export const UserGroups = () => {
return <>{group.name}>;
};
- const LeaveButtonRenderer = (group: GroupRepresentation) => {
- return (
- <>
-
- >
- );
- };
-
const toggleModal = () => setOpen(!open);
const [toggleDeleteDialog, DeleteConfirm] = useConfirmDialog({
@@ -213,6 +207,23 @@ export const UserGroups = () => {
toggleDeleteDialog();
};
+ const LeaveButtonRenderer = (group: GroupRepresentation) => {
+ if (
+ directMembershipList.some((item) => item.id === group.id) ||
+ directMembershipList.length === 0
+ ) {
+ return (
+ <>
+
+ >
+ );
+ } else {
+ return <> >;
+ }
+ };
+
return (
<>
@@ -258,6 +269,7 @@ export const UserGroups = () => {
cellFormatters: [emptyFormatter()],
transforms: [cellWidth(45)],
},
+
{
name: "",
cellRenderer: LeaveButtonRenderer,