Skip to content

Commit 30ae419

Browse files
committed
feat: disable nat
1 parent 0d27508 commit 30ae419

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

src/components/nat.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import { useTranslation } from "react-i18next"
2929
import { toast } from "sonner"
3030
import { KeyedMutator } from "swr"
3131
import { z } from "zod"
32+
import { Checkbox } from "./ui/checkbox"
33+
import { Label } from "./ui/label"
3234

3335
interface NATCardProps {
3436
data?: ModelNAT
@@ -37,6 +39,7 @@ interface NATCardProps {
3739

3840
const natFormSchema = z.object({
3941
name: z.string().min(1),
42+
enabled: z.boolean(),
4043
server_id: z.coerce.number().int(),
4144
host: z.string(),
4245
domain: z.string(),
@@ -50,6 +53,7 @@ export const NATCard: React.FC<NATCardProps> = ({ data, mutate }) => {
5053
? data
5154
: {
5255
name: "",
56+
enabled: false,
5357
server_id: 0,
5458
host: "",
5559
domain: "",
@@ -148,6 +152,26 @@ export const NATCard: React.FC<NATCardProps> = ({ data, mutate }) => {
148152
</FormItem>
149153
)}
150154
/>
155+
<FormField
156+
control={form.control}
157+
name="enabled"
158+
render={({ field }) => (
159+
<FormItem className="flex items-center space-x-2">
160+
<FormControl>
161+
<div className="flex items-center gap-2">
162+
<Checkbox
163+
checked={field.value}
164+
onCheckedChange={field.onChange}
165+
/>
166+
<Label className="text-sm">
167+
{t("Enable")}
168+
</Label>
169+
</div>
170+
</FormControl>
171+
<FormMessage />
172+
</FormItem>
173+
)}
174+
/>
151175
<DialogFooter className="justify-end">
152176
<DialogClose asChild>
153177
<Button type="button" className="my-2" variant="secondary">

src/routes/nat.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ export default function NATPage() {
6161
accessorKey: "id",
6262
accessorFn: (row) => row.id,
6363
},
64+
{
65+
header: t("Enabled"),
66+
accessorKey: "enabled",
67+
accessorFn: (row) => row.enabled,
68+
},
6469
{
6570
header: t("Name"),
6671
accessorKey: "name",

src/types/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ export interface ModelLoginResponse {
401401
export interface ModelNAT {
402402
created_at: string
403403
domain: string
404+
enabled: boolean
404405
host: string
405406
id: number
406407
name: string

0 commit comments

Comments
 (0)