mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-27 16:04:21 +00:00
perf: dynamic and pipeline config ui
This commit is contained in:
@@ -4,7 +4,7 @@ import {
|
|||||||
} from '@/app/infra/entities/form/dynamic';
|
} from '@/app/infra/entities/form/dynamic';
|
||||||
import { Input } from "@/components/ui/input"
|
import { Input } from "@/components/ui/input"
|
||||||
import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "@/components/ui/select"
|
import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "@/components/ui/select"
|
||||||
import { Checkbox } from "@/components/ui/checkbox"
|
import { Switch } from "@/components/ui/switch"
|
||||||
import { ControllerRenderProps } from "react-hook-form";
|
import { ControllerRenderProps } from "react-hook-form";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ export default function DynamicFormItemComponent({
|
|||||||
|
|
||||||
case DynamicFormItemType.BOOLEAN:
|
case DynamicFormItemType.BOOLEAN:
|
||||||
return (
|
return (
|
||||||
<Checkbox
|
<Switch
|
||||||
checked={field.value}
|
checked={field.value}
|
||||||
onCheckedChange={field.onChange}
|
onCheckedChange={field.onChange}
|
||||||
/>
|
/>
|
||||||
@@ -41,8 +41,9 @@ export default function DynamicFormItemComponent({
|
|||||||
return (
|
return (
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
{field.value.map((item: string, index: number) => (
|
{field.value.map((item: string, index: number) => (
|
||||||
<div key={index} className="flex gap-2">
|
<div key={index} className="flex gap-2 items-center">
|
||||||
<Input
|
<Input
|
||||||
|
className="w-[200px]"
|
||||||
value={item}
|
value={item}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
const newValue = [...field.value];
|
const newValue = [...field.value];
|
||||||
@@ -50,15 +51,18 @@ export default function DynamicFormItemComponent({
|
|||||||
field.onChange(newValue);
|
field.onChange(newValue);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Button
|
<button
|
||||||
variant="destructive"
|
type="button"
|
||||||
|
className="p-2 hover:bg-gray-100 rounded"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const newValue = field.value.filter((_: string, i: number) => i !== index);
|
const newValue = field.value.filter((_: string, i: number) => i !== index);
|
||||||
field.onChange(newValue);
|
field.onChange(newValue);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
删除
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" className="w-5 h-5 text-red-500">
|
||||||
</Button>
|
<path d="M7 4V2H17V4H22V6H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V6H2V4H7ZM6 6V20H18V6H6ZM9 9H11V17H9V9ZM13 9H15V17H13V9Z"></path>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
import { DynamicFormItemConfig } from '@/app/home/components/dynamic-form/DynamicFormItemConfig';
|
|
||||||
|
|
||||||
export interface IPipelineChildFormEntity {
|
|
||||||
name: string;
|
|
||||||
label: string;
|
|
||||||
formItems: DynamicFormItemConfig[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export class PipelineChildFormEntity implements IPipelineChildFormEntity {
|
|
||||||
formItems: DynamicFormItemConfig[];
|
|
||||||
label: string;
|
|
||||||
name: string;
|
|
||||||
|
|
||||||
constructor(props: IPipelineChildFormEntity) {
|
|
||||||
this.label = props.label;
|
|
||||||
this.name = props.name;
|
|
||||||
this.formItems = props.formItems;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,7 @@ import PipelineFormComponent from './components/pipeline-form/PipelineFormCompon
|
|||||||
import { httpClient } from '@/app/infra/http/HttpClient';
|
import { httpClient } from '@/app/infra/http/HttpClient';
|
||||||
import { PipelineCardVO } from '@/app/home/pipelines/components/pipeline-card/PipelineCardVO';
|
import { PipelineCardVO } from '@/app/home/pipelines/components/pipeline-card/PipelineCardVO';
|
||||||
import PipelineCard from '@/app/home/pipelines/components/pipeline-card/PipelineCard';
|
import PipelineCard from '@/app/home/pipelines/components/pipeline-card/PipelineCard';
|
||||||
import { PipelineFormEntity } from '@/app/home/pipelines/components/pipeline-form/PipelineFormEntity';
|
import { PipelineFormEntity } from '@/app/infra/entities/pipeline';
|
||||||
import styles from './pipelineConfig.module.css';
|
import styles from './pipelineConfig.module.css';
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
@@ -81,27 +81,6 @@ export default function PluginConfigPage() {
|
|||||||
return (
|
return (
|
||||||
<div className={styles.configPageContainer}>
|
<div className={styles.configPageContainer}>
|
||||||
|
|
||||||
{/* <Modal
|
|
||||||
title={isEditForm ? '编辑流水线' : '创建流水线'}
|
|
||||||
centered
|
|
||||||
open={modalOpen}
|
|
||||||
destroyOnClose={true}
|
|
||||||
onOk={() => setModalOpen(false)}
|
|
||||||
onCancel={() => setModalOpen(false)}
|
|
||||||
width={700}
|
|
||||||
footer={null}
|
|
||||||
>
|
|
||||||
<PipelineFormComponent
|
|
||||||
onFinish={() => {
|
|
||||||
getPipelines();
|
|
||||||
setModalOpen(false);
|
|
||||||
}}
|
|
||||||
isEditMode={isEditForm}
|
|
||||||
pipelineId={selectedPipelineId}
|
|
||||||
disableForm={disableForm}
|
|
||||||
initValues={selectedPipelineFormValue}
|
|
||||||
/>
|
|
||||||
</Modal> */}
|
|
||||||
<Dialog open={modalOpen} onOpenChange={setModalOpen}>
|
<Dialog open={modalOpen} onOpenChange={setModalOpen}>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
|
|||||||
Reference in New Issue
Block a user