diff --git a/messages/en-US.json b/messages/en-US.json index c2ae4f42b..a57d623fc 100644 --- a/messages/en-US.json +++ b/messages/en-US.json @@ -3742,9 +3742,8 @@ "howToAddRecords": "How to Add Records", "dnsRecord": "DNS Records", "customDnsRecords": "Custom DNS Records", - "customDnsRecordsDescription": "Additional records served by Pangolin's nameservers for this domain.", "customDnsRecordsAdd": "Add Record", - "customDnsRecordsEmpty": "No custom DNS records yet.", + "customDnsRecordsSearch": "Search records...", "customDnsRecordCreate": "Add DNS Record", "customDnsRecordEdit": "Edit DNS Record", "customDnsRecordFormDescription": "This record will be served for {domain}. Changes may take a few minutes to propagate.", diff --git a/src/components/CustomDnsRecordsTable.tsx b/src/components/CustomDnsRecordsTable.tsx index ec650451c..07969f2f9 100644 --- a/src/components/CustomDnsRecordsTable.tsx +++ b/src/components/CustomDnsRecordsTable.tsx @@ -3,24 +3,17 @@ import { useQuery } from "@tanstack/react-query"; import { useState } from "react"; import { useTranslations } from "next-intl"; -import { Pencil, Plus, Trash2 } from "lucide-react"; -import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow -} from "@app/components/ui/table"; -import { - Card, - CardContent, - CardDescription, - CardHeader, - CardTitle -} from "@app/components/ui/card"; +import { ArrowUpDown, MoreHorizontal } from "lucide-react"; +import { DataTable, ExtendedColumnDef } from "@app/components/ui/data-table"; import { Button } from "@app/components/ui/button"; +import { Badge } from "@app/components/ui/badge"; import { Switch } from "@app/components/ui/switch"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger +} from "@app/components/ui/dropdown-menu"; import CopyToClipboard from "@app/components/CopyToClipboard"; import ConfirmDeleteDialog from "@app/components/ConfirmDeleteDialog"; import CustomDnsRecordCredenza from "@app/components/CustomDnsRecordCredenza"; @@ -59,9 +52,11 @@ export default function CustomDnsRecordsTable({ const { isPaidUser } = usePaidStatus(); const isDisabled = !isPaidUser(tierMatrix.customDnsRecords); - const { data: records = [], refetch } = useQuery( - domainQueries.listCustomDnsRecords({ orgId, domainId }) - ); + const { + data: records = [], + isRefetching, + refetch + } = useQuery(domainQueries.listCustomDnsRecords({ orgId, domainId })); const [editorOpen, setEditorOpen] = useState(false); const [editingRecord, setEditingRecord] = @@ -112,122 +107,148 @@ export default function CustomDnsRecordsTable({ } } + const columns: ExtendedColumnDef[] = [ + { + accessorKey: "fullDomain", + enableHiding: false, + friendlyName: t("name"), + header: ({ column }) => { + return ( + + ); + }, + cell: ({ row }) => { + const fullDomain = row.original.fullDomain; + return ( + + ); + } + }, + { + accessorKey: "type", + friendlyName: t("type"), + header: ({ column }) => { + return ( + + ); + }, + cell: ({ row }) => { + return {row.original.type}; + } + }, + { + accessorKey: "value", + friendlyName: t("value"), + header: () => {t("value")}, + cell: ({ row }) => { + return ( + + {formatValue(row.original)} + + ); + } + }, + { + accessorKey: "ttl", + friendlyName: t("TTL"), + header: ({ column }) => { + return ( + + ); + } + }, + { + accessorKey: "enabled", + friendlyName: t("enabled"), + header: () => {t("enabled")}, + cell: ({ row }) => { + const record = row.original; + return ( + + toggleEnabled(record, checked) + } + /> + ); + } + }, + { + id: "actions", + enableHiding: false, + header: () => , + cell: ({ row }) => { + const record = row.original; + return ( +
+ + + + + + { + setDeletingRecord(record); + setDeleteOpen(true); + }} + > + + {t("delete")} + + + + + +
+ ); + } + } + ]; + return ( <> - - -
- {t("customDnsRecords")} - - {t("customDnsRecordsDescription")} - -
- -
- - - - - {t("name")} - {t("type")} - {t("value")} - {t("TTL")} - {t("enabled")} - - {t("actions")} - - - - - {records.length ? ( - records.map((record) => ( - - - - - {record.type} - - {formatValue(record)} - - {record.ttl} - - - toggleEnabled( - record, - checked - ) - } - /> - - - - - - - )) - ) : ( - - - {t("customDnsRecordsEmpty")} - - - )} - -
-
-
- - refetch()} - /> {deletingRecord && !isDisabled && ( )} + + refetch()} + /> + + openEditor(null)} + addButtonDisabled={isDisabled} + onRefresh={refetch} + isRefreshing={isRefetching} + enableColumnVisibility={true} + stickyLeftColumn="fullDomain" + stickyRightColumn="actions" + /> ); }