Self-hosted homelab infrastructure visualizer — interactive network diagram with live status monitoring
TypeScript diagramhomelabhomelab-infrastructure-observabilitynetworkproxmox-veself-hostedzigbeezwavezwave-js
feat: hide header View link in standalone mode
Pouzord1c052c9e8e8
diff --git a/frontend/src/components/panels/Toolbar.tsx b/frontend/src/components/panels/Toolbar.tsxindex 87d1d72..6f1b2b5 100644--- a/frontend/src/components/panels/Toolbar.tsx+++ b/frontend/src/components/panels/Toolbar.tsx@@ -4,6 +4,8 @@ import { Button } from '@/components/ui/button'import { Logo } from '@/components/ui/Logo'import { useCanvasStore } from '@/stores/canvasStore'+const STANDALONE = import.meta.env.VITE_STANDALONE === 'true'+interface ToolbarProps {onSave: () => voidonAutoLayout: () => void@@ -82,9 +84,13 @@ export function Toolbar({ onSave, onAutoLayout, onExport, onChangeStyle, onUndo,<Button size="sm" variant="ghost" className="gap-1.5 text-muted-foreground hover:text-foreground cursor-pointer hover:bg-[#21262d]" onClick={onExportMd} title="Copy inventory as Markdown table"><Table2 size={14} /> MD</Button>- <Button size="sm" variant="ghost" className="gap-1.5 text-muted-foreground hover:text-foreground cursor-pointer hover:bg-[#21262d]" onClick={onViewOnly} title="Open read-only live view of this canvas">- <Eye size={14} /> View- </Button>+ {/* Live view reads backend/localStorage canvas; pointless in standalone+ where the editor already shows the only (localStorage) copy. */}+ {!STANDALONE && (+ <Button size="sm" variant="ghost" className="gap-1.5 text-muted-foreground hover:text-foreground cursor-pointer hover:bg-[#21262d]" onClick={onViewOnly} title="Open read-only live view of this canvas">+ <Eye size={14} /> View+ </Button>+ )}<Button size="sm" variant="ghost" className="gap-1.5 text-muted-foreground hover:text-foreground cursor-pointer hover:bg-[#21262d]" onClick={onShortcuts} title="Keyboard shortcuts (?)"><HelpCircle size={14} /></Button>diff --git a/frontend/src/components/panels/__tests__/Toolbar.test.tsx b/frontend/src/components/panels/__tests__/Toolbar.test.tsxindex 0540929..e06cc60 100644--- a/frontend/src/components/panels/__tests__/Toolbar.test.tsx+++ b/frontend/src/components/panels/__tests__/Toolbar.test.tsx@@ -1,4 +1,4 @@-import { describe, it, expect, beforeEach, vi } from 'vitest'+import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'import { render, screen, fireEvent } from '@testing-library/react'import { Toolbar } from '../Toolbar'import { useCanvasStore } from '@/stores/canvasStore'@@ -56,4 +56,33 @@ describe('Toolbar', () => {fireEvent.click(screen.getByText('Save'))expect(defaultProps.onSave).toHaveBeenCalledWith()})++ it('shows the View (live view) link in full mode', () => {+ render(<Toolbar {...defaultProps} />)+ expect(screen.getByText('View')).toBeInTheDocument()+ })+})++// ── Standalone mode ────────────────────────────────────────────────────────────+// VITE_STANDALONE is read at module load, so re-import Toolbar after stubbing it.+describe('Toolbar (standalone)', () => {+ afterEach(() => {+ vi.unstubAllEnvs()+ })++ it('hides the View link (live view is pointless without a backend)', async () => {+ vi.stubEnv('VITE_STANDALONE', 'true')+ vi.resetModules()+ const { useCanvasStore: cs } = await import('@/stores/canvasStore')+ vi.mocked(cs).mockReturnValue({+ hasUnsavedChanges: false, past: [], future: [],+ } as ReturnType<typeof useCanvasStore>)+ const { Toolbar: TB } = await import('../Toolbar')++ render(<TB {...defaultProps} />)+ expect(screen.queryByText('View')).not.toBeInTheDocument()+ // Other actions remain.+ expect(screen.getByText('Save')).toBeInTheDocument()+ expect(screen.getByText('MD')).toBeInTheDocument()+ })})