@@ -9,49 +9,57 @@ import {
9
9
PuzzlePieceIcon ,
10
10
EyeDropperIcon ,
11
11
ChatBubbleLeftRightIcon ,
12
- // MagnifyingGlassIcon,
12
+ MagnifyingGlassIcon ,
13
13
} from "@heroicons/react/24/outline" ;
14
14
15
15
import { Link , useParams , useLocation , useNavigate } from "react-router-dom" ;
16
16
import { useAuth } from "../context/AuthContext" ;
17
17
import { Tooltip } from "antd" ;
18
18
import { ApplicationMenu } from "./ApplicationMenu" ;
19
+ import { useSettings } from "../hooks/useSettings" ;
19
20
20
21
const navigation = [
21
22
{
22
23
name : "Playground" ,
23
24
href : "/bot/:id" ,
24
25
icon : SparklesIcon ,
26
+ key : "playground" ,
25
27
} ,
26
- // {
27
- // name: "Search (Beta)",
28
- // href: "/bot/:id/search",
29
- // icon: MagnifyingGlassIcon,
30
- // },
31
28
{
32
29
name : "Data Sources" ,
33
30
href : "/bot/:id/data-sources" ,
34
31
icon : CircleStackIcon ,
32
+ key : "data-sources" ,
33
+ } ,
34
+ {
35
+ name : "Search (Beta)" ,
36
+ href : "/bot/:id/search" ,
37
+ icon : MagnifyingGlassIcon ,
38
+ key : "search" ,
35
39
} ,
36
40
{
37
41
name : "Integrations" ,
38
42
href : "/bot/:id/integrations" ,
39
43
icon : PuzzlePieceIcon ,
44
+ key : "integrations" ,
40
45
} ,
41
46
{
42
47
name : "Conversations" ,
43
48
href : "/bot/:id/conversations" ,
44
49
icon : ChatBubbleLeftRightIcon ,
50
+ key : "conversations" ,
45
51
} ,
46
52
{
47
53
name : "Appearance" ,
48
54
href : "/bot/:id/appearance" ,
49
55
icon : EyeDropperIcon ,
56
+ key : "appearance" ,
50
57
} ,
51
58
{
52
59
name : "Settings" ,
53
60
href : "/bot/:id/settings" ,
54
61
icon : CogIcon ,
62
+ key : "settings" ,
55
63
} ,
56
64
] ;
57
65
@@ -75,6 +83,8 @@ export default function BotLayout({
75
83
76
84
const { isLogged } = useAuth ( ) ;
77
85
86
+ const settings = useSettings ( ) ;
87
+
78
88
React . useEffect ( ( ) => {
79
89
if ( ! isLogged ) {
80
90
navigate ( "/login" ) ;
@@ -153,33 +163,41 @@ export default function BotLayout({
153
163
</ Link >
154
164
< div className = "mt-5 h-0 flex-1 overflow-y-auto" >
155
165
< nav className = "space-y-1 px-2" >
156
- { navigation . map ( ( item ) => (
157
- < Link
158
- key = { item . name }
159
- to = { {
160
- pathname : item . href . replace ( ":id" , params . id ! ) ,
161
- } }
162
- className = { classNames (
163
- location . pathname ===
164
- item . href . replace ( ":id" , params . id ! )
165
- ? "bg-gray-100 text-gray-900 dark:bg-[#262626] dark:text-white"
166
- : "text-gray-600 hover:bg-gray-50 hover:text-gray-900 dark:text-gray-200 dark:hover:text-white dark:hover:bg-[#262626]" ,
167
- "group flex items-center px-2 py-2 text-base font-medium rounded-md"
168
- ) }
169
- >
170
- < item . icon
166
+ { navigation . map ( ( item ) => {
167
+ if (
168
+ item . key === "search" &&
169
+ ! settings ?. data ?. internalSearchEnabled
170
+ ) {
171
+ return null ;
172
+ }
173
+ return (
174
+ < Link
175
+ key = { item . name }
176
+ to = { {
177
+ pathname : item . href . replace ( ":id" , params . id ! ) ,
178
+ } }
171
179
className = { classNames (
172
180
location . pathname ===
173
181
item . href . replace ( ":id" , params . id ! )
174
- ? "text-gray-500 "
175
- : "text-gray-400 group- hover:text-gray-500 " ,
176
- "mr-4 flex-shrink-0 h-6 w-6 "
182
+ ? "bg-gray-100 text-gray-900 dark:bg-[#262626] dark:text-white "
183
+ : "text-gray-600 hover:bg-gray-50 hover:text-gray-900 dark:text-gray-200 dark:hover:text-white dark:hover:bg-[#262626] " ,
184
+ "group flex items-center px-2 py-2 text-base font-medium rounded-md "
177
185
) }
178
- aria-hidden = "true"
179
- />
180
- { item . name }
181
- </ Link >
182
- ) ) }
186
+ >
187
+ < item . icon
188
+ className = { classNames (
189
+ location . pathname ===
190
+ item . href . replace ( ":id" , params . id ! )
191
+ ? "text-gray-500"
192
+ : "text-gray-400 group-hover:text-gray-500" ,
193
+ "mr-4 flex-shrink-0 h-6 w-6"
194
+ ) }
195
+ aria-hidden = "true"
196
+ />
197
+ { item . name }
198
+ </ Link >
199
+ ) ;
200
+ } ) }
183
201
</ nav >
184
202
</ div >
185
203
</ Dialog . Panel >
@@ -223,37 +241,46 @@ export default function BotLayout({
223
241
< div className = "flex flex-grow flex-col overflow-y-auto border-r border-gray-200 bg-white pt-5 dark:bg-[#171717] dark:border-gray-600" >
224
242
< div className = "mt-14 flex flex-grow flex-col" >
225
243
< nav className = "flex-1 space-y-1 px-2 pb-4" >
226
- { navigation . map ( ( item ) => (
227
- < Tooltip
228
- placement = "right"
229
- key = { item . name }
230
- title = { item . name }
231
- >
232
- < Link
233
- to = { {
234
- pathname : item . href . replace ( ":id" , params . id ! ) ,
235
- } }
236
- className = { classNames (
237
- location . pathname ===
238
- item . href . replace ( ":id" , params . id ! )
239
- ? "bg-gray-100 text-gray-900 dark:bg-[#262626] dark:text-white"
240
- : "text-gray-600 hover:bg-gray-50 hover:text-gray-900 dark:text-gray-200 dark:hover:text-white dark:hover:bg-[#262626]" ,
241
- "group flex items-center justify-center px-2 py-2 text-sm font-medium rounded-md"
242
- ) }
244
+ { navigation . map ( ( item ) => {
245
+ if (
246
+ item . key === "search" &&
247
+ ! settings . data ?. internalSearchEnabled
248
+ ) {
249
+ return null ;
250
+ }
251
+
252
+ return (
253
+ < Tooltip
254
+ placement = "right"
255
+ key = { item . name }
256
+ title = { item . name }
243
257
>
244
- < item . icon
258
+ < Link
259
+ to = { {
260
+ pathname : item . href . replace ( ":id" , params . id ! ) ,
261
+ } }
245
262
className = { classNames (
246
263
location . pathname ===
247
264
item . href . replace ( ":id" , params . id ! )
248
- ? "text-gray-500 dark:text-white"
249
- : "text-gray-400 group- hover:text-gray-500 dark:text-gray-400 dark:group- hover:text-white" ,
250
- "flex-shrink-0 h-6 w-6 "
265
+ ? "bg-gray-100 text-gray-900 dark:bg-[#262626] dark:text-white"
266
+ : "text-gray-600 hover:bg-gray-50 hover:text-gray-900 dark:text-gray-200 dark:hover:text-white dark:hover:bg-[#262626] " ,
267
+ "group flex items-center justify-center px-2 py-2 text-sm font-medium rounded-md "
251
268
) }
252
- aria-hidden = "true"
253
- />
254
- </ Link >
255
- </ Tooltip >
256
- ) ) }
269
+ >
270
+ < item . icon
271
+ className = { classNames (
272
+ location . pathname ===
273
+ item . href . replace ( ":id" , params . id ! )
274
+ ? "text-gray-500 dark:text-white"
275
+ : "text-gray-400 group-hover:text-gray-500 dark:text-gray-400 dark:group-hover:text-white" ,
276
+ "flex-shrink-0 h-6 w-6"
277
+ ) }
278
+ aria-hidden = "true"
279
+ />
280
+ </ Link >
281
+ </ Tooltip >
282
+ ) ;
283
+ } ) }
257
284
</ nav >
258
285
</ div >
259
286
</ div >
0 commit comments