fix: validate name assistant and improve area clickable (#5920)
This commit is contained in:
parent
3982ed4c6f
commit
6c15129ce8
@ -81,7 +81,7 @@ const DropdownAssistant = () => {
|
|||||||
>
|
>
|
||||||
<DropdownMenuItem className="hover:bg-transparent">
|
<DropdownMenuItem className="hover:bg-transparent">
|
||||||
<div
|
<div
|
||||||
className="text-main-view-fg/70 cursor-pointer flex gap-2"
|
className="text-main-view-fg/70 cursor-pointer flex gap-2 w-full"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setCurrentAssistant(assistant)
|
setCurrentAssistant(assistant)
|
||||||
updateCurrentThreadAssistant(assistant)
|
updateCurrentThreadAssistant(assistant)
|
||||||
|
|||||||
@ -61,6 +61,7 @@ export default function AddEditAssistant({
|
|||||||
const [paramsTypes, setParamsTypes] = useState<string[]>(['string'])
|
const [paramsTypes, setParamsTypes] = useState<string[]>(['string'])
|
||||||
const [showEmojiPicker, setShowEmojiPicker] = useState(false)
|
const [showEmojiPicker, setShowEmojiPicker] = useState(false)
|
||||||
const emojiPickerRef = useRef<HTMLDivElement>(null)
|
const emojiPickerRef = useRef<HTMLDivElement>(null)
|
||||||
|
const [nameError, setNameError] = useState<string | null>(null)
|
||||||
|
|
||||||
// Handle click outside emoji picker
|
// Handle click outside emoji picker
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -118,6 +119,7 @@ export default function AddEditAssistant({
|
|||||||
setParamsKeys([''])
|
setParamsKeys([''])
|
||||||
setParamsValues([''])
|
setParamsValues([''])
|
||||||
setParamsTypes(['string'])
|
setParamsTypes(['string'])
|
||||||
|
setNameError(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleParameterChange = (
|
const handleParameterChange = (
|
||||||
@ -193,6 +195,11 @@ export default function AddEditAssistant({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleSave = () => {
|
const handleSave = () => {
|
||||||
|
if (!name.trim()) {
|
||||||
|
setNameError(t('assistants:nameRequired'))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
setNameError(null)
|
||||||
// Convert parameters arrays to object
|
// Convert parameters arrays to object
|
||||||
const parameters: Record<string, unknown> = {}
|
const parameters: Record<string, unknown> = {}
|
||||||
paramsKeys.forEach((key, index) => {
|
paramsKeys.forEach((key, index) => {
|
||||||
@ -275,13 +282,22 @@ export default function AddEditAssistant({
|
|||||||
</label>
|
</label>
|
||||||
<Input
|
<Input
|
||||||
value={name}
|
value={name}
|
||||||
onChange={(e) => setName(e.target.value)}
|
onChange={(e) => {
|
||||||
|
setName(e.target.value)
|
||||||
|
if (e.target.value.trim()) setNameError(null)
|
||||||
|
}}
|
||||||
placeholder={t('assistants:enterName')}
|
placeholder={t('assistants:enterName')}
|
||||||
autoFocus
|
autoFocus
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{nameError && (
|
||||||
|
<div className="ml-12 text-xs text-destructive mt-1">
|
||||||
|
{nameError}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<label className="text-sm mb-2 inline-block">
|
<label className="text-sm mb-2 inline-block">
|
||||||
{t('assistants:description')}
|
{t('assistants:description')}
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
"emoji": "Emoji",
|
"emoji": "Emoji",
|
||||||
"name": "Name",
|
"name": "Name",
|
||||||
"enterName": "Namen eingeben",
|
"enterName": "Namen eingeben",
|
||||||
|
"nameRequired": "Name ist erforderlich",
|
||||||
"description": "Beschreibung (optional)",
|
"description": "Beschreibung (optional)",
|
||||||
"enterDescription": "Beschreibung eingeben",
|
"enterDescription": "Beschreibung eingeben",
|
||||||
"instructions": "Anweisungen",
|
"instructions": "Anweisungen",
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
"emoji": "Emoji",
|
"emoji": "Emoji",
|
||||||
"name": "Name",
|
"name": "Name",
|
||||||
"enterName": "Enter name",
|
"enterName": "Enter name",
|
||||||
|
"nameRequired": "Name is required",
|
||||||
"description": "Description (optional)",
|
"description": "Description (optional)",
|
||||||
"enterDescription": "Enter description",
|
"enterDescription": "Enter description",
|
||||||
"instructions": "Instructions",
|
"instructions": "Instructions",
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
"emoji": "Emoji",
|
"emoji": "Emoji",
|
||||||
"name": "Nama",
|
"name": "Nama",
|
||||||
"enterName": "Masukkan nama",
|
"enterName": "Masukkan nama",
|
||||||
|
"nameRequired": "Nama wajib diisi",
|
||||||
"description": "Deskripsi (opsional)",
|
"description": "Deskripsi (opsional)",
|
||||||
"enterDescription": "Masukkan deskripsi",
|
"enterDescription": "Masukkan deskripsi",
|
||||||
"instructions": "Instruksi",
|
"instructions": "Instruksi",
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
"emoji": "Biểu tượng",
|
"emoji": "Biểu tượng",
|
||||||
"name": "Tên",
|
"name": "Tên",
|
||||||
"enterName": "Nhập tên",
|
"enterName": "Nhập tên",
|
||||||
|
"nameRequired": "Tên là bắt buộc",
|
||||||
"description": "Mô tả (tùy chọn)",
|
"description": "Mô tả (tùy chọn)",
|
||||||
"enterDescription": "Nhập mô tả",
|
"enterDescription": "Nhập mô tả",
|
||||||
"instructions": "Hướng dẫn",
|
"instructions": "Hướng dẫn",
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
"emoji": "表情符号",
|
"emoji": "表情符号",
|
||||||
"name": "名称",
|
"name": "名称",
|
||||||
"enterName": "输入名称",
|
"enterName": "输入名称",
|
||||||
|
"nameRequired": "名称为必填项",
|
||||||
"description": "描述(可选)",
|
"description": "描述(可选)",
|
||||||
"enterDescription": "输入描述",
|
"enterDescription": "输入描述",
|
||||||
"instructions": "说明",
|
"instructions": "说明",
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
"emoji": "表情符號",
|
"emoji": "表情符號",
|
||||||
"name": "名稱",
|
"name": "名稱",
|
||||||
"enterName": "輸入名稱",
|
"enterName": "輸入名稱",
|
||||||
|
"nameRequired": "名稱為必填項",
|
||||||
"description": "描述(可選)",
|
"description": "描述(可選)",
|
||||||
"enterDescription": "輸入描述",
|
"enterDescription": "輸入描述",
|
||||||
"instructions": "指示",
|
"instructions": "指示",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user