mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
refactor(dashboard): reorganize menu actions across sidebar/header/profile
Move shutdown into header popup + profile, move remote into sidebar above settings, add flag-only language switcher in header, and add language card plus shutdown/logout actions to the profile page. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,13 +1,32 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useState, useEffect, useRef } from "react";
|
import { useState, useEffect, useRef } from "react";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
import { Card, Button, Toggle, Input } from "@/shared/components";
|
import { Card, Button, Toggle, Input } from "@/shared/components";
|
||||||
|
import { ConfirmModal } from "@/shared/components/Modal";
|
||||||
|
import LanguageSwitcher from "@/shared/components/LanguageSwitcher";
|
||||||
import { useTheme } from "@/shared/hooks/useTheme";
|
import { useTheme } from "@/shared/hooks/useTheme";
|
||||||
import { cn } from "@/shared/utils/cn";
|
import { cn } from "@/shared/utils/cn";
|
||||||
import { APP_CONFIG } from "@/shared/constants/config";
|
import { APP_CONFIG } from "@/shared/constants/config";
|
||||||
|
import { LOCALE_COOKIE, normalizeLocale } from "@/i18n/config";
|
||||||
|
import { LOCALE_FLAGS } from "@/shared/constants/locales";
|
||||||
|
|
||||||
|
function getLocaleFromCookie() {
|
||||||
|
if (typeof document === "undefined") return "en";
|
||||||
|
const cookie = document.cookie
|
||||||
|
.split(";")
|
||||||
|
.find((c) => c.trim().startsWith(`${LOCALE_COOKIE}=`));
|
||||||
|
const value = cookie ? decodeURIComponent(cookie.split("=")[1]) : "en";
|
||||||
|
return normalizeLocale(value);
|
||||||
|
}
|
||||||
|
|
||||||
export default function ProfilePage() {
|
export default function ProfilePage() {
|
||||||
|
const router = useRouter();
|
||||||
const { theme, setTheme, isDark } = useTheme();
|
const { theme, setTheme, isDark } = useTheme();
|
||||||
|
const [locale, setLocale] = useState("en");
|
||||||
|
const [langOpen, setLangOpen] = useState(false);
|
||||||
|
const [shutdownOpen, setShutdownOpen] = useState(false);
|
||||||
|
const [isShuttingDown, setIsShuttingDown] = useState(false);
|
||||||
const [settings, setSettings] = useState({ fallbackStrategy: "fill-first" });
|
const [settings, setSettings] = useState({ fallbackStrategy: "fill-first" });
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [passwords, setPasswords] = useState({ current: "", new: "", confirm: "" });
|
const [passwords, setPasswords] = useState({ current: "", new: "", confirm: "" });
|
||||||
@@ -39,6 +58,10 @@ export default function ProfilePage() {
|
|||||||
const [proxyLoading, setProxyLoading] = useState(false);
|
const [proxyLoading, setProxyLoading] = useState(false);
|
||||||
const [proxyTestLoading, setProxyTestLoading] = useState(false);
|
const [proxyTestLoading, setProxyTestLoading] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setLocale(getLocaleFromCookie());
|
||||||
|
}, [langOpen]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetch("/api/settings")
|
fetch("/api/settings")
|
||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
@@ -515,6 +538,29 @@ export default function ProfilePage() {
|
|||||||
|
|
||||||
const observabilityEnabled = settings.enableObservability === true;
|
const observabilityEnabled = settings.enableObservability === true;
|
||||||
|
|
||||||
|
const handleShutdown = async () => {
|
||||||
|
setIsShuttingDown(true);
|
||||||
|
try {
|
||||||
|
await fetch("/api/version/shutdown", { method: "POST" });
|
||||||
|
} catch (e) {
|
||||||
|
// Expected to fail as server shuts down; ignore error
|
||||||
|
}
|
||||||
|
setIsShuttingDown(false);
|
||||||
|
setShutdownOpen(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleLogout = async () => {
|
||||||
|
try {
|
||||||
|
const res = await fetch("/api/auth/logout", { method: "POST" });
|
||||||
|
if (res.ok) {
|
||||||
|
router.push("/login");
|
||||||
|
router.refresh();
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Failed to logout:", err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="max-w-2xl mx-auto px-4 sm:px-0">
|
<div className="max-w-2xl mx-auto px-4 sm:px-0">
|
||||||
<div className="flex flex-col gap-6">
|
<div className="flex flex-col gap-6">
|
||||||
@@ -593,6 +639,24 @@ export default function ProfilePage() {
|
|||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
{/* Language */}
|
||||||
|
<Card>
|
||||||
|
<div className="flex items-center gap-3 mb-4">
|
||||||
|
<div className="size-10 rounded-lg bg-blue-500/10 text-blue-500 flex items-center justify-center shrink-0">
|
||||||
|
<span className="material-symbols-outlined text-[20px]">language</span>
|
||||||
|
</div>
|
||||||
|
<h3 className="text-base sm:text-lg font-semibold">Language</h3>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
onClick={() => setLangOpen(true)}
|
||||||
|
className="flex items-center justify-between w-full p-3 rounded-lg bg-bg border border-border hover:border-primary/50 transition-colors"
|
||||||
|
data-i18n-skip="true"
|
||||||
|
>
|
||||||
|
<span className="text-sm text-text-muted">Display language</span>
|
||||||
|
<span className="text-2xl">{LOCALE_FLAGS[locale] || "🌐"}</span>
|
||||||
|
</button>
|
||||||
|
</Card>
|
||||||
|
|
||||||
{/* Security */}
|
{/* Security */}
|
||||||
<Card>
|
<Card>
|
||||||
<div className="flex items-center gap-3 mb-4">
|
<div className="flex items-center gap-3 mb-4">
|
||||||
@@ -1024,12 +1088,53 @@ export default function ProfilePage() {
|
|||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
{/* Account actions */}
|
||||||
|
<div className="flex flex-col sm:flex-row gap-2">
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
fullWidth
|
||||||
|
icon="power_settings_new"
|
||||||
|
onClick={() => setShutdownOpen(true)}
|
||||||
|
className="text-red-500 border-red-200 hover:bg-red-50 hover:border-red-300"
|
||||||
|
>
|
||||||
|
Shutdown
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
fullWidth
|
||||||
|
icon="logout"
|
||||||
|
onClick={handleLogout}
|
||||||
|
>
|
||||||
|
Logout
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* App Info */}
|
{/* App Info */}
|
||||||
<div className="text-center text-xs sm:text-sm text-text-muted py-4">
|
<div className="text-center text-xs sm:text-sm text-text-muted py-4">
|
||||||
<p>{APP_CONFIG.name} v{APP_CONFIG.version}</p>
|
<p>{APP_CONFIG.name} v{APP_CONFIG.version}</p>
|
||||||
<p className="mt-1">Local Mode - All data stored on your machine</p>
|
<p className="mt-1">Local Mode - All data stored on your machine</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<LanguageSwitcher
|
||||||
|
hideTrigger
|
||||||
|
isOpen={langOpen}
|
||||||
|
onClose={(next) => {
|
||||||
|
setLangOpen(false);
|
||||||
|
setLocale(next);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<ConfirmModal
|
||||||
|
isOpen={shutdownOpen}
|
||||||
|
onClose={() => setShutdownOpen(false)}
|
||||||
|
onConfirm={handleShutdown}
|
||||||
|
title="Close Proxy"
|
||||||
|
message="Are you sure you want to close the proxy server?"
|
||||||
|
confirmText="Close"
|
||||||
|
cancelText="Cancel"
|
||||||
|
variant="danger"
|
||||||
|
loading={isShuttingDown}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import Link from "next/link";
|
|||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import ProviderIcon from "@/shared/components/ProviderIcon";
|
import ProviderIcon from "@/shared/components/ProviderIcon";
|
||||||
import HeaderMenu from "@/shared/components/HeaderMenu";
|
import HeaderMenu from "@/shared/components/HeaderMenu";
|
||||||
|
import HeaderLanguage from "@/shared/components/HeaderLanguage";
|
||||||
import ThemeToggle from "@/shared/components/ThemeToggle";
|
import ThemeToggle from "@/shared/components/ThemeToggle";
|
||||||
import DonateModal from "@/shared/components/DonateModal";
|
import DonateModal from "@/shared/components/DonateModal";
|
||||||
import { useHeaderSearchStore } from "@/store/headerSearchStore";
|
import { useHeaderSearchStore } from "@/store/headerSearchStore";
|
||||||
@@ -315,6 +316,7 @@ export default function Header({ onMenuClick, showMenuButton = true }) {
|
|||||||
<span className="hidden sm:inline">Donate</span>
|
<span className="hidden sm:inline">Donate</span>
|
||||||
</button>
|
</button>
|
||||||
<ThemeToggle />
|
<ThemeToggle />
|
||||||
|
<HeaderLanguage />
|
||||||
<HeaderMenu onLogout={handleLogout} />
|
<HeaderMenu onLogout={handleLogout} />
|
||||||
</div>
|
</div>
|
||||||
<DonateModal isOpen={donateOpen} onClose={() => setDonateOpen(false)} />
|
<DonateModal isOpen={donateOpen} onClose={() => setDonateOpen(false)} />
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useState, useEffect } from "react";
|
||||||
|
import { LOCALE_COOKIE, normalizeLocale } from "@/i18n/config";
|
||||||
|
import { LOCALE_FLAGS } from "@/shared/constants/locales";
|
||||||
|
import LanguageSwitcher from "./LanguageSwitcher";
|
||||||
|
|
||||||
|
function getLocaleFromCookie() {
|
||||||
|
if (typeof document === "undefined") return "en";
|
||||||
|
const cookie = document.cookie
|
||||||
|
.split(";")
|
||||||
|
.find((c) => c.trim().startsWith(`${LOCALE_COOKIE}=`));
|
||||||
|
const value = cookie ? decodeURIComponent(cookie.split("=")[1]) : "en";
|
||||||
|
return normalizeLocale(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function HeaderLanguage() {
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const [locale, setLocale] = useState("en");
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setLocale(getLocaleFromCookie());
|
||||||
|
}, [open]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<button
|
||||||
|
onClick={() => setOpen(true)}
|
||||||
|
className="flex items-center justify-center p-2 rounded-lg text-text-muted hover:text-text-main hover:bg-black/5 dark:hover:bg-white/5 transition-all"
|
||||||
|
title="Language"
|
||||||
|
data-i18n-skip="true"
|
||||||
|
>
|
||||||
|
<span className="text-lg leading-none">{LOCALE_FLAGS[locale] || "🌐"}</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<LanguageSwitcher
|
||||||
|
hideTrigger
|
||||||
|
isOpen={open}
|
||||||
|
onClose={(next) => {
|
||||||
|
setOpen(false);
|
||||||
|
setLocale(next);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -2,56 +2,9 @@
|
|||||||
|
|
||||||
import { useState, useEffect, useRef } from "react";
|
import { useState, useEffect, useRef } from "react";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import { LOCALE_COOKIE, normalizeLocale } from "@/i18n/config";
|
|
||||||
import { useTheme } from "@/shared/hooks/useTheme";
|
import { useTheme } from "@/shared/hooks/useTheme";
|
||||||
import ChangelogModal from "./ChangelogModal";
|
import ChangelogModal from "./ChangelogModal";
|
||||||
import NineRemotePromoModal from "./NineRemotePromoModal";
|
import { ConfirmModal } from "./Modal";
|
||||||
import LanguageSwitcher from "./LanguageSwitcher";
|
|
||||||
|
|
||||||
const LOCALE_INFO = {
|
|
||||||
"en": { name: "English", flag: "🇺🇸" },
|
|
||||||
"vi": { name: "Tiếng Việt", flag: "🇻🇳" },
|
|
||||||
"zh-CN": { name: "简体中文", flag: "🇨🇳" },
|
|
||||||
"zh-TW": { name: "繁體中文", flag: "🇹🇼" },
|
|
||||||
"ja": { name: "日本語", flag: "🇯🇵" },
|
|
||||||
"pt-BR": { name: "Português (BR)", flag: "🇧🇷" },
|
|
||||||
"pt-PT": { name: "Português (PT)", flag: "🇵🇹" },
|
|
||||||
"ko": { name: "한국어", flag: "🇰🇷" },
|
|
||||||
"es": { name: "Español", flag: "🇪🇸" },
|
|
||||||
"de": { name: "Deutsch", flag: "🇩🇪" },
|
|
||||||
"fr": { name: "Français", flag: "🇫🇷" },
|
|
||||||
"he": { name: "עברית", flag: "🇮🇱" },
|
|
||||||
"ar": { name: "العربية", flag: "🇸🇦" },
|
|
||||||
"ru": { name: "Русский", flag: "🇷🇺" },
|
|
||||||
"pl": { name: "Polski", flag: "🇵🇱" },
|
|
||||||
"cs": { name: "Čeština", flag: "🇨🇿" },
|
|
||||||
"nl": { name: "Nederlands", flag: "🇳🇱" },
|
|
||||||
"tr": { name: "Türkçe", flag: "🇹🇷" },
|
|
||||||
"uk": { name: "Українська", flag: "🇺🇦" },
|
|
||||||
"tl": { name: "Tagalog", flag: "🇵🇭" },
|
|
||||||
"id": { name: "Indonesia", flag: "🇮🇩" },
|
|
||||||
"th": { name: "ไทย", flag: "🇹🇭" },
|
|
||||||
"hi": { name: "हिन्दी", flag: "🇮🇳" },
|
|
||||||
"bn": { name: "বাংলা", flag: "🇧🇩" },
|
|
||||||
"ur": { name: "اردو", flag: "🇵🇰" },
|
|
||||||
"ro": { name: "Română", flag: "🇷🇴" },
|
|
||||||
"sv": { name: "Svenska", flag: "🇸🇪" },
|
|
||||||
"it": { name: "Italiano", flag: "🇮🇹" },
|
|
||||||
"el": { name: "Ελληνικά", flag: "🇬🇷" },
|
|
||||||
"hu": { name: "Magyar", flag: "🇭🇺" },
|
|
||||||
"fi": { name: "Suomi", flag: "🇫🇮" },
|
|
||||||
"da": { name: "Dansk", flag: "🇩🇰" },
|
|
||||||
"no": { name: "Norsk", flag: "🇳🇴" },
|
|
||||||
};
|
|
||||||
|
|
||||||
function getLocaleFromCookie() {
|
|
||||||
if (typeof document === "undefined") return "en";
|
|
||||||
const cookie = document.cookie
|
|
||||||
.split(";")
|
|
||||||
.find((c) => c.trim().startsWith(`${LOCALE_COOKIE}=`));
|
|
||||||
const value = cookie ? decodeURIComponent(cookie.split("=")[1]) : "en";
|
|
||||||
return normalizeLocale(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
function MenuItem({ icon, label, onClick, trailing, danger }) {
|
function MenuItem({ icon, label, onClick, trailing, danger }) {
|
||||||
return (
|
return (
|
||||||
@@ -83,15 +36,21 @@ MenuItem.propTypes = {
|
|||||||
export default function HeaderMenu({ onLogout }) {
|
export default function HeaderMenu({ onLogout }) {
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
const [changelogOpen, setChangelogOpen] = useState(false);
|
const [changelogOpen, setChangelogOpen] = useState(false);
|
||||||
const [remoteOpen, setRemoteOpen] = useState(false);
|
const [shutdownOpen, setShutdownOpen] = useState(false);
|
||||||
const [langOpen, setLangOpen] = useState(false);
|
const [isShuttingDown, setIsShuttingDown] = useState(false);
|
||||||
const [locale, setLocale] = useState("en");
|
|
||||||
const { toggleTheme, isDark } = useTheme();
|
const { toggleTheme, isDark } = useTheme();
|
||||||
const menuRef = useRef(null);
|
const menuRef = useRef(null);
|
||||||
|
|
||||||
useEffect(() => {
|
const handleShutdown = async () => {
|
||||||
setLocale(getLocaleFromCookie());
|
setIsShuttingDown(true);
|
||||||
}, [langOpen]);
|
try {
|
||||||
|
await fetch("/api/version/shutdown", { method: "POST" });
|
||||||
|
} catch (e) {
|
||||||
|
// Expected to fail as server shuts down; ignore error
|
||||||
|
}
|
||||||
|
setIsShuttingDown(false);
|
||||||
|
setShutdownOpen(false);
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleClickOutside = (e) => {
|
const handleClickOutside = (e) => {
|
||||||
@@ -125,21 +84,16 @@ export default function HeaderMenu({ onLogout }) {
|
|||||||
label="Change Log"
|
label="Change Log"
|
||||||
onClick={() => { close(); setChangelogOpen(true); }}
|
onClick={() => { close(); setChangelogOpen(true); }}
|
||||||
/>
|
/>
|
||||||
<MenuItem
|
|
||||||
icon="language"
|
|
||||||
label={LOCALE_INFO[locale]?.name || locale}
|
|
||||||
trailing={LOCALE_INFO[locale]?.flag || "🌐"}
|
|
||||||
onClick={() => { close(); setLangOpen(true); }}
|
|
||||||
/>
|
|
||||||
<MenuItem
|
<MenuItem
|
||||||
icon={isDark ? "light_mode" : "dark_mode"}
|
icon={isDark ? "light_mode" : "dark_mode"}
|
||||||
label="Theme"
|
label="Theme"
|
||||||
onClick={() => { toggleTheme(); close(); }}
|
onClick={() => { toggleTheme(); close(); }}
|
||||||
/>
|
/>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
icon="computer"
|
icon="power_settings_new"
|
||||||
label="Remote"
|
label="Shutdown"
|
||||||
onClick={() => { close(); setRemoteOpen(true); }}
|
danger
|
||||||
|
onClick={() => { close(); setShutdownOpen(true); }}
|
||||||
/>
|
/>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
icon="logout"
|
icon="logout"
|
||||||
@@ -152,11 +106,17 @@ export default function HeaderMenu({ onLogout }) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ChangelogModal isOpen={changelogOpen} onClose={() => setChangelogOpen(false)} />
|
<ChangelogModal isOpen={changelogOpen} onClose={() => setChangelogOpen(false)} />
|
||||||
<NineRemotePromoModal isOpen={remoteOpen} onClose={() => setRemoteOpen(false)} />
|
<ConfirmModal
|
||||||
<LanguageSwitcher hideTrigger isOpen={langOpen} onClose={((locale) => {
|
isOpen={shutdownOpen}
|
||||||
setLangOpen(false)
|
onClose={() => setShutdownOpen(false)}
|
||||||
setLocale(locale)
|
onConfirm={handleShutdown}
|
||||||
})} />
|
title="Close Proxy"
|
||||||
|
message="Are you sure you want to close the proxy server?"
|
||||||
|
confirmText="Close"
|
||||||
|
cancelText="Cancel"
|
||||||
|
variant="danger"
|
||||||
|
loading={isShuttingDown}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { MEDIA_PROVIDER_KINDS } from "@/shared/constants/providers";
|
|||||||
import { useCopyToClipboard } from "@/shared/hooks/useCopyToClipboard";
|
import { useCopyToClipboard } from "@/shared/hooks/useCopyToClipboard";
|
||||||
import Button from "./Button";
|
import Button from "./Button";
|
||||||
import { ConfirmModal } from "./Modal";
|
import { ConfirmModal } from "./Modal";
|
||||||
|
import NineRemotePromoModal from "./NineRemotePromoModal";
|
||||||
|
|
||||||
// const VISIBLE_MEDIA_KINDS = ["embedding", "image", "imageToText", "tts", "stt", "webSearch", "webFetch", "video", "music"];
|
// const VISIBLE_MEDIA_KINDS = ["embedding", "image", "imageToText", "tts", "stt", "webSearch", "webFetch", "video", "music"];
|
||||||
const VISIBLE_MEDIA_KINDS = ["embedding", "image", "tts", "stt"];
|
const VISIBLE_MEDIA_KINDS = ["embedding", "image", "tts", "stt"];
|
||||||
@@ -40,8 +41,7 @@ const systemItems = [
|
|||||||
export default function Sidebar({ onClose }) {
|
export default function Sidebar({ onClose }) {
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const [mediaOpen, setMediaOpen] = useState(false);
|
const [mediaOpen, setMediaOpen] = useState(false);
|
||||||
const [showShutdownModal, setShowShutdownModal] = useState(false);
|
const [showRemoteModal, setShowRemoteModal] = useState(false);
|
||||||
const [isShuttingDown, setIsShuttingDown] = useState(false);
|
|
||||||
const [isDisconnected, setIsDisconnected] = useState(false);
|
const [isDisconnected, setIsDisconnected] = useState(false);
|
||||||
const [updateInfo, setUpdateInfo] = useState(null);
|
const [updateInfo, setUpdateInfo] = useState(null);
|
||||||
const [showUpdateModal, setShowUpdateModal] = useState(false);
|
const [showUpdateModal, setShowUpdateModal] = useState(false);
|
||||||
@@ -106,18 +106,6 @@ export default function Sidebar({ onClose }) {
|
|||||||
// user runs the command manually in another terminal.
|
// user runs the command manually in another terminal.
|
||||||
|
|
||||||
|
|
||||||
const handleShutdown = async () => {
|
|
||||||
setIsShuttingDown(true);
|
|
||||||
try {
|
|
||||||
await fetch("/api/version/shutdown", { method: "POST" });
|
|
||||||
} catch (e) {
|
|
||||||
// Expected to fail as server shuts down; ignore error
|
|
||||||
}
|
|
||||||
setIsShuttingDown(false);
|
|
||||||
setShowShutdownModal(false);
|
|
||||||
setIsDisconnected(true);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<aside className="flex w-72 flex-col border-r border-border-subtle bg-vibrancy backdrop-blur-xl transition-colors duration-300 min-h-full">
|
<aside className="flex w-72 flex-col border-r border-border-subtle bg-vibrancy backdrop-blur-xl transition-colors duration-300 min-h-full">
|
||||||
@@ -302,6 +290,20 @@ export default function Sidebar({ onClose }) {
|
|||||||
) : null;
|
) : null;
|
||||||
})}
|
})}
|
||||||
|
|
||||||
|
{/* Remote */}
|
||||||
|
<button
|
||||||
|
onClick={() => setShowRemoteModal(true)}
|
||||||
|
className={cn(
|
||||||
|
"flex items-center gap-3 px-3 py-1 rounded-lg transition-all group w-full",
|
||||||
|
"text-text-muted hover:bg-surface-2 hover:text-text-main"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<span className="material-symbols-outlined text-[18px] group-hover:text-primary transition-colors">
|
||||||
|
computer
|
||||||
|
</span>
|
||||||
|
<span className="text-[13px] font-medium">Remote</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
{/* Settings */}
|
{/* Settings */}
|
||||||
<Link
|
<Link
|
||||||
href="/dashboard/profile"
|
href="/dashboard/profile"
|
||||||
@@ -326,33 +328,10 @@ export default function Sidebar({ onClose }) {
|
|||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
{/* Footer section */}
|
|
||||||
<div className="p-3 border-t border-border-subtle">
|
|
||||||
{/* Shutdown button */}
|
|
||||||
<Button
|
|
||||||
variant="outline"
|
|
||||||
fullWidth
|
|
||||||
icon="power_settings_new"
|
|
||||||
onClick={() => setShowShutdownModal(true)}
|
|
||||||
className="text-red-500 border-red-200 hover:bg-red-50 hover:border-red-300"
|
|
||||||
>
|
|
||||||
Shutdown
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
{/* Shutdown Confirmation Modal */}
|
{/* Remote Promo Modal */}
|
||||||
<ConfirmModal
|
<NineRemotePromoModal isOpen={showRemoteModal} onClose={() => setShowRemoteModal(false)} />
|
||||||
isOpen={showShutdownModal}
|
|
||||||
onClose={() => setShowShutdownModal(false)}
|
|
||||||
onConfirm={handleShutdown}
|
|
||||||
title="Close Proxy"
|
|
||||||
message="Are you sure you want to close the proxy server?"
|
|
||||||
confirmText="Close"
|
|
||||||
cancelText="Cancel"
|
|
||||||
variant="danger"
|
|
||||||
loading={isShuttingDown}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* Update Confirmation Modal */}
|
{/* Update Confirmation Modal */}
|
||||||
<ConfirmModal
|
<ConfirmModal
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
// Centralized locale display flags (shared across UI components)
|
||||||
|
export const LOCALE_FLAGS = {
|
||||||
|
"en": "🇺🇸",
|
||||||
|
"vi": "🇻🇳",
|
||||||
|
"zh-CN": "🇨🇳",
|
||||||
|
"zh-TW": "🇹🇼",
|
||||||
|
"ja": "🇯🇵",
|
||||||
|
"pt-BR": "🇧🇷",
|
||||||
|
"pt-PT": "🇵🇹",
|
||||||
|
"ko": "🇰🇷",
|
||||||
|
"es": "🇪🇸",
|
||||||
|
"de": "🇩🇪",
|
||||||
|
"fr": "🇫🇷",
|
||||||
|
"he": "🇮🇱",
|
||||||
|
"ar": "🇸🇦",
|
||||||
|
"ru": "🇷🇺",
|
||||||
|
"pl": "🇵🇱",
|
||||||
|
"cs": "🇨🇿",
|
||||||
|
"nl": "🇳🇱",
|
||||||
|
"tr": "🇹🇷",
|
||||||
|
"uk": "🇺🇦",
|
||||||
|
"tl": "🇵🇭",
|
||||||
|
"id": "🇮🇩",
|
||||||
|
"th": "🇹🇭",
|
||||||
|
"hi": "🇮🇳",
|
||||||
|
"bn": "🇧🇩",
|
||||||
|
"ur": "🇵🇰",
|
||||||
|
"ro": "🇷🇴",
|
||||||
|
"sv": "🇸🇪",
|
||||||
|
"it": "🇮🇹",
|
||||||
|
"el": "🇬🇷",
|
||||||
|
"hu": "🇭🇺",
|
||||||
|
"fi": "🇫🇮",
|
||||||
|
"da": "🇩🇰",
|
||||||
|
"no": "🇳🇴",
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user