Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
import type { RouterOutputs } from "@/utils/api";
import { DnsHelperModal } from "./dns-helper-modal";
import { AddDomain } from "./handle-domain";
import type { ValidationStates } from "./show-domains";
import type { features, ValidationStates } from "./show-domains";

export type Domain =
| RouterOutputs["domain"]["byApplicationId"][0]
Expand Down Expand Up @@ -56,7 +56,7 @@ export const createColumns = ({
serverIp,
canCreateDomain,
canDeleteDomain,
}: ColumnsProps): ColumnDef<Domain>[] => [
}: ColumnsProps): ColumnDef<typeof features, Domain>[] => [
...(type === "compose"
? [
{
Expand All @@ -72,7 +72,7 @@ export const createColumns = ({
</Badge>
);
},
} satisfies ColumnDef<Domain>,
} satisfies ColumnDef<typeof features, Domain>,
]
: []),
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
import {
type ColumnFiltersState,
type ColumnVisibilityState,
columnFilteringFeature,
columnVisibilityFeature,
createFilteredRowModel,
createPaginatedRowModel,
createSortedRowModel,
filterFn_equals,
filterFn_includesString,
flexRender,
getCoreRowModel,
getFilteredRowModel,
getPaginationRowModel,
getSortedRowModel,
rowPaginationFeature,
rowSelectionFeature,
rowSortingFeature,
type SortingState,
useReactTable,
type VisibilityState,
sortFn_alphanumeric,
sortFn_datetime,
sortFn_text,
tableFeatures,
useTable,
} from "@tanstack/react-table";
import {
CheckCircle2,
Expand Down Expand Up @@ -67,6 +77,26 @@ import { AddDomain } from "./handle-domain";
import { HandleForwardAuth } from "./handle-forward-auth";
import { COMPOSE_REDEPLOY_TOAST, ComposeRedeployAlert } from "./redeploy-hint";

export const features = tableFeatures({
columnFilteringFeature,
rowSortingFeature,
rowPaginationFeature,
columnVisibilityFeature,
rowSelectionFeature,
filteredRowModel: createFilteredRowModel(),
sortedRowModel: createSortedRowModel(),
paginatedRowModel: createPaginatedRowModel(),
filterFns: {
equals: filterFn_equals,
includesString: filterFn_includesString,
},
sortFns: {
alphanumeric: sortFn_alphanumeric,
datetime: sortFn_datetime,
text: sortFn_text,
},
});

export type ValidationState = {
isLoading: boolean;
isValid?: boolean;
Expand Down Expand Up @@ -119,7 +149,8 @@ export const ShowDomains = ({ id, type }: Props) => {
});
const [sorting, setSorting] = useState<SortingState>([]);
const [columnFilters, setColumnFilters] = useState<ColumnFiltersState>([]);
const [columnVisibility, setColumnVisibility] = useState<VisibilityState>({});
const [columnVisibility, setColumnVisibility] =
useState<ColumnVisibilityState>({});
const [rowSelection, setRowSelection] = useState({});
const { data: ip } = api.settings.getIp.useQuery();

Expand Down Expand Up @@ -232,15 +263,12 @@ export const ShowDomains = ({ id, type }: Props) => {
canDeleteDomain,
});

const table = useReactTable({
const table = useTable({
features,
data: data ?? [],
columns,
onSortingChange: setSorting,
onColumnFiltersChange: setColumnFilters,
getCoreRowModel: getCoreRowModel(),
getPaginationRowModel: getPaginationRowModel(),
getSortedRowModel: getSortedRowModel(),
getFilteredRowModel: getFilteredRowModel(),
onColumnVisibilityChange: setColumnVisibility,
onRowSelectionChange: setRowSelection,
state: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
"use client";

import {
columnVisibilityFeature,
createPaginatedRowModel,
createSortedRowModel,
flexRender,
getCoreRowModel,
getPaginationRowModel,
getSortedRowModel,
type PaginationState,
rowPaginationFeature,
rowSortingFeature,
type SortingState,
useReactTable,
sortFn_alphanumeric,
sortFn_datetime,
sortFn_text,
tableFeatures,
useTable,
} from "@tanstack/react-table";
import type { inferRouterOutputs } from "@trpc/server";
import {
Expand Down Expand Up @@ -43,6 +49,19 @@ import {
import type { AppRouter } from "@/server/api/root";
import { api } from "@/utils/api";

const features = tableFeatures({
rowSortingFeature,
rowPaginationFeature,
columnVisibilityFeature,
sortedRowModel: createSortedRowModel(),
paginatedRowModel: createPaginatedRowModel(),
sortFns: {
alphanumeric: sortFn_alphanumeric,
datetime: sortFn_datetime,
text: sortFn_text,
},
});

type DeploymentRow =
inferRouterOutputs<AppRouter>["deployment"]["allCentralized"][number];

Expand Down Expand Up @@ -445,7 +464,8 @@ export function ShowDeploymentsTable({
[],
);

const table = useReactTable({
const table = useTable({
features,
data: filteredData,
columns,
state: {
Expand All @@ -454,9 +474,6 @@ export function ShowDeploymentsTable({
},
onSortingChange: setSorting,
onPaginationChange: setPagination,
getCoreRowModel: getCoreRowModel(),
getSortedRowModel: getSortedRowModel(),
getPaginationRowModel: getPaginationRowModel(),
});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@

import {
type ColumnDef,
columnVisibilityFeature,
createPaginatedRowModel,
createSortedRowModel,
flexRender,
getCoreRowModel,
getPaginationRowModel,
getSortedRowModel,
type PaginationState,
rowPaginationFeature,
rowSortingFeature,
type SortingState,
useReactTable,
sortFn_alphanumeric,
sortFn_datetime,
sortFn_text,
tableFeatures,
useTable,
} from "@tanstack/react-table";
import type { inferRouterOutputs } from "@trpc/server";
import {
Expand Down Expand Up @@ -46,6 +52,19 @@ import {
import type { AppRouter } from "@/server/api/root";
import { api } from "@/utils/api";

const features = tableFeatures({
rowSortingFeature,
rowPaginationFeature,
columnVisibilityFeature,
sortedRowModel: createSortedRowModel(),
paginatedRowModel: createPaginatedRowModel(),
sortFns: {
alphanumeric: sortFn_alphanumeric,
datetime: sortFn_datetime,
text: sortFn_text,
},
});

type DiskUsageItem =
inferRouterOutputs<AppRouter>["dockerDiskUsage"]["getDiskUsage"][number];
type BuildCacheBase =
Expand Down Expand Up @@ -176,7 +195,7 @@ export const ShowDiskUsage = ({ serverId }: Props) => {
}
};

const columns = useMemo<ColumnDef<BuildCacheRow>[]>(
const columns = useMemo<ColumnDef<typeof features, BuildCacheRow>[]>(
() => [
{
accessorKey: "id",
Expand Down Expand Up @@ -263,7 +282,8 @@ export const ShowDiskUsage = ({ serverId }: Props) => {
[],
);

const table = useReactTable({
const table = useTable({
features,
data: filteredData,
columns,
getRowId: (row) => row.key,
Expand All @@ -273,9 +293,6 @@ export const ShowDiskUsage = ({ serverId }: Props) => {
},
onSortingChange: setSorting,
onPaginationChange: setPagination,
getCoreRowModel: getCoreRowModel(),
getSortedRowModel: getSortedRowModel(),
getPaginationRowModel: getPaginationRowModel(),
});

return (
Expand Down Expand Up @@ -395,7 +412,7 @@ export const ShowDiskUsage = ({ serverId }: Props) => {
{table.getPageCount() > 1 && (
<div className="flex items-center justify-end gap-4">
<span className="text-sm text-muted-foreground">
Page {table.getState().pagination.pageIndex + 1} of{" "}
Page {table.state.pagination.pageIndex + 1} of{" "}
{table.getPageCount()}
</span>
<div className="flex gap-2">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import {
type ColumnDef,
columnVisibilityFeature,
createPaginatedRowModel,
createSortedRowModel,
flexRender,
getCoreRowModel,
getPaginationRowModel,
getSortedRowModel,
type PaginationState,
rowPaginationFeature,
rowSortingFeature,
type SortingState,
useReactTable,
sortFn_alphanumeric,
sortFn_datetime,
sortFn_text,
tableFeatures,
useTable,
} from "@tanstack/react-table";
import { Activity, ArrowUpDown, Loader2, RefreshCw } from "lucide-react";
import { useMemo, useState } from "react";
Expand Down Expand Up @@ -37,6 +43,19 @@ import {
} from "@/components/ui/table";
import { api, type RouterOutputs } from "@/utils/api";

const features = tableFeatures({
rowSortingFeature,
rowPaginationFeature,
columnVisibilityFeature,
sortedRowModel: createSortedRowModel(),
paginatedRowModel: createPaginatedRowModel(),
sortFns: {
alphanumeric: sortFn_alphanumeric,
datetime: sortFn_datetime,
text: sortFn_text,
},
});

interface Props {
serverId?: string;
}
Expand Down Expand Up @@ -153,7 +172,7 @@ export const ShowDockerEvents = ({ serverId }: Props) => {
});
}, [events, search]);

const columns = useMemo<ColumnDef<EventRow>[]>(
const columns = useMemo<ColumnDef<typeof features, EventRow>[]>(
() => [
{
id: "time",
Expand Down Expand Up @@ -228,7 +247,8 @@ export const ShowDockerEvents = ({ serverId }: Props) => {
[],
);

const table = useReactTable({
const table = useTable({
features,
data: filteredEvents,
columns,
getRowId: (row) => row.key,
Expand All @@ -238,9 +258,6 @@ export const ShowDockerEvents = ({ serverId }: Props) => {
},
onSortingChange: setSorting,
onPaginationChange: setPagination,
getCoreRowModel: getCoreRowModel(),
getSortedRowModel: getSortedRowModel(),
getPaginationRowModel: getPaginationRowModel(),
});

return (
Expand Down Expand Up @@ -362,7 +379,7 @@ export const ShowDockerEvents = ({ serverId }: Props) => {
{table.getPageCount() > 1 && (
<div className="flex items-center justify-end gap-4">
<span className="text-sm text-muted-foreground">
Page {table.getState().pagination.pageIndex + 1} of{" "}
Page {table.state.pagination.pageIndex + 1} of{" "}
{table.getPageCount()}
</span>
<div className="flex items-center gap-2">
Expand All @@ -371,8 +388,8 @@ export const ShowDockerEvents = ({ serverId }: Props) => {
type="number"
min={1}
max={table.getPageCount()}
defaultValue={table.getState().pagination.pageIndex + 1}
key={table.getState().pagination.pageIndex}
defaultValue={table.state.pagination.pageIndex + 1}
key={table.state.pagination.pageIndex}
onKeyDown={(e) => {
if (e.key !== "Enter") return;
const value = Number(
Expand Down
Loading