Skip to content

feat: add groups column to members page in organizations #14620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: add groups column to members page in organizations
  • Loading branch information
DanielleMaywood committed Sep 9, 2024
commit 01aabc5cb1dc5a492e69fec1d07b5f08a566ece3
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { groupsByUserId } from "api/queries/groups";
import {
addOrganizationMember,
organizationMembers,
Expand All @@ -22,6 +23,8 @@ const OrganizationMembersPage: FC = () => {
};
const { user: me } = useAuthenticated();

const groupsByUserIdQuery = useQuery(groupsByUserId());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note how this query doesn't take the organizationName as a parameter: this is not scoped to an organization, this shows every group a user is in.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops 🤦‍♀️ Thank you for catching that


const membersQuery = useQuery(organizationMembers(organizationName));
const organizationRolesQuery = useQuery(organizationRoles(organizationName));

Expand Down Expand Up @@ -58,6 +61,7 @@ const OrganizationMembersPage: FC = () => {
isUpdatingMemberRoles={updateMemberRolesMutation.isLoading}
me={me}
members={membersQuery.data}
groupsByUserId={groupsByUserIdQuery.data}
addMember={async (user: User) => {
await addMemberMutation.mutateAsync(user.id);
void membersQuery.refetch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import TableContainer from "@mui/material/TableContainer";
import TableHead from "@mui/material/TableHead";
import TableRow from "@mui/material/TableRow";
import { getErrorMessage } from "api/errors";
import type { GroupsByUserId } from "api/queries/groups";
import type {
OrganizationMemberWithUserData,
SlimRole,
Expand All @@ -30,6 +31,7 @@ import { UserAvatar } from "components/UserAvatar/UserAvatar";
import { type FC, useState } from "react";
import { TableColumnHelpTooltip } from "./UserTable/TableColumnHelpTooltip";
import { UserRoleCell } from "./UserTable/UserRoleCell";
import { UserGroupsCell } from "pages/UsersPage/UsersTable/UserGroupsCell";

interface OrganizationMembersPageViewProps {
allAvailableRoles: readonly SlimRole[] | undefined;
Expand All @@ -39,6 +41,7 @@ interface OrganizationMembersPageViewProps {
isUpdatingMemberRoles: boolean;
me: User;
members: OrganizationMemberWithUserData[] | undefined;
groupsByUserId: GroupsByUserId | undefined,
addMember: (user: User) => Promise<void>;
removeMember: (member: OrganizationMemberWithUserData) => Promise<void>;
updateMemberRoles: (
Expand Down Expand Up @@ -68,13 +71,19 @@ export const OrganizationMembersPageView: FC<
<Table>
<TableHead>
<TableRow>
<TableCell width="50%">User</TableCell>
<TableCell width="49%">
<TableCell width="33%">User</TableCell>
<TableCell width="33%">
<Stack direction="row" spacing={1} alignItems="center">
<span>Roles</span>
<TableColumnHelpTooltip variant="roles" />
</Stack>
</TableCell>
<TableCell width="33%">
<Stack direction="row" spacing={1} alignItems="center">
<span>Groups</span>
<TableColumnHelpTooltip variant="groups" />
</Stack>
</TableCell>
<TableCell width="1%"></TableCell>
</TableRow>
</TableHead>
Expand Down Expand Up @@ -111,6 +120,7 @@ export const OrganizationMembersPageView: FC<
}
}}
/>
<UserGroupsCell userGroups={props.groupsByUserId?.get(member.user_id)} />
<TableCell>
{member.user_id !== props.me.id && props.canEditMembers && (
<MoreMenu>
Expand Down
Loading