improve server tabs by type and viewport
Build and publish Docker image / build-and-publish (push) Successful in 14s
Build and publish Docker image / build-and-publish (push) Successful in 14s
This commit is contained in:
1 parent
afc69d61a9
commit
b539a38f26
2 files changed
+41
-13
No files matched your search
@@ -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 }) => {
|
||||
</div>
|
||||
|
||||
<div className="border-b bg-black/10" style={{ borderColor: colors.brightBlack }}>
|
||||
<div className="flex space-x-1 px-6">
|
||||
<div role="tablist" aria-label="Server sections" className="grid grid-cols-2 min-[480px]:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-1 p-2 sm:p-3">
|
||||
{[
|
||||
{ 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 (
|
||||
<button
|
||||
key={tab.id}
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={isActive}
|
||||
aria-controls="server-details-content"
|
||||
id={`server-details-tab-${tab.id}`}
|
||||
onClick={() => setActiveTab(tab.id)}
|
||||
className={`flex items-center space-x-2 px-5 py-4 text-sm font-bold border-b-2 transition-all duration-200 ${
|
||||
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 ${
|
||||
isActive ? '' : 'border-transparent opacity-50 hover:opacity-100 hover:bg-white/5'
|
||||
} ${tab.important && !isActive ? 'text-primary' : ''}`}
|
||||
style={{
|
||||
@@ -570,15 +586,15 @@ const ServerDetailsModal = ({ server, onClose, onServerAction, showAlert }) => {
|
||||
color: isActive ? colors.blue : (tab.important ? colors.primary : colors.foreground)
|
||||
}}
|
||||
>
|
||||
<Icon className={`w-4 h-4 ${tab.important && !isActive ? 'animate-pulse' : ''}`} />
|
||||
<span className="tracking-tight">{tab.label}</span>
|
||||
<Icon className={`w-4 h-4 shrink-0 ${tab.important && !isActive ? 'animate-pulse' : ''}`} />
|
||||
<span className="min-w-0 truncate">{tab.label}</span>
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex-1 overflow-y-auto p-4 sm:p-8 custom-scrollbar bg-black/5 w-full">
|
||||
<div id="server-details-content" role="tabpanel" aria-labelledby={`server-details-tab-${activeTab}`} className="flex-1 overflow-y-auto p-4 sm:p-8 custom-scrollbar bg-black/5 w-full">
|
||||
{activeTab === 'overview' && (
|
||||
<div className="space-y-8 w-full max-w-full animate-in fade-in slide-in-from-bottom-2 duration-300">
|
||||
|
||||
|
||||
@@ -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) => {
|
||||
</div>
|
||||
|
||||
<div className="border-b border-dash-border bg-black/5 shrink-0">
|
||||
<div role="tablist" aria-label="Server sections" className="flex space-x-1 px-6 overflow-x-auto custom-scrollbar">
|
||||
<div role="tablist" aria-label="Server sections" className="grid grid-cols-2 min-[480px]:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-1 p-2 sm:p-3">
|
||||
{[
|
||||
{ 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'
|
||||
}`}
|
||||
>
|
||||
<Icon className="w-3.5 h-3.5" />
|
||||
<span>{tab.label}</span>
|
||||
<Icon className="w-4 h-4 shrink-0" />
|
||||
<span className="min-w-0 truncate">{tab.label}</span>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
|
||||
Reference in new issue
Block a user