import { useState, useEffect } from 'react'; import { useAppStore } from '@/store/app-store'; import { Settings, FolderOpen, Menu, X } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { ProjectIdentitySection } from './project-identity-section'; import { ProjectThemeSection } from './project-theme-section'; import { WorktreePreferencesSection } from './worktree-preferences-section'; import { CommandsSection } from './commands-section'; import { ProjectModelsSection } from './project-models-section'; import { DataManagementSection } from './data-management-section'; import { DangerZoneSection } from '../settings-view/danger-zone/danger-zone-section'; import { DeleteProjectDialog } from '../settings-view/components/delete-project-dialog'; import { ProjectSettingsNavigation } from './components/project-settings-navigation'; import { useProjectSettingsView } from './hooks/use-project-settings-view'; import type { Project as ElectronProject } from '@/lib/electron'; // Breakpoint constant for mobile (matches Tailwind lg breakpoint) const LG_BREAKPOINT = 1024; // Convert to the shared types used by components interface SettingsProject { id: string; name: string; path: string; theme?: string; icon?: string; customIconPath?: string; } export function ProjectSettingsView() { const { currentProject, moveProjectToTrash } = useAppStore(); const [showDeleteDialog, setShowDeleteDialog] = useState(false); // Use project settings view navigation hook const { activeView, navigateTo } = useProjectSettingsView(); // Mobile navigation state - default to showing on desktop, hidden on mobile const [showNavigation, setShowNavigation] = useState(() => { if (typeof window !== 'undefined') { return window.innerWidth >= LG_BREAKPOINT; } return true; }); // Auto-close navigation on mobile when a section is selected useEffect(() => { if (typeof window !== 'undefined' && window.innerWidth < LG_BREAKPOINT) { setShowNavigation(false); } }, [activeView]); // Handle window resize to show/hide navigation appropriately useEffect(() => { const handleResize = () => { if (window.innerWidth >= LG_BREAKPOINT) { setShowNavigation(true); } }; window.addEventListener('resize', handleResize); return () => window.removeEventListener('resize', handleResize); }, []); // Convert electron Project to settings-view Project type const convertProject = (project: ElectronProject | null): SettingsProject | null => { if (!project) return null; return { id: project.id, name: project.name, path: project.path, theme: project.theme, icon: project.icon, customIconPath: project.customIconPath, }; }; const settingsProject = convertProject(currentProject); // Render the active section based on current view const renderActiveSection = () => { if (!currentProject) return null; switch (activeView) { case 'identity': return ; case 'theme': return ; case 'worktrees': return ; case 'commands': return ; case 'claude': return ; case 'data': return ; case 'danger': return ( setShowDeleteDialog(true)} /> ); default: return ; } }; // Show message if no project is selected if (!currentProject) { return ( No Project Selected Select a project from the sidebar to configure project-specific settings. ); } return ( {/* Header */} Project Settings Configure settings for {currentProject.name} {/* Mobile menu button - far right */} setShowNavigation(!showNavigation)} className="lg:hidden h-8 w-8 p-0" aria-label={showNavigation ? 'Close navigation menu' : 'Open navigation menu'} > {showNavigation ? : } {/* Content Area with Sidebar */} {/* Side Navigation */} setShowNavigation(false)} /> {/* Content Panel - Shows only the active section */} {renderActiveSection()} {/* Delete Project Confirmation Dialog */} ); }
Select a project from the sidebar to configure project-specific settings.
Configure settings for {currentProject.name}