balibabu commited on
Commit
f011ffe
·
1 Parent(s): 9da9f1a

Feat: Add AdvancedSettingForm #3221 (#4071)

Browse files

### What problem does this PR solve?

Feat: Add AdvancedSettingForm #3221

### Type of change


- [x] New Feature (non-breaking change which adds functionality)

web/src/pages/dataset/setting/advanced-setting-form.tsx ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use client';
2
+
3
+ import { zodResolver } from '@hookform/resolvers/zod';
4
+ import { useForm } from 'react-hook-form';
5
+ import { z } from 'zod';
6
+
7
+ import { Button } from '@/components/ui/button';
8
+ import {
9
+ Form,
10
+ FormControl,
11
+ FormDescription,
12
+ FormField,
13
+ FormItem,
14
+ FormLabel,
15
+ FormMessage,
16
+ } from '@/components/ui/form';
17
+ import {
18
+ Select,
19
+ SelectContent,
20
+ SelectItem,
21
+ SelectTrigger,
22
+ SelectValue,
23
+ } from '@/components/ui/select';
24
+ import { FormSlider } from '@/components/ui/slider';
25
+ import { Textarea } from '@/components/ui/textarea';
26
+
27
+ const formSchema = z.object({
28
+ username: z.number().min(2, {
29
+ message: 'Username must be at least 2 characters.',
30
+ }),
31
+ a: z.number().min(2, {
32
+ message: 'Username must be at least 2 characters.',
33
+ }),
34
+ b: z.string().min(2, {
35
+ message: 'Username must be at least 2 characters.',
36
+ }),
37
+ c: z.number().min(2, {
38
+ message: 'Username must be at least 2 characters.',
39
+ }),
40
+ d: z.string().min(2, {
41
+ message: 'Username must be at least 2 characters.',
42
+ }),
43
+ });
44
+
45
+ export default function AdvancedSettingForm() {
46
+ const form = useForm<z.infer<typeof formSchema>>({
47
+ resolver: zodResolver(formSchema),
48
+ defaultValues: {
49
+ username: 0,
50
+ },
51
+ });
52
+
53
+ function onSubmit(values: z.infer<typeof formSchema>) {
54
+ console.log(values);
55
+ }
56
+
57
+ return (
58
+ <Form {...form}>
59
+ <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8">
60
+ <FormField
61
+ control={form.control}
62
+ name="username"
63
+ render={({ field }) => (
64
+ <FormItem>
65
+ <FormLabel>Username</FormLabel>
66
+ <FormControl>
67
+ <FormSlider {...field}></FormSlider>
68
+ </FormControl>
69
+ <FormDescription>
70
+ This is your public display name.
71
+ </FormDescription>
72
+ <FormMessage />
73
+ </FormItem>
74
+ )}
75
+ />
76
+ <FormField
77
+ control={form.control}
78
+ name="a"
79
+ render={({ field }) => (
80
+ <FormItem>
81
+ <FormLabel>Username</FormLabel>
82
+ <FormControl>
83
+ <FormSlider {...field}></FormSlider>
84
+ </FormControl>
85
+ <FormDescription>
86
+ This is your public display name.
87
+ </FormDescription>
88
+ <FormMessage />
89
+ </FormItem>
90
+ )}
91
+ />
92
+ <FormField
93
+ control={form.control}
94
+ name="b"
95
+ render={({ field }) => (
96
+ <FormItem>
97
+ <FormLabel>Username</FormLabel>
98
+ <Select onValueChange={field.onChange} defaultValue={field.value}>
99
+ <FormControl>
100
+ <SelectTrigger className="bg-colors-background-inverse-weak">
101
+ <SelectValue placeholder="Select a verified email to display" />
102
+ </SelectTrigger>
103
+ </FormControl>
104
+ <SelectContent>
105
+ <SelectItem value="[email protected]">[email protected]</SelectItem>
106
+ <SelectItem value="[email protected]">[email protected]</SelectItem>
107
+ <SelectItem value="[email protected]">[email protected]</SelectItem>
108
+ </SelectContent>
109
+ </Select>
110
+ <FormDescription>
111
+ This is your public display name.
112
+ </FormDescription>
113
+ <FormMessage />
114
+ </FormItem>
115
+ )}
116
+ />
117
+ <FormField
118
+ control={form.control}
119
+ name="c"
120
+ render={({ field }) => (
121
+ <FormItem>
122
+ <FormLabel>Username</FormLabel>
123
+ <FormControl>
124
+ <FormSlider {...field}></FormSlider>
125
+ </FormControl>
126
+ <FormDescription>
127
+ This is your public display name.
128
+ </FormDescription>
129
+ <FormMessage />
130
+ </FormItem>
131
+ )}
132
+ />
133
+ <FormField
134
+ control={form.control}
135
+ name="d"
136
+ render={({ field }) => (
137
+ <FormItem>
138
+ <FormLabel>Username</FormLabel>
139
+ <FormControl>
140
+ <Textarea
141
+ {...field}
142
+ className="bg-colors-background-inverse-weak"
143
+ ></Textarea>
144
+ </FormControl>
145
+ <FormDescription>
146
+ This is your public display name.
147
+ </FormDescription>
148
+ <FormMessage />
149
+ </FormItem>
150
+ )}
151
+ />
152
+ <Button
153
+ variant={'tertiary'}
154
+ size={'sm'}
155
+ type="submit"
156
+ className="w-full"
157
+ >
158
+ Test
159
+ </Button>
160
+ </form>
161
+ </Form>
162
+ );
163
+ }
web/src/pages/dataset/setting/basic-setting-form.tsx ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use client';
2
+
3
+ import { zodResolver } from '@hookform/resolvers/zod';
4
+ import { useForm } from 'react-hook-form';
5
+ import { z } from 'zod';
6
+
7
+ import { Button } from '@/components/ui/button';
8
+ import {
9
+ Form,
10
+ FormControl,
11
+ FormDescription,
12
+ FormField,
13
+ FormItem,
14
+ FormLabel,
15
+ FormMessage,
16
+ } from '@/components/ui/form';
17
+ import {
18
+ Select,
19
+ SelectContent,
20
+ SelectItem,
21
+ SelectTrigger,
22
+ SelectValue,
23
+ } from '@/components/ui/select';
24
+ import { FormSlider } from '@/components/ui/slider';
25
+ import { Textarea } from '@/components/ui/textarea';
26
+
27
+ const formSchema = z.object({
28
+ username: z.number().min(2, {
29
+ message: 'Username must be at least 2 characters.',
30
+ }),
31
+ a: z.number().min(2, {
32
+ message: 'Username must be at least 2 characters.',
33
+ }),
34
+ b: z.string().min(2, {
35
+ message: 'Username must be at least 2 characters.',
36
+ }),
37
+ c: z.number().min(2, {
38
+ message: 'Username must be at least 2 characters.',
39
+ }),
40
+ d: z.string().min(2, {
41
+ message: 'Username must be at least 2 characters.',
42
+ }),
43
+ });
44
+
45
+ export default function BasicSettingForm() {
46
+ const form = useForm<z.infer<typeof formSchema>>({
47
+ resolver: zodResolver(formSchema),
48
+ defaultValues: {
49
+ username: 0,
50
+ },
51
+ });
52
+
53
+ function onSubmit(values: z.infer<typeof formSchema>) {
54
+ console.log(values);
55
+ }
56
+
57
+ return (
58
+ <Form {...form}>
59
+ <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8">
60
+ <FormField
61
+ control={form.control}
62
+ name="username"
63
+ render={({ field }) => (
64
+ <FormItem>
65
+ <FormLabel>Username</FormLabel>
66
+ <FormControl>
67
+ <FormSlider {...field}></FormSlider>
68
+ </FormControl>
69
+ <FormDescription>
70
+ This is your public display name.
71
+ </FormDescription>
72
+ <FormMessage />
73
+ </FormItem>
74
+ )}
75
+ />
76
+ <FormField
77
+ control={form.control}
78
+ name="a"
79
+ render={({ field }) => (
80
+ <FormItem>
81
+ <FormLabel>Username</FormLabel>
82
+ <FormControl>
83
+ <FormSlider {...field}></FormSlider>
84
+ </FormControl>
85
+ <FormDescription>
86
+ This is your public display name.
87
+ </FormDescription>
88
+ <FormMessage />
89
+ </FormItem>
90
+ )}
91
+ />
92
+ <FormField
93
+ control={form.control}
94
+ name="b"
95
+ render={({ field }) => (
96
+ <FormItem>
97
+ <FormLabel>Username</FormLabel>
98
+ <Select onValueChange={field.onChange} defaultValue={field.value}>
99
+ <FormControl>
100
+ <SelectTrigger className="bg-colors-background-inverse-weak">
101
+ <SelectValue placeholder="Select a verified email to display" />
102
+ </SelectTrigger>
103
+ </FormControl>
104
+ <SelectContent>
105
+ <SelectItem value="[email protected]">[email protected]</SelectItem>
106
+ <SelectItem value="[email protected]">[email protected]</SelectItem>
107
+ <SelectItem value="[email protected]">[email protected]</SelectItem>
108
+ </SelectContent>
109
+ </Select>
110
+ <FormDescription>
111
+ This is your public display name.
112
+ </FormDescription>
113
+ <FormMessage />
114
+ </FormItem>
115
+ )}
116
+ />
117
+ <FormField
118
+ control={form.control}
119
+ name="c"
120
+ render={({ field }) => (
121
+ <FormItem>
122
+ <FormLabel>Username</FormLabel>
123
+ <FormControl>
124
+ <FormSlider {...field}></FormSlider>
125
+ </FormControl>
126
+ <FormDescription>
127
+ This is your public display name.
128
+ </FormDescription>
129
+ <FormMessage />
130
+ </FormItem>
131
+ )}
132
+ />
133
+ <FormField
134
+ control={form.control}
135
+ name="d"
136
+ render={({ field }) => (
137
+ <FormItem>
138
+ <FormLabel>Username</FormLabel>
139
+ <FormControl>
140
+ <Textarea
141
+ {...field}
142
+ className="bg-colors-background-inverse-weak"
143
+ ></Textarea>
144
+ </FormControl>
145
+ <FormDescription>
146
+ This is your public display name.
147
+ </FormDescription>
148
+ <FormMessage />
149
+ </FormItem>
150
+ )}
151
+ />
152
+ <Button
153
+ variant={'tertiary'}
154
+ size={'sm'}
155
+ type="submit"
156
+ className="w-full"
157
+ >
158
+ Test
159
+ </Button>
160
+ </form>
161
+ </Form>
162
+ );
163
+ }
web/src/pages/dataset/setting/index.tsx ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Card } from '@/components/ui/card';
2
+ import AdvancedSettingForm from './advanced-setting-form';
3
+ import BasicSettingForm from './basic-setting-form';
4
+
5
+ export default function DatasetSettings() {
6
+ return (
7
+ <section className="flex flex-col p-8 overflow-auto h-[80vh]">
8
+ <div className="text-3xl font-bold mb-6">Basic settings</div>
9
+ <Card className="border-0 p-6 mb-8 bg-colors-background-inverse-weak">
10
+ <div className="w-2/5">
11
+ <BasicSettingForm></BasicSettingForm>
12
+ </div>
13
+ </Card>
14
+
15
+ <div className="text-3xl font-bold mb-6">Advanced settings</div>
16
+ <Card className="border-0 p-6 mb-8 bg-colors-background-inverse-weak">
17
+ <div className="w-2/5">
18
+ <AdvancedSettingForm></AdvancedSettingForm>
19
+ </div>
20
+ </Card>
21
+ </section>
22
+ );
23
+ }
web/src/pages/dataset/settings/index.tsx DELETED
@@ -1,8 +0,0 @@
1
- export default function DatasetSettings() {
2
- return (
3
- <section>
4
- <span className="text-3xl font-bold ">Basic settings</span>
5
- <span className="text-3xl font-bold ">Advanced settings</span>
6
- </section>
7
- );
8
- }
 
 
 
 
 
 
 
 
 
web/src/pages/dataset/sidebar/hooks.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { DatasetBaseKey, KnowledgeRouteKey } from '@/constants/knowledge';
2
  import { useCallback } from 'react';
3
  import { useNavigate } from 'umi';
4
 
@@ -6,8 +6,8 @@ export const useHandleMenuClick = () => {
6
  const navigate = useNavigate();
7
 
8
  const handleMenuClick = useCallback(
9
- (key: KnowledgeRouteKey) => () => {
10
- navigate(`/${DatasetBaseKey}/${key}`);
11
  },
12
  [navigate],
13
  );
 
1
+ import { Routes } from '@/routes';
2
  import { useCallback } from 'react';
3
  import { useNavigate } from 'umi';
4
 
 
6
  const navigate = useNavigate();
7
 
8
  const handleMenuClick = useCallback(
9
+ (key: Routes) => () => {
10
+ navigate(`${Routes.DatasetBase}${key}`);
11
  },
12
  [navigate],
13
  );
web/src/pages/dataset/sidebar/index.tsx CHANGED
@@ -1,18 +1,18 @@
1
  import { Button } from '@/components/ui/button';
2
- import { KnowledgeRouteKey } from '@/constants/knowledge';
3
  import { useSecondPathName } from '@/hooks/route-hook';
4
  import { cn } from '@/lib/utils';
 
5
  import { Banknote, LayoutGrid, Trash2, User } from 'lucide-react';
6
  import { useHandleMenuClick } from './hooks';
7
 
8
  const items = [
9
- { icon: User, label: 'Dataset', key: KnowledgeRouteKey.Dataset },
10
  {
11
  icon: LayoutGrid,
12
  label: 'Retrieval testing',
13
- key: KnowledgeRouteKey.Testing,
14
  },
15
- { icon: Banknote, label: 'Settings', key: KnowledgeRouteKey.Configuration },
16
  ];
17
 
18
  const dataset = {
@@ -29,7 +29,7 @@ export function SideBar() {
29
  const { handleMenuClick } = useHandleMenuClick();
30
 
31
  return (
32
- <aside className="w-[303px] relative">
33
  <div className="p-6 space-y-2 border-b">
34
  <div
35
  className="w-[70px] h-[70px] rounded-xl bg-cover"
@@ -44,7 +44,7 @@ export function SideBar() {
44
  </div>
45
  <div className="mt-4">
46
  {items.map((item, itemIdx) => {
47
- const active = pathName === item.key;
48
  return (
49
  <Button
50
  key={itemIdx}
 
1
  import { Button } from '@/components/ui/button';
 
2
  import { useSecondPathName } from '@/hooks/route-hook';
3
  import { cn } from '@/lib/utils';
4
+ import { Routes } from '@/routes';
5
  import { Banknote, LayoutGrid, Trash2, User } from 'lucide-react';
6
  import { useHandleMenuClick } from './hooks';
7
 
8
  const items = [
9
+ { icon: User, label: 'Dataset', key: Routes.DatasetBase },
10
  {
11
  icon: LayoutGrid,
12
  label: 'Retrieval testing',
13
+ key: Routes.DatasetTesting,
14
  },
15
+ { icon: Banknote, label: 'Settings', key: Routes.DatasetSetting },
16
  ];
17
 
18
  const dataset = {
 
29
  const { handleMenuClick } = useHandleMenuClick();
30
 
31
  return (
32
+ <aside className="w-[303px] relative border-r ">
33
  <div className="p-6 space-y-2 border-b">
34
  <div
35
  className="w-[70px] h-[70px] rounded-xl bg-cover"
 
44
  </div>
45
  <div className="mt-4">
46
  {items.map((item, itemIdx) => {
47
+ const active = '/' + pathName === item.key;
48
  return (
49
  <Button
50
  key={itemIdx}
web/src/pages/dataset/testing/index.tsx CHANGED
@@ -8,7 +8,7 @@ const list = new Array(15).fill({
8
 
9
  export default function RetrievalTesting() {
10
  return (
11
- <section className="flex divide-x border-l h-full">
12
  <div className="p-4">
13
  <TestingForm></TestingForm>
14
  </div>
 
8
 
9
  export default function RetrievalTesting() {
10
  return (
11
+ <section className="flex divide-x h-full">
12
  <div className="p-4">
13
  <TestingForm></TestingForm>
14
  </div>
web/src/routes.ts CHANGED
@@ -8,6 +8,8 @@ export enum Routes {
8
  Search = '/next-search',
9
  Chat = '/next-chat',
10
  ProfileSetting = '/profile-setting',
 
 
11
  }
12
 
13
  const routes = [
@@ -207,12 +209,12 @@ const routes = [
207
  component: `@/pages${Routes.Dataset}`,
208
  },
209
  {
210
- path: `${Routes.DatasetBase}/configuration`,
211
- component: `@/pages${Routes.DatasetBase}/settings`,
212
  },
213
  {
214
- path: `${Routes.DatasetBase}/testing`,
215
- component: `@/pages${Routes.DatasetBase}/testing`,
216
  },
217
  ],
218
  },
 
8
  Search = '/next-search',
9
  Chat = '/next-chat',
10
  ProfileSetting = '/profile-setting',
11
+ DatasetTesting = '/testing',
12
+ DatasetSetting = '/setting',
13
  }
14
 
15
  const routes = [
 
209
  component: `@/pages${Routes.Dataset}`,
210
  },
211
  {
212
+ path: `${Routes.DatasetBase}${Routes.DatasetSetting}`,
213
+ component: `@/pages${Routes.DatasetBase}${Routes.DatasetSetting}`,
214
  },
215
  {
216
+ path: `${Routes.DatasetBase}${Routes.DatasetTesting}`,
217
+ component: `@/pages${Routes.DatasetBase}${Routes.DatasetTesting}`,
218
  },
219
  ],
220
  },