feat: Dokploy-style sidebar layout for site pages
Sidebar takes full viewport height with Pulse logo at top. No Header on site pages — UtilityBar in content area provides theme toggle, app launcher, notifications, and user menu. Non-site authenticated pages keep static Header. No footer on dashboard pages.
This commit is contained in:
@@ -8,6 +8,7 @@ import { useAuth } from '@/lib/auth/context'
|
|||||||
import { useOnlineStatus } from '@/lib/hooks/useOnlineStatus'
|
import { useOnlineStatus } from '@/lib/hooks/useOnlineStatus'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
|
import { usePathname } from 'next/navigation'
|
||||||
import { logger } from '@/lib/utils/logger'
|
import { logger } from '@/lib/utils/logger'
|
||||||
import { getUserOrganizations, switchContext, type OrganizationMember } from '@/lib/api/organization'
|
import { getUserOrganizations, switchContext, type OrganizationMember } from '@/lib/api/organization'
|
||||||
import { setSessionAction } from '@/app/actions/auth'
|
import { setSessionAction } from '@/app/actions/auth'
|
||||||
@@ -15,11 +16,10 @@ import { LoadingOverlay } from '@ciphera-net/ui'
|
|||||||
import { useRouter } from 'next/navigation'
|
import { useRouter } from 'next/navigation'
|
||||||
import { SettingsModalProvider, useSettingsModal } from '@/lib/settings-modal-context'
|
import { SettingsModalProvider, useSettingsModal } from '@/lib/settings-modal-context'
|
||||||
import SettingsModalWrapper from '@/components/settings/SettingsModalWrapper'
|
import SettingsModalWrapper from '@/components/settings/SettingsModalWrapper'
|
||||||
import { SidebarProvider, useSidebar } from '@/lib/sidebar-context'
|
import { SidebarProvider } from '@/lib/sidebar-context'
|
||||||
|
|
||||||
const ORG_SWITCH_KEY = 'pulse_switching_org'
|
const ORG_SWITCH_KEY = 'pulse_switching_org'
|
||||||
|
|
||||||
// * Available Ciphera apps for the app switcher
|
|
||||||
const CIPHERA_APPS: CipheraApp[] = [
|
const CIPHERA_APPS: CipheraApp[] = [
|
||||||
{
|
{
|
||||||
id: 'pulse',
|
id: 'pulse',
|
||||||
@@ -27,7 +27,7 @@ const CIPHERA_APPS: CipheraApp[] = [
|
|||||||
description: 'Your current app — Privacy-first analytics',
|
description: 'Your current app — Privacy-first analytics',
|
||||||
icon: 'https://ciphera.net/pulse_icon_no_margins.png',
|
icon: 'https://ciphera.net/pulse_icon_no_margins.png',
|
||||||
href: 'https://pulse.ciphera.net',
|
href: 'https://pulse.ciphera.net',
|
||||||
isAvailable: false, // * Current app
|
isAvailable: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'drop',
|
id: 'drop',
|
||||||
@@ -47,22 +47,10 @@ const CIPHERA_APPS: CipheraApp[] = [
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
function MobileSidebarToggle() {
|
|
||||||
const { openMobile } = useSidebar()
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
onClick={openMobile}
|
|
||||||
className="lg:hidden p-2 text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-white transition-colors"
|
|
||||||
aria-label="Open navigation"
|
|
||||||
>
|
|
||||||
<MenuIcon className="w-5 h-5" />
|
|
||||||
</button>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function LayoutInner({ children }: { children: React.ReactNode }) {
|
function LayoutInner({ children }: { children: React.ReactNode }) {
|
||||||
const auth = useAuth()
|
const auth = useAuth()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const pathname = usePathname()
|
||||||
const isOnline = useOnlineStatus()
|
const isOnline = useOnlineStatus()
|
||||||
const { openSettings } = useSettingsModal()
|
const { openSettings } = useSettingsModal()
|
||||||
const [orgs, setOrgs] = useState<OrganizationMember[]>([])
|
const [orgs, setOrgs] = useState<OrganizationMember[]>([])
|
||||||
@@ -71,7 +59,6 @@ function LayoutInner({ children }: { children: React.ReactNode }) {
|
|||||||
return sessionStorage.getItem(ORG_SWITCH_KEY) === 'true'
|
return sessionStorage.getItem(ORG_SWITCH_KEY) === 'true'
|
||||||
})
|
})
|
||||||
|
|
||||||
// * Clear the switching flag once the page has settled after reload
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isSwitchingOrg) {
|
if (isSwitchingOrg) {
|
||||||
sessionStorage.removeItem(ORG_SWITCH_KEY)
|
sessionStorage.removeItem(ORG_SWITCH_KEY)
|
||||||
@@ -80,7 +67,6 @@ function LayoutInner({ children }: { children: React.ReactNode }) {
|
|||||||
}
|
}
|
||||||
}, [isSwitchingOrg])
|
}, [isSwitchingOrg])
|
||||||
|
|
||||||
// * Fetch organizations for the header organization switcher
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (auth.user) {
|
if (auth.user) {
|
||||||
getUserOrganizations()
|
getUserOrganizations()
|
||||||
@@ -90,7 +76,7 @@ function LayoutInner({ children }: { children: React.ReactNode }) {
|
|||||||
}, [auth.user])
|
}, [auth.user])
|
||||||
|
|
||||||
const handleSwitchOrganization = async (orgId: string | null) => {
|
const handleSwitchOrganization = async (orgId: string | null) => {
|
||||||
if (!orgId) return // Pulse doesn't support personal organization context
|
if (!orgId) return
|
||||||
try {
|
try {
|
||||||
const { access_token } = await switchContext(orgId)
|
const { access_token } = await switchContext(orgId)
|
||||||
await setSessionAction(access_token)
|
await setSessionAction(access_token)
|
||||||
@@ -101,69 +87,83 @@ function LayoutInner({ children }: { children: React.ReactNode }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleCreateOrganization = () => {
|
|
||||||
router.push('/onboarding')
|
|
||||||
}
|
|
||||||
|
|
||||||
const isAuthenticated = !!auth.user
|
const isAuthenticated = !!auth.user
|
||||||
const showOfflineBar = Boolean(auth.user && !isOnline)
|
const showOfflineBar = Boolean(auth.user && !isOnline)
|
||||||
|
// Site pages use DashboardShell with full sidebar — no Header needed
|
||||||
|
const isSitePage = pathname.startsWith('/sites/') && pathname !== '/sites/new'
|
||||||
|
|
||||||
if (isSwitchingOrg) {
|
if (isSwitchingOrg) {
|
||||||
return <LoadingOverlay logoSrc="/pulse_icon_no_margins.png" title="Pulse" portal={false} />
|
return <LoadingOverlay logoSrc="/pulse_icon_no_margins.png" title="Pulse" portal={false} />
|
||||||
}
|
}
|
||||||
|
|
||||||
const headerElement = (
|
// Authenticated site pages: full Dokploy-style layout (sidebar + utility bar)
|
||||||
|
// DashboardShell inside children handles everything
|
||||||
|
if (isAuthenticated && isSitePage) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{showOfflineBar && <OfflineBanner isOnline={isOnline} />}
|
||||||
|
{children}
|
||||||
|
<SettingsModalWrapper />
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Authenticated non-site pages (sites list, onboarding, etc.): static header
|
||||||
|
if (isAuthenticated) {
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col min-h-screen">
|
||||||
|
{showOfflineBar && <OfflineBanner isOnline={isOnline} />}
|
||||||
<Header
|
<Header
|
||||||
auth={auth}
|
auth={auth}
|
||||||
LinkComponent={Link}
|
LinkComponent={Link}
|
||||||
logoSrc="/pulse_icon_no_margins.png"
|
logoSrc="/pulse_icon_no_margins.png"
|
||||||
appName="Pulse"
|
appName="Pulse"
|
||||||
variant={isAuthenticated ? 'static' : 'floating'}
|
variant="static"
|
||||||
orgs={orgs}
|
orgs={orgs}
|
||||||
activeOrgId={auth.user?.org_id}
|
activeOrgId={auth.user?.org_id}
|
||||||
onSwitchOrganization={handleSwitchOrganization}
|
onSwitchOrganization={handleSwitchOrganization}
|
||||||
onCreateOrganization={handleCreateOrganization}
|
onCreateOrganization={() => router.push('/onboarding')}
|
||||||
allowPersonalOrganization={false}
|
allowPersonalOrganization={false}
|
||||||
showFaq={false}
|
showFaq={false}
|
||||||
showSecurity={false}
|
showSecurity={false}
|
||||||
showPricing={true}
|
showPricing={false}
|
||||||
topOffset={!isAuthenticated && showOfflineBar ? '2.5rem' : undefined}
|
rightSideActions={<NotificationCenter />}
|
||||||
rightSideActions={auth.user ? <NotificationCenter /> : null}
|
|
||||||
apps={CIPHERA_APPS}
|
apps={CIPHERA_APPS}
|
||||||
currentAppId="pulse"
|
currentAppId="pulse"
|
||||||
onOpenSettings={openSettings}
|
onOpenSettings={openSettings}
|
||||||
leftActions={isAuthenticated ? <MobileSidebarToggle /> : undefined}
|
/>
|
||||||
|
<main className="flex-1 pb-8">
|
||||||
|
{children}
|
||||||
|
</main>
|
||||||
|
<SettingsModalWrapper />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Public/marketing: floating header + footer
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col min-h-screen">
|
||||||
|
<Header
|
||||||
|
auth={auth}
|
||||||
|
LinkComponent={Link}
|
||||||
|
logoSrc="/pulse_icon_no_margins.png"
|
||||||
|
appName="Pulse"
|
||||||
|
variant="floating"
|
||||||
|
showFaq={false}
|
||||||
|
showSecurity={false}
|
||||||
|
showPricing={true}
|
||||||
|
topOffset={showOfflineBar ? '2.5rem' : undefined}
|
||||||
|
apps={CIPHERA_APPS}
|
||||||
|
currentAppId="pulse"
|
||||||
customNavItems={
|
customNavItems={
|
||||||
<>
|
|
||||||
{!auth.user && (
|
|
||||||
<Link
|
<Link
|
||||||
href="/features"
|
href="/features"
|
||||||
className="px-4 py-2 text-sm font-medium text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-white rounded-lg hover:bg-neutral-100/50 dark:hover:bg-neutral-800/50 transition-all duration-200"
|
className="px-4 py-2 text-sm font-medium text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-white rounded-lg hover:bg-neutral-100/50 dark:hover:bg-neutral-800/50 transition-all duration-200"
|
||||||
>
|
>
|
||||||
Features
|
Features
|
||||||
</Link>
|
</Link>
|
||||||
)}
|
|
||||||
</>
|
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
)
|
|
||||||
|
|
||||||
if (isAuthenticated) {
|
|
||||||
// Dashboard layout: header pinned, sidebar + content fill remaining viewport
|
|
||||||
return (
|
|
||||||
<div className="flex flex-col h-screen overflow-hidden">
|
|
||||||
{auth.user && <OfflineBanner isOnline={isOnline} />}
|
|
||||||
<div className="shrink-0">{headerElement}</div>
|
|
||||||
{children}
|
|
||||||
<SettingsModalWrapper />
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Public/marketing layout: floating header, scrollable page, footer
|
|
||||||
return (
|
|
||||||
<div className="flex flex-col min-h-screen">
|
|
||||||
{headerElement}
|
|
||||||
<main className="flex-1 pb-8 pt-24">
|
<main className="flex-1 pb-8 pt-24">
|
||||||
{children}
|
{children}
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import Sidebar from './Sidebar'
|
import Sidebar from './Sidebar'
|
||||||
|
import UtilityBar from './UtilityBar'
|
||||||
import { useSidebar } from '@/lib/sidebar-context'
|
import { useSidebar } from '@/lib/sidebar-context'
|
||||||
|
|
||||||
export default function DashboardShell({
|
export default function DashboardShell({
|
||||||
@@ -13,11 +14,14 @@ export default function DashboardShell({
|
|||||||
const { mobileOpen, closeMobile } = useSidebar()
|
const { mobileOpen, closeMobile } = useSidebar()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-1 overflow-hidden">
|
<div className="flex h-screen overflow-hidden">
|
||||||
<Sidebar siteId={siteId} mobileOpen={mobileOpen} onMobileClose={closeMobile} />
|
<Sidebar siteId={siteId} mobileOpen={mobileOpen} onMobileClose={closeMobile} />
|
||||||
<main className="flex-1 min-w-0 overflow-y-auto">
|
<div className="flex-1 flex flex-col min-w-0 overflow-hidden">
|
||||||
|
<UtilityBar />
|
||||||
|
<main className="flex-1 overflow-y-auto">
|
||||||
{children}
|
{children}
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -253,8 +253,23 @@ export default function Sidebar({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col h-full">
|
<div className="flex flex-col h-full">
|
||||||
|
{/* Logo */}
|
||||||
|
<Link
|
||||||
|
href="/"
|
||||||
|
className={`flex items-center gap-2.5 px-4 py-4 border-b border-neutral-200 dark:border-neutral-800 shrink-0 ${isCollapsed ? 'justify-center' : ''}`}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src="/pulse_icon_no_margins.png"
|
||||||
|
alt="Pulse"
|
||||||
|
className="w-8 h-8 shrink-0"
|
||||||
|
/>
|
||||||
|
{!isCollapsed && (
|
||||||
|
<span className="text-lg font-bold text-neutral-900 dark:text-white tracking-tight">Pulse</span>
|
||||||
|
)}
|
||||||
|
</Link>
|
||||||
|
|
||||||
{/* Site Picker */}
|
{/* Site Picker */}
|
||||||
<div className="pt-4 pb-2">
|
<div className="pt-3 pb-2">
|
||||||
<SitePicker sites={sites} currentSiteId={siteId} collapsed={isCollapsed} />
|
<SitePicker sites={sites} currentSiteId={siteId} collapsed={isCollapsed} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -319,7 +334,7 @@ export default function Sidebar({
|
|||||||
|
|
||||||
{/* Desktop sidebar */}
|
{/* Desktop sidebar */}
|
||||||
<aside
|
<aside
|
||||||
className={`hidden lg:flex flex-col shrink-0 border-r border-neutral-200 dark:border-neutral-800 bg-white dark:bg-neutral-900 transition-[width] duration-200 overflow-hidden ${
|
className={`hidden lg:flex flex-col shrink-0 border-r border-neutral-200 dark:border-neutral-800 bg-white dark:bg-neutral-900 transition-[width] duration-200 ${
|
||||||
collapsed ? 'w-[68px]' : 'w-60'
|
collapsed ? 'w-[68px]' : 'w-60'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
|
|||||||
102
components/dashboard/UtilityBar.tsx
Normal file
102
components/dashboard/UtilityBar.tsx
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
import { useRouter } from 'next/navigation'
|
||||||
|
import Link from 'next/link'
|
||||||
|
import { ThemeToggle, AppLauncher, UserMenu, type CipheraApp, MenuIcon } from '@ciphera-net/ui'
|
||||||
|
import { useAuth } from '@/lib/auth/context'
|
||||||
|
import { useSettingsModal } from '@/lib/settings-modal-context'
|
||||||
|
import { getUserOrganizations, switchContext, type OrganizationMember } from '@/lib/api/organization'
|
||||||
|
import { setSessionAction } from '@/app/actions/auth'
|
||||||
|
import { logger } from '@/lib/utils/logger'
|
||||||
|
import { useSidebar } from '@/lib/sidebar-context'
|
||||||
|
import NotificationCenter from '@/components/notifications/NotificationCenter'
|
||||||
|
|
||||||
|
const CIPHERA_APPS: CipheraApp[] = [
|
||||||
|
{
|
||||||
|
id: 'pulse',
|
||||||
|
name: 'Pulse',
|
||||||
|
description: 'Your current app — Privacy-first analytics',
|
||||||
|
icon: 'https://ciphera.net/pulse_icon_no_margins.png',
|
||||||
|
href: 'https://pulse.ciphera.net',
|
||||||
|
isAvailable: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'drop',
|
||||||
|
name: 'Drop',
|
||||||
|
description: 'Secure file sharing',
|
||||||
|
icon: 'https://ciphera.net/drop_icon_no_margins.png',
|
||||||
|
href: 'https://drop.ciphera.net',
|
||||||
|
isAvailable: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'auth',
|
||||||
|
name: 'Auth',
|
||||||
|
description: 'Your Ciphera account settings',
|
||||||
|
icon: 'https://ciphera.net/auth_icon_no_margins.png',
|
||||||
|
href: 'https://auth.ciphera.net',
|
||||||
|
isAvailable: true,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
export default function UtilityBar() {
|
||||||
|
const auth = useAuth()
|
||||||
|
const router = useRouter()
|
||||||
|
const { openSettings } = useSettingsModal()
|
||||||
|
const { openMobile } = useSidebar()
|
||||||
|
const [orgs, setOrgs] = useState<OrganizationMember[]>([])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (auth.user) {
|
||||||
|
getUserOrganizations()
|
||||||
|
.then((organizations) => setOrgs(Array.isArray(organizations) ? organizations : []))
|
||||||
|
.catch(err => logger.error('Failed to fetch orgs for utility bar', err))
|
||||||
|
}
|
||||||
|
}, [auth.user])
|
||||||
|
|
||||||
|
const handleSwitchOrganization = async (orgId: string | null) => {
|
||||||
|
if (!orgId) return
|
||||||
|
try {
|
||||||
|
const { access_token } = await switchContext(orgId)
|
||||||
|
await setSessionAction(access_token)
|
||||||
|
sessionStorage.setItem('pulse_switching_org', 'true')
|
||||||
|
window.location.reload()
|
||||||
|
} catch (err) {
|
||||||
|
logger.error('Failed to switch organization', err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="shrink-0 flex items-center justify-between border-b border-neutral-200 dark:border-neutral-800 bg-white dark:bg-neutral-900 px-4 sm:px-6 py-2">
|
||||||
|
{/* Left: mobile sidebar toggle */}
|
||||||
|
<button
|
||||||
|
onClick={openMobile}
|
||||||
|
className="lg:hidden p-2 -ml-2 text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-white transition-colors"
|
||||||
|
aria-label="Open navigation"
|
||||||
|
>
|
||||||
|
<MenuIcon className="w-5 h-5" />
|
||||||
|
</button>
|
||||||
|
<div className="hidden lg:block" />
|
||||||
|
|
||||||
|
{/* Right: actions */}
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
<ThemeToggle />
|
||||||
|
<AppLauncher
|
||||||
|
apps={CIPHERA_APPS}
|
||||||
|
currentAppId="pulse"
|
||||||
|
/>
|
||||||
|
<NotificationCenter />
|
||||||
|
<UserMenu
|
||||||
|
auth={auth}
|
||||||
|
LinkComponent={Link}
|
||||||
|
orgs={orgs}
|
||||||
|
activeOrgId={auth.user?.org_id}
|
||||||
|
onSwitchOrganization={handleSwitchOrganization}
|
||||||
|
onCreateOrganization={() => router.push('/onboarding')}
|
||||||
|
allowPersonalOrganization={false}
|
||||||
|
onOpenSettings={openSettings}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user