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
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: migrate to shadcn table
  • Loading branch information
jaaydenh committed Mar 12, 2025
commit eb79b33b3280671bf7c8912c177d8c2e8ca635c3
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ import AddIcon from "@mui/icons-material/AddOutlined";
import AddOutlined from "@mui/icons-material/AddOutlined";
import Button from "@mui/material/Button";
import Skeleton from "@mui/material/Skeleton";
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 { AssignableRoles, Role } from "api/typesGenerated";
import { ChooseOne, Cond } from "components/Conditionals/ChooseOne";
import { EmptyState } from "components/EmptyState/EmptyState";
Expand All @@ -21,6 +15,14 @@ import {
} from "components/MoreMenu/MoreMenu";
import { Paywall } from "components/Paywall/Paywall";
import { Stack } from "components/Stack/Stack";
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "components/Table/Table";
import {
TableLoaderSkeleton,
TableRowSkeleton,
Expand Down Expand Up @@ -123,68 +125,66 @@ const RoleTable: FC<RoleTableProps> = ({
const isLoading = roles === undefined;
const isEmpty = Boolean(roles && roles.length === 0);
return (
<TableContainer>
<Table>
<TableHead>
<TableRow>
<TableCell width="40%">Name</TableCell>
<TableCell width="59%">Permissions</TableCell>
<TableCell width="1%" />
</TableRow>
</TableHead>
<TableBody>
<ChooseOne>
<Cond condition={isLoading}>
<TableLoader />
</Cond>
<Table>
<TableHeader>
<TableRow>
<TableHead className="w-2/5">Name</TableHead>
<TableHead className="w-3/5">Permissions</TableHead>
<TableHead className="w-auto" />
</TableRow>
</TableHeader>
<TableBody>
<ChooseOne>
<Cond condition={isLoading}>
<TableLoader />
</Cond>

<Cond condition={isEmpty}>
<TableRow>
<TableCell colSpan={999}>
<EmptyState
message="No custom roles yet"
description={
canCreateOrgRole && isCustomRolesEnabled
? "Create your first custom role"
: !isCustomRolesEnabled
? "Upgrade to a premium license to create a custom role"
: "You don't have permission to create a custom role"
}
cta={
canCreateOrgRole &&
isCustomRolesEnabled && (
<Button
component={RouterLink}
to="create"
startIcon={<AddOutlined />}
variant="contained"
>
Create custom role
</Button>
)
}
/>
</TableCell>
</TableRow>
</Cond>
<Cond condition={isEmpty}>
<TableRow>
<TableCell colSpan={999}>
<EmptyState
message="No custom roles yet"
description={
canCreateOrgRole && isCustomRolesEnabled
? "Create your first custom role"
: !isCustomRolesEnabled
? "Upgrade to a premium license to create a custom role"
: "You don't have permission to create a custom role"
}
cta={
canCreateOrgRole &&
isCustomRolesEnabled && (
<Button
component={RouterLink}
to="create"
startIcon={<AddOutlined />}
variant="contained"
>
Create custom role
</Button>
)
}
/>
</TableCell>
</TableRow>
</Cond>

<Cond>
{roles
?.sort((a, b) => a.name.localeCompare(b.name))
.map((role) => (
<RoleRow
key={role.name}
role={role}
canUpdateOrgRole={canUpdateOrgRole}
canDeleteOrgRole={canDeleteOrgRole}
onDelete={() => onDeleteRole(role)}
/>
))}
</Cond>
</ChooseOne>
</TableBody>
</Table>
</TableContainer>
<Cond>
{roles
?.sort((a, b) => a.name.localeCompare(b.name))
.map((role) => (
<RoleRow
key={role.name}
role={role}
canUpdateOrgRole={canUpdateOrgRole}
canDeleteOrgRole={canDeleteOrgRole}
onDelete={() => onDeleteRole(role)}
/>
))}
</Cond>
</ChooseOne>
</TableBody>
</Table>
);
};

Expand Down