Skip to content

Commit eb79b33

Browse files
committed
chore: migrate to shadcn table
1 parent e2cdf22 commit eb79b33

File tree

1 file changed

+66
-66
lines changed

1 file changed

+66
-66
lines changed

site/src/pages/OrganizationSettingsPage/CustomRolesPage/CustomRolesPageView.tsx

Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@ import AddIcon from "@mui/icons-material/AddOutlined";
33
import AddOutlined from "@mui/icons-material/AddOutlined";
44
import Button from "@mui/material/Button";
55
import Skeleton from "@mui/material/Skeleton";
6-
import Table from "@mui/material/Table";
7-
import TableBody from "@mui/material/TableBody";
8-
import TableCell from "@mui/material/TableCell";
9-
import TableContainer from "@mui/material/TableContainer";
10-
import TableHead from "@mui/material/TableHead";
11-
import TableRow from "@mui/material/TableRow";
126
import type { AssignableRoles, Role } from "api/typesGenerated";
137
import { ChooseOne, Cond } from "components/Conditionals/ChooseOne";
148
import { EmptyState } from "components/EmptyState/EmptyState";
@@ -21,6 +15,14 @@ import {
2115
} from "components/MoreMenu/MoreMenu";
2216
import { Paywall } from "components/Paywall/Paywall";
2317
import { Stack } from "components/Stack/Stack";
18+
import {
19+
Table,
20+
TableBody,
21+
TableCell,
22+
TableHead,
23+
TableHeader,
24+
TableRow,
25+
} from "components/Table/Table";
2426
import {
2527
TableLoaderSkeleton,
2628
TableRowSkeleton,
@@ -123,68 +125,66 @@ const RoleTable: FC<RoleTableProps> = ({
123125
const isLoading = roles === undefined;
124126
const isEmpty = Boolean(roles && roles.length === 0);
125127
return (
126-
<TableContainer>
127-
<Table>
128-
<TableHead>
129-
<TableRow>
130-
<TableCell width="40%">Name</TableCell>
131-
<TableCell width="59%">Permissions</TableCell>
132-
<TableCell width="1%" />
133-
</TableRow>
134-
</TableHead>
135-
<TableBody>
136-
<ChooseOne>
137-
<Cond condition={isLoading}>
138-
<TableLoader />
139-
</Cond>
128+
<Table>
129+
<TableHeader>
130+
<TableRow>
131+
<TableHead className="w-2/5">Name</TableHead>
132+
<TableHead className="w-3/5">Permissions</TableHead>
133+
<TableHead className="w-auto" />
134+
</TableRow>
135+
</TableHeader>
136+
<TableBody>
137+
<ChooseOne>
138+
<Cond condition={isLoading}>
139+
<TableLoader />
140+
</Cond>
140141

141-
<Cond condition={isEmpty}>
142-
<TableRow>
143-
<TableCell colSpan={999}>
144-
<EmptyState
145-
message="No custom roles yet"
146-
description={
147-
canCreateOrgRole && isCustomRolesEnabled
148-
? "Create your first custom role"
149-
: !isCustomRolesEnabled
150-
? "Upgrade to a premium license to create a custom role"
151-
: "You don't have permission to create a custom role"
152-
}
153-
cta={
154-
canCreateOrgRole &&
155-
isCustomRolesEnabled && (
156-
<Button
157-
component={RouterLink}
158-
to="create"
159-
startIcon={<AddOutlined />}
160-
variant="contained"
161-
>
162-
Create custom role
163-
</Button>
164-
)
165-
}
166-
/>
167-
</TableCell>
168-
</TableRow>
169-
</Cond>
142+
<Cond condition={isEmpty}>
143+
<TableRow>
144+
<TableCell colSpan={999}>
145+
<EmptyState
146+
message="No custom roles yet"
147+
description={
148+
canCreateOrgRole && isCustomRolesEnabled
149+
? "Create your first custom role"
150+
: !isCustomRolesEnabled
151+
? "Upgrade to a premium license to create a custom role"
152+
: "You don't have permission to create a custom role"
153+
}
154+
cta={
155+
canCreateOrgRole &&
156+
isCustomRolesEnabled && (
157+
<Button
158+
component={RouterLink}
159+
to="create"
160+
startIcon={<AddOutlined />}
161+
variant="contained"
162+
>
163+
Create custom role
164+
</Button>
165+
)
166+
}
167+
/>
168+
</TableCell>
169+
</TableRow>
170+
</Cond>
170171

171-
<Cond>
172-
{roles
173-
?.sort((a, b) => a.name.localeCompare(b.name))
174-
.map((role) => (
175-
<RoleRow
176-
key={role.name}
177-
role={role}
178-
canUpdateOrgRole={canUpdateOrgRole}
179-
canDeleteOrgRole={canDeleteOrgRole}
180-
onDelete={() => onDeleteRole(role)}
181-
/>
182-
))}
183-
</Cond>
184-
</ChooseOne>
185-
</TableBody>
186-
</Table>
187-
</TableContainer>
172+
<Cond>
173+
{roles
174+
?.sort((a, b) => a.name.localeCompare(b.name))
175+
.map((role) => (
176+
<RoleRow
177+
key={role.name}
178+
role={role}
179+
canUpdateOrgRole={canUpdateOrgRole}
180+
canDeleteOrgRole={canDeleteOrgRole}
181+
onDelete={() => onDeleteRole(role)}
182+
/>
183+
))}
184+
</Cond>
185+
</ChooseOne>
186+
</TableBody>
187+
</Table>
188188
);
189189
};
190190

0 commit comments

Comments
 (0)