Skip to content

Commit 8e741de

Browse files
authored
ENG-1812 Allow non-admin group members to see view group membership (#1091)
1 parent 7dba053 commit 8e741de

1 file changed

Lines changed: 2 additions & 24 deletions

File tree

apps/website/app/components/auth/ListGroups.tsx

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ type GroupData = Tables<"my_groups">;
88

99
export const ListGroups = async () => {
1010
let groupData: GroupData[] | null = null;
11-
let adminData: Record<string, boolean> = {};
1211
let userName: string | undefined;
1312
let error: string | undefined;
1413

@@ -18,7 +17,7 @@ export const ListGroups = async () => {
1817
if (!userData) {
1918
throw new Error("Not logged in.\nPlease log in from application.");
2019
}
21-
const { name, type, id } = userData;
20+
const { name, type } = userData;
2221
if (type === "anonymous") userName = "Space " + name;
2322
else if (type === "group") userName = "group " + name;
2423
else if (type === "person") userName = name;
@@ -30,23 +29,6 @@ export const ListGroups = async () => {
3029
throw new Error("Could not access Discourse Graphs");
3130
}
3231
groupData = groupResponse.data;
33-
const membershipReq = await client
34-
.from("group_membership")
35-
.select("group_id,admin")
36-
.eq("member_id", id);
37-
if (membershipReq.error) {
38-
internalError({
39-
error: membershipReq.error,
40-
});
41-
throw new Error("Could not access Discourse Graphs");
42-
}
43-
adminData = Object.fromEntries(
44-
// eslint-disable-next-line @typescript-eslint/naming-convention
45-
membershipReq.data.map(({ group_id, admin }) => [
46-
group_id,
47-
admin || false,
48-
]),
49-
);
5032
} catch (e) {
5133
error = e instanceof Error ? e.message : "An unknown error occured";
5234
}
@@ -69,11 +51,7 @@ export const ListGroups = async () => {
6951
<ul className="list-inside list-disc space-y-2">
7052
{groupData.map((d) => (
7153
<li key={d.id}>
72-
{adminData[d.id || ""] ? (
73-
<Link href={"/auth/group/" + d.id!}>{d.name}</Link>
74-
) : (
75-
d.name
76-
)}
54+
<Link href={"/auth/group/" + d.id!}>{d.name}</Link>
7755
</li>
7856
))}
7957
</ul>

0 commit comments

Comments
 (0)