Skip to content

Commit 33fa9d8

Browse files
committed
Improve form submission feedback and UI consistency
Refactored LLM and SE instance forms to handle async submission and provide user feedback on success or failure. Updated page header to improve layout and button structure. Also clarified search engine vendor names in SE instance form.
1 parent f0818c1 commit 33fa9d8

File tree

3 files changed

+40
-23
lines changed

3 files changed

+40
-23
lines changed

turing-react/src/components/llm/llm.instance.form.tsx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,24 @@ export const LLMInstanceForm: React.FC<Props> = ({ value, isNew }) => {
5555
form.reset(value);
5656
}, [value])
5757

58-
function onSubmit(llmInstance: TurLLMInstance) {
58+
async function onSubmit(llmInstance: TurLLMInstance) {
5959
try {
6060
if (isNew) {
61-
turLLMInstanceService.create(llmInstance);
62-
toast.success(`The ${llmInstance.title} Language Model was saved`);
63-
navigate(urlBase);
61+
const result = await turLLMInstanceService.create(llmInstance);
62+
if (result) {
63+
toast.success(`The ${llmInstance.title} Language Model was saved`);
64+
navigate(urlBase);
65+
} else {
66+
toast.error(`The ${llmInstance.title} Language Model was not saved`);
67+
}
6468
}
6569
else {
66-
turLLMInstanceService.update(llmInstance);
67-
toast.success(`The ${llmInstance.title} Language Model was updated`);
70+
const result = await turLLMInstanceService.update(llmInstance);
71+
if (result) {
72+
toast.success(`The ${llmInstance.title} Language Model was updated`);
73+
} else {
74+
toast.error(`The ${llmInstance.title} Language Model was not updated`);
75+
}
6876
}
6977
} catch (error) {
7078
console.error("Form submission error", error);
@@ -359,7 +367,7 @@ export const LLMInstanceForm: React.FC<Props> = ({ value, isNew }) => {
359367
/>
360368
<FormField
361369
control={form.control}
362-
name="responseFormat"
370+
name="supportedCapabilities"
363371
render={({ field }) => (
364372
<FormItem>
365373
<FormLabel>Supported capabilities</FormLabel>

turing-react/src/components/page-header.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { Separator } from "@/components/ui/separator"
2-
import { SidebarTrigger } from "@/components/ui/sidebar"
1+
import { Separator } from "@/components/ui/separator";
2+
import { SidebarTrigger } from "@/components/ui/sidebar";
3+
import { NavLink } from "react-router-dom";
34
import { ModeToggle } from "./mode-toggle";
45
import { Button } from "./ui/button";
5-
import { NavLink } from "react-router-dom";
66

77
interface MyComponentProps {
88
turIcon?: React.ElementType;
@@ -23,21 +23,22 @@ export const PageHeader: React.FC<MyComponentProps> = ({ turIcon: TurIcon, title
2323
/>
2424
{urlBase !== undefined ? (
2525
<>
26-
{TurIcon && <TurIcon />}
27-
<NavLink to={urlBase}>
26+
27+
<NavLink to={urlBase} className="flex items-center gap-2">
28+
{TurIcon && <TurIcon />}
2829
<h1 className="text-base font-medium"> {title}</h1>
2930
</NavLink>
3031
</>
3132
) :
32-
(<> {TurIcon && <TurIcon />}
33+
(<>
34+
{TurIcon && <TurIcon />}
3335
<h1 className="text-base font-medium"> {title}</h1>
3436
</>)
3537
}
3638
<div className="ml-auto flex items-center gap-2">
3739
{urlNew !== undefined && (
3840
<Button>
39-
{TurIcon && <TurIcon />}
40-
<NavLink to={urlNew}>Add</NavLink>
41+
<NavLink to={urlNew} className="flex items-center gap-2">{TurIcon && <TurIcon />} Add</NavLink>
4142
</Button>
4243
)}
4344
<ModeToggle></ModeToggle>

turing-react/src/components/se/se.instance.form.tsx

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,24 @@ export const SEInstanceForm: React.FC<Props> = ({ value, isNew }) => {
5353
form.reset(value);
5454
}, [value])
5555

56-
function onSubmit(seInstance: TurSEInstance) {
56+
async function onSubmit(seInstance: TurSEInstance) {
5757
try {
5858
if (isNew) {
59-
turSEInstanceService.create(seInstance);
60-
toast.success(`The ${seInstance.title} Search Engine was saved`);
61-
navigate(ROUTES.SE_INSTANCE);
59+
const result = await turSEInstanceService.create(seInstance);
60+
if (result) {
61+
toast.success(`The ${seInstance.title} Search Engine was saved`);
62+
navigate(ROUTES.SE_INSTANCE);
63+
} else {
64+
toast.error(`The ${seInstance.title} Search Engine was not saved`);
65+
}
6266
}
6367
else {
64-
turSEInstanceService.update(seInstance);
65-
toast.success(`The ${seInstance.title} Search Engine was updated`);
68+
const result = await turSEInstanceService.update(seInstance);
69+
if (result) {
70+
toast.success(`The ${seInstance.title} Search Engine was updated`);
71+
} else {
72+
toast.error(`The ${seInstance.title} Search Engine was not updated`);
73+
}
6674
}
6775
} catch (error) {
6876
console.error("Form submission error", error);
@@ -175,8 +183,8 @@ export const SEInstanceForm: React.FC<Props> = ({ value, isNew }) => {
175183
</SelectTrigger>
176184
</FormControl>
177185
<SelectContent>
178-
<SelectItem key="SOLR" value="SOLR">Solr</SelectItem>
179-
<SelectItem key="LUCENE" value="LUCENE">Lucene</SelectItem>
186+
<SelectItem key="SOLR" value="SOLR">Apache Solr</SelectItem>
187+
<SelectItem key="LUCENE" value="LUCENE">Apache Lucene</SelectItem>
180188
</SelectContent>
181189
</Select>
182190
<FormDescription>Search engine vendor that will be used.</FormDescription>

0 commit comments

Comments
 (0)