Skip to content

refactor: use the new Table component for the Templates table #17838

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 1 commit into from
May 14, 2025
Merged
Changes from all commits
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
80 changes: 41 additions & 39 deletions site/src/pages/TemplatesPage/TemplatesPageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ import type { Interpolation, Theme } from "@emotion/react";
import ArrowForwardOutlined from "@mui/icons-material/ArrowForwardOutlined";
import MuiButton 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 { hasError, isApiValidationError } from "api/errors";
import type { Template, TemplateExample } from "api/typesGenerated";
import { ErrorAlert } from "components/Alert/ErrorAlert";
Expand All @@ -33,6 +27,14 @@ import {
PageHeaderTitle,
} from "components/PageHeader/PageHeader";
import { Stack } from "components/Stack/Stack";
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "components/Table/Table";
import {
TableLoaderSkeleton,
TableRowSkeleton,
Expand Down Expand Up @@ -231,41 +233,41 @@ export const TemplatesPageView: FC<TemplatesPageViewProps> = ({
<ErrorAlert error={error} />
)}

<TableContainer>
<Table>
<TableHead>
<TableRow>
<TableCell width="35%">{Language.nameLabel}</TableCell>
<TableCell width="15%">
{showOrganizations ? "Organization" : Language.usedByLabel}
</TableCell>
<TableCell width="10%">{Language.buildTimeLabel}</TableCell>
<TableCell width="15%">{Language.lastUpdatedLabel}</TableCell>
<TableCell width="1%" />
</TableRow>
</TableHead>
<TableBody>
{isLoading && <TableLoader />}
<Table>
<TableHeader>
<TableRow>
<TableHead className="w-[35%]">{Language.nameLabel}</TableHead>
<TableHead className="w-[15%]">
{showOrganizations ? "Organization" : Language.usedByLabel}
</TableHead>
<TableHead className="w-[10%]">{Language.buildTimeLabel}</TableHead>
<TableHead className="w-[15%]">
{Language.lastUpdatedLabel}
</TableHead>
<TableHead className="w-[1%]" />
</TableRow>
</TableHeader>
<TableBody>
{isLoading && <TableLoader />}

{isEmpty ? (
<EmptyTemplates
canCreateTemplates={canCreateTemplates}
examples={examples ?? []}
isUsingFilter={filter.used}
{isEmpty ? (
<EmptyTemplates
canCreateTemplates={canCreateTemplates}
examples={examples ?? []}
isUsingFilter={filter.used}
/>
) : (
templates?.map((template) => (
<TemplateRow
key={template.id}
showOrganizations={showOrganizations}
template={template}
workspacePermissions={workspacePermissions}
/>
) : (
templates?.map((template) => (
<TemplateRow
key={template.id}
showOrganizations={showOrganizations}
template={template}
workspacePermissions={workspacePermissions}
/>
))
)}
</TableBody>
</Table>
</TableContainer>
))
)}
</TableBody>
</Table>
</Margins>
);
};
Expand Down
Loading