From b539a38f26c168a44833a140afbb8406e894a7be Mon Sep 17 00:00:00 2001 From: "Wiktor A. Falkowski" Date: Fri, 23 Oct 2026 21:50:53 +0000 Subject: [PATCH] improve server tabs by type and viewport --- src/features/servers/ServerDetailsModal.jsx | 30 ++++++++++++++++----- src/pages/DashboardPage.jsx | 24 ++++++++++++----- 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/src/features/servers/ServerDetailsModal.jsx b/src/features/servers/ServerDetailsModal.jsx index 1f47f6e..fd902bc 100644 --- a/src/features/servers/ServerDetailsModal.jsx +++ b/src/features/servers/ServerDetailsModal.jsx @@ -70,6 +70,15 @@ const ServerDetailsModal = ({ server, onClose, onServerAction, showAlert }) => { const [mcSettings, setMcSettings] = useState(null); const [isMcSettingsLoading, setIsMcSettingsLoading] = useState(false); + useEffect(() => { + const terminalUnavailable = ['vps', 'website', 'game'].includes(server?.type); + const logsUnavailable = server?.type === 'vps'; + if ((activeTab === 'terminal' && terminalUnavailable) || + (activeTab === 'logs' && logsUnavailable)) { + setActiveTab('overview'); + } + }, [server?.id, server?.type, activeTab]); + // Initialize version, loader and java version state when server loads or edit mode opens useEffect(() => { if (server) { @@ -531,7 +540,7 @@ const ServerDetailsModal = ({ server, onClose, onServerAction, showAlert }) => {
-
+
{[ { id: 'overview', label: 'Overview', icon: Info }, ...(server.type === 'game' ? @@ -553,16 +562,23 @@ const ServerDetailsModal = ({ server, onClose, onServerAction, showAlert }) => { ] : []), { id: 'network', label: 'Network', icon: NetworkIcon }, { id: 'backups', label: 'Backups', icon: Database, important: true }, - { id: 'terminal', label: 'Terminal', icon: Terminal }, - { id: 'logs', label: 'Logs', icon: FileText } + ...(['vps', 'website', 'game'].includes(server.type) + ? [] + : [{ id: 'terminal', label: 'Terminal', icon: Terminal }]), + ...(server.type === 'vps' ? [] : [{ id: 'logs', label: 'Logs', icon: FileText }]) ].map((tab) => { const Icon = tab.icon; const isActive = activeTab === tab.id; return ( ) })}
-
+
{activeTab === 'overview' && (
diff --git a/src/pages/DashboardPage.jsx b/src/pages/DashboardPage.jsx index 3b925de..c5d9a28 100644 --- a/src/pages/DashboardPage.jsx +++ b/src/pages/DashboardPage.jsx @@ -427,6 +427,15 @@ function DashboardPage({ setIsLoginOpen, setIsRegisterOpen, onCurrencyChange, pr const [userCredits, setUserCredits] = useState(user?.credits || 0); const [isMobileSidebarOpen, setIsMobileSidebarOpen] = useState(false); const [activeServerDetailTab, setActiveServerDetailTab] = useState('overview'); + + useEffect(() => { + const terminalUnavailable = ['vps', 'website', 'game'].includes(selectedServer?.type); + const logsUnavailable = selectedServer?.type === 'vps'; + if ((activeServerDetailTab === 'terminal' && terminalUnavailable) || + (activeServerDetailTab === 'logs' && logsUnavailable)) { + setActiveServerDetailTab('overview'); + } + }, [selectedServer?.id, selectedServer?.type, activeServerDetailTab]); // Ref for sendMessage to break circular dependency const sendMessageRef = useRef(null); @@ -2935,7 +2944,7 @@ const handleWebSocketMessage = useCallback((data) => {
-
+
{[ { id: 'overview', label: 'Overview', icon: Info }, ...(selectedServer.type === 'game' @@ -2952,8 +2961,10 @@ const handleWebSocketMessage = useCallback((data) => { ...(selectedServer.type !== 'database' && selectedServer.type !== 'vps' ? [{ id: 'files', label: 'Files', icon: Folder }] : []), - { id: 'terminal', label: 'Terminal', icon: Terminal }, - { id: 'logs', label: 'Logs', icon: FileText }, + ...(['vps', 'website', 'game'].includes(selectedServer.type) + ? [] + : [{ id: 'terminal', label: 'Terminal', icon: Terminal }]), + ...(selectedServer.type === 'vps' ? [] : [{ id: 'logs', label: 'Logs', icon: FileText }]), { id: 'network', label: 'Network', icon: NetworkIcon }, { id: 'backups', label: 'Backups', icon: Database }, ].map((tab) => { @@ -2970,14 +2981,15 @@ const handleWebSocketMessage = useCallback((data) => { setActiveServerDetailTab(tab.id); if (tab.id !== 'network') setShowPortMappingGuide(false); }} - className={`flex items-center space-x-2 px-5 py-4 text-xs font-bold uppercase tracking-widest border-b-2 transition-all duration-200 ${ + aria-controls="server-detail-panel" + className={`flex min-w-0 min-h-11 items-center justify-center sm:justify-start gap-2 rounded px-2 sm:px-3 py-2 text-[10px] sm:text-xs font-bold uppercase tracking-wide sm:tracking-wider border-b-2 transition-colors duration-200 ${ active ? 'border-primary text-primary bg-primary/5' : 'border-transparent text-dash-textMuted hover:text-dash-text hover:bg-white/5' }`} > - - {tab.label} + + {tab.label} ); })}