fix(record): comment field not display
This commit is contained in:
@@ -109,6 +109,10 @@ pnpm db:push
|
||||
|
||||
Follow https://localhost:3000/setup
|
||||
|
||||
## Environment Variables
|
||||
|
||||
查看 [开发者文档](https://wr.do/docs/developer).
|
||||
|
||||
## 社区群组
|
||||
|
||||
- Discord: https://discord.gg/AHPQYuZu3m
|
||||
|
||||
@@ -119,6 +119,10 @@ pnpm db:push
|
||||
|
||||
Follow https://localhost:3000/setup
|
||||
|
||||
## Environment Variables
|
||||
|
||||
Via [Installation For Developer](https://wr.do/docs/developer).
|
||||
|
||||
## Community Group
|
||||
|
||||
- Discord: https://discord.gg/AHPQYuZu3m
|
||||
|
||||
@@ -40,10 +40,7 @@ import {
|
||||
import { FormType, RecordForm } from "@/components/forms/record-form";
|
||||
import { EmptyPlaceholder } from "@/components/shared/empty-placeholder";
|
||||
import { Icons } from "@/components/shared/icons";
|
||||
import {
|
||||
LinkInfoPreviewer,
|
||||
LinkPreviewer,
|
||||
} from "@/components/shared/link-previewer";
|
||||
import { LinkInfoPreviewer } from "@/components/shared/link-previewer";
|
||||
import { PaginationWrapper } from "@/components/shared/pagination";
|
||||
|
||||
export interface RecordListProps {
|
||||
@@ -53,7 +50,7 @@ export interface RecordListProps {
|
||||
|
||||
function TableColumnSekleton() {
|
||||
return (
|
||||
<TableRow className="grid grid-cols-3 items-center sm:grid-cols-8">
|
||||
<TableRow className="grid grid-cols-3 items-center sm:grid-cols-9">
|
||||
<TableCell className="col-span-1">
|
||||
<Skeleton className="h-5 w-24" />
|
||||
</TableCell>
|
||||
@@ -72,6 +69,9 @@ function TableColumnSekleton() {
|
||||
<TableCell className="col-span-1 hidden justify-center sm:flex">
|
||||
<Skeleton className="h-5 w-16" />
|
||||
</TableCell>
|
||||
<TableCell className="col-span-1 hidden justify-center sm:flex">
|
||||
<Skeleton className="h-5 w-16" />
|
||||
</TableCell>
|
||||
<TableCell className="col-span-1 flex justify-center">
|
||||
<Skeleton className="h-5 w-16" />
|
||||
</TableCell>
|
||||
@@ -92,7 +92,7 @@ export default function UserRecordsList({ user, action }: RecordListProps) {
|
||||
|
||||
const { mutate } = useSWRConfig();
|
||||
|
||||
const { data, error, isLoading } = useSWR<{
|
||||
const { data, isLoading } = useSWR<{
|
||||
total: number;
|
||||
list: UserRecordFormData[];
|
||||
}>(`${action}?page=${currentPage}&size=${pageSize}`, fetcher, {
|
||||
@@ -109,7 +109,7 @@ export default function UserRecordsList({ user, action }: RecordListProps) {
|
||||
setChecked: (value: boolean) => void,
|
||||
) => {
|
||||
const originalState = record.active === 1;
|
||||
setChecked(checked); // 立即更新 UI
|
||||
setChecked(checked);
|
||||
|
||||
const res = await fetch(`/api/record/update`, {
|
||||
method: "PUT",
|
||||
@@ -201,7 +201,7 @@ export default function UserRecordsList({ user, action }: RecordListProps) {
|
||||
<CardContent>
|
||||
<Table>
|
||||
<TableHeader className="bg-gray-100/50 dark:bg-primary-foreground">
|
||||
<TableRow className="grid grid-cols-3 items-center sm:grid-cols-8">
|
||||
<TableRow className="grid grid-cols-3 items-center sm:grid-cols-9">
|
||||
<TableHead className="col-span-1 flex items-center font-bold">
|
||||
Type
|
||||
</TableHead>
|
||||
@@ -217,6 +217,9 @@ export default function UserRecordsList({ user, action }: RecordListProps) {
|
||||
<TableHead className="col-span-1 hidden items-center justify-center font-bold sm:flex">
|
||||
Status
|
||||
</TableHead>
|
||||
<TableHead className="col-span-1 hidden items-center font-bold sm:flex">
|
||||
User
|
||||
</TableHead>
|
||||
<TableHead className="col-span-1 hidden items-center justify-center font-bold sm:flex">
|
||||
Updated
|
||||
</TableHead>
|
||||
@@ -238,7 +241,7 @@ export default function UserRecordsList({ user, action }: RecordListProps) {
|
||||
data.list.map((record) => (
|
||||
<TableRow
|
||||
key={record.id}
|
||||
className="grid animate-fade-in grid-cols-3 items-center animate-in sm:grid-cols-8"
|
||||
className="grid animate-fade-in grid-cols-3 items-center animate-in sm:grid-cols-9"
|
||||
>
|
||||
<TableCell className="col-span-1">
|
||||
<Badge className="text-xs" variant="outline">
|
||||
@@ -316,6 +319,18 @@ export default function UserRecordsList({ user, action }: RecordListProps) {
|
||||
</TooltipProvider>
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell className="col-span-1 hidden truncate sm:flex">
|
||||
<TooltipProvider>
|
||||
<Tooltip delayDuration={200}>
|
||||
<TooltipTrigger className="truncate">
|
||||
{record.user.name ?? record.user.email}
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
{record.user.name ?? record.user.email}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
</TableCell>
|
||||
<TableCell className="col-span-1 hidden justify-center sm:flex">
|
||||
{timeAgo(record.modified_on as unknown as Date)}
|
||||
</TableCell>
|
||||
|
||||
@@ -103,25 +103,28 @@ export function RecordForm({
|
||||
});
|
||||
|
||||
const handleCreateRecord = async (data: CreateDNSRecord) => {
|
||||
startTransition(async () => {
|
||||
const response = await fetch(`${action}/add`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
records: [data],
|
||||
email,
|
||||
}),
|
||||
});
|
||||
|
||||
if (!response.ok || response.status !== 200) {
|
||||
toast.error("Created Failed!", {
|
||||
description: await response.text(),
|
||||
if (siteConfig.enableSubdomainApply && data.comment!.length < 20) {
|
||||
toast.warning("Apply reason must be at least 20 characters!");
|
||||
} else {
|
||||
startTransition(async () => {
|
||||
const response = await fetch(`${action}/add`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
records: [data],
|
||||
email,
|
||||
}),
|
||||
});
|
||||
} else {
|
||||
toast.success(`Created successfully!`);
|
||||
setShowForm(false);
|
||||
onRefresh();
|
||||
}
|
||||
});
|
||||
if (!response.ok || response.status !== 200) {
|
||||
toast.error("Created Failed!", {
|
||||
description: await response.text(),
|
||||
});
|
||||
} else {
|
||||
toast.success(`Created successfully!`);
|
||||
setShowForm(false);
|
||||
onRefresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleUpdateRecord = async (data: CreateDNSRecord) => {
|
||||
@@ -203,7 +206,6 @@ export function RecordForm({
|
||||
<div className="rounded-t-lg bg-muted px-4 py-2 text-lg font-semibold">
|
||||
{type === "add" ? "Create" : "Edit"} record
|
||||
</div>
|
||||
|
||||
{siteConfig.enableSubdomainApply && (
|
||||
<ul className="m-2 list-disc gap-1 rounded-md bg-yellow-600/10 p-2 px-5 pr-2 text-xs font-medium text-yellow-600 dark:bg-yellow-500/10 dark:text-yellow-500">
|
||||
<li>The administrator has enabled application mode.</li>
|
||||
@@ -213,7 +215,6 @@ export function RecordForm({
|
||||
</li>
|
||||
</ul>
|
||||
)}
|
||||
|
||||
<form className="p-4" onSubmit={onSubmit}>
|
||||
{isAdmin && (
|
||||
<div className="items-center justify-start gap-4 md:flex">
|
||||
@@ -245,7 +246,7 @@ export function RecordForm({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{siteConfig.enableSubdomainApply && initData?.active === 2 && (
|
||||
{siteConfig.enableSubdomainApply && (
|
||||
<FormSectionColumns
|
||||
title="What are you planning to use the subdomain for?"
|
||||
required
|
||||
@@ -266,7 +267,6 @@ export function RecordForm({
|
||||
</p>
|
||||
</FormSectionColumns>
|
||||
)}
|
||||
|
||||
<div className="items-center justify-start gap-4 md:flex">
|
||||
<FormSectionColumns title="Domain" required>
|
||||
{isLoading ? (
|
||||
@@ -326,7 +326,6 @@ export function RecordForm({
|
||||
<p className="p-1 text-[13px] text-muted-foreground">Required.</p>
|
||||
</FormSectionColumns>
|
||||
</div>
|
||||
|
||||
<div className="items-center justify-start gap-4 md:flex">
|
||||
<FormSectionColumns title="Name" required>
|
||||
<div className="flex w-full items-center gap-2">
|
||||
@@ -398,7 +397,6 @@ export function RecordForm({
|
||||
</div>
|
||||
</FormSectionColumns>
|
||||
</div>
|
||||
|
||||
<div className="items-center justify-start gap-4 md:flex">
|
||||
<FormSectionColumns title="TTL" required>
|
||||
<Select
|
||||
@@ -441,7 +439,6 @@ export function RecordForm({
|
||||
</FormSectionColumns>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Action buttons */}
|
||||
<div className="mt-3 flex justify-end gap-3">
|
||||
{type === "edit" && (
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use server";
|
||||
|
||||
import { UserRole } from "@prisma/client";
|
||||
import { User, UserRole } from "@prisma/client";
|
||||
|
||||
import { prisma } from "@/lib/db";
|
||||
import {
|
||||
@@ -25,6 +25,7 @@ export type UserRecordFormData = {
|
||||
created_on?: string;
|
||||
modified_on?: string;
|
||||
active: number; // 0: inactive, 1: active, 2: pending
|
||||
user: Pick<User, "name" | "email">;
|
||||
};
|
||||
|
||||
export async function createUserRecord(
|
||||
@@ -157,6 +158,30 @@ export async function getUserRecords(
|
||||
where: option,
|
||||
skip: (page - 1) * size,
|
||||
take: size,
|
||||
select: {
|
||||
id: true,
|
||||
record_id: true,
|
||||
zone_id: true,
|
||||
zone_name: true,
|
||||
name: true,
|
||||
type: true,
|
||||
content: true,
|
||||
ttl: true,
|
||||
proxied: true,
|
||||
proxiable: true,
|
||||
comment: true,
|
||||
tags: true,
|
||||
created_on: true,
|
||||
modified_on: true,
|
||||
active: true,
|
||||
userId: true,
|
||||
user: {
|
||||
select: {
|
||||
name: true,
|
||||
email: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
orderBy: {
|
||||
modified_on: "desc",
|
||||
},
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user