Skip to content

Commit

Permalink
feat: disable nat
Browse files Browse the repository at this point in the history
  • Loading branch information
naiba committed Jan 21, 2025
1 parent 0d27508 commit 30ae419
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/components/nat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import { useTranslation } from "react-i18next"
import { toast } from "sonner"
import { KeyedMutator } from "swr"
import { z } from "zod"
import { Checkbox } from "./ui/checkbox"
import { Label } from "./ui/label"

interface NATCardProps {
data?: ModelNAT
Expand All @@ -37,6 +39,7 @@ interface NATCardProps {

const natFormSchema = z.object({
name: z.string().min(1),
enabled: z.boolean(),
server_id: z.coerce.number().int(),
host: z.string(),
domain: z.string(),
Expand All @@ -50,6 +53,7 @@ export const NATCard: React.FC<NATCardProps> = ({ data, mutate }) => {
? data
: {
name: "",
enabled: false,
server_id: 0,
host: "",
domain: "",
Expand Down Expand Up @@ -148,6 +152,26 @@ export const NATCard: React.FC<NATCardProps> = ({ data, mutate }) => {
</FormItem>
)}
/>
<FormField
control={form.control}
name="enabled"
render={({ field }) => (
<FormItem className="flex items-center space-x-2">
<FormControl>
<div className="flex items-center gap-2">
<Checkbox
checked={field.value}
onCheckedChange={field.onChange}
/>
<Label className="text-sm">
{t("Enable")}
</Label>
</div>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<DialogFooter className="justify-end">
<DialogClose asChild>
<Button type="button" className="my-2" variant="secondary">
Expand Down
5 changes: 5 additions & 0 deletions src/routes/nat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ export default function NATPage() {
accessorKey: "id",
accessorFn: (row) => row.id,
},
{
header: t("Enabled"),
accessorKey: "enabled",
accessorFn: (row) => row.enabled,
},
{
header: t("Name"),
accessorKey: "name",
Expand Down
1 change: 1 addition & 0 deletions src/types/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ export interface ModelLoginResponse {
export interface ModelNAT {
created_at: string
domain: string
enabled: boolean
host: string
id: number
name: string
Expand Down

0 comments on commit 30ae419

Please sign in to comment.