mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-12 22:00:57 +00:00
refactor(web): make description optional and remove default values for bot, pipeline, and knowledge base
- Remove .min(1) validation on description field, replace with .optional().default('')
- Remove pre-filled default description text from all three create forms
- Remove required asterisk (*) marker from description labels
- No backend changes needed: Bot/Pipeline DB accepts empty string, KB DB allows null
This commit is contained in:
@@ -53,9 +53,7 @@ import { CustomApiError } from '@/app/infra/entities/common';
|
|||||||
const getFormSchema = (t: (key: string) => string) =>
|
const getFormSchema = (t: (key: string) => string) =>
|
||||||
z.object({
|
z.object({
|
||||||
name: z.string().min(1, { message: t('bots.botNameRequired') }),
|
name: z.string().min(1, { message: t('bots.botNameRequired') }),
|
||||||
description: z
|
description: z.string().optional().default(''),
|
||||||
.string()
|
|
||||||
.min(1, { message: t('bots.botDescriptionRequired') }),
|
|
||||||
adapter: z.string().min(1, { message: t('bots.adapterRequired') }),
|
adapter: z.string().min(1, { message: t('bots.adapterRequired') }),
|
||||||
adapter_config: z.record(z.string(), z.any()),
|
adapter_config: z.record(z.string(), z.any()),
|
||||||
enable: z.boolean().optional(),
|
enable: z.boolean().optional(),
|
||||||
@@ -80,7 +78,7 @@ export default function BotForm({
|
|||||||
resolver: zodResolver(formSchema),
|
resolver: zodResolver(formSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
name: '',
|
name: '',
|
||||||
description: t('bots.defaultDescription'),
|
description: '',
|
||||||
adapter: '',
|
adapter: '',
|
||||||
adapter_config: {},
|
adapter_config: {},
|
||||||
enable: true,
|
enable: true,
|
||||||
@@ -427,10 +425,7 @@ export default function BotForm({
|
|||||||
name="description"
|
name="description"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>
|
<FormLabel>{t('bots.botDescription')}</FormLabel>
|
||||||
{t('bots.botDescription')}
|
|
||||||
<span className="text-destructive">*</span>
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input {...field} />
|
<Input {...field} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|||||||
@@ -46,9 +46,7 @@ import { UUID } from 'uuidjs';
|
|||||||
const getFormSchema = (t: (key: string) => string) =>
|
const getFormSchema = (t: (key: string) => string) =>
|
||||||
z.object({
|
z.object({
|
||||||
name: z.string().min(1, { message: t('knowledge.kbNameRequired') }),
|
name: z.string().min(1, { message: t('knowledge.kbNameRequired') }),
|
||||||
description: z
|
description: z.string().optional().default(''),
|
||||||
.string()
|
|
||||||
.min(1, { message: t('knowledge.kbDescriptionRequired') }),
|
|
||||||
emoji: z.string().optional(),
|
emoji: z.string().optional(),
|
||||||
ragEngineId: z
|
ragEngineId: z
|
||||||
.string()
|
.string()
|
||||||
@@ -115,7 +113,7 @@ export default function KBForm({
|
|||||||
resolver: zodResolver(formSchema),
|
resolver: zodResolver(formSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
name: '',
|
name: '',
|
||||||
description: t('knowledge.defaultDescription'),
|
description: '',
|
||||||
emoji: '📚',
|
emoji: '📚',
|
||||||
ragEngineId: '',
|
ragEngineId: '',
|
||||||
},
|
},
|
||||||
@@ -373,10 +371,7 @@ export default function KBForm({
|
|||||||
name="description"
|
name="description"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>
|
<FormLabel>{t('knowledge.kbDescription')}</FormLabel>
|
||||||
{t('knowledge.kbDescription')}
|
|
||||||
<span className="text-destructive">*</span>
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input {...field} />
|
<Input {...field} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|||||||
@@ -80,9 +80,7 @@ export default function PipelineFormComponent({
|
|||||||
? z.object({
|
? z.object({
|
||||||
basic: z.object({
|
basic: z.object({
|
||||||
name: z.string().min(1, { message: t('pipelines.nameRequired') }),
|
name: z.string().min(1, { message: t('pipelines.nameRequired') }),
|
||||||
description: z
|
description: z.string().optional().default(''),
|
||||||
.string()
|
|
||||||
.min(1, { message: t('pipelines.descriptionRequired') }),
|
|
||||||
emoji: z.string().optional(),
|
emoji: z.string().optional(),
|
||||||
}),
|
}),
|
||||||
ai: z.record(z.string(), z.any()),
|
ai: z.record(z.string(), z.any()),
|
||||||
@@ -93,9 +91,7 @@ export default function PipelineFormComponent({
|
|||||||
: z.object({
|
: z.object({
|
||||||
basic: z.object({
|
basic: z.object({
|
||||||
name: z.string().min(1, { message: t('pipelines.nameRequired') }),
|
name: z.string().min(1, { message: t('pipelines.nameRequired') }),
|
||||||
description: z
|
description: z.string().optional().default(''),
|
||||||
.string()
|
|
||||||
.min(1, { message: t('pipelines.descriptionRequired') }),
|
|
||||||
emoji: z.string().optional(),
|
emoji: z.string().optional(),
|
||||||
}),
|
}),
|
||||||
ai: z.record(z.string(), z.any()).optional(),
|
ai: z.record(z.string(), z.any()).optional(),
|
||||||
@@ -563,10 +559,7 @@ export default function PipelineFormComponent({
|
|||||||
name="basic.description"
|
name="basic.description"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>
|
<FormLabel>{t('common.description')}</FormLabel>
|
||||||
{t('common.description')}
|
|
||||||
<span className="text-destructive">*</span>
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input {...field} />
|
<Input {...field} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|||||||
Reference in New Issue
Block a user