Skip to content

chore: migrate settings page tables from mui to shadcn #16896

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 8 commits into from
Mar 13, 2025
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
Prev Previous commit
Next Next commit
chore: update users page table to shadcn
  • Loading branch information
jaaydenh committed Mar 12, 2025
commit ecb2f3ce7fd407a656e24735e9a3d66db9b8869f
108 changes: 51 additions & 57 deletions site/src/pages/UsersPage/UsersTable/UsersTable.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import Table from "@mui/material/Table";
import TableBody from "@mui/material/TableBody";
import TableCell from "@mui/material/TableCell";
import TableContainer from "@mui/material/TableContainer";
import TableHead from "@mui/material/TableHead";
import TableRow from "@mui/material/TableRow";
import type { GroupsByUserId } from "api/queries/groups";
import type * as TypesGen from "api/typesGenerated";
import { Stack } from "components/Stack/Stack";
import {
Table,
TableBody,
TableHead,
TableHeader,
TableRow,
} from "components/Table/Table";
import type { FC } from "react";
import { TableColumnHelpTooltip } from "../../OrganizationSettingsPage/UserTable/TableColumnHelpTooltip";
import { UsersTableBody } from "./UsersTableBody";
Expand Down Expand Up @@ -65,57 +66,50 @@ export const UsersTable: FC<UsersTableProps> = ({
groupsByUserId,
}) => {
return (
<TableContainer>
<Table data-testid="users-table">
<TableHead>
<TableRow>
<TableCell width="32%">{Language.usernameLabel}</TableCell>
<Table data-testid="users-table">
<TableHeader>
<TableRow>
<TableHead className="w-2/6">{Language.usernameLabel}</TableHead>
<TableHead className="w-2/6">
<Stack direction="row" spacing={1} alignItems="center">
<span>{Language.rolesLabel}</span>
<TableColumnHelpTooltip variant="roles" />
</Stack>
</TableHead>
<TableHead className="w-1/6">
<Stack direction="row" spacing={1} alignItems="center">
<span>{Language.groupsLabel}</span>
<TableColumnHelpTooltip variant="groups" />
</Stack>
</TableHead>
<TableHead className="w-1/6">{Language.loginTypeLabel}</TableHead>
<TableHead className="w-1/6">{Language.statusLabel}</TableHead>
{canEditUsers && <TableHead className="w-auto" />}
</TableRow>
</TableHeader>

<TableCell width="29%">
<Stack direction="row" spacing={1} alignItems="center">
<span>{Language.rolesLabel}</span>
<TableColumnHelpTooltip variant="roles" />
</Stack>
</TableCell>

<TableCell width="13%">
<Stack direction="row" spacing={1} alignItems="center">
<span>{Language.groupsLabel}</span>
<TableColumnHelpTooltip variant="groups" />
</Stack>
</TableCell>

<TableCell width="13%">{Language.loginTypeLabel}</TableCell>
<TableCell width="13%">{Language.statusLabel}</TableCell>

{/* 1% is a trick to make the table cell width fit the content */}
{canEditUsers && <TableCell width="1%" />}
</TableRow>
</TableHead>

<TableBody>
<UsersTableBody
users={users}
roles={roles}
groupsByUserId={groupsByUserId}
isLoading={isLoading}
canEditUsers={canEditUsers}
canViewActivity={canViewActivity}
isUpdatingUserRoles={isUpdatingUserRoles}
onActivateUser={onActivateUser}
onDeleteUser={onDeleteUser}
onListWorkspaces={onListWorkspaces}
onViewActivity={onViewActivity}
onResetUserPassword={onResetUserPassword}
onSuspendUser={onSuspendUser}
onUpdateUserRoles={onUpdateUserRoles}
isNonInitialPage={isNonInitialPage}
actorID={actorID}
oidcRoleSyncEnabled={oidcRoleSyncEnabled}
authMethods={authMethods}
/>
</TableBody>
</Table>
</TableContainer>
<TableBody>
<UsersTableBody
users={users}
roles={roles}
groupsByUserId={groupsByUserId}
isLoading={isLoading}
canEditUsers={canEditUsers}
canViewActivity={canViewActivity}
isUpdatingUserRoles={isUpdatingUserRoles}
onActivateUser={onActivateUser}
onDeleteUser={onDeleteUser}
onListWorkspaces={onListWorkspaces}
onViewActivity={onViewActivity}
onResetUserPassword={onResetUserPassword}
onSuspendUser={onSuspendUser}
onUpdateUserRoles={onUpdateUserRoles}
isNonInitialPage={isNonInitialPage}
actorID={actorID}
oidcRoleSyncEnabled={oidcRoleSyncEnabled}
authMethods={authMethods}
/>
</TableBody>
</Table>
);
};
6 changes: 4 additions & 2 deletions site/src/pages/UsersPage/UsersTable/UsersTableBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import PasswordOutlined from "@mui/icons-material/PasswordOutlined";
import ShieldOutlined from "@mui/icons-material/ShieldOutlined";
import Divider from "@mui/material/Divider";
import Skeleton from "@mui/material/Skeleton";
import TableCell from "@mui/material/TableCell";
import TableRow from "@mui/material/TableRow";
import type { GroupsByUserId } from "api/queries/groups";
import type * as TypesGen from "api/typesGenerated";
import { AvatarData } from "components/Avatar/AvatarData";
Expand All @@ -23,6 +21,10 @@ import {
MoreMenuTrigger,
ThreeDotsButton,
} from "components/MoreMenu/MoreMenu";
import {
TableCell,
TableRow,
} from "components/Table/Table";
import {
TableLoaderSkeleton,
TableRowSkeleton,
Expand Down