mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 08:23:34 +00:00
Simplify sidebar navigation
This commit is contained in:
2 files changed
+49
-13
No files matched your search
@@ -19,12 +19,12 @@ vi.mock('@tanstack/react-query', () => ({
|
||||
})
|
||||
}));
|
||||
|
||||
// Mock the LoginArea component
|
||||
vi.mock('@/components/auth/LoginArea', () => ({
|
||||
LoginArea: ({ className }: { className?: string }) => (
|
||||
<div data-testid="login-area" className={className}>Login Area</div>
|
||||
)
|
||||
}));
|
||||
// Mock window.open for help button test
|
||||
const mockWindowOpen = vi.fn();
|
||||
Object.defineProperty(window, 'open', {
|
||||
value: mockWindowOpen,
|
||||
writable: true
|
||||
});
|
||||
|
||||
const mockUseProjects = vi.mocked(useProjects);
|
||||
const mockUseLocalStorage = vi.mocked(useLocalStorage);
|
||||
@@ -81,7 +81,7 @@ describe('ProjectSidebar', () => {
|
||||
expect(screen.queryByLabelText('Collapse sidebar')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders login area at the bottom', () => {
|
||||
it('renders settings and help buttons at the bottom', () => {
|
||||
render(
|
||||
<ProjectSidebar
|
||||
selectedProject={null}
|
||||
@@ -89,7 +89,8 @@ describe('ProjectSidebar', () => {
|
||||
/>
|
||||
);
|
||||
|
||||
expect(screen.getByTestId('login-area')).toBeInTheDocument();
|
||||
expect(screen.getByText('Settings')).toBeInTheDocument();
|
||||
expect(screen.getByLabelText('Help')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows new project button', () => {
|
||||
@@ -102,4 +103,21 @@ describe('ProjectSidebar', () => {
|
||||
|
||||
expect(screen.getByText('New Project')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('opens help documentation when help button is clicked', () => {
|
||||
render(
|
||||
<ProjectSidebar
|
||||
selectedProject={null}
|
||||
onSelectProject={vi.fn()}
|
||||
/>
|
||||
);
|
||||
|
||||
const helpButton = screen.getByLabelText('Help');
|
||||
fireEvent.click(helpButton);
|
||||
|
||||
expect(mockWindowOpen).toHaveBeenCalledWith(
|
||||
'https://soapbox.pub/shakespeare-resources/',
|
||||
'_blank'
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1,10 +1,9 @@
|
||||
import React, { useEffect } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { Plus, Folder, GitBranch, Loader2, ChevronDown, Star, Columns2, X } from 'lucide-react';
|
||||
import { Plus, Folder, GitBranch, Loader2, ChevronDown, Star, Columns2, X, Settings, HelpCircle } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@/components/ui/dropdown-menu';
|
||||
import { LoginArea } from '@/components/auth/LoginArea';
|
||||
import { useProjects } from '@/hooks/useProjects';
|
||||
import { useProjectSessionStatus } from '@/hooks/useProjectSessionStatus';
|
||||
import { useLocalStorage } from '@/hooks/useLocalStorage';
|
||||
@@ -224,9 +223,28 @@ export function ProjectSidebar({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Account Selector at Bottom */}
|
||||
<div className="p-4 border-t border-sidebar-border bg-gradient-to-r from-primary/5 to-accent/5 mt-auto">
|
||||
<LoginArea className="w-full" />
|
||||
{/* Settings and Help at Bottom */}
|
||||
<div className="p-2 border-t border-sidebar-border bg-gradient-to-r from-primary/5 to-accent/5 mt-auto">
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="flex-1 h-9 justify-start gap-2 hover:bg-primary/10 text-sidebar-foreground"
|
||||
onClick={() => navigateAndClose('/settings')}
|
||||
>
|
||||
<Settings className="h-4 w-4" />
|
||||
Settings
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="h-9 w-9 p-0 hover:bg-primary/10 text-sidebar-foreground"
|
||||
onClick={() => window.open('https://soapbox.pub/shakespeare-resources/', '_blank')}
|
||||
aria-label="Help"
|
||||
>
|
||||
<HelpCircle className="h-4 w-4" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user