feat: batch set server config (#114)

* feat: batch set server config

* make every field optional

* chore: auto-fix linting and formatting issues

* update

* [WIP] improve batch edit ux

* chore: auto-fix linting and formatting issues
This commit is contained in:
UUBulb authored and GitHub committed 2025-02-04 11:19:52 +08:00
1 parent 70b8f39bd6
commit a52bf64779
10 files changed
+349 -77

No files matched your search

+5
View File
@@ -10,6 +10,7 @@ import {
Expand,
FolderClosed,
Menu,
Minus,
Play,
Plus,
Terminal,
@@ -35,6 +36,7 @@ export interface IconButtonProps extends ButtonProps {
| "ban"
| "expand"
| "cog"
| "minus"
}
export const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>((props, ref) => {
@@ -92,6 +94,9 @@ export const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>((props,
case "cog": {
return <CogIcon />
}
case "minus": {
return <Minus />
}
}
})()}
</Button>
+50
View File
@@ -0,0 +1,50 @@
"use client"
import { useState } from "react"
import { Label } from "../ui/label"
import { Textarea } from "../ui/textarea"
import { IconButton } from "./icon-button"
interface PusherProps {
property: [string, string]
setData: React.Dispatch<React.SetStateAction<Record<string, any>>>
}
export const Pusher: React.FC<PusherProps> = ({ property, setData }) => {
const [cData, setCData] = useState<Record<string, any>>({})
return (
<div className="flex flex-col gap-3">
<div className="flex gap-2 ml-auto">
<IconButton
icon="plus"
onClick={() => {
const [k, v] = property
if (k && v) {
const temp = { ...cData }
temp[k] = JSON.parse(v)
setCData(temp)
setData(cData)
}
}}
/>
<IconButton
icon="minus"
variant="destructive"
onClick={() => {
const [k] = property
if (k) {
const temp = { ...cData }
temp[k] = undefined
setCData(temp)
setData(cData)
}
}}
/>
</div>
<Label>Preview</Label>
<Textarea value={JSON.stringify(cData, null, 2)} readOnly />
</div>
)
}