|
1 | 1 | "use client"; |
2 | 2 |
|
3 | | -import React, {ReactNode} from "react"; |
| 3 | +import {ReactNode} from "react"; |
4 | 4 | import {useTranslation} from "react-i18next"; |
5 | 5 |
|
6 | | -import {Badge, Button, Dropdown} from "antd"; |
7 | | -import {DownOutlined} from "@ant-design/icons"; |
8 | | -import {FiRefreshCw} from "react-icons/fi"; |
9 | | -import {Globe} from "lucide-react"; |
10 | | -import {languageOptions} from "@/const/constants"; |
11 | | -import {useLanguageSwitch} from "@/lib/language"; |
12 | | -import {CONNECTION_STATUS, ConnectionStatus,} from "@/const/modelConfig"; |
13 | | - |
14 | | -// ================ Setup Header Content Components ================ |
15 | | -// These components are exported so they can be used to customize the TopNavbar |
16 | | - |
17 | | -interface SetupHeaderRightContentProps { |
18 | | - connectionStatus: ConnectionStatus; |
19 | | - isCheckingConnection: boolean; |
20 | | - onCheckConnection: () => void; |
21 | | -} |
22 | | - |
23 | | -export function SetupHeaderRightContent({ |
24 | | - connectionStatus, |
25 | | - isCheckingConnection, |
26 | | - onCheckConnection, |
27 | | -}: SetupHeaderRightContentProps) { |
28 | | - const { t } = useTranslation(); |
29 | | - const { currentLanguage, handleLanguageChange } = useLanguageSwitch(); |
30 | | - |
31 | | - // Get status text |
32 | | - const getStatusText = () => { |
33 | | - switch (connectionStatus) { |
34 | | - case CONNECTION_STATUS.SUCCESS: |
35 | | - return t("setup.header.status.connected"); |
36 | | - case CONNECTION_STATUS.ERROR: |
37 | | - return t("setup.header.status.disconnected"); |
38 | | - case CONNECTION_STATUS.PROCESSING: |
39 | | - return t("setup.header.status.checking"); |
40 | | - default: |
41 | | - return t("setup.header.status.unknown"); |
42 | | - } |
43 | | - }; |
44 | | - |
45 | | - return ( |
46 | | - <div className="flex items-center gap-3"> |
47 | | - <Dropdown |
48 | | - menu={{ |
49 | | - items: languageOptions.map((opt) => ({ |
50 | | - key: opt.value, |
51 | | - label: opt.label, |
52 | | - })), |
53 | | - onClick: ({ key }) => handleLanguageChange(key as string), |
54 | | - }} |
55 | | - > |
56 | | - <a className="ant-dropdown-link text-sm !font-medium text-slate-600 hover:text-slate-900 dark:text-slate-300 dark:hover:text-white transition-colors flex items-center gap-2 cursor-pointer w-[110px] border-0 shadow-none bg-transparent text-left"> |
57 | | - <Globe className="h-4 w-4" /> |
58 | | - {languageOptions.find((o) => o.value === currentLanguage)?.label || |
59 | | - currentLanguage} |
60 | | - <DownOutlined className="text-[10px]" /> |
61 | | - </a> |
62 | | - </Dropdown> |
63 | | - {/* ModelEngine connectivity status */} |
64 | | - <div className="flex items-center px-3 py-1.5 rounded-md border border-slate-200 dark:border-slate-700"> |
65 | | - <Badge |
66 | | - status={connectionStatus} |
67 | | - text={getStatusText()} |
68 | | - className="[&>.ant-badge-status-dot]:w-[8px] [&>.ant-badge-status-dot]:h-[8px] [&>.ant-badge-status-text]:text-base [&>.ant-badge-status-text]:ml-2 [&>.ant-badge-status-text]:font-medium" |
69 | | - /> |
70 | | - <Button |
71 | | - icon={ |
72 | | - <FiRefreshCw |
73 | | - className={isCheckingConnection ? "animate-spin" : ""} |
74 | | - /> |
75 | | - } |
76 | | - size="small" |
77 | | - type="text" |
78 | | - onClick={onCheckConnection} |
79 | | - disabled={isCheckingConnection} |
80 | | - className="ml-2" |
81 | | - /> |
82 | | - </div> |
83 | | - </div> |
84 | | - ); |
85 | | -} |
86 | | - |
87 | 6 | // ================ Navigation ================ |
88 | 7 | interface NavigationProps { |
89 | 8 | onBack?: () => void; |
@@ -179,7 +98,6 @@ interface SetupLayoutProps { |
179 | 98 | /** |
180 | 99 | * SetupLayout - Content wrapper for setup pages |
181 | 100 | * This component should be wrapped by NavigationLayout |
182 | | - * Use SetupHeaderRightContent for customizing the top navbar |
183 | 101 | */ |
184 | 102 | export default function SetupLayout({ |
185 | 103 | children, |
|
0 commit comments